@blackpurl/bp-react-components 1.0.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 +384 -0
- package/dist/index.js +26286 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
# BP React Components
|
|
2
|
+
|
|
3
|
+
A reusable React-based table component system built with:
|
|
4
|
+
|
|
5
|
+
- React (Vite)
|
|
6
|
+
- MUI (Material UI)
|
|
7
|
+
- Minimal template
|
|
8
|
+
- TanStack React Table
|
|
9
|
+
- dnd-kit (column drag & drop)
|
|
10
|
+
- Storybook for component development
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Getting Started
|
|
15
|
+
|
|
16
|
+
### 1. Clone the repository
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
git clone <your-repository-url>
|
|
20
|
+
cd bp-react-component
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 2. Install dependencies
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Run the Application
|
|
32
|
+
|
|
33
|
+
Start the development server:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm run dev
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Open in browser:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
http://localhost:5173
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Run Storybook
|
|
48
|
+
|
|
49
|
+
Start Storybook:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm run storybook
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Open in browser:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
http://localhost:6006
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Project Structure
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
src
|
|
67
|
+
│ ├── components
|
|
68
|
+
│ │
|
|
69
|
+
│ │ ├── BPTable
|
|
70
|
+
│ │ │
|
|
71
|
+
│ │ │ ├── components
|
|
72
|
+
│ │ │ │ └── dataGridTable
|
|
73
|
+
│ │ │ │ ├── grid-table-row.jsx # Row rendering logic for DataGrid table
|
|
74
|
+
│ │ │ │ ├── list-view.jsx # Main table view component
|
|
75
|
+
│ │ │ │ ├── sortable-header.jsx # Drag-and-drop column header component
|
|
76
|
+
│ │ │ │ ├── status-tabs-grouping.jsx # Status based tab grouping for table data
|
|
77
|
+
│ │ │ │ ├── table-data-grid-filter-drawer.jsx # Drawer component for table filters
|
|
78
|
+
│ │ │ │ ├── table-filters.jsx # Filter UI for DataGrid table
|
|
79
|
+
│ │ │ │ ├── table-filters-result.jsx # Selected filter results display
|
|
80
|
+
│ │ │ │ └── table-header-dnd.jsx # Drag-and-drop logic for table headers
|
|
81
|
+
│ │ │
|
|
82
|
+
│ │ │ ├── utils # Utility/helper functions for BPTable
|
|
83
|
+
│ │ │
|
|
84
|
+
│ │ │ ├── BPTable.stories.jsx # Storybook configuration for table component
|
|
85
|
+
│ │ │ ├── cellRenderers.jsx # Custom cell rendering logic
|
|
86
|
+
│ │ │ ├── columns.js # Column configuration definitions
|
|
87
|
+
│ │ │ ├── index.jsx # BPTable main export
|
|
88
|
+
│ │ │ └── mockData.js # Sample/mock data for development and Storybook
|
|
89
|
+
│ │
|
|
90
|
+
│ │ ├── custom-dialog # Reusable dialog component
|
|
91
|
+
│ │ ├── custom-popover # Reusable popover component
|
|
92
|
+
│ │ ├── empty-content # Empty state component
|
|
93
|
+
│ │ ├── filters-result # Filter result display components
|
|
94
|
+
│ │ ├── iconify # Icon wrapper component
|
|
95
|
+
│ │ ├── label # Label UI components
|
|
96
|
+
│ │ └── snackbar # Snackbar / notification component
|
|
97
|
+
│ │
|
|
98
|
+
│ └── stories # Additional Storybook stories
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Theme
|
|
105
|
+
|
|
106
|
+
BPTable comes with a built-in Minimal UI theme.
|
|
107
|
+
No additional theme setup is required from the application side.
|
|
108
|
+
|
|
109
|
+
The application uses a custom MUI theme wrapped inside:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
src/theme/theme-wrapper.jsx
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Storybook is configured to use the same theme via:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
.storybook/preview.jsx
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Features
|
|
124
|
+
|
|
125
|
+
- Column drag & drop
|
|
126
|
+
- Column resizing
|
|
127
|
+
- Column visibility toggle
|
|
128
|
+
- Row selection (controlled & uncontrolled)
|
|
129
|
+
- Global search
|
|
130
|
+
- Column filters (Drawer with accordion groups)
|
|
131
|
+
- Grouping support
|
|
132
|
+
- Pagination
|
|
133
|
+
- Fully theme-aware UI
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Development Notes
|
|
138
|
+
|
|
139
|
+
- The project uses Vite.
|
|
140
|
+
- JSX files must use the `.jsx` extension.
|
|
141
|
+
- Storybook preview file must also be `.jsx` if JSX is used.
|
|
142
|
+
- Theme is applied globally using `ThemeWrapper`.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 📦 Installation
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npm install bp-react-components
|
|
150
|
+
```
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 🔗 Peer Dependencies
|
|
154
|
+
|
|
155
|
+
Make sure these are installed in your application:
|
|
156
|
+
```bash
|
|
157
|
+
npm install @mui/material @mui/x-data-grid react react-dom
|
|
158
|
+
```
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
# 📦 Component Usage (BPTable)
|
|
162
|
+
|
|
163
|
+
## Basic Example
|
|
164
|
+
|
|
165
|
+
```jsx
|
|
166
|
+
import BPTable from 'bp-react-components';
|
|
167
|
+
|
|
168
|
+
<BPTable
|
|
169
|
+
data={data}
|
|
170
|
+
columns={columns}
|
|
171
|
+
getRowId={(row) => row.id}
|
|
172
|
+
/>
|
|
173
|
+
|
|
174
|
+
## ⚙️ Props
|
|
175
|
+
|
|
176
|
+
| Prop | Type | Default | Description |
|
|
177
|
+
|--------------------------|----------|--------------|-------------------------------------|
|
|
178
|
+
| data | array | [] | Table data |
|
|
179
|
+
| columns | array | [] | Column configuration |
|
|
180
|
+
| getRowId | function | required | Unique row identifier |
|
|
181
|
+
| isLoading | boolean | false | Show loading state |
|
|
182
|
+
| enablePagination | boolean | true | Enable pagination |
|
|
183
|
+
| enableGrouping | boolean | false | Enable tab grouping |
|
|
184
|
+
| enableRowSelection | boolean | false | Enable checkbox selection |
|
|
185
|
+
| enableColumnSorting | boolean | true | Enable sorting |
|
|
186
|
+
| enableColumnResize | boolean | false | Enable column resizing |
|
|
187
|
+
| enableColumnReorder | boolean | false | Enable drag & drop |
|
|
188
|
+
| enableColumnVisibility | boolean | false | Toggle column visibility |
|
|
189
|
+
| enableColumnFilters | boolean | true | Enable filter drawer |
|
|
190
|
+
| enableGlobalFilter | boolean | true | Enable global search |
|
|
191
|
+
| enableDensityToggle | boolean | false | Toggle row density |
|
|
192
|
+
| storageKey | string | undefined | Enable local storage persistence |
|
|
193
|
+
| selectedRows | array | [] | Selected row IDs |
|
|
194
|
+
| onSelectedRowsChange | function | undefined | Selection change handler |
|
|
195
|
+
| onRowClick | function | undefined | Row click handler |
|
|
196
|
+
| rowActions | function | undefined | Dynamic row actions |
|
|
197
|
+
| dateFormatter | function | undefined | Custom date formatting |
|
|
198
|
+
| currency | string | 'USD' | Currency code |
|
|
199
|
+
| locale | string | 'en-US' | Locale |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 🧱 Column Configuration
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
const columns = [
|
|
207
|
+
{
|
|
208
|
+
accessorKey: 'DealStatus',
|
|
209
|
+
header: 'Deal Status',
|
|
210
|
+
type: 'Label',
|
|
211
|
+
isFilterable: true,
|
|
212
|
+
},
|
|
213
|
+
];
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 🎨 Supported Column Types
|
|
219
|
+
|
|
220
|
+
| Type | Description |
|
|
221
|
+
| ------- | -------------------- |
|
|
222
|
+
| Label | Status label |
|
|
223
|
+
| Date | Date + time display |
|
|
224
|
+
| Amount | Currency formatting |
|
|
225
|
+
| Avatar | Avatar / AvatarGroup |
|
|
226
|
+
| Number | Numeric value |
|
|
227
|
+
| Boolean | Yes / No |
|
|
228
|
+
| Rating | Star rating |
|
|
229
|
+
| Action | Row actions |
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## 📅 Date Formatting
|
|
234
|
+
|
|
235
|
+
Pass custom formatter from application:
|
|
236
|
+
|
|
237
|
+
```jsx
|
|
238
|
+
<BPTable
|
|
239
|
+
dateFormatter={(value) =>
|
|
240
|
+
moment(value).format('DD MMM YYYY')
|
|
241
|
+
}
|
|
242
|
+
/>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## 💰 Currency Formatting
|
|
248
|
+
|
|
249
|
+
```jsx
|
|
250
|
+
<BPTable
|
|
251
|
+
currency="USD"
|
|
252
|
+
locale="en-US"
|
|
253
|
+
/>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## ⚡ Row Actions
|
|
259
|
+
|
|
260
|
+
```javascript
|
|
261
|
+
const getRowActions = (row) => [
|
|
262
|
+
{
|
|
263
|
+
type: 'icon',
|
|
264
|
+
icon: 'solar:eye-bold',
|
|
265
|
+
label: 'View',
|
|
266
|
+
onClick: () => handleView(row),
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
type: 'button',
|
|
270
|
+
label: 'Edit',
|
|
271
|
+
variant: 'contained',
|
|
272
|
+
onClick: () => handleEdit(row),
|
|
273
|
+
},
|
|
274
|
+
];
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
```jsx
|
|
278
|
+
<BPTable rowActions={getRowActions} />
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 🏷️ Custom Cell Renderer
|
|
284
|
+
|
|
285
|
+
```javascript
|
|
286
|
+
{
|
|
287
|
+
accessorKey: 'DealStatus',
|
|
288
|
+
type: 'Label',
|
|
289
|
+
cellRenderer: (value) => <Label>{value}</Label>
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## 👤 Avatar Customization
|
|
296
|
+
|
|
297
|
+
```javascript
|
|
298
|
+
{
|
|
299
|
+
accessorKey: 'SalespersonNames',
|
|
300
|
+
type: 'Avatar',
|
|
301
|
+
getAvatarProps: (name) => ({
|
|
302
|
+
sx: { bgcolor: getColor(name) },
|
|
303
|
+
children: name[0]
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## 🔍 Filtering
|
|
311
|
+
|
|
312
|
+
* Global search supported
|
|
313
|
+
* Column-based filtering
|
|
314
|
+
* Dynamic filter drawer (based on `isFilterable`)
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## 📦 Persistence
|
|
319
|
+
|
|
320
|
+
Enable local storage:
|
|
321
|
+
|
|
322
|
+
```jsx
|
|
323
|
+
<BPTable storageKey="my-table" />
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Automatically persists:
|
|
327
|
+
|
|
328
|
+
* Pagination
|
|
329
|
+
* Filters
|
|
330
|
+
* Column order
|
|
331
|
+
* Column visibility
|
|
332
|
+
* Density
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## 🎯 Row Click Handling
|
|
337
|
+
|
|
338
|
+
```jsx
|
|
339
|
+
<BPTable
|
|
340
|
+
onRowClick={(row) => {
|
|
341
|
+
console.log('Clicked:', row);
|
|
342
|
+
}}
|
|
343
|
+
/>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## 🎨 Styling & Theme
|
|
349
|
+
|
|
350
|
+
* Uses Minimal UI theme internally
|
|
351
|
+
* Fully isolated using Emotion cache
|
|
352
|
+
* Works alongside external application themes
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## 📖 Storybook (Recommended)
|
|
357
|
+
|
|
358
|
+
👉 View full interactive documentation:
|
|
359
|
+
|
|
360
|
+
**[Add your Chromatic link here]**
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## ⚠️ Notes
|
|
365
|
+
|
|
366
|
+
* Column widths are configurable (`size`, `minSize`, `maxSize`)
|
|
367
|
+
* Supports dynamic rendering from application side
|
|
368
|
+
* Avoid overriding internal styles unless necessary
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## 🧑💻 Development
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
npm install
|
|
376
|
+
npm run dev
|
|
377
|
+
npm run build
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## 📜 License
|
|
383
|
+
|
|
384
|
+
Internal use only (Blackpurl)
|