@rozie-ui/data-table-lit 0.3.1 → 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/README.md +48 -2
- package/dist/index.cjs +541 -146
- package/dist/index.d.cts +66 -18
- package/dist/index.d.mts +66 -18
- package/dist/index.mjs +541 -146
- package/package.json +2 -2
- package/src/DataTable.ts +511 -141
- package/src/helpers/columnDefUtils.ts +77 -1
package/README.md
CHANGED
|
@@ -365,6 +365,44 @@ render(html`
|
|
|
365
365
|
`, document.body);
|
|
366
366
|
```
|
|
367
367
|
|
|
368
|
+
### Per-column slot families (`cell-<id>` / `colHeader-<id>` / `filter-<id>` / `editor-<id>`)
|
|
369
|
+
|
|
370
|
+
```ts
|
|
371
|
+
import { html, render } from 'lit';
|
|
372
|
+
import '@rozie-ui/data-table-lit';
|
|
373
|
+
|
|
374
|
+
const rows = [
|
|
375
|
+
{ id: 1, name: 'Alpha', category: 'Hardware', price: 30 },
|
|
376
|
+
{ id: 2, name: 'Beta', category: 'Software', price: 90 },
|
|
377
|
+
{ id: 3, name: 'Gamma', category: 'Hardware', price: 10 },
|
|
378
|
+
{ id: 4, name: 'Delta', category: 'Service', price: 50 },
|
|
379
|
+
];
|
|
380
|
+
|
|
381
|
+
// A family fill is a STATIC per-column override — the `.rozieSlots` record property
|
|
382
|
+
// (NOT an extension of `.cell` / `.colHeader` / `.filter` / `.editor`). Precedence per
|
|
383
|
+
// seam: rozieSlots['<seam>-<id>'] → the generic .<seam> property → the built-in render.
|
|
384
|
+
// editor-<id> needs editor="custom"; filter-<id> needs filterable (shown on category
|
|
385
|
+
// below); cell-<id> / colHeader-<id> have no gate.
|
|
386
|
+
render(html`
|
|
387
|
+
<rozie-data-table
|
|
388
|
+
.data=${rows}
|
|
389
|
+
.rozieSlots=${{
|
|
390
|
+
'cell-price': ({ value }) => html`💲 ${value}`,
|
|
391
|
+
'colHeader-price': ({ label }) => html`🏷️ ${label}`,
|
|
392
|
+
'filter-category': ({ columnId, uniqueValues, setFilter }) => html`
|
|
393
|
+
<select @change=${(e: Event) => setFilter(columnId, (e.target as HTMLSelectElement).value || null)}>
|
|
394
|
+
<option value="">All</option>
|
|
395
|
+
${uniqueValues.map((v) => html`<option value=${String(v)}>${String(v)}</option>`)}
|
|
396
|
+
</select>`,
|
|
397
|
+
}}
|
|
398
|
+
>
|
|
399
|
+
<rozie-column field="name" header="Name"></rozie-column>
|
|
400
|
+
<rozie-column field="category" header="Category" filterable></rozie-column>
|
|
401
|
+
<rozie-column field="price" header="Price"></rozie-column>
|
|
402
|
+
</rozie-data-table>
|
|
403
|
+
`, document.body);
|
|
404
|
+
```
|
|
405
|
+
|
|
368
406
|
## Theming
|
|
369
407
|
|
|
370
408
|
Every visual value is a `--rozie-data-table-*` CSS custom property — override any of them at any ancestor scope. Ready-made design-system bridges ship in the package (import `base.css` first, then a bridge):
|
|
@@ -488,14 +526,22 @@ All rendering slots live on the parent `<DataTable>` (a `<Column>` carries metad
|
|
|
488
526
|
|
|
489
527
|
The `detail` (expandable rows), `groupBar` (grouping) and `filter` (faceted filtering) scoped slots follow the SAME render-prop convention: on React they are `renderDetail` / `renderGroupBar` / `renderFilter`; on Solid they are `detailSlot` / `groupBarSlot` / `filterSlot`; on Lit they are the `.detail` / `.groupBar` / `.filter` properties — the documented React render-prop edge (per the cross-framework compatibility bar). On Vue / Svelte / Angular they are ordinary named scoped slots (`#detail` / `#groupBar` / `#filter`). The `groupBar` and `filter` slots are HEADLESS — the component ships NO built-in group-bar / facet control, so the consumer builds the UI purely from the exposed slot props.
|
|
490
528
|
|
|
529
|
+
`cell`, `colHeader`, `filter` and `editor` each also have a **per-column slot family** — a statically-named fill per `columnId` (`cell-price`, `colHeader-price`, `filter-category`, `editor-score`, …) that takes precedence OVER the matching generic slot above it: `<seam>-<id>` → the generic `<seam>` slot → the built-in render. `editor-<id>` (and `editor`) only render on a column declared `editor="custom"`; `filter-<id>` (and `filter`) only render on a column declared `filterable`; `cell-<id>` / `colHeader-<id>` have no gate. The auto-injected row-select / row-expander chrome columns never reach any family — they are excluded structurally. On Lit the family is the additive **`.rozieSlots`** record property — `.rozieSlots=${{ 'cell-price': (ctx) => html`…` }}` — keyed by the exact `<seam>-<id>` string.
|
|
530
|
+
|
|
531
|
+
A misspelled family key does not fail to compile — the emitted type carries a trailing catch-all index signature alongside the templated key, so it typechecks but is simply never invoked. See the "Per-column slot families" example in Usage above for the full per-target syntax.
|
|
532
|
+
|
|
491
533
|
| Slot | Params |
|
|
492
534
|
| --- | --- |
|
|
493
535
|
| (default) | |
|
|
494
536
|
| groupBar | grouping, groupableColumns, applyGrouping, clearGrouping |
|
|
495
537
|
| selectAll | checked, indeterminate, toggle |
|
|
538
|
+
| colHeader-<id> | columnId, column, label |
|
|
539
|
+
| filter-<id> | columnId, value, uniqueValues, minMax, setFilter |
|
|
540
|
+
| selectCell | row, checked, toggle |
|
|
541
|
+
| cell-<id> | columnId, column, row, value |
|
|
542
|
+
| editor-<id> | columnId, column, row, value, commit, cancel, autofocus |
|
|
543
|
+
| detail | row |
|
|
496
544
|
| colHeader | columnId, column, label |
|
|
497
545
|
| filter | columnId, value, uniqueValues, minMax, setFilter |
|
|
498
|
-
| selectCell | row, checked, toggle |
|
|
499
546
|
| cell | columnId, column, row, value |
|
|
500
547
|
| editor | columnId, column, row, value, commit, cancel, autofocus |
|
|
501
|
-
| detail | row |
|