@react-spectrum/table 3.17.11 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/dist/import.mjs +2 -6
  2. package/dist/main.js +8 -12
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +2 -6
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +3 -0
  7. package/package.json +14 -52
  8. package/src/index.ts +3 -18
  9. package/dist/DragPreview.main.js +0 -54
  10. package/dist/DragPreview.main.js.map +0 -1
  11. package/dist/DragPreview.mjs +0 -49
  12. package/dist/DragPreview.module.js +0 -49
  13. package/dist/DragPreview.module.js.map +0 -1
  14. package/dist/InsertionIndicator.main.js +0 -64
  15. package/dist/InsertionIndicator.main.js.map +0 -1
  16. package/dist/InsertionIndicator.mjs +0 -59
  17. package/dist/InsertionIndicator.module.js +0 -59
  18. package/dist/InsertionIndicator.module.js.map +0 -1
  19. package/dist/Nubbin.main.js +0 -62
  20. package/dist/Nubbin.main.js.map +0 -1
  21. package/dist/Nubbin.mjs +0 -53
  22. package/dist/Nubbin.module.js +0 -53
  23. package/dist/Nubbin.module.js.map +0 -1
  24. package/dist/Resizer.main.js +0 -150
  25. package/dist/Resizer.main.js.map +0 -1
  26. package/dist/Resizer.mjs +0 -144
  27. package/dist/Resizer.module.js +0 -144
  28. package/dist/Resizer.module.js.map +0 -1
  29. package/dist/RootDropIndicator.main.js +0 -57
  30. package/dist/RootDropIndicator.main.js.map +0 -1
  31. package/dist/RootDropIndicator.mjs +0 -48
  32. package/dist/RootDropIndicator.module.js +0 -48
  33. package/dist/RootDropIndicator.module.js.map +0 -1
  34. package/dist/TableView.main.js +0 -49
  35. package/dist/TableView.main.js.map +0 -1
  36. package/dist/TableView.mjs +0 -40
  37. package/dist/TableView.module.js +0 -40
  38. package/dist/TableView.module.js.map +0 -1
  39. package/dist/TableViewBase.main.js +0 -1240
  40. package/dist/TableViewBase.main.js.map +0 -1
  41. package/dist/TableViewBase.mjs +0 -1233
  42. package/dist/TableViewBase.module.js +0 -1233
  43. package/dist/TableViewBase.module.js.map +0 -1
  44. package/dist/TableViewLayout.main.js +0 -101
  45. package/dist/TableViewLayout.main.js.map +0 -1
  46. package/dist/TableViewLayout.mjs +0 -96
  47. package/dist/TableViewLayout.module.js +0 -96
  48. package/dist/TableViewLayout.module.js.map +0 -1
  49. package/dist/TableViewWrapper.main.js +0 -45
  50. package/dist/TableViewWrapper.main.js.map +0 -1
  51. package/dist/TableViewWrapper.mjs +0 -36
  52. package/dist/TableViewWrapper.module.js +0 -36
  53. package/dist/TableViewWrapper.module.js.map +0 -1
  54. package/dist/TreeGridTableView.main.js +0 -49
  55. package/dist/TreeGridTableView.main.js.map +0 -1
  56. package/dist/TreeGridTableView.mjs +0 -40
  57. package/dist/TreeGridTableView.module.js +0 -40
  58. package/dist/TreeGridTableView.module.js.map +0 -1
  59. package/dist/ar-AE.main.js +0 -14
  60. package/dist/ar-AE.main.js.map +0 -1
  61. package/dist/ar-AE.mjs +0 -16
  62. package/dist/ar-AE.module.js +0 -16
  63. package/dist/ar-AE.module.js.map +0 -1
  64. package/dist/bg-BG.main.js +0 -14
  65. package/dist/bg-BG.main.js.map +0 -1
  66. package/dist/bg-BG.mjs +0 -16
  67. package/dist/bg-BG.module.js +0 -16
  68. package/dist/bg-BG.module.js.map +0 -1
  69. package/dist/cs-CZ.main.js +0 -14
  70. package/dist/cs-CZ.main.js.map +0 -1
  71. package/dist/cs-CZ.mjs +0 -16
  72. package/dist/cs-CZ.module.js +0 -16
  73. package/dist/cs-CZ.module.js.map +0 -1
  74. package/dist/da-DK.main.js +0 -14
  75. package/dist/da-DK.main.js.map +0 -1
  76. package/dist/da-DK.mjs +0 -16
  77. package/dist/da-DK.module.js +0 -16
  78. package/dist/da-DK.module.js.map +0 -1
  79. package/dist/de-DE.main.js +0 -14
  80. package/dist/de-DE.main.js.map +0 -1
  81. package/dist/de-DE.mjs +0 -16
  82. package/dist/de-DE.module.js +0 -16
  83. package/dist/de-DE.module.js.map +0 -1
  84. package/dist/el-GR.main.js +0 -14
  85. package/dist/el-GR.main.js.map +0 -1
  86. package/dist/el-GR.mjs +0 -16
  87. package/dist/el-GR.module.js +0 -16
  88. package/dist/el-GR.module.js.map +0 -1
  89. package/dist/en-US.main.js +0 -14
  90. package/dist/en-US.main.js.map +0 -1
  91. package/dist/en-US.mjs +0 -16
  92. package/dist/en-US.module.js +0 -16
  93. package/dist/en-US.module.js.map +0 -1
  94. package/dist/es-ES.main.js +0 -14
  95. package/dist/es-ES.main.js.map +0 -1
  96. package/dist/es-ES.mjs +0 -16
  97. package/dist/es-ES.module.js +0 -16
  98. package/dist/es-ES.module.js.map +0 -1
  99. package/dist/et-EE.main.js +0 -14
  100. package/dist/et-EE.main.js.map +0 -1
  101. package/dist/et-EE.mjs +0 -16
  102. package/dist/et-EE.module.js +0 -16
  103. package/dist/et-EE.module.js.map +0 -1
  104. package/dist/fi-FI.main.js +0 -14
  105. package/dist/fi-FI.main.js.map +0 -1
  106. package/dist/fi-FI.mjs +0 -16
  107. package/dist/fi-FI.module.js +0 -16
  108. package/dist/fi-FI.module.js.map +0 -1
  109. package/dist/fr-FR.main.js +0 -14
  110. package/dist/fr-FR.main.js.map +0 -1
  111. package/dist/fr-FR.mjs +0 -16
  112. package/dist/fr-FR.module.js +0 -16
  113. package/dist/fr-FR.module.js.map +0 -1
  114. package/dist/he-IL.main.js +0 -14
  115. package/dist/he-IL.main.js.map +0 -1
  116. package/dist/he-IL.mjs +0 -16
  117. package/dist/he-IL.module.js +0 -16
  118. package/dist/he-IL.module.js.map +0 -1
  119. package/dist/hr-HR.main.js +0 -14
  120. package/dist/hr-HR.main.js.map +0 -1
  121. package/dist/hr-HR.mjs +0 -16
  122. package/dist/hr-HR.module.js +0 -16
  123. package/dist/hr-HR.module.js.map +0 -1
  124. package/dist/hu-HU.main.js +0 -14
  125. package/dist/hu-HU.main.js.map +0 -1
  126. package/dist/hu-HU.mjs +0 -16
  127. package/dist/hu-HU.module.js +0 -16
  128. package/dist/hu-HU.module.js.map +0 -1
  129. package/dist/intlStrings.main.js +0 -108
  130. package/dist/intlStrings.main.js.map +0 -1
  131. package/dist/intlStrings.mjs +0 -110
  132. package/dist/intlStrings.module.js +0 -110
  133. package/dist/intlStrings.module.js.map +0 -1
  134. package/dist/it-IT.main.js +0 -14
  135. package/dist/it-IT.main.js.map +0 -1
  136. package/dist/it-IT.mjs +0 -16
  137. package/dist/it-IT.module.js +0 -16
  138. package/dist/it-IT.module.js.map +0 -1
  139. package/dist/ja-JP.main.js +0 -14
  140. package/dist/ja-JP.main.js.map +0 -1
  141. package/dist/ja-JP.mjs +0 -16
  142. package/dist/ja-JP.module.js +0 -16
  143. package/dist/ja-JP.module.js.map +0 -1
  144. package/dist/ko-KR.main.js +0 -14
  145. package/dist/ko-KR.main.js.map +0 -1
  146. package/dist/ko-KR.mjs +0 -16
  147. package/dist/ko-KR.module.js +0 -16
  148. package/dist/ko-KR.module.js.map +0 -1
  149. package/dist/lt-LT.main.js +0 -14
  150. package/dist/lt-LT.main.js.map +0 -1
  151. package/dist/lt-LT.mjs +0 -16
  152. package/dist/lt-LT.module.js +0 -16
  153. package/dist/lt-LT.module.js.map +0 -1
  154. package/dist/lv-LV.main.js +0 -14
  155. package/dist/lv-LV.main.js.map +0 -1
  156. package/dist/lv-LV.mjs +0 -16
  157. package/dist/lv-LV.module.js +0 -16
  158. package/dist/lv-LV.module.js.map +0 -1
  159. package/dist/nb-NO.main.js +0 -14
  160. package/dist/nb-NO.main.js.map +0 -1
  161. package/dist/nb-NO.mjs +0 -16
  162. package/dist/nb-NO.module.js +0 -16
  163. package/dist/nb-NO.module.js.map +0 -1
  164. package/dist/nl-NL.main.js +0 -14
  165. package/dist/nl-NL.main.js.map +0 -1
  166. package/dist/nl-NL.mjs +0 -16
  167. package/dist/nl-NL.module.js +0 -16
  168. package/dist/nl-NL.module.js.map +0 -1
  169. package/dist/pl-PL.main.js +0 -14
  170. package/dist/pl-PL.main.js.map +0 -1
  171. package/dist/pl-PL.mjs +0 -16
  172. package/dist/pl-PL.module.js +0 -16
  173. package/dist/pl-PL.module.js.map +0 -1
  174. package/dist/pt-BR.main.js +0 -14
  175. package/dist/pt-BR.main.js.map +0 -1
  176. package/dist/pt-BR.mjs +0 -16
  177. package/dist/pt-BR.module.js +0 -16
  178. package/dist/pt-BR.module.js.map +0 -1
  179. package/dist/pt-PT.main.js +0 -14
  180. package/dist/pt-PT.main.js.map +0 -1
  181. package/dist/pt-PT.mjs +0 -16
  182. package/dist/pt-PT.module.js +0 -16
  183. package/dist/pt-PT.module.js.map +0 -1
  184. package/dist/ro-RO.main.js +0 -14
  185. package/dist/ro-RO.main.js.map +0 -1
  186. package/dist/ro-RO.mjs +0 -16
  187. package/dist/ro-RO.module.js +0 -16
  188. package/dist/ro-RO.module.js.map +0 -1
  189. package/dist/ru-RU.main.js +0 -14
  190. package/dist/ru-RU.main.js.map +0 -1
  191. package/dist/ru-RU.mjs +0 -16
  192. package/dist/ru-RU.module.js +0 -16
  193. package/dist/ru-RU.module.js.map +0 -1
  194. package/dist/sk-SK.main.js +0 -14
  195. package/dist/sk-SK.main.js.map +0 -1
  196. package/dist/sk-SK.mjs +0 -16
  197. package/dist/sk-SK.module.js +0 -16
  198. package/dist/sk-SK.module.js.map +0 -1
  199. package/dist/sl-SI.main.js +0 -14
  200. package/dist/sl-SI.main.js.map +0 -1
  201. package/dist/sl-SI.mjs +0 -16
  202. package/dist/sl-SI.module.js +0 -16
  203. package/dist/sl-SI.module.js.map +0 -1
  204. package/dist/sr-SP.main.js +0 -14
  205. package/dist/sr-SP.main.js.map +0 -1
  206. package/dist/sr-SP.mjs +0 -16
  207. package/dist/sr-SP.module.js +0 -16
  208. package/dist/sr-SP.module.js.map +0 -1
  209. package/dist/sv-SE.main.js +0 -14
  210. package/dist/sv-SE.main.js.map +0 -1
  211. package/dist/sv-SE.mjs +0 -16
  212. package/dist/sv-SE.module.js +0 -16
  213. package/dist/sv-SE.module.js.map +0 -1
  214. package/dist/table.0cdc494a.css +0 -992
  215. package/dist/table.0cdc494a.css.map +0 -1
  216. package/dist/table.11fc8462.css +0 -220
  217. package/dist/table.11fc8462.css.map +0 -1
  218. package/dist/table_css.main.js +0 -74
  219. package/dist/table_css.main.js.map +0 -1
  220. package/dist/table_css.mjs +0 -76
  221. package/dist/table_css.module.js +0 -76
  222. package/dist/table_css.module.js.map +0 -1
  223. package/dist/table_vars_css.main.js +0 -197
  224. package/dist/table_vars_css.main.js.map +0 -1
  225. package/dist/table_vars_css.mjs +0 -199
  226. package/dist/table_vars_css.module.js +0 -199
  227. package/dist/table_vars_css.module.js.map +0 -1
  228. package/dist/tr-TR.main.js +0 -14
  229. package/dist/tr-TR.main.js.map +0 -1
  230. package/dist/tr-TR.mjs +0 -16
  231. package/dist/tr-TR.module.js +0 -16
  232. package/dist/tr-TR.module.js.map +0 -1
  233. package/dist/types.d.ts +0 -85
  234. package/dist/types.d.ts.map +0 -1
  235. package/dist/uk-UA.main.js +0 -14
  236. package/dist/uk-UA.main.js.map +0 -1
  237. package/dist/uk-UA.mjs +0 -16
  238. package/dist/uk-UA.module.js +0 -16
  239. package/dist/uk-UA.module.js.map +0 -1
  240. package/dist/zh-CN.main.js +0 -14
  241. package/dist/zh-CN.main.js.map +0 -1
  242. package/dist/zh-CN.mjs +0 -16
  243. package/dist/zh-CN.module.js +0 -16
  244. package/dist/zh-CN.module.js.map +0 -1
  245. package/dist/zh-TW.main.js +0 -14
  246. package/dist/zh-TW.main.js.map +0 -1
  247. package/dist/zh-TW.mjs +0 -16
  248. package/dist/zh-TW.module.js +0 -16
  249. package/dist/zh-TW.module.js.map +0 -1
  250. package/src/DragPreview.tsx +0 -77
  251. package/src/InsertionIndicator.tsx +0 -62
  252. package/src/Nubbin.tsx +0 -28
  253. package/src/Resizer.tsx +0 -137
  254. package/src/RootDropIndicator.tsx +0 -40
  255. package/src/TableView.tsx +0 -44
  256. package/src/TableViewBase.tsx +0 -1570
  257. package/src/TableViewLayout.ts +0 -102
  258. package/src/TableViewWrapper.tsx +0 -103
  259. package/src/TreeGridTableView.tsx +0 -44
  260. package/src/cursors/Cur_MoveHorizontal_9_9.svg +0 -10
  261. package/src/cursors/Cur_MoveToLeft_9_9.svg +0 -10
  262. package/src/cursors/Cur_MoveToRight_9_9.svg +0 -10
  263. package/src/table.css +0 -235
