@react-spectrum/table 3.14.1 → 3.15.1
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/DragPreview.main.js +1 -1
- package/dist/DragPreview.mjs +1 -1
- package/dist/DragPreview.module.js +1 -1
- 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 +7 -7
- package/dist/Resizer.main.js.map +1 -1
- package/dist/Resizer.mjs +8 -8
- package/dist/Resizer.module.js +8 -8
- 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/TableView.main.js +2 -3
- package/dist/TableView.main.js.map +1 -1
- package/dist/TableView.mjs +2 -3
- package/dist/TableView.module.js +2 -3
- package/dist/TableView.module.js.map +1 -1
- package/dist/TableViewBase.main.js +81 -81
- package/dist/TableViewBase.main.js.map +1 -1
- package/dist/TableViewBase.mjs +81 -81
- package/dist/TableViewBase.module.js +81 -81
- 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/TableViewWrapper.main.js +4 -5
- package/dist/TableViewWrapper.main.js.map +1 -1
- package/dist/TableViewWrapper.mjs +4 -5
- package/dist/TableViewWrapper.module.js +4 -5
- package/dist/TableViewWrapper.module.js.map +1 -1
- package/dist/TreeGridTableView.main.js +2 -3
- package/dist/TreeGridTableView.main.js.map +1 -1
- package/dist/TreeGridTableView.mjs +2 -3
- package/dist/TreeGridTableView.module.js +2 -3
- package/dist/TreeGridTableView.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/dist/types.d.ts.map +1 -1
- package/dist/{vars.bd693cb4.css → vars.27f08d5f.css} +2 -2
- package/dist/{vars.bd693cb4.css.map → vars.27f08d5f.css.map} +1 -1
- package/package.json +29 -29
- package/src/InsertionIndicator.tsx +5 -5
- package/src/Resizer.tsx +11 -13
- package/src/RootDropIndicator.tsx +4 -4
- package/src/TableView.tsx +2 -5
- package/src/TableViewBase.tsx +136 -126
- package/src/TableViewLayout.ts +11 -5
- package/src/TableViewWrapper.tsx +6 -9
- package/src/TreeGridTableView.tsx +2 -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
|
}
|
package/src/TableViewWrapper.tsx
CHANGED
|
@@ -89,18 +89,15 @@ export interface SpectrumTableProps<T> extends TableProps<T>, SpectrumSelectionP
|
|
|
89
89
|
UNSTABLE_onExpandedChange?: (keys: Set<Key>) => any
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Tables are containers for displaying information. They allow users to quickly scan, sort, compare, and take action on large amounts of data.
|
|
94
|
+
*/
|
|
95
|
+
const TableViewWrapper = React.forwardRef(function TableViewWrapper<T extends object>(props: SpectrumTableProps<T>, ref: DOMRef<HTMLDivElement>) {
|
|
93
96
|
let {UNSTABLE_allowsExpandableRows, ...otherProps} = props;
|
|
94
97
|
if (tableNestedRows() && UNSTABLE_allowsExpandableRows) {
|
|
95
98
|
return <TreeGridTableView {...otherProps} ref={ref} />;
|
|
96
99
|
} else {
|
|
97
100
|
return <TableView {...otherProps} ref={ref} />;
|
|
98
101
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Tables are containers for displaying information. They allow users to quickly scan, sort, compare, and take action on large amounts of data.
|
|
103
|
-
*/
|
|
104
|
-
const _TableViewWrapper = React.forwardRef(TableViewWrapper) as <T>(props: SpectrumTableProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;
|
|
105
|
-
|
|
106
|
-
export {_TableViewWrapper as TableView};
|
|
102
|
+
}) as <T>(props: SpectrumTableProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;
|
|
103
|
+
export {TableViewWrapper as TableView};
|
|
@@ -18,7 +18,7 @@ import {UNSTABLE_useTreeGridState} from '@react-stately/table';
|
|
|
18
18
|
|
|
19
19
|
export interface TreeGridTableProps<T> extends Omit<SpectrumTableProps<T>, 'UNSTABLE_allowsExpandableRows'> {}
|
|
20
20
|
|
|
21
|
-
function TreeGridTableView<T extends object>(props: TreeGridTableProps<T>, ref: DOMRef<HTMLDivElement>) {
|
|
21
|
+
export const TreeGridTableView = React.forwardRef(function TreeGridTableView<T extends object>(props: TreeGridTableProps<T>, ref: DOMRef<HTMLDivElement>) {
|
|
22
22
|
let {
|
|
23
23
|
selectionStyle,
|
|
24
24
|
dragAndDropHooks
|
|
@@ -41,7 +41,4 @@ function TreeGridTableView<T extends object>(props: TreeGridTableProps<T>, ref:
|
|
|
41
41
|
return (
|
|
42
42
|
<TableViewBase {...props} state={state} ref={ref} />
|
|
43
43
|
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const _TreeGridTableView = React.forwardRef(TreeGridTableView) as <T>(props: TreeGridTableProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;
|
|
47
|
-
export {_TreeGridTableView as TreeGridTableView};
|
|
44
|
+
}) as <T>(props: TreeGridTableProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;
|