@sanity/hierarchical-document-list 2.0.1 → 2.1.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/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +13 -8
- package/src/components/TreeEditor.tsx +18 -1
- package/src/utils/getTreeHeight.ts +2 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/hierarchical-document-list",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Sanity Plugin - Hierarchical Document List",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@sanity/mutator": "^3.78.1",
|
|
55
55
|
"@sanity/ui": "^2.15.2",
|
|
56
56
|
"@sanity/util": "^3.78.1",
|
|
57
|
-
"react-dnd": "16.0.1",
|
|
58
|
-
"react-dnd-html5-backend": "16.0.1"
|
|
57
|
+
"react-dnd": "^16.0.1",
|
|
58
|
+
"react-dnd-html5-backend": "^16.0.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@commitlint/cli": "^18.4.3",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@sanity/plugin-kit": "^3.1.10",
|
|
65
65
|
"@sanity/semantic-release-preset": "^4.1.6",
|
|
66
66
|
"@sanity/vision": "^3.78.1",
|
|
67
|
-
"@types/react": "^
|
|
67
|
+
"@types/react": "^19.0.10",
|
|
68
68
|
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
69
69
|
"@typescript-eslint/parser": "^6.13.1",
|
|
70
70
|
"eslint": "^8.55.0",
|
|
@@ -78,18 +78,23 @@
|
|
|
78
78
|
"npm-run-all": "^4.1.5",
|
|
79
79
|
"prettier": "^3.1.0",
|
|
80
80
|
"prettier-plugin-packagejson": "^2.4.7",
|
|
81
|
-
"react": "^
|
|
82
|
-
"react-dom": "^
|
|
83
|
-
"react-is": "^
|
|
81
|
+
"react": "^19.0.0",
|
|
82
|
+
"react-dom": "^19.0.0",
|
|
83
|
+
"react-is": "^19.0.0",
|
|
84
84
|
"rimraf": "^5.0.5",
|
|
85
85
|
"sanity": "^3.78.1",
|
|
86
86
|
"styled-components": "^6.1.15",
|
|
87
87
|
"typescript": "5.3.2"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"react": "^18.3",
|
|
90
|
+
"react": "^18.3 || ^19",
|
|
91
91
|
"sanity": "^3"
|
|
92
92
|
},
|
|
93
|
+
"overrides": {
|
|
94
|
+
"react": "$react",
|
|
95
|
+
"react-dom": "$react-dom",
|
|
96
|
+
"react-is": "$react-is"
|
|
97
|
+
},
|
|
93
98
|
"engines": {
|
|
94
99
|
"node": ">=14"
|
|
95
100
|
}
|
|
@@ -42,6 +42,13 @@ const TreeEditor: React.FC<{
|
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
const [context, setContext] = React.useState<HTMLElement | null>(null)
|
|
45
|
+
const [treeViewHeight, setTreeViewHeight] = React.useState<string>('')
|
|
46
|
+
|
|
47
|
+
const updateTreeViewHeight = () => {
|
|
48
|
+
const el = document.querySelector(`#${props.options.documentId} [data-known-size]`) as HTMLElement | null
|
|
49
|
+
const rowHeight = Number(el?.dataset.knownSize || 51)
|
|
50
|
+
setTreeViewHeight(getTreeHeight(localTree, rowHeight))
|
|
51
|
+
}
|
|
45
52
|
|
|
46
53
|
React.useEffect(() => {
|
|
47
54
|
if (props.options.documentId) {
|
|
@@ -49,6 +56,16 @@ const TreeEditor: React.FC<{
|
|
|
49
56
|
}
|
|
50
57
|
}, [props.options.documentId])
|
|
51
58
|
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
// Wait for dom to load before initial execution.
|
|
61
|
+
setTimeout(updateTreeViewHeight)
|
|
62
|
+
}, [])
|
|
63
|
+
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
// Immediately update when changes are detected.
|
|
66
|
+
updateTreeViewHeight()
|
|
67
|
+
}, [props.options.documentId, localTree])
|
|
68
|
+
|
|
52
69
|
const onMoveNode = useCallback(
|
|
53
70
|
(data: NodeData & FullTree & any) =>
|
|
54
71
|
operations.handleMovedNode(data as unknown as HandleMovedNodeData),
|
|
@@ -79,7 +96,7 @@ const TreeEditor: React.FC<{
|
|
|
79
96
|
<TreeOperationsContext.Provider value={operationContext}>
|
|
80
97
|
<Stack space={4} paddingTop={4}>
|
|
81
98
|
<Card
|
|
82
|
-
style={{minHeight:
|
|
99
|
+
style={{minHeight: treeViewHeight}}
|
|
83
100
|
// Only include borderBottom if there's something to show in unadded items
|
|
84
101
|
borderBottom={allItemsStatus !== 'success' || unAddedItems?.length > 0}
|
|
85
102
|
>
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import {getVisibleNodeCount, TreeItem} from '@nosferatu500/react-sortable-tree'
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
export default function getTreeHeight(treeData: TreeItem[]): string {
|
|
3
|
+
export default function getTreeHeight(treeData: TreeItem[], rowHeight: number): string {
|
|
6
4
|
const visibleNodeCount = getVisibleNodeCount({treeData})
|
|
7
5
|
|
|
8
6
|
// prettier-ignore
|
|
9
|
-
return `${50 + (
|
|
7
|
+
return `${50 + (rowHeight * visibleNodeCount)}px`
|
|
10
8
|
}
|