import React, { useContext, useMemo, useRef, useEffect, useState } from 'react'
import { ConfigContext } from './Table'
import { RangeType, Modes, ModeType } from './prop-types'
import isEqual from 'lodash.isequal'
import { LEVELS, log } from './utils'
import './Range.css'
const Range = props => {
log('Range', LEVELS.INFO, props)
const { rowIdAttr } = useContext(ConfigContext)
const {
range: { row, col, width, height, split },
mode
} = props
const ref = useRef(null)
const className = useMemo(() => {
const classes = [
'rrt-range',
...(split ? [`rrt-range-${mode}`] : []),
...(width * height > 1 ? ['rrt-range-surface'] : [])
]
return classes.join(' ')
}, [width, height, mode])
const [style, setStyle] = useState({
left: 0,
top: 0,
width: 0,
height: 0
})
useEffect(() => {
const { current } = ref
if (current) {
const rows = current.parentNode
if (rows) {
const upperRow = rows.children[row]
const lowerRow = rows.children[row + height - 1]
if (upperRow && lowerRow) {
Copyright 2020 Ulrich Gaal
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.