@rozie-ui/data-table-lit 0.6.0 → 0.7.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 CHANGED
@@ -501,6 +501,8 @@ Beyond props, the component exposes imperative methods (declared once in the Roz
501
501
  | `focusCell` | Move + focus the active cell (grid interaction mode) — `focusCell(rowIndex, colIndex)`. `rowIndex` is the ABSOLUTE display-order position in `getPrePaginationRowModel().rows` (filter+sort+expand applied, BEFORE pagination/windowing), in BOTH paginated and virtual modes: a paginated `focusCell(abs)` switches to `Math.floor(abs/pageSize)` then focuses; a virtual `focusCell(abs)` scrolls-then-focuses. Args coerced to integers + clamped to bounds. Fires `activecell-change` with the absolute `rowIndex`. (Named `focusCell`, not `focus`: a bare `focus` verb shadows the inherited `HTMLElement.focus` on Lit — ROZ137.) |
502
502
  | `getActiveCell` | Return the current active-cell position — `getActiveCell()` → `{ rowIndex, colIndex, isHeader }`. For a body cell `rowIndex` is the ABSOLUTE display-order index (matching `focusCell` / `activecell-change`) and `isHeader` is `false`; for a header-active cell `rowIndex` is `null` and `isHeader` is `true` (integers only — no row data, no DOM node). |
503
503
  | `clearActiveCell` | Reset the roving active-cell position to the entry cell and exit interaction mode — `clearActiveCell()`. The next Tab-in re-enters at the entry cell. (Named `clearActiveCell`, not `clear`: distinct from the listbox `clear` selection verb.) |
504
+ | `scrollToRow` | Scroll a row into view on a `virtual` table — `scrollToRow(index, options?)` where `options` mirrors TanStack virtual-core's own `ScrollToOptions` (`{ align?: 'start'|'center'|'end'|'auto', behavior?: 'auto'|'smooth'|'instant' }`) and is forwarded UNCHANGED to `virtualizer.scrollToIndex`. INDEPENDENT of grid-mode focus: never moves the roving active cell and never fires `activecell-change`, callable in either `interactionMode`. `index` is coerced to an integer (never range-clamped here — virtual-core's own `scrollToIndex` already clamps to `[0, options.count-1]`). A no-op when rows are not windowed (`virtual` off, or `'columns'`-only). |
505
+ | `getScrollElement` | Return the scroll-container DOM node the row and column virtualizer(s) observe — `getScrollElement()` → `HTMLElement | null`. The supported replacement for reaching into the internal `.rdt-scroll` class selector. Returns `null` when nothing is windowed. |
504
506
  | `getRowIndexRelativeToPage` | Convert an ABSOLUTE display-order row index (the `focusCell` / `getActiveCell` / `activecell-change` space) to the PAGE-RELATIVE index — `getRowIndexRelativeToPage(absRow?)` → `number`. With no argument it converts the current active cell (`abs - pageIndex*pageSize`). In virtual mode (no pagination) it returns the absolute index unchanged. Mirrors MUI `getRowIndexRelativeToVisibleRows`. (Named `getRowIndexRelativeToPage`: collision-clean against the verb/event/prop and Lit ROZ137 reserved sets.) |
505
507
  | `editCell` | Programmatically open the editor on a cell — `editCell(rowIndex, colIndex)`, addressed by index over the visible model (args coerced to integers + clamped). No-op on a non-editable cell. (Named `editCell`, not `edit`: collision-clean against the verb/event/prop and Lit ROZ137 reserved sets.) |
506
508
  | `commitEditing` | Programmatically commit the open editor — `commitEditing()`. Runs the column validator; on success writes the two-way `data` model and fires one `cell-edit-commit`; on a validation failure keeps the editor open. No-op when no cell is editing. (Named `commitEditing`, not `commit`.) |
package/dist/index.cjs CHANGED
@@ -1146,6 +1146,11 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
1146
1146
  composed: true
1147
1147
  }));
1148
1148
  };
