@react-aria/table 3.13.6-nightly.4555 → 3.13.6-nightly.4558

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 (90) 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.mjs +1 -1
  7. package/dist/bg-BG.mjs +1 -1
  8. package/dist/cs-CZ.mjs +1 -1
  9. package/dist/da-DK.mjs +1 -1
  10. package/dist/de-DE.mjs +1 -1
  11. package/dist/el-GR.mjs +1 -1
  12. package/dist/en-US.mjs +1 -1
  13. package/dist/es-ES.mjs +1 -1
  14. package/dist/et-EE.mjs +1 -1
  15. package/dist/fi-FI.mjs +1 -1
  16. package/dist/fr-FR.mjs +1 -1
  17. package/dist/he-IL.mjs +1 -1
  18. package/dist/hr-HR.mjs +1 -1
  19. package/dist/hu-HU.mjs +1 -1
  20. package/dist/import.mjs +8 -779
  21. package/dist/intlStrings.main.js +108 -0
  22. package/dist/intlStrings.main.js.map +1 -0
  23. package/dist/intlStrings.mjs +110 -0
  24. package/dist/intlStrings.module.js +110 -0
  25. package/dist/intlStrings.module.js.map +1 -0
  26. package/dist/it-IT.mjs +1 -1
  27. package/dist/ja-JP.mjs +1 -1
  28. package/dist/ko-KR.mjs +1 -1
  29. package/dist/lt-LT.mjs +1 -1
  30. package/dist/lv-LV.mjs +1 -1
  31. package/dist/main.js +15 -786
  32. package/dist/main.js.map +1 -1
  33. package/dist/module.js +8 -779
  34. package/dist/module.js.map +1 -1
  35. package/dist/nb-NO.mjs +1 -1
  36. package/dist/nl-NL.mjs +1 -1
  37. package/dist/pl-PL.mjs +1 -1
  38. package/dist/pt-BR.mjs +1 -1
  39. package/dist/pt-PT.mjs +1 -1
  40. package/dist/ro-RO.mjs +1 -1
  41. package/dist/ru-RU.mjs +1 -1
  42. package/dist/sk-SK.mjs +1 -1
  43. package/dist/sl-SI.mjs +1 -1
  44. package/dist/sr-SP.mjs +1 -1
  45. package/dist/sv-SE.mjs +1 -1
  46. package/dist/tr-TR.mjs +1 -1
  47. package/dist/uk-UA.mjs +1 -1
  48. package/dist/useTable.main.js +111 -0
  49. package/dist/useTable.main.js.map +1 -0
  50. package/dist/useTable.mjs +106 -0
  51. package/dist/useTable.module.js +106 -0
  52. package/dist/useTable.module.js.map +1 -0
  53. package/dist/useTableCell.main.js +36 -0
  54. package/dist/useTableCell.main.js.map +1 -0
  55. package/dist/useTableCell.mjs +31 -0
  56. package/dist/useTableCell.module.js +31 -0
  57. package/dist/useTableCell.module.js.map +1 -0
  58. package/dist/useTableColumnHeader.main.js +93 -0
  59. package/dist/useTableColumnHeader.main.js.map +1 -0
  60. package/dist/useTableColumnHeader.mjs +88 -0
  61. package/dist/useTableColumnHeader.module.js +88 -0
  62. package/dist/useTableColumnHeader.module.js.map +1 -0
  63. package/dist/useTableColumnResize.main.js +216 -0
  64. package/dist/useTableColumnResize.main.js.map +1 -0
  65. package/dist/useTableColumnResize.mjs +211 -0
  66. package/dist/useTableColumnResize.module.js +211 -0
  67. package/dist/useTableColumnResize.module.js.map +1 -0
  68. package/dist/useTableHeaderRow.main.js +32 -0
  69. package/dist/useTableHeaderRow.main.js.map +1 -0
  70. package/dist/useTableHeaderRow.mjs +27 -0
  71. package/dist/useTableHeaderRow.module.js +27 -0
  72. package/dist/useTableHeaderRow.module.js.map +1 -0
  73. package/dist/useTableRow.main.js +80 -0
  74. package/dist/useTableRow.main.js.map +1 -0
  75. package/dist/useTableRow.mjs +75 -0
  76. package/dist/useTableRow.module.js +75 -0
  77. package/dist/useTableRow.module.js.map +1 -0
  78. package/dist/useTableSelectionCheckbox.main.js +56 -0
  79. package/dist/useTableSelectionCheckbox.main.js.map +1 -0
  80. package/dist/useTableSelectionCheckbox.mjs +50 -0
  81. package/dist/useTableSelectionCheckbox.module.js +50 -0
  82. package/dist/useTableSelectionCheckbox.module.js.map +1 -0
  83. package/dist/utils.main.js +43 -0
  84. package/dist/utils.main.js.map +1 -0
  85. package/dist/utils.mjs +35 -0
  86. package/dist/utils.module.js +35 -0
  87. package/dist/utils.module.js.map +1 -0
  88. package/dist/zh-CN.mjs +1 -1
  89. package/dist/zh-TW.mjs +1 -1
  90. package/package.json +17 -17
