@react-spectrum/table 3.3.2 → 3.3.3-nightly.3472
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/main.css +1 -1
- package/dist/main.js +45 -18
- package/dist/main.js.map +1 -1
- package/dist/module.js +48 -21
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +27 -27
- package/src/Resizer.tsx +2 -2
- package/src/TableView.tsx +63 -43
package/dist/module.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "./main.css";
|
|
2
2
|
import {Column as $gyhAV$Column, TableHeader as $e668f3d0f378a712$re_export$TableHeader, TableBody as $e668f3d0f378a712$re_export$TableBody, Section as $e668f3d0f378a712$re_export$Section, Row as $e668f3d0f378a712$re_export$Row, Cell as $e668f3d0f378a712$re_export$Cell, useTableState as $gyhAV$useTableState, useTableColumnResizeState as $gyhAV$useTableColumnResizeState} from "@react-stately/table";
|
|
3
3
|
import $gyhAV$spectrumiconsuiArrowDownSmall from "@spectrum-icons/ui/ArrowDownSmall";
|
|
4
|
-
import {
|
|
4
|
+
import {mergeProps as $gyhAV$mergeProps, useLayoutEffect as $gyhAV$useLayoutEffect, chain as $gyhAV$chain} from "@react-aria/utils";
|
|
5
5
|
import {Checkbox as $gyhAV$Checkbox} from "@react-spectrum/checkbox";
|
|
6
6
|
import {useStyleProps as $gyhAV$useStyleProps, useDOMRef as $gyhAV$useDOMRef, classNames as $gyhAV$classNames, useFocusableRef as $gyhAV$useFocusableRef, useUnwrapDOMRef as $gyhAV$useUnwrapDOMRef} from "@react-spectrum/utils";
|
|
7
|
-
import {
|
|
7
|
+
import {useFocusRing as $gyhAV$useFocusRing, FocusScope as $gyhAV$FocusScope, FocusRing as $gyhAV$FocusRing} from "@react-aria/focus";
|
|
8
8
|
import {MenuTrigger as $gyhAV$MenuTrigger, Menu as $gyhAV$Menu, Item as $gyhAV$Item} from "@react-spectrum/menu";
|
|
9
9
|
import {layoutInfoToStyle as $gyhAV$layoutInfoToStyle, VirtualizerItem as $gyhAV$VirtualizerItem, setScrollLeft as $gyhAV$setScrollLeft, useVirtualizer as $gyhAV$useVirtualizer, ScrollView as $gyhAV$ScrollView} from "@react-aria/virtualizer";
|
|
10
10
|
import {ProgressCircle as $gyhAV$ProgressCircle} from "@react-spectrum/progress";
|
|
@@ -13,7 +13,7 @@ import {useVirtualizerState as $gyhAV$useVirtualizerState} from "@react-stately/
|
|
|
13
13
|
import {TableLayout as $gyhAV$TableLayout} from "@react-stately/layout";
|
|
14
14
|
import {TooltipTrigger as $gyhAV$TooltipTrigger, Tooltip as $gyhAV$Tooltip} from "@react-spectrum/tooltip";
|
|
15
15
|
import {useButton as $gyhAV$useButton} from "@react-aria/button";
|
|
16
|
-
import {
|
|
16
|
+
import {usePress as $gyhAV$usePress, useHover as $gyhAV$useHover} from "@react-aria/interactions";
|
|
17
17
|
import {useLocale as $gyhAV$useLocale, useLocalizedStringFormatter as $gyhAV$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
18
18
|
import {useProviderProps as $gyhAV$useProviderProps, useProvider as $gyhAV$useProvider} from "@react-spectrum/provider";
|
|
19
19
|
import {useTable as $gyhAV$useTable, useTableRowGroup as $gyhAV$useTableRowGroup, useTableColumnHeader as $gyhAV$useTableColumnHeader, useTableSelectAllCheckbox as $gyhAV$useTableSelectAllCheckbox, useTableRow as $gyhAV$useTableRow, useTableHeaderRow as $gyhAV$useTableHeaderRow, useTableCell as $gyhAV$useTableCell, useTableSelectionCheckbox as $gyhAV$useTableSelectionCheckbox, useTableColumnResize as $gyhAV$useTableColumnResize} from "@react-aria/table";
|
|
@@ -583,12 +583,13 @@ $bd5d41f647a296c3$export$53aa811f86efbfad = "is-next-selected_d0fc74";
|
|
|
583
583
|
|
|
584
584
|
function $fc695d2eafc2b351$var$Resizer(props, ref) {
|
|
585
585
|
let { column: column , showResizer: showResizer } = props;
|
|
586
|
-
let { state: state , columnState: columnState } = $d14697b14e638114$export$3cb274deb6c2d854();
|
|
586
|
+
let { state: state , columnState: columnState , isEmpty: isEmpty } = $d14697b14e638114$export$3cb274deb6c2d854();
|
|
587
587
|
let stringFormatter = $gyhAV$useLocalizedStringFormatter((/*@__PURE__*/$parcel$interopDefault($467944769c14687b$exports)));
|
|
588
588
|
let { direction: direction } = $gyhAV$useLocale();
|
|
589
589
|
let { inputProps: inputProps , resizerProps: resizerProps } = $gyhAV$useTableColumnResize({
|
|
590
590
|
...props,
|
|
591
|
-
label: stringFormatter.format('columnResizer')
|
|
591
|
+
label: stringFormatter.format('columnResizer'),
|
|
592
|
+
isDisabled: isEmpty
|
|
592
593
|
}, state, columnState, ref);
|
|
593
594
|
let style = {
|
|
594
595
|
cursor: undefined,
|
|
@@ -791,6 +792,7 @@ function $d14697b14e638114$var$TableView(props, ref) {
|
|
|
791
792
|
if (item.props.isSelectionCell) return(/*#__PURE__*/ $gyhAV$react.createElement($d14697b14e638114$var$TableSelectAllCell, {
|
|
792
793
|
column: item
|
|
793
794
|
}));
|
|
795
|
+
// TODO: consider this case, what if we have hidden headers and a empty table
|
|
794
796
|
if (item.props.hideHeader) return(/*#__PURE__*/ $gyhAV$react.createElement($gyhAV$TooltipTrigger, {
|
|
795
797
|
placement: "top",
|
|
796
798
|
trigger: "focus"
|
|
@@ -835,15 +837,18 @@ function $d14697b14e638114$var$TableView(props, ref) {
|
|
|
835
837
|
setHorizontalScollbarVisible(bodyRef.current.clientHeight + 2 < bodyRef.current.offsetHeight);
|
|
836
838
|
}
|
|
837
839
|
}, []);
|
|
840
|
+
let { isFocusVisible: isFocusVisible , focusProps: focusProps } = $gyhAV$useFocusRing();
|
|
841
|
+
let isEmpty = state.collection.size === 0;
|
|
838
842
|
return(/*#__PURE__*/ $gyhAV$react.createElement($d14697b14e638114$var$TableContext.Provider, {
|
|
839
843
|
value: {
|
|
840
844
|
state: state,
|
|
841
845
|
layout: layout,
|
|
842
846
|
columnState: columnState,
|
|
843
|
-
headerRowHovered: headerRowHovered
|
|
847
|
+
headerRowHovered: headerRowHovered,
|
|
848
|
+
isEmpty: isEmpty
|
|
844
849
|
}
|
|
845
850
|
}, /*#__PURE__*/ $gyhAV$react.createElement($d14697b14e638114$var$TableVirtualizer, {
|
|
846
|
-
|
|
851
|
+
...$gyhAV$mergeProps(gridProps, focusProps),
|
|
847
852
|
...styleProps,
|
|
848
853
|
className: $gyhAV$classNames((/*@__PURE__*/$parcel$interopDefault($bd5d41f647a296c3$exports)), 'spectrum-Table', `spectrum-Table--${density}`, {
|
|
849
854
|
'spectrum-Table--quiet': isQuiet,
|
|
@@ -861,11 +866,12 @@ function $d14697b14e638114$var$TableView(props, ref) {
|
|
|
861
866
|
onVisibleRectChange: onVisibleRectChange,
|
|
862
867
|
domRef: domRef,
|
|
863
868
|
bodyRef: bodyRef,
|
|
869
|
+
isFocusVisible: isFocusVisible,
|
|
864
870
|
getColumnWidth: columnState.getColumnWidth
|
|
865
871
|
})));
|
|
866
872
|
}
|
|
867
873
|
// This is a custom Virtualizer that also has a header that syncs its scroll position with the body.
|
|
868
|
-
function $d14697b14e638114$var$TableVirtualizer({ layout: layout , collection: collection , focusedKey: focusedKey , renderView: renderView , renderWrapper: renderWrapper , domRef: domRef , bodyRef: bodyRef , setTableWidth: setTableWidth , getColumnWidth: getColumnWidth , onVisibleRectChange: onVisibleRectChangeProp , ...otherProps }) {
|
|
874
|
+
function $d14697b14e638114$var$TableVirtualizer({ layout: layout , collection: collection , focusedKey: focusedKey , renderView: renderView , renderWrapper: renderWrapper , domRef: domRef , bodyRef: bodyRef , setTableWidth: setTableWidth , getColumnWidth: getColumnWidth , onVisibleRectChange: onVisibleRectChangeProp , isFocusVisible: isFocusVisible , ...otherProps }) {
|
|
869
875
|
var ref;
|
|
870
876
|
let { direction: direction } = $gyhAV$useLocale();
|
|
871
877
|
let headerRef = $gyhAV$useRef();
|
|
@@ -939,8 +945,10 @@ function $d14697b14e638114$var$TableVirtualizer({ layout: layout , collection: c
|
|
|
939
945
|
onLoadMore,
|
|
940
946
|
isLoading
|
|
941
947
|
]);
|
|
942
|
-
return(/*#__PURE__*/ $gyhAV$react.createElement("div", {
|
|
943
|
-
...$gyhAV$mergeProps(otherProps, virtualizerProps
|
|
948
|
+
return(/*#__PURE__*/ $gyhAV$react.createElement($gyhAV$FocusScope, null, /*#__PURE__*/ $gyhAV$react.createElement("div", {
|
|
949
|
+
...$gyhAV$mergeProps(otherProps, virtualizerProps, collection.size === 0 && {
|
|
950
|
+
tabIndex: 0
|
|
951
|
+
}),
|
|
944
952
|
ref: domRef
|
|
945
953
|
}, /*#__PURE__*/ $gyhAV$react.createElement("div", {
|
|
946
954
|
role: "presentation",
|
|
@@ -956,7 +964,9 @@ function $d14697b14e638114$var$TableVirtualizer({ layout: layout , collection: c
|
|
|
956
964
|
ref: headerRef
|
|
957
965
|
}, state.visibleViews[0]), /*#__PURE__*/ $gyhAV$react.createElement($gyhAV$ScrollView, {
|
|
958
966
|
role: "presentation",
|
|
959
|
-
className: $gyhAV$classNames((/*@__PURE__*/$parcel$interopDefault($bd5d41f647a296c3$exports)), 'spectrum-Table-body'
|
|
967
|
+
className: $gyhAV$classNames((/*@__PURE__*/$parcel$interopDefault($bd5d41f647a296c3$exports)), 'spectrum-Table-body', {
|
|
968
|
+
'focus-ring': isFocusVisible
|
|
969
|
+
}),
|
|
960
970
|
style: {
|
|
961
971
|
flex: 1
|
|
962
972
|
},
|
|
@@ -970,7 +980,7 @@ function $d14697b14e638114$var$TableVirtualizer({ layout: layout , collection: c
|
|
|
970
980
|
onScrollStart: state.startScrolling,
|
|
971
981
|
onScrollEnd: state.endScrolling,
|
|
972
982
|
onScroll: onScroll
|
|
973
|
-
}, state.visibleViews[1])));
|
|
983
|
+
}, state.visibleViews[1]))));
|
|
974
984
|
}
|
|
975
985
|
function $d14697b14e638114$var$TableHeader({ children: children , ...otherProps }) {
|
|
976
986
|
let { rowGroupProps: rowGroupProps } = $gyhAV$useTableRowGroup();
|
|
@@ -984,16 +994,23 @@ function $d14697b14e638114$var$TableColumnHeader(props) {
|
|
|
984
994
|
var ref, ref1, ref2, ref3;
|
|
985
995
|
let { column: column } = props;
|
|
986
996
|
let ref4 = $gyhAV$useRef(null);
|
|
987
|
-
let { state: state } = $d14697b14e638114$export$3cb274deb6c2d854();
|
|
997
|
+
let { state: state , isEmpty: isEmpty } = $d14697b14e638114$export$3cb274deb6c2d854();
|
|
998
|
+
let { pressProps: pressProps , isPressed: isPressed } = $gyhAV$usePress({
|
|
999
|
+
isDisabled: isEmpty
|
|
1000
|
+
});
|
|
988
1001
|
let { columnHeaderProps: columnHeaderProps } = $gyhAV$useTableColumnHeader({
|
|
989
1002
|
node: column,
|
|
990
1003
|
isVirtualized: true
|
|
991
1004
|
}, state, ref4);
|
|
992
1005
|
let columnProps = column.props;
|
|
993
|
-
let { hoverProps: hoverProps , isHovered: isHovered } = $gyhAV$useHover(
|
|
1006
|
+
let { hoverProps: hoverProps , isHovered: isHovered } = $gyhAV$useHover({
|
|
1007
|
+
...props,
|
|
1008
|
+
isDisabled: isEmpty
|
|
1009
|
+
});
|
|
994
1010
|
const allProps = [
|
|
995
1011
|
columnHeaderProps,
|
|
996
|
-
hoverProps
|
|
1012
|
+
hoverProps,
|
|
1013
|
+
pressProps
|
|
997
1014
|
];
|
|
998
1015
|
return(/*#__PURE__*/ $gyhAV$react.createElement($gyhAV$FocusRing, {
|
|
999
1016
|
focusRingClass: $gyhAV$classNames((/*@__PURE__*/$parcel$interopDefault($bd5d41f647a296c3$exports)), 'focus-ring')
|
|
@@ -1001,6 +1018,7 @@ function $d14697b14e638114$var$TableColumnHeader(props) {
|
|
|
1001
1018
|
...$gyhAV$mergeProps(...allProps),
|
|
1002
1019
|
ref: ref4,
|
|
1003
1020
|
className: $gyhAV$classNames((/*@__PURE__*/$parcel$interopDefault($bd5d41f647a296c3$exports)), 'spectrum-Table-headCell', {
|
|
1021
|
+
'is-active': isPressed,
|
|
1004
1022
|
'is-resizable': columnProps.allowsResizing,
|
|
1005
1023
|
'is-sortable': columnProps.allowsSorting,
|
|
1006
1024
|
'is-sorted-desc': ((ref = state.sortDescriptor) === null || ref === void 0 ? void 0 : ref.column) === column.key && ((ref1 = state.sortDescriptor) === null || ref1 === void 0 ? void 0 : ref1.direction) === 'descending',
|
|
@@ -1018,10 +1036,12 @@ function $d14697b14e638114$var$TableColumnHeader(props) {
|
|
|
1018
1036
|
}))));
|
|
1019
1037
|
}
|
|
1020
1038
|
let $d14697b14e638114$var$_TableColumnHeaderButton = (props, ref)=>{
|
|
1039
|
+
let { isEmpty: isEmpty } = $d14697b14e638114$export$3cb274deb6c2d854();
|
|
1021
1040
|
let domRef = $gyhAV$useFocusableRef(ref);
|
|
1022
1041
|
let { buttonProps: buttonProps } = $gyhAV$useButton({
|
|
1023
1042
|
...props,
|
|
1024
|
-
elementType: 'div'
|
|
1043
|
+
elementType: 'div',
|
|
1044
|
+
isDisabled: isEmpty
|
|
1025
1045
|
}, domRef);
|
|
1026
1046
|
return(/*#__PURE__*/ $gyhAV$react.createElement("div", {
|
|
1027
1047
|
className: $gyhAV$classNames((/*@__PURE__*/$parcel$interopDefault($bd5d41f647a296c3$exports)), 'spectrum-Table-headCellContents')
|
|
@@ -1040,17 +1060,24 @@ function $d14697b14e638114$var$ResizableTableColumnHeader(props) {
|
|
|
1040
1060
|
let ref9 = $gyhAV$useRef(null);
|
|
1041
1061
|
let triggerRef = $gyhAV$useRef(null);
|
|
1042
1062
|
let resizingRef = $gyhAV$useRef(null);
|
|
1043
|
-
let { state: state , columnState: columnState , headerRowHovered: headerRowHovered } = $d14697b14e638114$export$3cb274deb6c2d854();
|
|
1063
|
+
let { state: state , columnState: columnState , headerRowHovered: headerRowHovered , isEmpty: isEmpty } = $d14697b14e638114$export$3cb274deb6c2d854();
|
|
1044
1064
|
let stringFormatter = $gyhAV$useLocalizedStringFormatter((/*@__PURE__*/$parcel$interopDefault($467944769c14687b$exports)));
|
|
1065
|
+
let { pressProps: pressProps , isPressed: isPressed } = $gyhAV$usePress({
|
|
1066
|
+
isDisabled: isEmpty
|
|
1067
|
+
});
|
|
1045
1068
|
let { columnHeaderProps: columnHeaderProps } = $gyhAV$useTableColumnHeader({
|
|
1046
1069
|
node: column,
|
|
1047
1070
|
isVirtualized: true,
|
|
1048
1071
|
hasMenu: true
|
|
1049
1072
|
}, state, ref9);
|
|
1050
|
-
let { hoverProps: hoverProps , isHovered: isHovered } = $gyhAV$useHover(
|
|
1073
|
+
let { hoverProps: hoverProps , isHovered: isHovered } = $gyhAV$useHover({
|
|
1074
|
+
...props,
|
|
1075
|
+
isDisabled: isEmpty
|
|
1076
|
+
});
|
|
1051
1077
|
const allProps = [
|
|
1052
1078
|
columnHeaderProps,
|
|
1053
|
-
hoverProps
|
|
1079
|
+
hoverProps,
|
|
1080
|
+
pressProps
|
|
1054
1081
|
];
|
|
1055
1082
|
let columnProps = column.props;
|
|
1056
1083
|
if (columnProps.width && columnProps.allowsResizing) throw new Error('Controlled state is not yet supported with column resizing. Please use defaultWidth for uncontrolled column resizing or remove the allowsResizing prop.');
|
|
@@ -1097,13 +1124,14 @@ function $d14697b14e638114$var$ResizableTableColumnHeader(props) {
|
|
|
1097
1124
|
columnState.currentlyResizingColumn,
|
|
1098
1125
|
column.key
|
|
1099
1126
|
]);
|
|
1100
|
-
let showResizer = headerRowHovered || columnState.currentlyResizingColumn != null;
|
|
1127
|
+
let showResizer = !isEmpty && (headerRowHovered || columnState.currentlyResizingColumn != null);
|
|
1101
1128
|
return(/*#__PURE__*/ $gyhAV$react.createElement($gyhAV$FocusRing, {
|
|
1102
1129
|
focusRingClass: $gyhAV$classNames((/*@__PURE__*/$parcel$interopDefault($bd5d41f647a296c3$exports)), 'focus-ring')
|
|
1103
1130
|
}, /*#__PURE__*/ $gyhAV$react.createElement("div", {
|
|
1104
1131
|
...$gyhAV$mergeProps(...allProps),
|
|
1105
1132
|
ref: ref9,
|
|
1106
1133
|
className: $gyhAV$classNames((/*@__PURE__*/$parcel$interopDefault($bd5d41f647a296c3$exports)), 'spectrum-Table-headCell', {
|
|
1134
|
+
'is-active': isPressed,
|
|
1107
1135
|
'is-resizable': columnProps.allowsResizing,
|
|
1108
1136
|
'is-sortable': columnProps.allowsSorting,
|
|
1109
1137
|
'is-sorted-desc': ((ref5 = state.sortDescriptor) === null || ref5 === void 0 ? void 0 : ref5.column) === column.key && ((ref6 = state.sortDescriptor) === null || ref6 === void 0 ? void 0 : ref6.direction) === 'descending',
|
|
@@ -1156,7 +1184,6 @@ function $d14697b14e638114$var$TableSelectAllCell({ column: column }) {
|
|
|
1156
1184
|
which for single selection will be "Select."
|
|
1157
1185
|
*/ isSingleSelectionMode && /*#__PURE__*/ $gyhAV$react.createElement($gyhAV$VisuallyHidden, null, checkboxProps['aria-label']), /*#__PURE__*/ $gyhAV$react.createElement($gyhAV$Checkbox, {
|
|
1158
1186
|
...checkboxProps,
|
|
1159
|
-
isDisabled: isSingleSelectionMode,
|
|
1160
1187
|
isEmphasized: true,
|
|
1161
1188
|
UNSAFE_style: isSingleSelectionMode ? {
|
|
1162
1189
|
visibility: 'hidden'
|