@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.
Files changed (3) hide show
  1. package/README.md +123 -79
  2. package/dist/index.js +953 -953
  3. 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 <your-repository-url>
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 (Drawer with accordion groups)
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
- data={data}
170
- columns={columns}
171
- getRowId={(row) => row.id}
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 | 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 |
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
- accessorKey: 'DealStatus',
209
- header: 'Deal Status',
210
- type: 'Label',
211
- isFilterable: true,
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
- 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
- },
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
- * Global search supported
313
- * Column-based filtering
314
- * Dynamic filter drawer (based on `isFilterable`)
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="my-table" />
367
+ <BPTable storageKey='my-table' />
324
368
  ```
325
369
 
326
370
  Automatically persists:
327
371
 
328
- * Pagination
329
- * Filters
330
- * Column order
331
- * Column visibility
332
- * Density
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
- onRowClick={(row) => {
341
- console.log('Clicked:', row);
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
- * Uses Minimal UI theme internally
351
- * Fully isolated using Emotion cache
352
- * Works alongside external application themes
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
- **[Add your Chromatic link here]**
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
- * Column widths are configurable (`size`, `minSize`, `maxSize`)
367
- * Supports dynamic rendering from application side
368
- * Avoid overriding internal styles unless necessary
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