UNPKG

@uppy/provider-views

Version:

View library for Uppy remote provider plugins.

12 lines 690 B
// Shift-clicking selects a single consecutive list of items // starting at the previous click. const getClickedRange = (clickedId, displayedPartialTree, isShiftKeyPressed, lastCheckbox) => { const lastCheckboxIndex = displayedPartialTree.findIndex(item => item.id === lastCheckbox); if (lastCheckboxIndex !== -1 && isShiftKeyPressed) { const newCheckboxIndex = displayedPartialTree.findIndex(item => item.id === clickedId); const clickedRange = displayedPartialTree.slice(Math.min(lastCheckboxIndex, newCheckboxIndex), Math.max(lastCheckboxIndex, newCheckboxIndex) + 1); return clickedRange.map(item => item.id); } return [clickedId]; }; export default getClickedRange;