@azrico/reactgrid 1.1.27 → 1.1.29
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/dist/src/example.js
CHANGED
|
@@ -108,7 +108,7 @@ function ExampleGrid() {
|
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
const onRowDoubleClick = _react.default.useCallback((index, rowdata) => {
|
|
111
|
-
console.log((rowdata === null || rowdata === void 0 ? void 0 : rowdata.data) || rowdata);
|
|
111
|
+
console.log('dbl', (rowdata === null || rowdata === void 0 ? void 0 : rowdata.data) || rowdata);
|
|
112
112
|
}, []);
|
|
113
113
|
const onRowClick = _react.default.useCallback((index, rowdata) => {
|
|
114
114
|
//console.log(rowdata?.data || rowdata);
|
|
@@ -148,7 +148,6 @@ function AzGrid(props) {
|
|
|
148
148
|
}, dynamic_option_names.map(r => props[r]));
|
|
149
149
|
return _react.default.createElement(DataGridEventsWrapper, {
|
|
150
150
|
...props,
|
|
151
|
-
base_gridOptions: base_gridOptions,
|
|
152
151
|
static_gridOptions: static_gridOptions,
|
|
153
152
|
dynamic_gridOptions: dynamic_gridOptions,
|
|
154
153
|
columns: cached_columns,
|
|
@@ -186,7 +185,7 @@ function DataGridEventsWrapper(props) {
|
|
|
186
185
|
}
|
|
187
186
|
click_data.current[get_row_id(rowProps)] = nowDate;
|
|
188
187
|
return props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
189
|
-
}, []);
|
|
188
|
+
}, [props.onRowClick, props.onRowDoubleClick]);
|
|
190
189
|
_react.default.useEffect(() => {
|
|
191
190
|
click_data.current = {};
|
|
192
191
|
}, [props.dataSource]);
|
|
@@ -201,19 +200,22 @@ function DataGridEventsWrapper(props) {
|
|
|
201
200
|
set_menuRow(r);
|
|
202
201
|
} else set_menuRow(null);
|
|
203
202
|
}, []);
|
|
204
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Merge click events into grid options
|
|
205
|
+
*/
|
|
206
|
+
const static_gridOptions = _react.default.useMemo(() => {
|
|
205
207
|
const events = {
|
|
206
208
|
onRowClick: onRowClick,
|
|
207
209
|
onRowContextMenu: onRowContextMenu
|
|
208
210
|
};
|
|
209
211
|
return {
|
|
210
|
-
...props.
|
|
212
|
+
...props.static_gridOptions,
|
|
211
213
|
...events
|
|
212
214
|
};
|
|
213
|
-
}, [props.
|
|
215
|
+
}, [props.static_gridOptions, onRowClick]);
|
|
214
216
|
return _react.default.createElement(DataGridSizeWrapper, {
|
|
215
217
|
...props,
|
|
216
|
-
|
|
218
|
+
static_gridOptions: static_gridOptions
|
|
217
219
|
}, _react.default.createElement(_controls.ContextMenu, {
|
|
218
220
|
menuAnchorEl: menuAnchorEl,
|
|
219
221
|
set_menuAnchorEl: update_menuAnchorEl,
|
|
@@ -222,6 +224,7 @@ function DataGridEventsWrapper(props) {
|
|
|
222
224
|
}), props.children);
|
|
223
225
|
}
|
|
224
226
|
function DataGridSizeWrapper(props) {
|
|
227
|
+
console.log(props);
|
|
225
228
|
if (props.delayedSize) {
|
|
226
229
|
return _react.default.createElement(DataGridDelayedSize, {
|
|
227
230
|
...props
|
package/package.json
CHANGED
package/src/example.tsx
CHANGED
|
@@ -95,7 +95,7 @@ export function ExampleGrid() {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
const onRowDoubleClick = React.useCallback((index: number, rowdata: any) => {
|
|
98
|
-
console.log(rowdata?.data || rowdata);
|
|
98
|
+
console.log('dbl', rowdata?.data || rowdata);
|
|
99
99
|
}, []);
|
|
100
100
|
const onRowClick = React.useCallback((index: number, rowdata: any) => {
|
|
101
101
|
//console.log(rowdata?.data || rowdata);
|
package/src/views/DataGrid.tsx
CHANGED
|
@@ -116,9 +116,8 @@ type DataGridProps = ModifyFields<
|
|
|
116
116
|
type DataGridWrapperProps = ModifyFields<
|
|
117
117
|
DataGridProps,
|
|
118
118
|
{
|
|
119
|
-
base_gridOptions: GridOptions;
|
|
120
|
-
dynamic_gridOptions: GridOptions;
|
|
121
119
|
static_gridOptions: GridOptions;
|
|
120
|
+
dynamic_gridOptions: GridOptions;
|
|
122
121
|
children?: React.ReactNode;
|
|
123
122
|
}
|
|
124
123
|
>;
|
|
@@ -273,7 +272,6 @@ export function AzGrid(props: AzGridProps) {
|
|
|
273
272
|
return (
|
|
274
273
|
<DataGridEventsWrapper
|
|
275
274
|
{...props}
|
|
276
|
-
base_gridOptions={base_gridOptions}
|
|
277
275
|
static_gridOptions={static_gridOptions}
|
|
278
276
|
dynamic_gridOptions={dynamic_gridOptions}
|
|
279
277
|
columns={cached_columns}
|
|
@@ -305,23 +303,26 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
|
|
|
305
303
|
update_menuAnchorEl(func_selection.getVirtualElement(event.clientX, event.clientY));
|
|
306
304
|
event.preventDefault();
|
|
307
305
|
}, []);
|
|
308
|
-
const onRowClick = React.useCallback(
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
306
|
+
const onRowClick = React.useCallback(
|
|
307
|
+
(rowProps, event) => {
|
|
308
|
+
const nowDate = Date.now();
|
|
309
|
+
const lastclick: number = click_data.current[get_row_id(rowProps)];
|
|
310
|
+
if (lastclick) {
|
|
311
|
+
const diffTime = Math.abs(nowDate - lastclick);
|
|
312
|
+
if (diffTime < 400) {
|
|
313
|
+
click_data.current[get_row_id(rowProps)] = null;
|
|
314
|
+
return (
|
|
315
|
+
props.onRowDoubleClick &&
|
|
316
|
+
props.onRowDoubleClick(rowProps.rowIndex, rowProps.data)
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
319
|
}
|
|
320
|
-
}
|
|
321
320
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
321
|
+
click_data.current[get_row_id(rowProps)] = nowDate;
|
|
322
|
+
return props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
323
|
+
},
|
|
324
|
+
[props.onRowClick, props.onRowDoubleClick]
|
|
325
|
+
);
|
|
325
326
|
|
|
326
327
|
React.useEffect(() => {
|
|
327
328
|
click_data.current = {};
|
|
@@ -340,16 +341,19 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
|
|
|
340
341
|
} else set_menuRow(null);
|
|
341
342
|
}, []);
|
|
342
343
|
|
|
343
|
-
|
|
344
|
+
/**
|
|
345
|
+
* Merge click events into grid options
|
|
346
|
+
*/
|
|
347
|
+
const static_gridOptions = React.useMemo<GridOptions>(() => {
|
|
344
348
|
const events: GridOptions = {
|
|
345
349
|
onRowClick: onRowClick,
|
|
346
350
|
onRowContextMenu: onRowContextMenu,
|
|
347
351
|
};
|
|
348
|
-
return { ...props.
|
|
349
|
-
}, [props.
|
|
352
|
+
return { ...props.static_gridOptions, ...events };
|
|
353
|
+
}, [props.static_gridOptions, onRowClick]);
|
|
350
354
|
|
|
351
355
|
return (
|
|
352
|
-
<DataGridSizeWrapper {...props}
|
|
356
|
+
<DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions}>
|
|
353
357
|
<ContextMenu
|
|
354
358
|
menuAnchorEl={menuAnchorEl}
|
|
355
359
|
set_menuAnchorEl={update_menuAnchorEl}
|
|
@@ -361,6 +365,7 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
|
|
|
361
365
|
);
|
|
362
366
|
}
|
|
363
367
|
function DataGridSizeWrapper(props: DataGridWrapperProps) {
|
|
368
|
+
console.log(props);
|
|
364
369
|
if (props.delayedSize) {
|
|
365
370
|
return <DataGridDelayedSize {...props} />;
|
|
366
371
|
} else {
|