gridular 1.0.3 → 1.1.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/README.md +68 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,8 @@ Gridular is a flexible and customizable data grid component for React applicatio
|
|
|
9
9
|
- **Pagination**: Navigate through large datasets with pagination controls.
|
|
10
10
|
- **Row Selection**: Select rows for actions or data manipulation.
|
|
11
11
|
- **Column Resizing**: Adjust column widths to fit your data needs.
|
|
12
|
+
- **Column Management**: Show/hide and reorder columns as needed.
|
|
13
|
+
- **Grid State Persistence**: Maintain column widths and ordering between sessions.
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
@@ -18,8 +20,6 @@ To install Gridular, use npm or yarn:
|
|
|
18
20
|
npm install gridular
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
or
|
|
22
|
-
|
|
23
23
|
```bash
|
|
24
24
|
yarn add gridular
|
|
25
25
|
```
|
|
@@ -28,19 +28,19 @@ yarn add gridular
|
|
|
28
28
|
|
|
29
29
|
To use the DataGrid component, import it into your React component:
|
|
30
30
|
|
|
31
|
-
```
|
|
32
|
-
import { DataGrid } from
|
|
31
|
+
```typescript
|
|
32
|
+
import { DataGrid } from "gridular/components/data-grid";
|
|
33
33
|
|
|
34
34
|
const MyComponent = () => {
|
|
35
35
|
const columns = [
|
|
36
|
-
{ id:
|
|
37
|
-
{ id:
|
|
36
|
+
{ id: "name", header: "Name" },
|
|
37
|
+
{ id: "age", header: "Age" },
|
|
38
38
|
// Add more columns as needed
|
|
39
39
|
];
|
|
40
40
|
|
|
41
41
|
const data = [
|
|
42
|
-
{ id: 1, name:
|
|
43
|
-
{ id: 2, name:
|
|
42
|
+
{ id: 1, name: "John Doe", age: 28 },
|
|
43
|
+
{ id: 2, name: "Jane Smith", age: 34 },
|
|
44
44
|
// Add more data as needed
|
|
45
45
|
];
|
|
46
46
|
|
|
@@ -57,16 +57,70 @@ const MyComponent = () => {
|
|
|
57
57
|
- **TableCell**: Represents individual cells in the data grid.
|
|
58
58
|
- **TableHeader**: Renders the header of the data grid.
|
|
59
59
|
- **TableRow**: Represents individual rows in the data grid.
|
|
60
|
+
- **ColumnManager**: Manages column visibility and order.
|
|
60
61
|
|
|
61
62
|
## Custom Hooks
|
|
62
63
|
|
|
63
|
-
Gridular
|
|
64
|
+
Gridular provides custom hooks for managing various functionalities:
|
|
64
65
|
|
|
65
66
|
- **useColumnResize**: For managing column resizing.
|
|
66
|
-
- **
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
- **useGridPersistence**: For persisting grid preferences like - \*\*column widths and order.
|
|
68
|
+
|
|
69
|
+
## Utility Functions
|
|
70
|
+
|
|
71
|
+
Gridular provides several utility functions to help with styling and component customization:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
cn(...inputs: ClassValue[])
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A utility function that combines multiple class names or conditional class expressions using clsx and tailwind-merge. This helps avoid className conflicts when using Tailwind CSS.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { cn } from "gridular";
|
|
81
|
+
|
|
82
|
+
// Usage
|
|
83
|
+
<div
|
|
84
|
+
className={cn(
|
|
85
|
+
"base-class",
|
|
86
|
+
isActive && "active-class",
|
|
87
|
+
isFocused ? "focused-class" : "unfocused-class"
|
|
88
|
+
)}
|
|
89
|
+
>
|
|
90
|
+
Content
|
|
91
|
+
</div>;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
mergeStyles(tssStyles, tailwindClasses);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Combines TSS-React style objects with Tailwind CSS classes, making it easier to integrate both styling approaches.
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { mergeStyles } from "gridular";
|
|
102
|
+
|
|
103
|
+
// Usage
|
|
104
|
+
const styles = mergeStyles(
|
|
105
|
+
{ color: "#000", backgroundColor: "#fff" },
|
|
106
|
+
"p-4 rounded-md hover:bg-gray-100"
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
<div {...styles}>Content</div>;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Parameters:
|
|
113
|
+
|
|
114
|
+
-- tssStyles: A TSS-React style object (CSSObject)
|
|
115
|
+
-- tailwindClasses: A string or array of strings containing -- Tailwind class names Returns an object with merged styles that can be spread into React components.
|
|
116
|
+
|
|
117
|
+
## Theming
|
|
118
|
+
|
|
119
|
+
Gridular includes a built-in theme provider that allows you to customize the appearance of your data grids:
|
|
120
|
+
|
|
121
|
+
-- ThemeProvider: Context provider for styling your data grids.
|
|
122
|
+
-- ThemeSwitcher: Component for toggling between light and dark themes.
|
|
123
|
+
-- ThemeWrapper: Utility component for wrapping your components with theme context.
|
|
70
124
|
|
|
71
125
|
## Contributing
|
|
72
126
|
|
|
@@ -74,4 +128,4 @@ Contributions are welcome! Please open an issue or submit a pull request for any
|
|
|
74
128
|
|
|
75
129
|
## License
|
|
76
130
|
|
|
77
|
-
This project is licensed under the MIT License. See the LICENSE file for details.
|
|
131
|
+
This project is licensed under the MIT License. See the LICENSE file for details.
|