all components with onSelectionChange have a bad api design
- Dominant language
- TypeScript
- Stars
- 15.9k
- Forks
- 1.6k
- Avg merge
- 3d 9m
- Merged PRs (30d)
- 59
Description
### Provide your feedback here.
# Problem Description
The Selection type in Nextui with TypeScript has a few issues that impact its usability and correctness.
# Issues Identified
1. Cannot Retrieve Length
The Selection type, which can be either 'all' or a Set, lacks a consistent way to retrieve its length.
This makes it challenging to perform operations that require knowledge of the number of elements in the selection.
2. Limited Iteration Support
The Selection type currently only offers methods like toString or valueOf in TypeScript.
This limitation prevents convenient iteration over the selection, hindering common use cases.
3. Error in Official Docs Example
The example provided in the official documentation leads to a TypeScript error:
```typescript
Type 'string' is not assignable to type 'SetStateAction>'.ts(2345)
```
Nextui Version: 2.2.9
TypeScript Version: 5.3.3
### 🔦 Context
_No response_
### 💻 Code Sample
https://nextui.org/docs/components/table#controlled-selection
### Version
_No response_
### What browsers are you seeing the problem on?
_No response_
### If other, please specify
_No response_
### What operating system are you using?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.