Skip to content

Conversation

@akrv7591
Copy link
Contributor

This PR introduces a new useSelection React hook to the @mantine/hooks package. This hook provides a comprehensive and intuitive API for managing selection state in various UI components like lists, tables, or multi-select inputs.

Key Features:

  • Flexible Selection Management: Includes select, deselect, and toggle functions for granular control over individual item selection.
  • Convenience Flags: Exposes isAllSelected and isSomeSelected flags to quickly determine the overall selection status, optimized for a better user experience (e.g., isAllSelected is false if data is empty).
  • Direct State Control: Allows direct manipulation of the selection array via setSelection.
  • Reset Functionality: Provides a resetSelection function to easily clear the current selection.
  • Type-Safe: Fully typed with TypeScript to ensure robust usage with any data type.

@rtivital
Copy link
Member

Please fix tests

@akrv7591
Copy link
Contributor Author

  1. Fixed tests
  2. Adde optional defaultSelection
  3. Added storybook demo
  4. updated tests to test defaultSelection

@rtivital rtivital changed the base branch from master to 8.2.0-contributions May 26, 2025 06:17
@rtivital rtivital merged commit a29e868 into mantinedev:8.2.0-contributions May 27, 2025
1 check passed
@rtivital
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants