Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xnerhu/rectangle-selection

Rectangle selection for React
https://github.com/xnerhu/rectangle-selection

Last synced: about 2 months ago
JSON representation

Rectangle selection for React

Awesome Lists containing this project

README

        

# rectangle-selection

[![NPM](https://img.shields.io/npm/v/rectangle-selection.svg?style=flat-square)](https://www.npmjs.com/package/rectangle-selection)

An easy to use items selection.

![](https://qusly.app/public/screenshots/rectangle-selection.gif)

## Installing

```bash
$ npm install rectangle-selection --save-dev
```

## Example

```tsx
import React from 'react';
import { SelectionArea, Selectable } from 'rectangle-selection';

const App = () => {
const items = React.useRef(Array.from(Array(10).keys()));

const [selected, setSelected] = React.useState([]);

// Clear selected items on background click
const onMouseDown = React.useCallback(() => {
setSelected([]);
}, []);

const onSelection = React.useCallback((items: number[]) => {
setSelected(items);
}, []);

const onItemMouseDown = (id: number) => (e: React.MouseEvent) => {
e.stopPropagation();
setSelected([id]);
};

return (

{items.current.map(r => (

{innerRef => (


)}

))}

);
};
```

# Related

- [Qusly](https://www.github.com/qusly/qusly) - full-featured FTP client.