@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 CHANGED
@@ -1,73 +1,279 @@
1
- # React + TypeScript + Vite
1
+ # ๐Ÿงฉ MDS DataTable
2
2
 
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3
+ A **headless-friendly, Chakra-styled, TanStack-powered data table** built for **real admin panels**, not toy demos.
4
4
 
5
- Currently, two official plugins are available:
5
+ This table is designed for **production dashboards** where you need:
6
6
 
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
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
- ## React Compiler
14
+ > Built with **React, Chakra UI, TanStack Store, DnD Kit**.
11
15
 
12
- The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
16
+ ---
13
17
 
14
- ## Expanding the ESLint configuration
18
+ ## โœจ Features
15
19
 
16
- If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
20
+ ### Core
17
21
 
18
- ```js
19
- export default defineConfig([
20
- globalIgnores(['dist']),
21
- {
22
- files: ['**/*.{ts,tsx}'],
23
- extends: [
24
- // Other configs...
25
-
26
- // Remove tseslint.configs.recommended and replace with this
27
- tseslint.configs.recommendedTypeChecked,
28
- // Alternatively, use this for stricter rules
29
- tseslint.configs.strictTypeChecked,
30
- // Optionally, add this for stylistic rules
31
- tseslint.configs.stylisticTypeChecked,
32
-
33
- // Other configs...
34
- ],
35
- languageOptions: {
36
- parserOptions: {
37
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
- tsconfigRootDir: import.meta.dirname,
39
- },
40
- // other options...
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
- You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
93
+ ---
47
94
 
48
- ```js
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
- export default defineConfig([
54
- globalIgnores(['dist']),
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
- files: ['**/*.{ts,tsx}'],
57
- extends: [
58
- // Other configs...
59
- // Enable lint rules for React
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.