Skip to content

Commit

Permalink
fix: type error
Browse files Browse the repository at this point in the history
  • Loading branch information
junjieit committed Jan 24, 2025
1 parent 2c91689 commit d9d4caf
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 55 deletions.
2 changes: 1 addition & 1 deletion packages/dodoex-components/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 7 additions & 6 deletions packages/dodoex-components/src/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -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<RootComponentType extends React.ElementType>(
props: CheckboxProps<RootComponentType>,
forwardedRef: React.ForwardedRef<Element>,
) {
Expand Down Expand Up @@ -89,6 +87,9 @@ const Checkbox = forwardRef(function Checkbox<
</>
</Box>
);
});
}

export default Checkbox;
export default forwardRef(Checkbox) as <T extends React.ElementType>(
// eslint-disable-next-line no-unused-vars
props: CheckboxProps<T> & { ref?: React.ForwardedRef<Element> },
) => ReturnType<typeof Checkbox>;
6 changes: 4 additions & 2 deletions packages/dodoex-components/src/Hover/HoverAddBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ interface Prop extends BoxProps {
hoverColor?: string;
}

const HoverAddBackground = forwardRef(
({ sx, hoverColor, ...other }: Prop, ref: any) => {
const HoverAddBackground = forwardRef<HTMLDivElement, Prop>(
({ sx, hoverColor, ...other }, ref) => {
const theme = useTheme();
const { isMobile } = useDevices();
const isLight = theme.palette.mode === 'light';
Expand Down Expand Up @@ -40,4 +40,6 @@ const HoverAddBackground = forwardRef(
},
);

HoverAddBackground.displayName = 'HoverAddBackground';

export default HoverAddBackground;
75 changes: 35 additions & 40 deletions packages/dodoex-components/src/Hover/HoverOpacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Box
ref={ref}
sx={merge(
{
color: defaultColor,
opacity: color && !weak ? 0.5 : 1,
...hoverCss,
},
sx,
)}
{...attrs}
/>
);
},
);
};
return (
<Box
ref={ref}
sx={merge(
{
color: defaultColor,
opacity: color && !weak ? 0.5 : 1,
...hoverCss,
},
sx,
)}
{...attrs}
/>
);
});

HoverOpacity.displayName = 'HoverOpacity';

export default HoverOpacity;
6 changes: 3 additions & 3 deletions packages/dodoex-components/src/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const StyledInput = styled(Box)(({ theme }) => {
`;
});

export default forwardRef(function Input(
export default forwardRef<HTMLInputElement, InputProps>(function Input(
{
fullWidth,
error,
Expand All @@ -138,8 +138,8 @@ export default forwardRef(function Input(
dataTestId,
inputSx,
...attrs
}: InputProps,
ref: React.ForwardedRef<HTMLInputElement>,
},
ref,
) {
const InputBaseRootMemo = useCallback(
(props: any) => (
Expand Down
8 changes: 6 additions & 2 deletions packages/dodoex-components/src/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ const Popup = styled('div')`
z-index: 10;
`;

interface Props<T extends {} = SelectOption, Multiple extends boolean = false> extends SelectProps<T, Multiple> {
interface Props<T extends {} = SelectOption, Multiple extends boolean = false>
extends SelectProps<T, Multiple> {
options?: SelectOption[];
fullWidth?: boolean;
px?: number;
Expand All @@ -196,7 +197,10 @@ interface Props<T extends {} = SelectOption, Multiple extends boolean = false> e
sx?: BoxProps['sx'];
}

export function Select<Value = number | string, Multiple extends boolean = false>({
export function Select<
Value = number | string,
Multiple extends boolean = false,
>({
options,
fullWidth,
px = 20,
Expand Down
1 change: 1 addition & 0 deletions packages/dodoex-components/src/Tabs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
1 change: 1 addition & 0 deletions packages/dodoex-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export {
TabsButtonGroup,
TabButton,
TabListButton,
tabClasses,
} from './Tabs';
export { Skeleton } from './Skeleton';
export type { SkeletonProps } from './Skeleton';
Expand Down
2 changes: 1 addition & 1 deletion packages/dodoex-widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d9d4caf

Please sign in to comment.