Fix typescript issues

This commit is contained in:
2025-11-15 14:56:48 +01:00
parent 9ba37b3342
commit cc8c8fd414
2 changed files with 17 additions and 18 deletions

View File

@@ -1,4 +1,4 @@
import React, { useRef, useState, useLayoutEffect, useCallback } from 'react'; import React, { useRef, useState, useCallback } from 'react';
import { Tree, type NodeApi } from 'react-arborist'; import { Tree, type NodeApi } from 'react-arborist';
import { import {
IconFile, IconFile,
@@ -23,15 +23,11 @@ interface FileTreeProps {
loadFileList: () => Promise<void>; loadFileList: () => Promise<void>;
} }
const useSize = (target: React.RefObject<HTMLElement>): Size | undefined => { const useSize = (
target: React.RefObject<HTMLElement | null>
): Size | undefined => {
const [size, setSize] = useState<Size>(); const [size, setSize] = useState<Size>();
useLayoutEffect(() => {
if (target.current) {
setSize(target.current.getBoundingClientRect());
}
}, [target]);
useResizeObserver(target, (entry) => setSize(entry.contentRect)); useResizeObserver(target, (entry) => setSize(entry.contentRect));
return size; return size;
}; };

View File

@@ -1,4 +1,4 @@
import React, { useRef, useLayoutEffect, useState } from 'react'; import React, { useRef, useState } from 'react';
import { Box } from '@mantine/core'; import { Box } from '@mantine/core';
import { Tree, type NodeApi } from 'react-arborist'; import { Tree, type NodeApi } from 'react-arborist';
import { import {
@@ -21,15 +21,11 @@ interface Size {
height: number; height: number;
} }
const useSize = (target: React.RefObject<HTMLElement>): Size | undefined => { const useSize = (
target: React.RefObject<HTMLElement | null>
): Size | undefined => {
const [size, setSize] = useState<Size>(); const [size, setSize] = useState<Size>();
useLayoutEffect(() => {
if (target.current) {
setSize(target.current.getBoundingClientRect());
}
}, [target]);
useResizeObserver(target, (entry) => setSize(entry.contentRect)); useResizeObserver(target, (entry) => setSize(entry.contentRect));
return size; return size;
}; };
@@ -239,7 +235,10 @@ export const FolderSelector: React.FC<FolderSelectorProps> = ({
}} }}
> >
{/* Root option */} {/* Root option */}
<RootNode isSelected={selectedPath === ''} onSelect={() => onSelect('')} /> <RootNode
isSelected={selectedPath === ''}
onSelect={() => onSelect('')}
/>
{/* Folder tree */} {/* Folder tree */}
{size && folders.length > 0 && ( {size && folders.length > 0 && (
@@ -255,7 +254,11 @@ export const FolderSelector: React.FC<FolderSelectorProps> = ({
disableDrop={() => true} disableDrop={() => true}
> >
{(props) => ( {(props) => (
<FolderNode {...props} selectedPath={selectedPath} onSelect={onSelect} /> <FolderNode
{...props}
selectedPath={selectedPath}
onSelect={onSelect}
/>
)} )}
</Tree> </Tree>
)} )}