Add more types to MultiGrid component
parent
14e1b26b61
commit
3cc66e1a0d
|
@ -4,22 +4,27 @@ import classnames from 'classnames'
|
||||||
import {Scrollbars} from 'react-custom-scrollbars'
|
import {Scrollbars} from 'react-custom-scrollbars'
|
||||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||||
|
|
||||||
|
interface DefaultProps {
|
||||||
|
autoHide: boolean
|
||||||
|
autoHeight: boolean
|
||||||
|
maxHeight: number
|
||||||
|
setScrollTop: (value: React.MouseEvent<JSX.Element>) => void
|
||||||
|
style: React.CSSProperties
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
autoHide?: boolean
|
|
||||||
autoHeight?: boolean
|
|
||||||
maxHeight?: number
|
|
||||||
className?: string
|
className?: string
|
||||||
setScrollTop?: (value: React.MouseEvent<JSX.Element>) => void
|
|
||||||
style?: React.CSSProperties
|
|
||||||
scrollTop?: number
|
scrollTop?: number
|
||||||
scrollLeft?: number
|
scrollLeft?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
@ErrorHandling
|
@ErrorHandling
|
||||||
class FancyScrollbar extends Component<Props> {
|
class FancyScrollbar extends Component<Props & Partial<DefaultProps>> {
|
||||||
public static defaultProps = {
|
public static defaultProps = {
|
||||||
autoHide: true,
|
autoHide: true,
|
||||||
autoHeight: false,
|
autoHeight: false,
|
||||||
|
maxHeight: null,
|
||||||
|
style: {},
|
||||||
setScrollTop: () => {},
|
setScrollTop: () => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +37,11 @@ class FancyScrollbar extends Component<Props> {
|
||||||
|
|
||||||
public updateScroll() {
|
public updateScroll() {
|
||||||
const ref = this.ref.current
|
const ref = this.ref.current
|
||||||
if (ref && _.isNumber(this.props.scrollTop)) {
|
if (ref && !_.isNil(this.props.scrollTop)) {
|
||||||
ref.scrollTop(this.props.scrollTop)
|
ref.scrollTop(this.props.scrollTop)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref && _.isNumber(this.props.scrollLeft)) {
|
if (ref && !_.isNil(this.props.scrollLeft)) {
|
||||||
ref.scrollLeft(this.props.scrollLeft)
|
ref.scrollLeft(this.props.scrollLeft)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ interface IndexParam {
|
||||||
index: number
|
index: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class CellMeasurerCacheDecorator {
|
class CellMeasurerCacheDecorator {
|
||||||
private cellMeasurerCache: CellMeasurerCache
|
private cellMeasurerCache: CellMeasurerCache
|
||||||
private columnIndexOffset: number
|
private columnIndexOffset: number
|
||||||
private rowIndexOffset: number
|
private rowIndexOffset: number
|
||||||
|
@ -101,3 +101,5 @@ export default class CellMeasurerCacheDecorator {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default CellMeasurerCacheDecorator
|
||||||
|
|
|
@ -31,7 +31,7 @@ interface Props {
|
||||||
scrollToRow?: () => {}
|
scrollToRow?: () => {}
|
||||||
onSectionRendered?: () => {}
|
onSectionRendered?: () => {}
|
||||||
scrollToColumn?: () => {}
|
scrollToColumn?: () => {}
|
||||||
cellRenderer?: (arg: object) => {}
|
cellRenderer?: (arg: object) => JSX.Element
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
|
@ -321,7 +321,10 @@ class MultiGrid extends React.PureComponent<Props, State> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public cellRendererBottomLeftGrid = ({rowIndex, ...rest}) => {
|
public cellRendererBottomLeftGrid = ({
|
||||||
|
rowIndex,
|
||||||
|
...rest
|
||||||
|
}: Partial<Props> & {rowIndex: number; key: string}): JSX.Element => {
|
||||||
const {cellRenderer, fixedRowCount, rowCount} = this.props
|
const {cellRenderer, fixedRowCount, rowCount} = this.props
|
||||||
|
|
||||||
if (rowIndex === rowCount - fixedRowCount) {
|
if (rowIndex === rowCount - fixedRowCount) {
|
||||||
|
|
Loading…
Reference in New Issue