1149
+ this.scrollToRow = (index, options) => {
1150
+ if (!this.rowsWindowed() || !this.virtualizer) return;
1151
+ this.virtualizer.scrollToIndex(Math.trunc(Number(index)) || 0, options || void 0);
1152
+ };
1153
+ this.getScrollElement = () => this.gridScrollEl;
1149
1154
  this.virtualItemKey = (i) => {
1150
1155
  const src = this.windowSource();
1151
1156
  return src && src[i] ? src[i].id : void 0;
package/dist/index.d.cts CHANGED
@@ -447,6 +447,11 @@ declare class DataTable extends DataTable_base {
447
447
  lastRangeStart: number;
448
448
  lastRangeEnd: number;
449
449
  emitVisibleRangeIfChanged: () => void;
450
+ scrollToRow: (index: any, options?: {
451
+ align?: "start" | "center" | "end" | "auto";
452
+ behavior?: "auto" | "smooth" | "instant";
453
+ }) => void;
454
+ getScrollElement: () => any;
450
455
  virtualItemKey: (i: any) => any;
451
456
  COL_OVERSCAN: number;
452
457
  colRtlObserver: any;
package/dist/index.d.mts CHANGED
@@ -447,6 +447,11 @@ declare class DataTable extends DataTable_base {
447
447
  lastRangeStart: number;
448
448
  lastRangeEnd: number;
449
449
  emitVisibleRangeIfChanged: () => void;
450
+ scrollToRow: (index: any, options?: {
451
+ align?: "start" | "center" | "end" | "auto";
452
+ behavior?: "auto" | "smooth" | "instant";
453
+ }) => void;
454
+ getScrollElement: () => any;
450
455
  virtualItemKey: (i: any) => any;
451
456
  COL_OVERSCAN: number;
452
457
  colRtlObserver: any;
package/dist/index.mjs CHANGED
@@ -1142,6 +1142,11 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
1142
1142
  composed: true
1143
1143
  }));
1144
1144
  };
1145
+ this.scrollToRow = (index, options) => {
1146
+ if (!this.rowsWindowed() || !this.virtualizer) return;
1147
+ this.virtualizer.scrollToIndex(Math.trunc(Number(index)) || 0, options || void 0);
1148
+ };
1149
+ this.getScrollElement = () => this.gridScrollEl;
1145
1150
  this.virtualItemKey = (i) => {
1146
1151
  const src = this.windowSource();
1147
1152
  return src && src[i] ? src[i].id : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rozie-ui/data-table-lit",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "license": "MIT",
package/src/DataTable.ts CHANGED
@@ -3420,6 +3420,35 @@ ${this.groupable ? html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4c>
3420
3420
  }));
3421
3421
  };
3422
3422
 
3423
+ // scrollToRow(index, options?) — quick 260927-a2r (oinbox dogfooding): plain scroll-into-view
3424
+ // for a windowed row, forwarding TanStack virtual-core's own ScrollToOptions ({ align?,
3425
+ // behavior? }) UNCHANGED to virtualizer.scrollToIndex — the SAME call focusActiveCell's D-12
3426
+ // off-window scroll-then-focus path (gridFocusNav.rzts) already drives, exposed here as a
3427
+ // standalone public verb rather than invented plumbing. INDEPENDENT of grid-mode focus
3428
+ // (feedback_no_false_equivalent_options / the todo's own open question): never reads or
3429
+ // writes $data.activeRow/activeColIndex, never emits activecell-change, and is callable in
3430
+ // EITHER interactionMode ('table' or 'grid') — a scroll, not a focus move. No-op when rows
3431
+ // are not windowed or the row virtualizer has not been constructed yet — mirrors the
3432
+ // isGrid()-gated no-op precedent on focusCell/clearActiveCell (gridActiveCellVerbs.rzts) for
3433
+ // the identical reason: the capability this verb drives isn't active. `index` is coerced
3434
+ // (T-260927A2R-01) — never range-clamped here: virtual-core's own scrollToIndex already
3435
+ // clamps to [0, options.count-1] internally (verified in @tanstack/virtual-core source).
3436
+ scrollToRow = (index: any, options?: {
3437
+ align?: 'start' | 'center' | 'end' | 'auto';
3438
+ behavior?: 'auto' | 'smooth' | 'instant';
3439
+ }): void => {
3440
+ if (!this.rowsWindowed() || !this.virtualizer) return;
3441
+ this.virtualizer.scrollToIndex(Math.trunc(Number(index)) || 0, options || undefined);
3442
+ };
3443
+
3444
+ // getScrollElement() — quick 260927-a2r: returns the DOM node the row AND column
3445
+ // virtualizer(s) observe/scroll (the `.rdt-scroll` div captured post-mount in
3446
+ // DataTable.rozie's own $onMount, D-03) — the supported replacement for a consumer reaching
3447
+ // into the internal `.rdt-scroll` class selector. Returns null when nothing is windowed:
3448
+ // gridScrollEl is only ever assigned inside the isWindowed() guard, so no extra gate is
3449
+ // needed here beyond that natural null.
3450
+ getScrollElement = (): any => this.gridScrollEl;
3451
+
3423
3452
  // ══ Generic vertical windowing math (Phase 64, D-04) — the target-agnostic virtual-core bridge ══
3424
3453
  // Lifted verbatim from the DataTable virtualization.rzts (the Phase 53/63 B13 baseline). This partial
3425
3454
  // holds ONLY the PURE windowing math; every DOM/refs/virtualizer-instance impurity stays per-consumer