From c8a52ddb5ff628890817c9f73a2126fc2d0cf934 Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Thu, 11 Apr 2024 15:24:17 +0200 Subject: [PATCH] Add disabled property to control --- src/story.ts | 98 ++++++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/src/story.ts b/src/story.ts index 9d60b79..9a3f3ad 100644 --- a/src/story.ts +++ b/src/story.ts @@ -53,55 +53,63 @@ type ControlType = type ConditionalTest = { truthy?: boolean } | { exists: boolean } | { eq: any } | { neq: any }; type ConditionalValue = { arg: string } | { global: string }; export type Conditional = ConditionalValue & ConditionalTest; + +interface ControlBase { + /** + * @see https://storybook.js.org/docs/api/arg-types#controltype + */ + type: ControlType; + disable: boolean; +} + +type Control = + | ControlType + | false + | (ControlBase & + ( + | { + type: 'color'; + /** + * @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors + */ + presetColors?: string[]; + } + | { + 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; + } + )); + export interface InputType { /** * @see https://storybook.js.org/docs/api/arg-types#control */ - control?: - | ControlType - | { - /** - * @see https://storybook.js.org/docs/api/arg-types#controltype - */ - type: ControlType; - } - | { - type: 'color'; - /** - * @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors - */ - presetColors?: string[]; - } - | { - 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; + control?: Control; /** * @see https://storybook.js.org/docs/api/arg-types#description */