@react-aria/table 3.17.10 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/dist/import.mjs +2 -19
  2. package/dist/main.js +10 -27
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +2 -19
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +4 -0
  7. package/package.json +15 -25
  8. package/src/index.ts +4 -21
  9. package/dist/TableKeyboardDelegate.main.js +0 -142
  10. package/dist/TableKeyboardDelegate.main.js.map +0 -1
  11. package/dist/TableKeyboardDelegate.mjs +0 -137
  12. package/dist/TableKeyboardDelegate.module.js +0 -137
  13. package/dist/TableKeyboardDelegate.module.js.map +0 -1
  14. package/dist/ar-AE.main.js +0 -14
  15. package/dist/ar-AE.main.js.map +0 -1
  16. package/dist/ar-AE.mjs +0 -16
  17. package/dist/ar-AE.module.js +0 -16
  18. package/dist/ar-AE.module.js.map +0 -1
  19. package/dist/bg-BG.main.js +0 -14
  20. package/dist/bg-BG.main.js.map +0 -1
  21. package/dist/bg-BG.mjs +0 -16
  22. package/dist/bg-BG.module.js +0 -16
  23. package/dist/bg-BG.module.js.map +0 -1
  24. package/dist/cs-CZ.main.js +0 -14
  25. package/dist/cs-CZ.main.js.map +0 -1
  26. package/dist/cs-CZ.mjs +0 -16
  27. package/dist/cs-CZ.module.js +0 -16
  28. package/dist/cs-CZ.module.js.map +0 -1
  29. package/dist/da-DK.main.js +0 -14
  30. package/dist/da-DK.main.js.map +0 -1
  31. package/dist/da-DK.mjs +0 -16
  32. package/dist/da-DK.module.js +0 -16
  33. package/dist/da-DK.module.js.map +0 -1
  34. package/dist/de-DE.main.js +0 -14
  35. package/dist/de-DE.main.js.map +0 -1
  36. package/dist/de-DE.mjs +0 -16
  37. package/dist/de-DE.module.js +0 -16
  38. package/dist/de-DE.module.js.map +0 -1
  39. package/dist/el-GR.main.js +0 -14
  40. package/dist/el-GR.main.js.map +0 -1
  41. package/dist/el-GR.mjs +0 -16
  42. package/dist/el-GR.module.js +0 -16
  43. package/dist/el-GR.module.js.map +0 -1
  44. package/dist/en-US.main.js +0 -14
  45. package/dist/en-US.main.js.map +0 -1
  46. package/dist/en-US.mjs +0 -16
  47. package/dist/en-US.module.js +0 -16
  48. package/dist/en-US.module.js.map +0 -1
  49. package/dist/es-ES.main.js +0 -14
  50. package/dist/es-ES.main.js.map +0 -1
  51. package/dist/es-ES.mjs +0 -16
  52. package/dist/es-ES.module.js +0 -16
  53. package/dist/es-ES.module.js.map +0 -1
  54. package/dist/et-EE.main.js +0 -14
  55. package/dist/et-EE.main.js.map +0 -1
  56. package/dist/et-EE.mjs +0 -16
  57. package/dist/et-EE.module.js +0 -16
  58. package/dist/et-EE.module.js.map +0 -1
  59. package/dist/fi-FI.main.js +0 -14
  60. package/dist/fi-FI.main.js.map +0 -1
  61. package/dist/fi-FI.mjs +0 -16
  62. package/dist/fi-FI.module.js +0 -16
  63. package/dist/fi-FI.module.js.map +0 -1
  64. package/dist/fr-FR.main.js +0 -14
  65. package/dist/fr-FR.main.js.map +0 -1
  66. package/dist/fr-FR.mjs +0 -16
  67. package/dist/fr-FR.module.js +0 -16
  68. package/dist/fr-FR.module.js.map +0 -1
  69. package/dist/he-IL.main.js +0 -14
  70. package/dist/he-IL.main.js.map +0 -1
  71. package/dist/he-IL.mjs +0 -16
  72. package/dist/he-IL.module.js +0 -16
  73. package/dist/he-IL.module.js.map +0 -1
  74. package/dist/hr-HR.main.js +0 -14
  75. package/dist/hr-HR.main.js.map +0 -1
  76. package/dist/hr-HR.mjs +0 -16
  77. package/dist/hr-HR.module.js +0 -16
  78. package/dist/hr-HR.module.js.map +0 -1
  79. package/dist/hu-HU.main.js +0 -14
  80. package/dist/hu-HU.main.js.map +0 -1
  81. package/dist/hu-HU.mjs +0 -16
  82. package/dist/hu-HU.module.js +0 -16
  83. package/dist/hu-HU.module.js.map +0 -1
  84. package/dist/intlStrings.main.js +0 -108
  85. package/dist/intlStrings.main.js.map +0 -1
  86. package/dist/intlStrings.mjs +0 -110
  87. package/dist/intlStrings.module.js +0 -110
  88. package/dist/intlStrings.module.js.map +0 -1
  89. package/dist/it-IT.main.js +0 -14
  90. package/dist/it-IT.main.js.map +0 -1
  91. package/dist/it-IT.mjs +0 -16
  92. package/dist/it-IT.module.js +0 -16
  93. package/dist/it-IT.module.js.map +0 -1
  94. package/dist/ja-JP.main.js +0 -14
  95. package/dist/ja-JP.main.js.map +0 -1
  96. package/dist/ja-JP.mjs +0 -16
  97. package/dist/ja-JP.module.js +0 -16
  98. package/dist/ja-JP.module.js.map +0 -1
  99. package/dist/ko-KR.main.js +0 -14
  100. package/dist/ko-KR.main.js.map +0 -1
  101. package/dist/ko-KR.mjs +0 -16
  102. package/dist/ko-KR.module.js +0 -16
  103. package/dist/ko-KR.module.js.map +0 -1
  104. package/dist/lt-LT.main.js +0 -14
  105. package/dist/lt-LT.main.js.map +0 -1
  106. package/dist/lt-LT.mjs +0 -16
  107. package/dist/lt-LT.module.js +0 -16
  108. package/dist/lt-LT.module.js.map +0 -1
  109. package/dist/lv-LV.main.js +0 -14
  110. package/dist/lv-LV.main.js.map +0 -1
  111. package/dist/lv-LV.mjs +0 -16
  112. package/dist/lv-LV.module.js +0 -16
  113. package/dist/lv-LV.module.js.map +0 -1
  114. package/dist/nb-NO.main.js +0 -14
  115. package/dist/nb-NO.main.js.map +0 -1
  116. package/dist/nb-NO.mjs +0 -16
  117. package/dist/nb-NO.module.js +0 -16
  118. package/dist/nb-NO.module.js.map +0 -1
  119. package/dist/nl-NL.main.js +0 -14
  120. package/dist/nl-NL.main.js.map +0 -1
  121. package/dist/nl-NL.mjs +0 -16
  122. package/dist/nl-NL.module.js +0 -16
  123. package/dist/nl-NL.module.js.map +0 -1
  124. package/dist/pl-PL.main.js +0 -14
  125. package/dist/pl-PL.main.js.map +0 -1
  126. package/dist/pl-PL.mjs +0 -16
  127. package/dist/pl-PL.module.js +0 -16
  128. package/dist/pl-PL.module.js.map +0 -1
  129. package/dist/pt-BR.main.js +0 -14
  130. package/dist/pt-BR.main.js.map +0 -1
  131. package/dist/pt-BR.mjs +0 -16
  132. package/dist/pt-BR.module.js +0 -16
  133. package/dist/pt-BR.module.js.map +0 -1
  134. package/dist/pt-PT.main.js +0 -14
  135. package/dist/pt-PT.main.js.map +0 -1
  136. package/dist/pt-PT.mjs +0 -16
  137. package/dist/pt-PT.module.js +0 -16
  138. package/dist/pt-PT.module.js.map +0 -1
  139. package/dist/ro-RO.main.js +0 -14
  140. package/dist/ro-RO.main.js.map +0 -1
  141. package/dist/ro-RO.mjs +0 -16
  142. package/dist/ro-RO.module.js +0 -16
  143. package/dist/ro-RO.module.js.map +0 -1
  144. package/dist/ru-RU.main.js +0 -14
  145. package/dist/ru-RU.main.js.map +0 -1
  146. package/dist/ru-RU.mjs +0 -16
  147. package/dist/ru-RU.module.js +0 -16
  148. package/dist/ru-RU.module.js.map +0 -1
  149. package/dist/sk-SK.main.js +0 -14
  150. package/dist/sk-SK.main.js.map +0 -1
  151. package/dist/sk-SK.mjs +0 -16
  152. package/dist/sk-SK.module.js +0 -16
  153. package/dist/sk-SK.module.js.map +0 -1
  154. package/dist/sl-SI.main.js +0 -14
  155. package/dist/sl-SI.main.js.map +0 -1
  156. package/dist/sl-SI.mjs +0 -16
  157. package/dist/sl-SI.module.js +0 -16
  158. package/dist/sl-SI.module.js.map +0 -1
  159. package/dist/sr-SP.main.js +0 -14
  160. package/dist/sr-SP.main.js.map +0 -1
  161. package/dist/sr-SP.mjs +0 -16
  162. package/dist/sr-SP.module.js +0 -16
  163. package/dist/sr-SP.module.js.map +0 -1
  164. package/dist/sv-SE.main.js +0 -14
  165. package/dist/sv-SE.main.js.map +0 -1
  166. package/dist/sv-SE.mjs +0 -16
  167. package/dist/sv-SE.module.js +0 -16
  168. package/dist/sv-SE.module.js.map +0 -1
  169. package/dist/tr-TR.main.js +0 -14
  170. package/dist/tr-TR.main.js.map +0 -1
  171. package/dist/tr-TR.mjs +0 -16
  172. package/dist/tr-TR.module.js +0 -16
  173. package/dist/tr-TR.module.js.map +0 -1
  174. package/dist/types.d.ts +0 -157
  175. package/dist/types.d.ts.map +0 -1
  176. package/dist/uk-UA.main.js +0 -14
  177. package/dist/uk-UA.main.js.map +0 -1
  178. package/dist/uk-UA.mjs +0 -16
  179. package/dist/uk-UA.module.js +0 -16
  180. package/dist/uk-UA.module.js.map +0 -1
  181. package/dist/useTable.main.js +0 -114
  182. package/dist/useTable.main.js.map +0 -1
  183. package/dist/useTable.mjs +0 -109
  184. package/dist/useTable.module.js +0 -109
  185. package/dist/useTable.module.js.map +0 -1
  186. package/dist/useTableCell.main.js +0 -37
  187. package/dist/useTableCell.main.js.map +0 -1
  188. package/dist/useTableCell.mjs +0 -32
  189. package/dist/useTableCell.module.js +0 -32
  190. package/dist/useTableCell.module.js.map +0 -1
  191. package/dist/useTableColumnHeader.main.js +0 -92
  192. package/dist/useTableColumnHeader.main.js.map +0 -1
  193. package/dist/useTableColumnHeader.mjs +0 -87
  194. package/dist/useTableColumnHeader.module.js +0 -87
  195. package/dist/useTableColumnHeader.module.js.map +0 -1
  196. package/dist/useTableColumnResize.main.js +0 -226
  197. package/dist/useTableColumnResize.main.js.map +0 -1
  198. package/dist/useTableColumnResize.mjs +0 -221
  199. package/dist/useTableColumnResize.module.js +0 -221
  200. package/dist/useTableColumnResize.module.js.map +0 -1
  201. package/dist/useTableHeaderRow.main.js +0 -32
  202. package/dist/useTableHeaderRow.main.js.map +0 -1
  203. package/dist/useTableHeaderRow.mjs +0 -27
  204. package/dist/useTableHeaderRow.module.js +0 -27
  205. package/dist/useTableHeaderRow.module.js.map +0 -1
  206. package/dist/useTableRow.main.js +0 -82
  207. package/dist/useTableRow.main.js.map +0 -1
  208. package/dist/useTableRow.mjs +0 -77
  209. package/dist/useTableRow.module.js +0 -77
  210. package/dist/useTableRow.module.js.map +0 -1
  211. package/dist/useTableSelectionCheckbox.main.js +0 -56
  212. package/dist/useTableSelectionCheckbox.main.js.map +0 -1
  213. package/dist/useTableSelectionCheckbox.mjs +0 -50
  214. package/dist/useTableSelectionCheckbox.module.js +0 -50
  215. package/dist/useTableSelectionCheckbox.module.js.map +0 -1
  216. package/dist/utils.main.js +0 -43
  217. package/dist/utils.main.js.map +0 -1
  218. package/dist/utils.mjs +0 -35
  219. package/dist/utils.module.js +0 -35
  220. package/dist/utils.module.js.map +0 -1
  221. package/dist/zh-CN.main.js +0 -14
  222. package/dist/zh-CN.main.js.map +0 -1
  223. package/dist/zh-CN.mjs +0 -16
  224. package/dist/zh-CN.module.js +0 -16
  225. package/dist/zh-CN.module.js.map +0 -1
  226. package/dist/zh-TW.main.js +0 -14
  227. package/dist/zh-TW.main.js.map +0 -1
  228. package/dist/zh-TW.mjs +0 -16
  229. package/dist/zh-TW.module.js +0 -16
  230. package/dist/zh-TW.module.js.map +0 -1
  231. package/src/TableKeyboardDelegate.ts +0 -214
  232. package/src/useTable.ts +0 -123
  233. package/src/useTableCell.ts +0 -59
  234. package/src/useTableColumnHeader.ts +0 -108
  235. package/src/useTableColumnResize.ts +0 -277
  236. package/src/useTableHeaderRow.ts +0 -42
  237. package/src/useTableRow.ts +0 -86
  238. package/src/useTableSelectionCheckbox.ts +0 -72
  239. package/src/utils.ts +0 -49
