@react-spectrum/table 3.14.0 → 3.15.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 +201 -0
- package/dist/InsertionIndicator.main.js +4 -3
- package/dist/InsertionIndicator.main.js.map +1 -1
- package/dist/InsertionIndicator.mjs +4 -3
- package/dist/InsertionIndicator.module.js +4 -3
- package/dist/InsertionIndicator.module.js.map +1 -1
- package/dist/Resizer.main.js +4 -3
- package/dist/Resizer.main.js.map +1 -1
- package/dist/Resizer.mjs +5 -4
- package/dist/Resizer.module.js +5 -4
- package/dist/Resizer.module.js.map +1 -1
- package/dist/RootDropIndicator.main.js +1 -1
- package/dist/RootDropIndicator.main.js.map +1 -1
- package/dist/RootDropIndicator.mjs +1 -1
- package/dist/RootDropIndicator.module.js +1 -1
- package/dist/RootDropIndicator.module.js.map +1 -1
- package/dist/TableViewBase.main.js +80 -80
- package/dist/TableViewBase.main.js.map +1 -1
- package/dist/TableViewBase.mjs +80 -80
- package/dist/TableViewBase.module.js +80 -80
- package/dist/TableViewBase.module.js.map +1 -1
- package/dist/TableViewLayout.main.js +7 -5
- package/dist/TableViewLayout.main.js.map +1 -1
- package/dist/TableViewLayout.mjs +7 -5
- package/dist/TableViewLayout.module.js +7 -5
- package/dist/TableViewLayout.module.js.map +1 -1
- package/dist/table_vars_css.main.js.map +1 -1
- package/dist/table_vars_css.module.js.map +1 -1
- package/package.json +31 -30
- package/src/InsertionIndicator.tsx +5 -5
- package/src/Resizer.tsx +10 -9
- package/src/RootDropIndicator.tsx +4 -4
- package/src/TableViewBase.tsx +136 -126
- package/src/TableViewLayout.ts +11 -5
package/src/TableViewLayout.ts
CHANGED
|
@@ -13,12 +13,14 @@ import {DropTarget} from '@react-types/shared';
|
|
|
13
13
|
import {GridNode} from '@react-types/grid';
|
|
14
14
|
import {LayoutInfo, Rect} from '@react-stately/virtualizer';
|
|
15
15
|
import {LayoutNode, TableLayout} from '@react-stately/layout';
|
|
16
|
+
import {TableCollection} from '@react-stately/table';
|
|
16
17
|
|
|
17
18
|
export class TableViewLayout<T> extends TableLayout<T> {
|
|
18
19
|
private isLoading: boolean = false;
|
|
19
20
|
|
|
20
21
|
protected buildCollection(): LayoutNode[] {
|
|
21
|
-
let
|
|
22
|
+
let collection = this.virtualizer!.collection as TableCollection<T>;
|
|
23
|
+
let loadingState = collection.body.props.loadingState;
|
|
22
24
|
this.isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
|
|
23
25
|
return super.buildCollection();
|
|
24
26
|
}
|
|
@@ -32,11 +34,15 @@ export class TableViewLayout<T> extends TableLayout<T> {
|
|
|
32
34
|
protected buildBody(): LayoutNode {
|
|
33
35
|
let node = super.buildBody(0);
|
|
34
36
|
let {children, layoutInfo} = node;
|
|
37
|
+
if (!children) {
|
|
38
|
+
throw new Error('Missing children in LayoutInfo');
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
let width = node.layoutInfo.rect.width;
|
|
36
42
|
|
|
37
43
|
if (this.isLoading) {
|
|
38
44
|
// Add some margin around the loader to ensure that scrollbars don't flicker in and out.
|
|
39
|
-
let rect = new Rect(40, children.length === 0 ? 40 : layoutInfo.rect.maxY, (width || this.virtualizer
|
|
45
|
+
let rect = new Rect(40, children.length === 0 ? 40 : layoutInfo.rect.maxY, (width || this.virtualizer!.visibleRect.width) - 80, children.length === 0 ? this.virtualizer!.visibleRect.height - 80 : 60);
|
|
40
46
|
let loader = new LayoutInfo('loader', 'loader', rect);
|
|
41
47
|
loader.parentKey = layoutInfo.key;
|
|
42
48
|
loader.isSticky = children.length === 0;
|
|
@@ -49,7 +55,7 @@ export class TableViewLayout<T> extends TableLayout<T> {
|
|
|
49
55
|
layoutInfo.rect.height = loader.rect.maxY;
|
|
50
56
|
width = Math.max(width, rect.width);
|
|
51
57
|
} else if (children.length === 0) {
|
|
52
|
-
let rect = new Rect(40, 40, this.virtualizer
|
|
58
|
+
let rect = new Rect(40, 40, this.virtualizer!.visibleRect.width - 80, this.virtualizer!.visibleRect.height - 80);
|
|
53
59
|
let empty = new LayoutInfo('empty', 'empty', rect);
|
|
54
60
|
empty.parentKey = layoutInfo.key;
|
|
55
61
|
empty.isSticky = true;
|
|
@@ -87,9 +93,9 @@ export class TableViewLayout<T> extends TableLayout<T> {
|
|
|
87
93
|
return node.props?.isDragButtonCell || node.props?.isSelectionCell;
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {
|
|
96
|
+
getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget | null {
|
|
91
97
|
// Offset for height of header row
|
|
92
|
-
y -= this.
|
|
98
|
+
y -= this.getVisibleLayoutInfos(new Rect(x, y, 1, 1)).find(info => info.type === 'headerrow')?.rect.height ?? 0;
|
|
93
99
|
return super.getDropTargetFromPoint(x, y, isValidDropTarget);
|
|
94
100
|
}
|
|
95
101
|
}
|