@ornery/ui-grid-react 0.1.10 → 1.0.1
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/AGENTS.md +67 -0
- package/dist/UiGrid.d.ts +6 -5
- package/dist/UiGrid.d.ts.map +1 -1
- package/dist/gridStateMath.d.ts +2 -2
- package/dist/gridStateMath.d.ts.map +1 -1
- package/dist/index.d.ts +2 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +159 -2142
- package/dist/index.mjs +153 -2229
- package/dist/mountUiGrid.d.ts +2 -0
- package/dist/mountUiGrid.d.ts.map +1 -1
- package/dist/ui-grid.css +48 -15
- package/dist/useGridState.d.ts.map +1 -1
- package/package.json +5 -3
- package/src/UiGrid.test.tsx +64 -235
- package/src/UiGrid.tsx +178 -699
- package/src/gridStateMath.test.ts +3 -3
- package/src/gridStateMath.ts +7 -4
- package/src/index.ts +2 -18
- package/src/mountUiGrid.tsx +26 -0
- package/src/test-setup.ts +13 -0
- package/src/ui-grid.css +48 -15
- package/src/useGridState.ts +8 -7
- package/tsconfig.dts.json +3 -2
- package/tsconfig.json +2 -1
- package/vitest.config.ts +2 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @ornery/ui-grid-react — Agent Instructions
|
|
2
|
+
|
|
3
|
+
Thin React wrapper. Mounts the vanilla `<ui-grid-element>` custom element and projects React render functions into it via the slot-based portal system.
|
|
4
|
+
|
|
5
|
+
## Build & Test
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run build --prefix projects/ui-grid-react # tsup → dist/
|
|
9
|
+
npm test --prefix projects/ui-grid-react # vitest (18 tests)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Depends on `@ornery/ui-grid-core` + `@ornery/ui-grid-vanilla` — build both first.
|
|
13
|
+
|
|
14
|
+
## Key Files
|
|
15
|
+
|
|
16
|
+
| File | Responsibility |
|
|
17
|
+
|------|---------------|
|
|
18
|
+
| `UiGrid.tsx` | React component wrapping the vanilla element |
|
|
19
|
+
| `mountUiGrid.tsx` | Imperative mount API: `mountUiGrid(host, { options, cellRenderers })` |
|
|
20
|
+
| `vanillaAdapter.ts` | Bridges React lifecycle to the vanilla element (options, event listeners) |
|
|
21
|
+
| `useGridState.ts` | React hook for grid state subscription |
|
|
22
|
+
| `useVirtualScroll.ts` | Virtual scroll hook |
|
|
23
|
+
| `gridStateMath.ts` | Pure math for grid layout calculations |
|
|
24
|
+
| `rustWasmGridEngine.ts` | Optional WASM engine integration |
|
|
25
|
+
| `ui-grid.css` | Wrapper-level styles |
|
|
26
|
+
|
|
27
|
+
## Architecture
|
|
28
|
+
|
|
29
|
+
### Mount Pattern
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
mountUiGrid(hostElement, {
|
|
33
|
+
options: gridOptions,
|
|
34
|
+
cellRenderers: {
|
|
35
|
+
status: ({ value }) => <Pill>{value}</Pill>,
|
|
36
|
+
price: ({ value, row }) => styledCell(String(value), row.color),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Cell Renderer Flow
|
|
42
|
+
|
|
43
|
+
1. `mountUiGrid` calls `el.setFrameworkRenderedSlots({ cells: Object.keys(cellRenderers) })`
|
|
44
|
+
2. Listens for `cellSlotsChanged` events
|
|
45
|
+
3. For each added slot: calls the matching render function, creates a React portal, appends to light DOM with `slot` attribute
|
|
46
|
+
4. For removed slots: unmounts the portal
|
|
47
|
+
|
|
48
|
+
### `styledCell` Helper
|
|
49
|
+
|
|
50
|
+
Quick inline-styled cell without creating a full component:
|
|
51
|
+
```tsx
|
|
52
|
+
styledCell(text: string, color: string, extraStyles?: CSSProperties)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Conventions
|
|
56
|
+
|
|
57
|
+
- No class components — functional components + hooks only
|
|
58
|
+
- External deps: `react`, `react-dom` (peer), `@ornery/ui-grid-core`, `@ornery/ui-grid-vanilla`
|
|
59
|
+
- The React wrapper never renders grid cells itself — it delegates to the vanilla element
|
|
60
|
+
- `cellRenderers` map keys must match `columnDef.name` values
|
|
61
|
+
|
|
62
|
+
## Do NOT
|
|
63
|
+
|
|
64
|
+
- Import from `dist/` paths — use tsconfig path mappings
|
|
65
|
+
- Call `setFrameworkRenderedSlots` on every render — only when `cellRenderers` keys change
|
|
66
|
+
- Forget to clean up portals on unmount
|
|
67
|
+
- Add Angular or vanilla rendering logic here — this package only bridges React ↔ vanilla
|
package/dist/UiGrid.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { GridOptions, GridCellTemplateContext,
|
|
2
|
+
import type { GridOptions, GridCellTemplateContext, UiGridApi } from '@ornery/ui-grid-core';
|
|
3
|
+
export interface UiGridCellRenderers {
|
|
4
|
+
[columnName: string]: (context: GridCellTemplateContext) => React.ReactNode;
|
|
5
|
+
}
|
|
3
6
|
export interface UiGridProps {
|
|
4
7
|
options: GridOptions;
|
|
5
8
|
onRegisterApi?: (api: UiGridApi) => void;
|
|
6
|
-
|
|
7
|
-
headerRenderer?: (context: GridHeaderTemplateContext) => React.ReactNode;
|
|
8
|
-
expandableRenderer?: (context: GridExpandableTemplateContext) => React.ReactNode;
|
|
9
|
+
cellRenderers?: UiGridCellRenderers;
|
|
9
10
|
className?: string;
|
|
10
11
|
}
|
|
11
|
-
export declare function UiGrid({ options, onRegisterApi,
|
|
12
|
+
export declare function UiGrid({ options, onRegisterApi, cellRenderers, className }: UiGridProps): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
//# sourceMappingURL=UiGrid.d.ts.map
|
package/dist/UiGrid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiGrid.d.ts","sourceRoot":"","sources":["../src/UiGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"UiGrid.d.ts","sourceRoot":"","sources":["../src/UiGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EACV,WAAW,EACX,uBAAuB,EAEvB,SAAS,EACV,MAAM,sBAAsB,CAAC;AAQ9B,MAAM,WAAW,mBAAmB;IAClC,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,uBAAuB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC7E;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,IAAI,CAAC;IACzC,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,wBAAgB,MAAM,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,WAAW,2CAqLvF"}
|
package/dist/gridStateMath.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export declare function orderVisibleColumns(columns: readonly GridColumnDef[], o
|
|
|
3
3
|
export declare function buildGridTemplateColumns(columns: readonly GridColumnDef[]): string;
|
|
4
4
|
export declare function resolveBenchmarkIterations(iterations?: number, configuredIterations?: number): number;
|
|
5
5
|
export declare function formatPaginationSummary(totalItems: number, firstRowIndex: number, lastRowIndex: number): string;
|
|
6
|
-
export declare function computeViewportHeightPx(
|
|
7
|
-
export declare function computeViewportRows(
|
|
6
|
+
export declare function computeViewportHeightPx(autoViewportHeight?: number | null, minRowsToShow?: number, rowHeight?: number): string;
|
|
7
|
+
export declare function computeViewportRows(autoViewportHeight?: number | null, rowHeight?: number, minRowsToShow?: number): number;
|
|
8
8
|
//# sourceMappingURL=gridStateMath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gridStateMath.d.ts","sourceRoot":"","sources":["../src/gridStateMath.ts"],"names":[],"mappings":"AAAA,OAAO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AAM,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAG1H"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
export { UiGrid } from './UiGrid';
|
|
2
|
-
export type { UiGridProps } from './UiGrid';
|
|
3
|
-
export { mountUiGrid, updateUiGrid, styledCell } from './mountUiGrid';
|
|
2
|
+
export type { UiGridProps, UiGridCellRenderers } from './UiGrid';
|
|
3
|
+
export { mountUiGrid, updateUiGrid, styledCell, datePickerCell } from './mountUiGrid';
|
|
4
4
|
export { mountUiGridCustomElement, type MountUiGridCustomElementOptions, type MountedUiGridCustomElement, } from './vanillaAdapter';
|
|
5
|
-
export { useGridState } from './useGridState';
|
|
6
|
-
export type { UseGridStateResult } from './useGridState';
|
|
7
|
-
export { useVirtualScroll } from './useVirtualScroll';
|
|
8
|
-
export type { UseVirtualScrollOptions, UseVirtualScrollResult } from './useVirtualScroll';
|
|
9
|
-
export { orderVisibleColumns, buildGridTemplateColumns, resolveBenchmarkIterations, formatPaginationSummary, computeViewportHeightPx, computeViewportRows, } from './gridStateMath';
|
|
10
|
-
export { enableReactUiGridWasmEngine, registerReactUiGridWasmEngineFromModule, } from './rustWasmGridEngine';
|
|
11
5
|
export type { GridOptions, GridColumnDef, GridRow, GridRecord, GridLabels, GridCellTemplateContext, GridExpandableTemplateContext, GridCellEditableContext, GridBenchmarkResult, GridSavedState, SortState, } from '@ornery/ui-grid-core';
|
|
12
6
|
export type { UiGridApi } from '@ornery/ui-grid-core';
|
|
13
7
|
export { DEFAULT_GRID_LABELS } from '@ornery/ui-grid-core';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EACL,wBAAwB,EACxB,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,GAChC,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,WAAW,EACX,aAAa,EACb,OAAO,EACP,UAAU,EACV,UAAU,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|