Create seprate props for ValueRotationButton
This commit is contained in:
@@ -27,8 +27,28 @@ interface DisplayData {
|
||||
|
||||
export type ValueToDisplayData<Value extends string | number> = Record<Value, DisplayData>;
|
||||
|
||||
export interface MultiValueButtonBaseProps<Value extends string | number, MultiValue extends Value | Value[] = Value> {
|
||||
export interface ValueRotationButtonBaseProps<Value extends string | number> {
|
||||
tooltip?: string;
|
||||
value: Value;
|
||||
defaultValue?: Value;
|
||||
values: Value[];
|
||||
setValue: (value: Value) => void;
|
||||
valueToDisplayData: ValueToDisplayData<Value>;
|
||||
}
|
||||
|
||||
export interface ValueRotationButtonDefaultableProps<Value extends string | number> extends OptionalProperty<
|
||||
ValueRotationButtonBaseProps<Value>,
|
||||
'value'
|
||||
> {
|
||||
isDefaultable?: boolean;
|
||||
onDefault?: () => void;
|
||||
}
|
||||
|
||||
export type ValueRotationButtonProps<Value extends string | number> =
|
||||
| (ValueRotationButtonBaseProps<Value> & PropertiesNever<ValueRotationButtonDefaultableProps<Value>>)
|
||||
| ValueRotationButtonDefaultableProps<Value>;
|
||||
|
||||
export interface MultiValueButtonBaseProps<Value extends string | number, MultiValue extends Value | Value[] = Value> {
|
||||
value: MultiValue;
|
||||
defaultValue?: Value;
|
||||
values: Value[];
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useMemo } from 'react';
|
||||
import Button from '@mui/material/Button';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
|
||||
import type { MultiValueButtonProps } from '@/base/Base.types.ts';
|
||||
import type { ValueRotationButtonProps } from '@/base/Base.types.ts';
|
||||
import { getNextRotationValue } from '@/base/utils/ValueRotationButton.utils.ts';
|
||||
import { Superscript } from '@/base/components/texts/Superscript.tsx';
|
||||
|
||||
@@ -25,7 +25,7 @@ export const ValueRotationButton = <Value extends string | number>({
|
||||
isDefaultable,
|
||||
onDefault,
|
||||
defaultIcon,
|
||||
}: MultiValueButtonProps<Value> & { defaultIcon?: ReactNode }) => {
|
||||
}: ValueRotationButtonProps<Value> & { defaultIcon?: ReactNode }) => {
|
||||
const { t } = useLingui();
|
||||
|
||||
const isDefault = value === undefined;
|
||||
|
||||
Reference in New Issue
Block a user