@ornery/ui-grid-vanilla 1.0.4 → 1.0.6
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/demo/main.ts +1 -2
- package/dist/index.d.mts +40 -2
- package/dist/index.d.ts +40 -2
- package/dist/index.js +263 -100
- package/dist/index.mjs +263 -102
- package/package.json +6 -5
- package/src/cell-state-management.test.ts +419 -0
- package/src/events.ts +77 -26
- package/src/framework-slots.ts +18 -0
- package/src/grid-controller.ts +142 -98
- package/src/index.integration.test.ts +27 -10
- package/src/index.test.ts +0 -4
- package/src/index.ts +6 -9
- package/src/keyboard-navigation.test.ts +1 -7
- package/src/patch.ts +118 -1
- package/src/row-edit.test.ts +1 -1
- package/src/ui-grid-standalone.element.ts +79 -1
- package/vitest.config.ts +30 -0
package/demo/main.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { mountVanillaUiGrid } from '../src/index';
|
|
2
2
|
import type { GridOptions, UiGridApi } from '../src/index';
|
|
3
3
|
import type { GridBenchmarkResult } from '@ornery/ui-grid-core';
|
|
4
|
-
import * as uiGridRustWebModule from '../../../dist/ui-grid-wasm-web/ui_grid_wasm.js';
|
|
5
4
|
|
|
6
5
|
const statuses = ['Active', 'Expansion', 'Enterprise', 'Pilot'] as const;
|
|
7
6
|
const companies = ['Northwind', 'Blue Harbor', 'Forge Group', 'Larkspur', 'Atlas'] as const;
|
|
@@ -113,7 +112,7 @@ exportButton?.addEventListener('click', () => {
|
|
|
113
112
|
gridApi?.core.exportCsv();
|
|
114
113
|
});
|
|
115
114
|
|
|
116
|
-
void mountVanillaUiGrid(mountPoint, options
|
|
115
|
+
void mountVanillaUiGrid(mountPoint, options).catch((error) => {
|
|
117
116
|
console.error(error);
|
|
118
117
|
mountPoint.textContent = error instanceof Error ? error.message : String(error);
|
|
119
118
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GridCellTemplateContext, GridLabels, GridExpandableTemplateContext, GridColumnDef, GridHeaderTemplateContext, GridRow, GroupItem, GridOptions, PipelineResult, SortState, PinnedColumnState, GridCellPosition, UiGridApi, GridRecord, DisplayItem, SortDirection, PinDirection, GridSelectionState, resolveGridSelectionOptions, GridInfiniteScrollState, GridValidatorRegistry
|
|
1
|
+
import { GridCellTemplateContext, GridLabels, GridExpandableTemplateContext, GridColumnDef, GridHeaderTemplateContext, GridRow, GroupItem, GridOptions, PipelineResult, SortState, PinnedColumnState, GridCellPosition, UiGridApi, GridRecord, DisplayItem, SortDirection, PinDirection, GridSelectionState, resolveGridSelectionOptions, GridBenchmarkResult, GridInfiniteScrollState, GridValidatorRegistry } from '@ornery/ui-grid-core';
|
|
2
2
|
export { GridOptions, UiGridApi } from '@ornery/ui-grid-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -127,6 +127,17 @@ declare class FrameworkSlotBridge {
|
|
|
127
127
|
hasExpandableRow(): boolean;
|
|
128
128
|
hasEmptyState(): boolean;
|
|
129
129
|
stageCell(column: GridColumnDef, row: GridRow, rowIndex: number): void;
|
|
130
|
+
/**
|
|
131
|
+
* Carry forward every previously-known cell slot for `rowId` into the
|
|
132
|
+
* current pending set. Used by the structural patch path when a row's
|
|
133
|
+
* fingerprint matches the previous render's: `stageCell` would normally
|
|
134
|
+
* re-record the slot during cell rendering, but the fingerprint
|
|
135
|
+
* short-circuit skips the render pass for unchanged rows. Without this,
|
|
136
|
+
* `flush()` would diff pending (missing the row's slots) against last
|
|
137
|
+
* (containing them) and emit a spurious `removed` for every cell of the
|
|
138
|
+
* unchanged row, destroying the framework wrappers' projected content.
|
|
139
|
+
*/
|
|
140
|
+
carryRowCells(rowId: string): void;
|
|
130
141
|
stageExpandableRow(row: GridRow, rowIndex: number): void;
|
|
131
142
|
stageGroupRow(group: GroupItem): void;
|
|
132
143
|
stageHeader(column: GridColumnDef): void;
|
|
@@ -390,6 +401,11 @@ declare class VanillaGridController {
|
|
|
390
401
|
* bring the viewport back to 0. Keeps the controller DOM-free. */
|
|
391
402
|
private infiniteScrollScrollToTopRequest;
|
|
392
403
|
setInfiniteScrollResetHandler(handler: (() => void) | null): void;
|
|
404
|
+
/** Element-owned render benchmark. When present, `core.benchmark()`
|
|
405
|
+
* measures the actual render path instead of the controller-only
|
|
406
|
+
* pipeline builder. */
|
|
407
|
+
private benchmarkRequest;
|
|
408
|
+
setBenchmarkHandler(handler: ((iterations?: number) => Promise<GridBenchmarkResult>) | null): void;
|
|
393
409
|
getInfiniteScrollState(): Readonly<GridInfiniteScrollState>;
|
|
394
410
|
canResizeColumns(): boolean;
|
|
395
411
|
setViewportWidth(width: number): void;
|
|
@@ -438,6 +454,10 @@ declare class VanillaGridController {
|
|
|
438
454
|
expandToggleLabel(row: GridRow): string;
|
|
439
455
|
editorInputType(column: GridColumnDef): string;
|
|
440
456
|
isEditingCell(rowId: string, columnName: string): boolean;
|
|
457
|
+
/** Compact key for the editing cell, or null when no edit is in flight.
|
|
458
|
+
* Used by the patch path to detect when the editing position moves so it
|
|
459
|
+
* can force the affected cells through the slow rebuild path. */
|
|
460
|
+
getEditingCellKey(): string | null;
|
|
441
461
|
/**
|
|
442
462
|
* Serialise the current grid state. Mirrors `ui.grid.saveState.save`:
|
|
443
463
|
* every field is gated by an `options.save*` flag with the old grid's
|
|
@@ -547,6 +567,12 @@ type VanillaUiGridElement = HTMLElement & {
|
|
|
547
567
|
* remains completely smooth while data ticks in the background.
|
|
548
568
|
*/
|
|
549
569
|
setData(rows: GridRecord[]): void;
|
|
570
|
+
/**
|
|
571
|
+
* Declare which slots the grid should emit as `<slot>` placeholders for a
|
|
572
|
+
* framework wrapper to project into. See `FrameworkSlotBridge` for the
|
|
573
|
+
* full contract.
|
|
574
|
+
*/
|
|
575
|
+
setFrameworkRenderedSlots(config: FrameworkRenderedSlotsConfig): void;
|
|
550
576
|
};
|
|
551
577
|
type VanillaGridOptions = GridOptions & {
|
|
552
578
|
iconOverrides?: UiGridIconOverrides;
|
|
@@ -598,6 +624,18 @@ declare class UiGridStandaloneElement extends HTMLElement {
|
|
|
598
624
|
/** @internal */ lastItemsFingerprint: string | null;
|
|
599
625
|
/** @internal */ lastVirtualOffset: number;
|
|
600
626
|
/** @internal */ lastTotalVirtualHeight: number;
|
|
627
|
+
/**
|
|
628
|
+
* @internal Per-row visual-state fingerprint from the previous patch pass.
|
|
629
|
+
* The patch path uses this to skip cells whose row state hasn't changed
|
|
630
|
+
* (selection, expand, dirty/saving/error flags) when the structure
|
|
631
|
+
* fingerprint matches. Cleared on full re-render.
|
|
632
|
+
*/
|
|
633
|
+
lastRowStateFingerprints: Map<string, {
|
|
634
|
+
fingerprint: string;
|
|
635
|
+
entity: unknown;
|
|
636
|
+
}>;
|
|
637
|
+
/** @internal */ lastEditingCellKey: string | null;
|
|
638
|
+
/** @internal */ lastFocusedCellKey: string | null;
|
|
601
639
|
/**
|
|
602
640
|
* @internal Framework-rendered slot bridge. See `./framework-slots.ts`.
|
|
603
641
|
*/
|
|
@@ -717,6 +755,7 @@ declare class UiGridStandaloneElement extends HTMLElement {
|
|
|
717
755
|
private patchCells;
|
|
718
756
|
connectedCallback(): void;
|
|
719
757
|
disconnectedCallback(): void;
|
|
758
|
+
private benchmarkRender;
|
|
720
759
|
/** @internal */
|
|
721
760
|
ensureShadowRoot(): ShadowRoot;
|
|
722
761
|
/** @internal */
|
|
@@ -854,7 +893,6 @@ declare class UIGridTemplate extends HTMLTemplateElement {
|
|
|
854
893
|
|
|
855
894
|
interface UiGridRustWebModule {
|
|
856
895
|
default(input?: unknown): Promise<unknown>;
|
|
857
|
-
build_pipeline_js(context: BuildGridPipelineContext): PipelineResult;
|
|
858
896
|
}
|
|
859
897
|
|
|
860
898
|
declare function registerVanillaUiGridRustModule(module: UiGridRustWebModule, input?: unknown): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GridCellTemplateContext, GridLabels, GridExpandableTemplateContext, GridColumnDef, GridHeaderTemplateContext, GridRow, GroupItem, GridOptions, PipelineResult, SortState, PinnedColumnState, GridCellPosition, UiGridApi, GridRecord, DisplayItem, SortDirection, PinDirection, GridSelectionState, resolveGridSelectionOptions, GridInfiniteScrollState, GridValidatorRegistry
|
|
1
|
+
import { GridCellTemplateContext, GridLabels, GridExpandableTemplateContext, GridColumnDef, GridHeaderTemplateContext, GridRow, GroupItem, GridOptions, PipelineResult, SortState, PinnedColumnState, GridCellPosition, UiGridApi, GridRecord, DisplayItem, SortDirection, PinDirection, GridSelectionState, resolveGridSelectionOptions, GridBenchmarkResult, GridInfiniteScrollState, GridValidatorRegistry } from '@ornery/ui-grid-core';
|
|
2
2
|
export { GridOptions, UiGridApi } from '@ornery/ui-grid-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -127,6 +127,17 @@ declare class FrameworkSlotBridge {
|
|
|
127
127
|
hasExpandableRow(): boolean;
|
|
128
128
|
hasEmptyState(): boolean;
|
|
129
129
|
stageCell(column: GridColumnDef, row: GridRow, rowIndex: number): void;
|
|
130
|
+
/**
|
|
131
|
+
* Carry forward every previously-known cell slot for `rowId` into the
|
|
132
|
+
* current pending set. Used by the structural patch path when a row's
|
|
133
|
+
* fingerprint matches the previous render's: `stageCell` would normally
|
|
134
|
+
* re-record the slot during cell rendering, but the fingerprint
|
|
135
|
+
* short-circuit skips the render pass for unchanged rows. Without this,
|
|
136
|
+
* `flush()` would diff pending (missing the row's slots) against last
|
|
137
|
+
* (containing them) and emit a spurious `removed` for every cell of the
|
|
138
|
+
* unchanged row, destroying the framework wrappers' projected content.
|
|
139
|
+
*/
|
|
140
|
+
carryRowCells(rowId: string): void;
|
|
130
141
|
stageExpandableRow(row: GridRow, rowIndex: number): void;
|
|
131
142
|
stageGroupRow(group: GroupItem): void;
|
|
132
143
|
stageHeader(column: GridColumnDef): void;
|
|
@@ -390,6 +401,11 @@ declare class VanillaGridController {
|
|
|
390
401
|
* bring the viewport back to 0. Keeps the controller DOM-free. */
|
|
391
402
|
private infiniteScrollScrollToTopRequest;
|
|
392
403
|
setInfiniteScrollResetHandler(handler: (() => void) | null): void;
|
|
404
|
+
/** Element-owned render benchmark. When present, `core.benchmark()`
|
|
405
|
+
* measures the actual render path instead of the controller-only
|
|
406
|
+
* pipeline builder. */
|
|
407
|
+
private benchmarkRequest;
|
|
408
|
+
setBenchmarkHandler(handler: ((iterations?: number) => Promise<GridBenchmarkResult>) | null): void;
|
|
393
409
|
getInfiniteScrollState(): Readonly<GridInfiniteScrollState>;
|
|
394
410
|
canResizeColumns(): boolean;
|
|
395
411
|
setViewportWidth(width: number): void;
|
|
@@ -438,6 +454,10 @@ declare class VanillaGridController {
|
|
|
438
454
|
expandToggleLabel(row: GridRow): string;
|
|
439
455
|
editorInputType(column: GridColumnDef): string;
|
|
440
456
|
isEditingCell(rowId: string, columnName: string): boolean;
|
|
457
|
+
/** Compact key for the editing cell, or null when no edit is in flight.
|
|
458
|
+
* Used by the patch path to detect when the editing position moves so it
|
|
459
|
+
* can force the affected cells through the slow rebuild path. */
|
|
460
|
+
getEditingCellKey(): string | null;
|
|
441
461
|
/**
|
|
442
462
|
* Serialise the current grid state. Mirrors `ui.grid.saveState.save`:
|
|
443
463
|
* every field is gated by an `options.save*` flag with the old grid's
|
|
@@ -547,6 +567,12 @@ type VanillaUiGridElement = HTMLElement & {
|
|
|
547
567
|
* remains completely smooth while data ticks in the background.
|
|
548
568
|
*/
|
|
549
569
|
setData(rows: GridRecord[]): void;
|
|
570
|
+
/**
|
|
571
|
+
* Declare which slots the grid should emit as `<slot>` placeholders for a
|
|
572
|
+
* framework wrapper to project into. See `FrameworkSlotBridge` for the
|
|
573
|
+
* full contract.
|
|
574
|
+
*/
|
|
575
|
+
setFrameworkRenderedSlots(config: FrameworkRenderedSlotsConfig): void;
|
|
550
576
|
};
|
|
551
577
|
type VanillaGridOptions = GridOptions & {
|
|
552
578
|
iconOverrides?: UiGridIconOverrides;
|
|
@@ -598,6 +624,18 @@ declare class UiGridStandaloneElement extends HTMLElement {
|
|
|
598
624
|
/** @internal */ lastItemsFingerprint: string | null;
|
|
599
625
|
/** @internal */ lastVirtualOffset: number;
|
|
600
626
|
/** @internal */ lastTotalVirtualHeight: number;
|
|
627
|
+
/**
|
|
628
|
+
* @internal Per-row visual-state fingerprint from the previous patch pass.
|
|
629
|
+
* The patch path uses this to skip cells whose row state hasn't changed
|
|
630
|
+
* (selection, expand, dirty/saving/error flags) when the structure
|
|
631
|
+
* fingerprint matches. Cleared on full re-render.
|
|
632
|
+
*/
|
|
633
|
+
lastRowStateFingerprints: Map<string, {
|
|
634
|
+
fingerprint: string;
|
|
635
|
+
entity: unknown;
|
|
636
|
+
}>;
|
|
637
|
+
/** @internal */ lastEditingCellKey: string | null;
|
|
638
|
+
/** @internal */ lastFocusedCellKey: string | null;
|
|
601
639
|
/**
|
|
602
640
|
* @internal Framework-rendered slot bridge. See `./framework-slots.ts`.
|
|
603
641
|
*/
|
|
@@ -717,6 +755,7 @@ declare class UiGridStandaloneElement extends HTMLElement {
|
|
|
717
755
|
private patchCells;
|
|
718
756
|
connectedCallback(): void;
|
|
719
757
|
disconnectedCallback(): void;
|
|
758
|
+
private benchmarkRender;
|
|
720
759
|
/** @internal */
|
|
721
760
|
ensureShadowRoot(): ShadowRoot;
|
|
722
761
|
/** @internal */
|
|
@@ -854,7 +893,6 @@ declare class UIGridTemplate extends HTMLTemplateElement {
|
|
|
854
893
|
|
|
855
894
|
interface UiGridRustWebModule {
|
|
856
895
|
default(input?: unknown): Promise<unknown>;
|
|
857
|
-
build_pipeline_js(context: BuildGridPipelineContext): PipelineResult;
|
|
858
896
|
}
|
|
859
897
|
|
|
860
898
|
declare function registerVanillaUiGridRustModule(module: UiGridRustWebModule, input?: unknown): Promise<void>;
|