@react-aria/table 3.8.2-nightly.3749 → 3.8.2-nightly.3757
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/import.mjs +60 -19
- package/dist/main.js +59 -18
- package/dist/main.js.map +1 -1
- package/dist/module.js +60 -19
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +4 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/useTableCell.ts +2 -0
- package/src/useTableColumnResize.ts +69 -24
package/dist/import.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {useId as $lJcFS$useId, useDescription as $lJcFS$useDescription, useUpdat
|
|
|
5
5
|
import {useMemo as $lJcFS$useMemo, useRef as $lJcFS$useRef, useCallback as $lJcFS$useCallback} from "react";
|
|
6
6
|
import {useCollator as $lJcFS$useCollator, useLocale as $lJcFS$useLocale, useLocalizedStringFormatter as $lJcFS$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
7
7
|
import {useFocusable as $lJcFS$useFocusable, focusSafely as $lJcFS$focusSafely} from "@react-aria/focus";
|
|
8
|
-
import {usePress as $lJcFS$usePress, useKeyboard as $lJcFS$useKeyboard, useMove as $lJcFS$useMove} from "@react-aria/interactions";
|
|
8
|
+
import {usePress as $lJcFS$usePress, useKeyboard as $lJcFS$useKeyboard, useMove as $lJcFS$useMove, useInteractionModality as $lJcFS$useInteractionModality} from "@react-aria/interactions";
|
|
9
9
|
|
|
10
10
|
function $parcel$interopDefault(a) {
|
|
11
11
|
return a && a.__esModule ? a.default : a;
|
|
@@ -154,7 +154,8 @@ $09e6b82e0d6e466a$exports = {
|
|
|
154
154
|
"descending": `descending`,
|
|
155
155
|
"ascendingSort": (args)=>`sorted by column ${args.columnName} in ascending order`,
|
|
156
156
|
"descendingSort": (args)=>`sorted by column ${args.columnName} in descending order`,
|
|
157
|
-
"columnSize": (args)=>`${args.value} pixels
|
|
157
|
+
"columnSize": (args)=>`${args.value} pixels`,
|
|
158
|
+
"resizerDescription": `Press Enter to start resizing`
|
|
158
159
|
};
|
|
159
160
|
|
|
160
161
|
|
|
@@ -961,13 +962,28 @@ function $e91ef4e5004e3774$export$52994e973806c219(props, state, ref) {
|
|
|
961
962
|
let id = (0, $lJcFS$useId)();
|
|
962
963
|
let isResizing = (0, $lJcFS$useRef)(false);
|
|
963
964
|
let lastSize = (0, $lJcFS$useRef)(null);
|
|
965
|
+
let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;
|
|
964
966
|
let { direction: direction } = (0, $lJcFS$useLocale)();
|
|
965
967
|
let { keyboardProps: keyboardProps } = (0, $lJcFS$useKeyboard)({
|
|
966
968
|
onKeyDown: (e)=>{
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
969
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
970
|
+
if (editModeEnabled) {
|
|
971
|
+
if (e.key === "Escape" || e.key === "Enter" || e.key === " " || e.key === "Tab") {
|
|
972
|
+
e.preventDefault();
|
|
973
|
+
if (resizeOnFocus) // switch focus back to the column header on anything that ends edit mode
|
|
974
|
+
(0, $lJcFS$focusSafely)(triggerRef.current);
|
|
975
|
+
else {
|
|
976
|
+
endResize(item);
|
|
977
|
+
state.tableState.setKeyboardNavigationDisabled(false);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
} else if (!resizeOnFocus) {
|
|
981
|
+
// Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there
|
|
982
|
+
e.continuePropagation();
|
|
983
|
+
if (e.key === "Enter") {
|
|
984
|
+
startResize(item);
|
|
985
|
+
state.tableState.setKeyboardNavigationDisabled(true);
|
|
986
|
+
}
|
|
971
987
|
}
|
|
972
988
|
}
|
|
973
989
|
});
|
|
@@ -992,8 +1008,8 @@ function $e91ef4e5004e3774$export$52994e973806c219(props, state, ref) {
|
|
|
992
1008
|
state
|
|
993
1009
|
]);
|
|
994
1010
|
let endResize = (0, $lJcFS$useCallback)((item)=>{
|
|
995
|
-
if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
996
1011
|
if (isResizing.current) {
|
|
1012
|
+
if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
997
1013
|
state.endResize();
|
|
998
1014
|
onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd(lastSize.current);
|
|
999
1015
|
}
|
|
@@ -1024,15 +1040,25 @@ function $e91ef4e5004e3774$export$52994e973806c219(props, state, ref) {
|
|
|
1024
1040
|
}
|
|
1025
1041
|
},
|
|
1026
1042
|
onMoveEnd (e) {
|
|
1043
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
1027
1044
|
let { pointerType: pointerType } = e;
|
|
1028
1045
|
columnResizeWidthRef.current = 0;
|
|
1029
|
-
if (pointerType === "mouse") endResize(item);
|
|
1046
|
+
if (pointerType === "mouse" || pointerType === "touch" && !resizeOnFocus) endResize(item);
|
|
1030
1047
|
}
|
|
1031
1048
|
});
|
|
1049
|
+
let onKeyDown = (0, $lJcFS$useCallback)((e)=>{
|
|
1050
|
+
if (editModeEnabled) moveProps.onKeyDown(e);
|
|
1051
|
+
}, [
|
|
1052
|
+
editModeEnabled,
|
|
1053
|
+
moveProps
|
|
1054
|
+
]);
|
|
1032
1055
|
let min = Math.floor(state.getColumnMinWidth(item.key));
|
|
1033
1056
|
let max = Math.floor(state.getColumnMaxWidth(item.key));
|
|
1034
1057
|
if (max === Infinity) max = Number.MAX_SAFE_INTEGER;
|
|
1035
1058
|
let value = Math.floor(state.getColumnWidth(item.key));
|
|
1059
|
+
let modality = (0, $lJcFS$useInteractionModality)();
|
|
1060
|
+
let description = (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) == null && (modality === "keyboard" || modality === "virtual") && !isResizing.current ? stringFormatter.format("resizerDescription") : undefined;
|
|
1061
|
+
let descriptionProps = (0, $lJcFS$useDescription)(description);
|
|
1036
1062
|
let ariaProps = {
|
|
1037
1063
|
"aria-label": props.label,
|
|
1038
1064
|
"aria-orientation": "horizontal",
|
|
@@ -1043,7 +1069,8 @@ function $e91ef4e5004e3774$export$52994e973806c219(props, state, ref) {
|
|
|
1043
1069
|
"type": "range",
|
|
1044
1070
|
min: min,
|
|
1045
1071
|
max: max,
|
|
1046
|
-
value: value
|
|
1072
|
+
value: value,
|
|
1073
|
+
...descriptionProps
|
|
1047
1074
|
};
|
|
1048
1075
|
const focusInput = (0, $lJcFS$useCallback)(()=>{
|
|
1049
1076
|
if (ref.current) (0, $lJcFS$focusWithoutScrolling)(ref.current);
|
|
@@ -1061,28 +1088,42 @@ function $e91ef4e5004e3774$export$52994e973806c219(props, state, ref) {
|
|
|
1061
1088
|
onPressStart: (e)=>{
|
|
1062
1089
|
if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === "keyboard") return;
|
|
1063
1090
|
if (e.pointerType === "virtual" && state.resizingColumn != null) {
|
|
1091
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
1064
1092
|
endResize(item);
|
|
1065
|
-
if (
|
|
1093
|
+
if (resizeOnFocus) (0, $lJcFS$focusSafely)(triggerRef.current);
|
|
1066
1094
|
return;
|
|
1067
1095
|
}
|
|
1096
|
+
// Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away
|
|
1097
|
+
// can cancel resize mode for us.
|
|
1068
1098
|
focusInput();
|
|
1099
|
+
// If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need
|
|
1100
|
+
// to handle a virtual click to start the resizer.
|
|
1101
|
+
if (e.pointerType !== "virtual") startResize(item);
|
|
1069
1102
|
},
|
|
1070
1103
|
onPress: (e)=>{
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
if (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) (0, $lJcFS$focusSafely)(triggerRef.current);
|
|
1074
|
-
}
|
|
1104
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
1105
|
+
if ((e.pointerType === "touch" && !resizeOnFocus || e.pointerType === "mouse") && state.resizingColumn != null) endResize(item);
|
|
1075
1106
|
}
|
|
1076
1107
|
});
|
|
1077
1108
|
return {
|
|
1078
|
-
resizerProps: (0, $lJcFS$mergeProps)(keyboardProps,
|
|
1109
|
+
resizerProps: (0, $lJcFS$mergeProps)(keyboardProps, {
|
|
1110
|
+
...moveProps,
|
|
1111
|
+
onKeyDown: onKeyDown
|
|
1112
|
+
}, pressProps),
|
|
1079
1113
|
inputProps: (0, $lJcFS$mergeProps)({
|
|
1080
1114
|
id: id,
|
|
1115
|
+
// Override browser default margin. Without this, scrollIntoViewport will think we need to scroll the input into view
|
|
1116
|
+
style: {
|
|
1117
|
+
margin: "0px"
|
|
1118
|
+
},
|
|
1081
1119
|
onFocus: ()=>{
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1120
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
1121
|
+
if (resizeOnFocus) {
|
|
1122
|
+
// useMove calls onMoveStart for every keypress, but we want resize start to only be called when we start resize mode
|
|
1123
|
+
// call instead during focus and blur
|
|
1124
|
+
startResize(item);
|
|
1125
|
+
state.tableState.setKeyboardNavigationDisabled(true);
|
|
1126
|
+
}
|
|
1086
1127
|
},
|
|
1087
1128
|
onBlur: ()=>{
|
|
1088
1129
|
endResize(item);
|
package/dist/main.js
CHANGED
|
@@ -167,7 +167,8 @@ $8629e38d73986227$exports = {
|
|
|
167
167
|
"descending": `descending`,
|
|
168
168
|
"ascendingSort": (args)=>`sorted by column ${args.columnName} in ascending order`,
|
|
169
169
|
"descendingSort": (args)=>`sorted by column ${args.columnName} in descending order`,
|
|
170
|
-
"columnSize": (args)=>`${args.value} pixels
|
|
170
|
+
"columnSize": (args)=>`${args.value} pixels`,
|
|
171
|
+
"resizerDescription": `Press Enter to start resizing`
|
|
171
172
|
};
|
|
172
173
|
|
|
173
174
|
|
|
@@ -974,13 +975,28 @@ function $16d645f9e2153641$export$52994e973806c219(props, state, ref) {
|
|
|
974
975
|
let id = (0, $kJQf8$reactariautils.useId)();
|
|
975
976
|
let isResizing = (0, $kJQf8$react.useRef)(false);
|
|
976
977
|
let lastSize = (0, $kJQf8$react.useRef)(null);
|
|
978
|
+
let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;
|
|
977
979
|
let { direction: direction } = (0, $kJQf8$reactariai18n.useLocale)();
|
|
978
980
|
let { keyboardProps: keyboardProps } = (0, $kJQf8$reactariainteractions.useKeyboard)({
|
|
979
981
|
onKeyDown: (e)=>{
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
982
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
983
|
+
if (editModeEnabled) {
|
|
984
|
+
if (e.key === "Escape" || e.key === "Enter" || e.key === " " || e.key === "Tab") {
|
|
985
|
+
e.preventDefault();
|
|
986
|
+
if (resizeOnFocus) // switch focus back to the column header on anything that ends edit mode
|
|
987
|
+
(0, $kJQf8$reactariafocus.focusSafely)(triggerRef.current);
|
|
988
|
+
else {
|
|
989
|
+
endResize(item);
|
|
990
|
+
state.tableState.setKeyboardNavigationDisabled(false);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
} else if (!resizeOnFocus) {
|
|
994
|
+
// Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there
|
|
995
|
+
e.continuePropagation();
|
|
996
|
+
if (e.key === "Enter") {
|
|
997
|
+
startResize(item);
|
|
998
|
+
state.tableState.setKeyboardNavigationDisabled(true);
|
|
999
|
+
}
|
|
984
1000
|
}
|
|
985
1001
|
}
|
|
986
1002
|
});
|
|
@@ -1005,8 +1021,8 @@ function $16d645f9e2153641$export$52994e973806c219(props, state, ref) {
|
|
|
1005
1021
|
state
|
|
1006
1022
|
]);
|
|
1007
1023
|
let endResize = (0, $kJQf8$react.useCallback)((item)=>{
|
|
1008
|
-
if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
1009
1024
|
if (isResizing.current) {
|
|
1025
|
+
if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
1010
1026
|
state.endResize();
|
|
1011
1027
|
onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd(lastSize.current);
|
|
1012
1028
|
}
|
|
@@ -1037,15 +1053,25 @@ function $16d645f9e2153641$export$52994e973806c219(props, state, ref) {
|
|
|
1037
1053
|
}
|
|
1038
1054
|
},
|
|
1039
1055
|
onMoveEnd (e) {
|
|
1056
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
1040
1057
|
let { pointerType: pointerType } = e;
|
|
1041
1058
|
columnResizeWidthRef.current = 0;
|
|
1042
|
-
if (pointerType === "mouse") endResize(item);
|
|
1059
|
+
if (pointerType === "mouse" || pointerType === "touch" && !resizeOnFocus) endResize(item);
|
|
1043
1060
|
}
|
|
1044
1061
|
});
|
|
1062
|
+
let onKeyDown = (0, $kJQf8$react.useCallback)((e)=>{
|
|
1063
|
+
if (editModeEnabled) moveProps.onKeyDown(e);
|
|
1064
|
+
}, [
|
|
1065
|
+
editModeEnabled,
|
|
1066
|
+
moveProps
|
|
1067
|
+
]);
|
|
1045
1068
|
let min = Math.floor(state.getColumnMinWidth(item.key));
|
|
1046
1069
|
let max = Math.floor(state.getColumnMaxWidth(item.key));
|
|
1047
1070
|
if (max === Infinity) max = Number.MAX_SAFE_INTEGER;
|
|
1048
1071
|
let value = Math.floor(state.getColumnWidth(item.key));
|
|
1072
|
+
let modality = (0, $kJQf8$reactariainteractions.useInteractionModality)();
|
|
1073
|
+
let description = (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) == null && (modality === "keyboard" || modality === "virtual") && !isResizing.current ? stringFormatter.format("resizerDescription") : undefined;
|
|
1074
|
+
let descriptionProps = (0, $kJQf8$reactariautils.useDescription)(description);
|
|
1049
1075
|
let ariaProps = {
|
|
1050
1076
|
"aria-label": props.label,
|
|
1051
1077
|
"aria-orientation": "horizontal",
|
|
@@ -1056,7 +1082,8 @@ function $16d645f9e2153641$export$52994e973806c219(props, state, ref) {
|
|
|
1056
1082
|
"type": "range",
|
|
1057
1083
|
min: min,
|
|
1058
1084
|
max: max,
|
|
1059
|
-
value: value
|
|
1085
|
+
value: value,
|
|
1086
|
+
...descriptionProps
|
|
1060
1087
|
};
|
|
1061
1088
|
const focusInput = (0, $kJQf8$react.useCallback)(()=>{
|
|
1062
1089
|
if (ref.current) (0, $kJQf8$reactariautils.focusWithoutScrolling)(ref.current);
|
|
@@ -1074,28 +1101,42 @@ function $16d645f9e2153641$export$52994e973806c219(props, state, ref) {
|
|
|
1074
1101
|
onPressStart: (e)=>{
|
|
1075
1102
|
if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === "keyboard") return;
|
|
1076
1103
|
if (e.pointerType === "virtual" && state.resizingColumn != null) {
|
|
1104
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
1077
1105
|
endResize(item);
|
|
1078
|
-
if (
|
|
1106
|
+
if (resizeOnFocus) (0, $kJQf8$reactariafocus.focusSafely)(triggerRef.current);
|
|
1079
1107
|
return;
|
|
1080
1108
|
}
|
|
1109
|
+
// Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away
|
|
1110
|
+
// can cancel resize mode for us.
|
|
1081
1111
|
focusInput();
|
|
1112
|
+
// If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need
|
|
1113
|
+
// to handle a virtual click to start the resizer.
|
|
1114
|
+
if (e.pointerType !== "virtual") startResize(item);
|
|
1082
1115
|
},
|
|
1083
1116
|
onPress: (e)=>{
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
if (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) (0, $kJQf8$reactariafocus.focusSafely)(triggerRef.current);
|
|
1087
|
-
}
|
|
1117
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
1118
|
+
if ((e.pointerType === "touch" && !resizeOnFocus || e.pointerType === "mouse") && state.resizingColumn != null) endResize(item);
|
|
1088
1119
|
}
|
|
1089
1120
|
});
|
|
1090
1121
|
return {
|
|
1091
|
-
resizerProps: (0, $kJQf8$reactariautils.mergeProps)(keyboardProps,
|
|
1122
|
+
resizerProps: (0, $kJQf8$reactariautils.mergeProps)(keyboardProps, {
|
|
1123
|
+
...moveProps,
|
|
1124
|
+
onKeyDown: onKeyDown
|
|
1125
|
+
}, pressProps),
|
|
1092
1126
|
inputProps: (0, $kJQf8$reactariautils.mergeProps)({
|
|
1093
1127
|
id: id,
|
|
1128
|
+
// Override browser default margin. Without this, scrollIntoViewport will think we need to scroll the input into view
|
|
1129
|
+
style: {
|
|
1130
|
+
margin: "0px"
|
|
1131
|
+
},
|
|
1094
1132
|
onFocus: ()=>{
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1133
|
+
let resizeOnFocus = !!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current);
|
|
1134
|
+
if (resizeOnFocus) {
|
|
1135
|
+
// useMove calls onMoveStart for every keypress, but we want resize start to only be called when we start resize mode
|
|
1136
|
+
// call instead during focus and blur
|
|
1137
|
+
startResize(item);
|
|
1138
|
+
state.tableState.setKeyboardNavigationDisabled(true);
|
|
1139
|
+
}
|
|
1099
1140
|
},
|
|
1100
1141
|
onBlur: ()=>{
|
|
1101
1142
|
endResize(item);
|