From d9d4caff60325af507fe2a91897a3ae5399ade1a Mon Sep 17 00:00:00 2001 From: JunJie Date: Fri, 24 Jan 2025 12:19:52 +0800 Subject: [PATCH] fix: type error --- packages/dodoex-components/package.json | 2 +- .../src/Checkbox/Checkbox.tsx | 13 ++-- .../src/Hover/HoverAddBackground.tsx | 6 +- .../src/Hover/HoverOpacity.tsx | 75 +++++++++---------- .../dodoex-components/src/Input/Input.tsx | 6 +- .../dodoex-components/src/Select/index.tsx | 8 +- packages/dodoex-components/src/Tabs/index.ts | 1 + packages/dodoex-components/src/index.ts | 1 + packages/dodoex-widgets/package.json | 2 +- 9 files changed, 59 insertions(+), 55 deletions(-) diff --git a/packages/dodoex-components/package.json b/packages/dodoex-components/package.json index d3a67bae..5565165d 100644 --- a/packages/dodoex-components/package.json +++ b/packages/dodoex-components/package.json @@ -1,6 +1,6 @@ { "name": "@dodoex/components", - "version": "3.0.2", + "version": "3.0.3", "description": "UI component library", "source": "src/index.ts", "types": "dist/types/index.d.ts", diff --git a/packages/dodoex-components/src/Checkbox/Checkbox.tsx b/packages/dodoex-components/src/Checkbox/Checkbox.tsx index a30769d7..0e43c113 100644 --- a/packages/dodoex-components/src/Checkbox/Checkbox.tsx +++ b/packages/dodoex-components/src/Checkbox/Checkbox.tsx @@ -1,11 +1,9 @@ import { Box, styled, useTheme } from '@mui/system'; -import { forwardRef } from 'react'; +import React, { forwardRef } from 'react'; import { CheckboxProps } from './Checkbox.types'; import { Done as CheckedIcon } from '@dodoex/icons'; -const Checkbox = forwardRef(function Checkbox< - RootComponentType extends React.ElementType, ->( +function Checkbox( props: CheckboxProps, forwardedRef: React.ForwardedRef, ) { @@ -89,6 +87,9 @@ const Checkbox = forwardRef(function Checkbox< ); -}); +} -export default Checkbox; +export default forwardRef(Checkbox) as ( + // eslint-disable-next-line no-unused-vars + props: CheckboxProps & { ref?: React.ForwardedRef }, +) => ReturnType; diff --git a/packages/dodoex-components/src/Hover/HoverAddBackground.tsx b/packages/dodoex-components/src/Hover/HoverAddBackground.tsx index 7227af65..eeff1b93 100644 --- a/packages/dodoex-components/src/Hover/HoverAddBackground.tsx +++ b/packages/dodoex-components/src/Hover/HoverAddBackground.tsx @@ -7,8 +7,8 @@ interface Prop extends BoxProps { hoverColor?: string; } -const HoverAddBackground = forwardRef( - ({ sx, hoverColor, ...other }: Prop, ref: any) => { +const HoverAddBackground = forwardRef( + ({ sx, hoverColor, ...other }, ref) => { const theme = useTheme(); const { isMobile } = useDevices(); const isLight = theme.palette.mode === 'light'; @@ -40,4 +40,6 @@ const HoverAddBackground = forwardRef( }, ); +HoverAddBackground.displayName = 'HoverAddBackground'; + export default HoverAddBackground; diff --git a/packages/dodoex-components/src/Hover/HoverOpacity.tsx b/packages/dodoex-components/src/Hover/HoverOpacity.tsx index 84b1c4c3..cc11af1b 100644 --- a/packages/dodoex-components/src/Hover/HoverOpacity.tsx +++ b/packages/dodoex-components/src/Hover/HoverOpacity.tsx @@ -2,46 +2,41 @@ import { merge } from 'lodash'; import { forwardRef } from 'react'; import { Box, BoxProps } from '../Box'; -const HoverOpacity = forwardRef( - ( - { - weak, - color, - sx, - ...attrs - }: BoxProps & { - weak?: boolean; - color?: string; +const HoverOpacity = forwardRef< + HTMLDivElement, + BoxProps & { + weak?: boolean; + color?: string; + } +>(({ weak, color, sx, ...attrs }, ref) => { + let defaultColor = weak ? 'text.primary' : 'text.secondary'; + let hoverColor = weak ? 'text.secondary' : 'text.primary'; + if (color) { + defaultColor = color; + hoverColor = color; + } + const hoverCss = { + '&:hover': { + color: hoverColor, + opacity: color && weak ? 0.5 : 1, }, - ref: any, - ) => { - let defaultColor = weak ? 'text.primary' : 'text.secondary'; - let hoverColor = weak ? 'text.secondary' : 'text.primary'; - if (color) { - defaultColor = color; - hoverColor = color; - } - const hoverCss = { - '&:hover': { - color: hoverColor, - opacity: color && weak ? 0.5 : 1, - }, - }; - return ( - - ); - }, -); + }; + return ( + + ); +}); + +HoverOpacity.displayName = 'HoverOpacity'; export default HoverOpacity; diff --git a/packages/dodoex-components/src/Input/Input.tsx b/packages/dodoex-components/src/Input/Input.tsx index a5254de8..a44255d3 100644 --- a/packages/dodoex-components/src/Input/Input.tsx +++ b/packages/dodoex-components/src/Input/Input.tsx @@ -125,7 +125,7 @@ const StyledInput = styled(Box)(({ theme }) => { `; }); -export default forwardRef(function Input( +export default forwardRef(function Input( { fullWidth, error, @@ -138,8 +138,8 @@ export default forwardRef(function Input( dataTestId, inputSx, ...attrs - }: InputProps, - ref: React.ForwardedRef, + }, + ref, ) { const InputBaseRootMemo = useCallback( (props: any) => ( diff --git a/packages/dodoex-components/src/Select/index.tsx b/packages/dodoex-components/src/Select/index.tsx index 803e432e..7591bea2 100644 --- a/packages/dodoex-components/src/Select/index.tsx +++ b/packages/dodoex-components/src/Select/index.tsx @@ -186,7 +186,8 @@ const Popup = styled('div')` z-index: 10; `; -interface Props extends SelectProps { +interface Props + extends SelectProps { options?: SelectOption[]; fullWidth?: boolean; px?: number; @@ -196,7 +197,10 @@ interface Props e sx?: BoxProps['sx']; } -export function Select({ +export function Select< + Value = number | string, + Multiple extends boolean = false, +>({ options, fullWidth, px = 20, diff --git a/packages/dodoex-components/src/Tabs/index.ts b/packages/dodoex-components/src/Tabs/index.ts index 0b316866..5a843bc0 100644 --- a/packages/dodoex-components/src/Tabs/index.ts +++ b/packages/dodoex-components/src/Tabs/index.ts @@ -4,3 +4,4 @@ export { TabsList } from './TabsGroup/TabsList'; export { TabPanel } from './TabPanel'; export { TabsGroup } from './TabsGroup'; export { TabsButtonGroup, TabButton, TabListButton } from './TabsButtonGroup'; +export { tabClasses } from '@mui/base'; diff --git a/packages/dodoex-components/src/index.ts b/packages/dodoex-components/src/index.ts index 68782879..f122248b 100644 --- a/packages/dodoex-components/src/index.ts +++ b/packages/dodoex-components/src/index.ts @@ -38,6 +38,7 @@ export { TabsButtonGroup, TabButton, TabListButton, + tabClasses, } from './Tabs'; export { Skeleton } from './Skeleton'; export type { SkeletonProps } from './Skeleton'; diff --git a/packages/dodoex-widgets/package.json b/packages/dodoex-widgets/package.json index 5ec3d2ae..5fa18e0e 100644 --- a/packages/dodoex-widgets/package.json +++ b/packages/dodoex-widgets/package.json @@ -59,7 +59,7 @@ "dependencies": { "@babel/runtime": "^7.17.0", "@dodoex/api": "3.0.3-morph.7", - "@dodoex/components": "3.0.2", + "@dodoex/components": "3.0.3", "@dodoex/contract-request": "^1.3.0", "@dodoex/dodo-contract-request": "^1.9.0-alpha.9", "@dodoex/icons": "^2.0.2",