@@ -1,226 +0,0 @@
1
- var $6acf696f746f932c$exports = require("./utils.main.js");
2
- var $7ff3f66df3873a5e$exports = require("./intlStrings.main.js");
3
- var $gDW2h$react = require("react");
4
- var $gDW2h$reactariainteractions = require("@react-aria/interactions");
5
- var $gDW2h$reactariautils = require("@react-aria/utils");
6
- var $gDW2h$reactariai18n = require("@react-aria/i18n");
7
- var $gDW2h$reactariavisuallyhidden = require("@react-aria/visually-hidden");
8
-
9
-
10
- function $parcel$interopDefault(a) {
11
- return a && a.__esModule ? a.default : a;
12
- }
13
-
14
- function $parcel$export(e, n, v, s) {
15
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
16
- }
17
-
18
- $parcel$export(module.exports, "useTableColumnResize", () => $16d645f9e2153641$export$52994e973806c219);
19
- /*
20
- * Copyright 2020 Adobe. All rights reserved.
21
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
- * you may not use this file except in compliance with the License. You may obtain a copy
23
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
- *
25
- * Unless required by applicable law or agreed to in writing, software distributed under
26
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
- * OF ANY KIND, either express or implied. See the License for the specific language
28
- * governing permissions and limitations under the License.
29
- */
30
-
31
-
32
-
33
-
34
-
35
-
36
- function $16d645f9e2153641$export$52994e973806c219(props, state, ref) {
37
- let { column: item, triggerRef: triggerRef, isDisabled: isDisabled, onResizeStart: onResizeStart, onResize: onResize, onResizeEnd: onResizeEnd, 'aria-label': ariaLabel } = props;
38
- const stringFormatter = (0, $gDW2h$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($7ff3f66df3873a5e$exports))), '@react-aria/table');
39
- let id = (0, $gDW2h$reactariautils.useId)();
40
- let isResizing = state.resizingColumn === item.key;
41
- let isResizingRef = (0, $gDW2h$react.useRef)(isResizing);
42
- let lastSize = (0, $gDW2h$react.useRef)(null);
43
- let wasFocusedOnResizeStart = (0, $gDW2h$react.useRef)(false);
44
- let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;
45
- let { direction: direction } = (0, $gDW2h$reactariai18n.useLocale)();
46
- let startResize = (0, $gDW2h$react.useCallback)((item)=>{
47
- if (!isResizingRef.current) {
48
- lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
49
- state.startResize(item.key);
50
- state.tableState.setKeyboardNavigationDisabled(true);
51
- onResizeStart === null || onResizeStart === void 0 ? void 0 : onResizeStart(lastSize.current);
52
- }
53
- isResizingRef.current = true;
54
- }, [
55
- state,
56
- onResizeStart
57
- ]);
58
- let resize = (0, $gDW2h$react.useCallback)((item, newWidth)=>{
59
- let sizes = state.updateResizedColumns(item.key, newWidth);
60
- onResize === null || onResize === void 0 ? void 0 : onResize(sizes);
61
- lastSize.current = sizes;
62
- }, [
63
- state,
64
- onResize
65
- ]);
66
- let endResize = (0, $gDW2h$react.useCallback)((item)=>{
67
- if (isResizingRef.current) {
68
- if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
69
- state.endResize();
70
- state.tableState.setKeyboardNavigationDisabled(false);
71
- onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd(lastSize.current);
72
- isResizingRef.current = false;
73
- 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.
74
- (0, $gDW2h$reactariainteractions.focusSafely)(triggerRef.current);
75
- }
76
- lastSize.current = null;
77
- }, [
78
- state,
79
- triggerRef,
80
- onResizeEnd
81
- ]);
82
- let { keyboardProps: keyboardProps } = (0, $gDW2h$reactariainteractions.useKeyboard)({
83
- onKeyDown: (e)=>{
84
- if (editModeEnabled) {
85
- if (e.key === 'Escape' || e.key === 'Enter' || e.key === ' ' || e.key === 'Tab') {
86
- e.preventDefault();
87
- endResize(item);
88
- }
89
- } else {
90
- // Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there
91
- e.continuePropagation();
92
- if (e.key === 'Enter') startResize(item);
93
- }
94
- }
95
- });
96
- const columnResizeWidthRef = (0, $gDW2h$react.useRef)(0);
97
- const { moveProps: moveProps } = (0, $gDW2h$reactariainteractions.useMove)({
98
- onMoveStart () {
99
- columnResizeWidthRef.current = state.getColumnWidth(item.key);
100
- startResize(item);
101
- },
102
- onMove (e) {
103
- let { deltaX: deltaX, deltaY: deltaY, pointerType: pointerType } = e;
104
- if (direction === 'rtl') deltaX *= -1;
105
- if (pointerType === 'keyboard') {
106
- if (deltaY !== 0 && deltaX === 0) deltaX = deltaY * -1;
107
- deltaX *= 10;
108
- }
109
- // if moving up/down only, no need to resize
110
- if (deltaX !== 0) {
111
- columnResizeWidthRef.current += deltaX;
112
- resize(item, columnResizeWidthRef.current);
113
- }
114
- },
115
- onMoveEnd (e) {
116
- let { pointerType: pointerType } = e;
117
- columnResizeWidthRef.current = 0;
118
- if (pointerType === 'mouse' || pointerType === 'touch' && wasFocusedOnResizeStart.current) endResize(item);
119
- }
120
- });
121
- let onKeyDown = (0, $gDW2h$react.useCallback)((e)=>{
122
- var _moveProps_onKeyDown;
123
- if (editModeEnabled) (_moveProps_onKeyDown = moveProps.onKeyDown) === null || _moveProps_onKeyDown === void 0 ? void 0 : _moveProps_onKeyDown.call(moveProps, e);
124
- }, [
125
- editModeEnabled,
126
- moveProps
127
- ]);
128
- let min = Math.floor(state.getColumnMinWidth(item.key));
129
- let max = Math.floor(state.getColumnMaxWidth(item.key));
130
- if (max === Infinity) max = Number.MAX_SAFE_INTEGER;
131
- let value = Math.floor(state.getColumnWidth(item.key));
132
- let modality = (0, $gDW2h$reactariainteractions.useInteractionModality)();
133
- if (modality === 'virtual' && typeof window !== 'undefined' && 'ontouchstart' in window) modality = 'touch';
134
- let description = (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) == null && (modality === 'keyboard' || modality === 'virtual') && !isResizing ? stringFormatter.format('resizerDescription') : undefined;
135
- let descriptionProps = (0, $gDW2h$reactariautils.useDescription)(description);
136
- let ariaProps = {
137
- 'aria-label': ariaLabel,
138
- 'aria-orientation': 'horizontal',
139
- 'aria-labelledby': `${id} ${(0, $6acf696f746f932c$exports.getColumnHeaderId)(state.tableState, item.key)}`,
140
- 'aria-valuetext': stringFormatter.format('columnSize', {
141
- value: value
142
- }),
143
- 'type': 'range',
144
- min: min,
145
- max: max,
146
- value: value,
147
- ...descriptionProps
148
- };
149
- const focusInput = (0, $gDW2h$react.useCallback)(()=>{
150
- if (ref.current) (0, $gDW2h$reactariainteractions.focusSafely)(ref.current);
151
- }, [
152
- ref
153
- ]);
154
- let resizingColumn = state.resizingColumn;
155
- let prevResizingColumn = (0, $gDW2h$react.useRef)(null);
156
- let startResizeEvent = (0, $gDW2h$reactariautils.useEffectEvent)(startResize);
157
- (0, $gDW2h$react.useEffect)(()=>{
158
- if (prevResizingColumn.current !== resizingColumn && resizingColumn != null && resizingColumn === item.key) {
159
- wasFocusedOnResizeStart.current = document.activeElement === ref.current;
160
- startResizeEvent(item);
161
- // Delay focusing input until Android Chrome's delayed click after touchend happens: https://bugs.chromium.org/p/chromium/issues/detail?id=1150073
162
- let timeout = setTimeout(()=>focusInput(), 0);
163
- // VoiceOver on iOS has problems focusing the input from a menu.
164
- let VOTimeout = setTimeout(focusInput, 400);
165
- return ()=>{
166
- clearTimeout(timeout);
167
- clearTimeout(VOTimeout);
168
- };
169
- }
170
- prevResizingColumn.current = resizingColumn;
171
- }, [
172
- resizingColumn,
173
- item,
174
- focusInput,
175
- ref
176
- ]);
177
- let onChange = (e)=>{
178
- let currentWidth = state.getColumnWidth(item.key);
179
- let nextValue = parseFloat(e.target.value);
180
- if (nextValue > currentWidth) nextValue = currentWidth + 10;
181
- else nextValue = currentWidth - 10;
182
- resize(item, nextValue);
183
- };
184
- let { pressProps: pressProps } = (0, $gDW2h$reactariainteractions.usePress)({
185
- preventFocusOnPress: true,
186
- onPressStart: (e)=>{
187
- if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === 'keyboard') return;
188
- if (e.pointerType === 'virtual' && state.resizingColumn != null) {
189
- endResize(item);
190
- return;
191
- }
192
- // Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away
193
- // can cancel resize mode for us.
194
- focusInput();
195
- // If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need
196
- // to handle a virtual click to start the resizer.
197
- if (e.pointerType !== 'virtual') startResize(item);
198
- },
199
- onPress: (e)=>{
200
- if ((e.pointerType === 'touch' && wasFocusedOnResizeStart.current || e.pointerType === 'mouse') && state.resizingColumn != null) endResize(item);
201
- }
202
- });
203
- let { visuallyHiddenProps: visuallyHiddenProps } = (0, $gDW2h$reactariavisuallyhidden.useVisuallyHidden)();
204
- return {
205
- resizerProps: (0, $gDW2h$reactariautils.mergeProps)(keyboardProps, {
206
- ...moveProps,
207
- onKeyDown: onKeyDown
208
- }, pressProps, {
209
- style: {
210
- touchAction: 'none'
211
- }
212
- }),
213
- inputProps: (0, $gDW2h$reactariautils.mergeProps)(visuallyHiddenProps, {
214
- id: id,
215
- onBlur: ()=>{
216
- endResize(item);
217
- },
218
- onChange: onChange,
219
- disabled: isDisabled
220
- }, ariaProps),
221
- isResizing: isResizing
222
- };
223
- }
224
-
225
-
226
- //# sourceMappingURL=useTableColumnResize.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmDM,SAAS,0CAAwB,KAAoC,EAAE,KAAgC,EAAE,GAAuC;IACrJ,IAAI,EAAC,QAAQ,IAAI,cAAE,UAAU,cAAE,UAAU,iBAAE,aAAa,YAAE,QAAQ,eAAE,WAAW,EAAE,cAAc,SAAS,EAAC,GAAG;IAC5G,MAAM,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAClE,IAAI,KAAK,CAAA,GAAA,2BAAI;IACb,IAAI,aAAa,MAAM,cAAc,KAAK,KAAK,GAAG;IAClD,IAAI,gBAAgB,CAAA,GAAA,mBAAK,EAAE;IAC3B,IAAI,WAAW,CAAA,GAAA,mBAAK,EAA+B;IACnD,IAAI,0BAA0B,CAAA,GAAA,mBAAK,EAAE;IACrC,IAAI,kBAAkB,MAAM,UAAU,CAAC,4BAA4B;IAEnE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAE1B,IAAI,cAAc,CAAA,GAAA,wBAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,cAAc,OAAO,EAAE;YAC1B,SAAS,OAAO,GAAG,MAAM,oBAAoB,CAAC,KAAK,GAAG,EAAE,MAAM,cAAc,CAAC,K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AY,eAAe;QAE7B,OAAO,MAAM;IACf;IAEA,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,qBAAqB;QACrB,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,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, useCallback, useEffect, useRef} from 'react';\nimport {ColumnSize} from '@react-types/table';\nimport {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {focusSafely, useInteractionModality, useKeyboard, useMove, usePress} from '@react-aria/interactions';\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 {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 | null>,\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 | null>): 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<Map<Key, ColumnSize> | null>(null);\n let wasFocusedOnResizeStart = useRef(false);\n let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;\n\n let {direction} = useLocale();\n\n let startResize = useCallback((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 }, [state, onResizeStart]);\n\n let resize = useCallback((item, newWidth) => {\n let sizes = state.updateResizedColumns(item.key, newWidth);\n onResize?.(sizes);\n lastSize.current = sizes;\n }, [state, onResize]);\n\n let endResize = useCallback((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 }, [state, triggerRef, onResizeEnd]);\n\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 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 | null = 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<Key | null>(null);\n let startResizeEvent = useEffectEvent(startResize);\n useEffect(() => {\n if (prevResizingColumn.current !== resizingColumn && resizingColumn != null && resizingColumn === item.key) {\n wasFocusedOnResizeStart.current = document.activeElement === ref.current;\n startResizeEvent(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]);\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 preventFocusOnPress: true,\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"}
@@ -1,221 +0,0 @@
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, useKeyboard as $d9Rqy$useKeyboard, useMove as $d9Rqy$useMove, useInteractionModality as $d9Rqy$useInteractionModality, usePress as $d9Rqy$usePress} from "@react-aria/interactions";
5
- import {useId as $d9Rqy$useId, useDescription as $d9Rqy$useDescription, useEffectEvent as $d9Rqy$useEffectEvent, mergeProps as $d9Rqy$mergeProps} from "@react-aria/utils";
6
- import {useLocalizedStringFormatter as $d9Rqy$useLocalizedStringFormatter, useLocale as $d9Rqy$useLocale} from "@react-aria/i18n";
7
- import {useVisuallyHidden as $d9Rqy$useVisuallyHidden} from "@react-aria/visually-hidden";
8
-
9
-
10
- function $parcel$interopDefault(a) {
11
- return a && a.__esModule ? a.default : a;
12
- }
13
- /*
14
- * Copyright 2020 Adobe. All rights reserved.
15
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
- * you may not use this file except in compliance with the License. You may obtain a copy
17
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software distributed under
20
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
- * OF ANY KIND, either express or implied. See the License for the specific language
22
- * governing permissions and limitations under the License.
23
- */
24
-
25
-
26
-
27
-
28
-
29
-
30
- function $e91ef4e5004e3774$export$52994e973806c219(props, state, ref) {
31
- let { column: item, triggerRef: triggerRef, isDisabled: isDisabled, onResizeStart: onResizeStart, onResize: onResize, onResizeEnd: onResizeEnd, 'aria-label': ariaLabel } = props;
32
- const stringFormatter = (0, $d9Rqy$useLocalizedStringFormatter)((0, ($parcel$interopDefault($d9Rqy$intlStringsmodulejs))), '@react-aria/table');
33
- let id = (0, $d9Rqy$useId)();
34
- let isResizing = state.resizingColumn === item.key;
35
- let isResizingRef = (0, $d9Rqy$useRef)(isResizing);
36
- let lastSize = (0, $d9Rqy$useRef)(null);
37
- let wasFocusedOnResizeStart = (0, $d9Rqy$useRef)(false);
38
- let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;
39
- let { direction: direction } = (0, $d9Rqy$useLocale)();
40
- let startResize = (0, $d9Rqy$useCallback)((item)=>{
41
- if (!isResizingRef.current) {
42
- lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
43
- state.startResize(item.key);
44
- state.tableState.setKeyboardNavigationDisabled(true);
45
- onResizeStart === null || onResizeStart === void 0 ? void 0 : onResizeStart(lastSize.current);
46
- }
47
- isResizingRef.current = true;
48
- }, [
49
- state,
50
- onResizeStart
51
- ]);
52
- let resize = (0, $d9Rqy$useCallback)((item, newWidth)=>{
53
- let sizes = state.updateResizedColumns(item.key, newWidth);
54
- onResize === null || onResize === void 0 ? void 0 : onResize(sizes);
55
- lastSize.current = sizes;
56
- }, [
57
- state,
58
- onResize
59
- ]);
60
- let endResize = (0, $d9Rqy$useCallback)((item)=>{
61
- if (isResizingRef.current) {
62
- if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
63
- state.endResize();
64
- state.tableState.setKeyboardNavigationDisabled(false);
65
- onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd(lastSize.current);
66
- isResizingRef.current = false;
67
- 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.
68
- (0, $d9Rqy$focusSafely)(triggerRef.current);
69
- }
70
- lastSize.current = null;
71
- }, [
72
- state,
73
- triggerRef,
74
- onResizeEnd
75
- ]);
76
- let { keyboardProps: keyboardProps } = (0, $d9Rqy$useKeyboard)({
77
- onKeyDown: (e)=>{
78
- if (editModeEnabled) {
79
- if (e.key === 'Escape' || e.key === 'Enter' || e.key === ' ' || e.key === 'Tab') {
80
- e.preventDefault();
81
- endResize(item);
82
- }
83
- } else {
84
- // Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there
85
- e.continuePropagation();
86
- if (e.key === 'Enter') startResize(item);
87
- }
88
- }
89
- });
90
- const columnResizeWidthRef = (0, $d9Rqy$useRef)(0);
91
- const { moveProps: moveProps } = (0, $d9Rqy$useMove)({
92
- onMoveStart () {
93
- columnResizeWidthRef.current = state.getColumnWidth(item.key);
94
- startResize(item);
95
- },
96
- onMove (e) {
97
- let { deltaX: deltaX, deltaY: deltaY, pointerType: pointerType } = e;
98
- if (direction === 'rtl') deltaX *= -1;
99
- if (pointerType === 'keyboard') {
100
- if (deltaY !== 0 && deltaX === 0) deltaX = deltaY * -1;
101
- deltaX *= 10;
102
- }
103
- // if moving up/down only, no need to resize
104
- if (deltaX !== 0) {
105
- columnResizeWidthRef.current += deltaX;
106
- resize(item, columnResizeWidthRef.current);
107
- }
108
- },
109
- onMoveEnd (e) {
110
- let { pointerType: pointerType } = e;
111
- columnResizeWidthRef.current = 0;
112
- if (pointerType === 'mouse' || pointerType === 'touch' && wasFocusedOnResizeStart.current) endResize(item);
113
- }
114
- });
115
- let onKeyDown = (0, $d9Rqy$useCallback)((e)=>{
116
- var _moveProps_onKeyDown;
117
- if (editModeEnabled) (_moveProps_onKeyDown = moveProps.onKeyDown) === null || _moveProps_onKeyDown === void 0 ? void 0 : _moveProps_onKeyDown.call(moveProps, e);
118
- }, [
119
- editModeEnabled,
120
- moveProps
121
- ]);
122
- let min = Math.floor(state.getColumnMinWidth(item.key));
123
- let max = Math.floor(state.getColumnMaxWidth(item.key));
124
- if (max === Infinity) max = Number.MAX_SAFE_INTEGER;
125
- let value = Math.floor(state.getColumnWidth(item.key));
126
- let modality = (0, $d9Rqy$useInteractionModality)();
127
- if (modality === 'virtual' && typeof window !== 'undefined' && 'ontouchstart' in window) modality = 'touch';
128
- let description = (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) == null && (modality === 'keyboard' || modality === 'virtual') && !isResizing ? stringFormatter.format('resizerDescription') : undefined;
129
- let descriptionProps = (0, $d9Rqy$useDescription)(description);
130
- let ariaProps = {
131
- 'aria-label': ariaLabel,
132
- 'aria-orientation': 'horizontal',
133
- 'aria-labelledby': `${id} ${(0, $2140fb2337097f2d$export$37cd4213f2ad742e)(state.tableState, item.key)}`,
134
- 'aria-valuetext': stringFormatter.format('columnSize', {
135
- value: value
136
- }),
137
- 'type': 'range',
138
- min: min,
139
- max: max,
140
- value: value,
141
- ...descriptionProps
142
- };
143
- const focusInput = (0, $d9Rqy$useCallback)(()=>{
144
- if (ref.current) (0, $d9Rqy$focusSafely)(ref.current);
145
- }, [
146
- ref
147
- ]);
148
- let resizingColumn = state.resizingColumn;
149
- let prevResizingColumn = (0, $d9Rqy$useRef)(null);
150
- let startResizeEvent = (0, $d9Rqy$useEffectEvent)(startResize);
151
- (0, $d9Rqy$useEffect)(()=>{
152
- if (prevResizingColumn.current !== resizingColumn && resizingColumn != null && resizingColumn === item.key) {
153
- wasFocusedOnResizeStart.current = document.activeElement === ref.current;
154
- startResizeEvent(item);
155
- // Delay focusing input until Android Chrome's delayed click after touchend happens: https://bugs.chromium.org/p/chromium/issues/detail?id=1150073
156
- let timeout = setTimeout(()=>focusInput(), 0);
157
- // VoiceOver on iOS has problems focusing the input from a menu.
158
- let VOTimeout = setTimeout(focusInput, 400);
159
- return ()=>{
160
- clearTimeout(timeout);
161
- clearTimeout(VOTimeout);
162
- };
163
- }
164
- prevResizingColumn.current = resizingColumn;
165
- }, [
166
- resizingColumn,
167
- item,
168
- focusInput,
169
- ref
170
- ]);
171
- let onChange = (e)=>{
172
- let currentWidth = state.getColumnWidth(item.key);
173
- let nextValue = parseFloat(e.target.value);
174
- if (nextValue > currentWidth) nextValue = currentWidth + 10;
175
- else nextValue = currentWidth - 10;
176
- resize(item, nextValue);
177
- };
178
- let { pressProps: pressProps } = (0, $d9Rqy$usePress)({
179
- preventFocusOnPress: true,
180
- onPressStart: (e)=>{
181
- if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === 'keyboard') return;
182
- if (e.pointerType === 'virtual' && state.resizingColumn != null) {
183
- endResize(item);
184
- return;
185
- }
186
- // Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away
187
- // can cancel resize mode for us.
188
- focusInput();
189
- // If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need
190
- // to handle a virtual click to start the resizer.
191
- if (e.pointerType !== 'virtual') startResize(item);
192
- },
193
- onPress: (e)=>{
194
- if ((e.pointerType === 'touch' && wasFocusedOnResizeStart.current || e.pointerType === 'mouse') && state.resizingColumn != null) endResize(item);
195
- }
196
- });
197
- let { visuallyHiddenProps: visuallyHiddenProps } = (0, $d9Rqy$useVisuallyHidden)();
198
- return {
199
- resizerProps: (0, $d9Rqy$mergeProps)(keyboardProps, {
200
- ...moveProps,
201
- onKeyDown: onKeyDown
202
- }, pressProps, {
203
- style: {
204
- touchAction: 'none'
205
- }
206
- }),
207
- inputProps: (0, $d9Rqy$mergeProps)(visuallyHiddenProps, {
208
- id: id,
209
- onBlur: ()=>{
210
- endResize(item);
211
- },
212
- onChange: onChange,
213
- disabled: isDisabled
214
- }, ariaProps),
215
- isResizing: isResizing
216
- };
217
- }
218
-
219
-
220
- export {$e91ef4e5004e3774$export$52994e973806c219 as useTableColumnResize};
221
- //# sourceMappingURL=useTableColumnResize.module.js.map