@ya-grid/react 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +78 -2
- package/dist/index.d.ts +17 -0
- package/dist/index.js +242 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Erik-Jan van Baaren
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,79 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ya-grid/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React 18/19 adapter for [YA-Grid](https://github.com/eriky/ya-grid) with Portal-based custom cell and Master–Detail renderers.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @ya-grid/react @ya-grid/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import '@ya-grid/core/styles.css';
|
|
15
|
+
import { type ColDef, YaGrid } from '@ya-grid/react';
|
|
16
|
+
|
|
17
|
+
interface Row {
|
|
18
|
+
id: number;
|
|
19
|
+
name: string;
|
|
20
|
+
notes: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Define columns outside the component (or with useMemo). A new columnDefs array on every
|
|
24
|
+
// render makes the grid rebuild its columns and remount custom cells each time.
|
|
25
|
+
const columnDefs: ColDef<Row>[] = [{ field: 'name', filter: 'text', floatingFilter: true }];
|
|
26
|
+
|
|
27
|
+
export function Example({ rows }: { rows: Row[] }) {
|
|
28
|
+
return (
|
|
29
|
+
<div style={{ height: 640 }}>
|
|
30
|
+
<YaGrid<Row>
|
|
31
|
+
rowData={rows}
|
|
32
|
+
columnDefs={columnDefs}
|
|
33
|
+
getRowId={({ data }) => String(data.id)}
|
|
34
|
+
masterDetail
|
|
35
|
+
detailCellRenderer={({ data }) => <div>{data.notes}</div>}
|
|
36
|
+
globalSearch
|
|
37
|
+
pagination
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### How props are applied
|
|
45
|
+
|
|
46
|
+
- After the first render, only props whose value changed (by `Object.is`) are sent to the
|
|
47
|
+
grid. Unchanged props never overwrite state the grid changed itself, such as rows added
|
|
48
|
+
with `api.applyTransaction`, the user's search text or a theme set through the API.
|
|
49
|
+
- Event handlers (`onCellClicked`, `onSelectionChanged`, …), `getRowId` and `isRowMaster`
|
|
50
|
+
can be inline functions: the grid always calls the latest one. Changing what
|
|
51
|
+
`isRowMaster` returns for existing rows takes effect on the next render of those rows;
|
|
52
|
+
call `api.refreshCells()` to apply it immediately.
|
|
53
|
+
- Get the grid API from `onGridReady={(e) => …e.api}`.
|
|
54
|
+
|
|
55
|
+
### Custom cell renderers
|
|
56
|
+
|
|
57
|
+
`cellRenderer` and `detailCellRenderer` accept React components (function components,
|
|
58
|
+
class components, `memo`, `forwardRef`). A plain function that returns a DOM element is
|
|
59
|
+
mounted as DOM too, but wrapping it in `vanillaRenderer` lets the grid render it directly
|
|
60
|
+
without going through React, which is faster for large grids:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { vanillaRenderer } from '@ya-grid/react';
|
|
64
|
+
|
|
65
|
+
const flagCell = vanillaRenderer(({ value }) => {
|
|
66
|
+
const img = document.createElement('img');
|
|
67
|
+
img.src = `/flags/${value}.svg`;
|
|
68
|
+
return img;
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
An error thrown by one cell renderer is logged and leaves that cell empty instead of
|
|
73
|
+
unmounting your app.
|
|
74
|
+
|
|
75
|
+
See the [YA-Grid documentation](https://github.com/eriky/ya-grid#readme) for full API details.
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT © 2026 Erik-Jan van Baaren
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GridOptions, VanillaCellRendererFn } from '@ya-grid/core';
|
|
2
|
+
export { AggFunc, AggFuncParams, BadgeColumnOptions, BadgeStyleConfig, BadgeTone, BarColumnOptions, BarColumnThresholds, BooleanColumnOptions, BuiltInAggFunc, CellClassParams, CellClickedEvent, CellEditorParams, CellEditorType, CellRenderer, CellRendererParams, CellValidatorParams, CellValueChangedEvent, ColDef, ColGroupDef, ColumnDefItem, ColumnFilterModel, ColumnMovedEvent, ColumnPinnedEvent, ColumnResizedEvent, ColumnStateItem, ColumnTypeDef, ColumnVisibilityChangedEvent, CsvExportParams, CurrencyColumnOptions, DetailCellRenderer, DetailCellRendererParams, EditableParams, FilterChangedEvent, FilterModel, FilterType, GlobalSearchConfig, GridApi, GridDensity, GridOptions, GridReadyEvent, GridState, GridThemeMode, HeaderGroupMeta, PaginationChangedEvent, PaginationState, PercentColumnOptions, PinnedDirection, PinnedSummaryConfig, ResolvedColDef, ResponsivePinningConfig, RowClickedEvent, RowDataTransaction, RowDataTransactionResult, RowDetailToggledEvent, RowModelType, RowNode, RowSelectionConfig, SelectionChangedEvent, ServerSideDatasource, ServerSideGetRowsRequest, ServerSideGetRowsResult, SortChangedEvent, SortDirection, SortModelItem, SparklineColumnOptions, StateChangedEvent, ValueParserParams, ValueSetterParams, VirtualizationConfig, badgeColumn, barColumn, booleanColumn, createBuiltInColumnTypes, currencyColumn, percentColumn, sparklineColumn } from '@ya-grid/core';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { CSSProperties } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Marks a function as a plain DOM cell renderer (returns an HTMLElement or string), so the
|
|
8
|
+
* grid core renders it directly instead of mounting it as a React component.
|
|
9
|
+
*/
|
|
10
|
+
declare function vanillaRenderer<TData = Record<string, unknown>, TValue = unknown>(fn: VanillaCellRendererFn<TData, TValue>): VanillaCellRendererFn<TData, TValue>;
|
|
11
|
+
interface YaGridProps<TData = Record<string, unknown>> extends Omit<GridOptions<TData>, 'componentMountAdapter'> {
|
|
12
|
+
className?: string;
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
}
|
|
15
|
+
declare function YaGrid<TData = Record<string, unknown>>(props: YaGridProps<TData>): react.JSX.Element;
|
|
16
|
+
|
|
17
|
+
export { YaGrid, type YaGridProps, vanillaRenderer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
badgeColumn,
|
|
4
|
+
barColumn,
|
|
5
|
+
booleanColumn,
|
|
6
|
+
createBuiltInColumnTypes,
|
|
7
|
+
currencyColumn,
|
|
8
|
+
percentColumn,
|
|
9
|
+
sparklineColumn
|
|
10
|
+
} from "@ya-grid/core";
|
|
11
|
+
|
|
12
|
+
// src/YaGrid.tsx
|
|
13
|
+
import {
|
|
14
|
+
createGrid,
|
|
15
|
+
markVanillaRenderer,
|
|
16
|
+
VANILLA_RENDERER_SYMBOL
|
|
17
|
+
} from "@ya-grid/core";
|
|
18
|
+
import {
|
|
19
|
+
Component,
|
|
20
|
+
useEffect,
|
|
21
|
+
useLayoutEffect,
|
|
22
|
+
useRef,
|
|
23
|
+
useState
|
|
24
|
+
} from "react";
|
|
25
|
+
import { createPortal, flushSync } from "react-dom";
|
|
26
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
+
var VANILLA_RENDERER_BRAND = VANILLA_RENDERER_SYMBOL;
|
|
28
|
+
function vanillaRenderer(fn) {
|
|
29
|
+
return markVanillaRenderer(fn);
|
|
30
|
+
}
|
|
31
|
+
function isReactCellRenderer(renderer) {
|
|
32
|
+
if (!renderer) return false;
|
|
33
|
+
if (typeof renderer === "function") {
|
|
34
|
+
return !(VANILLA_RENDERER_BRAND in renderer);
|
|
35
|
+
}
|
|
36
|
+
return typeof renderer === "object" && "$$typeof" in renderer;
|
|
37
|
+
}
|
|
38
|
+
function isClassComponent(renderer) {
|
|
39
|
+
return typeof renderer === "function" && Boolean(
|
|
40
|
+
renderer.prototype?.isReactComponent
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function DomNodeHost({ node }) {
|
|
44
|
+
const ref = useRef(null);
|
|
45
|
+
useLayoutEffect(() => {
|
|
46
|
+
const host = ref.current;
|
|
47
|
+
if (!host) return;
|
|
48
|
+
host.appendChild(node);
|
|
49
|
+
return () => {
|
|
50
|
+
if (node.parentNode === host) host.removeChild(node);
|
|
51
|
+
};
|
|
52
|
+
}, [node]);
|
|
53
|
+
return /* @__PURE__ */ jsx("span", { ref, style: { display: "contents" } });
|
|
54
|
+
}
|
|
55
|
+
function FunctionRendererHost({
|
|
56
|
+
renderer,
|
|
57
|
+
params
|
|
58
|
+
}) {
|
|
59
|
+
const result = renderer(params);
|
|
60
|
+
if (typeof Node !== "undefined" && result instanceof Node) {
|
|
61
|
+
return /* @__PURE__ */ jsx(DomNodeHost, { node: result });
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
var CellErrorBoundary = class extends Component {
|
|
66
|
+
state = { failed: false };
|
|
67
|
+
static getDerivedStateFromError() {
|
|
68
|
+
return { failed: true };
|
|
69
|
+
}
|
|
70
|
+
componentDidCatch(error, info) {
|
|
71
|
+
console.error("[ya-grid] A cell renderer threw an error", error, info.componentStack);
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
return this.state.failed ? null : this.props.children;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function renderCellContent(renderer, params) {
|
|
78
|
+
if (typeof renderer === "function" && !isClassComponent(renderer)) {
|
|
79
|
+
return /* @__PURE__ */ jsx(FunctionRendererHost, { renderer, params });
|
|
80
|
+
}
|
|
81
|
+
const Comp = renderer;
|
|
82
|
+
return /* @__PURE__ */ jsx(Comp, { ...params });
|
|
83
|
+
}
|
|
84
|
+
var EVENT_KEYS = [
|
|
85
|
+
"onGridReady",
|
|
86
|
+
"onRowClicked",
|
|
87
|
+
"onCellClicked",
|
|
88
|
+
"onCellValueChanged",
|
|
89
|
+
"onSelectionChanged",
|
|
90
|
+
"onSortChanged",
|
|
91
|
+
"onFilterChanged",
|
|
92
|
+
"onColumnResized",
|
|
93
|
+
"onColumnMoved",
|
|
94
|
+
"onColumnPinned",
|
|
95
|
+
"onColumnVisibilityChanged",
|
|
96
|
+
"onPaginationChanged",
|
|
97
|
+
"onStateChanged",
|
|
98
|
+
"onRowDetailToggled"
|
|
99
|
+
];
|
|
100
|
+
var OPTIONAL_FN_KEYS = [
|
|
101
|
+
"getRowId",
|
|
102
|
+
"isRowMaster"
|
|
103
|
+
];
|
|
104
|
+
var WRAPPED_KEYS = /* @__PURE__ */ new Set([...EVENT_KEYS, ...OPTIONAL_FN_KEYS, "detailCellRenderer"]);
|
|
105
|
+
function YaGrid(props) {
|
|
106
|
+
const { className, style, ...gridOptions } = props;
|
|
107
|
+
const hostRef = useRef(null);
|
|
108
|
+
const apiRef = useRef(null);
|
|
109
|
+
const latestRef = useRef(gridOptions);
|
|
110
|
+
latestRef.current = gridOptions;
|
|
111
|
+
const sentRef = useRef({});
|
|
112
|
+
const portalMapRef = useRef(/* @__PURE__ */ new Map());
|
|
113
|
+
const portalCounterRef = useRef(0);
|
|
114
|
+
const flushScheduledRef = useRef(false);
|
|
115
|
+
const mountedRef = useRef(false);
|
|
116
|
+
const [portals, setPortals] = useState([]);
|
|
117
|
+
const wrappersRef = useRef(null);
|
|
118
|
+
if (!wrappersRef.current) {
|
|
119
|
+
const wrappers = {};
|
|
120
|
+
for (const key of WRAPPED_KEYS) {
|
|
121
|
+
wrappers[key] = (...args) => {
|
|
122
|
+
const fn = latestRef.current[key];
|
|
123
|
+
if (typeof fn === "function") return fn(...args);
|
|
124
|
+
return key === "isRowMaster" ? true : void 0;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const callDetail = (params) => latestRef.current.detailCellRenderer(params);
|
|
128
|
+
wrappers.detailCellRenderer = callDetail;
|
|
129
|
+
wrappers.detailCellRendererVanilla = vanillaRenderer(((params) => callDetail(params)));
|
|
130
|
+
wrappersRef.current = wrappers;
|
|
131
|
+
}
|
|
132
|
+
const toGridOptions = (options) => {
|
|
133
|
+
const out = {};
|
|
134
|
+
for (const [key, value] of Object.entries(options)) {
|
|
135
|
+
if (!WRAPPED_KEYS.has(key)) out[key] = value;
|
|
136
|
+
}
|
|
137
|
+
for (const key of EVENT_KEYS) out[key] = wrappersRef.current[key];
|
|
138
|
+
for (const key of OPTIONAL_FN_KEYS) {
|
|
139
|
+
out[key] = typeof options[key] === "function" ? wrappersRef.current[key] : void 0;
|
|
140
|
+
}
|
|
141
|
+
const detail = options.detailCellRenderer;
|
|
142
|
+
out.detailCellRenderer = typeof detail === "function" && !isClassComponent(detail) ? VANILLA_RENDERER_BRAND in detail ? wrappersRef.current.detailCellRendererVanilla : wrappersRef.current.detailCellRenderer : detail;
|
|
143
|
+
return out;
|
|
144
|
+
};
|
|
145
|
+
const schedulePortalSync = () => {
|
|
146
|
+
if (flushScheduledRef.current) return;
|
|
147
|
+
flushScheduledRef.current = true;
|
|
148
|
+
queueMicrotask(() => {
|
|
149
|
+
flushScheduledRef.current = false;
|
|
150
|
+
if (!mountedRef.current) return;
|
|
151
|
+
flushSync(() => setPortals([...portalMapRef.current.values()]));
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
const mountPortal = (prefix, container, renderer, params) => {
|
|
155
|
+
const id = `${prefix}-${++portalCounterRef.current}`;
|
|
156
|
+
const portalHost = document.createElement("div");
|
|
157
|
+
portalHost.className = "ya-react-cell";
|
|
158
|
+
portalHost.style.display = "contents";
|
|
159
|
+
container.appendChild(portalHost);
|
|
160
|
+
portalMapRef.current.set(id, { id, container: portalHost, renderer, params });
|
|
161
|
+
schedulePortalSync();
|
|
162
|
+
return {
|
|
163
|
+
destroy: () => {
|
|
164
|
+
portalHost.remove();
|
|
165
|
+
if (portalMapRef.current.delete(id)) {
|
|
166
|
+
schedulePortalSync();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
const mountAdapterRef = useRef({
|
|
172
|
+
canMount: (renderer) => isReactCellRenderer(renderer),
|
|
173
|
+
mount: (container, renderer, params) => mountPortal("ya-react-portal", container, renderer, params),
|
|
174
|
+
canMountDetail: (renderer) => isReactCellRenderer(renderer),
|
|
175
|
+
mountDetail: (container, renderer, params) => mountPortal("ya-react-detail-portal", container, renderer, params)
|
|
176
|
+
});
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
const el = hostRef.current;
|
|
179
|
+
if (!el) return;
|
|
180
|
+
mountedRef.current = true;
|
|
181
|
+
const initial = toGridOptions(latestRef.current);
|
|
182
|
+
sentRef.current = initial;
|
|
183
|
+
const api = createGrid(el, {
|
|
184
|
+
...initial,
|
|
185
|
+
componentMountAdapter: mountAdapterRef.current
|
|
186
|
+
});
|
|
187
|
+
apiRef.current = api;
|
|
188
|
+
return () => {
|
|
189
|
+
mountedRef.current = false;
|
|
190
|
+
api.destroy();
|
|
191
|
+
apiRef.current = null;
|
|
192
|
+
portalMapRef.current.clear();
|
|
193
|
+
setPortals([]);
|
|
194
|
+
};
|
|
195
|
+
}, []);
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
const api = apiRef.current;
|
|
198
|
+
if (!api) return;
|
|
199
|
+
const next = toGridOptions(latestRef.current);
|
|
200
|
+
const prev = sentRef.current;
|
|
201
|
+
const changed = {};
|
|
202
|
+
let hasChanges = false;
|
|
203
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(next)])) {
|
|
204
|
+
const value = next[key];
|
|
205
|
+
if (!Object.is(prev[key], value)) {
|
|
206
|
+
changed[key] = value;
|
|
207
|
+
hasChanges = true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
sentRef.current = next;
|
|
211
|
+
if (hasChanges) api.updateOptions(changed);
|
|
212
|
+
});
|
|
213
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
214
|
+
/* @__PURE__ */ jsx(
|
|
215
|
+
"div",
|
|
216
|
+
{
|
|
217
|
+
ref: hostRef,
|
|
218
|
+
className,
|
|
219
|
+
style: { width: "100%", height: "100%", ...style }
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
portals.map(
|
|
223
|
+
(entry) => createPortal(
|
|
224
|
+
/* @__PURE__ */ jsx(CellErrorBoundary, { children: renderCellContent(entry.renderer, entry.params) }),
|
|
225
|
+
entry.container,
|
|
226
|
+
entry.id
|
|
227
|
+
)
|
|
228
|
+
)
|
|
229
|
+
] });
|
|
230
|
+
}
|
|
231
|
+
export {
|
|
232
|
+
YaGrid,
|
|
233
|
+
badgeColumn,
|
|
234
|
+
barColumn,
|
|
235
|
+
booleanColumn,
|
|
236
|
+
createBuiltInColumnTypes,
|
|
237
|
+
currencyColumn,
|
|
238
|
+
percentColumn,
|
|
239
|
+
sparklineColumn,
|
|
240
|
+
vanillaRenderer
|
|
241
|
+
};
|
|
242
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/YaGrid.tsx"],"sourcesContent":["export type {\n AggFunc,\n AggFuncParams,\n BadgeColumnOptions,\n BadgeStyleConfig,\n BadgeTone,\n BarColumnOptions,\n BarColumnThresholds,\n BooleanColumnOptions,\n BuiltInAggFunc,\n CellClassParams,\n CellClickedEvent,\n CellEditorParams,\n CellEditorType,\n CellRenderer,\n CellRendererParams,\n CellValidatorParams,\n CellValueChangedEvent,\n ColDef,\n ColGroupDef,\n ColumnDefItem,\n ColumnFilterModel,\n ColumnMovedEvent,\n ColumnPinnedEvent,\n ColumnResizedEvent,\n ColumnStateItem,\n ColumnTypeDef,\n ColumnVisibilityChangedEvent,\n CsvExportParams,\n CurrencyColumnOptions,\n DetailCellRenderer,\n DetailCellRendererParams,\n EditableParams,\n FilterChangedEvent,\n FilterModel,\n FilterType,\n GlobalSearchConfig,\n GridApi,\n GridDensity,\n GridOptions,\n GridReadyEvent,\n GridState,\n GridThemeMode,\n HeaderGroupMeta,\n PaginationChangedEvent,\n PaginationState,\n PercentColumnOptions,\n PinnedDirection,\n PinnedSummaryConfig,\n ResolvedColDef,\n ResponsivePinningConfig,\n RowClickedEvent,\n RowDataTransaction,\n RowDataTransactionResult,\n RowDetailToggledEvent,\n RowModelType,\n RowNode,\n RowSelectionConfig,\n SelectionChangedEvent,\n ServerSideDatasource,\n ServerSideGetRowsRequest,\n ServerSideGetRowsResult,\n SortChangedEvent,\n SortDirection,\n SortModelItem,\n SparklineColumnOptions,\n StateChangedEvent,\n ValueParserParams,\n ValueSetterParams,\n VirtualizationConfig,\n} from '@ya-grid/core';\nexport {\n badgeColumn,\n barColumn,\n booleanColumn,\n createBuiltInColumnTypes,\n currencyColumn,\n percentColumn,\n sparklineColumn,\n} from '@ya-grid/core';\nexport { vanillaRenderer, YaGrid, type YaGridProps } from './YaGrid.js';\n","import {\n type CellRendererParams,\n type ComponentMountAdapter,\n createGrid,\n type DetailCellRendererParams,\n type GridApi,\n type GridOptions,\n markVanillaRenderer,\n VANILLA_RENDERER_SYMBOL,\n type VanillaCellRendererFn,\n} from '@ya-grid/core';\nimport {\n Component,\n type ComponentType,\n type CSSProperties,\n type ErrorInfo,\n type ReactNode,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal, flushSync } from 'react-dom';\n\nconst VANILLA_RENDERER_BRAND = VANILLA_RENDERER_SYMBOL;\n\n/**\n * Marks a function as a plain DOM cell renderer (returns an HTMLElement or string), so the\n * grid core renders it directly instead of mounting it as a React component.\n */\nexport function vanillaRenderer<TData = Record<string, unknown>, TValue = unknown>(\n fn: VanillaCellRendererFn<TData, TValue>,\n): VanillaCellRendererFn<TData, TValue> {\n return markVanillaRenderer(fn);\n}\n\ntype AnyParams = CellRendererParams<any, any> | DetailCellRendererParams<any>;\n\nfunction isReactCellRenderer(renderer: unknown): boolean {\n if (!renderer) return false;\n if (typeof renderer === 'function') {\n return !(VANILLA_RENDERER_BRAND in renderer);\n }\n // React.memo / React.forwardRef / React.lazy are objects with $$typeof\n return typeof renderer === 'object' && '$$typeof' in (renderer as object);\n}\n\nfunction isClassComponent(renderer: unknown): boolean {\n return (\n typeof renderer === 'function' &&\n Boolean(\n (renderer as { prototype?: { isReactComponent?: unknown } }).prototype?.isReactComponent,\n )\n );\n}\n\n/** Appends a DOM node produced by a plain (unbranded) renderer function. */\nfunction DomNodeHost({ node }: { node: Node }) {\n const ref = useRef<HTMLSpanElement | null>(null);\n useLayoutEffect(() => {\n const host = ref.current;\n if (!host) return;\n host.appendChild(node);\n return () => {\n if (node.parentNode === host) host.removeChild(node);\n };\n }, [node]);\n return <span ref={ref} style={{ display: 'contents' }} />;\n}\n\n/**\n * Renders a plain function renderer. It is called like a function component (its hooks\n * belong to this host, which is created once per renderer), so React components work as\n * before, and a function that returns a DOM node — a vanilla renderer that was not wrapped\n * in vanillaRenderer() — is mounted as DOM instead of crashing React.\n */\nfunction FunctionRendererHost({\n renderer,\n params,\n}: {\n renderer: (p: AnyParams) => unknown;\n params: AnyParams;\n}) {\n const result = renderer(params);\n if (typeof Node !== 'undefined' && result instanceof Node) {\n return <DomNodeHost node={result} />;\n }\n return result as ReactNode;\n}\n\ninterface CellBoundaryProps {\n children: ReactNode;\n}\n\n/** Keeps an error in one cell renderer from unmounting the whole React tree. */\nclass CellErrorBoundary extends Component<CellBoundaryProps, { failed: boolean }> {\n override state = { failed: false };\n\n static getDerivedStateFromError(): { failed: boolean } {\n return { failed: true };\n }\n\n override componentDidCatch(error: Error, info: ErrorInfo): void {\n console.error('[ya-grid] A cell renderer threw an error', error, info.componentStack);\n }\n\n override render(): ReactNode {\n return this.state.failed ? null : this.props.children;\n }\n}\n\nfunction renderCellContent(renderer: unknown, params: AnyParams): ReactNode {\n if (typeof renderer === 'function' && !isClassComponent(renderer)) {\n return (\n <FunctionRendererHost renderer={renderer as (p: AnyParams) => unknown} params={params} />\n );\n }\n const Comp = renderer as ComponentType<any>;\n return <Comp {...params} />;\n}\n\ninterface PortalEntry {\n id: string;\n container: HTMLElement;\n renderer: unknown;\n params: AnyParams;\n}\n\nexport interface YaGridProps<TData = Record<string, unknown>>\n extends Omit<GridOptions<TData>, 'componentMountAdapter'> {\n className?: string;\n style?: CSSProperties;\n}\n\n/** Event props. The grid receives stable wrappers that always call the latest prop. */\nconst EVENT_KEYS = [\n 'onGridReady',\n 'onRowClicked',\n 'onCellClicked',\n 'onCellValueChanged',\n 'onSelectionChanged',\n 'onSortChanged',\n 'onFilterChanged',\n 'onColumnResized',\n 'onColumnMoved',\n 'onColumnPinned',\n 'onColumnVisibilityChanged',\n 'onPaginationChanged',\n 'onStateChanged',\n 'onRowDetailToggled',\n] as const satisfies readonly (keyof GridOptions)[];\n\n/**\n * Function props whose presence changes grid behaviour. They are wrapped too (so inline\n * arrow functions do not re-key rows or re-render on every parent render), but the wrapper\n * is only passed while the prop is set.\n */\nconst OPTIONAL_FN_KEYS = [\n 'getRowId',\n 'isRowMaster',\n] as const satisfies readonly (keyof GridOptions)[];\n\nconst WRAPPED_KEYS = new Set<string>([...EVENT_KEYS, ...OPTIONAL_FN_KEYS, 'detailCellRenderer']);\n\ntype Options<TData> = Omit<YaGridProps<TData>, 'className' | 'style'>;\n\nexport function YaGrid<TData = Record<string, unknown>>(props: YaGridProps<TData>) {\n const { className, style, ...gridOptions } = props;\n const hostRef = useRef<HTMLDivElement | null>(null);\n const apiRef = useRef<GridApi<TData> | null>(null);\n const latestRef = useRef<Options<TData>>(gridOptions);\n latestRef.current = gridOptions;\n /** Options as last sent to the grid; only differences are sent on re-render. */\n const sentRef = useRef<Partial<GridOptions<TData>>>({});\n\n const portalMapRef = useRef(new Map<string, PortalEntry>());\n const portalCounterRef = useRef(0);\n const flushScheduledRef = useRef(false);\n const mountedRef = useRef(false);\n const [portals, setPortals] = useState<PortalEntry[]>([]);\n\n const wrappersRef = useRef<Record<string, (...args: never[]) => unknown> | null>(null);\n if (!wrappersRef.current) {\n const wrappers: Record<string, (...args: never[]) => unknown> = {};\n for (const key of WRAPPED_KEYS) {\n wrappers[key] = (...args: never[]) => {\n const fn = (latestRef.current as Record<string, unknown>)[key];\n if (typeof fn === 'function') return fn(...args);\n // isRowMaster wrapper is only installed while the prop exists; default to \"master\"\n return key === 'isRowMaster' ? true : undefined;\n };\n }\n // detailCellRenderer: an inline function would change identity on every render and make\n // the grid re-render all rows. Pass a stable wrapper that calls the latest function; a\n // vanillaRenderer() function gets a branded wrapper so the core still renders it as DOM.\n const callDetail = (params: never) =>\n (latestRef.current.detailCellRenderer as unknown as (p: never) => unknown)(params);\n wrappers.detailCellRenderer = callDetail;\n wrappers.detailCellRendererVanilla = vanillaRenderer(((params: never) =>\n callDetail(params)) as unknown as VanillaCellRendererFn) as unknown as (\n ...args: never[]\n ) => unknown;\n wrappersRef.current = wrappers;\n }\n\n /** Grid options for the current props: plain values plus wrappers for function props. */\n const toGridOptions = (options: Options<TData>): Partial<GridOptions<TData>> => {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(options)) {\n if (!WRAPPED_KEYS.has(key)) out[key] = value;\n }\n for (const key of EVENT_KEYS) out[key] = wrappersRef.current![key];\n for (const key of OPTIONAL_FN_KEYS) {\n out[key] = typeof options[key] === 'function' ? wrappersRef.current![key] : undefined;\n }\n const detail = options.detailCellRenderer;\n out.detailCellRenderer =\n typeof detail === 'function' && !isClassComponent(detail)\n ? VANILLA_RENDERER_BRAND in detail\n ? wrappersRef.current!.detailCellRendererVanilla\n : wrappersRef.current!.detailCellRenderer\n : detail;\n return out as Partial<GridOptions<TData>>;\n };\n\n const schedulePortalSync = () => {\n if (flushScheduledRef.current) return;\n flushScheduledRef.current = true;\n queueMicrotask(() => {\n flushScheduledRef.current = false;\n if (!mountedRef.current) return;\n // Commit portal changes before the browser paints, so recycled cells never show\n // a blank frame (a plain state update could be rendered in a later task)\n flushSync(() => setPortals([...portalMapRef.current.values()]));\n });\n };\n\n const mountPortal = (\n prefix: string,\n container: HTMLElement,\n renderer: unknown,\n params: AnyParams,\n ) => {\n const id = `${prefix}-${++portalCounterRef.current}`;\n // Render into an element this adapter owns. The core may clear or replace the cell's\n // children at any time (live patches, editing); React must only ever remove nodes from\n // a parent it controls, otherwise its deferred unmount throws \"removeChild\" errors.\n const portalHost = document.createElement('div');\n portalHost.className = 'ya-react-cell';\n portalHost.style.display = 'contents';\n container.appendChild(portalHost);\n portalMapRef.current.set(id, { id, container: portalHost, renderer, params });\n schedulePortalSync();\n return {\n destroy: () => {\n // Detach right away so stale content never shows next to its replacement; React\n // unmounts the portal from the detached host on the next sync.\n portalHost.remove();\n if (portalMapRef.current.delete(id)) {\n schedulePortalSync();\n }\n },\n };\n };\n\n const mountAdapterRef = useRef<ComponentMountAdapter>({\n canMount: (renderer) => isReactCellRenderer(renderer),\n mount: (container, renderer, params) =>\n mountPortal('ya-react-portal', container, renderer, params),\n canMountDetail: (renderer) => isReactCellRenderer(renderer),\n mountDetail: (container, renderer, params) =>\n mountPortal('ya-react-detail-portal', container, renderer, params),\n });\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: the grid is created once per mount; later prop changes go through updateOptions below.\n useEffect(() => {\n const el = hostRef.current;\n if (!el) return;\n mountedRef.current = true;\n\n const initial = toGridOptions(latestRef.current);\n sentRef.current = initial;\n const api = createGrid<TData>(el, {\n ...(initial as GridOptions<TData>),\n componentMountAdapter: mountAdapterRef.current,\n });\n apiRef.current = api;\n\n return () => {\n mountedRef.current = false;\n api.destroy();\n apiRef.current = null;\n portalMapRef.current.clear();\n setPortals([]);\n };\n }, []);\n\n // After every render, send only the options whose values changed since the last update.\n // Re-sending unchanged props would overwrite state the grid changed itself (rows from\n // applyTransaction, the user's search text, theme set through the API, ...).\n useEffect(() => {\n const api = apiRef.current;\n if (!api) return;\n const next = toGridOptions(latestRef.current);\n const prev = sentRef.current;\n const changed: Record<string, unknown> = {};\n let hasChanges = false;\n for (const key of new Set([...Object.keys(prev), ...Object.keys(next)])) {\n const value = (next as Record<string, unknown>)[key];\n if (!Object.is((prev as Record<string, unknown>)[key], value)) {\n changed[key] = value;\n hasChanges = true;\n }\n }\n sentRef.current = next;\n if (hasChanges) api.updateOptions(changed as Partial<GridOptions<TData>>);\n });\n\n return (\n <>\n <div\n ref={hostRef}\n className={className}\n style={{ width: '100%', height: '100%', ...style }}\n />\n {portals.map((entry) =>\n createPortal(\n <CellErrorBoundary>{renderCellContent(entry.renderer, entry.params)}</CellErrorBoundary>,\n entry.container,\n entry.id,\n ),\n )}\n </>\n );\n}\n"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UAAM,OAAO,cAAc,UAAU,OAAO;AAC5C,UAAM,OAAO,QAAQ;AACrB,UAAM,UAAmC,CAAC;AAC1C,QAAI,aAAa;AACjB,eAAW,OAAO,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,IAAI,GAAG,GAAG,OAAO,KAAK,IAAI,CAAC,CAAC,GAAG;AACvE,YAAM,QAAS,KAAiC,GAAG;AACnD,UAAI,CAAC,OAAO,GAAI,KAAiC,GAAG,GAAG,KAAK,GAAG;AAC7D,gBAAQ,GAAG,IAAI;AACf,qBAAa;AAAA,MACf;AAAA,IACF;AACA,YAAQ,UAAU;AAClB,QAAI,WAAY,KAAI,cAAc,OAAsC;AAAA,EAC1E,CAAC;AAED,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA,OAAO,EAAE,OAAO,QAAQ,QAAQ,QAAQ,GAAG,MAAM;AAAA;AAAA,IACnD;AAAA,IACC,QAAQ;AAAA,MAAI,CAAC,UACZ;AAAA,QACE,oBAAC,qBAAmB,4BAAkB,MAAM,UAAU,MAAM,MAAM,GAAE;AAAA,QACpE,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ya-grid/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "React 18/19 adapter for YA-Grid with Portal-based custom cell and Master-Detail renderers",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Erik-Jan van Baaren <erikjan@gmail.com>",
|
|
7
|
+
"homepage": "https://github.com/eriky/ya-grid#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/eriky/ya-grid.git",
|
|
11
|
+
"directory": "packages/react"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/eriky/ya-grid/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"react",
|
|
18
|
+
"data-grid",
|
|
19
|
+
"datagrid",
|
|
20
|
+
"table",
|
|
21
|
+
"virtualization",
|
|
22
|
+
"ya-grid"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"module": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@ya-grid/core": "0.4.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": ">=18.0.0",
|
|
47
|
+
"react-dom": ">=18.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/react": "^19.1.0",
|
|
51
|
+
"@types/react-dom": "^19.1.0",
|
|
52
|
+
"react": "^19.1.0",
|
|
53
|
+
"react-dom": "^19.1.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup src/index.ts --format esm --dts --clean --sourcemap --external react --external react-dom --external @ya-grid/core",
|
|
57
|
+
"typecheck": "tsc --noEmit"
|
|
58
|
+
}
|
|
6
59
|
}
|