How to use the @amalto/helpers.arrayMax function in @amalto/helpers

To help you get started, we’ve selected a few @amalto/helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amalto / platform6-ui-components / components / data-grid / components / SelectablesContainer.tsx View on Github external
else if ( event.shiftKey ) {

            //if we click on an already selected item, do nothing, else go in that if
            if ( idx === -1 ) {
                if ( selectedItems.length >= 1 ) {

                    let selectedIdx = itemIndex

                    //case only one item selected
                    let currentMin = selectedItems[0]
                    let currentMax = currentMin

                    //case multiple items already selected => set proper min & max to build the largest interval
                    if ( selectedItems.length > 1 ) {
                        currentMin = arrayMin( selectedItems )
                        currentMax = arrayMax( selectedItems )
                    }

                    let min = Math.min( selectedIdx, currentMin )
                    let max = Math.max( selectedIdx, currentMax )

                    //build the interval
                    let interval = []
                    let i = min
                    for ( i; i <= max; i++ ) {
                        interval.push( i )
                    }

                    onSelect( interval )


                }