@etsoo/react 1.6.63 → 1.6.64
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.
|
@@ -81,7 +81,7 @@ export type GridCellRendererProps<T, P = any> = GridCellFormatterProps<T> & {
|
|
|
81
81
|
* Set items for rerenderer
|
|
82
82
|
* @param callback Callback
|
|
83
83
|
*/
|
|
84
|
-
setItems: (callback: (items: T[], ref
|
|
84
|
+
setItems: (callback: ((items: T[]) => T[] | undefined | void) | ((items: T[], ref: ScrollerGridForwardRef<T>) => T[] | undefined | void)) => void;
|
|
85
85
|
};
|
|
86
86
|
/**
|
|
87
87
|
* Grid header cell renderer props
|
|
@@ -12,7 +12,7 @@ export type ScrollerGridItemRendererProps<T> = Omit<GridChildComponentProps<T>,
|
|
|
12
12
|
* Set items for rerenderer
|
|
13
13
|
* @param callback Callback
|
|
14
14
|
*/
|
|
15
|
-
setItems: (callback: (items: T[], ref
|
|
15
|
+
setItems: (callback: (items: T[], ref: ScrollerGridForwardRef<T>) => T[] | undefined | void) => void;
|
|
16
16
|
/**
|
|
17
17
|
* Data
|
|
18
18
|
*/
|
|
@@ -95,7 +95,7 @@ export const ScrollerGrid = (props) => {
|
|
|
95
95
|
data,
|
|
96
96
|
selectedItems: state.selectedItems,
|
|
97
97
|
setItems: (callback) => {
|
|
98
|
-
const result = callback(rows,
|
|
98
|
+
const result = callback(rows, instance);
|
|
99
99
|
if (result == null)
|
|
100
100
|
return;
|
|
101
101
|
setRows(result);
|
|
@@ -131,7 +131,7 @@ export const ScrollerGrid = (props) => {
|
|
|
131
131
|
if (state.isMounted !== false)
|
|
132
132
|
setRows([]);
|
|
133
133
|
};
|
|
134
|
-
|
|
134
|
+
const instance = {
|
|
135
135
|
scrollTo(params) {
|
|
136
136
|
var _a;
|
|
137
137
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollTo(params);
|
|
@@ -189,7 +189,8 @@ export const ScrollerGrid = (props) => {
|
|
|
189
189
|
var _a;
|
|
190
190
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.resetAfterRowIndex(index, shouldForceUpdate);
|
|
191
191
|
}
|
|
192
|
-
}
|
|
192
|
+
};
|
|
193
|
+
React.useImperativeHandle(mRef, () => instance, [rows]);
|
|
193
194
|
React.useEffect(() => {
|
|
194
195
|
return () => {
|
|
195
196
|
state.isMounted = false;
|
package/package.json
CHANGED
|
@@ -121,10 +121,12 @@ export type GridCellRendererProps<T, P = any> = GridCellFormatterProps<T> & {
|
|
|
121
121
|
* @param callback Callback
|
|
122
122
|
*/
|
|
123
123
|
setItems: (
|
|
124
|
-
callback:
|
|
125
|
-
items: T[]
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
callback:
|
|
125
|
+
| ((items: T[]) => T[] | undefined | void)
|
|
126
|
+
| ((
|
|
127
|
+
items: T[],
|
|
128
|
+
ref: ScrollerGridForwardRef<T>
|
|
129
|
+
) => T[] | undefined | void)
|
|
128
130
|
) => void;
|
|
129
131
|
};
|
|
130
132
|
|
|
@@ -26,7 +26,7 @@ export type ScrollerGridItemRendererProps<T> = Omit<
|
|
|
26
26
|
setItems: (
|
|
27
27
|
callback: (
|
|
28
28
|
items: T[],
|
|
29
|
-
ref
|
|
29
|
+
ref: ScrollerGridForwardRef<T>
|
|
30
30
|
) => T[] | undefined | void
|
|
31
31
|
) => void;
|
|
32
32
|
|
|
@@ -293,10 +293,10 @@ export const ScrollerGrid = <
|
|
|
293
293
|
setItems: (
|
|
294
294
|
callback: (
|
|
295
295
|
items: T[],
|
|
296
|
-
ref
|
|
296
|
+
ref: ScrollerGridForwardRef<T>
|
|
297
297
|
) => T[] | undefined | void
|
|
298
298
|
) => {
|
|
299
|
-
const result = callback(rows,
|
|
299
|
+
const result = callback(rows, instance);
|
|
300
300
|
if (result == null) return;
|
|
301
301
|
setRows(result);
|
|
302
302
|
}
|
|
@@ -336,74 +336,72 @@ export const ScrollerGrid = <
|
|
|
336
336
|
if (state.isMounted !== false) setRows([]);
|
|
337
337
|
};
|
|
338
338
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
rows.forEach((row) => {
|
|
363
|
-
const index = selectedItems.findIndex(
|
|
364
|
-
(selectedItem) => selectedItem[idField] === row[idField]
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
if (checked) {
|
|
368
|
-
if (index === -1) selectedItems.push(row);
|
|
369
|
-
} else if (index !== -1) {
|
|
370
|
-
selectedItems.splice(index, 1);
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
if (onSelectChange) onSelectChange(selectedItems);
|
|
375
|
-
},
|
|
376
|
-
selectItem(item: T, checked: boolean) {
|
|
377
|
-
const selectedItems = state.selectedItems;
|
|
339
|
+
const instance: ScrollerGridForwardRef<T> = {
|
|
340
|
+
scrollTo(params: { scrollLeft: number; scrollTop: number }) {
|
|
341
|
+
ref.current?.scrollTo(params);
|
|
342
|
+
},
|
|
343
|
+
scrollToItem(params: {
|
|
344
|
+
align?: Align | undefined;
|
|
345
|
+
columnIndex?: number | undefined;
|
|
346
|
+
rowIndex?: number | undefined;
|
|
347
|
+
}) {
|
|
348
|
+
ref.current?.scrollToItem(params);
|
|
349
|
+
},
|
|
350
|
+
select(rowIndex: number) {
|
|
351
|
+
// Select only one item
|
|
352
|
+
const selectedItems = state.selectedItems;
|
|
353
|
+
selectedItems[0] = rows[rowIndex];
|
|
354
|
+
|
|
355
|
+
if (onSelectChange) onSelectChange(selectedItems);
|
|
356
|
+
},
|
|
357
|
+
selectAll(checked: boolean) {
|
|
358
|
+
const selectedItems = state.selectedItems;
|
|
359
|
+
|
|
360
|
+
rows.forEach((row) => {
|
|
378
361
|
const index = selectedItems.findIndex(
|
|
379
|
-
(selectedItem) => selectedItem[idField] ===
|
|
362
|
+
(selectedItem) => selectedItem[idField] === row[idField]
|
|
380
363
|
);
|
|
381
364
|
|
|
382
365
|
if (checked) {
|
|
383
|
-
if (index === -1) selectedItems.push(
|
|
384
|
-
} else {
|
|
385
|
-
|
|
366
|
+
if (index === -1) selectedItems.push(row);
|
|
367
|
+
} else if (index !== -1) {
|
|
368
|
+
selectedItems.splice(index, 1);
|
|
386
369
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
resetAfterRowIndex(index: number, shouldForceUpdate?: boolean) {
|
|
402
|
-
ref.current?.resetAfterRowIndex(index, shouldForceUpdate);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
if (onSelectChange) onSelectChange(selectedItems);
|
|
373
|
+
},
|
|
374
|
+
selectItem(item: T, checked: boolean) {
|
|
375
|
+
const selectedItems = state.selectedItems;
|
|
376
|
+
const index = selectedItems.findIndex(
|
|
377
|
+
(selectedItem) => selectedItem[idField] === item[idField]
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
if (checked) {
|
|
381
|
+
if (index === -1) selectedItems.push(item);
|
|
382
|
+
} else {
|
|
383
|
+
if (index !== -1) selectedItems.splice(index, 1);
|
|
403
384
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
385
|
+
|
|
386
|
+
if (onSelectChange) onSelectChange(selectedItems);
|
|
387
|
+
},
|
|
388
|
+
reset,
|
|
389
|
+
resetAfterColumnIndex(index: number, shouldForceUpdate?: boolean) {
|
|
390
|
+
ref.current?.resetAfterColumnIndex(index, shouldForceUpdate);
|
|
391
|
+
},
|
|
392
|
+
resetAfterIndices(params: {
|
|
393
|
+
columnIndex: number;
|
|
394
|
+
rowIndex: number;
|
|
395
|
+
shouldForceUpdate?: boolean | undefined;
|
|
396
|
+
}) {
|
|
397
|
+
ref.current?.resetAfterIndices(params);
|
|
398
|
+
},
|
|
399
|
+
resetAfterRowIndex(index: number, shouldForceUpdate?: boolean) {
|
|
400
|
+
ref.current?.resetAfterRowIndex(index, shouldForceUpdate);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
React.useImperativeHandle(mRef, () => instance, [rows]);
|
|
407
405
|
|
|
408
406
|
React.useEffect(() => {
|
|
409
407
|
return () => {
|