@react-aria/table 3.0.0-beta.1 → 3.0.0-nightly-4980928d3-240906

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/TableKeyboardDelegate.main.js +132 -0
  2. package/dist/TableKeyboardDelegate.main.js.map +1 -0
  3. package/dist/TableKeyboardDelegate.mjs +127 -0
  4. package/dist/TableKeyboardDelegate.module.js +127 -0
  5. package/dist/TableKeyboardDelegate.module.js.map +1 -0
  6. package/dist/ar-AE.main.js +14 -0
  7. package/dist/ar-AE.main.js.map +1 -0
  8. package/dist/ar-AE.mjs +16 -0
  9. package/dist/ar-AE.module.js +16 -0
  10. package/dist/ar-AE.module.js.map +1 -0
  11. package/dist/bg-BG.main.js +14 -0
  12. package/dist/bg-BG.main.js.map +1 -0
  13. package/dist/bg-BG.mjs +16 -0
  14. package/dist/bg-BG.module.js +16 -0
  15. package/dist/bg-BG.module.js.map +1 -0
  16. package/dist/cs-CZ.main.js +14 -0
  17. package/dist/cs-CZ.main.js.map +1 -0
  18. package/dist/cs-CZ.mjs +16 -0
  19. package/dist/cs-CZ.module.js +16 -0
  20. package/dist/cs-CZ.module.js.map +1 -0
  21. package/dist/da-DK.main.js +14 -0
  22. package/dist/da-DK.main.js.map +1 -0
  23. package/dist/da-DK.mjs +16 -0
  24. package/dist/da-DK.module.js +16 -0
  25. package/dist/da-DK.module.js.map +1 -0
  26. package/dist/de-DE.main.js +14 -0
  27. package/dist/de-DE.main.js.map +1 -0
  28. package/dist/de-DE.mjs +16 -0
  29. package/dist/de-DE.module.js +16 -0
  30. package/dist/de-DE.module.js.map +1 -0
  31. package/dist/el-GR.main.js +14 -0
  32. package/dist/el-GR.main.js.map +1 -0
  33. package/dist/el-GR.mjs +16 -0
  34. package/dist/el-GR.module.js +16 -0
  35. package/dist/el-GR.module.js.map +1 -0
  36. package/dist/en-US.main.js +14 -0
  37. package/dist/en-US.main.js.map +1 -0
  38. package/dist/en-US.mjs +16 -0
  39. package/dist/en-US.module.js +16 -0
  40. package/dist/en-US.module.js.map +1 -0
  41. package/dist/es-ES.main.js +14 -0
  42. package/dist/es-ES.main.js.map +1 -0
  43. package/dist/es-ES.mjs +16 -0
  44. package/dist/es-ES.module.js +16 -0
  45. package/dist/es-ES.module.js.map +1 -0
  46. package/dist/et-EE.main.js +14 -0
  47. package/dist/et-EE.main.js.map +1 -0
  48. package/dist/et-EE.mjs +16 -0
  49. package/dist/et-EE.module.js +16 -0
  50. package/dist/et-EE.module.js.map +1 -0
  51. package/dist/fi-FI.main.js +14 -0
  52. package/dist/fi-FI.main.js.map +1 -0
  53. package/dist/fi-FI.mjs +16 -0
  54. package/dist/fi-FI.module.js +16 -0
  55. package/dist/fi-FI.module.js.map +1 -0
  56. package/dist/fr-FR.main.js +14 -0
  57. package/dist/fr-FR.main.js.map +1 -0
  58. package/dist/fr-FR.mjs +16 -0
  59. package/dist/fr-FR.module.js +16 -0
  60. package/dist/fr-FR.module.js.map +1 -0
  61. package/dist/he-IL.main.js +14 -0
  62. package/dist/he-IL.main.js.map +1 -0
  63. package/dist/he-IL.mjs +16 -0
  64. package/dist/he-IL.module.js +16 -0
  65. package/dist/he-IL.module.js.map +1 -0
  66. package/dist/hr-HR.main.js +14 -0
  67. package/dist/hr-HR.main.js.map +1 -0
  68. package/dist/hr-HR.mjs +16 -0
  69. package/dist/hr-HR.module.js +16 -0
  70. package/dist/hr-HR.module.js.map +1 -0
  71. package/dist/hu-HU.main.js +14 -0
  72. package/dist/hu-HU.main.js.map +1 -0
  73. package/dist/hu-HU.mjs +16 -0
  74. package/dist/hu-HU.module.js +16 -0
  75. package/dist/hu-HU.module.js.map +1 -0
  76. package/dist/import.mjs +34 -0
  77. package/dist/intlStrings.main.js +108 -0
  78. package/dist/intlStrings.main.js.map +1 -0
  79. package/dist/intlStrings.mjs +110 -0
  80. package/dist/intlStrings.module.js +110 -0
  81. package/dist/intlStrings.module.js.map +1 -0
  82. package/dist/it-IT.main.js +14 -0
  83. package/dist/it-IT.main.js.map +1 -0
  84. package/dist/it-IT.mjs +16 -0
  85. package/dist/it-IT.module.js +16 -0
  86. package/dist/it-IT.module.js.map +1 -0
  87. package/dist/ja-JP.main.js +14 -0
  88. package/dist/ja-JP.main.js.map +1 -0
  89. package/dist/ja-JP.mjs +16 -0
  90. package/dist/ja-JP.module.js +16 -0
  91. package/dist/ja-JP.module.js.map +1 -0
  92. package/dist/ko-KR.main.js +14 -0
  93. package/dist/ko-KR.main.js.map +1 -0
  94. package/dist/ko-KR.mjs +16 -0
  95. package/dist/ko-KR.module.js +16 -0
  96. package/dist/ko-KR.module.js.map +1 -0
  97. package/dist/lt-LT.main.js +14 -0
  98. package/dist/lt-LT.main.js.map +1 -0
  99. package/dist/lt-LT.mjs +16 -0
  100. package/dist/lt-LT.module.js +16 -0
  101. package/dist/lt-LT.module.js.map +1 -0
  102. package/dist/lv-LV.main.js +14 -0
  103. package/dist/lv-LV.main.js.map +1 -0
  104. package/dist/lv-LV.mjs +16 -0
  105. package/dist/lv-LV.module.js +16 -0
  106. package/dist/lv-LV.module.js.map +1 -0
  107. package/dist/main.js +26 -499
  108. package/dist/main.js.map +1 -1
  109. package/dist/module.js +12 -454
  110. package/dist/module.js.map +1 -1
  111. package/dist/nb-NO.main.js +14 -0
  112. package/dist/nb-NO.main.js.map +1 -0
  113. package/dist/nb-NO.mjs +16 -0
  114. package/dist/nb-NO.module.js +16 -0
  115. package/dist/nb-NO.module.js.map +1 -0
  116. package/dist/nl-NL.main.js +14 -0
  117. package/dist/nl-NL.main.js.map +1 -0
  118. package/dist/nl-NL.mjs +16 -0
  119. package/dist/nl-NL.module.js +16 -0
  120. package/dist/nl-NL.module.js.map +1 -0
  121. package/dist/pl-PL.main.js +14 -0
  122. package/dist/pl-PL.main.js.map +1 -0
  123. package/dist/pl-PL.mjs +16 -0
  124. package/dist/pl-PL.module.js +16 -0
  125. package/dist/pl-PL.module.js.map +1 -0
  126. package/dist/pt-BR.main.js +14 -0
  127. package/dist/pt-BR.main.js.map +1 -0
  128. package/dist/pt-BR.mjs +16 -0
  129. package/dist/pt-BR.module.js +16 -0
  130. package/dist/pt-BR.module.js.map +1 -0
  131. package/dist/pt-PT.main.js +14 -0
  132. package/dist/pt-PT.main.js.map +1 -0
  133. package/dist/pt-PT.mjs +16 -0
  134. package/dist/pt-PT.module.js +16 -0
  135. package/dist/pt-PT.module.js.map +1 -0
  136. package/dist/ro-RO.main.js +14 -0
  137. package/dist/ro-RO.main.js.map +1 -0
  138. package/dist/ro-RO.mjs +16 -0
  139. package/dist/ro-RO.module.js +16 -0
  140. package/dist/ro-RO.module.js.map +1 -0
  141. package/dist/ru-RU.main.js +14 -0
  142. package/dist/ru-RU.main.js.map +1 -0
  143. package/dist/ru-RU.mjs +16 -0
  144. package/dist/ru-RU.module.js +16 -0
  145. package/dist/ru-RU.module.js.map +1 -0
  146. package/dist/sk-SK.main.js +14 -0
  147. package/dist/sk-SK.main.js.map +1 -0
  148. package/dist/sk-SK.mjs +16 -0
  149. package/dist/sk-SK.module.js +16 -0
  150. package/dist/sk-SK.module.js.map +1 -0
  151. package/dist/sl-SI.main.js +14 -0
  152. package/dist/sl-SI.main.js.map +1 -0
  153. package/dist/sl-SI.mjs +16 -0
  154. package/dist/sl-SI.module.js +16 -0
  155. package/dist/sl-SI.module.js.map +1 -0
  156. package/dist/sr-SP.main.js +14 -0
  157. package/dist/sr-SP.main.js.map +1 -0
  158. package/dist/sr-SP.mjs +16 -0
  159. package/dist/sr-SP.module.js +16 -0
  160. package/dist/sr-SP.module.js.map +1 -0
  161. package/dist/sv-SE.main.js +14 -0
  162. package/dist/sv-SE.main.js.map +1 -0
  163. package/dist/sv-SE.mjs +16 -0
  164. package/dist/sv-SE.module.js +16 -0
  165. package/dist/sv-SE.module.js.map +1 -0
  166. package/dist/tr-TR.main.js +14 -0
  167. package/dist/tr-TR.main.js.map +1 -0
  168. package/dist/tr-TR.mjs +16 -0
  169. package/dist/tr-TR.module.js +16 -0
  170. package/dist/tr-TR.module.js.map +1 -0
  171. package/dist/types.d.ts +87 -25
  172. package/dist/types.d.ts.map +1 -1
  173. package/dist/uk-UA.main.js +14 -0
  174. package/dist/uk-UA.main.js.map +1 -0
  175. package/dist/uk-UA.mjs +16 -0
  176. package/dist/uk-UA.module.js +16 -0
  177. package/dist/uk-UA.module.js.map +1 -0
  178. package/dist/useTable.main.js +113 -0
  179. package/dist/useTable.main.js.map +1 -0
  180. package/dist/useTable.mjs +108 -0
  181. package/dist/useTable.module.js +108 -0
  182. package/dist/useTable.module.js.map +1 -0
  183. package/dist/useTableCell.main.js +36 -0
  184. package/dist/useTableCell.main.js.map +1 -0
  185. package/dist/useTableCell.mjs +31 -0
  186. package/dist/useTableCell.module.js +31 -0
  187. package/dist/useTableCell.module.js.map +1 -0
  188. package/dist/useTableColumnHeader.main.js +93 -0
  189. package/dist/useTableColumnHeader.main.js.map +1 -0
  190. package/dist/useTableColumnHeader.mjs +88 -0
  191. package/dist/useTableColumnHeader.module.js +88 -0
  192. package/dist/useTableColumnHeader.module.js.map +1 -0
  193. package/dist/useTableColumnResize.main.js +216 -0
  194. package/dist/useTableColumnResize.main.js.map +1 -0
  195. package/dist/useTableColumnResize.mjs +211 -0
  196. package/dist/useTableColumnResize.module.js +211 -0
  197. package/dist/useTableColumnResize.module.js.map +1 -0
  198. package/dist/useTableHeaderRow.main.js +32 -0
  199. package/dist/useTableHeaderRow.main.js.map +1 -0
  200. package/dist/useTableHeaderRow.mjs +27 -0
  201. package/dist/useTableHeaderRow.module.js +27 -0
  202. package/dist/useTableHeaderRow.module.js.map +1 -0
  203. package/dist/useTableRow.main.js +81 -0
  204. package/dist/useTableRow.main.js.map +1 -0
  205. package/dist/useTableRow.mjs +76 -0
  206. package/dist/useTableRow.module.js +76 -0
  207. package/dist/useTableRow.module.js.map +1 -0
  208. package/dist/useTableSelectionCheckbox.main.js +56 -0
  209. package/dist/useTableSelectionCheckbox.main.js.map +1 -0
  210. package/dist/useTableSelectionCheckbox.mjs +50 -0
  211. package/dist/useTableSelectionCheckbox.module.js +50 -0
  212. package/dist/useTableSelectionCheckbox.module.js.map +1 -0
  213. package/dist/utils.main.js +43 -0
  214. package/dist/utils.main.js.map +1 -0
  215. package/dist/utils.mjs +35 -0
  216. package/dist/utils.module.js +35 -0
  217. package/dist/utils.module.js.map +1 -0
  218. package/dist/zh-CN.main.js +14 -0
  219. package/dist/zh-CN.main.js.map +1 -0
  220. package/dist/zh-CN.mjs +16 -0
  221. package/dist/zh-CN.module.js +16 -0
  222. package/dist/zh-CN.module.js.map +1 -0
  223. package/dist/zh-TW.main.js +14 -0
  224. package/dist/zh-TW.main.js.map +1 -0
  225. package/dist/zh-TW.mjs +16 -0
  226. package/dist/zh-TW.module.js +16 -0
  227. package/dist/zh-TW.module.js.map +1 -0
  228. package/package.json +25 -17
  229. package/src/TableKeyboardDelegate.ts +18 -10
  230. package/src/index.ts +21 -7
  231. package/src/useTable.ts +62 -42
  232. package/src/useTableCell.ts +19 -9
  233. package/src/useTableColumnHeader.ts +53 -17
  234. package/src/useTableColumnResize.ts +275 -0
  235. package/src/useTableHeaderRow.ts +10 -4
  236. package/src/useTableRow.ts +60 -7
  237. package/src/useTableSelectionCheckbox.ts +17 -22
  238. package/src/utils.ts +1 -1
  239. package/LICENSE +0 -201
