Skip to content

Commit

Permalink
feat: React.Key to any
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyair committed Dec 20, 2023
1 parent 4073184 commit 59f30a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/MotionThumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type ThumbReact = {
width: number;
} | null;

export interface MotionThumbInterface<Value = React.Key> {
export interface MotionThumbInterface<Value = any> {
containerRef: React.RefObject<HTMLDivElement>;
value: Value;
getValueIndex: (value: Value) => number;
Expand Down
15 changes: 6 additions & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as React from 'react';

import MotionThumb from './MotionThumb';

export interface SegmentedLabeledOption<Value = React.Key> {
export interface SegmentedLabeledOption<Value = any> {
className?: string;
disabled?: boolean;
label: React.ReactNode;
Expand All @@ -17,12 +17,9 @@ export interface SegmentedLabeledOption<Value = React.Key> {
title?: string;
}

type SegmentedOptions<Value = React.Key> = (
| Value
| SegmentedLabeledOption<Value>
)[];
type SegmentedOptions<Value = any> = (Value | SegmentedLabeledOption<Value>)[];

export interface SegmentedProps<Value = React.Key>
export interface SegmentedProps<Value = any>
extends Omit<
React.HTMLProps<HTMLDivElement>,
'value' | 'defaultValue' | 'onChange'
Expand Down Expand Up @@ -74,8 +71,8 @@ const InternalSegmentedOption: React.FC<{
checked: boolean;
label: React.ReactNode;
title?: string;
value: React.Key;
onChange: (e: React.ChangeEvent<HTMLInputElement>, value: React.Key) => void;
value: any;
onChange: (e: React.ChangeEvent<HTMLInputElement>, value: any) => void;
}> = ({
prefixCls,
className,
Expand Down Expand Up @@ -153,7 +150,7 @@ const InternalSegmented: React.ForwardRefRenderFunction<

const handleChange = (
event: React.ChangeEvent<HTMLInputElement>,
val: React.Key,
val: any,
) => {
if (disabled) {
return;

Check warning on line 156 in src/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/index.tsx#L156

Added line #L156 was not covered by tests
Expand Down

0 comments on commit 59f30a1

Please sign in to comment.