@teselagen/ove 0.0.13 → 0.0.15
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/index.umd.js +164751 -135808
- package/package.json +78 -2
- package/src/AlignmentTool/index.js +16 -0
- package/src/AlignmentView/AlignmentVisibilityTool.js +105 -0
- package/src/AlignmentView/EditTrackNameDialog.js +34 -0
- package/src/AlignmentView/HorizontalPanelDragHandle.js +35 -0
- package/src/AlignmentView/Minimap.js +520 -0
- package/src/AlignmentView/Mismatches.js +134 -0
- package/src/AlignmentView/PairwiseAlignmentView.js +68 -0
- package/src/AlignmentView/PerformantSelectionLayer.js +32 -0
- package/src/AlignmentView/coerceInitialValue.js +7 -0
- package/src/AlignmentView/getGapMap.js +12 -0
- package/src/AlignmentView/getGaps.js +27 -0
- package/src/AlignmentView/getPairwiseOverviewLinearViewOptions.js +38 -0
- package/src/AlignmentView/getTrackFromEvent.js +25 -0
- package/src/AlignmentView/index.js +2058 -0
- package/src/AlignmentView/isTargetWithinEl.js +6 -0
- package/src/AlignmentView/style.css +100 -0
- package/src/AlignmentView/updateTrackHelper.js +58 -0
- package/src/AutoAnnotate.js +500 -0
- package/src/AutoAnnotateBpMatchingDialog.js +208 -0
- package/src/CircularView/Axis.js +40 -0
- package/src/CircularView/AxisNumbers.js +35 -0
- package/src/CircularView/Caret.js +63 -0
- package/src/CircularView/CircularDnaSequence.js +73 -0
- package/src/CircularView/CircularZoomMinimap.js +16 -0
- package/src/CircularView/Cutsite.js +18 -0
- package/src/CircularView/Cutsites.js +113 -0
- package/src/CircularView/DeletionLayer.js +28 -0
- package/src/CircularView/Feature.js +83 -0
- package/src/CircularView/Labels/index.js +536 -0
- package/src/CircularView/Labels/relaxLabelAngles.js +157 -0
- package/src/CircularView/Labels/relaxLabels_DEPRECATED.js +105 -0
- package/src/CircularView/Labels/style.css +55 -0
- package/src/CircularView/Orf.js +25 -0
- package/src/CircularView/Part.js +34 -0
- package/src/CircularView/PositionAnnotationOnCircle.js +26 -0
- package/src/CircularView/Primer.js +41 -0
- package/src/CircularView/RotateCircularViewSlider.js +82 -0
- package/src/CircularView/SelectionLayer.js +132 -0
- package/src/CircularView/VeTopRightContainer.js +12 -0
- package/src/CircularView/ZoomCircularViewSlider.js +62 -0
- package/src/CircularView/drawAnnotations.js +433 -0
- package/src/CircularView/drawDirectedPiePiece.js +142 -0
- package/src/CircularView/getAngleForPositionMidpoint.js +3 -0
- package/src/CircularView/getInternalLabel.js +40 -0
- package/src/CircularView/getRangeAnglesSpecial.js +12 -0
- package/src/CircularView/getYOffset.js +15 -0
- package/src/CircularView/index.d.ts +20 -0
- package/src/CircularView/index.js +930 -0
- package/src/CircularView/normalizeAngle.js +3 -0
- package/src/CircularView/normalizeAngleRange.js +9 -0
- package/src/CircularView/positionCutsites.js +6 -0
- package/src/CircularView/shouldFlipText.js +4 -0
- package/src/CircularView/style.css +47 -0
- package/src/CircularView/utils/polarToSpecialCartesian.js +7 -0
- package/src/CreateAnnotationsPage.js +96 -0
- package/src/CreateCustomEnzyme/index.js +337 -0
- package/src/CreateCustomEnzyme/style.css +100 -0
- package/src/CutsiteFilter/AdditionalCutsiteInfoDialog.js +599 -0
- package/src/CutsiteFilter/index.js +408 -0
- package/src/CutsiteFilter/style.css +23 -0
- package/src/CutsiteFilter/withRestrictionEnzymes.js +15 -0
- package/src/DigestTool/AddLaddersDialog.js +82 -0
- package/src/DigestTool/DigestTool.js +223 -0
- package/src/DigestTool/Ladder.css +20 -0
- package/src/DigestTool/Ladder.js +303 -0
- package/src/DigestTool/createFragmentLines.js +120 -0
- package/src/DigestTool/ladderDefaults.js +26 -0
- package/src/DigestTool/ruler.css +89 -0
- package/src/Editor/CommandHotkeyHandler.js +44 -0
- package/src/Editor/DropHandler.css +21 -0
- package/src/Editor/DropHandler.js +64 -0
- package/src/Editor/FillWindow.js +46 -0
- package/src/Editor/darkmode.css +98 -0
- package/src/Editor/index.js +1005 -0
- package/src/Editor/style.css +235 -0
- package/src/Editor/userDefinedHandlersAndOpts.js +56 -0
- package/src/EnzymeViewer/index.js +81 -0
- package/src/EnzymeViewer/style.css +6 -0
- package/src/FindBar/index.js +411 -0
- package/src/FindBar/style.css +46 -0
- package/src/GlobalDialog.js +66 -0
- package/src/GlobalDialogUtils.js +85 -0
- package/src/LinearView/SequenceName.js +15 -0
- package/src/LinearView/ZoomLinearView.js +47 -0
- package/src/LinearView/index.js +374 -0
- package/src/LinearView/style.css +12 -0
- package/src/ManageEnzymes/index.js +326 -0
- package/src/ManageEnzymes/style.css +100 -0
- package/src/MenuBar/defaultConfig.js +149 -0
- package/src/MenuBar/index.js +98 -0
- package/src/MenuBar/viewSubmenu.js +479 -0
- package/src/PCRTool/PCRTool.js +173 -0
- package/src/Reflex/Browser.js +107 -0
- package/src/Reflex/ReflexContainer.js +802 -0
- package/src/Reflex/ReflexElement.js +160 -0
- package/src/Reflex/ReflexEvents.js +77 -0
- package/src/Reflex/ReflexSplitter.js +205 -0
- package/src/Reflex/index.js +5 -0
- package/src/Reflex/reflex-styles.css +128 -0
- package/src/Reflex/reflex-styles.css.map +9 -0
- package/src/RowItem/AnnotationContainerHolder.js +20 -0
- package/src/RowItem/AnnotationPositioner.js +27 -0
- package/src/RowItem/Axis.js +149 -0
- package/src/RowItem/Caret/index.js +64 -0
- package/src/RowItem/Caret/style.css +8 -0
- package/src/RowItem/Chromatograms/Chromatogram.js +289 -0
- package/src/RowItem/CutsiteSelectionLayers.js +47 -0
- package/src/RowItem/Cutsites.js +271 -0
- package/src/RowItem/DeletionLayers/index.js +113 -0
- package/src/RowItem/DeletionLayers/style.css +5 -0
- package/src/RowItem/Labels.js +327 -0
- package/src/RowItem/Orf.js +109 -0
- package/src/RowItem/Orfs.js +35 -0
- package/src/RowItem/ReplacementLayers/style.css +5 -0
- package/src/RowItem/SelectionLayer/index.js +184 -0
- package/src/RowItem/SelectionLayer/style.css +21 -0
- package/src/RowItem/Sequence.js +269 -0
- package/src/RowItem/StackedAnnotations/PointedAnnotation.js +347 -0
- package/src/RowItem/StackedAnnotations/getStructuredBases.js +97 -0
- package/src/RowItem/StackedAnnotations/index.js +182 -0
- package/src/RowItem/StackedAnnotations/primerBases.js +218 -0
- package/src/RowItem/StackedAnnotations/style.css +14 -0
- package/src/RowItem/Translations/AASliver.js +190 -0
- package/src/RowItem/Translations/Translation.js +162 -0
- package/src/RowItem/Translations/index.js +54 -0
- package/src/RowItem/Translations/style.css +3 -0
- package/src/RowItem/constants.js +3 -0
- package/src/RowItem/getCutsiteLabelHeights.js +56 -0
- package/src/RowItem/getXStartAndWidthFromNonCircularRange.js +12 -0
- package/src/RowItem/getXStartAndWidthOfRangeWrtRow.js +27 -0
- package/src/RowItem/getXStartAndWidthOfRowAnnotation.js +19 -0
- package/src/RowItem/index.js +647 -0
- package/src/RowItem/partOverhangs.js +6 -0
- package/src/RowItem/style.css +103 -0
- package/src/RowItem/utils.js +32 -0
- package/src/RowView/estimateRowHeight.js +184 -0
- package/src/RowView/index.d.ts +10 -0
- package/src/RowView/index.js +554 -0
- package/src/RowView/style.css +12 -0
- package/src/SimpleCircularOrLinearView.js +379 -0
- package/src/SimpleOligoPreview.js +39 -0
- package/src/StatusBar/MeltingTemp.js +81 -0
- package/src/StatusBar/index.js +275 -0
- package/src/StatusBar/style.css +38 -0
- package/src/ToolBar/ToolbarItem.js +194 -0
- package/src/ToolBar/alignmentTool.js +503 -0
- package/src/ToolBar/array_move.js +10 -0
- package/src/ToolBar/cutsiteTool.js +88 -0
- package/src/ToolBar/downloadTool.js +38 -0
- package/src/ToolBar/editTool.js +26 -0
- package/src/ToolBar/featureTool.js +34 -0
- package/src/ToolBar/findTool.js +2 -0
- package/src/ToolBar/importTool.js +27 -0
- package/src/ToolBar/index.js +231 -0
- package/src/ToolBar/inlineFindTool.js +38 -0
- package/src/ToolBar/oligoTool.js +30 -0
- package/src/ToolBar/orfTool.js +141 -0
- package/src/ToolBar/partTool.js +47 -0
- package/src/ToolBar/printTool.js +31 -0
- package/src/ToolBar/redoTool.js +30 -0
- package/src/ToolBar/saveTool.js +48 -0
- package/src/ToolBar/style.css +138 -0
- package/src/ToolBar/undoTool.js +30 -0
- package/src/ToolBar/veToolbarIcons/find.png +0 -0
- package/src/ToolBar/veToolbarIcons/fullscreen.png +0 -0
- package/src/ToolBar/veToolbarIcons/linear.png +0 -0
- package/src/ToolBar/veToolbarIcons/pie.png +0 -0
- package/src/ToolBar/veToolbarIcons/print.png +0 -0
- package/src/ToolBar/veToolbarIcons/save.png +0 -0
- package/src/ToolBar/veToolbarIcons/show_cut_sites.png +0 -0
- package/src/ToolBar/veToolbarIcons/show_features.png +0 -0
- package/src/ToolBar/veToolbarIcons/show_orfs.png +0 -0
- package/src/ToolBar/veToolbarIcons/show_primers.png +0 -0
- package/src/ToolBar/veToolbarIcons/toggle_views.svg +1 -0
- package/src/ToolBar/versionHistoryTool.js +20 -0
- package/src/ToolBar/visibilityTool.js +39 -0
- package/src/VersionHistoryView/index.js +215 -0
- package/src/addAlignment.js +6 -0
- package/src/commands/getOveHotkeyDefs.js +12 -0
- package/src/commands/index.js +1585 -0
- package/src/constants/constants.js +2 -0
- package/src/constants/dnaToColor.js +17 -0
- package/src/constants/draggableClassnames.js +5 -0
- package/src/constants/findToolConstants.js +1 -0
- package/src/constants/orfFrameToColorMap.js +10 -0
- package/src/constants/rowviewContants.js +3 -0
- package/src/constants/specialCutsiteFilterOptions.js +22 -0
- package/src/constants.js +1 -0
- package/src/createVectorEditor/index.js +138 -0
- package/src/createVectorEditor/makeStore.js +34 -0
- package/src/fileUtils.js +103 -0
- package/src/helperComponents/AddOrEditAnnotationDialog/index.js +711 -0
- package/src/helperComponents/AddOrEditAnnotationDialog/style.css +11 -0
- package/src/helperComponents/AddOrEditFeatureDialog/index.js +58 -0
- package/src/helperComponents/AddOrEditPartDialog/index.js +101 -0
- package/src/helperComponents/AddOrEditPrimerDialog/EditCaretPosition.js +234 -0
- package/src/helperComponents/AddOrEditPrimerDialog/index.js +329 -0
- package/src/helperComponents/AddOrEditPrimerDialog/style.css +41 -0
- package/src/helperComponents/EnzymesDialog/index.js +904 -0
- package/src/helperComponents/EnzymesDialog/style.css +21 -0
- package/src/helperComponents/GoToDialog.js +21 -0
- package/src/helperComponents/MergeFeaturesDialog/index.js +253 -0
- package/src/helperComponents/MergeFeaturesDialog/style.css +3 -0
- package/src/helperComponents/MultipleSeqsDetectedOnImportDialog.js +74 -0
- package/src/helperComponents/PinchHelper/PinchHelper.js +24 -0
- package/src/helperComponents/PrintDialog/index.js +396 -0
- package/src/helperComponents/PrintDialog/style.css +4 -0
- package/src/helperComponents/PropertiesDialog/ColorPicker.js +30 -0
- package/src/helperComponents/PropertiesDialog/CutsiteProperties.js +185 -0
- package/src/helperComponents/PropertiesDialog/FeatureProperties.js +6 -0
- package/src/helperComponents/PropertiesDialog/GenbankView.js +74 -0
- package/src/helperComponents/PropertiesDialog/GeneralProperties.js +140 -0
- package/src/helperComponents/PropertiesDialog/GenericAnnotationProperties.js +406 -0
- package/src/helperComponents/PropertiesDialog/OrfProperties.js +117 -0
- package/src/helperComponents/PropertiesDialog/PartProperties.js +9 -0
- package/src/helperComponents/PropertiesDialog/PrimerProperties.js +19 -0
- package/src/helperComponents/PropertiesDialog/SingleEnzymeCutsiteInfo.js +131 -0
- package/src/helperComponents/PropertiesDialog/TranslationProperties.js +149 -0
- package/src/helperComponents/PropertiesDialog/index.js +166 -0
- package/src/helperComponents/PropertiesDialog/style.css +68 -0
- package/src/helperComponents/PropertiesDialog/typeField.js +24 -0
- package/src/helperComponents/PropertiesDialog/utils.js +37 -0
- package/src/helperComponents/RemoveDuplicates/index.js +194 -0
- package/src/helperComponents/RenameSequenceDialog.js +7 -0
- package/src/helperComponents/SelectDialog.js +150 -0
- package/src/helperComponents/UncontrolledSliderWithPlusMinusBtns.css +5 -0
- package/src/helperComponents/UncontrolledSliderWithPlusMinusBtns.js +134 -0
- package/src/helperComponents/VeWarning/index.js +22 -0
- package/src/helperComponents/VeWarning/style.css +10 -0
- package/src/helperComponents/createSimpleDialog.js +89 -0
- package/src/helperComponents/partTagSearch.js +72 -0
- package/src/helperComponents/simpleDialog.css +13 -0
- package/src/helperComponents/withHover.js +90 -0
- package/src/index.js +60 -0
- package/src/redux/alignments.js +373 -0
- package/src/redux/annotationLabelVisibility.js +53 -0
- package/src/redux/annotationVisibility.js +196 -0
- package/src/redux/annotationsToSupport.js +104 -0
- package/src/redux/caretPosition.js +27 -0
- package/src/redux/charWidth.js +22 -0
- package/src/redux/copyOptions.js +34 -0
- package/src/redux/createYourOwnEnzyme.js +39 -0
- package/src/redux/deletionLayers.js +36 -0
- package/src/redux/digestTool.js +34 -0
- package/src/redux/featureLengthsToHide.js +27 -0
- package/src/redux/findTool.js +79 -0
- package/src/redux/frameTranslations.js +52 -0
- package/src/redux/hoveredAnnotation.js +24 -0
- package/src/redux/index.js +196 -0
- package/src/redux/labelLineIntensity.js +25 -0
- package/src/redux/labelSize.js +23 -0
- package/src/redux/lastSavedId.js +20 -0
- package/src/redux/middleware.js +112 -0
- package/src/redux/minimumOrfSize.js +24 -0
- package/src/redux/modalActions.js +3 -0
- package/src/redux/panelsShown.js +273 -0
- package/src/redux/partLengthsToHide.js +23 -0
- package/src/redux/primerLengthsToHide.js +27 -0
- package/src/redux/propertiesTool.js +40 -0
- package/src/redux/readOnly.js +28 -0
- package/src/redux/replacementLayers.js +36 -0
- package/src/redux/restrictionEnzymes.js +52 -0
- package/src/redux/selectedAnnotations.js +89 -0
- package/src/redux/selectedPartTags.js +21 -0
- package/src/redux/selectionLayer.js +46 -0
- package/src/redux/sequenceData/circular.js +19 -0
- package/src/redux/sequenceData/description.js +21 -0
- package/src/redux/sequenceData/features.js +19 -0
- package/src/redux/sequenceData/index.js +81 -0
- package/src/redux/sequenceData/lineageLines.js +11 -0
- package/src/redux/sequenceData/materiallyAvailable.js +19 -0
- package/src/redux/sequenceData/name.js +19 -0
- package/src/redux/sequenceData/parts.js +19 -0
- package/src/redux/sequenceData/primers.js +19 -0
- package/src/redux/sequenceData/sequence.js +12 -0
- package/src/redux/sequenceData/sharedActionCreators.js +0 -0
- package/src/redux/sequenceData/translations.js +20 -0
- package/src/redux/sequenceData/upsertDeleteActionGenerator.js +31 -0
- package/src/redux/sequenceDataHistory.js +43 -0
- package/src/redux/showGCContent.js +23 -0
- package/src/redux/toolBar.js +25 -0
- package/src/redux/uppercaseSequenceMapFont.js +25 -0
- package/src/redux/useAdditionalOrfStartCodons.js +24 -0
- package/src/redux/utils/addDashesForMatchStartAndEndForTracks/index.js +71 -0
- package/src/redux/utils/addMetaToActionCreators.js +12 -0
- package/src/redux/utils/createMergedDefaultStateReducer.js +30 -0
- package/src/redux/utils/createMetaAction.js +12 -0
- package/src/redux/versionHistory.js +27 -0
- package/src/selectors/annotationLabelVisibility.js +2 -0
- package/src/selectors/annotationSearchSelector.js +24 -0
- package/src/selectors/cdsFeaturesSelector.js +9 -0
- package/src/selectors/circularSelector.js +4 -0
- package/src/selectors/cutsiteLabelColorSelector.js +6 -0
- package/src/selectors/cutsitesByRangeSelector.js +5 -0
- package/src/selectors/cutsitesSelector.js +61 -0
- package/src/selectors/editorSelector.js +2 -0
- package/src/selectors/featuresSelector.js +8 -0
- package/src/selectors/filteredCutsitesSelector.js +137 -0
- package/src/selectors/filteredFeaturesSelector.js +32 -0
- package/src/selectors/filteredPartsSelector.js +57 -0
- package/src/selectors/filteredPrimersSelector.js +27 -0
- package/src/selectors/filteredRestrictionEnzymesSelector.js +1 -0
- package/src/selectors/getAdditionalEnzymesSelector.js +46 -0
- package/src/selectors/index.js +41 -0
- package/src/selectors/isEnzymeFilterAndSelector.js +1 -0
- package/src/selectors/minimumOrfSizeSelector.js +2 -0
- package/src/selectors/orfsSelector.js +15 -0
- package/src/selectors/partsSelector.js +8 -0
- package/src/selectors/primersSelector.js +8 -0
- package/src/selectors/restrictionEnzymesSelector.js +34 -0
- package/src/selectors/searchLayersSelector.js +71 -0
- package/src/selectors/selectedAnnotationsSelector.js +1 -0
- package/src/selectors/selectedCutsitesSelector.js +21 -0
- package/src/selectors/sequenceDataSelector.js +2 -0
- package/src/selectors/sequenceLengthSelector.js +5 -0
- package/src/selectors/sequenceSelector.js +4 -0
- package/src/selectors/tagsToBoldSelector.js +2 -0
- package/src/selectors/translationSearchMatchesSelector.js +14 -0
- package/src/selectors/translationsRawSelector.js +8 -0
- package/src/selectors/translationsSelector.js +137 -0
- package/src/style.css +82 -0
- package/src/updateEditor.js +198 -0
- package/src/utils/PassThrough.js +3 -0
- package/src/utils/addWrappedAddons.js +20 -0
- package/src/utils/annotationTypes.js +37 -0
- package/src/utils/arrayUtils.js +19 -0
- package/src/utils/calculateTickMarkPositionsForGivenRange.js +47 -0
- package/src/utils/cleanSequenceData_DEPRECATED/arrayToObjWithIds.js +17 -0
- package/src/utils/combineReducersDontIgnoreKeys.js +12 -0
- package/src/utils/commandUtils.js +18 -0
- package/src/utils/editorUtils.js +223 -0
- package/src/utils/getAnnotationClassnames.js +12 -0
- package/src/utils/getAnnotationNameAndStartStopString.js +61 -0
- package/src/utils/getVisibleStartEnd.js +7 -0
- package/src/utils/massageTickSpacing.js +19 -0
- package/src/utils/onlyUpdateForKeysDeep.js +31 -0
- package/src/utils/prepareRowData.js +64 -0
- package/src/utils/proteinUtils.js +3 -0
- package/src/utils/pureNoFunc.js +18 -0
- package/src/utils/selectionLayer.js +25 -0
- package/src/utils/shouldRerender.js +27 -0
- package/src/utils/showFileDialog.js +26 -0
- package/src/utils/updateLabelsForInViewFeatures.js +55 -0
- package/src/utils/updateLabelsForInViewFeaturesCircView.js +41 -0
- package/src/utils/useAAColorType.js +8 -0
- package/src/utils/useAnnotationLimits.js +42 -0
- package/src/utils/useChromatogramPrefs.js +31 -0
- package/src/utils/useLadders.js +6 -0
- package/src/utils/useMeltingTemp.js +7 -0
- package/src/utils/useTmType.js +10 -0
- package/src/withEditorInteractions/Keyboard.js +86 -0
- package/src/withEditorInteractions/clickAndDragUtils.js +576 -0
- package/src/withEditorInteractions/createSequenceInputPopup.js +296 -0
- package/src/withEditorInteractions/createSequenceInputPopupStyle.css +85 -0
- package/src/withEditorInteractions/getBpsPerRow.js +19 -0
- package/src/withEditorInteractions/index.js +1252 -0
- package/src/withEditorInteractions/isElementInViewport.js +29 -0
- package/src/withEditorInteractions/moveCaret.js +58 -0
- package/src/withEditorProps/index.js +1010 -0
- package/index.mjs +0 -193201
| @@ -0,0 +1,802 @@ | |
| 1 | 
            +
            ///////////////////////////////////////////////////////////
         | 