@@ -0,0 +1,88 @@
1
+ import {getColumnHeaderId as $2140fb2337097f2d$export$37cd4213f2ad742e} from "./utils.mjs";
2
+ import $cjB6b$intlStringsmodulejs from "./intlStrings.mjs";
3
+ import {isAndroid as $cjB6b$isAndroid, useDescription as $cjB6b$useDescription, mergeProps as $cjB6b$mergeProps} from "@react-aria/utils";
4
+ import {useEffect as $cjB6b$useEffect} from "react";
5
+ import {useFocusable as $cjB6b$useFocusable} from "@react-aria/focus";
6
+ import {useGridCell as $cjB6b$useGridCell} from "@react-aria/grid";
7
+ import {useLocalizedStringFormatter as $cjB6b$useLocalizedStringFormatter} from "@react-aria/i18n";
8
+ import {usePress as $cjB6b$usePress} from "@react-aria/interactions";
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 $f329116d8ad0aba0$export$9514819a8c81e960(props, state, ref) {
33
+ var _state_sortDescriptor, _state_sortDescriptor1;
34
+ let { node: node } = props;
35
+ let allowsSorting = node.props.allowsSorting;
36
+ // if there are no focusable children, the column header will focus the cell
37
+ let { gridCellProps: gridCellProps } = (0, $cjB6b$useGridCell)({
38
+ ...props,
39
+ focusMode: 'child'
40
+ }, state, ref);
41
+ let isSelectionCellDisabled = node.props.isSelectionCell && state.selectionManager.selectionMode === 'single';
42
+ let { pressProps: pressProps } = (0, $cjB6b$usePress)({
43
+ isDisabled: !allowsSorting || isSelectionCellDisabled,
44
+ onPress () {
45
+ state.sort(node.key);
46
+ },
47
+ ref: ref
48
+ });
49
+ // Needed to pick up the focusable context, enabling things like Tooltips for example
50
+ let { focusableProps: focusableProps } = (0, $cjB6b$useFocusable)({}, ref);
51
+ let ariaSort = null;
52
+ let isSortedColumn = ((_state_sortDescriptor = state.sortDescriptor) === null || _state_sortDescriptor === void 0 ? void 0 : _state_sortDescriptor.column) === node.key;
53
+ let sortDirection = (_state_sortDescriptor1 = state.sortDescriptor) === null || _state_sortDescriptor1 === void 0 ? void 0 : _state_sortDescriptor1.direction;
54
+ // aria-sort not supported in Android Talkback
55
+ if (node.props.allowsSorting && !(0, $cjB6b$isAndroid)()) ariaSort = isSortedColumn ? sortDirection : 'none';
56
+ let stringFormatter = (0, $cjB6b$useLocalizedStringFormatter)((0, ($parcel$interopDefault($cjB6b$intlStringsmodulejs))), '@react-aria/table');
57
+ let sortDescription;
58
+ if (allowsSorting) {
59
+ sortDescription = `${stringFormatter.format('sortable')}`;
60
+ // Android Talkback doesn't support aria-sort so we add sort order details to the aria-described by here
61
+ if (isSortedColumn && sortDirection && (0, $cjB6b$isAndroid)()) sortDescription = `${sortDescription}, ${stringFormatter.format(sortDirection)}`;
62
+ }
63
+ let descriptionProps = (0, $cjB6b$useDescription)(sortDescription);
64
+ let shouldDisableFocus = state.collection.size === 0;
65
+ (0, $cjB6b$useEffect)(()=>{
66
+ if (shouldDisableFocus && state.selectionManager.focusedKey === node.key) state.selectionManager.setFocusedKey(null);
67
+ }, [
68
+ shouldDisableFocus,
69
+ state.selectionManager,
70
+ node.key
71
+ ]);
72
+ return {
73
+ columnHeaderProps: {
74
+ ...(0, $cjB6b$mergeProps)(gridCellProps, pressProps, focusableProps, descriptionProps, // If the table is empty, make all column headers untabbable
75
+ shouldDisableFocus && {
76
+ tabIndex: -1
77
+ }),
78
+ role: 'columnheader',
79
+ id: (0, $2140fb2337097f2d$export$37cd4213f2ad742e)(state, node.key),
80
+ 'aria-colspan': node.colspan && node.colspan > 1 ? node.colspan : null,
81
+ 'aria-sort': ariaSort
82
+ }
83
+ };
84
+ }
85
+
86
+
87
+ export {$f329116d8ad0aba0$export$9514819a8c81e960 as useTableColumnHeader};
88
+ //# sourceMappingURL=useTableColumnHeader.module.js.map
@@ -0,0 +1,88 @@
1
+ import {getColumnHeaderId as $2140fb2337097f2d$export$37cd4213f2ad742e} from "./utils.module.js";
2
+ import $cjB6b$intlStringsmodulejs from "./intlStrings.module.js";
3
+ import {isAndroid as $cjB6b$isAndroid, useDescription as $cjB6b$useDescription, mergeProps as $cjB6b$mergeProps} from "@react-aria/utils";
4
+ import {useEffect as $cjB6b$useEffect} from "react";
5
+ import {useFocusable as $cjB6b$useFocusable} from "@react-aria/focus";
6
+ import {useGridCell as $cjB6b$useGridCell} from "@react-aria/grid";
7
+ import {useLocalizedStringFormatter as $cjB6b$useLocalizedStringFormatter} from "@react-aria/i18n";
8
+ import {usePress as $cjB6b$usePress} from "@react-aria/interactions";
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 $f329116d8ad0aba0$export$9514819a8c81e960(props, state, ref) {
33
+ var _state_sortDescriptor, _state_sortDescriptor1;
34
+ let { node: node } = props;
35
+ let allowsSorting = node.props.allowsSorting;
36
+ // if there are no focusable children, the column header will focus the cell
37
+ let { gridCellProps: gridCellProps } = (0, $cjB6b$useGridCell)({
38
+ ...props,
39
+ focusMode: 'child'
40
+ }, state, ref);
41
+ let isSelectionCellDisabled = node.props.isSelectionCell && state.selectionManager.selectionMode === 'single';
42
+ let { pressProps: pressProps } = (0, $cjB6b$usePress)({
43
+ isDisabled: !allowsSorting || isSelectionCellDisabled,
44
+ onPress () {
45
+ state.sort(node.key);
46
+ },
47
+ ref: ref
48
+ });
49
+ // Needed to pick up the focusable context, enabling things like Tooltips for example
50
+ let { focusableProps: focusableProps } = (0, $cjB6b$useFocusable)({}, ref);
51
+ let ariaSort = null;
52
+ let isSortedColumn = ((_state_sortDescriptor = state.sortDescriptor) === null || _state_sortDescriptor === void 0 ? void 0 : _state_sortDescriptor.column) === node.key;
53
+ let sortDirection = (_state_sortDescriptor1 = state.sortDescriptor) === null || _state_sortDescriptor1 === void 0 ? void 0 : _state_sortDescriptor1.direction;
54
+ // aria-sort not supported in Android Talkback
55
+ if (node.props.allowsSorting && !(0, $cjB6b$isAndroid)()) ariaSort = isSortedColumn ? sortDirection : 'none';
56
+ let stringFormatter = (0, $cjB6b$useLocalizedStringFormatter)((0, ($parcel$interopDefault($cjB6b$intlStringsmodulejs))), '@react-aria/table');
57
+ let sortDescription;
58
+ if (allowsSorting) {
59
+ sortDescription = `${stringFormatter.format('sortable')}`;
60
+ // Android Talkback doesn't support aria-sort so we add sort order details to the aria-described by here
61
+ if (isSortedColumn && sortDirection && (0, $cjB6b$isAndroid)()) sortDescription = `${sortDescription}, ${stringFormatter.format(sortDirection)}`;
62
+ }
63
+ let descriptionProps = (0, $cjB6b$useDescription)(sortDescription);
64
+ let shouldDisableFocus = state.collection.size === 0;
65
+ (0, $cjB6b$useEffect)(()=>{
66
+ if (shouldDisableFocus && state.selectionManager.focusedKey === node.key) state.selectionManager.setFocusedKey(null);
67
+ }, [
68
+ shouldDisableFocus,
69
+ state.selectionManager,
70
+ node.key
71
+ ]);
72
+ return {
73
+ columnHeaderProps: {
74
+ ...(0, $cjB6b$mergeProps)(gridCellProps, pressProps, focusableProps, descriptionProps, // If the table is empty, make all column headers untabbable
75
+ shouldDisableFocus && {
76
+ tabIndex: -1
77
+ }),
78
+ role: 'columnheader',
79
+ id: (0, $2140fb2337097f2d$export$37cd4213f2ad742e)(state, node.key),
80
+ 'aria-colspan': node.colspan && node.colspan > 1 ? node.colspan : null,
81
+ 'aria-sort': ariaSort
82
+ }
83
+ };
84
+ }
85
+
86
+
87
+ export {$f329116d8ad0aba0$export$9514819a8c81e960 as useTableColumnHeader};
88
+ //# sourceMappingURL=useTableColumnHeader.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAiCM,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AAa,EAAE;IAEtC,IAAI,qBAAqB,MAAM,UAAU,CAAC,IAAI,KAAK;IACnD,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,sBAAsB,MAAM,gBAAgB,CAAC,UAAU,KAAK,KAAK,GAAG,EACtE,MAAM,gBAAgB,CAAC,aAAa,CAAC;IAEzC,GAAG;QAAC;QAAoB,MAAM,gBAAgB;QAAE,KAAK,GAAG;KAAC;IAEzD,OAAO;QACL,mBAAmB;YACjB,GAAG,CAAA,GAAA,iBAAS,EACV,eACA,YACA,gBACA,kBACA,4DAA4D;YAC5D,sBAAsB;gBAAC,UAAU;YAAE,EACpC;YACD,MAAM;YACN,IAAI,CAAA,GAAA,yCAAgB,EAAE,OAAO,KAAK,GAAG;YACrC,gBAAgB,KAAK,OAAO,IAAI,KAAK,OAAO,GAAG,IAAI,KAAK,OAAO,GAAG;YAClE,aAAa;QACf;IACF;AACF","sources":["packages/@react-aria/table/src/useTableColumnHeader.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, FocusableElement, RefObject} from '@react-types/shared';\nimport {getColumnHeaderId} from './utils';\nimport {GridNode} from '@react-types/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {isAndroid, mergeProps, useDescription} from '@react-aria/utils';\nimport {TableState} from '@react-stately/table';\nimport {useEffect} from 'react';\nimport {useFocusable} from '@react-aria/focus';\nimport {useGridCell} from '@react-aria/grid';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface AriaTableColumnHeaderProps<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 node: GridNode<T>,\n /** Whether the [column header](https://www.w3.org/TR/wai-aria-1.1/#columnheader) is contained in a virtual scroller. */\n isVirtualized?: boolean\n}\n\nexport interface TableColumnHeaderAria {\n /** Props for the [column header](https://www.w3.org/TR/wai-aria-1.1/#columnheader) element. */\n columnHeaderProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a column header in a table.\n * @param props - Props for the column header.\n * @param state - State of the table, as returned by `useTableState`.\n * @param ref - The ref attached to the column header element.\n */\nexport function useTableColumnHeader<T>(props: AriaTableColumnHeaderProps<T>, state: TableState<T>, ref: RefObject<FocusableElement | null>): TableColumnHeaderAria {\n let {node} = props;\n let allowsSorting = node.props.allowsSorting;\n // if there are no focusable children, the column header will focus the cell\n let {gridCellProps} = useGridCell({...props, focusMode: 'child'}, state, ref);\n\n let isSelectionCellDisabled = node.props.isSelectionCell && state.selectionManager.selectionMode === 'single';\n\n let {pressProps} = usePress({\n isDisabled: !allowsSorting || isSelectionCellDisabled,\n onPress() {\n state.sort(node.key);\n },\n ref\n });\n\n // Needed to pick up the focusable context, enabling things like Tooltips for example\n let {focusableProps} = useFocusable({}, ref);\n\n let ariaSort: DOMAttributes['aria-sort'] = null;\n let isSortedColumn = state.sortDescriptor?.column === node.key;\n let sortDirection = state.sortDescriptor?.direction;\n // aria-sort not supported in Android Talkback\n if (node.props.allowsSorting && !isAndroid()) {\n ariaSort = isSortedColumn ? sortDirection : 'none';\n }\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/table');\n let sortDescription;\n if (allowsSorting) {\n sortDescription = `${stringFormatter.format('sortable')}`;\n // Android Talkback doesn't support aria-sort so we add sort order details to the aria-described by here\n if (isSortedColumn && sortDirection && isAndroid()) {\n sortDescription = `${sortDescription}, ${stringFormatter.format(sortDirection)}`;\n }\n }\n\n let descriptionProps = useDescription(sortDescription);\n\n let shouldDisableFocus = state.collection.size === 0;\n useEffect(() => {\n if (shouldDisableFocus && state.selectionManager.focusedKey === node.key) {\n state.selectionManager.setFocusedKey(null);\n }\n }, [shouldDisableFocus, state.selectionManager, node.key]);\n\n return {\n columnHeaderProps: {\n ...mergeProps(\n gridCellProps,\n pressProps,\n focusableProps,\n descriptionProps,\n // If the table is empty, make all column headers untabbable\n shouldDisableFocus && {tabIndex: -1}\n ),\n role: 'columnheader',\n id: getColumnHeaderId(state, node.key),\n 'aria-colspan': node.colspan && node.colspan > 1 ? node.colspan : null,\n 'aria-sort': ariaSort\n }\n };\n}\n"],"names":[],"version":3,"file":"useTableColumnHeader.module.js.map"}
@@ -0,0 +1,216 @@
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$reactariafocus = require("@react-aria/focus");
5
+ var $gDW2h$reactariautils = require("@react-aria/utils");
6
+ var $gDW2h$reactariainteractions = require("@react-aria/interactions");
7
+ var $gDW2h$reactariai18n = require("@react-aria/i18n");
8
+ var $gDW2h$reactariavisuallyhidden = require("@react-aria/visually-hidden");
9
+
10
+
11
+ function $parcel$interopDefault(a) {
12
+ return a && a.__esModule ? a.default : a;
13
+ }
14
+
15
+ function $parcel$export(e, n, v, s) {
16
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
17
+ }
18
+
19
+ $parcel$export(module.exports, "useTableColumnResize", () => $16d645f9e2153641$export$52994e973806c219);
20
+ /*
21
+ * Copyright 2020 Adobe. All rights reserved.
22
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
23
+ * you may not use this file except in compliance with the License. You may obtain a copy
24
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software distributed under
27
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
28
+ * OF ANY KIND, either express or implied. See the License for the specific language
29
+ * governing permissions and limitations under the License.
30
+ */
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+ function $16d645f9e2153641$export$52994e973806c219(props, state, ref) {
39
+ let { column: item, triggerRef: triggerRef, isDisabled: isDisabled, onResizeStart: onResizeStart, onResize: onResize, onResizeEnd: onResizeEnd, 'aria-label': ariaLabel } = props;
40
+ const stringFormatter = (0, $gDW2h$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($7ff3f66df3873a5e$exports))), '@react-aria/table');
41
+ let id = (0, $gDW2h$reactariautils.useId)();
42
+ let isResizing = state.resizingColumn === item.key;
43
+ let isResizingRef = (0, $gDW2h$react.useRef)(isResizing);
44
+ let lastSize = (0, $gDW2h$react.useRef)(null);
45
+ let wasFocusedOnResizeStart = (0, $gDW2h$react.useRef)(false);
46
+ let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;
47
+ let { direction: direction } = (0, $gDW2h$reactariai18n.useLocale)();
48
+ let { keyboardProps: keyboardProps } = (0, $gDW2h$reactariainteractions.useKeyboard)({
49
+ onKeyDown: (e)=>{
50
+ if (editModeEnabled) {
51
+ if (e.key === 'Escape' || e.key === 'Enter' || e.key === ' ' || e.key === 'Tab') {
52
+ e.preventDefault();
53
+ endResize(item);
54
+ }
55
+ } else {
56
+ // Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there
57
+ e.continuePropagation();
58
+ if (e.key === 'Enter') startResize(item);
59
+ }
60
+ }
61
+ });
62
+ let startResize = (0, $gDW2h$reactariautils.useEffectEvent)((item)=>{
63
+ if (!isResizingRef.current) {
64
+ lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
65
+ state.startResize(item.key);
66
+ state.tableState.setKeyboardNavigationDisabled(true);
67
+ onResizeStart === null || onResizeStart === void 0 ? void 0 : onResizeStart(lastSize.current);
68
+ }
69
+ isResizingRef.current = true;
70
+ });
71
+ let resize = (0, $gDW2h$reactariautils.useEffectEvent)((item, newWidth)=>{
72
+ let sizes = state.updateResizedColumns(item.key, newWidth);
73
+ onResize === null || onResize === void 0 ? void 0 : onResize(sizes);
74
+ lastSize.current = sizes;
75
+ });
76
+ let endResize = (0, $gDW2h$reactariautils.useEffectEvent)((item)=>{
77
+ if (isResizingRef.current) {
78
+ if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
79
+ state.endResize();
80
+ state.tableState.setKeyboardNavigationDisabled(false);
81
+ onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd(lastSize.current);
82
+ isResizingRef.current = false;
83
+ 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.
84
+ (0, $gDW2h$reactariafocus.focusSafely)(triggerRef.current);
85
+ }
86
+ lastSize.current = null;
87
+ });
88
+ const columnResizeWidthRef = (0, $gDW2h$react.useRef)(0);
89
+ const { moveProps: moveProps } = (0, $gDW2h$reactariainteractions.useMove)({
90
+ onMoveStart () {
91
+ columnResizeWidthRef.current = state.getColumnWidth(item.key);
92
+ startResize(item);
93
+ },
94
+ onMove (e) {
95
+ let { deltaX: deltaX, deltaY: deltaY, pointerType: pointerType } = e;
96
+ if (direction === 'rtl') deltaX *= -1;
97
+ if (pointerType === 'keyboard') {
98
+ if (deltaY !== 0 && deltaX === 0) deltaX = deltaY * -1;
99
+ deltaX *= 10;
100
+ }
101
+ // if moving up/down only, no need to resize
102
+ if (deltaX !== 0) {
103
+ columnResizeWidthRef.current += deltaX;
104
+ resize(item, columnResizeWidthRef.current);
105
+ }
106
+ },
107
+ onMoveEnd (e) {
108
+ let { pointerType: pointerType } = e;
109
+ columnResizeWidthRef.current = 0;
110
+ if (pointerType === 'mouse' || pointerType === 'touch' && wasFocusedOnResizeStart.current) endResize(item);
111
+ }
112
+ });
113
+ let onKeyDown = (0, $gDW2h$react.useCallback)((e)=>{
114
+ if (editModeEnabled) moveProps.onKeyDown(e);
115
+ }, [
116
+ editModeEnabled,
117
+ moveProps
118
+ ]);
119
+ let min = Math.floor(state.getColumnMinWidth(item.key));
120
+ let max = Math.floor(state.getColumnMaxWidth(item.key));
121
+ if (max === Infinity) max = Number.MAX_SAFE_INTEGER;
122
+ let value = Math.floor(state.getColumnWidth(item.key));
123
+ let modality = (0, $gDW2h$reactariainteractions.useInteractionModality)();
124
+ if (modality === 'virtual' && typeof window !== 'undefined' && 'ontouchstart' in window) modality = 'touch';
125
+ let description = (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) == null && (modality === 'keyboard' || modality === 'virtual') && !isResizing ? stringFormatter.format('resizerDescription') : undefined;
126
+ let descriptionProps = (0, $gDW2h$reactariautils.useDescription)(description);
127
+ let ariaProps = {
128
+ 'aria-label': ariaLabel,
129
+ 'aria-orientation': 'horizontal',
130
+ 'aria-labelledby': `${id} ${(0, $6acf696f746f932c$exports.getColumnHeaderId)(state.tableState, item.key)}`,
131
+ 'aria-valuetext': stringFormatter.format('columnSize', {
132
+ value: value
133
+ }),
134
+ 'type': 'range',
135
+ min: min,
136
+ max: max,
137
+ value: value,
138
+ ...descriptionProps
139
+ };
140
+ const focusInput = (0, $gDW2h$react.useCallback)(()=>{
141
+ if (ref.current) (0, $gDW2h$reactariafocus.focusSafely)(ref.current);
142
+ }, [
143
+ ref
144
+ ]);
145
+ let resizingColumn = state.resizingColumn;
146
+ let prevResizingColumn = (0, $gDW2h$react.useRef)(null);
147
+ (0, $gDW2h$react.useEffect)(()=>{
148
+ if (prevResizingColumn.current !== resizingColumn && resizingColumn != null && resizingColumn === item.key) {
149
+ wasFocusedOnResizeStart.current = document.activeElement === ref.current;
150
+ startResize(item);
151
+ // Delay focusing input until Android Chrome's delayed click after touchend happens: https://bugs.chromium.org/p/chromium/issues/detail?id=1150073
152
+ let timeout = setTimeout(()=>focusInput(), 0);
153
+ // VoiceOver on iOS has problems focusing the input from a menu.
154
+ let VOTimeout = setTimeout(focusInput, 400);
155
+ return ()=>{
156
+ clearTimeout(timeout);
157
+ clearTimeout(VOTimeout);
158
+ };
159
+ }
160
+ prevResizingColumn.current = resizingColumn;
161
+ }, [
162
+ resizingColumn,
163
+ item,
164
+ focusInput,
165
+ ref,
166
+ startResize
167
+ ]);
168
+ let onChange = (e)=>{
169
+ let currentWidth = state.getColumnWidth(item.key);
170
+ let nextValue = parseFloat(e.target.value);
171
+ if (nextValue > currentWidth) nextValue = currentWidth + 10;
172
+ else nextValue = currentWidth - 10;
173
+ resize(item, nextValue);
174
+ };
175
+ let { pressProps: pressProps } = (0, $gDW2h$reactariainteractions.usePress)({
176
+ onPressStart: (e)=>{
177
+ if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === 'keyboard') return;
178
+ if (e.pointerType === 'virtual' && state.resizingColumn != null) {
179
+ endResize(item);
180
+ return;
181
+ }
182
+ // Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away
183
+ // can cancel resize mode for us.
184
+ focusInput();
185
+ // If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need
186
+ // to handle a virtual click to start the resizer.
187
+ if (e.pointerType !== 'virtual') startResize(item);
188
+ },
189
+ onPress: (e)=>{
190
+ if ((e.pointerType === 'touch' && wasFocusedOnResizeStart.current || e.pointerType === 'mouse') && state.resizingColumn != null) endResize(item);
191
+ }
192
+ });
193
+ let { visuallyHiddenProps: visuallyHiddenProps } = (0, $gDW2h$reactariavisuallyhidden.useVisuallyHidden)();
194
+ return {
195
+ resizerProps: (0, $gDW2h$reactariautils.mergeProps)(keyboardProps, {
196
+ ...moveProps,
197
+ onKeyDown: onKeyDown
198
+ }, pressProps, {
199
+ style: {
200
+ touchAction: 'none'
201
+ }
202
+ }),
203
+ inputProps: (0, $gDW2h$reactariautils.mergeProps)(visuallyHiddenProps, {
204
+ id: id,
205
+ onBlur: ()=>{
206
+ endResize(item);
207
+ },
208
+ onChange: onChange,
209
+ disabled: isDisabled
210
+ }, ariaProps),
211
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AAW,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} 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 | 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(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.module.js.map