Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit 09005de

Browse files
committed
Bump deps.
1 parent f81e4cf commit 09005de

7 files changed

+1266
-1080
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ style.css.map
2424
# Error files
2525
yarn-error.log
2626

27-
.vscode
27+
.vscode
28+
.eslintcache

package.json

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nosferatu500/react-sortable-tree",
3-
"version": "4.2.1",
3+
"version": "4.2.2",
44
"description": "Drag-and-drop sortable component for nested data and hierarchies",
55
"main": "./index.js",
66
"module": "./esm/index.js",
@@ -25,7 +25,7 @@
2525
"build:storybook": "build-storybook -o build",
2626
"clean": "rimraf dist",
2727
"clean:storybook": "rimraf build",
28-
"lint": "eslint '*.{js,json}' '{src,tests}/**/*.{ts,tsx}'",
28+
"lint": "eslint '*.{js,json}' '{src,tests}/**/*.{ts,tsx}' --cache",
2929
"prepublishOnly": "yarn build",
3030
"release": "standard-version",
3131
"storybook": "start-storybook -p ${PORT:-3001} -h 0.0.0.0",
@@ -73,57 +73,57 @@
7373
"react-virtuoso": "^2.19.1"
7474
},
7575
"devDependencies": {
76-
"@babel/core": "^7.20.2",
76+
"@babel/core": "^7.20.12",
7777
"@babel/eslint-parser": "^7.19.1",
7878
"@babel/helper-module-imports": "^7.18.6",
79-
"@babel/plugin-transform-react-jsx": "^7.19.0",
79+
"@babel/plugin-transform-react-jsx": "^7.20.13",
8080
"@babel/preset-env": "^7.20.2",
81-
"@babel/types": "^7.20.2",
81+
"@babel/types": "^7.20.7",
8282
"@rollup/plugin-babel": "^5.3.1",
8383
"@rollup/plugin-node-resolve": "^14.1.0",
8484
"@rollup/plugin-typescript": "^8.5.0",
8585
"@storybook/addon-postcss": "^2.0.0",
86-
"@storybook/addons": "^6.5.13",
87-
"@storybook/react": "^6.5.13",
88-
"@storybook/theming": "^6.5.13",
86+
"@storybook/addons": "^6.5.16",
87+
"@storybook/react": "^6.5.16",
88+
"@storybook/theming": "^6.5.16",
8989
"@types/babel-plugin-macros": "^2.8.5",
9090
"@types/lodash.isequal": "^4.5.6",
91-
"@types/react": "^17.0.52",
91+
"@types/react": "^16.14.35",
9292
"@types/react-dom": "^17.0.18",
93-
"@typescript-eslint/eslint-plugin": "^5.42.0",
94-
"@typescript-eslint/parser": "^5.42.0",
93+
"@typescript-eslint/eslint-plugin": "^5.50.0",
94+
"@typescript-eslint/parser": "^5.50.0",
9595
"acorn-jsx": "^5.3.2",
9696
"autoprefixer": "^10.4.13",
9797
"babel-plugin-macros": "^3.1.0",
98-
"esbuild": "^0.15.13",
99-
"eslint": "^8.27.0",
98+
"esbuild": "^0.17.5",
99+
"eslint": "^8.33.0",
100100
"eslint-config-airbnb": "^19.0.4",
101101
"eslint-config-airbnb-typescript": "^17.0.0",
102-
"eslint-config-prettier": "^8.5.0",
103-
"eslint-import-resolver-typescript": "^3.5.2",
104-
"eslint-plugin-import": "^2.26.0",
105-
"eslint-plugin-jsx-a11y": "^6.6.1",
102+
"eslint-config-prettier": "^8.6.0",
103+
"eslint-import-resolver-typescript": "^3.5.3",
104+
"eslint-plugin-import": "^2.27.5",
105+
"eslint-plugin-jsx-a11y": "^6.7.1",
106106
"eslint-plugin-prettier": "^4.2.1",
107107
"eslint-plugin-promise": "^6.1.1",
108-
"eslint-plugin-react": "^7.31.10",
108+
"eslint-plugin-react": "^7.32.2",
109109
"eslint-plugin-react-hooks": "^4.6.0",
110-
"eslint-plugin-sonarjs": "^0.16.0",
111-
"eslint-plugin-storybook": "^0.6.7",
112-
"eslint-plugin-unicorn": "^44.0.2",
110+
"eslint-plugin-sonarjs": "^0.18.0",
111+
"eslint-plugin-storybook": "^0.6.10",
112+
"eslint-plugin-unicorn": "^45.0.2",
113113
"json": "^11.0.0",
114-
"postcss": "^8.4.18",
115-
"prettier": "^2.7.1",
114+
"postcss": "^8.4.21",
115+
"prettier": "^2.8.3",
116116
"prop-types": "^15.8.1",
117117
"react": "^17.0.2",
118118
"react-dnd-touch-backend": "^14.1.1",
119119
"react-dom": "^17.0.2",
120-
"rimraf": "^3.0.2",
120+
"rimraf": "^4.1.2",
121121
"rollup": "^2.79.1",
122-
"rollup-plugin-esbuild": "^4.10.1",
122+
"rollup-plugin-esbuild": "^4.10.3",
123123
"rollup-plugin-postcss": "^4.0.2",
124124
"shx": "^0.3.4",
125-
"tslib": "^2.4.1",
126-
"typescript": "^4.8.4"
125+
"tslib": "^2.5.0",
126+
"typescript": "^4.9.5"
127127
},
128128
"peerDependencies": {
129129
"react": ">=17.0.2",

src/node-renderer-default.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const NodeRendererDefault: React.FC<NodeRendererProps> = function (props) {
9595
typeof node.children === 'function' && node.expanded ? (
9696
<div className="rst__loadingHandle">
9797
<div className="rst__loadingCircle">
98-
{[...Array.from({ length: 12 })].map((_, index) => (
98+
{Array.from({ length: 12 }).map((_, index) => (
9999
<div
100100
key={index}
101101
className={classnames(
@@ -178,7 +178,7 @@ const NodeRendererDefault: React.FC<NodeRendererProps> = function (props) {
178178
<div
179179
className={classnames(
180180
'rst__rowContents',
181-
!canDrag ? 'rst__rowContentsDragDisabled' : '',
181+
canDrag ? '' : 'rst__rowContentsDragDisabled',
182182
rowDirectionClass ?? ''
183183
)}>
184184
<div

src/react-sortable-tree.tsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ const mergeTheme = (props) => {
5959
// If all else fails, fall back to the default
6060
if (props[propKey] === undefined) {
6161
merged[propKey] =
62-
typeof props.theme[propKey] !== 'undefined'
63-
? props.theme[propKey]
64-
: overridableDefaults[propKey]
62+
props.theme[propKey] === undefined
63+
? overridableDefaults[propKey]
64+
: props.theme[propKey]
6565
}
6666
}
6767

@@ -588,11 +588,9 @@ class ReactSortableTree extends Component {
588588
isSearchMatch,
589589
isSearchFocus,
590590
}
591-
const nodeProps = !generateNodeProps
592-
? {}
593-
: generateNodeProps(callbackParams)
591+
const nodeProps = generateNodeProps ? generateNodeProps(callbackParams) : {}
594592
const rowCanDrag =
595-
typeof canDrag !== 'function' ? canDrag : canDrag(callbackParams)
593+
typeof canDrag === 'function' ? canDrag(callbackParams) : canDrag
596594

597595
const sharedProps = {
598596
treeIndex,

src/utils/dnd-manager.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,15 @@ const getTargetDepth = (
101101
let dragSourceInitialDepth = (monitor.getItem().path || []).length
102102

103103
// When adding node from external source
104-
if (monitor.getItem().treeId !== treeId) {
104+
if (monitor.getItem().treeId === treeId) {
105+
// handle row direction support
106+
const direction = dropTargetProps.rowDirection === 'rtl' ? -1 : 1
107+
108+
blocksOffset = Math.round(
109+
(direction * monitor.getDifferenceFromInitialOffset().x) /
110+
dropTargetProps.scaffoldBlockPxWidth
111+
)
112+
} else {
105113
// Ignore the tree depth of the source, if it had any to begin with
106114
dragSourceInitialDepth = 0
107115

@@ -115,14 +123,6 @@ const getTargetDepth = (
115123
} else {
116124
blocksOffset = dropTargetProps.path.length
117125
}
118-
} else {
119-
// handle row direction support
120-
const direction = dropTargetProps.rowDirection === 'rtl' ? -1 : 1
121-
122-
blocksOffset = Math.round(
123-
(direction * monitor.getDifferenceFromInitialOffset().x) /
124-
dropTargetProps.scaffoldBlockPxWidth
125-
)
126126
}
127127

128128
let targetDepth = Math.min(
@@ -131,7 +131,7 @@ const getTargetDepth = (
131131
)
132132

133133
// If a maxDepth is defined, constrain the target depth
134-
if (typeof maxDepth !== 'undefined' && maxDepth !== undefined) {
134+
if (maxDepth !== undefined && maxDepth !== undefined) {
135135
const draggedNode = monitor.getItem().node
136136
const draggedChildDepth = getDepth(draggedNode)
137137

src/utils/tree-data-utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ const getNodeDataAtTreeIndexOrNextIndex = ({
4747
isPseudoRoot: boolean
4848
}) => {
4949
// The pseudo-root is not considered in the path
50-
const selfPath = !isPseudoRoot
51-
? [...path, getNodeKey({ node, treeIndex: currentIndex })]
52-
: []
50+
const selfPath = isPseudoRoot
51+
? []
52+
: [...path, getNodeKey({ node, treeIndex: currentIndex })]
5353

5454
// Return target node when found
5555
if (currentIndex === targetIndex) {

0 commit comments

Comments
 (0)