@react-aria/table 3.13.6-nightly.4555 → 3.13.6-nightly.4560
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/TableKeyboardDelegate.main.js +132 -0
- package/dist/TableKeyboardDelegate.main.js.map +1 -0
- package/dist/TableKeyboardDelegate.mjs +127 -0
- package/dist/TableKeyboardDelegate.module.js +127 -0
- package/dist/TableKeyboardDelegate.module.js.map +1 -0
- package/dist/ar-AE.mjs +1 -1
- package/dist/bg-BG.mjs +1 -1
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/import.mjs +8 -779
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/main.js +15 -786
- package/dist/main.js.map +1 -1
- package/dist/module.js +8 -779
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/uk-UA.mjs +1 -1
- package/dist/useTable.main.js +111 -0
- package/dist/useTable.main.js.map +1 -0
- package/dist/useTable.mjs +106 -0
- package/dist/useTable.module.js +106 -0
- package/dist/useTable.module.js.map +1 -0
- package/dist/useTableCell.main.js +36 -0
- package/dist/useTableCell.main.js.map +1 -0
- package/dist/useTableCell.mjs +31 -0
- package/dist/useTableCell.module.js +31 -0
- package/dist/useTableCell.module.js.map +1 -0
- package/dist/useTableColumnHeader.main.js +93 -0
- package/dist/useTableColumnHeader.main.js.map +1 -0
- package/dist/useTableColumnHeader.mjs +88 -0
- package/dist/useTableColumnHeader.module.js +88 -0
- package/dist/useTableColumnHeader.module.js.map +1 -0
- package/dist/useTableColumnResize.main.js +216 -0
- package/dist/useTableColumnResize.main.js.map +1 -0
- package/dist/useTableColumnResize.mjs +211 -0
- package/dist/useTableColumnResize.module.js +211 -0
- package/dist/useTableColumnResize.module.js.map +1 -0
- package/dist/useTableHeaderRow.main.js +32 -0
- package/dist/useTableHeaderRow.main.js.map +1 -0
- package/dist/useTableHeaderRow.mjs +27 -0
- package/dist/useTableHeaderRow.module.js +27 -0
- package/dist/useTableHeaderRow.module.js.map +1 -0
- package/dist/useTableRow.main.js +80 -0
- package/dist/useTableRow.main.js.map +1 -0
- package/dist/useTableRow.mjs +75 -0
- package/dist/useTableRow.module.js +75 -0
- package/dist/useTableRow.module.js.map +1 -0
- package/dist/useTableSelectionCheckbox.main.js +56 -0
- package/dist/useTableSelectionCheckbox.main.js.map +1 -0
- package/dist/useTableSelectionCheckbox.mjs +50 -0
- package/dist/useTableSelectionCheckbox.module.js +50 -0
- package/dist/useTableSelectionCheckbox.module.js.map +1 -0
- package/dist/utils.main.js +43 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +35 -0
- package/dist/utils.module.js +35 -0
- package/dist/utils.module.js.map +1 -0
- package/dist/zh-CN.m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AW,wBAAwB,OAAO,IAAK,EAAE,WAAW,KAAK,OAAM,KAAM,MAAM,cAAc,IAAI,MAC3H,UAAU;QAEd;IACF;IACA,IAAI,uBAAC,mBAAmB,EAAC,GAAG,CAAA,GAAA,gDAAgB;IAE5C,OAAO;QACL,cAAc,CAAA,GAAA,gCAAS,EACrB,eACA;YAAC,GAAG,SAAS;uBAAE;QAAS,GACxB,YACA;YAAC,OAAO;gBAAC,aAAa;YAAM;QAAC;QAE/B,YAAY,CAAA,GAAA,gCAAS,EACnB,qBACA;gBACE;YACA,QAAQ;gBACN,UAAU;YACZ;sBACA;YACA,UAAU;QACZ,GACA;oBAEF;IACF;AACF","sources":["packages/@react-aria/table/src/useTableColumnResize.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ChangeEvent, RefObject, useCallback, useEffect, useRef} from 'react';\nimport {ColumnSize} from '@react-types/table';\nimport {DOMAttributes, FocusableElement, Key} from '@react-types/shared';\nimport {focusSafely} from '@react-aria/focus';\nimport {getColumnHeaderId} from './utils';\nimport {GridNode} from '@react-types/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeProps, useDescription, useEffectEvent, useId} from '@react-aria/utils';\nimport {TableColumnResizeState} from '@react-stately/table';\nimport {useInteractionModality, useKeyboard, useMove, usePress} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface TableColumnResizeAria {\n /** Props for the visually hidden input element. */\n inputProps: DOMAttributes,\n /** Props for the resizer element. */\n resizerProps: DOMAttributes,\n /** Whether this column is currently being resized. */\n isResizing: boolean\n}\n\nexport interface AriaTableColumnResizeProps<T> {\n /** An object representing the [column header](https://www.w3.org/TR/wai-aria-1.1/#columnheader). Contains all the relevant information that makes up the column header. */\n column: GridNode<T>,\n /** Aria label for the hidden input. Gets read when resizing. */\n 'aria-label': string,\n /**\n * Ref to the trigger if resizing was started from a column header menu. If it's provided,\n * focus will be returned there when resizing is done. If it isn't provided, it is assumed that the resizer is\n * visible at all time and keyboard resizing is started via pressing Enter on the resizer and not on focus.\n * */\n triggerRef?: RefObject<FocusableElement>,\n /** If resizing is disabled. */\n isDisabled?: boolean,\n /** Called when resizing starts. */\n onResizeStart?: (widths: Map<Key, ColumnSize>) => void,\n /** Called for every resize event that results in new column sizes. */\n onResize?: (widths: Map<Key, ColumnSize>) => void,\n /** Called when resizing ends. */\n onResizeEnd?: (widths: Map<Key, ColumnSize>) => void\n}\n\n/**\n * Provides the behavior and accessibility implementation for a table column resizer element.\n * @param props - Props for the resizer.\n * @param state - State for the table's resizable columns, as returned by `useTableColumnResizeState`.\n * @param ref - The ref attached to the resizer's visually hidden input element.\n */\nexport function useTableColumnResize<T>(props: AriaTableColumnResizeProps<T>, state: TableColumnResizeState<T>, ref: RefObject<HTMLInputElement>): TableColumnResizeAria {\n let {column: item, triggerRef, isDisabled, onResizeStart, onResize, onResizeEnd, 'aria-label': ariaLabel} = props;\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/table');\n let id = useId();\n let isResizing = state.resizingColumn === item.key;\n let isResizingRef = useRef(isResizing);\n let lastSize = useRef(null);\n let wasFocusedOnResizeStart = useRef(false);\n let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;\n\n let {direction} = useLocale();\n let {keyboardProps} = useKeyboard({\n onKeyDown: (e) => {\n if (editModeEnabled) {\n if (e.key === 'Escape' || e.key === 'Enter' || e.key === ' ' || e.key === 'Tab') {\n e.preventDefault();\n endResize(item);\n }\n } else {\n // Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there\n e.continuePropagation();\n\n if (e.key === 'Enter') {\n startResize(item);\n }\n }\n }\n });\n\n let startResize = useEffectEvent((item) => {\n if (!isResizingRef.current) {\n lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));\n state.startResize(item.key);\n state.tableState.setKeyboardNavigationDisabled(true);\n onResizeStart?.(lastSize.current);\n }\n isResizingRef.current = true;\n });\n\n let resize = useEffectEvent((item, newWidth) => {\n let sizes = state.updateResizedColumns(item.key, newWidth);\n onResize?.(sizes);\n lastSize.current = sizes;\n });\n\n let endResize = useEffectEvent((item) => {\n if (isResizingRef.current) {\n if (lastSize.current == null) {\n lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));\n }\n\n state.endResize();\n state.tableState.setKeyboardNavigationDisabled(false);\n onResizeEnd?.(lastSize.current);\n isResizingRef.current = false;\n\n if (triggerRef?.current && !wasFocusedOnResizeStart.current) {\n // switch focus back to the column header unless the resizer was already focused when resizing started.\n focusSafely(triggerRef.current);\n }\n }\n lastSize.current = null;\n });\n\n const columnResizeWidthRef = useRef<number>(0);\n const {moveProps} = useMove({\n onMoveStart() {\n columnResizeWidthRef.current = state.getColumnWidth(item.key);\n startResize(item);\n },\n onMove(e) {\n let {deltaX, deltaY, pointerType} = e;\n if (direction === 'rtl') {\n deltaX *= -1;\n }\n if (pointerType === 'keyboard') {\n if (deltaY !== 0 && deltaX === 0) {\n deltaX = deltaY * -1;\n }\n deltaX *= 10;\n }\n // if moving up/down only, no need to resize\n if (deltaX !== 0) {\n columnResizeWidthRef.current += deltaX;\n resize(item, columnResizeWidthRef.current);\n }\n },\n onMoveEnd(e) {\n let {pointerType} = e;\n columnResizeWidthRef.current = 0;\n if (pointerType === 'mouse' || (pointerType === 'touch' && wasFocusedOnResizeStart.current)) {\n endResize(item);\n }\n }\n });\n\n let onKeyDown = useCallback((e) => {\n if (editModeEnabled) {\n moveProps.onKeyDown(e);\n }\n }, [editModeEnabled, moveProps]);\n\n\n let min = Math.floor(state.getColumnMinWidth(item.key));\n let max = Math.floor(state.getColumnMaxWidth(item.key));\n if (max === Infinity) {\n max = Number.MAX_SAFE_INTEGER;\n }\n let value = Math.floor(state.getColumnWidth(item.key));\n let modality: string = useInteractionModality();\n if (modality === 'virtual' && (typeof window !== 'undefined' && 'ontouchstart' in window)) {\n modality = 'touch';\n }\n let description = triggerRef?.current == null && (modality === 'keyboard' || modality === 'virtual') && !isResizing ? stringFormatter.format('resizerDescription') : undefined;\n let descriptionProps = useDescription(description);\n let ariaProps = {\n 'aria-label': ariaLabel,\n 'aria-orientation': 'horizontal' as 'horizontal',\n 'aria-labelledby': `${id} ${getColumnHeaderId(state.tableState, item.key)}`,\n 'aria-valuetext': stringFormatter.format('columnSize', {value}),\n 'type': 'range',\n min,\n max,\n value,\n ...descriptionProps\n };\n\n const focusInput = useCallback(() => {\n if (ref.current) {\n focusSafely(ref.current);\n }\n }, [ref]);\n\n let resizingColumn = state.resizingColumn;\n let prevResizingColumn = useRef(null);\n useEffect(() => {\n if (prevResizingColumn.current !== resizingColumn && resizingColumn != null && resizingColumn === item.key) {\n wasFocusedOnResizeStart.current = document.activeElement === ref.current;\n startResize(item);\n // Delay focusing input until Android Chrome's delayed click after touchend happens: https://bugs.chromium.org/p/chromium/issues/detail?id=1150073\n let timeout = setTimeout(() => focusInput(), 0);\n // VoiceOver on iOS has problems focusing the input from a menu.\n let VOTimeout = setTimeout(focusInput, 400);\n return () => {\n clearTimeout(timeout);\n clearTimeout(VOTimeout);\n };\n }\n prevResizingColumn.current = resizingColumn;\n }, [resizingColumn, item, focusInput, ref, startResize]);\n\n let onChange = (e: ChangeEvent<HTMLInputElement>) => {\n let currentWidth = state.getColumnWidth(item.key);\n let nextValue = parseFloat(e.target.value);\n\n if (nextValue > currentWidth) {\n nextValue = currentWidth + 10;\n } else {\n nextValue = currentWidth - 10;\n }\n resize(item, nextValue);\n };\n\n let {pressProps} = usePress({\n onPressStart: (e) => {\n if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === 'keyboard') {\n return;\n }\n if (e.pointerType === 'virtual' && state.resizingColumn != null) {\n endResize(item);\n return;\n }\n\n // Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away\n // can cancel resize mode for us.\n focusInput();\n\n // If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need\n // to handle a virtual click to start the resizer.\n if (e.pointerType !== 'virtual') {\n startResize(item);\n }\n },\n onPress: (e) => {\n if (((e.pointerType === 'touch' && wasFocusedOnResizeStart.current) || e.pointerType === 'mouse') && state.resizingColumn != null) {\n endResize(item);\n }\n }\n });\n let {visuallyHiddenProps} = useVisuallyHidden();\n\n return {\n resizerProps: mergeProps(\n keyboardProps,\n {...moveProps, onKeyDown},\n pressProps,\n {style: {touchAction: 'none'}}\n ),\n inputProps: mergeProps(\n visuallyHiddenProps,\n {\n id,\n onBlur: () => {\n endResize(item);\n },\n onChange,\n disabled: isDisabled\n },\n ariaProps\n ),\n isResizing\n };\n}\n"],"names":[],"version":3,"file":"useTableColumnResize.main.js.map"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import {getColumnHeaderId as $2140fb2337097f2d$export$37cd4213f2ad742e} from "./utils.mjs";
|
|
2
|
+
import $d9Rqy$intlStringsmodulejs from "./intlStrings.mjs";
|
|
3
|
+
import {useRef as $d9Rqy$useRef, useCallback as $d9Rqy$useCallback, useEffect as $d9Rqy$useEffect} from "react";
|
|
4
|
+
import {focusSafely as $d9Rqy$focusSafely} from "@react-aria/focus";
|
|
5
|
+
import {useId as $d9Rqy$useId, useEffectEvent as $d9Rqy$useEffectEvent, useDescription as $d9Rqy$useDescription, mergeProps as $d9Rqy$mergeProps} from "@react-aria/utils";
|
|
6
|
+
import {useKeyboard as $d9Rqy$useKeyboard, useMove as $d9Rqy$useMove, useInteractionModality as $d9Rqy$useInteractionModality, usePress as $d9Rqy$usePress} from "@react-aria/interactions";
|
|
7
|
+
import {useLocalizedStringFormatter as $d9Rqy$useLocalizedStringFormatter, useLocale as $d9Rqy$useLocale} from "@react-aria/i18n";
|
|
8
|
+
import {useVisuallyHidden as $d9Rqy$useVisuallyHidden} from "@react-aria/visually-hidden";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function $parcel$interopDefault(a) {
|
|
12
|
+
return a && a.__esModule ? a.default : a;
|
|
13
|
+
}
|
|
14
|
+
/*
|
|
15
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
*
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
+
* governing permissions and limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
function $e91ef4e5004e3774$export$52994e973806c219(props, state, ref) {
|
|
33
|
+
let { column: item, triggerRef: triggerRef, isDisabled: isDisabled, onResizeStart: onResizeStart, onResize: onResize, onResizeEnd: onResizeEnd, "aria-label": ariaLabel } = props;
|
|
34
|
+
const stringFormatter = (0, $d9Rqy$useLocalizedStringFormatter)((0, ($parcel$interopDefault($d9Rqy$intlStringsmodulejs))), "@react-aria/table");
|
|
35
|
+
let id = (0, $d9Rqy$useId)();
|
|
36
|
+
let isResizing = state.resizingColumn === item.key;
|
|
37
|
+
let isResizingRef = (0, $d9Rqy$useRef)(isResizing);
|
|
38
|
+
let lastSize = (0, $d9Rqy$useRef)(null);
|
|
39
|
+
let wasFocusedOnResizeStart = (0, $d9Rqy$useRef)(false);
|
|
40
|
+
let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;
|
|
41
|
+
let { direction: direction } = (0, $d9Rqy$useLocale)();
|
|
42
|
+
let { keyboardProps: keyboardProps } = (0, $d9Rqy$useKeyboard)({
|
|
43
|
+
onKeyDown: (e)=>{
|
|
44
|
+
if (editModeEnabled) {
|
|
45
|
+
if (e.key === "Escape" || e.key === "Enter" || e.key === " " || e.key === "Tab") {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
endResize(item);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
// Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there
|
|
51
|
+
e.continuePropagation();
|
|
52
|
+
if (e.key === "Enter") startResize(item);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
let startResize = (0, $d9Rqy$useEffectEvent)((item)=>{
|
|
57
|
+
if (!isResizingRef.current) {
|
|
58
|
+
lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
59
|
+
state.startResize(item.key);
|
|
60
|
+
state.tableState.setKeyboardNavigationDisabled(true);
|
|
61
|
+
onResizeStart === null || onResizeStart === void 0 ? void 0 : onResizeStart(lastSize.current);
|
|
62
|
+
}
|
|
63
|
+
isResizingRef.current = true;
|
|
64
|
+
});
|
|
65
|
+
let resize = (0, $d9Rqy$useEffectEvent)((item, newWidth)=>{
|
|
66
|
+
let sizes = state.updateResizedColumns(item.key, newWidth);
|
|
67
|
+
onResize === null || onResize === void 0 ? void 0 : onResize(sizes);
|
|
68
|
+
lastSize.current = sizes;
|
|
69
|
+
});
|
|
70
|
+
let endResize = (0, $d9Rqy$useEffectEvent)((item)=>{
|
|
71
|
+
if (isResizingRef.current) {
|
|
72
|
+
if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
73
|
+
state.endResize();
|
|
74
|
+
state.tableState.setKeyboardNavigationDisabled(false);
|
|
75
|
+
onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd(lastSize.current);
|
|
76
|
+
isResizingRef.current = false;
|
|
77
|
+
if ((triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) && !wasFocusedOnResizeStart.current) // switch focus back to the column header unless the resizer was already focused when resizing started.
|
|
78
|
+
(0, $d9Rqy$focusSafely)(triggerRef.current);
|
|
79
|
+
}
|
|
80
|
+
lastSize.current = null;
|
|
81
|
+
});
|
|
82
|
+
const columnResizeWidthRef = (0, $d9Rqy$useRef)(0);
|
|
83
|
+
const { moveProps: moveProps } = (0, $d9Rqy$useMove)({
|
|
84
|
+
onMoveStart () {
|
|
85
|
+
columnResizeWidthRef.current = state.getColumnWidth(item.key);
|
|
86
|
+
startResize(item);
|
|
87
|
+
},
|
|
88
|
+
onMove (e) {
|
|
89
|
+
let { deltaX: deltaX, deltaY: deltaY, pointerType: pointerType } = e;
|
|
90
|
+
if (direction === "rtl") deltaX *= -1;
|
|
91
|
+
if (pointerType === "keyboard") {
|
|
92
|
+
if (deltaY !== 0 && deltaX === 0) deltaX = deltaY * -1;
|
|
93
|
+
deltaX *= 10;
|
|
94
|
+
}
|
|
95
|
+
// if moving up/down only, no need to resize
|
|
96
|
+
if (deltaX !== 0) {
|
|
97
|
+
columnResizeWidthRef.current += deltaX;
|
|
98
|
+
resize(item, columnResizeWidthRef.current);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
onMoveEnd (e) {
|
|
102
|
+
let { pointerType: pointerType } = e;
|
|
103
|
+
columnResizeWidthRef.current = 0;
|
|
104
|
+
if (pointerType === "mouse" || pointerType === "touch" && wasFocusedOnResizeStart.current) endResize(item);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
let onKeyDown = (0, $d9Rqy$useCallback)((e)=>{
|
|
108
|
+
if (editModeEnabled) moveProps.onKeyDown(e);
|
|
109
|
+
}, [
|
|
110
|
+
editModeEnabled,
|
|
111
|
+
moveProps
|
|
112
|
+
]);
|
|
113
|
+
let min = Math.floor(state.getColumnMinWidth(item.key));
|
|
114
|
+
let max = Math.floor(state.getColumnMaxWidth(item.key));
|
|
115
|
+
if (max === Infinity) max = Number.MAX_SAFE_INTEGER;
|
|
116
|
+
let value = Math.floor(state.getColumnWidth(item.key));
|
|
117
|
+
let modality = (0, $d9Rqy$useInteractionModality)();
|
|
118
|
+
if (modality === "virtual" && typeof window !== "undefined" && "ontouchstart" in window) modality = "touch";
|
|
119
|
+
let description = (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) == null && (modality === "keyboard" || modality === "virtual") && !isResizing ? stringFormatter.format("resizerDescription") : undefined;
|
|
120
|
+
let descriptionProps = (0, $d9Rqy$useDescription)(description);
|
|
121
|
+
let ariaProps = {
|
|
122
|
+
"aria-label": ariaLabel,
|
|
123
|
+
"aria-orientation": "horizontal",
|
|
124
|
+
"aria-labelledby": `${id} ${(0, $2140fb2337097f2d$export$37cd4213f2ad742e)(state.tableState, item.key)}`,
|
|
125
|
+
"aria-valuetext": stringFormatter.format("columnSize", {
|
|
126
|
+
value: value
|
|
127
|
+
}),
|
|
128
|
+
"type": "range",
|
|
129
|
+
min: min,
|
|
130
|
+
max: max,
|
|
131
|
+
value: value,
|
|
132
|
+
...descriptionProps
|
|
133
|
+
};
|
|
134
|
+
const focusInput = (0, $d9Rqy$useCallback)(()=>{
|
|
135
|
+
if (ref.current) (0, $d9Rqy$focusSafely)(ref.current);
|
|
136
|
+
}, [
|
|
137
|
+
ref
|
|
138
|
+
]);
|
|
139
|
+
let resizingColumn = state.resizingColumn;
|
|
140
|
+
let prevResizingColumn = (0, $d9Rqy$useRef)(null);
|
|
141
|
+
(0, $d9Rqy$useEffect)(()=>{
|
|
142
|
+
if (prevResizingColumn.current !== resizingColumn && resizingColumn != null && resizingColumn === item.key) {
|
|
143
|
+
wasFocusedOnResizeStart.current = document.activeElement === ref.current;
|
|
144
|
+
startResize(item);
|
|
145
|
+
// Delay focusing input until Android Chrome's delayed click after touchend happens: https://bugs.chromium.org/p/chromium/issues/detail?id=1150073
|
|
146
|
+
let timeout = setTimeout(()=>focusInput(), 0);
|
|
147
|
+
// VoiceOver on iOS has problems focusing the input from a menu.
|
|
148
|
+
let VOTimeout = setTimeout(focusInput, 400);
|
|
149
|
+
return ()=>{
|
|
150
|
+
clearTimeout(timeout);
|
|
151
|
+
clearTimeout(VOTimeout);
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
prevResizingColumn.current = resizingColumn;
|
|
155
|
+
}, [
|
|
156
|
+
resizingColumn,
|
|
157
|
+
item,
|
|
158
|
+
focusInput,
|
|
159
|
+
ref,
|
|
160
|
+
startResize
|
|
161
|
+
]);
|
|
162
|
+
let onChange = (e)=>{
|
|
163
|
+
let currentWidth = state.getColumnWidth(item.key);
|
|
164
|
+
let nextValue = parseFloat(e.target.value);
|
|
165
|
+
if (nextValue > currentWidth) nextValue = currentWidth + 10;
|
|
166
|
+
else nextValue = currentWidth - 10;
|
|
167
|
+
resize(item, nextValue);
|
|
168
|
+
};
|
|
169
|
+
let { pressProps: pressProps } = (0, $d9Rqy$usePress)({
|
|
170
|
+
onPressStart: (e)=>{
|
|
171
|
+
if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === "keyboard") return;
|
|
172
|
+
if (e.pointerType === "virtual" && state.resizingColumn != null) {
|
|
173
|
+
endResize(item);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
// Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away
|
|
177
|
+
// can cancel resize mode for us.
|
|
178
|
+
focusInput();
|
|
179
|
+
// If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need
|
|
180
|
+
// to handle a virtual click to start the resizer.
|
|
181
|
+
if (e.pointerType !== "virtual") startResize(item);
|
|
182
|
+
},
|
|
183
|
+
onPress: (e)=>{
|
|
184
|
+
if ((e.pointerType === "touch" && wasFocusedOnResizeStart.current || e.pointerType === "mouse") && state.resizingColumn != null) endResize(item);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $d9Rqy$useVisuallyHidden)();
|
|
188
|
+
return {
|
|
189
|
+
resizerProps: (0, $d9Rqy$mergeProps)(keyboardProps, {
|
|
190
|
+
...moveProps,
|
|
191
|
+
onKeyDown: onKeyDown
|
|
192
|
+
}, pressProps, {
|
|
193
|
+
style: {
|
|
194
|
+
touchAction: "none"
|
|
195
|
+
}
|
|
196
|
+
}),
|
|
197
|
+
inputProps: (0, $d9Rqy$mergeProps)(visuallyHiddenProps, {
|
|
198
|
+
id: id,
|
|
199
|
+
onBlur: ()=>{
|
|
200
|
+
endResize(item);
|
|
201
|
+
},
|
|
202
|
+
onChange: onChange,
|
|
203
|
+
disabled: isDisabled
|
|
204
|
+
}, ariaProps),
|
|
205
|
+
isResizing: isResizing
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
export {$e91ef4e5004e3774$export$52994e973806c219 as useTableColumnResize};
|
|
211
|
+
//# sourceMappingURL=useTableColumnResize.mjs.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import {getColumnHeaderId as $2140fb2337097f2d$export$37cd4213f2ad742e} from "./utils.module.js";
|
|
2
|
+
import $d9Rqy$intlStringsmodulejs from "./intlStrings.module.js";
|
|
3
|
+
import {useRef as $d9Rqy$useRef, useCallback as $d9Rqy$useCallback, useEffect as $d9Rqy$useEffect} from "react";
|
|
4
|
+
import {focusSafely as $d9Rqy$focusSafely} from "@react-aria/focus";
|
|
5
|
+
import {useId as $d9Rqy$useId, useEffectEvent as $d9Rqy$useEffectEvent, useDescription as $d9Rqy$useDescription, mergeProps as $d9Rqy$mergeProps} from "@react-aria/utils";
|
|
6
|
+
import {useKeyboard as $d9Rqy$useKeyboard, useMove as $d9Rqy$useMove, useInteractionModality as $d9Rqy$useInteractionModality, usePress as $d9Rqy$usePress} from "@react-aria/interactions";
|
|
7
|
+
import {useLocalizedStringFormatter as $d9Rqy$useLocalizedStringFormatter, useLocale as $d9Rqy$useLocale} from "@react-aria/i18n";
|
|
8
|
+
import {useVisuallyHidden as $d9Rqy$useVisuallyHidden} from "@react-aria/visually-hidden";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function $parcel$interopDefault(a) {
|
|
12
|
+
return a && a.__esModule ? a.default : a;
|
|
13
|
+
}
|
|
14
|
+
/*
|
|
15
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
*
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
+
* governing permissions and limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
function $e91ef4e5004e3774$export$52994e973806c219(props, state, ref) {
|
|
33
|
+
let { column: item, triggerRef: triggerRef, isDisabled: isDisabled, onResizeStart: onResizeStart, onResize: onResize, onResizeEnd: onResizeEnd, "aria-label": ariaLabel } = props;
|
|
34
|
+
const stringFormatter = (0, $d9Rqy$useLocalizedStringFormatter)((0, ($parcel$interopDefault($d9Rqy$intlStringsmodulejs))), "@react-aria/table");
|
|
35
|
+
let id = (0, $d9Rqy$useId)();
|
|
36
|
+
let isResizing = state.resizingColumn === item.key;
|
|
37
|
+
let isResizingRef = (0, $d9Rqy$useRef)(isResizing);
|
|
38
|
+
let lastSize = (0, $d9Rqy$useRef)(null);
|
|
39
|
+
let wasFocusedOnResizeStart = (0, $d9Rqy$useRef)(false);
|
|
40
|
+
let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;
|
|
41
|
+
let { direction: direction } = (0, $d9Rqy$useLocale)();
|
|
42
|
+
let { keyboardProps: keyboardProps } = (0, $d9Rqy$useKeyboard)({
|
|
43
|
+
onKeyDown: (e)=>{
|
|
44
|
+
if (editModeEnabled) {
|
|
45
|
+
if (e.key === "Escape" || e.key === "Enter" || e.key === " " || e.key === "Tab") {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
endResize(item);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
// Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there
|
|
51
|
+
e.continuePropagation();
|
|
52
|
+
if (e.key === "Enter") startResize(item);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
let startResize = (0, $d9Rqy$useEffectEvent)((item)=>{
|
|
57
|
+
if (!isResizingRef.current) {
|
|
58
|
+
lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
59
|
+
state.startResize(item.key);
|
|
60
|
+
state.tableState.setKeyboardNavigationDisabled(true);
|
|
61
|
+
onResizeStart === null || onResizeStart === void 0 ? void 0 : onResizeStart(lastSize.current);
|
|
62
|
+
}
|
|
63
|
+
isResizingRef.current = true;
|
|
64
|
+
});
|
|
65
|
+
let resize = (0, $d9Rqy$useEffectEvent)((item, newWidth)=>{
|
|
66
|
+
let sizes = state.updateResizedColumns(item.key, newWidth);
|
|
67
|
+
onResize === null || onResize === void 0 ? void 0 : onResize(sizes);
|
|
68
|
+
lastSize.current = sizes;
|
|
69
|
+
});
|
|
70
|
+
let endResize = (0, $d9Rqy$useEffectEvent)((item)=>{
|
|
71
|
+
if (isResizingRef.current) {
|
|
72
|
+
if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
73
|
+
state.endResize();
|
|
74
|
+
state.tableState.setKeyboardNavigationDisabled(false);
|
|
75
|
+
onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd(lastSize.current);
|
|
76
|
+
isResizingRef.current = false;
|
|
77
|
+
if ((triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) && !wasFocusedOnResizeStart.current) // switch focus back to the column header unless the resizer was already focused when resizing started.
|
|
78
|
+
(0, $d9Rqy$focusSafely)(triggerRef.current);
|
|
79
|
+
}
|
|
80
|
+
lastSize.current = null;
|
|
81
|
+
});
|
|
82
|
+
const columnResizeWidthRef = (0, $d9Rqy$useRef)(0);
|
|
83
|
+
const { moveProps: moveProps } = (0, $d9Rqy$useMove)({
|
|
84
|
+
onMoveStart () {
|
|
85
|
+
columnResizeWidthRef.current = state.getColumnWidth(item.key);
|
|
86
|
+
startResize(item);
|
|
87
|
+
},
|
|
88
|
+
onMove (e) {
|
|
89
|
+
let { deltaX: deltaX, deltaY: deltaY, pointerType: pointerType } = e;
|
|
90
|
+
if (direction === "rtl") deltaX *= -1;
|
|
91
|
+
if (pointerType === "keyboard") {
|
|
92
|
+
if (deltaY !== 0 && deltaX === 0) deltaX = deltaY * -1;
|
|
93
|
+
deltaX *= 10;
|
|
94
|
+
}
|
|
95
|
+
// if moving up/down only, no need to resize
|
|
96
|
+
if (deltaX !== 0) {
|
|
97
|
+
columnResizeWidthRef.current += deltaX;
|
|
98
|
+
resize(item, columnResizeWidthRef.current);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
onMoveEnd (e) {
|
|
102
|
+
let { pointerType: pointerType } = e;
|
|
103
|
+
columnResizeWidthRef.current = 0;
|
|
104
|
+
if (pointerType === "mouse" || pointerType === "touch" && wasFocusedOnResizeStart.current) endResize(item);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
let onKeyDown = (0, $d9Rqy$useCallback)((e)=>{
|
|
108
|
+
if (editModeEnabled) moveProps.onKeyDown(e);
|
|
109
|
+
}, [
|
|
110
|
+
editModeEnabled,
|
|
111
|
+
moveProps
|
|
112
|
+
]);
|
|
113
|
+
let min = Math.floor(state.getColumnMinWidth(item.key));
|
|
114
|
+
let max = Math.floor(state.getColumnMaxWidth(item.key));
|
|
115
|
+
if (max === Infinity) max = Number.MAX_SAFE_INTEGER;
|
|
116
|
+
let value = Math.floor(state.getColumnWidth(item.key));
|
|
117
|
+
let modality = (0, $d9Rqy$useInteractionModality)();
|
|
118
|
+
if (modality === "virtual" && typeof window !== "undefined" && "ontouchstart" in window) modality = "touch";
|
|
119
|
+
let description = (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) == null && (modality === "keyboard" || modality === "virtual") && !isResizing ? stringFormatter.format("resizerDescription") : undefined;
|
|
120
|
+
let descriptionProps = (0, $d9Rqy$useDescription)(description);
|
|
121
|
+
let ariaProps = {
|
|
122
|
+
"aria-label": ariaLabel,
|
|
123
|
+
"aria-orientation": "horizontal",
|
|
124
|
+
"aria-labelledby": `${id} ${(0, $2140fb2337097f2d$export$37cd4213f2ad742e)(state.tableState, item.key)}`,
|
|
125
|
+
"aria-valuetext": stringFormatter.format("columnSize", {
|
|
126
|
+
value: value
|
|
127
|
+
}),
|
|
128
|
+
"type": "range",
|
|
129
|
+
min: min,
|
|
130
|
+
max: max,
|
|
131
|
+
value: value,
|
|
132
|
+
...descriptionProps
|
|
133
|
+
};
|
|
134
|
+
const focusInput = (0, $d9Rqy$useCallback)(()=>{
|
|
135
|
+
if (ref.current) (0, $d9Rqy$focusSafely)(ref.current);
|
|
136
|
+
}, [
|
|
137
|
+
ref
|
|
138
|
+
]);
|
|
139
|
+
let resizingColumn = state.resizingColumn;
|
|
140
|
+
let prevResizingColumn = (0, $d9Rqy$useRef)(null);
|
|
141
|
+
(0, $d9Rqy$useEffect)(()=>{
|
|
142
|
+
if (prevResizingColumn.current !== resizingColumn && resizingColumn != null && resizingColumn === item.key) {
|
|
143
|
+
wasFocusedOnResizeStart.current = document.activeElement === ref.current;
|
|
144
|
+
startResize(item);
|
|
145
|
+
// Delay focusing input until Android Chrome's delayed click after touchend happens: https://bugs.chromium.org/p/chromium/issues/detail?id=1150073
|
|
146
|
+
let timeout = setTimeout(()=>focusInput(), 0);
|
|
147
|
+
// VoiceOver on iOS has problems focusing the input from a menu.
|
|
148
|
+
let VOTimeout = setTimeout(focusInput, 400);
|
|
149
|
+
return ()=>{
|
|
150
|
+
clearTimeout(timeout);
|
|
151
|
+
clearTimeout(VOTimeout);
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
prevResizingColumn.current = resizingColumn;
|
|
155
|
+
}, [
|
|
156
|
+
resizingColumn,
|
|
157
|
+
item,
|
|
158
|
+
focusInput,
|
|
159
|
+
ref,
|
|
160
|
+
startResize
|
|
161
|
+
]);
|
|
162
|
+
let onChange = (e)=>{
|
|
163
|
+
let currentWidth = state.getColumnWidth(item.key);
|
|
164
|
+
let nextValue = parseFloat(e.target.value);
|
|
165
|
+
if (nextValue > currentWidth) nextValue = currentWidth + 10;
|
|
166
|
+
else nextValue = currentWidth - 10;
|
|
167
|
+
resize(item, nextValue);
|
|
168
|
+
};
|
|
169
|
+
let { pressProps: pressProps } = (0, $d9Rqy$usePress)({
|
|
170
|
+
onPressStart: (e)=>{
|
|
171
|
+
if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === "keyboard") return;
|
|
172
|
+
if (e.pointerType === "virtual" && state.resizingColumn != null) {
|
|
173
|
+
endResize(item);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
// Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away
|
|
177
|
+
// can cancel resize mode for us.
|
|
178
|
+
focusInput();
|
|
179
|
+
// If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need
|
|
180
|
+
// to handle a virtual click to start the resizer.
|
|
181
|
+
if (e.pointerType !== "virtual") startResize(item);
|
|
182
|
+
},
|
|
183
|
+
onPress: (e)=>{
|
|
184
|
+
if ((e.pointerType === "touch" && wasFocusedOnResizeStart.current || e.pointerType === "mouse") && state.resizingColumn != null) endResize(item);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $d9Rqy$useVisuallyHidden)();
|
|
188
|
+
return {
|
|
189
|
+
resizerProps: (0, $d9Rqy$mergeProps)(keyboardProps, {
|
|
190
|
+
...moveProps,
|
|
191
|
+
onKeyDown: onKeyDown
|
|
192
|
+
}, pressProps, {
|
|
193
|
+
style: {
|
|
194
|
+
touchAction: "none"
|
|
195
|
+
}
|
|
196
|
+
}),
|
|
197
|
+
inputProps: (0, $d9Rqy$mergeProps)(visuallyHiddenProps, {
|
|
198
|
+
id: id,
|
|
199
|
+
onBlur: ()=>{
|
|
200
|
+
endResize(item);
|
|
201
|
+
},
|
|
202
|
+
onChange: onChange,
|
|
203
|
+
disabled: isDisabled
|
|
204
|
+
}, ariaProps),
|
|
205
|
+
isResizing: isResizing
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
export {$e91ef4e5004e3774$export$52994e973806c219 as useTableColumnResize};
|
|
211
|
+
//# sourceMappingURL=useTableColumnResize.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAoDM,SAAS,0CAAwB,KAAoC,EAAE,KAAgC,EAAE,GAAgC;IAC9I,IAAI,EAAC,QAAQ,IAAI,cAAE,UAAU,cAAE,UAAU,iBAAE,aAAa,YAAE,QAAQ,eAAE,WAAW,EAAE,cAAc,SAAS,EAAC,GAAG;IAC5G,MAAM,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAClE,IAAI,KAAK,CAAA,GAAA,YAAI;IACb,IAAI,aAAa,MAAM,cAAc,KAAK,KAAK,GAAG;IAClD,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAE;IAC3B,IAAI,WAAW,CAAA,GAAA,aAAK,EAAE;IACtB,IAAI,0BAA0B,CAAA,GAAA,aAAK,EAAE;IACrC,I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c,CAAC,KAAK,GAAG;QAChD,IAAI,YAAY,WAAW,EAAE,MAAM,CAAC,KAAK;QAEzC,IAAI,YAAY,cACd,YAAY,eAAe;aAE3B,YAAY,eAAe;QAE7B,OAAO,MAAM;IACf;IAEA,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,cAAc,CAAC;YACb,IAAI,EAAE,OAAO,IAAI,EAAE,MAAM,IAAI,EAAE,OAAO,IAAI,EAAE,QAAQ,IAAI,EAAE,WAAW,KAAK,YACxE;YAEF,IAAI,EAAE,WAAW,KAAK,aAAa,MAAM,cAAc,IAAI,MAAM;gBAC/D,UAAU;gBACV;YACF;YAEA,0GAA0G;YAC1G,iCAAiC;YACjC;YAEA,gIAAgI;YAChI,kDAAkD;YAClD,IAAI,EAAE,WAAW,KAAK,WACpB,YAAY;QAEhB;QACA,SAAS,CAAC;YACR,IAAI,AAAC,CAAA,AAAC,EAAE,WAAW,KAAK,WAAW,wBAAwB,OAAO,IAAK,EAAE,WAAW,KAAK,OAAM,KAAM,MAAM,cAAc,IAAI,MAC3H,UAAU;QAEd;IACF;IACA,IAAI,uBAAC,mBAAmB,EAAC,GAAG,CAAA,GAAA,wBAAgB;IAE5C,OAAO;QACL,cAAc,CAAA,GAAA,iBAAS,EACrB,eACA;YAAC,GAAG,SAAS;uBAAE;QAAS,GACxB,YACA;YAAC,OAAO;gBAAC,aAAa;YAAM;QAAC;QAE/B,YAAY,CAAA,GAAA,iBAAS,EACnB,qBACA;gBACE;YACA,QAAQ;gBACN,UAAU;YACZ;sBACA;YACA,UAAU;QACZ,GACA;oBAEF;IACF;AACF","sources":["packages/@react-aria/table/src/useTableColumnResize.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ChangeEvent, RefObject, useCallback, useEffect, useRef} from 'react';\nimport {ColumnSize} from '@react-types/table';\nimport {DOMAttributes, FocusableElement, Key} from '@react-types/shared';\nimport {focusSafely} from '@react-aria/focus';\nimport {getColumnHeaderId} from './utils';\nimport {GridNode} from '@react-types/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeProps, useDescription, useEffectEvent, useId} from '@react-aria/utils';\nimport {TableColumnResizeState} from '@react-stately/table';\nimport {useInteractionModality, useKeyboard, useMove, usePress} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface TableColumnResizeAria {\n /** Props for the visually hidden input element. */\n inputProps: DOMAttributes,\n /** Props for the resizer element. */\n resizerProps: DOMAttributes,\n /** Whether this column is currently being resized. */\n isResizing: boolean\n}\n\nexport interface AriaTableColumnResizeProps<T> {\n /** An object representing the [column header](https://www.w3.org/TR/wai-aria-1.1/#columnheader). Contains all the relevant information that makes up the column header. */\n column: GridNode<T>,\n /** Aria label for the hidden input. Gets read when resizing. */\n 'aria-label': string,\n /**\n * Ref to the trigger if resizing was started from a column header menu. If it's provided,\n * focus will be returned there when resizing is done. If it isn't provided, it is assumed that the resizer is\n * visible at all time and keyboard resizing is started via pressing Enter on the resizer and not on focus.\n * */\n triggerRef?: RefObject<FocusableElement>,\n /** If resizing is disabled. */\n isDisabled?: boolean,\n /** Called when resizing starts. */\n onResizeStart?: (widths: Map<Key, ColumnSize>) => void,\n /** Called for every resize event that results in new column sizes. */\n onResize?: (widths: Map<Key, ColumnSize>) => void,\n /** Called when resizing ends. */\n onResizeEnd?: (widths: Map<Key, ColumnSize>) => void\n}\n\n/**\n * Provides the behavior and accessibility implementation for a table column resizer element.\n * @param props - Props for the resizer.\n * @param state - State for the table's resizable columns, as returned by `useTableColumnResizeState`.\n * @param ref - The ref attached to the resizer's visually hidden input element.\n */\nexport function useTableColumnResize<T>(props: AriaTableColumnResizeProps<T>, state: TableColumnResizeState<T>, ref: RefObject<HTMLInputElement>): TableColumnResizeAria {\n let {column: item, triggerRef, isDisabled, onResizeStart, onResize, onResizeEnd, 'aria-label': ariaLabel} = props;\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/table');\n let id = useId();\n let isResizing = state.resizingColumn === item.key;\n let isResizingRef = useRef(isResizing);\n let lastSize = useRef(null);\n let wasFocusedOnResizeStart = useRef(false);\n let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;\n\n let {direction} = useLocale();\n let {keyboardProps} = useKeyboard({\n onKeyDown: (e) => {\n if (editModeEnabled) {\n if (e.key === 'Escape' || e.key === 'Enter' || e.key === ' ' || e.key === 'Tab') {\n e.preventDefault();\n endResize(item);\n }\n } else {\n // Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there\n e.continuePropagation();\n\n if (e.key === 'Enter') {\n startResize(item);\n }\n }\n }\n });\n\n let startResize = useEffectEvent((item) => {\n if (!isResizingRef.current) {\n lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));\n state.startResize(item.key);\n state.tableState.setKeyboardNavigationDisabled(true);\n onResizeStart?.(lastSize.current);\n }\n isResizingRef.current = true;\n });\n\n let resize = useEffectEvent((item, newWidth) => {\n let sizes = state.updateResizedColumns(item.key, newWidth);\n onResize?.(sizes);\n lastSize.current = sizes;\n });\n\n let endResize = useEffectEvent((item) => {\n if (isResizingRef.current) {\n if (lastSize.current == null) {\n lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));\n }\n\n state.endResize();\n state.tableState.setKeyboardNavigationDisabled(false);\n onResizeEnd?.(lastSize.current);\n isResizingRef.current = false;\n\n if (triggerRef?.current && !wasFocusedOnResizeStart.current) {\n // switch focus back to the column header unless the resizer was already focused when resizing started.\n focusSafely(triggerRef.current);\n }\n }\n lastSize.current = null;\n });\n\n const columnResizeWidthRef = useRef<number>(0);\n const {moveProps} = useMove({\n onMoveStart() {\n columnResizeWidthRef.current = state.getColumnWidth(item.key);\n startResize(item);\n },\n onMove(e) {\n let {deltaX, deltaY, pointerType} = e;\n if (direction === 'rtl') {\n deltaX *= -1;\n }\n if (pointerType === 'keyboard') {\n if (deltaY !== 0 && deltaX === 0) {\n deltaX = deltaY * -1;\n }\n deltaX *= 10;\n }\n // if moving up/down only, no need to resize\n if (deltaX !== 0) {\n columnResizeWidthRef.current += deltaX;\n resize(item, columnResizeWidthRef.current);\n }\n },\n onMoveEnd(e) {\n let {pointerType} = e;\n columnResizeWidthRef.current = 0;\n if (pointerType === 'mouse' || (pointerType === 'touch' && wasFocusedOnResizeStart.current)) {\n endResize(item);\n }\n }\n });\n\n let onKeyDown = useCallback((e) => {\n if (editModeEnabled) {\n moveProps.onKeyDown(e);\n }\n }, [editModeEnabled, moveProps]);\n\n\n let min = Math.floor(state.getColumnMinWidth(item.key));\n let max = Math.floor(state.getColumnMaxWidth(item.key));\n if (max === Infinity) {\n max = Number.MAX_SAFE_INTEGER;\n }\n let value = Math.floor(state.getColumnWidth(item.key));\n let modality: string = useInteractionModality();\n if (modality === 'virtual' && (typeof window !== 'undefined' && 'ontouchstart' in window)) {\n modality = 'touch';\n }\n let description = triggerRef?.current == null && (modality === 'keyboard' || modality === 'virtual') && !isResizing ? stringFormatter.format('resizerDescription') : undefined;\n let descriptionProps = useDescription(description);\n let ariaProps = {\n 'aria-label': ariaLabel,\n 'aria-orientation': 'horizontal' as 'horizontal',\n 'aria-labelledby': `${id} ${getColumnHeaderId(state.tableState, item.key)}`,\n 'aria-valuetext': stringFormatter.format('columnSize', {value}),\n 'type': 'range',\n min,\n max,\n value,\n ...descriptionProps\n };\n\n const focusInput = useCallback(() => {\n if (ref.current) {\n focusSafely(ref.current);\n }\n }, [ref]);\n\n let resizingColumn = state.resizingColumn;\n let prevResizingColumn = useRef(null);\n useEffect(() => {\n if (prevResizingColumn.current !== resizingColumn && resizingColumn != null && resizingColumn === item.key) {\n wasFocusedOnResizeStart.current = document.activeElement === ref.current;\n startResize(item);\n // Delay focusing input until Android Chrome's delayed click after touchend happens: https://bugs.chromium.org/p/chromium/issues/detail?id=1150073\n let timeout = setTimeout(() => focusInput(), 0);\n // VoiceOver on iOS has problems focusing the input from a menu.\n let VOTimeout = setTimeout(focusInput, 400);\n return () => {\n clearTimeout(timeout);\n clearTimeout(VOTimeout);\n };\n }\n prevResizingColumn.current = resizingColumn;\n }, [resizingColumn, item, focusInput, ref, startResize]);\n\n let onChange = (e: ChangeEvent<HTMLInputElement>) => {\n let currentWidth = state.getColumnWidth(item.key);\n let nextValue = parseFloat(e.target.value);\n\n if (nextValue > currentWidth) {\n nextValue = currentWidth + 10;\n } else {\n nextValue = currentWidth - 10;\n }\n resize(item, nextValue);\n };\n\n let {pressProps} = usePress({\n onPressStart: (e) => {\n if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === 'keyboard') {\n return;\n }\n if (e.pointerType === 'virtual' && state.resizingColumn != null) {\n endResize(item);\n return;\n }\n\n // Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away\n // can cancel resize mode for us.\n focusInput();\n\n // If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need\n // to handle a virtual click to start the resizer.\n if (e.pointerType !== 'virtual') {\n startResize(item);\n }\n },\n onPress: (e) => {\n if (((e.pointerType === 'touch' && wasFocusedOnResizeStart.current) || e.pointerType === 'mouse') && state.resizingColumn != null) {\n endResize(item);\n }\n }\n });\n let {visuallyHiddenProps} = useVisuallyHidden();\n\n return {\n resizerProps: mergeProps(\n keyboardProps,\n {...moveProps, onKeyDown},\n pressProps,\n {style: {touchAction: 'none'}}\n ),\n inputProps: mergeProps(\n visuallyHiddenProps,\n {\n id,\n onBlur: () => {\n endResize(item);\n },\n onChange,\n disabled: isDisabled\n },\n ariaProps\n ),\n isResizing\n };\n}\n"],"names":[],"version":3,"file":"useTableColumnResize.module.js.map"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var $dwJMn$reactstatelyflags = require("@react-stately/flags");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "useTableHeaderRow", () => $eb16c38321a72835$export$1b95a7d2d517b841);
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
function $eb16c38321a72835$export$1b95a7d2d517b841(props, state, ref) {
|
|
21
|
+
let { node: node, isVirtualized: isVirtualized } = props;
|
|
22
|
+
let rowProps = {
|
|
23
|
+
role: "row"
|
|
24
|
+
};
|
|
25
|
+
if (isVirtualized && !((0, $dwJMn$reactstatelyflags.tableNestedRows)() && "expandedKeys" in state)) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
|
|
26
|
+
return {
|
|
27
|
+
rowProps: rowProps
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=useTableHeaderRow.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAmBM,SAAS,0CAAqB,KAAsB,EAAE,KAAoB,EAAE,GAAuB;IACxG,IAAI,QAAC,IAAI,iBAAE,aAAa,EAAC,GAAG;IAC5B,IAAI,WAAW;QACb,MAAM;IACR;IAEA,IAAI,iBAAiB,CAAE,CAAA,CAAA,GAAA,wCAAc,OAAO,kBAAkB,KAAI,GAChE,QAAQ,CAAC,gBAAgB,GAAG,KAAK,KAAK,GAAG,GAAG,2BAA2B;IAGzE,OAAO;kBACL;IACF;AACF","sources":["packages/@react-aria/table/src/useTableHeaderRow.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes} from '@react-types/shared';\nimport {GridRowProps} from '@react-aria/grid';\nimport {RefObject} from 'react';\nimport {tableNestedRows} from '@react-stately/flags';\nimport {TableState} from '@react-stately/table';\n\nexport interface TableHeaderRowAria {\n /** Props for the grid row element. */\n rowProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a header row in a table.\n * @param props - Props for the row.\n * @param state - State of the table, as returned by `useTableState`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useTableHeaderRow<T>(props: GridRowProps<T>, state: TableState<T>, ref: RefObject<Element>): TableHeaderRowAria {\n let {node, isVirtualized} = props;\n let rowProps = {\n role: 'row'\n };\n\n if (isVirtualized && !(tableNestedRows() && 'expandedKeys' in state)) {\n rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based\n }\n\n return {\n rowProps\n };\n}\n"],"names":[],"version":3,"file":"useTableHeaderRow.main.js.map"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {tableNestedRows as $4ns2c$tableNestedRows} from "@react-stately/flags";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
function $f917ee10f4c32dab$export$1b95a7d2d517b841(props, state, ref) {
|
|
15
|
+
let { node: node, isVirtualized: isVirtualized } = props;
|
|
16
|
+
let rowProps = {
|
|
17
|
+
role: "row"
|
|
18
|
+
};
|
|
19
|
+
if (isVirtualized && !((0, $4ns2c$tableNestedRows)() && "expandedKeys" in state)) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
|
|
20
|
+
return {
|
|
21
|
+
rowProps: rowProps
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export {$f917ee10f4c32dab$export$1b95a7d2d517b841 as useTableHeaderRow};
|
|
27
|
+
//# sourceMappingURL=useTableHeaderRow.mjs.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {tableNestedRows as $4ns2c$tableNestedRows} from "@react-stately/flags";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
function $f917ee10f4c32dab$export$1b95a7d2d517b841(props, state, ref) {
|
|
15
|
+
let { node: node, isVirtualized: isVirtualized } = props;
|
|
16
|
+
let rowProps = {
|
|
17
|
+
role: "row"
|
|
18
|
+
};
|
|
19
|
+
if (isVirtualized && !((0, $4ns2c$tableNestedRows)() && "expandedKeys" in state)) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
|
|
20
|
+
return {
|
|
21
|
+
rowProps: rowProps
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export {$f917ee10f4c32dab$export$1b95a7d2d517b841 as useTableHeaderRow};
|
|
27
|
+
//# sourceMappingURL=useTableHeaderRow.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAmBM,SAAS,0CAAqB,KAAsB,EAAE,KAAoB,EAAE,GAAuB;IACxG,IAAI,QAAC,IAAI,iBAAE,aAAa,EAAC,GAAG;IAC5B,IAAI,WAAW;QACb,MAAM;IACR;IAEA,IAAI,iBAAiB,CAAE,CAAA,CAAA,GAAA,sBAAc,OAAO,kBAAkB,KAAI,GAChE,QAAQ,CAAC,gBAAgB,GAAG,KAAK,KAAK,GAAG,GAAG,2BAA2B;IAGzE,OAAO;kBACL;IACF;AACF","sources":["packages/@react-aria/table/src/useTableHeaderRow.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes} from '@react-types/shared';\nimport {GridRowProps} from '@react-aria/grid';\nimport {RefObject} from 'react';\nimport {tableNestedRows} from '@react-stately/flags';\nimport {TableState} from '@react-stately/table';\n\nexport interface TableHeaderRowAria {\n /** Props for the grid row element. */\n rowProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a header row in a table.\n * @param props - Props for the row.\n * @param state - State of the table, as returned by `useTableState`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useTableHeaderRow<T>(props: GridRowProps<T>, state: TableState<T>, ref: RefObject<Element>): TableHeaderRowAria {\n let {node, isVirtualized} = props;\n let rowProps = {\n role: 'row'\n };\n\n if (isVirtualized && !(tableNestedRows() && 'expandedKeys' in state)) {\n rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based\n }\n\n return {\n rowProps\n };\n}\n"],"names":[],"version":3,"file":"useTableHeaderRow.module.js.map"}
|