@mdspl/mds-shared-ui 0.4.5 โ 0.4.7
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 +264 -58
- package/dist/index.cjs +3 -3
- package/dist/index.js +942 -952
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,73 +1,279 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ๐งฉ MDS DataTable
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A **headless-friendly, Chakra-styled, TanStack-powered data table** built for **real admin panels**, not toy demos.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This table is designed for **production dashboards** where you need:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
* stable layouts
|
|
8
|
+
* column control
|
|
9
|
+
* client/server pagination
|
|
10
|
+
* loading + skeleton states
|
|
11
|
+
* drag-reorderable headers
|
|
12
|
+
* zero dependency on heavy table engines
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
> Built with **React, Chakra UI, TanStack Store, DnD Kit**.
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
---
|
|
13
17
|
|
|
14
|
-
##
|
|
18
|
+
## โจ Features
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
### Core
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
* โ
Fully typed (`<DataTable<T>>`)
|
|
23
|
+
* โ
Client & server pagination
|
|
24
|
+
* โ
Column sorting (asc / desc)
|
|
25
|
+
* โ
Persistent column order (per table)
|
|
26
|
+
* โ
Column visibility toggle
|
|
27
|
+
* โ
Action column support
|
|
28
|
+
* โ
Sticky headers
|
|
29
|
+
* โ
Density control (`sm | md | lg`)
|
|
30
|
+
|
|
31
|
+
### UX & States
|
|
32
|
+
|
|
33
|
+
* โ
Centered loading spinner (table-safe)
|
|
34
|
+
* โ
Skeleton rows (layout-accurate)
|
|
35
|
+
* โ
Empty state handling
|
|
36
|
+
* โ
No layout jump during loading
|
|
37
|
+
* โ
Header always visible
|
|
38
|
+
|
|
39
|
+
### Advanced
|
|
40
|
+
|
|
41
|
+
* ๐ Drag & drop column reordering
|
|
42
|
+
* ๐พ Column order persisted via `localStorage`
|
|
43
|
+
* ๐ง Derived selectors (no duplicated logic)
|
|
44
|
+
* ๐งฑ Table-aware skeletons (not fake divs)
|
|
45
|
+
* โก Powered by `@tanstack/store` (lightweight & fast)
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## ๐งฑ Architecture
|
|
50
|
+
|
|
51
|
+
This table **does not rely on heavy table engines**.
|
|
52
|
+
|
|
53
|
+
Instead:
|
|
54
|
+
|
|
55
|
+
* **Store** โ holds raw state
|
|
56
|
+
* **Selectors** โ derive visible/sorted columns
|
|
57
|
+
* **Components** โ render only what they should
|
|
58
|
+
|
|
59
|
+
This keeps:
|
|
60
|
+
|
|
61
|
+
* logic reusable
|
|
62
|
+
* rendering predictable
|
|
63
|
+
* performance stable on large datasets
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## ๐ฆ Installation
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm install @chakra-ui/react @tanstack/react-store @dnd-kit/core @dnd-kit/sortable
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> Chakra UI is required.
|
|
74
|
+
> This library is designed to **embrace Chakra**, not fight it.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## ๐ Basic Usage
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<DataTable
|
|
82
|
+
tableId="users-table"
|
|
83
|
+
headers={headers}
|
|
84
|
+
data={data}
|
|
85
|
+
page={page}
|
|
86
|
+
pageSize={pageSize}
|
|
87
|
+
totalCount={data.length}
|
|
88
|
+
onPageChange={setPage}
|
|
89
|
+
onPageSizeChange={setPageSize}
|
|
90
|
+
/>
|
|
44
91
|
```
|
|
45
92
|
|
|
46
|
-
|
|
93
|
+
---
|
|
47
94
|
|
|
48
|
-
|
|
49
|
-
// eslint.config.js
|
|
50
|
-
import reactX from 'eslint-plugin-react-x'
|
|
51
|
-
import reactDom from 'eslint-plugin-react-dom'
|
|
95
|
+
## ๐งฉ Column Definition
|
|
52
96
|
|
|
53
|
-
|
|
54
|
-
|
|
97
|
+
```ts
|
|
98
|
+
const headers = [
|
|
99
|
+
{ id: 'id', label: 'ID' },
|
|
100
|
+
{ id: 'name', label: 'User Name', backgroundColor: 'orange.400' },
|
|
101
|
+
{ id: 'email', label: 'Email' },
|
|
102
|
+
{ id: 'role', label: 'Role' },
|
|
103
|
+
];
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Supported column features
|
|
107
|
+
|
|
108
|
+
* alignment
|
|
109
|
+
* background color
|
|
110
|
+
* custom formatters
|
|
111
|
+
* sortable toggle
|
|
112
|
+
* width control
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## โ๏ธ Actions Column
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
actions={[
|
|
55
120
|
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
reactX.configs['recommended-typescript'],
|
|
61
|
-
// Enable lint rules for React DOM
|
|
62
|
-
reactDom.configs.recommended,
|
|
63
|
-
],
|
|
64
|
-
languageOptions: {
|
|
65
|
-
parserOptions: {
|
|
66
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
-
tsconfigRootDir: import.meta.dirname,
|
|
68
|
-
},
|
|
69
|
-
// other options...
|
|
70
|
-
},
|
|
121
|
+
icon: <Edit size={14} />,
|
|
122
|
+
label: 'Edit',
|
|
123
|
+
onClick: (row) => console.log(row),
|
|
124
|
+
colorScheme: 'blue',
|
|
71
125
|
},
|
|
72
|
-
|
|
126
|
+
{
|
|
127
|
+
icon: <Trash size={14} />,
|
|
128
|
+
label: 'Delete',
|
|
129
|
+
onClick: () => setOpen(true),
|
|
130
|
+
colorScheme: 'red',
|
|
131
|
+
},
|
|
132
|
+
]}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
โ Sticky
|
|
136
|
+
โ Optional
|
|
137
|
+
โ Fully configurable
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## โณ Loading States
|
|
142
|
+
|
|
143
|
+
### Blocking loading (spinner)
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
<DataTable
|
|
147
|
+
loading
|
|
148
|
+
loadingChildren={<Spinner size="sm" />}
|
|
149
|
+
/>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
* Spinner is **perfectly centered**
|
|
153
|
+
* Header remains visible
|
|
154
|
+
* Pagination remains stable
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
### Skeleton loading (background fetch)
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
<DataTable
|
|
162
|
+
skeletonLoading
|
|
163
|
+
/>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
* Skeleton rows align with real columns
|
|
167
|
+
* Uses `<Table.Row>` / `<Table.Cell>`
|
|
168
|
+
* No layout mismatch
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## ๐ญ Empty State
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
<DataTable
|
|
176
|
+
data={[]}
|
|
177
|
+
emptyMessage="No records found"
|
|
178
|
+
/>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Centered, accessible, and table-safe.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## ๐ Pagination Modes
|
|
186
|
+
|
|
187
|
+
### Client-side
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
paginationMode="client"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Server-side
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
paginationMode="server"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
You fully control data fetching.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## ๐ง Filters Integration (Optional)
|
|
204
|
+
|
|
205
|
+
The table plays nicely with external toolbars:
|
|
206
|
+
|
|
207
|
+
* reorderable filters
|
|
208
|
+
* saved presets
|
|
209
|
+
* controlled visibility
|
|
210
|
+
* size-aware layout
|
|
211
|
+
|
|
212
|
+
Example shown using `FiltersToolBar`.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## ๐งช Types (Fully Typed)
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
DataTableProps<T>
|
|
220
|
+
Column<T>
|
|
221
|
+
DataTableAction<T>
|
|
222
|
+
ActionHeaderProps
|
|
73
223
|
```
|
|
224
|
+
|
|
225
|
+
Everything is typed.
|
|
226
|
+
No `any` leaks.
|
|
227
|
+
No guessing.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## ๐ฏ Design Philosophy
|
|
232
|
+
|
|
233
|
+
This table is built for:
|
|
234
|
+
|
|
235
|
+
* admin panels
|
|
236
|
+
* analytics dashboards
|
|
237
|
+
* internal tools
|
|
238
|
+
* B2B SaaS products
|
|
239
|
+
|
|
240
|
+
**Not** for:
|
|
241
|
+
|
|
242
|
+
* marketing pages
|
|
243
|
+
* static lists
|
|
244
|
+
* low-control UI kits
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## ๐ฃ Roadmap
|
|
249
|
+
|
|
250
|
+
* [ ] Column resizing
|
|
251
|
+
* [ ] Row selection
|
|
252
|
+
* [ ] Virtualized rows
|
|
253
|
+
* [ ] Export (CSV / Excel)
|
|
254
|
+
* [ ] Preset column layouts
|
|
255
|
+
* [ ] Server-side sorting helpers
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## ๐งโ๐ป Author
|
|
260
|
+
|
|
261
|
+
Built by **Raj Purkait**
|
|
262
|
+
Full-stack engineer focused on **performance-first UI systems**.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## ๐ License
|
|
267
|
+
|
|
268
|
+
MIT โ free, open-source, forever.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
If you want, next I can:
|
|
273
|
+
|
|
274
|
+
* tighten this README for npm
|
|
275
|
+
* add architecture diagrams
|
|
276
|
+
* write contribution guidelines
|
|
277
|
+
* extract this into a mono-repo-ready package
|
|
278
|
+
|
|
279
|
+
Just say the word.
|