@topgrid/grid-features 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Topvel Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # @topgrid/grid-features
2
+
3
+ Column reorder, multi-sort, filter UI features
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @topgrid/grid-features
9
+ # or
10
+ npm install @topgrid/grid-features
11
+ # or
12
+ yarn add @topgrid/grid-features
13
+ ```
14
+
15
+ ## Peer Dependencies
16
+
17
+ | Package | Version |
18
+ |---------|---------|
19
+ | `@tanstack/react-table` | `^8.0.0` |
20
+ | `@tanstack/react-virtual` | `^3.0.0` (optional) |
21
+ | `react` | `^18.0.0 \|\| ^19.0.0` |
22
+ | `react-dom` | `^18.0.0 \|\| ^19.0.0` |
23
+ | `date-fns` | `^4.1.0` |
24
+ | `react-datepicker` | `^8.3.0` |
25
+
26
+ ## Usage
27
+
28
+ ### Column Drag-and-Drop Reorder
29
+
30
+ ```tsx
31
+ import { useColumnDrag, DropIndicator } from '@topgrid/grid-features';
32
+
33
+ export function ReorderableGrid({ columns, data }) {
34
+ const { dragProps, dropProps } = useColumnDrag({ columns });
35
+ return (
36
+ <table>
37
+ <thead>
38
+ <tr>
39
+ {columns.map((col) => (
40
+ <th key={col.id} {...dragProps(col.id)}>
41
+ {col.header}
42
+ <DropIndicator {...dropProps(col.id)} />
43
+ </th>
44
+ ))}
45
+ </tr>
46
+ </thead>
47
+ </table>
48
+ );
49
+ }
50
+ ```
51
+
52
+ ### Multi-Sort
53
+
54
+ ```tsx
55
+ import { useMultiSort, SortBadge, SortClearButton } from '@topgrid/grid-features';
56
+
57
+ export function SortableGrid({ table }) {
58
+ const { sortState } = useMultiSort({ table });
59
+ return (
60
+ <div>
61
+ <SortClearButton table={table} />
62
+ {/* SortBadge renders sort indicator per column */}
63
+ </div>
64
+ );
65
+ }
66
+ ```
67
+
68
+ ## Main API
69
+
70
+ | Export | Description |
71
+ |--------|-------------|
72
+ | `useColumnDrag` | Column drag-and-drop reorder hook |
73
+ | `DropIndicator` | Drop target indicator component |
74
+ | `useColumnOrderPersist` | Persist column order to storage |
75
+ | `useMultiSort` | Multi-column sort hook |
76
+ | `SortBadge` | Sort order indicator badge |
77
+ | `SortClearButton` | Button to clear all sort state |
78
+
79
+ ## License
80
+
81
+ MIT
82
+
83
+ ---
84
+
85
+ [Documentation](https://grid.tomis.dev) | [API Reference](https://grid.tomis.dev/api)