index.d.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. import { Conditional, DocsContextProps, PreparedStory, ModuleExports, ModuleExport, Parameters as Parameters$1, StrictArgTypes, Renderer as Renderer$1, Args as Args$1, StoryId, StoryContextForLoaders, StoryAnnotations, ResolvedModuleExportType, ResolvedModuleExportFromType, ProjectAnnotations, BaseAnnotations, ComponentTitle } from '@storybook/types';
  2. export { DocsContextProps } from '@storybook/types';
  3. import React, { ComponentProps, FunctionComponent, ReactNode, FC, PropsWithChildren, Context } from 'react';
  4. import { Renderer } from '@storybook/csf';
  5. import { PropDescriptor } from '@storybook/preview-api';
  6. import { SyntaxHighlighter, ActionItem, SyntaxHighlighterFormatTypes } from '@storybook/components';
  7. import { SourceType } from '@storybook/docs-tools';
  8. import { Channel } from '@storybook/channels';
  9. import { ThemeVars } from '@storybook/theming';
  10. import PureMarkdown from 'markdown-to-jsx';
  11. declare enum SourceError {
  12. NO_STORY = "There\u2019s no story here.",
  13. SOURCE_UNAVAILABLE = "Oh no! The source is not available."
  14. }
  15. interface SourceCodeProps {
  16. /**
  17. * The language the syntax highlighter uses for your story’s code
  18. */
  19. language?: string;
  20. /**
  21. * Use this to override the content of the source block.
  22. */
  23. code?: string;
  24. /**
  25. * The (prettier) formatter the syntax highlighter uses for your story’s code.
  26. */
  27. format?: ComponentProps<typeof SyntaxHighlighter>['format'];
  28. /**
  29. * Display the source snippet in a dark mode.
  30. */
  31. dark?: boolean;
  32. }
  33. interface SourceProps$1 extends SourceCodeProps {
  34. isLoading?: boolean;
  35. error?: SourceError;
  36. }
  37. /**
  38. * Syntax-highlighted source code for a component (or anything!)
  39. */
  40. declare const Source$1: FunctionComponent<SourceProps$1>;
  41. interface PreviewProps {
  42. isLoading?: true;
  43. layout?: Layout;
  44. isColumn?: boolean;
  45. columns?: number;
  46. withSource?: SourceProps$1;
  47. isExpanded?: boolean;
  48. withToolbar?: boolean;
  49. className?: string;
  50. additionalActions?: ActionItem[];
  51. children?: ReactNode;
  52. }
  53. type Layout = 'padded' | 'fullscreen' | 'centered';
  54. interface ArgType {
  55. name?: string;
  56. description?: string;
  57. defaultValue?: any;
  58. if?: Conditional;
  59. [key: string]: any;
  60. }
  61. interface ArgTypes$1 {
  62. [key: string]: ArgType;
  63. }
  64. interface Args {
  65. [key: string]: any;
  66. }
  67. type Globals = {
  68. [name: string]: any;
  69. };
  70. declare enum ArgsTableError {
  71. NO_COMPONENT = "No component found.",
  72. ARGS_UNSUPPORTED = "Args unsupported. See Args documentation for your framework."
  73. }
  74. type SortType = 'alpha' | 'requiredFirst' | 'none';
  75. interface ArgsTableOptionProps {
  76. children?: React.ReactNode;
  77. updateArgs?: (args: Args) => void;
  78. resetArgs?: (argNames?: string[]) => void;
  79. compact?: boolean;
  80. inAddonPanel?: boolean;
  81. initialExpandedArgs?: boolean;
  82. isLoading?: boolean;
  83. sort?: SortType;
  84. }
  85. interface ArgsTableDataProps {
  86. rows: ArgTypes$1;
  87. args?: Args;
  88. globals?: Globals;
  89. }
  90. interface ArgsTableErrorProps {
  91. error: ArgsTableError;
  92. }
  93. interface ArgsTableLoadingProps {
  94. isLoading: boolean;
  95. }
  96. type ArgsTableProps$1 = ArgsTableOptionProps & (ArgsTableDataProps | ArgsTableErrorProps | ArgsTableLoadingProps);
  97. /**
  98. * Display the props for a component as a props table. Each row is a collection of
  99. * ArgDefs, usually derived from docgen info for the component.
  100. */
  101. declare const ArgsTable$1: FC<ArgsTableProps$1>;
  102. interface CommonProps {
  103. story: PreparedStory;
  104. inline: boolean;
  105. primary: boolean;
  106. }
  107. interface InlineStoryProps extends CommonProps {
  108. inline: true;
  109. height?: string;
  110. autoplay: boolean;
  111. forceInitialArgs: boolean;
  112. renderStoryToElement: DocsContextProps['renderStoryToElement'];
  113. }
  114. interface IFrameStoryProps extends CommonProps {
  115. inline: false;
  116. height: string;
  117. }
  118. type StoryProps$2 = InlineStoryProps | IFrameStoryProps;
  119. /**
  120. * A story element, either rendered inline or in an iframe,
  121. * with configurable height.
  122. */
  123. declare const Story$1: FunctionComponent<StoryProps$2>;
  124. interface TypesetProps {
  125. fontFamily?: string;
  126. fontSizes: string[];
  127. fontWeight?: number;
  128. sampleText?: string;
  129. }
  130. /**
  131. * Convenient styleguide documentation showing examples of type
  132. * with different sizes and weights and configurable sample text.
  133. */
  134. declare const Typeset: FC<TypesetProps>;
  135. type Colors = string[] | {
  136. [key: string]: string;
  137. };
  138. interface ColorItemProps {
  139. title: string;
  140. subtitle: string;
  141. colors: Colors;
  142. }
  143. /**
  144. * A single color row your styleguide showing title, subtitle and one or more colors, used
  145. * as a child of `ColorPalette`.
  146. */
  147. declare const ColorItem: FunctionComponent<ColorItemProps>;
  148. interface ColorPaletteProps {
  149. children?: React.ReactNode;
  150. }
  151. /**
  152. * Styleguide documentation for colors, including names, captions, and color swatches,
  153. * all specified as `ColorItem` children of this wrapper component.
  154. */
  155. declare const ColorPalette: FunctionComponent<ColorPaletteProps>;
  156. interface IconItemProps {
  157. name: string;
  158. children?: React.ReactNode;
  159. }
  160. /**
  161. * An individual icon with a caption and an example (passed as `children`).
  162. */
  163. declare const IconItem: FunctionComponent<IconItemProps>;
  164. interface IconGalleryProps {
  165. children?: React.ReactNode;
  166. }
  167. /**
  168. * Show a grid of icons, as specified by `IconItem`.
  169. */
  170. declare const IconGallery: FunctionComponent<IconGalleryProps>;
  171. declare const anchorBlockIdFromId: (storyId: string) => string;
  172. interface AnchorProps {
  173. storyId: string;
  174. }
  175. declare const Anchor: FC<PropsWithChildren<AnchorProps>>;
  176. type ArgTypesParameters = {
  177. include?: PropDescriptor;
  178. exclude?: PropDescriptor;
  179. sort?: SortType;
  180. };
  181. type ArgTypesProps = ArgTypesParameters & {
  182. of?: Renderer['component'] | ModuleExports;
  183. };
  184. declare const ArgTypes: FC<ArgTypesProps>;
  185. declare const PRIMARY_STORY = "^";
  186. type Component = any;
  187. type DocsStoryProps = {
  188. of: ModuleExport;
  189. expanded?: boolean;
  190. withToolbar?: boolean;
  191. __forceInitialArgs?: boolean;
  192. __primary?: boolean;
  193. };
  194. interface BaseProps {
  195. include?: PropDescriptor;
  196. exclude?: PropDescriptor;
  197. sort?: SortType;
  198. }
  199. type OfProps = BaseProps & {
  200. of: '^' | Component;
  201. };
  202. type ComponentsProps = BaseProps & {
  203. parameters: Parameters$1;
  204. components: {
  205. [label: string]: Component;
  206. };
  207. };
  208. type StoryProps$1 = BaseProps & {
  209. story: '.' | '^' | string;
  210. showComponent?: boolean;
  211. };
  212. type ArgsTableProps = BaseProps | OfProps | ComponentsProps | StoryProps$1;
  213. declare const extractComponentArgTypes: (component: Component, parameters: Parameters$1, include?: PropDescriptor, exclude?: PropDescriptor) => StrictArgTypes;
  214. declare const getComponent: (props: ArgsTableProps, component: Component) => Component;
  215. declare const StoryTable: FC<StoryProps$1 & {
  216. component: Component;
  217. subcomponents: Record<string, Component>;
  218. }>;
  219. declare const ComponentsTable: FC<ComponentsProps>;
  220. declare const ArgsTable: FC<ArgsTableProps>;
  221. declare const DocsContext: Context<DocsContextProps<Renderer$1>>;
  222. type ArgsHash = string;
  223. declare function argsHash(args: Args$1): ArgsHash;
  224. interface SourceItem {
  225. code: string;
  226. format?: SyntaxHighlighterFormatTypes;
  227. }
  228. type StorySources = Record<StoryId, Record<ArgsHash, SourceItem>>;
  229. interface SourceContextProps {
  230. sources: StorySources;
  231. setSource?: (id: StoryId, item: SourceItem) => void;
  232. }
  233. declare const SourceContext: Context<SourceContextProps>;
  234. declare const UNKNOWN_ARGS_HASH = "--unknown--";
  235. declare const SourceContainer: FC<PropsWithChildren<{
  236. channel: Channel;
  237. }>>;
  238. declare enum SourceState {
  239. OPEN = "open",
  240. CLOSED = "closed",
  241. NONE = "none"
  242. }
  243. type SourceParameters = SourceCodeProps & {
  244. /**
  245. * Where to read the source code from, see `SourceType`
  246. */
  247. type?: SourceType;
  248. /**
  249. * Transform the detected source for display
  250. *
  251. * @deprecated use `transform` prop instead
  252. */
  253. transformSource?: (code: string, storyContext: StoryContextForLoaders) => string;
  254. /**
  255. * Transform the detected source for display
  256. */
  257. transform?: (code: string, storyContext: StoryContextForLoaders) => string;
  258. /**
  259. * Internal: set by our CSF loader (`enrichCsf` in `@storybook/csf-tools`).
  260. */
  261. originalSource?: string;
  262. };
  263. type SourceProps = SourceParameters & {
  264. /**
  265. * Pass the export defining a story to render its source
  266. *
  267. * ```jsx
  268. * import { Source } from '@storybook/blocks';
  269. * import * as ButtonStories from './Button.stories';
  270. *
  271. * <Source of={ButtonStories.Primary} />
  272. * ```
  273. */
  274. of?: ModuleExport;
  275. /** @deprecated use of={storyExport} instead */
  276. id?: string;
  277. /** @deprecated use of={storyExport} instead */
  278. ids?: string[];
  279. /**
  280. * Internal prop to control if a story re-renders on args updates
  281. */
  282. __forceInitialArgs?: boolean;
  283. };
  284. type SourceStateProps = {
  285. state: SourceState;
  286. };
  287. type PureSourceProps = ComponentProps<typeof Source$1>;
  288. declare const useSourceProps: (props: SourceProps, docsContext: DocsContextProps<any>, sourceContext: SourceContextProps) => PureSourceProps & SourceStateProps;
  289. /**
  290. * Story source doc block renders source code if provided,
  291. * or the source for a story if `storyId` is provided, or
  292. * the source for the current story if nothing is provided.
  293. */
  294. declare const Source: FC<SourceProps>;
  295. type PureStoryProps = ComponentProps<typeof Story$1>;
  296. /**
  297. * Props to define a story
  298. *
  299. * @deprecated Define stories in CSF files
  300. */
  301. type StoryDefProps = StoryAnnotations;
  302. /**
  303. * Props to reference another story
  304. */
  305. type StoryRefProps = {
  306. /**
  307. * @deprecated Use of={storyExport} instead
  308. */
  309. id?: string;
  310. /**
  311. * @deprecated Use of={storyExport} and define the story in the CSF file
  312. */
  313. story?: StoryAnnotations;
  314. /**
  315. * Pass the export defining a story to render that story
  316. *
  317. * ```jsx
  318. * import { Meta, Story } from '@storybook/blocks';
  319. * import * as ButtonStories from './Button.stories';
  320. *
  321. * <Meta of={ButtonStories} />
  322. * <Story of={ButtonStories.Primary} />
  323. * ```
  324. */
  325. of?: ModuleExport;
  326. /**
  327. * Pass all exports of the CSF file if this MDX file is unattached
  328. *
  329. * ```jsx
  330. * import { Story } from '@storybook/blocks';
  331. * import * as ButtonStories from './Button.stories';
  332. *
  333. * <Story of={ButtonStories.Primary} meta={ButtonStories} />
  334. * ```
  335. */
  336. meta?: ModuleExports;
  337. };
  338. type StoryParameters = {
  339. /**
  340. * Render the story inline or in an iframe
  341. */
  342. inline?: boolean;
  343. /**
  344. * When rendering in an iframe (`inline={false}`), set the story height
  345. */
  346. height?: string;
  347. /**
  348. * Whether to run the story's play function
  349. */
  350. autoplay?: boolean;
  351. /**
  352. * Internal prop to control if a story re-renders on args updates
  353. */
  354. __forceInitialArgs?: boolean;
  355. /**
  356. * Internal prop if this story is the primary story
  357. */
  358. __primary?: boolean;
  359. };
  360. type StoryProps = (StoryDefProps | StoryRefProps) & StoryParameters;
  361. declare const getStoryId: (props: StoryProps, context: DocsContextProps) => StoryId;
  362. declare const getStoryProps: <TFramework extends Renderer$1>(props: StoryParameters, story: PreparedStory<TFramework>, context: DocsContextProps<TFramework>) => PureStoryProps;
  363. declare const Story: FC<StoryProps>;
  364. type DeprecatedCanvasProps = {
  365. /**
  366. * @deprecated multiple stories are not supported
  367. */
  368. isColumn?: boolean;
  369. /**
  370. * @deprecated multiple stories are not supported
  371. */
  372. columns?: number;
  373. /**
  374. * @deprecated use `sourceState` instead
  375. */
  376. withSource?: SourceState;
  377. /**
  378. * @deprecated use `source.code` instead
  379. */
  380. mdxSource?: string;
  381. /**
  382. * @deprecated reference stories with the `of` prop instead
  383. */
  384. children?: ReactNode;
  385. };
  386. type CanvasProps = Pick<PreviewProps, 'withToolbar' | 'additionalActions' | 'className'> & {
  387. /**
  388. * Pass the export defining a story to render that story
  389. *
  390. * ```jsx
  391. * import { Meta, Canvas } from '@storybook/blocks';
  392. * import * as ButtonStories from './Button.stories';
  393. *
  394. * <Meta of={ButtonStories} />
  395. * <Canvas of={ButtonStories.Primary} />
  396. * ```
  397. */
  398. of?: ModuleExport;
  399. /**
  400. * Pass all exports of the CSF file if this MDX file is unattached
  401. *
  402. * ```jsx
  403. * import { Canvas } from '@storybook/blocks';
  404. * import * as ButtonStories from './Button.stories';
  405. *
  406. * <Canvas of={ButtonStories.Primary} meta={ButtonStories} />
  407. * ```
  408. */
  409. meta?: ModuleExports;
  410. /**
  411. * Specify the initial state of the source panel
  412. * hidden: the source panel is hidden by default
  413. * shown: the source panel is shown by default
  414. * none: the source panel is not available and the button to show it is hidden
  415. * @default 'hidden'
  416. */
  417. sourceState?: 'hidden' | 'shown' | 'none';
  418. /**
  419. * how to layout the story within the canvas
  420. * padded: the story has padding within the canvas
  421. * fullscreen: the story is rendered edge to edge within the canvas
  422. * centered: the story is centered within the canvas
  423. * @default 'padded'
  424. */
  425. layout?: Layout;
  426. /**
  427. * @see {SourceProps}
  428. */
  429. source?: Omit<SourceProps, 'dark'>;
  430. /**
  431. * @see {StoryProps}
  432. */
  433. story?: Pick<StoryProps, 'inline' | 'height' | 'autoplay' | '__forceInitialArgs' | '__primary'>;
  434. };
  435. declare const Canvas: FC<CanvasProps & DeprecatedCanvasProps>;
  436. type ControlsParameters = {
  437. include?: PropDescriptor;
  438. exclude?: PropDescriptor;
  439. sort?: SortType;
  440. };
  441. type ControlsProps = ControlsParameters & {
  442. of?: Renderer['component'] | ModuleExports;
  443. };
  444. declare const Controls: FC<ControlsProps>;
  445. type Of = Parameters<DocsContextProps['resolveOf']>[0];
  446. /**
  447. * A hook to resolve the `of` prop passed to a block.
  448. * will return the resolved module
  449. * if the resolved module is a meta it will include a preparedMeta property similar to a preparedStory
  450. * if the resolved module is a component it will include the project annotations
  451. */
  452. declare const useOf: <TType extends ResolvedModuleExportType>(moduleExportOrType: Of, validTypes?: TType[]) => ResolvedModuleExportFromType<TType>;
  453. declare enum DescriptionType {
  454. INFO = "info",
  455. NOTES = "notes",
  456. DOCGEN = "docgen",
  457. AUTO = "auto"
  458. }
  459. interface DescriptionProps {
  460. /**
  461. * Specify where to get the description from. Can be a component, a CSF file or a story.
  462. * If not specified, the description will be extracted from the meta of the attached CSF file.
  463. */
  464. of?: Of;
  465. /**
  466. * @deprecated Manually specifying description type is deprecated. See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#description-block-parametersnotes-and-parametersinfo
  467. */
  468. type?: DescriptionType;
  469. /**
  470. * @deprecated The 'markdown' prop on the Description block is deprecated. See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#description-block-parametersnotes-and-parametersinfo
  471. */
  472. markdown?: string;
  473. /**
  474. * @deprecated The 'children' prop on the Description block is deprecated. See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#description-block-parametersnotes-and-parametersinfo
  475. */
  476. children?: string;
  477. }
  478. declare const DescriptionContainer: FC<DescriptionProps>;
  479. type DocsProps<TRenderer extends Renderer$1 = Renderer$1> = {
  480. docsParameter: Parameters$1;
  481. context: DocsContextProps<TRenderer>;
  482. };
  483. declare function Docs<TRenderer extends Renderer$1 = Renderer$1>({ context, docsParameter, }: DocsProps<TRenderer>): React.JSX.Element;
  484. declare const DocsPage: FC;
  485. interface DocsContainerProps<TFramework extends Renderer$1 = Renderer$1> {
  486. context: DocsContextProps<TFramework>;
  487. theme?: ThemeVars;
  488. }
  489. declare const DocsContainer: FC<PropsWithChildren<DocsContainerProps>>;
  490. declare const DocsStory: FC<DocsStoryProps>;
  491. type ExternalDocsProps<TRenderer extends Renderer$1 = Renderer$1> = {
  492. projectAnnotationsList: ProjectAnnotations<TRenderer>[];
  493. };
  494. declare function ExternalDocs<TRenderer extends Renderer$1 = Renderer$1>({ projectAnnotationsList, children, }: PropsWithChildren<ExternalDocsProps<TRenderer>>): React.JSX.Element;
  495. declare const ExternalDocsContainer: React.FC<{
  496. projectAnnotations: any;
  497. }>;
  498. interface HeadingProps {
  499. disableAnchor?: boolean;
  500. }
  501. declare const Heading: FC<PropsWithChildren<HeadingProps>>;
  502. type MarkdownProps = typeof PureMarkdown extends React.ComponentType<infer Props> ? Props : never;
  503. declare const Markdown: (props: MarkdownProps) => React.JSX.Element;
  504. type MetaProps = BaseAnnotations & {
  505. of?: ModuleExports;
  506. title?: string;
  507. };
  508. /**
  509. * This component is used to declare component metadata in docs
  510. * and gets transformed into a default export underneath the hood.
  511. */
  512. declare const Meta: FC<MetaProps>;
  513. interface PrimaryProps {
  514. /**
  515. * @deprecated Primary block should only be used to render the primary story, which is automatically found.
  516. */
  517. name?: string;
  518. /**
  519. * Specify where to get the primary story from.
  520. */
  521. of?: Of;
  522. }
  523. declare const Primary: FC<PrimaryProps>;
  524. interface StoriesProps {
  525. title?: JSX.Element | string;
  526. includePrimary?: boolean;
  527. }
  528. declare const Stories: FC<StoriesProps>;
  529. declare const Subheading: FC<PropsWithChildren<HeadingProps>>;
  530. interface SubtitleProps {
  531. children?: ReactNode;
  532. }
  533. declare const Subtitle: FunctionComponent<SubtitleProps>;
  534. interface TitleProps {
  535. children?: ReactNode;
  536. }
  537. declare const extractTitle: (title: ComponentTitle) => string;
  538. declare const Title: FunctionComponent<TitleProps>;
  539. declare const Unstyled: React.FC<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
  540. declare const Wrapper: FC<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
  541. declare const assertIsFn: (val: any) => any;
  542. declare const AddContext: FC<DocsContextProps>;
  543. interface CodeOrSourceMdxProps {
  544. className?: string;
  545. }
  546. declare const CodeOrSourceMdx: FC<CodeOrSourceMdxProps>;
  547. interface AnchorMdxProps {
  548. href: string;
  549. target: string;
  550. }
  551. declare const AnchorMdx: FC<PropsWithChildren<AnchorMdxProps>>;
  552. interface HeaderMdxProps {
  553. as: string;
  554. id: string;
  555. }
  556. declare const HeaderMdx: FC<PropsWithChildren<HeaderMdxProps>>;
  557. declare const HeadersMdx: {};
  558. interface ControlProps<T> {
  559. name: string;
  560. value?: T;
  561. defaultValue?: T;
  562. argType?: ArgType;
  563. onChange: (value: T) => T | void;
  564. onFocus?: (evt: any) => void;
  565. onBlur?: (evt: any) => void;
  566. }
  567. type BooleanValue = boolean;
  568. interface BooleanConfig {
  569. }
  570. type ColorValue = string;
  571. type PresetColor = ColorValue | {
  572. color: ColorValue;
  573. title?: string;
  574. };
  575. interface ColorConfig {
  576. presetColors?: PresetColor[];
  577. /**
  578. * Whether the color picker should be open by default when rendered.
  579. * @default false
  580. */
  581. startOpen?: boolean;
  582. }
  583. type DateValue = Date | number;
  584. interface DateConfig {
  585. }
  586. type NumberValue = number;
  587. interface NumberConfig {
  588. min?: number;
  589. max?: number;
  590. step?: number;
  591. }
  592. type RangeConfig = NumberConfig;
  593. type ObjectValue = any;
  594. interface ObjectConfig {
  595. }
  596. type OptionsSingleSelection = any;
  597. type OptionsMultiSelection = any[];
  598. type OptionsSelection = OptionsSingleSelection | OptionsMultiSelection;
  599. type OptionsArray = any[];
  600. type OptionsObject = Record<string, any>;
  601. type Options = OptionsArray | OptionsObject;
  602. type OptionsControlType = 'radio' | 'inline-radio' | 'check' | 'inline-check' | 'select' | 'multi-select';
  603. interface OptionsConfig {
  604. labels: Record<any, string>;
  605. type: OptionsControlType;
  606. }
  607. interface NormalizedOptionsConfig {
  608. options: OptionsObject;
  609. }
  610. type TextValue = string;
  611. interface TextConfig {
  612. maxLength?: number;
  613. }
  614. type ControlType = 'array' | 'boolean' | 'color' | 'date' | 'number' | 'range' | 'object' | OptionsControlType | 'text';
  615. type Control = BooleanConfig | ColorConfig | DateConfig | NumberConfig | ObjectConfig | OptionsConfig | RangeConfig | TextConfig;
  616. type ColorControlProps = ControlProps<ColorValue> & ColorConfig;
  617. type BooleanProps = ControlProps<BooleanValue> & BooleanConfig;
  618. /**
  619. * # Boolean Control
  620. * Renders a switch toggle with "True" or "False".
  621. * or if the value is `undefined`, renders a button to set the boolean.
  622. *
  623. * ## Example usage
  624. *
  625. * ```
  626. *
  627. * <BooleanControl name="isTrue" value={value} onChange={handleValueChange}/>
  628. * ```
  629. */
  630. declare const BooleanControl: FC<BooleanProps>;
  631. declare const parseDate: (value: string) => Date;
  632. declare const parseTime: (value: string) => Date;
  633. declare const formatDate: (value: Date | number) => string;
  634. declare const formatTime: (value: Date | number) => string;
  635. type DateProps = ControlProps<DateValue> & DateConfig;
  636. declare const DateControl: FC<DateProps>;
  637. type NumberProps = ControlProps<NumberValue | null> & NumberConfig;
  638. declare const parse: (value: string) => number;
  639. declare const format: (value: NumberValue) => string;
  640. declare const NumberControl: FC<NumberProps>;
  641. type OptionsProps = ControlProps<OptionsSelection> & OptionsConfig;
  642. declare const OptionsControl: FC<OptionsProps>;
  643. type ObjectProps = ControlProps<ObjectValue> & ObjectConfig & {
  644. theme: any;
  645. };
  646. declare const ObjectControl: FC<ObjectProps>;
  647. type RangeProps = ControlProps<NumberValue | null> & RangeConfig;
  648. declare const RangeControl: FC<RangeProps>;
  649. type TextProps = ControlProps<TextValue | undefined> & TextConfig;
  650. declare const TextControl: FC<TextProps>;
  651. interface FilesControlProps extends ControlProps<string[]> {
  652. /**
  653. * The accept attribute value is a string that defines the file types the file input should accept. This string is a comma-separated list of unique file type specifiers.
  654. * @example
  655. * *\/*
  656. * @example
  657. * .webm,video/webm
  658. * @example
  659. * .doc,.docx,application/msword
  660. * @defaultValue `image/*`
  661. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept
  662. */
  663. accept?: string;
  664. }
  665. declare const FilesControl: FC<FilesControlProps>;
  666. type ColorProps = ColorControlProps;
  667. declare const LazyColorControl: React.LazyExoticComponent<React.FC<ColorControlProps>>;
  668. declare const ColorControl: (props: ComponentProps<typeof LazyColorControl>) => React.JSX.Element;
  669. export { AddContext, Anchor, AnchorMdx, AnchorProps, ArgTypes, ArgsTable, BooleanConfig, BooleanControl, BooleanProps, BooleanValue, Canvas, CodeOrSourceMdx, ColorConfig, ColorControl, ColorItem, ColorPalette, ColorProps, ColorValue, Component, ComponentsTable, Control, ControlProps, ControlType, Controls, DateConfig, DateControl, DateProps, DateValue, DescriptionContainer as Description, DescriptionType, Docs, DocsContainer, DocsContainerProps, DocsContext, DocsPage, DocsProps, DocsStory, DocsStoryProps, ExternalDocs, ExternalDocsContainer, ExternalDocsProps, FilesControl, FilesControlProps, HeaderMdx, HeadersMdx, Heading, HeadingProps, IconGallery, IconItem, Markdown, Meta, NormalizedOptionsConfig, NumberConfig, NumberControl, NumberValue, ObjectConfig, ObjectControl, ObjectProps, ObjectValue, Of, Options, OptionsArray, OptionsConfig, OptionsControl, OptionsControlType, OptionsMultiSelection, OptionsObject, OptionsProps, OptionsSelection, OptionsSingleSelection, PRIMARY_STORY, PresetColor, Primary, ArgsTable$1 as PureArgsTable, RangeConfig, RangeControl, SortType, Source, SourceContainer, SourceContext, SourceContextProps, SourceItem, SourceProps, SourceState, Stories, Story, StoryProps, StorySources, StoryTable, Subheading, Subtitle, TextConfig, TextControl, TextProps, TextValue, Title, Typeset, UNKNOWN_ARGS_HASH, Unstyled, Wrapper, anchorBlockIdFromId, argsHash, assertIsFn, extractComponentArgTypes, extractTitle, format, formatDate, formatTime, getComponent, getStoryId, getStoryProps, parse, parseDate, parseTime, useOf, useSourceProps };