mui-universal-table 1.0.1
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 +21 -0
- package/README.md +159 -0
- package/dist/index.esm.js +1134 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1139 -0
- package/dist/index.js.map +1 -0
- package/package.json +99 -0
- package/src/index.d.ts +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Skulldorom
|
|
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,159 @@
|
|
|
1
|
+
# MUI Universal Table
|
|
2
|
+
|
|
3
|
+
A comprehensive, feature-rich table component built with Material-UI for React applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔍 **Built-in Search** - Filter data across searchable columns
|
|
8
|
+
- 📄 **Pagination** - Handle large datasets with customizable page sizes
|
|
9
|
+
- 🔄 **Sorting** - Sort by any column with visual indicators
|
|
10
|
+
- ✅ **Row Selection** - Single or multiple row selection with checkboxes
|
|
11
|
+
- 📊 **Sub-tables** - Expandable nested tables for hierarchical data
|
|
12
|
+
- 🎨 **Customizable** - Extensive styling and behavior customization
|
|
13
|
+
- ⚡ **Performance** - Optimized for large datasets with lazy loading support
|
|
14
|
+
- 🔄 **Refresh** - Built-in reload functionality
|
|
15
|
+
- 📱 **Responsive** - Mobile-friendly design
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install mui-universale-table
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Peer Dependencies
|
|
24
|
+
|
|
25
|
+
Make sure you have these peer dependencies installed:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material prop-types
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Basic Usage
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
import React from "react";
|
|
35
|
+
import { UniversalTable } from "mui-universale-table";
|
|
36
|
+
|
|
37
|
+
const headers = [
|
|
38
|
+
{ id: "name", label: "Name", searchable: true },
|
|
39
|
+
{ id: "email", label: "Email", searchable: true },
|
|
40
|
+
{ id: "age", label: "Age", numeric: true },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const data = [
|
|
44
|
+
{ name: "John Doe", email: "john@example.com", age: 30 },
|
|
45
|
+
{ name: "Jane Smith", email: "jane@example.com", age: 25 },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
function MyTable() {
|
|
49
|
+
const [loading, setLoading] = React.useState(false);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<UniversalTable
|
|
53
|
+
data={data}
|
|
54
|
+
headers={headers}
|
|
55
|
+
name="Users"
|
|
56
|
+
loading={loading}
|
|
57
|
+
setLoading={setLoading}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Props
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
| ------------------ | --------- | ------------ | -------------------------------------------------- |
|
|
67
|
+
| `data` | `array` | **required** | Array of data objects to display |
|
|
68
|
+
| `headers` | `array` | **required** | Array of header configuration objects |
|
|
69
|
+
| `name` | `string` | - | Table title |
|
|
70
|
+
| `loading` | `bool` | `false` | Shows loading state |
|
|
71
|
+
| `setLoading` | `func` | - | Function to control loading state |
|
|
72
|
+
| `selectRows` | `bool` | `false` | Enable row selection |
|
|
73
|
+
| `selectID` | `string` | - | Property to use as unique identifier for selection |
|
|
74
|
+
| `onSelection` | `func` | - | Callback when rows are selected |
|
|
75
|
+
| `subTable` | `bool` | `false` | Whether this is a nested sub-table |
|
|
76
|
+
| `hideBadge` | `bool` | `false` | Hide badges on expandable rows |
|
|
77
|
+
| `reloadBtnLoading` | `bool` | `false` | Loading state for reload button |
|
|
78
|
+
| `lazyloading` | `bool` | `false` | Enable lazy loading indicator |
|
|
79
|
+
| `currentPage` | `number` | - | Current page for lazy loading |
|
|
80
|
+
| `totalPages` | `number` | - | Total pages for lazy loading |
|
|
81
|
+
| `selectIcon` | `element` | - | Custom icon for selection action |
|
|
82
|
+
|
|
83
|
+
## Header Configuration
|
|
84
|
+
|
|
85
|
+
Each header object can have the following properties:
|
|
86
|
+
|
|
87
|
+
| Property | Type | Description |
|
|
88
|
+
| ------------ | --------- | -------------------------------------------------------- |
|
|
89
|
+
| `id` | `string` | **Required** - Column identifier (matches data property) |
|
|
90
|
+
| `label` | `string` | **Required** - Display label for column |
|
|
91
|
+
| `searchable` | `bool` | Whether this column is searchable |
|
|
92
|
+
| `numeric` | `bool` | Right-align column for numeric data |
|
|
93
|
+
| `date` | `bool` | Format as date/time |
|
|
94
|
+
| `component` | `func` | Custom render function `(rowData) => ReactElement` |
|
|
95
|
+
| `cellProps` | `object` | Additional props for table cells |
|
|
96
|
+
| `subRow` | `bool` | Column contains expandable sub-table data |
|
|
97
|
+
| `iconColor` | `string` | Color for expand/collapse icons |
|
|
98
|
+
| `openIcon` | `element` | Custom icon for expanding |
|
|
99
|
+
| `closeIcon` | `element` | Custom icon for collapsing |
|
|
100
|
+
|
|
101
|
+
## Advanced Examples
|
|
102
|
+
|
|
103
|
+
### With Row Selection
|
|
104
|
+
|
|
105
|
+
```jsx
|
|
106
|
+
<UniversalTable
|
|
107
|
+
data={data}
|
|
108
|
+
headers={headers}
|
|
109
|
+
name="Selectable Users"
|
|
110
|
+
selectRows={true}
|
|
111
|
+
selectID="id"
|
|
112
|
+
onSelection={(selectedIds) => {
|
|
113
|
+
console.log("Selected:", selectedIds);
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### With Custom Cell Rendering
|
|
119
|
+
|
|
120
|
+
```jsx
|
|
121
|
+
const headers = [
|
|
122
|
+
{ id: "name", label: "Name", searchable: true },
|
|
123
|
+
{
|
|
124
|
+
id: "status",
|
|
125
|
+
label: "Status",
|
|
126
|
+
component: (row) => (
|
|
127
|
+
<Chip
|
|
128
|
+
label={row.status}
|
|
129
|
+
color={row.status === "active" ? "success" : "default"}
|
|
130
|
+
/>
|
|
131
|
+
),
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### With Sub-tables
|
|
137
|
+
|
|
138
|
+
```jsx
|
|
139
|
+
const headers = [
|
|
140
|
+
{ id: "name", label: "Department", searchable: true },
|
|
141
|
+
{
|
|
142
|
+
id: "employees",
|
|
143
|
+
label: "Employees",
|
|
144
|
+
subRow: true,
|
|
145
|
+
headers: [
|
|
146
|
+
{ id: "name", label: "Employee Name", searchable: true },
|
|
147
|
+
{ id: "role", label: "Role" },
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|
|
156
|
+
|
|
157
|
+
## Contributing
|
|
158
|
+
|
|
159
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|