| 2 | 
            +
            // ReflexContainer
         | 
| 3 | 
            +
            // By Philippe Leefsma
         | 
| 4 | 
            +
            // December 2016
         | 
| 5 | 
            +
            //
         | 
| 6 | 
            +
            ///////////////////////////////////////////////////////////
         | 
| 7 | 
            +
            import ReflexSplitter from "./ReflexSplitter";
         | 
| 8 | 
            +
            import ReflexEvents from "./ReflexEvents";
         | 
| 9 | 
            +
            import PropTypes from "prop-types";
         | 
| 10 | 
            +
            import ReactDOM from "react-dom";
         | 
| 11 | 
            +
            import React from "react";
         | 
| 12 | 
            +
            import { cloneDeep, round } from "lodash";
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            class ReflexContainer extends React.Component {
         | 
| 15 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 16 | 
            +
              //
         | 
| 17 | 
            +
              //
         | 
| 18 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 19 | 
            +
              constructor(props) {
         | 
| 20 | 
            +
                super(props);
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                this.state = {
         | 
| 23 | 
            +
                  flexData: []
         | 
| 24 | 
            +
                };
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                this.events = new ReflexEvents();
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                this.onSplitterStartResize = this.onSplitterStartResize.bind(this);
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                this.onSplitterStopResize = this.onSplitterStopResize.bind(this);
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                this.onSplitterResize = this.onSplitterResize.bind(this);
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                this.onElementSize = this.onElementSize.bind(this);
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                this.children = [];
         | 
| 37 | 
            +
              }
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 40 | 
            +
              //
         | 
| 41 | 
            +
              //
         | 
| 42 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 43 | 
            +
              setPartialState(partialState) {
         | 
| 44 | 
            +
                return new Promise(resolve => {
         | 
| 45 | 
            +
                  this.setState(Object.assign({}, this.state, partialState), () => {
         | 
| 46 | 
            +
                    resolve();
         | 
| 47 | 
            +
                  });
         | 
| 48 | 
            +
                });
         | 
| 49 | 
            +
              }
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 52 | 
            +
              //
         | 
| 53 | 
            +
              //
         | 
| 54 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 55 | 
            +
              componentDidMount() {
         | 
| 56 | 
            +
                const flexData = this.computeFlexData();
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                this.setPartialState({
         | 
| 59 | 
            +
                  flexData
         | 
| 60 | 
            +
                });
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                this.events.on("splitter.startResize", this.onSplitterStartResize);
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                this.events.on("splitter.stopResize", this.onSplitterStopResize);
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                this.events.on("splitter.resize", this.onSplitterResize);
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                this.events.on("element.size", this.onElementSize);
         | 
| 69 | 
            +
              }
         | 
| 70 | 
            +
             | 
| 71 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 72 | 
            +
              //
         | 
| 73 | 
            +
              //
         | 
| 74 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 75 | 
            +
              componentWillUnmount() {
         | 
| 76 | 
            +
                this.events.off();
         | 
| 77 | 
            +
              }
         | 
| 78 | 
            +
             | 
| 79 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 80 | 
            +
              //
         | 
| 81 | 
            +
              //
         | 
| 82 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 83 | 
            +
              getValidChildren(props = this.props) {
         | 
| 84 | 
            +
                return this.toArray(props.children).filter(child => {
         | 
| 85 | 
            +
                  return !!child;
         | 
| 86 | 
            +
                });
         | 
| 87 | 
            +
              }
         | 
| 88 | 
            +
             | 
| 89 | 
            +
              /////////////////////////////////////////////////////////////
         | 
| 90 | 
            +
              //
         | 
| 91 | 
            +
              //
         | 
| 92 | 
            +
              /////////////////////////////////////////////////////////////
         | 
| 93 | 
            +
              UNSAFE_componentWillReceiveProps(props) {
         | 
| 94 | 
            +
                const children = this.getValidChildren(props);
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                if (
         | 
| 97 | 
            +
                  children.length !== this.state.flexData.length ||
         | 
| 98 | 
            +
                  this.flexHasChanged(props)
         | 
| 99 | 
            +
                ) {
         | 
| 100 | 
            +
                  const flexData = this.computeFlexData(children);
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  this.setPartialState({
         | 
| 103 | 
            +
                    flexData
         | 
| 104 | 
            +
                  });
         | 
| 105 | 
            +
                }
         | 
| 106 | 
            +
              }
         | 
| 107 | 
            +
             | 
| 108 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 109 | 
            +
              // Check if flex has changed: this allows updating the
         | 
| 110 | 
            +
              // component when different flex is passed as property
         | 
| 111 | 
            +
              // to one or several children
         | 
| 112 | 
            +
              //
         | 
| 113 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 114 | 
            +
              flexHasChanged(props) {
         | 
| 115 | 
            +
                const nextChildrenFlex = this.getValidChildren(props).map(child => {
         | 
| 116 | 
            +
                  return child.props.flex || 0;
         | 
| 117 | 
            +
                });
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                const childrenFlex = this.getValidChildren().map(child => {
         | 
| 120 | 
            +
                  return child.props.flex || 0;
         | 
| 121 | 
            +
                });
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                return !childrenFlex.every((flex, idx) => {
         | 
| 124 | 
            +
                  return flex === nextChildrenFlex[idx];
         | 
| 125 | 
            +
                });
         | 
| 126 | 
            +
              }
         | 
| 127 | 
            +
             | 
| 128 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 129 | 
            +
              // Returns size of a ReflexElement
         | 
| 130 | 
            +
              //
         | 
| 131 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 132 | 
            +
              getSize(element) {
         | 
| 133 | 
            +
                const ref = element.ref ? this.refs[element.ref] : element;
         | 
| 134 | 
            +
             | 
| 135 | 
            +
                const domElement = ReactDOM.findDOMNode(ref);
         | 
| 136 | 
            +
             | 
| 137 | 
            +
                switch (this.props.orientation) {
         | 
| 138 | 
            +
                  case "horizontal":
         | 
| 139 | 
            +
                    return domElement.offsetHeight;
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                  case "vertical":
         | 
| 142 | 
            +
                  default:
         | 
| 143 | 
            +
                    return domElement.offsetWidth;
         | 
| 144 | 
            +
                }
         | 
| 145 | 
            +
              }
         | 
| 146 | 
            +
             | 
| 147 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 148 | 
            +
              // Computes offset from pointer position
         | 
| 149 | 
            +
              //
         | 
| 150 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 151 | 
            +
              getOffset(event) {
         | 
| 152 | 
            +
                const pos = event.changedTouches ? event.changedTouches[0] : event;
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                switch (this.props.orientation) {
         | 
| 155 | 
            +
                  case "horizontal":
         | 
| 156 | 
            +
                    return pos.pageY - this.previousPos;
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                  case "vertical":
         | 
| 159 | 
            +
                  default:
         | 
| 160 | 
            +
                    return pos.pageX - this.previousPos;
         | 
| 161 | 
            +
                }
         | 
| 162 | 
            +
              }
         | 
| 163 | 
            +
             | 
| 164 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 165 | 
            +
              // Handles splitter startResize event
         | 
| 166 | 
            +
              //
         | 
| 167 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 168 | 
            +
              onSplitterStartResize(data) {
         | 
| 169 | 
            +
                const pos = data.event.changedTouches
         | 
| 170 | 
            +
                  ? data.event.changedTouches[0]
         | 
| 171 | 
            +
                  : data.event;
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                switch (this.props.orientation) {
         | 
| 174 | 
            +
                  case "horizontal":
         | 
| 175 | 
            +
                    document.body.style.cursor = "row-resize";
         | 
| 176 | 
            +
                    this.previousPos = pos.pageY;
         | 
| 177 | 
            +
                    break;
         | 
| 178 | 
            +
             | 
| 179 | 
            +
                  case "vertical":
         | 
| 180 | 
            +
                  default:
         | 
| 181 | 
            +
                    document.body.style.cursor = "col-resize";
         | 
| 182 | 
            +
                    this.previousPos = pos.pageX;
         | 
| 183 | 
            +
                    break;
         | 
| 184 | 
            +
                }
         | 
| 185 | 
            +
             | 
| 186 | 
            +
                const idx = data.splitter.props.index;
         | 
| 187 | 
            +
             | 
| 188 | 
            +
                this.elements = [this.children[idx - 1], this.children[idx + 1]];
         | 
| 189 | 
            +
             | 
| 190 | 
            +
                this.emitElementsEvent(this.elements, "onStartResize");
         | 
| 191 | 
            +
              }
         | 
| 192 | 
            +
             | 
| 193 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 194 | 
            +
              // Handles splitter resize event
         | 
| 195 | 
            +
              //
         | 
| 196 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 197 | 
            +
              onSplitterResize(data) {
         | 
| 198 | 
            +
                const idx = data.splitter.props.index;
         | 
| 199 | 
            +
             | 
| 200 | 
            +
                const offset = this.getOffset(data.event);
         | 
| 201 | 
            +
             | 
| 202 | 
            +
                let availableOffset = this.computeAvailableOffset(idx, offset);
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                if (this.hasCollapsed) {
         | 
| 205 | 
            +
                  if (this.isNegativeWhenCollapsing ? offset > 0 : offset < 0) {
         | 
| 206 | 
            +
                    this.hasCollapsed = false;
         | 
| 207 | 
            +
                    this.setPartialState(this.stateBeforeCollapse).then(() => {
         | 
| 208 | 
            +
                      this.emitElementsEvent(this.elements, "onResize");
         | 
| 209 | 
            +
                    });
         | 
| 210 | 
            +
                  }
         | 
| 211 | 
            +
                  return;
         | 
| 212 | 
            +
                }
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                if (!availableOffset) {
         | 
| 215 | 
            +
                  this.closeThreshold = 40;
         | 
| 216 | 
            +
                  const shrink = this.computeAvailableShrink(idx, offset);
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                  if (shrink === 0 && Math.abs(offset) > this.closeThreshold) {
         | 
| 219 | 
            +
                    const childIdx = offset > 0 ? idx + 1 : idx - 1;
         | 
| 220 | 
            +
             | 
| 221 | 
            +
                    const child = this.children[childIdx];
         | 
| 222 | 
            +
                    const size = this.getSize(child);
         | 
| 223 | 
            +
                    this.stateBeforeCollapse = cloneDeep(this.state);
         | 
| 224 | 
            +
                    this.isNegativeWhenCollapsing = offset < 0;
         | 
| 225 | 
            +
                    availableOffset = size * (offset > 0 ? 1 : -1);
         | 
| 226 | 
            +
                    this.hasCollapsed = child.props;
         | 
| 227 | 
            +
                    this.elements = this.dispatchOffset(idx, availableOffset);
         | 
| 228 | 
            +
                    this.adjustFlex(this.elements);
         | 
| 229 | 
            +
                    this.setPartialState(this.state).then(() => {
         | 
| 230 | 
            +
                      this.emitElementsEvent(this.elements, "onResize");
         | 
| 231 | 
            +
                    });
         | 
| 232 | 
            +
                  }
         | 
| 233 | 
            +
                } else if (availableOffset) {
         | 
| 234 | 
            +
                  const pos = data.event.changedTouches
         | 
| 235 | 
            +
                    ? data.event.changedTouches[0]
         | 
| 236 | 
            +
                    : data.event;
         | 
| 237 | 
            +
             | 
| 238 | 
            +
                  switch (this.props.orientation) {
         | 
| 239 | 
            +
                    case "horizontal":
         | 
| 240 | 
            +
                      this.previousPos = pos.pageY;
         | 
| 241 | 
            +
                      break;
         | 
| 242 | 
            +
             | 
| 243 | 
            +
                    case "vertical":
         | 
| 244 | 
            +
                    default:
         | 
| 245 | 
            +
                      this.previousPos = pos.pageX;
         | 
| 246 | 
            +
                      break;
         | 
| 247 | 
            +
                  }
         | 
| 248 | 
            +
             | 
| 249 | 
            +
                  this.elements = this.dispatchOffset(idx, availableOffset);
         | 
| 250 | 
            +
             | 
| 251 | 
            +
                  this.adjustFlex(this.elements);
         | 
| 252 | 
            +
                  this.setPartialState(this.state).then(() => {
         | 
| 253 | 
            +
                    this.emitElementsEvent(this.elements, "onResize");
         | 
| 254 | 
            +
                  });
         | 
| 255 | 
            +
                }
         | 
| 256 | 
            +
              }
         | 
| 257 | 
            +
             | 
| 258 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 259 | 
            +
              // Determines if element is a splitter
         | 
| 260 | 
            +
              // or wraps a splitter
         | 
| 261 | 
            +
              //
         | 
| 262 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 263 | 
            +
              isSplitterElement(element) {
         | 
| 264 | 
            +
                //https://github.com/leefsmp/Re-Flex/issues/49
         | 
| 265 | 
            +
                return process.env.NODE_ENV === "development"
         | 
| 266 | 
            +
                  ? element.type === React.createElement(ReflexSplitter).type
         | 
| 267 | 
            +
                  : element.type === ReflexSplitter;
         | 
| 268 | 
            +
              }
         | 
| 269 | 
            +
             | 
| 270 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 271 | 
            +
              // Handles splitter stopResize event
         | 
| 272 | 
            +
              //
         | 
| 273 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 274 | 
            +
              onSplitterStopResize() {
         | 
| 275 | 
            +
                if (this.hasCollapsed) {
         | 
| 276 | 
            +
                  this.props.onPanelCollapse &&
         | 
| 277 | 
            +
                    this.props.onPanelCollapse(this.hasCollapsed);
         | 
| 278 | 
            +
                  this.hasCollapsed = false;
         | 
| 279 | 
            +
                }
         | 
| 280 | 
            +
             | 
| 281 | 
            +
                document.body.style.cursor = "auto";
         | 
| 282 | 
            +
             | 
| 283 | 
            +
                const resizedRefs = this.elements.map(element => {
         | 
| 284 | 
            +
                  return element.ref;
         | 
| 285 | 
            +
                });
         | 
| 286 | 
            +
             | 
| 287 | 
            +
                const elements = this.children.filter(child => {
         | 
| 288 | 
            +
                  return !this.isSplitterElement(child) && resizedRefs.includes(child.ref);
         | 
| 289 | 
            +
                });
         | 
| 290 | 
            +
             | 
| 291 | 
            +
                this.emitElementsEvent(elements, "onStopResize");
         | 
| 292 | 
            +
              }
         | 
| 293 | 
            +
             | 
| 294 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 295 | 
            +
              // Handles element size modified event
         | 
| 296 | 
            +
              //
         | 
| 297 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 298 | 
            +
              onElementSize(data) {
         | 
| 299 | 
            +
                return new Promise(resolve => {
         | 
| 300 | 
            +
                  try {
         | 
| 301 | 
            +
                    const idx = data.element.props.index;
         | 
| 302 | 
            +
             | 
| 303 | 
            +
                    const size = this.getSize(this.children[idx]);
         | 
| 304 | 
            +
             | 
| 305 | 
            +
                    const offset = data.size - size;
         | 
| 306 | 
            +
             | 
| 307 | 
            +
                    const dir = data.direction;
         | 
| 308 | 
            +
             | 
| 309 | 
            +
                    const splitterIdx = idx + dir;
         | 
| 310 | 
            +
             | 
| 311 | 
            +
                    const availableOffset = this.computeAvailableOffset(
         | 
| 312 | 
            +
                      splitterIdx,
         | 
| 313 | 
            +
                      dir * offset
         | 
| 314 | 
            +
                    );
         | 
| 315 | 
            +
             | 
| 316 | 
            +
                    this.elements = null;
         | 
| 317 | 
            +
             | 
| 318 | 
            +
                    if (availableOffset) {
         | 
| 319 | 
            +
                      this.elements = this.dispatchOffset(splitterIdx, availableOffset);
         | 
| 320 | 
            +
             | 
| 321 | 
            +
                      this.adjustFlex(this.elements);
         | 
| 322 | 
            +
                    }
         | 
| 323 | 
            +
             | 
| 324 | 
            +
                    this.setPartialState(this.state).then(() => {
         | 
| 325 | 
            +
                      this.emitElementsEvent(this.elements, "onResize");
         | 
| 326 | 
            +
             | 
| 327 | 
            +
                      resolve();
         | 
| 328 | 
            +
                    });
         | 
| 329 | 
            +
                  } catch (ex) {
         | 
| 330 | 
            +
                    // TODO handle exception ...
         | 
| 331 | 
            +
                  }
         | 
| 332 | 
            +
                });
         | 
| 333 | 
            +
              }
         | 
| 334 | 
            +
             | 
| 335 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 336 | 
            +
              // Adjusts flex after a dispatch to make sure
         | 
| 337 | 
            +
              // total flex of modified elements remains the same
         | 
| 338 | 
            +
              //
         | 
| 339 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 340 | 
            +
              adjustFlex(elements) {
         | 
| 341 | 
            +
                const diffFlex = elements.reduce((sum, element) => {
         | 
| 342 | 
            +
                  const idx = element.props.index;
         | 
| 343 | 
            +
             | 
| 344 | 
            +
                  const previousFlex = element.props.flex;
         | 
| 345 | 
            +
             | 
| 346 | 
            +
                  const nextFlex = this.state.flexData[idx].flex;
         | 
| 347 | 
            +
             | 
| 348 | 
            +
                  return sum + (previousFlex - nextFlex) / elements.length;
         | 
| 349 | 
            +
                }, 0);
         | 
| 350 | 
            +
             | 
| 351 | 
            +
                elements.forEach(element => {
         | 
| 352 | 
            +
                  // eslint-disable-next-line react/no-direct-mutation-state
         | 
| 353 | 
            +
                  this.state.flexData[element.props.index].flex += diffFlex;
         | 
| 354 | 
            +
                });
         | 
| 355 | 
            +
              }
         | 
| 356 | 
            +
             | 
| 357 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 358 | 
            +
              // Returns available offset for a given raw offset value
         | 
| 359 | 
            +
              // This checks how much the panes can be stretched and
         | 
| 360 | 
            +
              // shrink, then returns the min
         | 
| 361 | 
            +
              //
         | 
| 362 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 363 | 
            +
              computeAvailableOffset(idx, offset) {
         | 
| 364 | 
            +
                const stretch = this.computeAvailableStretch(idx, offset);
         | 
| 365 | 
            +
             | 
| 366 | 
            +
                const shrink = this.computeAvailableShrink(idx, offset);
         | 
| 367 | 
            +
             | 
| 368 | 
            +
                const availableOffset = Math.min(stretch, shrink) * Math.sign(offset);
         | 
| 369 | 
            +
             | 
| 370 | 
            +
                return availableOffset;
         | 
| 371 | 
            +
              }
         | 
| 372 | 
            +
             | 
| 373 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 374 | 
            +
              // Returns true if the next splitter than the one at idx
         | 
| 375 | 
            +
              // can propagate the drag. This can happen if that
         | 
| 376 | 
            +
              // next element is actually a splitter and it has
         | 
| 377 | 
            +
              // propagate=true property set
         | 
| 378 | 
            +
              //
         | 
| 379 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 380 | 
            +
              checkPropagate(idx, direction) {
         | 
| 381 | 
            +
                if (direction > 0) {
         | 
| 382 | 
            +
                  if (idx < this.children.length - 2) {
         | 
| 383 | 
            +
                    const child = this.children[idx + 2];
         | 
| 384 | 
            +
             | 
| 385 | 
            +
                    const typeCheck = this.isSplitterElement(child);
         | 
| 386 | 
            +
             | 
| 387 | 
            +
                    return typeCheck && child.props.propagate;
         | 
| 388 | 
            +
                  }
         | 
| 389 | 
            +
                } else {
         | 
| 390 | 
            +
                  if (idx > 2) {
         | 
| 391 | 
            +
                    const child = this.children[idx - 2];
         | 
| 392 | 
            +
             | 
| 393 | 
            +
                    const typeCheck = this.isSplitterElement(child);
         | 
| 394 | 
            +
             | 
| 395 | 
            +
                    return typeCheck && child.props.propagate;
         | 
| 396 | 
            +
                  }
         | 
| 397 | 
            +
                }
         | 
| 398 | 
            +
             | 
| 399 | 
            +
                return false;
         | 
| 400 | 
            +
              }
         | 
| 401 | 
            +
             | 
| 402 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 403 | 
            +
              // Recursively computes available stretch at splitter
         | 
| 404 | 
            +
              // idx for given raw offset
         | 
| 405 | 
            +
              //
         | 
| 406 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 407 | 
            +
              computeAvailableStretch(idx, offset) {
         | 
| 408 | 
            +
                const childIdx = offset < 0 ? idx + 1 : idx - 1;
         | 
| 409 | 
            +
             | 
| 410 | 
            +
                const child = this.children[childIdx];
         | 
| 411 | 
            +
             | 
| 412 | 
            +
                const size = this.getSize(child);
         | 
| 413 | 
            +
             | 
| 414 | 
            +
                const maxSize = child.props.maxSize;
         | 
| 415 | 
            +
             | 
| 416 | 
            +
                const availableStretch = maxSize - size;
         | 
| 417 | 
            +
             | 
| 418 | 
            +
                if (availableStretch < Math.abs(offset)) {
         | 
| 419 | 
            +
                  if (this.checkPropagate(idx, -1 * offset)) {
         | 
| 420 | 
            +
                    const nextOffset =
         | 
| 421 | 
            +
                      Math.sign(offset) * (Math.abs(offset) - availableStretch);
         | 
| 422 | 
            +
             | 
| 423 | 
            +
                    return (
         | 
| 424 | 
            +
                      availableStretch +
         | 
| 425 | 
            +
                      this.computeAvailableStretch(
         | 
| 426 | 
            +
                        offset < 0 ? idx + 2 : idx - 2,
         | 
| 427 | 
            +
                        nextOffset
         | 
| 428 | 
            +
                      )
         | 
| 429 | 
            +
                    );
         | 
| 430 | 
            +
                  }
         | 
| 431 | 
            +
                }
         | 
| 432 | 
            +
             | 
| 433 | 
            +
                return Math.min(availableStretch, Math.abs(offset));
         | 
| 434 | 
            +
              }
         | 
| 435 | 
            +
             | 
| 436 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 437 | 
            +
              // Recursively computes available shrink at splitter
         | 
| 438 | 
            +
              // idx for given raw offset
         | 
| 439 | 
            +
              //
         | 
| 440 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 441 | 
            +
              computeAvailableShrink(idx, offset) {
         | 
| 442 | 
            +
                const childIdx = offset > 0 ? idx + 1 : idx - 1;
         | 
| 443 | 
            +
             | 
| 444 | 
            +
                const child = this.children[childIdx];
         | 
| 445 | 
            +
             | 
| 446 | 
            +
                const size = this.getSize(child);
         | 
| 447 | 
            +
             | 
| 448 | 
            +
                const minSize = Math.max(child.props.minSize, 0);
         | 
| 449 | 
            +
             | 
| 450 | 
            +
                const availableShrink = size - minSize;
         | 
| 451 | 
            +
             | 
| 452 | 
            +
                if (availableShrink < Math.abs(offset)) {
         | 
| 453 | 
            +
                  if (this.checkPropagate(idx, offset)) {
         | 
| 454 | 
            +
                    const nextOffset =
         | 
| 455 | 
            +
                      Math.sign(offset) * (Math.abs(offset) - availableShrink);
         | 
| 456 | 
            +
             | 
| 457 | 
            +
                    return (
         | 
| 458 | 
            +
                      availableShrink +
         | 
| 459 | 
            +
                      this.computeAvailableShrink(
         | 
| 460 | 
            +
                        offset > 0 ? idx + 2 : idx - 2,
         | 
| 461 | 
            +
                        nextOffset
         | 
| 462 | 
            +
                      )
         | 
| 463 | 
            +
                    );
         | 
| 464 | 
            +
                  }
         | 
| 465 | 
            +
                }
         | 
| 466 | 
            +
             | 
| 467 | 
            +
                return Math.min(availableShrink, Math.abs(offset));
         | 
| 468 | 
            +
              }
         | 
| 469 | 
            +
             | 
| 470 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 471 | 
            +
              // Returns flex value for unit pixel
         | 
| 472 | 
            +
              //
         | 
| 473 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 474 | 
            +
              computePixelFlex() {
         | 
| 475 | 
            +
                const domElement = ReactDOM.findDOMNode(this);
         | 
| 476 | 
            +
             | 
| 477 | 
            +
                switch (this.props.orientation) {
         | 
| 478 | 
            +
                  case "horizontal":
         | 
| 479 | 
            +
                    if (domElement.offsetHeight === 0.0) {
         | 
| 480 | 
            +
                      console.warn(
         | 
| 481 | 
            +
                        "Found ReflexContainer with height=0, " +
         | 
| 482 | 
            +
                          "this will cause invalid behavior..."
         | 
| 483 | 
            +
                      );
         | 
| 484 | 
            +
                      console.warn(domElement);
         | 
| 485 | 
            +
                      return 0.0;
         | 
| 486 | 
            +
                    }
         | 
| 487 | 
            +
             | 
| 488 | 
            +
                    return 1.0 / domElement.offsetHeight;
         | 
| 489 | 
            +
             | 
| 490 | 
            +
                  case "vertical":
         | 
| 491 | 
            +
                  default:
         | 
| 492 | 
            +
                    if (domElement.offsetWidth === 0.0) {
         | 
| 493 | 
            +
                      console.warn(
         | 
| 494 | 
            +
                        "Found ReflexContainer with width=0, " +
         | 
| 495 | 
            +
                          "this will cause invalid behavior..."
         | 
| 496 | 
            +
                      );
         | 
| 497 | 
            +
                      console.warn(domElement);
         | 
| 498 | 
            +
                      return 0.0;
         | 
| 499 | 
            +
                    }
         | 
| 500 | 
            +
             | 
| 501 | 
            +
                    return 1.0 / domElement.offsetWidth;
         | 
| 502 | 
            +
                }
         | 
| 503 | 
            +
              }
         | 
| 504 | 
            +
             | 
| 505 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 506 | 
            +
              // Adds offset to a given ReflexElement
         | 
| 507 | 
            +
              //
         | 
| 508 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 509 | 
            +
              addOffset(element, offset) {
         | 
| 510 | 
            +
                const size = this.getSize(element);
         | 
| 511 | 
            +
             | 
| 512 | 
            +
                const idx = element.props.index;
         | 
| 513 | 
            +
             | 
| 514 | 
            +
                const newSize = Math.max(size + offset, 0);
         | 
| 515 | 
            +
             | 
| 516 | 
            +
                const currentFlex = this.state.flexData[idx].flex;
         | 
| 517 | 
            +
             | 
| 518 | 
            +
                const newFlex =
         | 
| 519 | 
            +
                  currentFlex > 0
         | 
| 520 | 
            +
                    ? currentFlex * newSize / size
         | 
| 521 | 
            +
                    : this.computePixelFlex() * newSize;
         | 
| 522 | 
            +
             | 
| 523 | 
            +
                // eslint-disable-next-line react/no-direct-mutation-state
         | 
| 524 | 
            +
                this.state.flexData[idx].flex =
         | 
| 525 | 
            +
                  !isFinite(newFlex) || isNaN(newFlex) ? 0 : newFlex;
         | 
| 526 | 
            +
              }
         | 
| 527 | 
            +
             | 
| 528 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 529 | 
            +
              // Recursively dispatches stretch offset across
         | 
| 530 | 
            +
              // children elements starting at splitter idx
         | 
| 531 | 
            +
              //
         | 
| 532 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 533 | 
            +
              dispatchStretch(idx, offset) {
         | 
| 534 | 
            +
                const childIdx = offset < 0 ? idx + 1 : idx - 1;
         | 
| 535 | 
            +
             | 
| 536 | 
            +
                if (childIdx < 0 || childIdx > this.children.length - 1) {
         | 
| 537 | 
            +
                  return [];
         | 
| 538 | 
            +
                }
         | 
| 539 | 
            +
             | 
| 540 | 
            +
                const child = this.children[childIdx];
         | 
| 541 | 
            +
             | 
| 542 | 
            +
                const size = this.getSize(child);
         | 
| 543 | 
            +
             | 
| 544 | 
            +
                const newSize = Math.min(child.props.maxSize, size + Math.abs(offset));
         | 
| 545 | 
            +
             | 
| 546 | 
            +
                const dispatchedStretch = newSize - size;
         | 
| 547 | 
            +
             | 
| 548 | 
            +
                this.addOffset(child, dispatchedStretch);
         | 
| 549 | 
            +
             | 
| 550 | 
            +
                if (dispatchedStretch < Math.abs(offset)) {
         | 
| 551 | 
            +
                  const nextIdx = idx - Math.sign(offset) * 2;
         | 
| 552 | 
            +
             | 
| 553 | 
            +
                  const nextOffset =
         | 
| 554 | 
            +
                    Math.sign(offset) * (Math.abs(offset) - dispatchedStretch);
         | 
| 555 | 
            +
             | 
| 556 | 
            +
                  return [child, ...this.dispatchStretch(nextIdx, nextOffset)];
         | 
| 557 | 
            +
                }
         | 
| 558 | 
            +
             | 
| 559 | 
            +
                return [child];
         | 
| 560 | 
            +
              }
         | 
| 561 | 
            +
             | 
| 562 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 563 | 
            +
              // Recursively dispatches shrink offset across
         | 
| 564 | 
            +
              // children elements starting at splitter idx
         | 
| 565 | 
            +
              //
         | 
| 566 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 567 | 
            +
              dispatchShrink(idx, offset) {
         | 
| 568 | 
            +
                const childIdx = offset > 0 ? idx + 1 : idx - 1;
         | 
| 569 | 
            +
             | 
| 570 | 
            +
                if (childIdx < 0 || childIdx > this.children.length - 1) {
         | 
| 571 | 
            +
                  return [];
         | 
| 572 | 
            +
                }
         | 
| 573 | 
            +
             | 
| 574 | 
            +
                const child = this.children[childIdx];
         | 
| 575 | 
            +
             | 
| 576 | 
            +
                const size = this.getSize(child);
         | 
| 577 | 
            +
             | 
| 578 | 
            +
                const newSize = Math.max(
         | 
| 579 | 
            +
                  // child.props.minSize, //tnr: not sure what to do about this.. I had to comment this out to make the collapsing work
         | 
| 580 | 
            +
                  size - Math.abs(offset)
         | 
| 581 | 
            +
                );
         | 
| 582 | 
            +
             | 
| 583 | 
            +
                const dispatchedShrink = newSize - size;
         | 
| 584 | 
            +
             | 
| 585 | 
            +
                this.addOffset(child, dispatchedShrink);
         | 
| 586 | 
            +
             | 
| 587 | 
            +
                if (Math.abs(dispatchedShrink) < Math.abs(offset)) {
         | 
| 588 | 
            +
                  const nextIdx = idx + Math.sign(offset) * 2;
         | 
| 589 | 
            +
             | 
| 590 | 
            +
                  const nextOffset =
         | 
| 591 | 
            +
                    Math.sign(offset) * (Math.abs(offset) + dispatchedShrink);
         | 
| 592 | 
            +
             | 
| 593 | 
            +
                  return [child, ...this.dispatchShrink(nextIdx, nextOffset)];
         | 
| 594 | 
            +
                }
         | 
| 595 | 
            +
             | 
| 596 | 
            +
                return [child];
         | 
| 597 | 
            +
              }
         | 
| 598 | 
            +
             | 
| 599 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 600 | 
            +
              // Dispatch offset at splitter idx
         | 
| 601 | 
            +
              //
         | 
| 602 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 603 | 
            +
              dispatchOffset(idx, offset) {
         | 
| 604 | 
            +
                return [
         | 
| 605 | 
            +
                  ...this.dispatchStretch(idx, offset),
         | 
| 606 | 
            +
                  ...this.dispatchShrink(idx, offset)
         | 
| 607 | 
            +
                ];
         | 
| 608 | 
            +
              }
         | 
| 609 | 
            +
             | 
| 610 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 611 | 
            +
              // Emits given if event for each given element
         | 
| 612 | 
            +
              // if present in the component props
         | 
| 613 | 
            +
              //
         | 
| 614 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 615 | 
            +
              emitElementsEvent(elements, event) {
         | 
| 616 | 
            +
                this.toArray(elements).forEach(element => {
         | 
| 617 | 
            +
                  if (element.props[event]) {
         | 
| 618 | 
            +
                    const ref = this.refs[element.ref];
         | 
| 619 | 
            +
             | 
| 620 | 
            +
                    element.props[event]({
         | 
| 621 | 
            +
                      domElement: ReactDOM.findDOMNode(ref),
         | 
| 622 | 
            +
                      component: element
         | 
| 623 | 
            +
                    });
         | 
| 624 | 
            +
                  }
         | 
| 625 | 
            +
                });
         | 
| 626 | 
            +
              }
         | 
| 627 | 
            +
             | 
| 628 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 629 | 
            +
              // Computes initial flex data based on provided flex
         | 
| 630 | 
            +
              // properties. By default each ReflexElement gets
         | 
| 631 | 
            +
              // evenly arranged within its container
         | 
| 632 | 
            +
              //
         | 
| 633 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 634 | 
            +
              computeFlexData(children = this.getValidChildren()) {
         | 
| 635 | 
            +
                const pixelFlex = this.computePixelFlex();
         | 
| 636 | 
            +
             | 
| 637 | 
            +
                const computeFreeFlex = flexData => {
         | 
| 638 | 
            +
                  return flexData.reduce((sum, entry) => {
         | 
| 639 | 
            +
                    if (!this.isSplitterElement(entry) && entry.constrained) {
         | 
| 640 | 
            +
                      return sum - entry.flex;
         | 
| 641 | 
            +
                    }
         | 
| 642 | 
            +
                    return sum;
         | 
| 643 | 
            +
                  }, 1);
         | 
| 644 | 
            +
                };
         | 
| 645 | 
            +
             | 
| 646 | 
            +
                const computeFreeElements = flexData => {
         | 
| 647 | 
            +
                  return flexData.reduce((sum, entry) => {
         | 
| 648 | 
            +
                    if (!this.isSplitterElement(entry) && !entry.constrained) {
         | 
| 649 | 
            +
                      return sum + 1;
         | 
| 650 | 
            +
                    }
         | 
| 651 | 
            +
                    return sum;
         | 
| 652 | 
            +
                  }, 0);
         | 
| 653 | 
            +
                };
         | 
| 654 | 
            +
             | 
| 655 | 
            +
                const flexDataInit = children.map(child => {
         | 
| 656 | 
            +
                  const props = child.props;
         | 
| 657 | 
            +
             | 
| 658 | 
            +
                  return {
         | 
| 659 | 
            +
                    maxFlex: (props.maxSize || Number.MAX_VALUE) * pixelFlex,
         | 
| 660 | 
            +
                    sizeFlex: (props.size || Number.MAX_VALUE) * pixelFlex,
         | 
| 661 | 
            +
                    minFlex: (props.minSize || 1) * pixelFlex,
         | 
| 662 | 
            +
                    constrained: props.flex !== undefined,
         | 
| 663 | 
            +
                    guid: props.ref || this.guid(),
         | 
| 664 | 
            +
                    flex: props.flex || 0,
         | 
| 665 | 
            +
                    type: child.type
         | 
| 666 | 
            +
                  };
         | 
| 667 | 
            +
                });
         | 
| 668 | 
            +
             | 
| 669 | 
            +
                const computeFlexDataRec = flexDataIn => {
         | 
| 670 | 
            +
                  let hasContrain = false;
         | 
| 671 | 
            +
             | 
| 672 | 
            +
                  const freeElements = computeFreeElements(flexDataIn);
         | 
| 673 | 
            +
             | 
| 674 | 
            +
                  const freeFlex = computeFreeFlex(flexDataIn);
         | 
| 675 | 
            +
             | 
| 676 | 
            +
                  const flexDataOut = flexDataIn.map(entry => {
         | 
| 677 | 
            +
                    if (this.isSplitterElement(entry)) {
         | 
| 678 | 
            +
                      return entry;
         | 
| 679 | 
            +
                    }
         | 
| 680 | 
            +
             | 
| 681 | 
            +
                    const proposedFlex = !entry.constrained
         | 
| 682 | 
            +
                      ? freeFlex / freeElements
         | 
| 683 | 
            +
                      : entry.flex;
         | 
| 684 | 
            +
             | 
| 685 | 
            +
                    const constrainedFlex = Math.min(
         | 
| 686 | 
            +
                      entry.sizeFlex,
         | 
| 687 | 
            +
                      Math.min(entry.maxFlex, Math.max(entry.minFlex, proposedFlex))
         | 
| 688 | 
            +
                    );
         | 
| 689 | 
            +
             | 
| 690 | 
            +
                    const constrained = constrainedFlex !== proposedFlex;
         | 
| 691 | 
            +
             | 
| 692 | 
            +
                    hasContrain = hasContrain || constrained;
         | 
| 693 | 
            +
             | 
| 694 | 
            +
                    return Object.assign({}, entry, {
         | 
| 695 | 
            +
                      flex: constrainedFlex,
         | 
| 696 | 
            +
                      constrained
         | 
| 697 | 
            +
                    });
         | 
| 698 | 
            +
                  });
         | 
| 699 | 
            +
             | 
| 700 | 
            +
                  return hasContrain ? computeFlexDataRec(flexDataOut) : flexDataOut;
         | 
| 701 | 
            +
                };
         | 
| 702 | 
            +
             | 
| 703 | 
            +
                const flexData = computeFlexDataRec(flexDataInit);
         | 
| 704 | 
            +
             | 
| 705 | 
            +
                return flexData.map(entry => {
         | 
| 706 | 
            +
                  return {
         | 
| 707 | 
            +
                    flex: !this.isSplitterElement(entry) ? entry.flex : 0.0,
         | 
| 708 | 
            +
                    guid: entry.guid
         | 
| 709 | 
            +
                  };
         | 
| 710 | 
            +
                });
         | 
| 711 | 
            +
              }
         | 
| 712 | 
            +
             | 
| 713 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 714 | 
            +
              // Utility method that generates a new unique GUID
         | 
| 715 | 
            +
              //
         | 
| 716 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 717 | 
            +
              guid(format = "xxxx-xxxx") {
         | 
| 718 | 
            +
                let d = new Date().getTime();
         | 
| 719 | 
            +
             | 
| 720 | 
            +
                return format.replace(/[xy]/g, function(c) {
         | 
| 721 | 
            +
                  const r = ((d + Math.random() * 16) % 16) | 0;
         | 
| 722 | 
            +
                  d = Math.floor(d / 16);
         | 
| 723 | 
            +
                  // eslint-disable-next-line eqeqeq
         | 
| 724 | 
            +
                  return (c == "x" ? r : (r & 0x7) | 0x8).toString(16);
         | 
| 725 | 
            +
                });
         | 
| 726 | 
            +
              }
         | 
| 727 | 
            +
             | 
| 728 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 729 | 
            +
              // Utility method to ensure given argument is
         | 
| 730 | 
            +
              // returned as an array
         | 
| 731 | 
            +
              //
         | 
| 732 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 733 | 
            +
              toArray(obj) {
         | 
| 734 | 
            +
                return obj ? (Array.isArray(obj) ? obj : [obj]) : [];
         | 
| 735 | 
            +
              }
         | 
| 736 | 
            +
             | 
| 737 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 738 | 
            +
              // Render container. This will clone all original child
         | 
| 739 | 
            +
              // components in order to pass some internal properties
         | 
| 740 | 
            +
              // used to handle resizing logic
         | 
| 741 | 
            +
              //
         | 
| 742 | 
            +
              /////////////////////////////////////////////////////////
         | 
| 743 | 
            +
              render() {
         | 
| 744 | 
            +
                const classNames = [
         | 
| 745 | 
            +
                  "reflex-layout",
         | 
| 746 | 
            +
                  "reflex-container",
         | 
| 747 | 
            +
                  this.props.orientation,
         | 
| 748 | 
            +
                  ...this.props.className.split(" ")
         | 
| 749 | 
            +
                ];
         | 
| 750 | 
            +
             | 
| 751 | 
            +
                this.children = React.Children.map(
         | 
| 752 | 
            +
                  this.getValidChildren(),
         | 
| 753 | 
            +
                  (child, idx) => {
         | 
| 754 | 
            +
                    if (idx > this.state.flexData.length - 1) {
         | 
| 755 | 
            +
                      return <div />;
         | 
| 756 | 
            +
                    }
         | 
| 757 | 
            +
             | 
| 758 | 
            +
                    const flexData = this.state.flexData[idx];
         | 
| 759 | 
            +
             | 
| 760 | 
            +
                    const newProps = Object.assign({}, child.props, {
         | 
| 761 | 
            +
                      maxSize: child.props.maxSize || Number.MAX_VALUE,
         | 
| 762 | 
            +
                      orientation: this.props.orientation,
         | 
| 763 | 
            +
                      minSize: child.props.minSize || 1,
         | 
| 764 | 
            +
                      events: this.events,
         | 
| 765 | 
            +
                      flex: round(flexData.flex, 5), //tnr: this rounding is necessary because flex was getting computed very slightly off (eg -1.423432e-17). This corrects for that
         | 
| 766 | 
            +
                      ref: flexData.guid,
         | 
| 767 | 
            +
                      index: idx
         | 
| 768 | 
            +
                    });
         | 
| 769 | 
            +
             | 
| 770 | 
            +
                    return React.cloneElement(child, newProps);
         | 
| 771 | 
            +
                  }
         | 
| 772 | 
            +
                );
         | 
| 773 | 
            +
             | 
| 774 | 
            +
                return (
         | 
| 775 | 
            +
                  <div className={classNames.join(" ")} style={this.props.style}>
         | 
| 776 | 
            +
                    {this.children}
         | 
| 777 | 
            +
                  </div>
         | 
| 778 | 
            +
                );
         | 
| 779 | 
            +
              }
         | 
| 780 | 
            +
            }
         | 
