@azrico/reactgrid 1.0.17 → 1.0.19
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/views/DataGrid.d.ts +2 -0
- package/dist/src/views/DataGrid.js +16 -10
- package/package.json +1 -1
- package/src/views/DataGrid.tsx +23 -12
|
@@ -54,6 +54,8 @@ export type AzGridProps = {
|
|
|
54
54
|
onRowDoubleClick?: (rowIndex: number, row: any) => void;
|
|
55
55
|
onLimitChange?: (v: number) => void;
|
|
56
56
|
onSkipChange?: (v: number) => void;
|
|
57
|
+
skip?: number;
|
|
58
|
+
limit?: number;
|
|
57
59
|
loading?: boolean;
|
|
58
60
|
dark?: boolean;
|
|
59
61
|
allowChildRows?: boolean;
|
|
@@ -30,6 +30,7 @@ const defaultColumnOptions = {
|
|
|
30
30
|
draggable: false,
|
|
31
31
|
lockable: false
|
|
32
32
|
};
|
|
33
|
+
const dynamic_option_names = ['selected', 'loading', 'limit', 'skip'];
|
|
33
34
|
/* -------------------------------------------------------------------------- */
|
|
34
35
|
function AzGrid(props) {
|
|
35
36
|
const [pendingChanges, set_pendingChanges] = _react.default.useState(1);
|
|
@@ -185,7 +186,7 @@ function DataGrid(props) {
|
|
|
185
186
|
/* -------------------------------------------------------------------------- */
|
|
186
187
|
/* Create the grid */
|
|
187
188
|
/* -------------------------------------------------------------------------- */
|
|
188
|
-
const
|
|
189
|
+
const base_gridOptions = _react.default.useMemo(() => {
|
|
189
190
|
const firstcolumn = columns[0];
|
|
190
191
|
const licenseKey = props.licenseKey || get_default_key();
|
|
191
192
|
const events = {
|
|
@@ -205,19 +206,24 @@ function DataGrid(props) {
|
|
|
205
206
|
return {
|
|
206
207
|
...defaultOptions,
|
|
207
208
|
...events,
|
|
208
|
-
...extra_ops
|
|
209
|
-
...props.gridOptions,
|
|
210
|
-
...forcedOptions
|
|
209
|
+
...extra_ops
|
|
211
210
|
};
|
|
212
211
|
}, [props.gridOptions]);
|
|
213
|
-
const
|
|
212
|
+
const static_gridOptions = _react.default.useMemo(() => {
|
|
214
213
|
return {
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
...base_gridOptions,
|
|
215
|
+
...props.gridOptions,
|
|
216
|
+
...forcedOptions
|
|
217
217
|
};
|
|
218
|
-
}, [props.
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
}, [props.gridOptions, base_gridOptions]);
|
|
219
|
+
const dynamic_gridOptions = _react.default.useMemo(() => {
|
|
220
|
+
const res = {};
|
|
221
|
+
dynamic_option_names.map(r => {
|
|
222
|
+
res[r] = props[r];
|
|
223
|
+
});
|
|
224
|
+
return res;
|
|
225
|
+
}, dynamic_option_names.map(r => props[r]));
|
|
226
|
+
/* --------------------------------- events --------------------------------- */
|
|
221
227
|
function onRowContextMenu(row, ev) {
|
|
222
228
|
if (_helpers.func_selection.has_selection()) return;
|
|
223
229
|
update_menuAnchorEl(_helpers.func_selection.getVirtualElement(ev.clientX, ev.clientY));
|
package/package.json
CHANGED
package/src/views/DataGrid.tsx
CHANGED
|
@@ -69,13 +69,17 @@ export type AzGridProps = {
|
|
|
69
69
|
RowDetail?: RowDetailsFunc;
|
|
70
70
|
|
|
71
71
|
selected?: RowSelectionValue;
|
|
72
|
+
/* -------------------------------------------------------------------------- */
|
|
72
73
|
onSelectionChange?: OnSelectionChangeFunc;
|
|
73
74
|
onRowsChange?: (rows: any[], options: any) => void;
|
|
74
75
|
onRowClick?: (rowIndex: number, row: any) => void;
|
|
75
76
|
onRowDoubleClick?: (rowIndex: number, row: any) => void;
|
|
76
77
|
onLimitChange?: (v: number) => void;
|
|
77
78
|
onSkipChange?: (v: number) => void;
|
|
78
|
-
|
|
79
|
+
/* -------------------------------------------------------------------------- */
|
|
80
|
+
skip?: number;
|
|
81
|
+
limit?: number;
|
|
82
|
+
//
|
|
79
83
|
loading?: boolean;
|
|
80
84
|
dark?: boolean;
|
|
81
85
|
allowChildRows?: boolean;
|
|
@@ -105,7 +109,7 @@ const defaultColumnOptions: ColumnDefinition = {
|
|
|
105
109
|
draggable: false,
|
|
106
110
|
lockable: false,
|
|
107
111
|
};
|
|
108
|
-
|
|
112
|
+
const dynamic_option_names = ['selected', 'loading', 'limit', 'skip'];
|
|
109
113
|
/* -------------------------------------------------------------------------- */
|
|
110
114
|
export function AzGrid(props: AzGridProps) {
|
|
111
115
|
const [pendingChanges, set_pendingChanges] = React.useState<number>(1);
|
|
@@ -263,9 +267,8 @@ function DataGrid(props: DataGridProps) {
|
|
|
263
267
|
/* Create the grid */
|
|
264
268
|
/* -------------------------------------------------------------------------- */
|
|
265
269
|
|
|
266
|
-
const
|
|
270
|
+
const base_gridOptions = React.useMemo<GridOptions>(() => {
|
|
267
271
|
const firstcolumn = columns[0];
|
|
268
|
-
|
|
269
272
|
const licenseKey = props.licenseKey || get_default_key();
|
|
270
273
|
const events: GridOptions = {
|
|
271
274
|
onRowClick: props.onRowClick ? onRowClick : undefined,
|
|
@@ -281,16 +284,24 @@ function DataGrid(props: DataGridProps) {
|
|
|
281
284
|
renderRowDetails: props.RowDetail,
|
|
282
285
|
theme: dark ? 'amber-dark' : 'default-light',
|
|
283
286
|
};
|
|
284
|
-
return { ...defaultOptions, ...events, ...extra_ops
|
|
287
|
+
return { ...defaultOptions, ...events, ...extra_ops };
|
|
285
288
|
}, [props.gridOptions]);
|
|
286
|
-
const
|
|
287
|
-
return {
|
|
288
|
-
}, [props.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
const static_gridOptions = React.useMemo<GridOptions>(() => {
|
|
290
|
+
return { ...base_gridOptions, ...props.gridOptions, ...forcedOptions };
|
|
291
|
+
}, [props.gridOptions, base_gridOptions]);
|
|
292
|
+
|
|
293
|
+
const dynamic_gridOptions = React.useMemo<GridOptions>(
|
|
294
|
+
() => {
|
|
295
|
+
const res = {};
|
|
296
|
+
dynamic_option_names.map((r) => {
|
|
297
|
+
res[r] = props[r];
|
|
298
|
+
});
|
|
299
|
+
return res;
|
|
300
|
+
},
|
|
301
|
+
dynamic_option_names.map((r) => props[r])
|
|
302
|
+
);
|
|
293
303
|
|
|
304
|
+
/* --------------------------------- events --------------------------------- */
|
|
294
305
|
function onRowContextMenu(row: TypeRowProps, ev: any) {
|
|
295
306
|
if (func_selection.has_selection()) return;
|
|
296
307
|
update_menuAnchorEl(func_selection.getVirtualElement(ev.clientX, ev.clientY));
|