Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
.DS_Store
*.log
.idea
lib/react-selectable-fast.js
2 changes: 2 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/react-selectable-fast.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/react-selectable-fast.js.map

Large diffs are not rendered by default.

363 changes: 363 additions & 0 deletions lib/react-selectable-fast.js

Large diffs are not rendered by default.

11,811 changes: 11,811 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "react-selectable-fast",
"version": "3.4.0",
"name": "react-selectable-fast2",
"version": "3.4.1",
"description": "Enable other React components to be selectable by drawing a box with your mouse/touch",
"repository": {
"type": "git",
"url": "git://github.com/valerybugakov/react-selectable-fast.git"
"url": "git://github.com/vparaskevas/react-selectable-fast.git"
},
"main": "lib/index.js",
"main": "dist/index.js",
"scripts": {
"clean": "rimraf ./lib ./dist",
"watch": "webpack --watch",
Expand Down
56 changes: 28 additions & 28 deletions src/SelectableGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
noop,
Maybe,
TComputedBounds,
getDocumentScroll,
getDocumentScroll
} from './utils'
import { TSelectableItem } from './Selectable.types'
import { SelectableGroupContext } from './SelectableGroup.context'
Expand Down Expand Up @@ -109,7 +109,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
allowCtrlClick: false,
allowMetaClick: false,
allowShiftClick: false,
selectOnClick: true,
selectOnClick: true
}

state = { selectionMode: false }
Expand All @@ -131,7 +131,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
mouseDownData: TMouseDownData = {
selectboxY: 0,
selectboxX: 0,
target: null,
target: null
}

registry = new Set<TSelectableItem>()
Expand Down Expand Up @@ -160,12 +160,12 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {

containerScroll = {
scrollTop: 0,
scrollLeft: 0,
scrollLeft: 0
}

documentScroll = {
scrollTop: 0,
scrollLeft: 0,
scrollLeft: 0
}

componentDidMount() {
Expand Down Expand Up @@ -213,7 +213,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {

this.containerScroll = {
scrollTop,
scrollLeft,
scrollLeft
}
}

Expand All @@ -222,20 +222,20 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {

this.documentScroll = {
scrollTop: documentScrollTop,
scrollLeft: documentScrollLeft,
scrollLeft: documentScrollLeft
}
}

get containerDocumentScroll() {
return {
scrollTop: this.containerScroll.scrollTop + this.documentScroll.scrollTop,
scrollLeft: this.containerScroll.scrollLeft + this.documentScroll.scrollLeft,
scrollLeft: this.containerScroll.scrollLeft + this.documentScroll.scrollLeft
}
}

removeTempEventListeners() {
document.removeEventListener('mousemove', this.updateSelectBox)
document.removeEventListener('touchmove', this.updateSelectBox)
// document.removeEventListener('touchmove', this.updateSelectBox)
document.removeEventListener('mouseup', this.mouseUp)
document.removeEventListener('touchend', this.mouseUp)
}
Expand Down Expand Up @@ -278,7 +278,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
toggleSelectionMode() {
const {
selectedItems,
state: { selectionMode },
state: { selectionMode }
} = this

if (selectedItems.size && !selectionMode) {
Expand Down Expand Up @@ -362,7 +362,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
x: selectboxX,
y: selectboxY,
width: Math.abs(pointX - mouseDownData.selectboxX),
height: Math.abs(pointY - mouseDownData.selectboxY),
height: Math.abs(pointY - mouseDownData.selectboxY)
}

this.setSelectboxState!(selectboxState)
Expand All @@ -373,7 +373,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
width: selectboxState.width,
height: selectboxState.height,
offsetWidth: selectboxState.width || 1,
offsetHeight: selectboxState.height || 1,
offsetHeight: selectboxState.height || 1
}

this.selectItems(selectboxBounds)
Expand All @@ -391,7 +391,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
tolerance: tolerance!,
mixedDeselect: mixedDeselect!,
enableDeselect: enableDeselect!,
isFromClick: options && options.isFromClick,
isFromClick: options && options.isFromClick
})
}
}
Expand Down Expand Up @@ -458,7 +458,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
}

