From 59f30a1a453fe7156bc9346efe60673ccbc38c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?= <645381995@qq.com> Date: Wed, 20 Dec 2023 14:08:48 +0800 Subject: [PATCH] feat: React.Key to any --- src/MotionThumb.tsx | 2 +- src/index.tsx | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/MotionThumb.tsx b/src/MotionThumb.tsx index 1f17d24..faea6f9 100644 --- a/src/MotionThumb.tsx +++ b/src/MotionThumb.tsx @@ -10,7 +10,7 @@ type ThumbReact = { width: number; } | null; -export interface MotionThumbInterface { +export interface MotionThumbInterface { containerRef: React.RefObject; value: Value; getValueIndex: (value: Value) => number; diff --git a/src/index.tsx b/src/index.tsx index 7b60da6..6d82894 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -6,7 +6,7 @@ import * as React from 'react'; import MotionThumb from './MotionThumb'; -export interface SegmentedLabeledOption { +export interface SegmentedLabeledOption { className?: string; disabled?: boolean; label: React.ReactNode; @@ -17,12 +17,9 @@ export interface SegmentedLabeledOption { title?: string; } -type SegmentedOptions = ( - | Value - | SegmentedLabeledOption -)[]; +type SegmentedOptions = (Value | SegmentedLabeledOption)[]; -export interface SegmentedProps +export interface SegmentedProps extends Omit< React.HTMLProps, 'value' | 'defaultValue' | 'onChange' @@ -74,8 +71,8 @@ const InternalSegmentedOption: React.FC<{ checked: boolean; label: React.ReactNode; title?: string; - value: React.Key; - onChange: (e: React.ChangeEvent, value: React.Key) => void; + value: any; + onChange: (e: React.ChangeEvent, value: any) => void; }> = ({ prefixCls, className, @@ -153,7 +150,7 @@ const InternalSegmented: React.ForwardRefRenderFunction< const handleChange = ( event: React.ChangeEvent, - val: React.Key, + val: any, ) => { if (disabled) { return;