@storybook/blocks 7.0.0-alpha.49 → 7.0.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +69 -66
- package/dist/index.js +19 -19
- package/dist/index.mjs +8 -8
- package/jest.config.js +7 -0
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FunctionComponent, ComponentProps, ReactNode, FC, ElementType, Context } from 'react';
|
|
2
|
-
import { Conditional, Parameters,
|
|
2
|
+
import { Conditional, Parameters, Renderer, Store_PropDescriptor, StrictArgTypes, StoryId, ProjectAnnotations, BaseAnnotations, Store_ModuleExports, Store_Story, StoryAnnotations, Store_ModuleExport, ComponentTitle } from '@storybook/types';
|
|
3
3
|
import { DocsContextProps } from '@storybook/preview-web';
|
|
4
4
|
export { DocsContextProps } from '@storybook/preview-web';
|
|
5
5
|
import { SyntaxHighlighter, ActionItem, SyntaxHighlighterFormatTypes } from '@storybook/components';
|
|
@@ -20,7 +20,7 @@ interface SourceCodeProps {
|
|
|
20
20
|
format?: ComponentProps<typeof SyntaxHighlighter>['format'];
|
|
21
21
|
dark?: boolean;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
type SourceProps$1 = SourceErrorProps & SourceCodeProps;
|
|
24
24
|
/**
|
|
25
25
|
* Syntax-highlighted source code for a component (or anything!)
|
|
26
26
|
*/
|
|
@@ -55,7 +55,7 @@ interface ArgTypes {
|
|
|
55
55
|
interface Args {
|
|
56
56
|
[key: string]: any;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
type Globals = {
|
|
59
59
|
[name: string]: any;
|
|
60
60
|
};
|
|
61
61
|
|
|
@@ -63,7 +63,7 @@ declare enum ArgsTableError {
|
|
|
63
63
|
NO_COMPONENT = "No component found.",
|
|
64
64
|
ARGS_UNSUPPORTED = "Args unsupported. See Args documentation for your framework."
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
type SortType = 'alpha' | 'requiredFirst' | 'none';
|
|
67
67
|
interface ArgsTableOptionProps {
|
|
68
68
|
children?: React.ReactNode;
|
|
69
69
|
updateArgs?: (args: Args) => void;
|
|
@@ -85,7 +85,7 @@ interface ArgsTableErrorProps {
|
|
|
85
85
|
interface ArgsTableLoadingProps {
|
|
86
86
|
isLoading: true;
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
type ArgsTableProps$1 = ArgsTableOptionProps & (ArgsTableDataProps | ArgsTableErrorProps | ArgsTableLoadingProps);
|
|
89
89
|
/**
|
|
90
90
|
* Display the props for a component as a props table. Each row is a collection of
|
|
91
91
|
* ArgDefs, usually derived from docgen info for the component.
|
|
@@ -106,8 +106,8 @@ interface InlineStoryProps extends CommonProps$2 {
|
|
|
106
106
|
parameters: Parameters;
|
|
107
107
|
storyFn: ElementType;
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
type IFrameStoryProps = CommonProps$2;
|
|
110
|
+
type StoryProps$2 = InlineStoryProps | IFrameStoryProps;
|
|
111
111
|
/**
|
|
112
112
|
* A story element, either rendered inline or in an iframe,
|
|
113
113
|
* with configurable height.
|
|
@@ -130,7 +130,7 @@ interface TypesetProps {
|
|
|
130
130
|
*/
|
|
131
131
|
declare const Typeset: FC<TypesetProps>;
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
type Colors = string[] | {
|
|
134
134
|
[key: string]: string;
|
|
135
135
|
};
|
|
136
136
|
interface ColorItemProps {
|
|
@@ -174,17 +174,17 @@ interface AnchorProps {
|
|
|
174
174
|
}
|
|
175
175
|
declare const Anchor: FC<AnchorProps>;
|
|
176
176
|
|
|
177
|
-
declare const DocsContext: Context<DocsContextProps<
|
|
177
|
+
declare const DocsContext: Context<DocsContextProps<Renderer>>;
|
|
178
178
|
|
|
179
179
|
declare const PRIMARY_STORY = "^";
|
|
180
|
-
|
|
180
|
+
type Component = any;
|
|
181
181
|
interface StoryData {
|
|
182
182
|
id?: string;
|
|
183
183
|
kind?: string;
|
|
184
184
|
name?: string;
|
|
185
185
|
parameters?: any;
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
type DocsStoryProps = StoryData & {
|
|
188
188
|
expanded?: boolean;
|
|
189
189
|
withToolbar?: boolean;
|
|
190
190
|
};
|
|
@@ -194,19 +194,19 @@ interface BaseProps {
|
|
|
194
194
|
exclude?: Store_PropDescriptor;
|
|
195
195
|
sort?: SortType;
|
|
196
196
|
}
|
|
197
|
-
|
|
197
|
+
type OfProps = BaseProps & {
|
|
198
198
|
of: '^' | Component;
|
|
199
199
|
};
|
|
200
|
-
|
|
200
|
+
type ComponentsProps = BaseProps & {
|
|
201
201
|
components: {
|
|
202
202
|
[label: string]: Component;
|
|
203
203
|
};
|
|
204
204
|
};
|
|
205
|
-
|
|
205
|
+
type StoryProps$1 = BaseProps & {
|
|
206
206
|
story: '.' | '^' | string;
|
|
207
207
|
showComponent?: boolean;
|
|
208
208
|
};
|
|
209
|
-
|
|
209
|
+
type ArgsTableProps = BaseProps | OfProps | ComponentsProps | StoryProps$1;
|
|
210
210
|
declare const extractComponentArgTypes: (component: Component, context: DocsContextProps, include?: Store_PropDescriptor, exclude?: Store_PropDescriptor) => StrictArgTypes;
|
|
211
211
|
declare const getComponent: (props: ArgsTableProps, context: DocsContextProps) => Component;
|
|
212
212
|
declare const StoryTable: FC<StoryProps$1 & {
|
|
@@ -220,7 +220,7 @@ interface SourceItem {
|
|
|
220
220
|
code: string;
|
|
221
221
|
format: SyntaxHighlighterFormatTypes;
|
|
222
222
|
}
|
|
223
|
-
|
|
223
|
+
type StorySources = Record<StoryId, SourceItem>;
|
|
224
224
|
interface SourceContextProps {
|
|
225
225
|
sources: StorySources;
|
|
226
226
|
setSource?: (id: StoryId, item: SourceItem) => void;
|
|
@@ -241,22 +241,22 @@ interface CommonProps$1 {
|
|
|
241
241
|
format?: PureSourceProps['format'];
|
|
242
242
|
code?: string;
|
|
243
243
|
}
|
|
244
|
-
|
|
244
|
+
type SingleSourceProps = {
|
|
245
245
|
id: string;
|
|
246
246
|
} & CommonProps$1;
|
|
247
|
-
|
|
247
|
+
type MultiSourceProps = {
|
|
248
248
|
ids: string[];
|
|
249
249
|
} & CommonProps$1;
|
|
250
|
-
|
|
250
|
+
type CodeProps = {
|
|
251
251
|
code: string;
|
|
252
252
|
} & CommonProps$1;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
type NoneProps = CommonProps$1;
|
|
254
|
+
type SourceProps = SingleSourceProps | MultiSourceProps | CodeProps | NoneProps;
|
|
255
|
+
type SourceStateProps = {
|
|
256
256
|
state: SourceState;
|
|
257
257
|
};
|
|
258
|
-
|
|
259
|
-
declare const
|
|
258
|
+
type PureSourceProps = ComponentProps<typeof Source$1>;
|
|
259
|
+
declare const useSourceProps: (props: SourceProps, docsContext: DocsContextProps<any>, sourceContext: SourceContextProps) => PureSourceProps & SourceStateProps;
|
|
260
260
|
/**
|
|
261
261
|
* Story source doc block renders source code if provided,
|
|
262
262
|
* or the source for a story if `storyId` is provided, or
|
|
@@ -264,7 +264,7 @@ declare const getSourceProps: (props: SourceProps, docsContext: DocsContextProps
|
|
|
264
264
|
*/
|
|
265
265
|
declare const Source: FC<PureSourceProps>;
|
|
266
266
|
|
|
267
|
-
|
|
267
|
+
type CanvasProps = Omit<PreviewProps, 'isExpanded'> & {
|
|
268
268
|
withSource?: SourceState;
|
|
269
269
|
mdxSource?: string;
|
|
270
270
|
};
|
|
@@ -286,7 +286,7 @@ interface DescriptionProps {
|
|
|
286
286
|
declare const getDescriptionProps: ({ of, type, markdown, children }: DescriptionProps, { storyById }: DocsContextProps<any>) => DescriptionProps$1;
|
|
287
287
|
declare const DescriptionContainer: FC<DescriptionProps>;
|
|
288
288
|
|
|
289
|
-
|
|
289
|
+
type DocsProps<TFramework extends Renderer = Renderer> = {
|
|
290
290
|
docsParameter: Parameters;
|
|
291
291
|
context: DocsContextProps<TFramework>;
|
|
292
292
|
};
|
|
@@ -294,7 +294,7 @@ declare const Docs: FunctionComponent<DocsProps>;
|
|
|
294
294
|
|
|
295
295
|
declare const DocsPage: FC;
|
|
296
296
|
|
|
297
|
-
interface DocsContainerProps<TFramework extends
|
|
297
|
+
interface DocsContainerProps<TFramework extends Renderer = Renderer> {
|
|
298
298
|
context: DocsContextProps<TFramework>;
|
|
299
299
|
theme?: ThemeVars;
|
|
300
300
|
children?: ReactNode;
|
|
@@ -303,7 +303,7 @@ declare const DocsContainer: FunctionComponent<DocsContainerProps>;
|
|
|
303
303
|
|
|
304
304
|
declare const DocsStory: FC<DocsStoryProps>;
|
|
305
305
|
|
|
306
|
-
|
|
306
|
+
type ExternalDocsProps<TFramework extends Renderer = Renderer> = {
|
|
307
307
|
projectAnnotationsList: ProjectAnnotations<TFramework>[];
|
|
308
308
|
};
|
|
309
309
|
declare const ExternalDocs: FunctionComponent<ExternalDocsProps>;
|
|
@@ -318,7 +318,7 @@ interface HeadingProps {
|
|
|
318
318
|
}
|
|
319
319
|
declare const Heading: FC<HeadingProps>;
|
|
320
320
|
|
|
321
|
-
|
|
321
|
+
type MetaProps = BaseAnnotations & {
|
|
322
322
|
of?: Store_ModuleExports;
|
|
323
323
|
};
|
|
324
324
|
/**
|
|
@@ -339,27 +339,25 @@ interface StoriesProps {
|
|
|
339
339
|
declare const Stories: FC<StoriesProps>;
|
|
340
340
|
|
|
341
341
|
declare const storyBlockIdFromId: (storyId: string) => string;
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
type PureStoryProps = ComponentProps<typeof Story$1>;
|
|
343
|
+
type CommonProps = StoryAnnotations & {
|
|
344
344
|
height?: string;
|
|
345
345
|
inline?: boolean;
|
|
346
346
|
};
|
|
347
|
-
|
|
347
|
+
type StoryDefProps = {
|
|
348
348
|
name: string;
|
|
349
|
-
children: ReactNode;
|
|
350
349
|
};
|
|
351
|
-
|
|
350
|
+
type StoryRefProps = {
|
|
352
351
|
id?: string;
|
|
353
352
|
of?: Store_ModuleExport;
|
|
354
353
|
meta?: Store_ModuleExports;
|
|
355
354
|
};
|
|
356
|
-
|
|
355
|
+
type StoryImportProps = {
|
|
357
356
|
name: string;
|
|
358
|
-
story: ElementType;
|
|
359
357
|
};
|
|
360
|
-
|
|
358
|
+
type StoryProps = (StoryDefProps | StoryRefProps | StoryImportProps) & CommonProps;
|
|
361
359
|
declare const getStoryId: (props: StoryProps, context: DocsContextProps) => StoryId;
|
|
362
|
-
declare const getStoryProps: <TFramework extends
|
|
360
|
+
declare const getStoryProps: <TFramework extends Renderer>({ height, inline }: StoryProps, story: Store_Story<TFramework>) => PureStoryProps;
|
|
363
361
|
declare const Story: FC<StoryProps>;
|
|
364
362
|
|
|
365
363
|
declare const Subheading: FC<HeadingProps>;
|
|
@@ -404,11 +402,11 @@ interface ControlProps<T> {
|
|
|
404
402
|
onFocus?: (evt: any) => void;
|
|
405
403
|
onBlur?: (evt: any) => void;
|
|
406
404
|
}
|
|
407
|
-
|
|
405
|
+
type BooleanValue = boolean;
|
|
408
406
|
interface BooleanConfig {
|
|
409
407
|
}
|
|
410
|
-
|
|
411
|
-
|
|
408
|
+
type ColorValue = string;
|
|
409
|
+
type PresetColor = ColorValue | {
|
|
412
410
|
color: ColorValue;
|
|
413
411
|
title?: string;
|
|
414
412
|
};
|
|
@@ -420,26 +418,26 @@ interface ColorConfig {
|
|
|
420
418
|
*/
|
|
421
419
|
startOpen?: boolean;
|
|
422
420
|
}
|
|
423
|
-
|
|
421
|
+
type DateValue = Date | number;
|
|
424
422
|
interface DateConfig {
|
|
425
423
|
}
|
|
426
|
-
|
|
424
|
+
type NumberValue = number;
|
|
427
425
|
interface NumberConfig {
|
|
428
426
|
min?: number;
|
|
429
427
|
max?: number;
|
|
430
428
|
step?: number;
|
|
431
429
|
}
|
|
432
|
-
|
|
433
|
-
|
|
430
|
+
type RangeConfig = NumberConfig;
|
|
431
|
+
type ObjectValue = any;
|
|
434
432
|
interface ObjectConfig {
|
|
435
433
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
434
|
+
type OptionsSingleSelection = any;
|
|
435
|
+
type OptionsMultiSelection = any[];
|
|
436
|
+
type OptionsSelection = OptionsSingleSelection | OptionsMultiSelection;
|
|
437
|
+
type OptionsArray = any[];
|
|
438
|
+
type OptionsObject = Record<string, any>;
|
|
439
|
+
type Options = OptionsArray | OptionsObject;
|
|
440
|
+
type OptionsControlType = 'radio' | 'inline-radio' | 'check' | 'inline-check' | 'select' | 'multi-select';
|
|
443
441
|
interface OptionsConfig {
|
|
444
442
|
labels: Record<any, string>;
|
|
445
443
|
type: OptionsControlType;
|
|
@@ -447,43 +445,48 @@ interface OptionsConfig {
|
|
|
447
445
|
interface NormalizedOptionsConfig {
|
|
448
446
|
options: OptionsObject;
|
|
449
447
|
}
|
|
450
|
-
|
|
448
|
+
type TextValue = string;
|
|
451
449
|
interface TextConfig {
|
|
452
450
|
maxLength?: number;
|
|
453
451
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
452
|
+
type ControlType = 'array' | 'boolean' | 'color' | 'date' | 'number' | 'range' | 'object' | OptionsControlType | 'text';
|
|
453
|
+
type Control = BooleanConfig | ColorConfig | DateConfig | NumberConfig | ObjectConfig | OptionsConfig | RangeConfig | TextConfig;
|
|
454
|
+
type Controls = Record<string, Control>;
|
|
457
455
|
|
|
458
|
-
|
|
456
|
+
type ColorControlProps = ControlProps<ColorValue> & ColorConfig;
|
|
459
457
|
|
|
460
|
-
|
|
458
|
+
type BooleanProps = ControlProps<BooleanValue> & BooleanConfig;
|
|
459
|
+
/**
|
|
460
|
+
* # Boolean control
|
|
461
|
+
* Renders a switch toggle with "True" or "False".
|
|
462
|
+
* or if the value is `undefined`, renders a button to set the boolean.
|
|
463
|
+
*/
|
|
461
464
|
declare const BooleanControl: FC<BooleanProps>;
|
|
462
465
|
|
|
463
466
|
declare const parseDate: (value: string) => Date;
|
|
464
467
|
declare const parseTime: (value: string) => Date;
|
|
465
468
|
declare const formatDate: (value: Date | number) => string;
|
|
466
469
|
declare const formatTime: (value: Date | number) => string;
|
|
467
|
-
|
|
470
|
+
type DateProps = ControlProps<DateValue> & DateConfig;
|
|
468
471
|
declare const DateControl: FC<DateProps>;
|
|
469
472
|
|
|
470
|
-
|
|
473
|
+
type NumberProps = ControlProps<NumberValue | null> & NumberConfig;
|
|
471
474
|
declare const parse: (value: string) => number;
|
|
472
475
|
declare const format: (value: NumberValue) => string;
|
|
473
476
|
declare const NumberControl: FC<NumberProps>;
|
|
474
477
|
|
|
475
|
-
|
|
478
|
+
type OptionsProps = ControlProps<OptionsSelection> & OptionsConfig;
|
|
476
479
|
declare const OptionsControl: FC<OptionsProps>;
|
|
477
480
|
|
|
478
|
-
|
|
481
|
+
type ObjectProps = ControlProps<ObjectValue> & ObjectConfig & {
|
|
479
482
|
theme: any;
|
|
480
483
|
};
|
|
481
484
|
declare const ObjectControl: FC<ObjectProps>;
|
|
482
485
|
|
|
483
|
-
|
|
486
|
+
type RangeProps = ControlProps<NumberValue | null> & RangeConfig;
|
|
484
487
|
declare const RangeControl: FC<RangeProps>;
|
|
485
488
|
|
|
486
|
-
|
|
489
|
+
type TextProps = ControlProps<TextValue | undefined> & TextConfig;
|
|
487
490
|
declare const TextControl: FC<TextProps>;
|
|
488
491
|
|
|
489
492
|
interface FilesControlProps extends ControlProps<string[]> {
|
|
@@ -502,8 +505,8 @@ interface FilesControlProps extends ControlProps<string[]> {
|
|
|
502
505
|
}
|
|
503
506
|
declare const FilesControl: FC<FilesControlProps>;
|
|
504
507
|
|
|
505
|
-
|
|
508
|
+
type ColorProps = ColorControlProps;
|
|
506
509
|
declare const LazyColorControl: React.LazyExoticComponent<React.FC<ColorControlProps>>;
|
|
507
510
|
declare const ColorControl: (props: ComponentProps<typeof LazyColorControl>) => JSX.Element;
|
|
508
511
|
|
|
509
|
-
export { AddContext, Anchor, AnchorMdx, AnchorProps, 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, Meta, NoControlsWarning, NormalizedOptionsConfig, NumberConfig, NumberControl, NumberValue, ObjectConfig, ObjectControl, ObjectProps, ObjectValue, 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, SourceState, Stories, Story, StoryData, StoryProps, StorySources, StoryTable, Subheading, Subtitle, TextConfig, TextControl, TextProps, TextValue, Title, Typeset, Wrapper, anchorBlockIdFromId, assertIsFn, extractComponentArgTypes, extractTitle, format, formatDate, formatTime, getComponent, getDescriptionProps,
|
|
512
|
+
export { AddContext, Anchor, AnchorMdx, AnchorProps, 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, Meta, NoControlsWarning, NormalizedOptionsConfig, NumberConfig, NumberControl, NumberValue, ObjectConfig, ObjectControl, ObjectProps, ObjectValue, 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, SourceState, Stories, Story, StoryData, StoryProps, StorySources, StoryTable, Subheading, Subtitle, TextConfig, TextControl, TextProps, TextValue, Title, Typeset, Wrapper, anchorBlockIdFromId, assertIsFn, extractComponentArgTypes, extractTitle, format, formatDate, formatTime, getComponent, getDescriptionProps, getStoryId, getStoryProps, parse, parseDate, parseTime, storyBlockIdFromId, useSourceProps };
|