this.setState({ selectionMode: false })
this.props.onSelectionFinish!([...this.selectedItems])
this.props.onSelectionFinish!([...this.selectedItems], this.selectableGroup)
this.props.onSelectionClear!()
}

Expand All @@ -473,7 +473,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
}

this.setState({ selectionMode: true })
this.props.onSelectionFinish!([...this.selectedItems])
this.props.onSelectionFinish!([...this.selectedItems], this.selectableGroup)
}

isInIgnoreList(target: HTMLElement | null) {
Expand Down Expand Up @@ -510,7 +510,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
allowAltClick: this.props.allowAltClick,
allowCtrlClick: this.props.allowCtrlClick,
allowMetaClick: this.props.allowMetaClick,
allowShiftClick: this.props.allowShiftClick,
allowShiftClick: this.props.allowShiftClick
})
if (this.mouseDownStarted || this.props.disabled || isNotLeftButtonClick) {
return
Expand Down Expand Up @@ -540,15 +540,15 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
width: 0,
height: 0,
offsetHeight: bounds.offsetHeight,
offsetWidth: bounds.offsetWidth,
offsetWidth: bounds.offsetWidth
},
{
top: evt.pageY,
left: evt.pageX,
width: 0,
height: 0,
offsetWidth: 0,
offsetHeight: 0,
offsetHeight: 0
}
)

Expand All @@ -563,13 +563,13 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
this.mouseDownData = {
target: evt.target as HTMLElement,
selectboxY: evt.clientY - this.scrollBounds!.top + this.containerScroll.scrollTop,
selectboxX: evt.clientX - this.scrollBounds!.left + this.containerScroll.scrollLeft,
selectboxX: evt.clientX - this.scrollBounds!.left + this.containerScroll.scrollLeft
}

evt.preventDefault()

document.addEventListener('mousemove', this.updateSelectBox)
document.addEventListener('touchmove', this.updateSelectBox)
// document.addEventListener('touchmove', this.updateSelectBox)
document.addEventListener('mouseup', this.mouseUp)
document.addEventListener('touchend', this.mouseUp)
}
Expand Down Expand Up @@ -616,9 +616,9 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
x: 0,
y: 0,
width: 0,
height: 0,
height: 0
})
this.props.onSelectionFinish!([...this.selectedItems])
this.props.onSelectionFinish!([...this.selectedItems], this.selectableGroup)
}

this.toggleSelectionMode()
Expand Down Expand Up @@ -654,7 +654,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {

// eslint-disable-next-line react/sort-comp
defaultContainerStyle: CSSProperties = {
position: 'relative',
position: 'relative'
}

contextValue = {
Expand All @@ -663,8 +663,8 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
unregister: this.unregisterSelectable,
selectAll: this.selectAll,
clearSelection: this.clearSelection,
getScrolledContainer: () => this.scrollContainer,
},
getScrolledContainer: () => this.scrollContainer
}
}

handleClick(evt: any, top: number, left: number) {
Expand All @@ -689,12 +689,12 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
width: 0,
height: 0,
offsetWidth: 0,
offsetHeight: 0,
offsetHeight: 0
},
{ isFromClick: true }
)

onSelectionFinish!([...this.selectedItems], this.clickedItem)
onSelectionFinish!([...this.selectedItems], this.selectableGroup, this.clickedItem)

if (evt.which === 1) {
this.preventEvent(evt.target, 'click')
Expand All @@ -714,7 +714,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
selectionModeClass,
fixedPosition,
selectboxClassName,
children,
children
} = this.props

return (
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '',
filename: 'react-selectable-fast.js',
filename: 'index.js',
library: 'React-Selectable-Fast',
libraryTarget: 'umd',
},
Expand Down