mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
a6a4326820
commit
55553322c8
@ -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>>;
|
||||
|
@ -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>>>;
|
||||
/**
|
||||
|
@ -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>
|
||||
);
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ReactElement } from 'react';
|
||||
|
||||
export interface SegmentProps<T> {
|
||||
export interface SegmentProps {
|
||||
Component?: ReactElement;
|
||||
className?: string;
|
||||
allowCustomValue?: boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user