UNPKG

1.59 kBTypeScriptView Raw
1import { TextTypeKnob, NumberTypeKnob, ColorTypeKnob, BooleanTypeKnob, ObjectTypeKnob, SelectTypeKnob, RadiosTypeKnob, ArrayTypeKnob, DateTypeKnob, ButtonTypeOnClickProp, FileTypeKnob, OptionsTypeKnob, KnobType } from './components/types';
2export declare type Mutable<T> = {
3 -readonly [P in keyof T]: T[P] extends readonly (infer U)[] ? U[] : T[P];
4};
5declare type KnobPlus<T extends KnobType, K> = K & {
6 type: T;
7 groupId?: string;
8 disableDebounce?: boolean;
9 disableForceUpdate?: boolean;
10};
11export declare type Knob<T extends KnobType = any> = T extends 'text' ? KnobPlus<T, Pick<TextTypeKnob, 'value'>> : T extends 'boolean' ? KnobPlus<T, Pick<BooleanTypeKnob, 'value'>> : T extends 'number' ? KnobPlus<T, Pick<NumberTypeKnob, 'value' | 'range' | 'min' | 'max' | 'step'>> : T extends 'color' ? KnobPlus<T, Pick<ColorTypeKnob, 'value'>> : T extends 'object' ? KnobPlus<T, Pick<ObjectTypeKnob<any>, 'value'>> : T extends 'select' ? KnobPlus<T, Pick<SelectTypeKnob, 'value' | 'options'> & {
12 selectV2: true;
13}> : T extends 'radios' ? KnobPlus<T, Pick<RadiosTypeKnob, 'value' | 'options'>> : T extends 'array' ? KnobPlus<T, Pick<ArrayTypeKnob, 'value' | 'separator'>> : T extends 'date' ? KnobPlus<T, Pick<DateTypeKnob, 'value'>> : T extends 'files' ? KnobPlus<T, Pick<FileTypeKnob, 'value' | 'accept'>> : T extends 'button' ? KnobPlus<T, {
14 value?: never;
15 callback: ButtonTypeOnClickProp;
16 hideLabel: true;
17}> : T extends 'options' ? KnobPlus<T, Pick<OptionsTypeKnob<any>, 'options' | 'value' | 'optionsObj'>> : never;
18export { KnobType };