| 781 | 
            +
             | 
| 782 | 
            +
            /////////////////////////////////////////////////////////
         | 
| 783 | 
            +
            //
         | 
| 784 | 
            +
            //
         | 
| 785 | 
            +
            /////////////////////////////////////////////////////////
         | 
| 786 | 
            +
            ReflexContainer.propTypes = {
         | 
| 787 | 
            +
              orientation: PropTypes.oneOf(["horizontal", "vertical"]),
         | 
| 788 | 
            +
              className: PropTypes.string,
         | 
| 789 | 
            +
              style: PropTypes.object
         | 
| 790 | 
            +
            };
         | 
| 791 | 
            +
             | 
| 792 | 
            +
            /////////////////////////////////////////////////////////
         | 
| 793 | 
            +
            //
         | 
| 794 | 
            +
            //
         | 
| 795 | 
            +
            /////////////////////////////////////////////////////////
         | 
| 796 | 
            +
            ReflexContainer.defaultProps = {
         | 
| 797 | 
            +
              orientation: "horizontal",
         | 
| 798 | 
            +
              className: "",
         | 
| 799 | 
            +
              style: {}
         | 
| 800 | 
            +
            };
         | 
| 801 | 
            +
             | 
| 802 | 
            +
            export default ReflexContainer;
         |