@react-spectrum/table 3.17.10 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +2 -6
- package/dist/main.js +8 -12
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -6
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +3 -0
- package/package.json +14 -52
- package/src/index.ts +3 -18
- package/dist/DragPreview.main.js +0 -54
- package/dist/DragPreview.main.js.map +0 -1
- package/dist/DragPreview.mjs +0 -49
- package/dist/DragPreview.module.js +0 -49
- package/dist/DragPreview.module.js.map +0 -1
- package/dist/InsertionIndicator.main.js +0 -64
- package/dist/InsertionIndicator.main.js.map +0 -1
- package/dist/InsertionIndicator.mjs +0 -59
- package/dist/InsertionIndicator.module.js +0 -59
- package/dist/InsertionIndicator.module.js.map +0 -1
- package/dist/Nubbin.main.js +0 -62
- package/dist/Nubbin.main.js.map +0 -1
- package/dist/Nubbin.mjs +0 -53
- package/dist/Nubbin.module.js +0 -53
- package/dist/Nubbin.module.js.map +0 -1
- package/dist/Resizer.main.js +0 -150
- package/dist/Resizer.main.js.map +0 -1
- package/dist/Resizer.mjs +0 -144
- package/dist/Resizer.module.js +0 -144
- package/dist/Resizer.module.js.map +0 -1
- package/dist/RootDropIndicator.main.js +0 -57
- package/dist/RootDropIndicator.main.js.map +0 -1
- package/dist/RootDropIndicator.mjs +0 -48
- package/dist/RootDropIndicator.module.js +0 -48
- package/dist/RootDropIndicator.module.js.map +0 -1
- package/dist/TableView.main.js +0 -49
- package/dist/TableView.main.js.map +0 -1
- package/dist/TableView.mjs +0 -40
- package/dist/TableView.module.js +0 -40
- package/dist/TableView.module.js.map +0 -1
- package/dist/TableViewBase.main.js +0 -1239
- package/dist/TableViewBase.main.js.map +0 -1
- package/dist/TableViewBase.mjs +0 -1232
- package/dist/TableViewBase.module.js +0 -1232
- package/dist/TableViewBase.module.js.map +0 -1
- package/dist/TableViewLayout.main.js +0 -101
- package/dist/TableViewLayout.main.js.map +0 -1
- package/dist/TableViewLayout.mjs +0 -96
- package/dist/TableViewLayout.module.js +0 -96
- package/dist/TableViewLayout.module.js.map +0 -1
- package/dist/TableViewWrapper.main.js +0 -45
- package/dist/TableViewWrapper.main.js.map +0 -1
- package/dist/TableViewWrapper.mjs +0 -36
- package/dist/TableViewWrapper.module.js +0 -36
- package/dist/TableViewWrapper.module.js.map +0 -1
- package/dist/TreeGridTableView.main.js +0 -49
- package/dist/TreeGridTableView.main.js.map +0 -1
- package/dist/TreeGridTableView.mjs +0 -40
- package/dist/TreeGridTableView.module.js +0 -40
- package/dist/TreeGridTableView.module.js.map +0 -1
- package/dist/ar-AE.main.js +0 -14
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -16
- package/dist/ar-AE.module.js +0 -16
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -14
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -16
- package/dist/bg-BG.module.js +0 -16
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -14
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -16
- package/dist/cs-CZ.module.js +0 -16
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -14
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -16
- package/dist/da-DK.module.js +0 -16
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -14
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -16
- package/dist/de-DE.module.js +0 -16
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -14
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -16
- package/dist/el-GR.module.js +0 -16
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -14
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -16
- package/dist/en-US.module.js +0 -16
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -14
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -16
- package/dist/es-ES.module.js +0 -16
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -14
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -16
- package/dist/et-EE.module.js +0 -16
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -14
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -16
- package/dist/fi-FI.module.js +0 -16
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -14
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -16
- package/dist/fr-FR.module.js +0 -16
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -14
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -16
- package/dist/he-IL.module.js +0 -16
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -14
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -16
- package/dist/hr-HR.module.js +0 -16
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -14
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -16
- package/dist/hu-HU.module.js +0 -16
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -14
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -16
- package/dist/it-IT.module.js +0 -16
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -14
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -16
- package/dist/ja-JP.module.js +0 -16
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -14
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -16
- package/dist/ko-KR.module.js +0 -16
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -14
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -16
- package/dist/lt-LT.module.js +0 -16
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -14
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -16
- package/dist/lv-LV.module.js +0 -16
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -14
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -16
- package/dist/nb-NO.module.js +0 -16
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -14
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -16
- package/dist/nl-NL.module.js +0 -16
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -14
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -16
- package/dist/pl-PL.module.js +0 -16
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -14
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -16
- package/dist/pt-BR.module.js +0 -16
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -14
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -16
- package/dist/pt-PT.module.js +0 -16
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -14
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -16
- package/dist/ro-RO.module.js +0 -16
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -14
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -16
- package/dist/ru-RU.module.js +0 -16
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -14
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -16
- package/dist/sk-SK.module.js +0 -16
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -14
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -16
- package/dist/sl-SI.module.js +0 -16
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -14
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -16
- package/dist/sr-SP.module.js +0 -16
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -14
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -16
- package/dist/sv-SE.module.js +0 -16
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/table.0cdc494a.css +0 -992
- package/dist/table.0cdc494a.css.map +0 -1
- package/dist/table.11fc8462.css +0 -220
- package/dist/table.11fc8462.css.map +0 -1
- package/dist/table_css.main.js +0 -74
- package/dist/table_css.main.js.map +0 -1
- package/dist/table_css.mjs +0 -76
- package/dist/table_css.module.js +0 -76
- package/dist/table_css.module.js.map +0 -1
- package/dist/table_vars_css.main.js +0 -197
- package/dist/table_vars_css.main.js.map +0 -1
- package/dist/table_vars_css.mjs +0 -199
- package/dist/table_vars_css.module.js +0 -199
- package/dist/table_vars_css.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -14
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -16
- package/dist/tr-TR.module.js +0 -16
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -85
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -14
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -16
- package/dist/uk-UA.module.js +0 -16
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -14
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -16
- package/dist/zh-CN.module.js +0 -16
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -14
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -16
- package/dist/zh-TW.module.js +0 -16
- package/dist/zh-TW.module.js.map +0 -1
- package/src/DragPreview.tsx +0 -77
- package/src/InsertionIndicator.tsx +0 -62
- package/src/Nubbin.tsx +0 -28
- package/src/Resizer.tsx +0 -137
- package/src/RootDropIndicator.tsx +0 -40
- package/src/TableView.tsx +0 -44
- package/src/TableViewBase.tsx +0 -1569
- package/src/TableViewLayout.ts +0 -102
- package/src/TableViewWrapper.tsx +0 -103
- package/src/TreeGridTableView.tsx +0 -44
- package/src/cursors/Cur_MoveHorizontal_9_9.svg +0 -10
- package/src/cursors/Cur_MoveToLeft_9_9.svg +0 -10
- package/src/cursors/Cur_MoveToRight_9_9.svg +0 -10
- package/src/table.css +0 -235
package/src/DragPreview.tsx
DELETED
|
@@ -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;
|