@@ -0,0 +1,36 @@
1
+ var $6acf696f746f932c$exports = require("./utils.main.js");
2
+ var $8iEv8$reactariagrid = require("@react-aria/grid");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "useTableCell", () => $32387a1f2c61cda2$export$49571c903d73624c);
10
+ /*
11
+ * Copyright 2020 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */
21
+
22
+ function $32387a1f2c61cda2$export$49571c903d73624c(props, state, ref) {
23
+ let { gridCellProps: gridCellProps, isPressed: isPressed } = (0, $8iEv8$reactariagrid.useGridCell)(props, state, ref);
24
+ let columnKey = props.node.column.key;
25
+ if (state.collection.rowHeaderColumnKeys.has(columnKey)) {
26
+ gridCellProps.role = "rowheader";
27
+ gridCellProps.id = (0, $6acf696f746f932c$exports.getCellId)(state, props.node.parentKey, columnKey);
28
+ }
29
+ return {
30
+ gridCellProps: gridCellProps,
31
+ isPressed: isPressed
32
+ };
33
+ }
34
+
35
+
36
+ //# sourceMappingURL=useTableCell.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAqCM,SAAS,0CAAgB,KAAyB,EAAE,KAAoB,EAAE,GAAgC;IAC/G,IAAI,iBAAC,aAAa,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gCAAU,EAAE,OAAO,OAAO;IAE3D,IAAI,YAAY,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG;IACrC,IAAI,MAAM,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,YAAY;QACvD,cAAc,IAAI,GAAG;QACrB,cAAc,EAAE,GAAG,CAAA,GAAA,mCAAQ,EAAE,OAAO,MAAM,IAAI,CAAC,SAAS,EAAE;IAC5D;IAEA,OAAO;uBACL;mBACA;IACF;AACF","sources":["packages/@react-aria/table/src/useTableCell.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} from '@react-types/shared';\nimport {getCellId} from './utils';\nimport {GridNode} from '@react-types/grid';\nimport {RefObject} from 'react';\nimport {TableState} from '@react-stately/table';\nimport {useGridCell} from '@react-aria/grid';\n\nexport interface AriaTableCellProps {\n /** An object representing the table cell. Contains all the relevant information that makes up the row header. */\n node: GridNode<unknown>,\n /** Whether the cell is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the cell.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface TableCellAria {\n /** Props for the table cell element. */\n gridCellProps: DOMAttributes,\n /** Whether the cell is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a cell in a table.\n * @param props - Props for the cell.\n * @param state - State of the table, as returned by `useTableState`.\n * @param ref - The ref attached to the cell element.\n */\nexport function useTableCell<T>(props: AriaTableCellProps, state: TableState<T>, ref: RefObject<FocusableElement>): TableCellAria {\n let {gridCellProps, isPressed} = useGridCell(props, state, ref);\n\n let columnKey = props.node.column.key;\n if (state.collection.rowHeaderColumnKeys.has(columnKey)) {\n gridCellProps.role = 'rowheader';\n gridCellProps.id = getCellId(state, props.node.parentKey, columnKey);\n }\n\n return {\n gridCellProps,\n isPressed\n };\n}\n"],"names":[],"version":3,"file":"useTableCell.main.js.map"}
@@ -0,0 +1,31 @@
1
+ import {getCellId as $2140fb2337097f2d$export$19baff3266315d44} from "./utils.mjs";
2
+ import {useGridCell as $1jd6q$useGridCell} from "@react-aria/grid";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $7713593715703b24$export$49571c903d73624c(props, state, ref) {
17
+ let { gridCellProps: gridCellProps, isPressed: isPressed } = (0, $1jd6q$useGridCell)(props, state, ref);
18
+ let columnKey = props.node.column.key;
19
+ if (state.collection.rowHeaderColumnKeys.has(columnKey)) {
20
+ gridCellProps.role = "rowheader";
21
+ gridCellProps.id = (0, $2140fb2337097f2d$export$19baff3266315d44)(state, props.node.parentKey, columnKey);
22
+ }
23
+ return {
24
+ gridCellProps: gridCellProps,
25
+ isPressed: isPressed
26
+ };
27
+ }
28
+
29
+
30
+ export {$7713593715703b24$export$49571c903d73624c as useTableCell};
31
+ //# sourceMappingURL=useTableCell.mjs.map
@@ -0,0 +1,31 @@
1
+ import {getCellId as $2140fb2337097f2d$export$19baff3266315d44} from "./utils.module.js";
2
+ import {useGridCell as $1jd6q$useGridCell} from "@react-aria/grid";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $7713593715703b24$export$49571c903d73624c(props, state, ref) {
17
+ let { gridCellProps: gridCellProps, isPressed: isPressed } = (0, $1jd6q$useGridCell)(props, state, ref);
18
+ let columnKey = props.node.column.key;
19
+ if (state.collection.rowHeaderColumnKeys.has(columnKey)) {
20
+ gridCellProps.role = "rowheader";
21
+ gridCellProps.id = (0, $2140fb2337097f2d$export$19baff3266315d44)(state, props.node.parentKey, columnKey);
22
+ }
23
+ return {
24
+ gridCellProps: gridCellProps,
25
+ isPressed: isPressed
26
+ };
27
+ }
28
+
29
+
30
+ export {$7713593715703b24$export$49571c903d73624c as useTableCell};
31
+ //# sourceMappingURL=useTableCell.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAqCM,SAAS,0CAAgB,KAAyB,EAAE,KAAoB,EAAE,GAAgC;IAC/G,IAAI,iBAAC,aAAa,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,kBAAU,EAAE,OAAO,OAAO;IAE3D,IAAI,YAAY,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG;IACrC,IAAI,MAAM,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,YAAY;QACvD,cAAc,IAAI,GAAG;QACrB,cAAc,EAAE,GAAG,CAAA,GAAA,yCAAQ,EAAE,OAAO,MAAM,IAAI,CAAC,SAAS,EAAE;IAC5D;IAEA,OAAO;uBACL;mBACA;IACF;AACF","sources":["packages/@react-aria/table/src/useTableCell.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} from '@react-types/shared';\nimport {getCellId} from './utils';\nimport {GridNode} from '@react-types/grid';\nimport {RefObject} from 'react';\nimport {TableState} from '@react-stately/table';\nimport {useGridCell} from '@react-aria/grid';\n\nexport interface AriaTableCellProps {\n /** An object representing the table cell. Contains all the relevant information that makes up the row header. */\n node: GridNode<unknown>,\n /** Whether the cell is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the cell.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface TableCellAria {\n /** Props for the table cell element. */\n gridCellProps: DOMAttributes,\n /** Whether the cell is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a cell in a table.\n * @param props - Props for the cell.\n * @param state - State of the table, as returned by `useTableState`.\n * @param ref - The ref attached to the cell element.\n */\nexport function useTableCell<T>(props: AriaTableCellProps, state: TableState<T>, ref: RefObject<FocusableElement>): TableCellAria {\n let {gridCellProps, isPressed} = useGridCell(props, state, ref);\n\n let columnKey = props.node.column.key;\n if (state.collection.rowHeaderColumnKeys.has(columnKey)) {\n gridCellProps.role = 'rowheader';\n gridCellProps.id = getCellId(state, props.node.parentKey, columnKey);\n }\n\n return {\n gridCellProps,\n isPressed\n };\n}\n"],"names":[],"version":3,"file":"useTableCell.module.js.map"}
@@ -0,0 +1,93 @@
1
+ var $6acf696f746f932c$exports = require("./utils.main.js");
2
+ var $7ff3f66df3873a5e$exports = require("./intlStrings.main.js");
3
+ var $33PgG$reactariautils = require("@react-aria/utils");
4
+ var $33PgG$react = require("react");
5
+ var $33PgG$reactariafocus = require("@react-aria/focus");
6
+ var $33PgG$reactariagrid = require("@react-aria/grid");
7
+ var $33PgG$reactariai18n = require("@react-aria/i18n");
8
+ var $33PgG$reactariainteractions = require("@react-aria/interactions");
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, "useTableColumnHeader", () => $7669c34a63ef0113$export$9514819a8c81e960);
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 $7669c34a63ef0113$export$9514819a8c81e960(props, state, ref) {
39
+ var _state_sortDescriptor, _state_sortDescriptor1;
40
+ let { node: node } = props;
41
+ let allowsSorting = node.props.allowsSorting;
42
+ // if there are no focusable children, the column header will focus the cell
43
+ let { gridCellProps: gridCellProps } = (0, $33PgG$reactariagrid.useGridCell)({
44
+ ...props,
45
+ focusMode: "child"
46
+ }, state, ref);
47
+ let isSelectionCellDisabled = node.props.isSelectionCell && state.selectionManager.selectionMode === "single";
48
+ let { pressProps: pressProps } = (0, $33PgG$reactariainteractions.usePress)({
49
+ isDisabled: !allowsSorting || isSelectionCellDisabled,
50
+ onPress () {
51
+ state.sort(node.key);
52
+ },
53
+ ref: ref
54
+ });
55
+ // Needed to pick up the focusable context, enabling things like Tooltips for example
56
+ let { focusableProps: focusableProps } = (0, $33PgG$reactariafocus.useFocusable)({}, ref);
57
+ let ariaSort = null;
58
+ let isSortedColumn = ((_state_sortDescriptor = state.sortDescriptor) === null || _state_sortDescriptor === void 0 ? void 0 : _state_sortDescriptor.column) === node.key;
59
+ let sortDirection = (_state_sortDescriptor1 = state.sortDescriptor) === null || _state_sortDescriptor1 === void 0 ? void 0 : _state_sortDescriptor1.direction;
60
+ // aria-sort not supported in Android Talkback
61
+ if (node.props.allowsSorting && !(0, $33PgG$reactariautils.isAndroid)()) ariaSort = isSortedColumn ? sortDirection : "none";
62
+ let stringFormatter = (0, $33PgG$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($7ff3f66df3873a5e$exports))), "@react-aria/table");
63
+ let sortDescription;
64
+ if (allowsSorting) {
65
+ sortDescription = `${stringFormatter.format("sortable")}`;
66
+ // Android Talkback doesn't support aria-sort so we add sort order details to the aria-described by here
67
+ if (isSortedColumn && sortDirection && (0, $33PgG$reactariautils.isAndroid)()) sortDescription = `${sortDescription}, ${stringFormatter.format(sortDirection)}`;
68
+ }
69
+ let descriptionProps = (0, $33PgG$reactariautils.useDescription)(sortDescription);
70
+ let shouldDisableFocus = state.collection.size === 0;
71
+ (0, $33PgG$react.useEffect)(()=>{
72
+ if (shouldDisableFocus && state.selectionManager.focusedKey === node.key) state.selectionManager.setFocusedKey(null);
73
+ }, [
74
+ shouldDisableFocus,
75
+ state.selectionManager,
76
+ node.key
77
+ ]);
78
+ return {
79
+ columnHeaderProps: {
80
+ ...(0, $33PgG$reactariautils.mergeProps)(gridCellProps, pressProps, focusableProps, descriptionProps, // If the table is empty, make all column headers untabbable
81
+ shouldDisableFocus && {
82
+ tabIndex: -1
83
+ }),
84
+ role: "columnheader",
85
+ id: (0, $6acf696f746f932c$exports.getColumnHeaderId)(state, node.key),
86
+ "aria-colspan": node.colspan && node.colspan > 1 ? node.colspan : null,
87
+ "aria-sort": ariaSort
88
+ }
89
+ };
90
+ }
91
+
92
+
93
+ //# sourceMappingURL=useTableColumnHeader.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAiCM,SAAS,0CAAwB,KAAoC,EAAE,KAAoB,EAAE,GAAgC;QAoB7G,uBACD;IApBpB,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,gBAAgB,KAAK,KAAK,CAAC,aAAa;IAC5C,4EAA4E;IAC5E,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,gCAAU,EAAE;QAAC,GAAG,KAAK;QAAE,WAAW;IAAO,GAAG,OAAO;IAEzE,IAAI,0BAA0B,KAAK,KAAK,CAAC,eAAe,IAAI,MAAM,gBAAgB,CAAC,aAAa,KAAK;IAErG,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,YAAY,CAAC,iBAAiB;QAC9B;YACE,MAAM,IAAI,CAAC,KAAK,GAAG;QACrB;aACA;IACF;IAEA,qFAAqF;IACrF,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW,EAAE,CAAC,GAAG;IAExC,IAAI,WAAuC;IAC3C,IAAI,iBAAiB,EAAA,wBAAA,MAAM,cAAc,cAApB,4CAAA,sBAAsB,MAAM,MAAK,KAAK,GAAG;IAC9D,IAAI,iBAAgB,yBAAA,MAAM,cAAc,cAApB,6CAAA,uBAAsB,SAAS;IACnD,8CAA8C;IAC9C,IAAI,KAAK,KAAK,CAAC,aAAa,IAAI,CAAC,CAAA,GAAA,+BAAQ,KACvC,WAAW,iBAAiB,gBAAgB;IAG9C,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI;IACJ,IAAI,eAAe;QACjB,kBAAkB,CAAC,EAAE,gBAAgB,MAAM,CAAC,YAAY,CAAC;QACzD,wGAAwG;QACxG,IAAI,kBAAkB,iBAAiB,CAAA,GAAA,+BAAQ,KAC7C,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,EAAE,gBAAgB,MAAM,CAAC,eAAe,CAAC;IAEpF;IAEA,IAAI,mBAAmB,CAAA,GAAA,oCAAa,EAAE;IAEtC,IAAI,qBAAqB,MAAM,UAAU,CAAC,IAAI,KAAK;IACnD,CAAA,GAAA,sBAAQ,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,gCAAS,EACV,eACA,YACA,gBACA,kBACA,4DAA4D;YAC5D,sBAAsB;gBAAC,UAAU;YAAE,EACpC;YACD,MAAM;YACN,IAAI,CAAA,GAAA,2CAAgB,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} 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 {RefObject, useEffect} from 'react';\nimport {TableState} from '@react-stately/table';\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>): 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.main.js.map"}
@@ -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.mjs.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,SAAS,0CAAwB,KAAoC,EAAE,KAAoB,EAAE,GAAgC;QAoB7G,uBACD;IApBpB,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,gBAAgB,KAAK,KAAK,CAAC,aAAa;IAC5C,4EAA4E;IAC5E,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,kBAAU,EAAE;QAAC,GAAG,KAAK;QAAE,WAAW;IAAO,GAAG,OAAO;IAEzE,IAAI,0BAA0B,KAAK,KAAK,CAAC,eAAe,IAAI,MAAM,gBAAgB,CAAC,aAAa,KAAK;IAErG,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,YAAY,CAAC,iBAAiB;QAC9B;YACE,MAAM,IAAI,CAAC,KAAK,GAAG;QACrB;aACA;IACF;IAEA,qFAAqF;IACrF,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE,CAAC,GAAG;IAExC,IAAI,WAAuC;IAC3C,IAAI,iBAAiB,EAAA,wBAAA,MAAM,cAAc,cAApB,4CAAA,sBAAsB,MAAM,MAAK,KAAK,GAAG;IAC9D,IAAI,iBAAgB,yBAAA,MAAM,cAAc,cAApB,6CAAA,uBAAsB,SAAS;IACnD,8CAA8C;IAC9C,IAAI,KAAK,KAAK,CAAC,aAAa,IAAI,CAAC,CAAA,GAAA,gBAAQ,KACvC,WAAW,iBAAiB,gBAAgB;IAG9C,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI;IACJ,IAAI,eAAe;QACjB,kBAAkB,CAAC,EAAE,gBAAgB,MAAM,CAAC,YAAY,CAAC;QACzD,wGAAwG;QACxG,IAAI,kBAAkB,iBAAiB,CAAA,GAAA,gBAAQ,KAC7C,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,EAAE,gBAAgB,MAAM,CAAC,eAAe,CAAC;IAEpF;IAEA,IAAI,mBAAmB,CAAA,GAAA,qBAAa,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} 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 {RefObject, useEffect} from 'react';\nimport {TableState} from '@react-stately/table';\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>): 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
+ isResizing: isResizing
212
+ };
213
+ }
214
+
215
+
216
+ //# sourceMappingURL=useTableColumnResize.main.js.map