diff --git a/web/app/components/base/action-button/index.tsx b/web/app/components/base/action-button/index.tsx index c90d1a8de..f70bfb444 100644 --- a/web/app/components/base/action-button/index.tsx +++ b/web/app/components/base/action-button/index.tsx @@ -32,6 +32,7 @@ export type ActionButtonProps = { size?: 'xs' | 's' | 'm' | 'l' | 'xl' state?: ActionButtonState styleCss?: CSSProperties + ref?: React.Ref } & React.ButtonHTMLAttributes & VariantProps function getActionButtonState(state: ActionButtonState) { @@ -49,24 +50,22 @@ function getActionButtonState(state: ActionButtonState) { } } -const ActionButton = React.forwardRef( - ({ className, size, state = ActionButtonState.Default, styleCss, children, ...props }, ref) => { - return ( - - ) - }, -) +const ActionButton = ({ className, size, state = ActionButtonState.Default, styleCss, children, ref, ...props }: ActionButtonProps) => { + return ( + + ) +} ActionButton.displayName = 'ActionButton' export default ActionButton diff --git a/web/app/components/base/button/index.tsx b/web/app/components/base/button/index.tsx index 2040c65d3..4f75aec5a 100644 --- a/web/app/components/base/button/index.tsx +++ b/web/app/components/base/button/index.tsx @@ -35,27 +35,26 @@ export type ButtonProps = { loading?: boolean styleCss?: CSSProperties spinnerClassName?: string + ref?: React.Ref } & React.ButtonHTMLAttributes & VariantProps -const Button = React.forwardRef( - ({ className, variant, size, destructive, loading, styleCss, children, spinnerClassName, ...props }, ref) => { - return ( - - ) - }, -) +const Button = ({ className, variant, size, destructive, loading, styleCss, children, spinnerClassName, ref, ...props }: ButtonProps) => { + return ( + + ) +} Button.displayName = 'Button' export default Button diff --git a/web/app/components/base/input/index.tsx b/web/app/components/base/input/index.tsx index ae171b0a7..63ba0e89a 100644 --- a/web/app/components/base/input/index.tsx +++ b/web/app/components/base/input/index.tsx @@ -30,9 +30,10 @@ export type InputProps = { wrapperClassName?: string styleCss?: CSSProperties unit?: string + ref?: React.Ref } & Omit, 'size'> & VariantProps -const Input = React.forwardRef(({ +const Input = ({ size, disabled, destructive, @@ -46,8 +47,9 @@ const Input = React.forwardRef(({ placeholder, onChange = noop, unit, + ref, ...props -}, ref) => { +}: InputProps) => { const { t } = useTranslation() return (
@@ -93,7 +95,7 @@ const Input = React.forwardRef(({ }
) -}) +} Input.displayName = 'Input' diff --git a/web/app/components/base/mermaid/index.tsx b/web/app/components/base/mermaid/index.tsx index 7df9ee398..c1deab6e0 100644 --- a/web/app/components/base/mermaid/index.tsx +++ b/web/app/components/base/mermaid/index.tsx @@ -107,10 +107,13 @@ const initMermaid = () => { return isMermaidInitialized } -const Flowchart = React.forwardRef((props: { +type FlowchartProps = { PrimitiveCode: string theme?: 'light' | 'dark' -}, ref) => { + ref?: React.Ref +} + +const Flowchart = (props: FlowchartProps) => { const { t } = useTranslation() const [svgString, setSvgString] = useState(null) const [look, setLook] = useState<'classic' | 'handDrawn'>('classic') @@ -490,7 +493,7 @@ const Flowchart = React.forwardRef((props: { } return ( -
} className={themeClasses.container}> +
} className={themeClasses.container}>
) -}) +} Flowchart.displayName = 'Flowchart' diff --git a/web/app/components/base/textarea/index.tsx b/web/app/components/base/textarea/index.tsx index 43cc33d62..8b01aa9b5 100644 --- a/web/app/components/base/textarea/index.tsx +++ b/web/app/components/base/textarea/index.tsx @@ -24,30 +24,29 @@ export type TextareaProps = { disabled?: boolean destructive?: boolean styleCss?: CSSProperties + ref?: React.Ref } & React.TextareaHTMLAttributes & VariantProps -const Textarea = React.forwardRef( - ({ className, value, onChange, disabled, size, destructive, styleCss, ...props }, ref) => { - return ( - - ) - }, -) +const Textarea = ({ className, value, onChange, disabled, size, destructive, styleCss, ref, ...props }: TextareaProps) => { + return ( + + ) +} Textarea.displayName = 'Textarea' export default Textarea diff --git a/web/app/components/datasets/preview/container.tsx b/web/app/components/datasets/preview/container.tsx index 69412e65a..3be7aa6a0 100644 --- a/web/app/components/datasets/preview/container.tsx +++ b/web/app/components/datasets/preview/container.tsx @@ -1,14 +1,14 @@ import type { ComponentProps, FC, ReactNode } from 'react' -import { forwardRef } from 'react' import classNames from '@/utils/classnames' export type PreviewContainerProps = ComponentProps<'div'> & { header: ReactNode mainClassName?: string + ref?: React.Ref } -export const PreviewContainer: FC = forwardRef((props, ref) => { - const { children, className, header, mainClassName, ...rest } = props +export const PreviewContainer: FC = (props) => { + const { children, className, header, mainClassName, ref, ...rest } = props return
= forwardRef((props, re
-}) +} PreviewContainer.displayName = 'PreviewContainer' diff --git a/web/app/components/plugins/install-plugin/install-bundle/steps/install-multi.tsx b/web/app/components/plugins/install-plugin/install-bundle/steps/install-multi.tsx index 2691877a0..57732653e 100644 --- a/web/app/components/plugins/install-plugin/install-bundle/steps/install-multi.tsx +++ b/web/app/components/plugins/install-plugin/install-bundle/steps/install-multi.tsx @@ -1,5 +1,4 @@ 'use client' -import type { ForwardRefRenderFunction } from 'react' import { useImperativeHandle } from 'react' import React, { useCallback, useEffect, useMemo, useState } from 'react' import type { Dependency, GitHubItemAndMarketPlaceDependency, PackageDependency, Plugin, VersionInfo } from '../../../types' @@ -21,6 +20,7 @@ type Props = { onDeSelectAll: () => void onLoadedAllPlugin: (installedInfo: Record) => void isFromMarketPlace?: boolean + ref?: React.Ref } export type ExposeRefs = { @@ -28,7 +28,7 @@ export type ExposeRefs = { deSelectAllPlugins: () => void } -const InstallByDSLList: ForwardRefRenderFunction = ({ +const InstallByDSLList = ({ allPlugins, selectedPlugins, onSelect, @@ -36,7 +36,8 @@ const InstallByDSLList: ForwardRefRenderFunction = ({ onDeSelectAll, onLoadedAllPlugin, isFromMarketPlace, -}, ref) => { + ref, +}: Props) => { const systemFeatures = useGlobalPublicStore(s => s.systemFeatures) // DSL has id, to get plugin info to show more info const { isLoading: isFetchingMarketplaceDataById, data: infoGetById, error: infoByIdError } = useFetchPluginsInMarketPlaceByInfo(allPlugins.filter(d => d.type === 'marketplace').map((d) => { @@ -268,4 +269,4 @@ const InstallByDSLList: ForwardRefRenderFunction = ({ ) } -export default React.forwardRef(InstallByDSLList) +export default InstallByDSLList diff --git a/web/app/components/workflow/block-selector/market-place-plugin/list.tsx b/web/app/components/workflow/block-selector/market-place-plugin/list.tsx index 98b799adf..49d708283 100644 --- a/web/app/components/workflow/block-selector/market-place-plugin/list.tsx +++ b/web/app/components/workflow/block-selector/market-place-plugin/list.tsx @@ -1,5 +1,5 @@ 'use client' -import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react' +import React, { useEffect, useImperativeHandle, useMemo, useRef } from 'react' import { useTranslation } from 'react-i18next' import useStickyScroll, { ScrollPosition } from '../use-sticky-scroll' import Item from './item' @@ -17,18 +17,20 @@ export type ListProps = { tags: string[] toolContentClassName?: string disableMaxWidth?: boolean + ref?: React.Ref } export type ListRef = { handleScroll: () => void } -const List = forwardRef(({ +const List = ({ wrapElemRef, searchText, tags, list, toolContentClassName, disableMaxWidth = false, -}, ref) => { + ref, +}: ListProps) => { const { t } = useTranslation() const hasFilter = !searchText const hasRes = list.length > 0 @@ -125,7 +127,7 @@ const List = forwardRef(({
) -}) +} List.displayName = 'List'