1.9.0 • Published 2 months ago

react-selectable-box v1.9.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

A React component that allows you to select elements in the drag area using the mouse

Changelog · Report Bug · Request Feature

NPM version NPM downloads install size

Test CI status Deploy CI Coverage

contributors forks stargazers issues

 docs by dumi Build With father

Introduction

A React component that allows you to select elements in the drag area using the mouse

Usage

Install

npm i react-selectable-box
// or
yarn add react-selectable-box
// or
pnpm add react-selectable-box

Docs

docs

Example

import Selectable, { useSelectable } from 'react-selectable-box';

const list: number[] = [];
for (let i = 0; i < 200; i++) {
  list.push(i);
}

const App = () => {
  return (
    <Selectable>
      <div
        style={{
          display: 'flex',
          flexWrap: 'wrap',
          gap: 20,
          padding: 20,
          border: '1px solid #ccc',
        }}
      >
        {list.map((i) => (
          <Item key={i} value={i} />
        ))}
      </div>
    </Selectable>
  );
};

const Item = ({ value }: { value: number }) => {
  const { setNodeRef, isSelected, isAdding } = useSelectable({
    value,
  });

  return (
    <div
      ref={setNodeRef}
      style={{
        width: 50,
        height: 50,
        borderRadius: 4,
        border: isAdding ? '1px solid #1677ff' : undefined,
        background: isSelected ? '#1677ff' : '#ccc',
      }}
    />
  );
};

Changelog

CHANGELOG

📝 License

Copyright © 2023 - present linxianxi. This project is MIT licensed.

1.9.0

2 months ago

1.8.2

3 months ago

1.8.1

3 months ago

1.8.0

3 months ago

1.7.1

3 months ago

1.7.0

3 months ago

1.6.0

3 months ago

1.5.0

3 months ago

1.4.0

4 months ago

1.3.0

4 months ago

1.2.0

6 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

9 months ago

1.0.0

9 months ago