Skip to content

Commit

Permalink
feat: t to value
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyair committed Dec 8, 2023
1 parent ee39834 commit 457691e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,31 @@ import * as React from 'react';

import MotionThumb from './MotionThumb';

export interface SegmentedLabeledOption<T = React.Key> {
export interface SegmentedLabeledOption<Value = React.Key> {
className?: string;
disabled?: boolean;
label: React.ReactNode;
value: T;
value: Value;
/**
* html `title` property for label
*/
title?: string;
}

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

export interface SegmentedProps<T = React.Key>
export interface SegmentedProps<Value = React.Key>
extends Omit<
React.HTMLProps<HTMLDivElement>,
'value' | 'defaultValue' | 'onChange'
> {
options: SegmentedOptions<T>;
defaultValue?: T;
value?: T;
onChange?: (value: T) => void;
options: SegmentedOptions<Value>;
defaultValue?: Value;
value?: Value;
onChange?: (value: Value) => void;
disabled?: boolean;
prefixCls?: string;
direction?: 'ltr' | 'rtl';
Expand Down Expand Up @@ -218,8 +221,8 @@ const InternalSegmented: React.ForwardRefRenderFunction<

const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
InternalSegmented,
) as (<Values = any>(
props: SegmentedProps<Values> & { ref?: React.Ref<HTMLDivElement> },
) as (<Value = any>(
props: SegmentedProps<Value> & { ref?: React.Ref<HTMLDivElement> },
) => React.ReactElement) & { displayName?: string };

if (process.env.NODE_ENV !== 'production') {
Expand Down

0 comments on commit 457691e

Please sign in to comment.