
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
react-selectable-fast
Advanced tools
Enable other React components to be selectable by drawing a box with your mouse/touch
Enable a React component (or group of components) to be selectable via mouse/touch.
http://valerybugakov.github.io/react-selectable-fast
npm i -S react-selectable-fast
This project is based on react-selectable by unclecheese. The main idea of this fork is to eliminate render during selection caused by state updates of SelectableGroup. Only items under selectbox rerender themselves, which great for big lists of selectable items. Also, this package extends the original functionality with ability to scroll items while selecting relative to window and specified scroll container.
Package exports 4 entities { SelectableGroup, createSelectable, SelectAll, DeselectAll }
.
To make other components selectable wrap them using HoC createSelectable
, add passed selectableRef
prop to the target node and put a list of seletable items under SelectableGroup
.
import React, { Component } from 'react'
import { SelectableGroup } from 'react-selectable-fast'
class App extends Component {
...
render() {
return (
<SelectableGroup
className="main"
clickClassName="tick"
enableDeselect
tolerance={this.state.tolerance}
globalMouse={this.state.isGlobal}
allowClickWithoutSelected={false}
duringSelection={this.handleSelecting}
onSelectionClear={this.handleSelectionClear}
onSelectionFinish={this.handleSelectionFinish}
ignoreList={['.not-selectable', '.item:nth-child(10)', '.item:nth-child(27)']}
>
<List items={this.props.items} />
</SelectableGroup>
)
}
}
import React from 'react'
import { createSelectable } from 'react-selectable-fast'
const SomeComponent = ({ selectableRef, selected, selecting }) => (
<div ref={selectableRef}>...</div>
)
export default createSelectable(SomeComponent)
import React from 'react'
import { SelectAll, DeselectAll } from 'react-selectable-fast'
import SelectableComponent from './SomeComponent'
const List = () => (
<div>
<SelectAll className="selectable-button">
<button>Select all</button>
</SelectAll>
<DeselectAll className="selectable-button">
<button>Clear selection</button>
</DeselectAll>
{this.props.items.map((item, i) => (
<SelectableComponent
key={i}
title={item.title}
year={item.year}
/>
))}
</div>
)
The <SelectableGroup />
component accepts a few optional props:
duringSelection
(Function) Callback fired rapidly during selection (while the selector is being dragged). Passes an array containing selectable items currently under the selector to the callback function.onSelectionFinish
(Function) Callback.onSelectionClear
(Function) Callback.enableDeselect
(Boolean) Enables deselect with selectbox.mixedDeselect
(Boolean) When enabled items can be selected and deselected with selectbox at the same time, enableDeselect
should be set to true
.scrollContainer
(String) Selector of scroll container which will be used to calculate selectbox position. If not specified SelectableGroup element will be used as scroll container.ignoreList
(Array) Array of ignored selectors.clickableClassName
(String) On elements with specified selector click item containing this element will be selected.tolerance
(Number) The amount of buffer to add around your <SelectableGroup />
container, in pixels.className
(String) Class of selectable group element.selectionModeClass
(String) Class indicating that there is more than 1 selected item. Defaults to 'in-selection-mode'.component
(String) The component to render. Defaults to div
.allowClickWithoutSelected
(Boolean) When disabled items can be selected by click only if there is more than 1 already selected item.fixedPosition
(Boolean) Whether the <SelectableGroup />
container is a fixed or absolutely positioned element or the grandchild of one.FAQs
Enable other React components to be selectable by drawing a box with your mouse/touch
The npm package react-selectable-fast receives a total of 3,653 weekly downloads. As such, react-selectable-fast popularity was classified as popular.
We found that react-selectable-fast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.