@@ -1,77 +0,0 @@
1
- /*
2
- * Copyright 2023 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {classNames} from '@react-spectrum/utils';
14
- import {Flex} from '@react-spectrum/layout';
15
- import React, {ReactNode} from 'react';
16
- import styles from '@adobe/spectrum-css-temp/components/table/vars.css';
17
- import stylesOverrides from './table.css';
18
-
19
- interface DragPreviewProps {
20
- itemText: string,
21
- itemCount: number,
22
- height: number,
23
- maxWidth: number
24
- }
25
-
26
- export function DragPreview(props: DragPreviewProps): ReactNode {
27
- let {
28
- itemText,
29
- itemCount,
30
- height,
31
- maxWidth
32
- } = props;
33
- let isDraggingMultiple = itemCount > 1;
34
- return (
35
- <Flex
36
- justifyContent="space-between"
37
- height={height}
38
- maxWidth={maxWidth}
39
- UNSAFE_className={
40
- classNames(
41
- styles,
42
- 'spectrum-Table-row',
43
- classNames(
44
- stylesOverrides,
45
- 'react-spectrum-Table-row',
46
- 'react-spectrum-Table-row-dragPreview',
47
- {'react-spectrum-Table-row-dragPreview--multiple': isDraggingMultiple}
48
- )
49
- )
50
- }>
51
- <div
52
- className={
53
- classNames(
54
- styles,
55
- 'spectrum-Table-cell',
56
- classNames(
57
- stylesOverrides,
58
- 'react-spectrum-Table-cell'
59
- )
60
- )
61
- }>
62
- <span
63
- className={
64
- classNames(
65
- styles,
66
- 'spectrum-Table-cellContents'
67
- )
68
- }>
69
- {itemText}
70
- </span>
71
- </div>
72
- {isDraggingMultiple &&
73
- <div className={classNames(stylesOverrides, 'react-spectrum-Table-row-badge')}>{itemCount}</div>
74
- }
75
- </Flex>
76
- );
77
- }
@@ -1,62 +0,0 @@
1
- /*
2
- * Copyright 2023 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {classNames} from '@react-spectrum/utils';
14
- import {FocusableElement, ItemDropTarget} from '@react-types/shared';
15
- import React, {DOMAttributes, HTMLAttributes, ReactNode, useRef} from 'react';
16
- import styles from './table.css';
17
- import {useTableContext} from './TableViewBase';
18
- import {useVisuallyHidden} from '@react-aria/visually-hidden';
19
-
20
- interface InsertionIndicatorProps {
21
- target: ItemDropTarget,
22
- rowProps: HTMLAttributes<HTMLElement> & DOMAttributes<FocusableElement>
23
- }
24
-
25
- export function InsertionIndicator(props: InsertionIndicatorProps): ReactNode | null {
26
- let {dropState, dragAndDropHooks} = useTableContext();
27
- const {target, rowProps} = props;
28
-
29
- let ref = useRef<HTMLDivElement | null>(null);
30
- let {dropIndicatorProps} = dragAndDropHooks!.useDropIndicator!(props, dropState!, ref);
31
- let {visuallyHiddenProps} = useVisuallyHidden();
32
-
33
- let isDropTarget = dropState!.isDropTarget(target);
34
-
35
- if (!isDropTarget && dropIndicatorProps['aria-hidden']) {
36
- return null;
37
- }
38
-
39
- return (
40
- <div
41
- style={{
42
- position: 'absolute',
43
- top: typeof rowProps.style?.top === 'number' && typeof rowProps.style?.height === 'number' ? rowProps.style.top + (target.dropPosition === 'after' ? rowProps.style.height : 0) : 0,
44
- width: rowProps.style?.width
45
- }}
46
- role="row"
47
- aria-hidden={dropIndicatorProps['aria-hidden']}>
48
- <div
49
- role="gridcell"
50
- className={
51
- classNames(
52
- styles,
53
- 'react-spectrum-Table-InsertionIndicator',
54
- {
55
- 'react-spectrum-Table-InsertionIndicator--dropTarget': isDropTarget
56
- }
57
- )}>
58
- <div {...visuallyHiddenProps} role="button" {...dropIndicatorProps} ref={ref} />
59
- </div>
60
- </div>
61
- );
62
- }
package/src/Nubbin.tsx DELETED
@@ -1,28 +0,0 @@
1
- /*
2
- * Copyright 2022 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import React, {ReactNode} from 'react';
14
-
15
-
16
- // TODO resize with scale? colors should be variables
17
- export function Nubbin(): ReactNode {
18
- return (
19
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
20
- <g fill="var(--spectrum-global-color-blue-600)" stroke="var(--spectrum-global-color-blue-600)" strokeWidth="2">
21
- <circle cx="8" cy="8" r="8" stroke="none" />
22
- <circle cx="8" cy="8" r="7" fill="none" />
23
- </g>
24
- <path d="M-2106-7380.263v5l2.5-2.551Z" transform="translate(2116 7385.763)" fill="#fff" stroke="#fff" strokeLinejoin="round" strokeWidth="2" />
25
- <path d="M-2106-7380.263v5l2.5-2.551Z" transform="translate(-2100 -7369.763) rotate(180)" fill="#fff" stroke="#fff" strokeLinejoin="round" strokeWidth="2" />
26
- </svg>
27
- );
28
- }
package/src/Resizer.tsx DELETED
@@ -1,137 +0,0 @@
1
-
2
- import {classNames} from '@react-spectrum/utils';
3
- import {ColumnSize} from '@react-types/table';
4
- import eCursor from 'bundle-text:./cursors/Cur_MoveToRight_9_9.svg';
5
- import ewCursor from 'bundle-text:./cursors/Cur_MoveHorizontal_9_9.svg';
6
- import {FocusRing} from '@react-aria/focus';
7
- import {GridNode} from '@react-types/grid';
8
- // @ts-ignore
9
- import intlMessages from '../intl/*.json';
10
- import {isWebKit, mergeProps, useObjectRef} from '@react-aria/utils';
11
- import {Key, RefObject} from '@react-types/shared';
12
- import React, {createContext, ForwardedRef, useContext, useEffect, useState} from 'react';
13
- import ReactDOM from 'react-dom';
14
- import styles from '@adobe/spectrum-css-temp/components/table/vars.css';
15
- import {TableColumnResizeState} from '@react-stately/table';
16
- import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
17
- import {useTableColumnResize} from '@react-aria/table';
18
- import {useTableContext, useVirtualizerContext} from './TableViewBase';
19
- import {useUNSAFE_PortalContext} from '@react-aria/overlays';
20
- // @ts-ignore
21
- import wCursor from 'bundle-text:./cursors/Cur_MoveToLeft_9_9.svg';
22
-
23
- function getCursor(svg: string, fallback: string) {
24
- // WebKit renders SVG cursors blurry on 2x screens: https://bugs.webkit.org/show_bug.cgi?id=160657
25
- // To work around this, we generate two SVGs at different sizes and use image-set to pick between them.
26
- // Only do this in WebKit to avoid Firefox rendering the cursor at twice the size.
27
- if (isWebKit()) {
28
- return `image-set(url("data:image/svg+xml,${encodeURIComponent(svg)}") 1x, url("data:image/svg+xml,${encodeURIComponent(svg.replace('width="32" height="32"', 'width="64" height="64"'))}") 2x) 8 8, ${fallback}`;
29
- } else {
30
- return `url("data:image/svg+xml,${encodeURIComponent(svg)}") 8 8, ${fallback}`;
31
- }
32
- }
33
-
34
- interface ResizerProps<T> {
35
- column: GridNode<T>,
36
- showResizer: boolean,
37
- triggerRef: RefObject<HTMLDivElement | null>,
38
- onResizeStart?: (widths: Map<Key, ColumnSize>) => void,
39
- onResize?: (widths: Map<Key, ColumnSize>) => void,
40
- onResizeEnd?: (widths: Map<Key, ColumnSize>) => void
41
- }
42
-
43
- const CURSORS = {
44
- ew: getCursor(ewCursor, 'ew-resize'),
45
- w: getCursor(wCursor, 'w-resize'),
46
- e: getCursor(eCursor, 'e-resize')
47
- };
48
-
49
- export const ResizeStateContext = createContext<TableColumnResizeState<unknown> | null>(null);
50
-
51
- export const Resizer = React.forwardRef(function Resizer<T>(props: ResizerProps<T>, ref: ForwardedRef<HTMLInputElement | null>) {
52
- let {column, showResizer} = props;
53
- let objectRef = useObjectRef(ref);
54
- let {isEmpty, onFocusedResizer} = useTableContext();
55
- let layout = useContext(ResizeStateContext)!;
56
- // Virtualizer re-renders, but these components are all cached
57
- // in order to get around that and cause a rerender here, we use context
58
- // but we don't actually need any value, they are available on the layout object
59
- useVirtualizerContext();
60
- let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/table');
61
- let {direction} = useLocale();
62
-
63
- let [isPointerDown, setIsPointerDown] = useState(false);
64
- useEffect(() => {
65
- let setDown = (e) => {
66
- if (e.pointerType === 'mouse') {
67
- setIsPointerDown(true);
68
- }
69
- };
70
- let setUp = (e) => {
71
- if (e.pointerType === 'mouse') {
72
- setIsPointerDown(false);
73
- }
74
- };
75
- document.addEventListener('pointerdown', setDown, {capture: true});
76
- document.addEventListener('pointerup', setUp, {capture: true});
77
- return () => {
78
- document.removeEventListener('pointerdown', setDown, {capture: true});
79
- document.removeEventListener('pointerup', setUp, {capture: true});
80
- };
81
- }, []);
82
-
83
- let {inputProps, resizerProps} = useTableColumnResize<unknown>(
84
- mergeProps(props, {
85
- 'aria-label': stringFormatter.format('columnResizer'),
86
- isDisabled: isEmpty
87
- }), layout, objectRef);
88
-
89
- let isEResizable = layout.getColumnMinWidth(column.key) >= layout.getColumnWidth(column.key);
90
- let isWResizable = layout.getColumnMaxWidth(column.key) <= layout.getColumnWidth(column.key);
91
- let isResizing = layout.resizingColumn === column.key;
92
- let cursor = '';
93
- if (isEResizable) {
94
- cursor = direction === 'rtl' ? CURSORS.w : CURSORS.e;
95
- } else if (isWResizable) {
96
- cursor = direction === 'rtl' ? CURSORS.e : CURSORS.w;
97
- } else {
98
- cursor = CURSORS.ew;
99
- }
100
-
101
- let style = {
102
- ...resizerProps.style,
103
- height: '100%',
104
- display: showResizer ? undefined : 'none',
105
- cursor
106
- };
107
-
108
- return (
109
- <>
110
- <FocusRing within focusRingClass={classNames(styles, 'focus-ring')}>
111
- <div
112
- {...resizerProps}
113
- role="presentation"
114
- style={style}
115
- className={classNames(styles, 'spectrum-Table-columnResizer')}>
116
- <input
117
- ref={objectRef}
118
- {...mergeProps(inputProps, {onFocus: onFocusedResizer})} />
119
- </div>
120
- </FocusRing>
121
- {/* Placeholder so that the title doesn't intersect with space reserved by the resizer when it appears. */}
122
- <div
123
- aria-hidden
124
- role="presentation"
125
- className={classNames(styles, 'spectrum-Table-columnResizerPlaceholder')} />
126
- <CursorOverlay show={isResizing && isPointerDown}>
127
- <div style={{position: 'fixed', top: 0, left: 0, bottom: 0, right: 0, cursor}} />
128
- </CursorOverlay>
129
- </>
130
- );
131
- });
132
-
133
- function CursorOverlay(props) {
134
- let {show, children} = props;
135
- let {getContainer} = useUNSAFE_PortalContext();
136
- return show ? ReactDOM.createPortal(children, getContainer?.() ?? document.body) : null;
137
- }
@@ -1,40 +0,0 @@
1
- /*
2
- * Copyright 2023 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import React, {ReactNode, useRef} from 'react';
14
- import {useTableContext} from './TableViewBase';
15
- import {useVisuallyHidden} from '@react-aria/visually-hidden';
16
-
17
- export function RootDropIndicator(): ReactNode | null {
18
- let {dropState, dragAndDropHooks, state} = useTableContext();
19
- let ref = useRef<HTMLDivElement | null>(null);
20
- let {dropIndicatorProps} = dragAndDropHooks!.useDropIndicator!({
21
- target: {type: 'root'}
22
- }, dropState!, ref);
23
- let isDropTarget = dropState!.isDropTarget({type: 'root'});
24
- let {visuallyHiddenProps} = useVisuallyHidden();
25
-
26
- if (!isDropTarget && dropIndicatorProps['aria-hidden']) {
27
- return null;
28
- }
29
-
30
- return (
31
- <div role="row" aria-hidden={dropIndicatorProps['aria-hidden']}>
32
- <div
33
- role="gridcell"
34
- aria-selected="false"
35
- aria-colspan={state.collection.columns.length}>
36
- <div role="button" {...visuallyHiddenProps} {...dropIndicatorProps} ref={ref} />
37
- </div>
38
- </div>
39
- );
40
- }
package/src/TableView.tsx DELETED
@@ -1,44 +0,0 @@
1
- /*
2
- * Copyright 2023 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {DOMRef} from '@react-types/shared';
14
- import React, {ReactElement, useState} from 'react';
15
- import {SpectrumTableProps} from './TableViewWrapper';
16
- import {TableViewBase} from './TableViewBase';
17
- import {useTableState} from '@react-stately/table';
18
-
19
- interface TableProps<T> extends Omit<SpectrumTableProps<T>, 'UNSTABLE_allowsExpandableRows'> {}
20
-
21
- export const TableView = React.forwardRef(function TableView<T extends object>(props: TableProps<T>, ref: DOMRef<HTMLDivElement>) {
22
- let {
23
- selectionStyle,
24
- dragAndDropHooks
25
- } = props;
26
- let [showSelectionCheckboxes, setShowSelectionCheckboxes] = useState(selectionStyle !== 'highlight');
27
- let isTableDraggable = !!dragAndDropHooks?.useDraggableCollectionState;
28
- let state = useTableState({
29
- ...props,
30
- showSelectionCheckboxes,
31
- showDragButtons: isTableDraggable,
32
- selectionBehavior: props.selectionStyle === 'highlight' ? 'replace' : 'toggle'
33
- });
34
-
35
- // If the selection behavior changes in state, we need to update showSelectionCheckboxes here due to the circular dependency...
36
- let shouldShowCheckboxes = state.selectionManager.selectionBehavior !== 'replace';
37
- if (shouldShowCheckboxes !== showSelectionCheckboxes) {
38
- setShowSelectionCheckboxes(shouldShowCheckboxes);
39
- }
40
-
41
- return (
42
- <TableViewBase {...props} state={state} ref={ref} />
43
- );
44
- }) as <T>(props: TableProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;