@bfrs/agentic-components 0.3.9 → 0.4.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/BFRS_AGENTIC_COMPONENTS.md +115 -0
- package/package.json +1 -1
|
@@ -2412,6 +2412,121 @@ Step-by-step progress indicator. Calculates `done` / `active` / `pending` state
|
|
|
2412
2412
|
|
|
2413
2413
|
---
|
|
2414
2414
|
|
|
2415
|
+
## Table / Thead / Tbody / Tfoot / Tr / Th / Td
|
|
2416
|
+
|
|
2417
|
+
Primitive table components with DataTable-matching styles, density support, and row hover effects. Use these for custom layouts where `DataTable` is too prescriptive.
|
|
2418
|
+
|
|
2419
|
+
### React
|
|
2420
|
+
|
|
2421
|
+
```tsx
|
|
2422
|
+
import { Table, Thead, Tbody, Tfoot, Tr, Th, Td } from "@bfrs/agentic-components";
|
|
2423
|
+
|
|
2424
|
+
<Table density="compact" sticky aria-label="Orders">
|
|
2425
|
+
<Thead sticky>
|
|
2426
|
+
<Tr>
|
|
2427
|
+
<Th>Order</Th>
|
|
2428
|
+
<Th align="right">Amount</Th>
|
|
2429
|
+
<Th>Status</Th>
|
|
2430
|
+
</Tr>
|
|
2431
|
+
</Thead>
|
|
2432
|
+
<Tbody>
|
|
2433
|
+
{orders.map((order) => (
|
|
2434
|
+
<Tr key={order.id} onClick={() => navigate(`/orders/${order.id}`)}>
|
|
2435
|
+
<Td>{order.id}</Td>
|
|
2436
|
+
<Td align="right">₹{order.amount}</Td>
|
|
2437
|
+
<Td>{order.status}</Td>
|
|
2438
|
+
</Tr>
|
|
2439
|
+
))}
|
|
2440
|
+
</Tbody>
|
|
2441
|
+
<Tfoot>
|
|
2442
|
+
<Tr>
|
|
2443
|
+
<Th colSpan={2}>Total</Th>
|
|
2444
|
+
<Th align="right">₹{total}</Th>
|
|
2445
|
+
</Tr>
|
|
2446
|
+
</Tfoot>
|
|
2447
|
+
</Table>
|
|
2448
|
+
```
|
|
2449
|
+
|
|
2450
|
+
#### Table props
|
|
2451
|
+
|
|
2452
|
+
| Prop | Type | Default | Description |
|
|
2453
|
+
|------|------|---------|-------------|
|
|
2454
|
+
| `density` | `"compact" \| "default" \| "comfortable"` | `"default"` | Cell padding density — propagates to Th/Td via React context |
|
|
2455
|
+
| `maxHeight` | `string \| number` | — | Enables vertical scrolling at this height |
|
|
2456
|
+
| `minWidth` | `string \| number` | — | Minimum table width (useful for fixed-layout tables) |
|
|
2457
|
+
| `className` | `string` | — | Applied to the outer border wrapper |
|
|
2458
|
+
| `tableClassName` | `string` | — | Applied to the `<table>` element |
|
|
2459
|
+
| `aria-label` | `string` | `"Table"` | Accessibility label |
|
|
2460
|
+
| `children` | `ReactNode` | — | `Thead`, `Tbody`, `Tfoot` elements |
|
|
2461
|
+
|
|
2462
|
+
#### Thead props
|
|
2463
|
+
|
|
2464
|
+
| Prop | Type | Default | Description |
|
|
2465
|
+
|------|------|---------|-------------|
|
|
2466
|
+
| `sticky` | `boolean` | `false` | Sticks the header at the top of the scroll container |
|
|
2467
|
+
| `className` | `string` | — | Extra class on `<thead>` |
|
|
2468
|
+
|
|
2469
|
+
#### Tr props
|
|
2470
|
+
|
|
2471
|
+
| Prop | Type | Default | Description |
|
|
2472
|
+
|------|------|---------|-------------|
|
|
2473
|
+
| `onClick` | `() => void` | — | Row click handler; adds `cursor-pointer` automatically |
|
|
2474
|
+
| `className` | `string` | — | Extra class on `<tr>` |
|
|
2475
|
+
|
|
2476
|
+
#### Th props
|
|
2477
|
+
|
|
2478
|
+
| Prop | Type | Default | Description |
|
|
2479
|
+
|------|------|---------|-------------|
|
|
2480
|
+
| `align` | `"left" \| "center" \| "right"` | `"left"` | Text alignment |
|
|
2481
|
+
| `colSpan` | `number` | — | HTML colspan |
|
|
2482
|
+
| `className` | `string` | — | Extra class on `<th>` |
|
|
2483
|
+
|
|
2484
|
+
#### Td props
|
|
2485
|
+
|
|
2486
|
+
| Prop | Type | Default | Description |
|
|
2487
|
+
|------|------|---------|-------------|
|
|
2488
|
+
| `align` | `"left" \| "center" \| "right"` | `"left"` | Text alignment |
|
|
2489
|
+
| `colSpan` | `number` | — | HTML colspan |
|
|
2490
|
+
| `className` | `string` | — | Extra class on `<td>` |
|
|
2491
|
+
|
|
2492
|
+
### Angular (custom elements)
|
|
2493
|
+
|
|
2494
|
+
Custom elements: `bfrs-table`, `bfrs-thead`, `bfrs-tbody`, `bfrs-tfoot`, `bfrs-tr`, `bfrs-th`, `bfrs-td`.
|
|
2495
|
+
|
|
2496
|
+
`bfrs-table` propagates `density` to all descendant `bfrs-th` and `bfrs-td` elements automatically. Row hover transitions the background color of all `bfrs-td` children via JavaScript events.
|
|
2497
|
+
|
|
2498
|
+
```html
|
|
2499
|
+
<bfrs-table density="compact" max-height="400px" aria-label="Orders">
|
|
2500
|
+
<bfrs-thead sticky>
|
|
2501
|
+
<bfrs-tr>
|
|
2502
|
+
<bfrs-th>Order</bfrs-th>
|
|
2503
|
+
<bfrs-th align="right">Amount</bfrs-th>
|
|
2504
|
+
<bfrs-th>Status</bfrs-th>
|
|
2505
|
+
</bfrs-tr>
|
|
2506
|
+
</bfrs-thead>
|
|
2507
|
+
<bfrs-tbody>
|
|
2508
|
+
<bfrs-tr *ngFor="let order of orders" (click)="navigate(order.id)">
|
|
2509
|
+
<bfrs-td>{{ order.id }}</bfrs-td>
|
|
2510
|
+
<bfrs-td align="right">₹{{ order.amount }}</bfrs-td>
|
|
2511
|
+
<bfrs-td>{{ order.status }}</bfrs-td>
|
|
2512
|
+
</bfrs-tr>
|
|
2513
|
+
</bfrs-tbody>
|
|
2514
|
+
</bfrs-table>
|
|
2515
|
+
```
|
|
2516
|
+
|
|
2517
|
+
| Attribute | Element | Description |
|
|
2518
|
+
|-----------|---------|-------------|
|
|
2519
|
+
| `density` | `bfrs-table` | `"compact"`, `"default"`, or `"comfortable"` — propagated to all th/td |
|
|
2520
|
+
| `max-height` | `bfrs-table` | CSS max-height for scroll container |
|
|
2521
|
+
| `min-width` | `bfrs-table` | CSS min-width on the table |
|
|
2522
|
+
| `aria-label` | `bfrs-table` | Accessibility label |
|
|
2523
|
+
| `sticky` | `bfrs-thead` | Boolean — sticks header at scroll top |
|
|
2524
|
+
| `on-click` | `bfrs-tr` | Emits `click` event; adds `cursor-pointer` |
|
|
2525
|
+
| `align` | `bfrs-th`, `bfrs-td` | `"left"`, `"center"`, or `"right"` |
|
|
2526
|
+
| `density` | `bfrs-th`, `bfrs-td` | Override density per cell (set explicitly; overrides table propagation) |
|
|
2527
|
+
|
|
2528
|
+
---
|
|
2529
|
+
|
|
2415
2530
|
## What NOT to do
|
|
2416
2531
|
|
|
2417
2532
|
- Do not use raw Tailwind classes for spacing, color, or typography — use `Stack`, `Text`, and component props instead
|