Design System: Remove unused type parameter in SegmentProps and SegmentInput (#64919)

* fix: Remove unused type parameter in `SegmentProps` and `SegmentInput`

* lint: prettier auto fix

* fix( SegmentInput.story.tsx ): adapt to changes
This commit is contained in:
Mofeng 2023-04-06 21:32:39 +08:00 committed by GitHub
parent a6a4326820
commit 55553322c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 12 deletions

View File

@ -11,7 +11,7 @@ import { getSegmentStyles } from './styles';
import { SegmentSelect, useExpandableLabel, SegmentProps } from './';
export interface SegmentSyncProps<T> extends SegmentProps<T>, Omit<HTMLProps<HTMLDivElement>, 'value' | 'onChange'> {
export interface SegmentSyncProps<T> extends SegmentProps, Omit<HTMLProps<HTMLDivElement>, 'value' | 'onChange'> {
value?: T | SelectableValue<T>;
onChange: (item: SelectableValue<T>) => void;
options: Array<SelectableValue<T>>;

View File

@ -15,7 +15,7 @@ import { getSegmentStyles } from './styles';
import { useExpandableLabel, SegmentProps } from '.';
export interface SegmentAsyncProps<T> extends SegmentProps<T>, Omit<HTMLProps<HTMLDivElement>, 'value' | 'onChange'> {
export interface SegmentAsyncProps<T> extends SegmentProps, Omit<HTMLProps<HTMLDivElement>, 'value' | 'onChange'> {
value?: T | SelectableValue<T>;
loadOptions: (query?: string) => Promise<Array<SelectableValue<T>>>;
/**

View File

@ -100,12 +100,10 @@ export const InputWithAutoFocus = () => {
);
};
export const Basic: ComponentStory<React.ComponentType<SegmentInputProps<string | number>>> = (
args: SegmentInputProps<string | number>
) => {
export const Basic: ComponentStory<React.ComponentType<SegmentInputProps>> = (args: SegmentInputProps) => {
const [value, setValue] = useState(args.value);
const props: SegmentInputProps<string | number> = {
const props: SegmentInputProps = {
...args,
value,
onChange: (value) => {
@ -117,7 +115,7 @@ export const Basic: ComponentStory<React.ComponentType<SegmentInputProps<string
return (
<SegmentSection label="Segment:">
<SegmentInput<string | number> {...props} />
<SegmentInput {...props} />
</SegmentSection>
);
};

View File

@ -10,8 +10,8 @@ import { getSegmentStyles } from './styles';
import { useExpandableLabel, SegmentProps } from '.';
export interface SegmentInputProps<T>
extends Omit<SegmentProps<T>, 'allowCustomValue' | 'allowEmptyValue'>,
export interface SegmentInputProps
extends Omit<SegmentProps, 'allowCustomValue' | 'allowEmptyValue'>,
Omit<HTMLProps<HTMLInputElement>, 'value' | 'onChange'> {
value: string | number;
onChange: (text: string | number) => void;
@ -19,7 +19,7 @@ export interface SegmentInputProps<T>
const FONT_SIZE = 14;
export function SegmentInput<T>({
export function SegmentInput({
value: initialValue,
onChange,
Component,
@ -30,7 +30,7 @@ export function SegmentInput<T>({
autofocus = false,
onExpandedChange,
...rest
}: React.PropsWithChildren<SegmentInputProps<T>>) {
}: React.PropsWithChildren<SegmentInputProps>) {
const ref = useRef<HTMLInputElement>(null);
const [value, setValue] = useState<number | string>(initialValue);
const [inputWidth, setInputWidth] = useState<number>(measureText((initialValue || '').toString(), FONT_SIZE).width);

View File

@ -1,6 +1,6 @@
import { ReactElement } from 'react';
export interface SegmentProps<T> {
export interface SegmentProps {
Component?: ReactElement;
className?: string;
allowCustomValue?: boolean;