/
eb
/
js-excel
Обзор
Документация
Войти
/
eb
/
js-excel
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/components/table/table.functions.js
46 строк
1 KB
Evgeniy Budaev
Finish redux and table logic
16 июн 2020, 10:52
16 июн 2020, 10:52
b7d4906
Код
Авторство
О чём код?
import {range} from "@core/utils"; export function shouldResize(event) { return event.target.dataset.resize } export function isCell(event) { return event.target.dataset.type === 'cell' } export function matrix($target, $current) { const target = $target.id(true) const current = $current .id(true) const cols = range(current.col, target.col) const rows = range(current.row, target.row) // console.log('Cols ', cols) // console.log('Rows ', rows) return cols.reduce((acc, col) => { rows.forEach(row => acc.push(`${row}:${col}`)) return acc }, []) // console.log(ids) } export function nextSelector(key, {col, row}) { const MIN_VALUE = 0 switch (key) { case 'Enter': case 'ArrowDown': row++ break case 'Tab': case 'ArrowRight': col++ break case 'ArrowLeft': col = col - 1 < MIN_VALUE ? MIN_VALUE : col - 1 break case 'ArrowUp': row = row - 1 < MIN_VALUE ? MIN_VALUE : row - 1 break } return `[data-id="${row}:${col}"]` }