Skip to content

Commit

Permalink
fix: ts type
Browse files Browse the repository at this point in the history
  • Loading branch information
liweijie0812 committed Dec 12, 2024
1 parent 3974706 commit bec7275
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import useDefaultProps from '../hooks/useDefaultProps';
import { radioDefaultProps } from './defaultProps';

export interface RadioProps extends TdRadioProps {
ref?: Ref<HTMLDivElement>;
ref?: Ref<HTMLInputElement>;
}

export interface RadioContextValue {
Expand All @@ -26,7 +26,7 @@ const getLimitRow = (row: number): CSSProperties => ({
WebkitLineClamp: row,
});

const Radio = forwardRef((_props: RadioProps, ref: Ref<HTMLDivElement>) => {
const Radio = forwardRef((_props: RadioProps, ref: Ref<HTMLInputElement>) => {
const radioClass = usePrefixClass('radio');
const inputRef = useRef();
const context = useContext(RadioContext);
Expand Down Expand Up @@ -153,6 +153,6 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref<HTMLDivElement>) => {
});

export default forwardRefWithStatics(
(props: RadioProps, ref: Ref<HTMLDivElement>) => <Radio ref={ref} {...props}></Radio>,
(props: RadioProps, ref: Ref<HTMLInputElement>) => <Radio ref={ref} {...props}></Radio>,
{ Group: RadioGroup },
);
3 changes: 1 addition & 2 deletions src/radio/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ const RadioGroup: FC<RadioGroupProps> = (props) => {
if (typeof radioProps.onChange === 'function') {
radioProps.onChange(checked, { e });
}
// @ts-ignore
setInternalValue(radioProps.value, { e });
setInternalValue(radioProps.value, { e, name: props.name });
},
};
},
Expand Down
2 changes: 1 addition & 1 deletion src/radio/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export interface TdRadioGroupProps<T = RadioValue> {
/**
* 选中值发生变化时触发, `context.name` 指 RadioGroup 的 name 属性
*/
onChange?: (value: T, context: { e: ChangeEvent<HTMLDivElement>; name?: string }) => void;
onChange?: (value: T, context: { e: ChangeEvent<HTMLInputElement>; name?: string }) => void;
}

export type RadioOption = string | number | RadioOptionObj;
Expand Down

0 comments on commit bec7275

Please sign in to comment.