@blackpurl/bp-react-components 1.0.2 → 1.0.3
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 +123 -79
- package/dist/index.js +953 -953
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# BP React Components
|
|
2
2
|
|
|
3
|
+
## 🔗 Repository
|
|
4
|
+
|
|
5
|
+
GitHub: https://github.com/black-purl/bp-react-component
|
|
6
|
+
|
|
3
7
|
A reusable React-based table component system built with:
|
|
4
8
|
|
|
5
9
|
- React (Vite)
|
|
@@ -16,7 +20,7 @@ A reusable React-based table component system built with:
|
|
|
16
20
|
### 1. Clone the repository
|
|
17
21
|
|
|
18
22
|
```bash
|
|
19
|
-
git clone
|
|
23
|
+
git clone https://github.com/black-purl/bp-react-component
|
|
20
24
|
cd bp-react-component
|
|
21
25
|
```
|
|
22
26
|
|
|
@@ -127,10 +131,11 @@ Storybook is configured to use the same theme via:
|
|
|
127
131
|
- Column visibility toggle
|
|
128
132
|
- Row selection (controlled & uncontrolled)
|
|
129
133
|
- Global search
|
|
130
|
-
- Column filters (
|
|
134
|
+
- Column filters (Controlled via filterGroups)
|
|
131
135
|
- Grouping support
|
|
132
136
|
- Pagination
|
|
133
137
|
- Fully theme-aware UI
|
|
138
|
+
- Sorting (default + dynamic)
|
|
134
139
|
|
|
135
140
|
---
|
|
136
141
|
|
|
@@ -146,16 +151,19 @@ Storybook is configured to use the same theme via:
|
|
|
146
151
|
## 📦 Installation
|
|
147
152
|
|
|
148
153
|
```bash
|
|
149
|
-
npm install bp-react-components
|
|
154
|
+
npm install @blackpurl/bp-react-components
|
|
150
155
|
```
|
|
156
|
+
|
|
151
157
|
---
|
|
152
158
|
|
|
153
159
|
## 🔗 Peer Dependencies
|
|
154
160
|
|
|
155
161
|
Make sure these are installed in your application:
|
|
162
|
+
|
|
156
163
|
```bash
|
|
157
164
|
npm install @mui/material @mui/x-data-grid react react-dom
|
|
158
165
|
```
|
|
166
|
+
|
|
159
167
|
---
|
|
160
168
|
|
|
161
169
|
# 📦 Component Usage (BPTable)
|
|
@@ -163,40 +171,65 @@ npm install @mui/material @mui/x-data-grid react react-dom
|
|
|
163
171
|
## Basic Example
|
|
164
172
|
|
|
165
173
|
```jsx
|
|
166
|
-
import BPTable from 'bp-react-components';
|
|
174
|
+
import BPTable from '@blackpurl/bp-react-components';
|
|
167
175
|
|
|
168
|
-
<BPTable
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
<BPTable data={data} columns={columns} getRowId={(row) => row.id} />;
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 🔍 Filters (Controlled)
|
|
182
|
+
|
|
183
|
+
BPTable supports dynamic filter generation based on column configuration.
|
|
184
|
+
|
|
185
|
+
Filters are controlled via `filterGroups` and `onFilterChange`.
|
|
186
|
+
|
|
187
|
+
### Example
|
|
188
|
+
|
|
189
|
+
```jsx
|
|
190
|
+
const [filters, setFilters] = useState(generateFilterGroupsFromData(data, columns));
|
|
191
|
+
|
|
192
|
+
<BPTable data={data} columns={columns} filterGroups={filters} onFilterChange={setFilters} />;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 🔃 Sorting
|
|
198
|
+
|
|
199
|
+
Default sorting can be applied using:
|
|
200
|
+
|
|
201
|
+
```jsx
|
|
202
|
+
<BPTable defaultSortModel={[{ field: 'OrderNumber', sort: 'asc' }]} />
|
|
203
|
+
```
|
|
173
204
|
|
|
174
205
|
## ⚙️ Props
|
|
175
206
|
|
|
176
|
-
| Prop
|
|
177
|
-
|
|
178
|
-
| data
|
|
179
|
-
| columns
|
|
180
|
-
| getRowId
|
|
181
|
-
| isLoading
|
|
182
|
-
| enablePagination
|
|
183
|
-
| enableGrouping
|
|
184
|
-
| enableRowSelection
|
|
185
|
-
| enableColumnSorting
|
|
186
|
-
| enableColumnResize
|
|
187
|
-
| enableColumnReorder
|
|
188
|
-
| enableColumnVisibility
|
|
189
|
-
| enableColumnFilters
|
|
190
|
-
| enableGlobalFilter
|
|
191
|
-
| enableDensityToggle
|
|
192
|
-
| storageKey
|
|
193
|
-
| selectedRows
|
|
194
|
-
| onSelectedRowsChange
|
|
195
|
-
| onRowClick
|
|
196
|
-
| rowActions
|
|
197
|
-
|
|
|
198
|
-
|
|
|
199
|
-
|
|
|
207
|
+
| Prop | Type | Default | Description |
|
|
208
|
+
| ---------------------- | -------- | --------- | -------------------------------- |
|
|
209
|
+
| data | array | [] | Table data |
|
|
210
|
+
| columns | array | [] | Column configuration |
|
|
211
|
+
| getRowId | function | required | Unique row identifier |
|
|
212
|
+
| isLoading | boolean | false | Show loading state |
|
|
213
|
+
| enablePagination | boolean | true | Enable pagination |
|
|
214
|
+
| enableGrouping | boolean | false | Enable tab grouping |
|
|
215
|
+
| enableRowSelection | boolean | false | Enable checkbox selection |
|
|
216
|
+
| enableColumnSorting | boolean | true | Enable sorting |
|
|
217
|
+
| enableColumnResize | boolean | false | Enable column resizing |
|
|
218
|
+
| enableColumnReorder | boolean | false | Enable drag & drop |
|
|
219
|
+
| enableColumnVisibility | boolean | true | Toggle column visibility |
|
|
220
|
+
| enableColumnFilters | boolean | true | Enable filter drawer |
|
|
221
|
+
| enableGlobalFilter | boolean | true | Enable global search |
|
|
222
|
+
| enableDensityToggle | boolean | false | Toggle row density |
|
|
223
|
+
| storageKey | string | undefined | Enable local storage persistence |
|
|
224
|
+
| selectedRows | array | [] | Selected row IDs |
|
|
225
|
+
| onSelectedRowsChange | function | undefined | Selection change handler |
|
|
226
|
+
| onRowClick | function | undefined | Row click handler |
|
|
227
|
+
| rowActions | function | undefined | Dynamic row actions |
|
|
228
|
+
| headerActions | function | undefined | Dynamic tableheader actions |
|
|
229
|
+
| dateFormatter | function | undefined | Custom date formatting |
|
|
230
|
+
| currency | string | 'USD' | Currency code |
|
|
231
|
+
| locale | string | 'en-US' | Locale |
|
|
232
|
+
| defaultSortModel | array | [] | Default sorting configuration |
|
|
200
233
|
|
|
201
234
|
---
|
|
202
235
|
|
|
@@ -204,12 +237,12 @@ import BPTable from 'bp-react-components';
|
|
|
204
237
|
|
|
205
238
|
```javascript
|
|
206
239
|
const columns = [
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
240
|
+
{
|
|
241
|
+
accessorKey: 'DealStatus',
|
|
242
|
+
header: 'Deal Status',
|
|
243
|
+
type: 'Label',
|
|
244
|
+
isFilterable: true
|
|
245
|
+
}
|
|
213
246
|
];
|
|
214
247
|
```
|
|
215
248
|
|
|
@@ -235,11 +268,7 @@ const columns = [
|
|
|
235
268
|
Pass custom formatter from application:
|
|
236
269
|
|
|
237
270
|
```jsx
|
|
238
|
-
<BPTable
|
|
239
|
-
dateFormatter={(value) =>
|
|
240
|
-
moment(value).format('DD MMM YYYY')
|
|
241
|
-
}
|
|
242
|
-
/>
|
|
271
|
+
<BPTable dateFormatter={(value) => moment(value).format('DD MMM YYYY')} />
|
|
243
272
|
```
|
|
244
273
|
|
|
245
274
|
---
|
|
@@ -247,10 +276,7 @@ Pass custom formatter from application:
|
|
|
247
276
|
## 💰 Currency Formatting
|
|
248
277
|
|
|
249
278
|
```jsx
|
|
250
|
-
<BPTable
|
|
251
|
-
currency="USD"
|
|
252
|
-
locale="en-US"
|
|
253
|
-
/>
|
|
279
|
+
<BPTable currency='USD' locale='en-US' />
|
|
254
280
|
```
|
|
255
281
|
|
|
256
282
|
---
|
|
@@ -259,18 +285,18 @@ Pass custom formatter from application:
|
|
|
259
285
|
|
|
260
286
|
```javascript
|
|
261
287
|
const getRowActions = (row) => [
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
288
|
+
{
|
|
289
|
+
type: 'icon',
|
|
290
|
+
icon: <VisibilityOutlinedIcon />,
|
|
291
|
+
label: 'View',
|
|
292
|
+
onClick: () => handleView(row)
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
type: 'button',
|
|
296
|
+
label: 'Edit',
|
|
297
|
+
variant: 'contained',
|
|
298
|
+
onClick: () => handleEdit(row)
|
|
299
|
+
}
|
|
274
300
|
];
|
|
275
301
|
```
|
|
276
302
|
|
|
@@ -278,6 +304,24 @@ const getRowActions = (row) => [
|
|
|
278
304
|
<BPTable rowActions={getRowActions} />
|
|
279
305
|
```
|
|
280
306
|
|
|
307
|
+
## ⚡ Table Header Actions
|
|
308
|
+
|
|
309
|
+
```javascript
|
|
310
|
+
const headerActions = [
|
|
311
|
+
{
|
|
312
|
+
label: 'Add Vendor',
|
|
313
|
+
variant: 'contained',
|
|
314
|
+
color: 'primary',
|
|
315
|
+
isDisabled: !isPermitted,
|
|
316
|
+
icon: <StoreOutlined />,
|
|
317
|
+
onClick: handleAddVendorClick
|
|
318
|
+
}
|
|
319
|
+
];
|
|
320
|
+
```
|
|
321
|
+
```jsx
|
|
322
|
+
<BPTable headerActions={headerActions} />
|
|
323
|
+
```
|
|
324
|
+
|
|
281
325
|
---
|
|
282
326
|
|
|
283
327
|
## 🏷️ Custom Cell Renderer
|
|
@@ -309,9 +353,9 @@ const getRowActions = (row) => [
|
|
|
309
353
|
|
|
310
354
|
## 🔍 Filtering
|
|
311
355
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
356
|
+
- Global search supported
|
|
357
|
+
- Column-based filtering
|
|
358
|
+
- Dynamic filter drawer (based on `isFilterable`)
|
|
315
359
|
|
|
316
360
|
---
|
|
317
361
|
|
|
@@ -320,16 +364,16 @@ const getRowActions = (row) => [
|
|
|
320
364
|
Enable local storage:
|
|
321
365
|
|
|
322
366
|
```jsx
|
|
323
|
-
<BPTable storageKey=
|
|
367
|
+
<BPTable storageKey='my-table' />
|
|
324
368
|
```
|
|
325
369
|
|
|
326
370
|
Automatically persists:
|
|
327
371
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
372
|
+
- Pagination
|
|
373
|
+
- Filters
|
|
374
|
+
- Column order
|
|
375
|
+
- Column visibility
|
|
376
|
+
- Density
|
|
333
377
|
|
|
334
378
|
---
|
|
335
379
|
|
|
@@ -337,9 +381,9 @@ Automatically persists:
|
|
|
337
381
|
|
|
338
382
|
```jsx
|
|
339
383
|
<BPTable
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
384
|
+
onRowClick={(row) => {
|
|
385
|
+
console.log('Clicked:', row);
|
|
386
|
+
}}
|
|
343
387
|
/>
|
|
344
388
|
```
|
|
345
389
|
|
|
@@ -347,9 +391,9 @@ Automatically persists:
|
|
|
347
391
|
|
|
348
392
|
## 🎨 Styling & Theme
|
|
349
393
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
394
|
+
- Uses Minimal UI theme internally
|
|
395
|
+
- Fully isolated using Emotion cache
|
|
396
|
+
- Works alongside external application themes
|
|
353
397
|
|
|
354
398
|
---
|
|
355
399
|
|
|
@@ -357,15 +401,15 @@ Automatically persists:
|
|
|
357
401
|
|
|
358
402
|
👉 View full interactive documentation:
|
|
359
403
|
|
|
360
|
-
|
|
404
|
+
🔗 Chromatic Preview: https://main--69ce1b19a977f6e5c4aa712c.chromatic.com/?path=/story/data-display-bp-table--default
|
|
361
405
|
|
|
362
406
|
---
|
|
363
407
|
|
|
364
408
|
## ⚠️ Notes
|
|
365
409
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
410
|
+
- Column widths are configurable (`size`, `minSize`, `maxSize`)
|
|
411
|
+
- Supports dynamic rendering from application side
|
|
412
|
+
- Avoid overriding internal styles unless necessary
|
|
369
413
|
|
|
370
414
|
---
|
|
371
415
|
|