@azrico/reactgrid 1.2.36 → 1.2.37
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/CHANGELOG.md +14 -0
- package/dist/src/views/DataGrid.js +20 -22
- package/package.json +1 -1
- package/src/views/DataGrid.tsx +30 -30
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.2.37](https://github.com/Azrideus/azrico-reactgrid/compare/v1.2.10...v1.2.37) (2023-07-09)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* editable can be a function ([6ea857e](https://github.com/Azrideus/azrico-reactgrid/commit/6ea857e4f403d2a334dc5e74065f6b8033277ca4))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* DataGridDelayedSizeWrapper actual delayed ([2ddfd2f](https://github.com/Azrideus/azrico-reactgrid/commit/2ddfd2fb58c90bd906e1330f22f0ef7468d34afb))
|
|
16
|
+
* onCellSelectionChange ([95c8f54](https://github.com/Azrideus/azrico-reactgrid/commit/95c8f540e94dde0c7e245fb29fb6afc7172957ec))
|
|
17
|
+
* styling ([9018f75](https://github.com/Azrideus/azrico-reactgrid/commit/9018f7593e253720f751f52855a2d956dfc578ed))
|
|
18
|
+
|
|
5
19
|
### [1.2.36](https://github.com/Azrideus/azrico-reactgrid/compare/v1.2.10...v1.2.36) (2023-07-09)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -115,15 +115,7 @@ function DataGridEventsWrapper(props) {
|
|
|
115
115
|
/* -------------------------------------------------------------------------- */
|
|
116
116
|
const click_data = _react.default.useRef(null);
|
|
117
117
|
const [menuAnchorEl, set_menuAnchorEl] = _react.default.useState(null);
|
|
118
|
-
const [menuRow, set_menuRow] = _react.default.useState(null);
|
|
119
118
|
/* --------------------------------- events --------------------------------- */
|
|
120
|
-
const onRowContextMenu = _react.default.useCallback((rowProps, event) => {
|
|
121
|
-
if (!rowProps || !rowProps.data || _func_child.func_selection.has_selection()) return;
|
|
122
|
-
const anEl = _func_child.func_selection.getVirtualElement(event.clientX, event.clientY);
|
|
123
|
-
update_menuRow(rowProps.data);
|
|
124
|
-
update_menuAnchorEl(anEl);
|
|
125
|
-
event.preventDefault();
|
|
126
|
-
}, []);
|
|
127
119
|
const onRowClick = _react.default.useCallback((rowProps, event) => {
|
|
128
120
|
const nowDate = Date.now();
|
|
129
121
|
const lastclick = click_data.current[(0, _func_grid.get_row_id)(rowProps)];
|
|
@@ -141,12 +133,22 @@ function DataGridEventsWrapper(props) {
|
|
|
141
133
|
click_data.current = {};
|
|
142
134
|
}, [props.dataSource]);
|
|
143
135
|
/* ------------------------------- ContextMenu ------------------------------ */
|
|
136
|
+
const onRowContextMenu = _react.default.useCallback((rowProps, event) => {
|
|
137
|
+
if (!rowProps || !rowProps.data || _func_child.func_selection.has_selection()) return;
|
|
138
|
+
const anEl = _func_child.func_selection.getVirtualElement(event.clientX, event.clientY);
|
|
139
|
+
update_menuAnchorEl(anEl);
|
|
140
|
+
}, []);
|
|
141
|
+
const renderRowContextMenu = _react.default.useCallback((menuProps, rowProps) => {
|
|
142
|
+
return _react.default.createElement(_controls.ContextMenu, {
|
|
143
|
+
menuAnchorEl: menuAnchorEl,
|
|
144
|
+
set_menuAnchorEl: update_menuAnchorEl,
|
|
145
|
+
menuRow: rowProps.data,
|
|
146
|
+
menu_items: props.contextMenuItems
|
|
147
|
+
});
|
|
148
|
+
}, [props.contextMenuItems]);
|
|
144
149
|
const update_menuAnchorEl = _react.default.useCallback(el => {
|
|
145
150
|
set_menuAnchorEl(el || null);
|
|
146
151
|
}, []);
|
|
147
|
-
const update_menuRow = _react.default.useCallback(r => {
|
|
148
|
-
set_menuRow(r || null);
|
|
149
|
-
}, []);
|
|
150
152
|
/**
|
|
151
153
|
* Merge click events into grid options
|
|
152
154
|
*/
|
|
@@ -155,30 +157,26 @@ function DataGridEventsWrapper(props) {
|
|
|
155
157
|
onRowClick: onRowClick,
|
|
156
158
|
onRowContextMenu: onRowContextMenu
|
|
157
159
|
};
|
|
160
|
+
const contextmenuProps = {
|
|
161
|
+
renderRowContextMenu: renderRowContextMenu
|
|
162
|
+
};
|
|
158
163
|
return {
|
|
159
164
|
...props.static_gridOptions,
|
|
160
|
-
...events
|
|
165
|
+
...events,
|
|
166
|
+
...contextmenuProps
|
|
161
167
|
};
|
|
162
168
|
}, [props.static_gridOptions, onRowClick]);
|
|
163
169
|
/* -------------------------------------------------------------------------- */
|
|
164
|
-
const contextMenu = _react.default.useMemo(() => {
|
|
165
|
-
return _react.default.createElement(_controls.ContextMenu, {
|
|
166
|
-
menuAnchorEl: menuAnchorEl,
|
|
167
|
-
set_menuAnchorEl: update_menuAnchorEl,
|
|
168
|
-
menuRow: menuRow,
|
|
169
|
-
menu_items: props.contextMenuItems
|
|
170
|
-
});
|
|
171
|
-
}, [menuRow, menuAnchorEl, props.contextMenuItems]);
|
|
172
170
|
if (props.details_dataSource) {
|
|
173
171
|
return _react.default.createElement(DataGridDetailsWrapper, {
|
|
174
172
|
...props,
|
|
175
173
|
static_gridOptions: static_gridOptions
|
|
176
|
-
}
|
|
174
|
+
});
|
|
177
175
|
} else {
|
|
178
176
|
return _react.default.createElement(DataGridSizeWrapper, {
|
|
179
177
|
...props,
|
|
180
178
|
static_gridOptions: static_gridOptions
|
|
181
|
-
}
|
|
179
|
+
});
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
function DataGridDetailsWrapper(props) {
|
package/package.json
CHANGED
package/src/views/DataGrid.tsx
CHANGED
|
@@ -259,18 +259,9 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
|
|
|
259
259
|
const click_data = React.useRef<any>(null);
|
|
260
260
|
|
|
261
261
|
const [menuAnchorEl, set_menuAnchorEl] = React.useState<any>(null);
|
|
262
|
-
const [menuRow, set_menuRow] = React.useState<any>(null);
|
|
263
262
|
|
|
264
263
|
/* --------------------------------- events --------------------------------- */
|
|
265
264
|
|
|
266
|
-
const onRowContextMenu = React.useCallback((rowProps, event) => {
|
|
267
|
-
if (!rowProps || !rowProps.data || func_selection.has_selection()) return;
|
|
268
|
-
|
|
269
|
-
const anEl = func_selection.getVirtualElement(event.clientX, event.clientY);
|
|
270
|
-
update_menuRow(rowProps.data);
|
|
271
|
-
update_menuAnchorEl(anEl);
|
|
272
|
-
event.preventDefault();
|
|
273
|
-
}, []);
|
|
274
265
|
const onRowClick = React.useCallback(
|
|
275
266
|
(rowProps, event) => {
|
|
276
267
|
const nowDate = Date.now();
|
|
@@ -297,13 +288,27 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
|
|
|
297
288
|
}, [props.dataSource]);
|
|
298
289
|
|
|
299
290
|
/* ------------------------------- ContextMenu ------------------------------ */
|
|
300
|
-
|
|
291
|
+
const onRowContextMenu = React.useCallback((rowProps, event) => {
|
|
292
|
+
if (!rowProps || !rowProps.data || func_selection.has_selection()) return;
|
|
293
|
+
const anEl = func_selection.getVirtualElement(event.clientX, event.clientY);
|
|
294
|
+
update_menuAnchorEl(anEl);
|
|
295
|
+
}, []);
|
|
296
|
+
const renderRowContextMenu = React.useCallback(
|
|
297
|
+
(menuProps, rowProps) => {
|
|
298
|
+
return (
|
|
299
|
+
<ContextMenu
|
|
300
|
+
menuAnchorEl={menuAnchorEl}
|
|
301
|
+
set_menuAnchorEl={update_menuAnchorEl}
|
|
302
|
+
menuRow={rowProps.data}
|
|
303
|
+
menu_items={props.contextMenuItems as any}
|
|
304
|
+
/>
|
|
305
|
+
);
|
|
306
|
+
},
|
|
307
|
+
[props.contextMenuItems]
|
|
308
|
+
);
|
|
301
309
|
const update_menuAnchorEl = React.useCallback((el) => {
|
|
302
310
|
set_menuAnchorEl(el || null);
|
|
303
311
|
}, []);
|
|
304
|
-
const update_menuRow = React.useCallback((r) => {
|
|
305
|
-
set_menuRow(r || null);
|
|
306
|
-
}, []);
|
|
307
312
|
|
|
308
313
|
/**
|
|
309
314
|
* Merge click events into grid options
|
|
@@ -313,32 +318,27 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
|
|
|
313
318
|
onRowClick: onRowClick,
|
|
314
319
|
onRowContextMenu: onRowContextMenu,
|
|
315
320
|
};
|
|
316
|
-
|
|
321
|
+
const contextmenuProps: AzGridOptions = {
|
|
322
|
+
renderRowContextMenu: renderRowContextMenu,
|
|
323
|
+
};
|
|
324
|
+
return { ...props.static_gridOptions, ...events, ...contextmenuProps };
|
|
317
325
|
}, [props.static_gridOptions, onRowClick]);
|
|
318
326
|
|
|
319
327
|
/* -------------------------------------------------------------------------- */
|
|
320
|
-
const contextMenu = React.useMemo(() => {
|
|
321
|
-
return (
|
|
322
|
-
<ContextMenu
|
|
323
|
-
menuAnchorEl={menuAnchorEl}
|
|
324
|
-
set_menuAnchorEl={update_menuAnchorEl}
|
|
325
|
-
menuRow={menuRow}
|
|
326
|
-
menu_items={props.contextMenuItems as any}
|
|
327
|
-
/>
|
|
328
|
-
);
|
|
329
|
-
}, [menuRow, menuAnchorEl, props.contextMenuItems]);
|
|
330
328
|
|
|
331
329
|
if (props.details_dataSource) {
|
|
332
330
|
return (
|
|
333
|
-
<DataGridDetailsWrapper
|
|
334
|
-
{
|
|
335
|
-
|
|
331
|
+
<DataGridDetailsWrapper
|
|
332
|
+
{...props}
|
|
333
|
+
static_gridOptions={static_gridOptions}
|
|
334
|
+
></DataGridDetailsWrapper>
|
|
336
335
|
);
|
|
337
336
|
} else {
|
|
338
337
|
return (
|
|
339
|
-
<DataGridSizeWrapper
|
|
340
|
-
{
|
|
341
|
-
|
|
338
|
+
<DataGridSizeWrapper
|
|
339
|
+
{...props}
|
|
340
|
+
static_gridOptions={static_gridOptions}
|
|
341
|
+
></DataGridSizeWrapper>
|
|
342
342
|
);
|
|
343
343
|
}
|
|
344
344
|
}
|