Skip to content

Commit

Permalink
Merge pull request #75 from Shinigami92/improve-input-type
Browse files Browse the repository at this point in the history
Improve InputType
  • Loading branch information
shilman authored Mar 14, 2024
2 parents cdc80df + 17be521 commit c372cc8
Showing 1 changed file with 120 additions and 3 deletions.
123 changes: 120 additions & 3 deletions src/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,129 @@ export interface StrictParameters {
[name: string]: unknown;
}

type ControlType =
| 'object'
| 'boolean'
| 'check'
| 'inline-check'
| 'radio'
| 'inline-radio'
| 'select'
| 'multi-select'
| 'number'
| 'range'
| 'file'
| 'color'
| 'date'
| 'text';

type ConditionalTest = { truthy?: boolean } | { exists: boolean } | { eq: any } | { neq: any };
type ConditionalValue = { arg: string } | { global: string };
export type Conditional = ConditionalValue & ConditionalTest;
export interface InputType {
name?: string;
/**
* @see https://storybook.js.org/docs/api/arg-types#control
*/
control?:
| ControlType
| {
/**

Check failure on line 63 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Insert `··`
* @see https://storybook.js.org/docs/api/arg-types#controltype

Check failure on line 64 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Insert `··`
*/

Check failure on line 65 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Insert `··`
type: ControlType;

Check failure on line 66 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Insert `··`
}

Check failure on line 67 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Insert `··`
| {
type: 'color';

Check failure on line 69 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Insert `··`
/**

Check failure on line 70 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Insert `··`
* @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors

Check failure on line 71 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Insert `··`
*/

Check failure on line 72 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Insert `··`
presetColors?: string[];

Check failure on line 73 in src/story.ts

View workflow job for this annotation

GitHub Actions / test

Replace `······` with `········`
}
| {
type: 'file';
/**
* @see https://storybook.js.org/docs/api/arg-types#controlaccept
*/
accept?: string;
}
| {
type: 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select';
/**
* @see https://storybook.js.org/docs/api/arg-types#controllabels
*/
labels?: { [options: string]: string };
}
| {
type: 'number' | 'range';
/**
* @see https://storybook.js.org/docs/api/arg-types#controlmax
*/
max?: number;
/**
* @see https://storybook.js.org/docs/api/arg-types#controlmin
*/
min?: number;
/**
* @see https://storybook.js.org/docs/api/arg-types#controlstep
*/
step?: number;
}
| false;
/**
* @see https://storybook.js.org/docs/api/arg-types#description
*/
description?: string;
defaultValue?: any;
type?: SBType | SBScalarType['name'];
/**
* @see https://storybook.js.org/docs/api/arg-types#if
*/
if?: Conditional;
/**
* @see https://storybook.js.org/docs/api/arg-types#mapping
*/
mapping?: { [key: string]: { [option: string]: any } };
/**
* @see https://storybook.js.org/docs/api/arg-types#name
*/
name?: string;
/**
* @see https://storybook.js.org/docs/api/arg-types#options
*/
options?: string[];
/**
* @see https://storybook.js.org/docs/api/arg-types#table
*/
table?: {
/**
* @see https://storybook.js.org/docs/api/arg-types#tablecategory
*/
category?: string;
/**
* @see https://storybook.js.org/docs/api/arg-types#tabledefaultvalue
*/
defaultValue?: { summary: string; detail?: string };
/**
* @see https://storybook.js.org/docs/api/arg-types#tabledisable
*/
disable?: boolean;
/**
* @see https://storybook.js.org/docs/api/arg-types#tablesubcategory
*/
subcategory?: string;
/**
* @see https://storybook.js.org/docs/api/arg-types#tabletype
*/
type?: { summary?: string; detail?: string };
};
/**
* @see https://storybook.js.org/docs/api/arg-types#type
*/
type?: SBType | SBScalarType['name'];
/**
* @see https://storybook.js.org/docs/api/arg-types#defaultvalue
*
* @deprecated Use `table.defaultValue.summary` instead.
*/
defaultValue?: any;
[key: string]: any;
}

Expand All @@ -59,6 +173,9 @@ export interface StrictArgs {
[name: string]: unknown;
}

/**
* @see https://storybook.js.org/docs/api/arg-types#argtypes
*/
export type ArgTypes<TArgs = Args> = { [name in keyof TArgs]: InputType };
export type StrictArgTypes<TArgs = Args> = { [name in keyof TArgs]: StrictInputType };

Expand Down

0 comments on commit c372cc8

Please sign in to comment.