mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Merge branch 'storybook__addon-knobs/4.0' of https://github.com/MLoughry/DefinitelyTyped into MLoughry-storybook__addon-knobs/4.0
This commit is contained in:
13
types/storybook__addon-knobs/index.d.ts
vendored
13
types/storybook__addon-knobs/index.d.ts
vendored
@@ -1,10 +1,11 @@
|
||||
// Type definitions for @storybook/addon-knobs 3.4
|
||||
// Type definitions for @storybook/addon-knobs 4.0
|
||||
// Project: https://github.com/storybooks/storybook
|
||||
// Definitions by: Joscha Feth <https://github.com/joscha>
|
||||
// Martynas Kadisa <https://github.com/martynaskadisa>
|
||||
// A.MacLeay <https://github.com/amacleay>
|
||||
// Michael Loughry <https://github.com/MLoughry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
import * as React from 'react';
|
||||
import { RenderFunction } from '@storybook/react';
|
||||
@@ -50,13 +51,11 @@ export function object<T>(name: string, value: T, groupId?: string): T;
|
||||
export function radios<T>(name: string, options: { [s: string]: T }, value?: T, groupId?: string): string;
|
||||
|
||||
export type SelectValue = string | number;
|
||||
export function select<T extends string>(name: string, options: { [s: string]: string }, value: T, groupId?: string): T;
|
||||
export function select<T extends number>(name: string, options: { [s: number]: string }, value: T, groupId?: string): T;
|
||||
export function select<T extends SelectValue>(name: string, options: { [s: string]: T }, value: T | ReadonlyArray<T>, groupId?: string): T;
|
||||
export function select<T extends SelectValue>(name: string, options: { [s: string]: ReadonlyArray<T> }, value: ReadonlyArray<T>, groupId?: string): T[];
|
||||
export function select<T extends SelectValue>(name: string, options: { [s: string]: T | ReadonlyArray<T> }, value: T | ReadonlyArray<T>, groupId?: string): T | T[];
|
||||
export function select<T extends SelectValue>(name: string, options: ReadonlyArray<T>, value: T, groupId?: string): T;
|
||||
|
||||
export function selectV2<T extends string | number>(name: string, options: { [s: string]: T | T[] }, value: T | T[], groupId?: string): T;
|
||||
export function selectV2<T extends SelectValue>(name: string, options: T[], value: T, groupId?: string): T;
|
||||
|
||||
export function date(name: string, value?: Date, groupId?: string): Date;
|
||||
|
||||
export function array<T>(name: string, value: ReadonlyArray<T>, separator?: string, groupId?: string): T[];
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
array,
|
||||
button,
|
||||
knob,
|
||||
selectV2,
|
||||
radios,
|
||||
} from '@storybook/addon-knobs';
|
||||
|
||||
@@ -38,9 +37,9 @@ stories.add('with all knobs', () => {
|
||||
const comfortTemp = number('Comfort Temp', 72, { range: true, min: 60, max: 90, step: 1 });
|
||||
const radioStation = radios('Favorite Radio Station', { 1100: "1100", 2200: "2200", 3300: "3300" });
|
||||
const textDecoration = select('Decoration', {
|
||||
none: 'None',
|
||||
underline: 'Underline',
|
||||
'line-through': 'Line-Through'
|
||||
None: 'none',
|
||||
Underline: 'underline',
|
||||
'Line-through': 'line-through'
|
||||
}, 'none');
|
||||
|
||||
const customStyle = object('Style', {
|
||||
@@ -52,15 +51,12 @@ stories.add('with all knobs', () => {
|
||||
|
||||
type X = 'a' | 'b';
|
||||
|
||||
const genericSelect: X = select<X>('Some generic select', { a: 'type a', b: 'type b' }, 'b');
|
||||
|
||||
const enumSelectOptions: { [s: number]: string } = {};
|
||||
enumSelectOptions[SomeEnum.Type1] = "Type 1";
|
||||
enumSelectOptions[SomeEnum.Type2] = "Type 2";
|
||||
const genericSelect2: SomeEnum = select<SomeEnum>('Some generic select', enumSelectOptions, SomeEnum.Type1);
|
||||
|
||||
const genericSelectV2: X = selectV2<X>('Some generic select', { 'type a': 'a', 'type b': 'b' }, 'b');
|
||||
const genericSelectV2Enum: SomeEnum = selectV2<SomeEnum>('Some generic select v2', { 'type a': SomeEnum.Type1, 'type b': SomeEnum.Type2 }, SomeEnum.Type2);
|
||||
const genericSelectV2: X = select<X>('Some generic select', { 'type a': 'a', 'type b': 'b' }, 'b');
|
||||
const genericSelectV2Enum: SomeEnum = select<SomeEnum>('Some generic select v2', { 'type a': SomeEnum.Type1, 'type b': SomeEnum.Type2 }, SomeEnum.Type2);
|
||||
|
||||
const genericArray: string[] = array<string>('Some generic array', ['red', 'green', 'blue']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user