@storybook/blocks 7.0.0-beta.8 → 7.0.0-rc.0

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.
@@ -0,0 +1 @@
1
+ import{getControlId}from"./chunk-GWAJ4KRU.mjs";import React,{useCallback,useEffect,useMemo,useState}from"react";import{HexColorPicker,HslaStringColorPicker,RgbaStringColorPicker}from"react-colorful";import convert from"color-convert";import throttle from"lodash/throttle.js";import{styled}from"@storybook/theming";import{TooltipNote,WithTooltip,Form,Icons}from"@storybook/components";var Wrapper=styled.div({position:"relative",maxWidth:250}),PickerTooltip=styled(WithTooltip)({position:"absolute",zIndex:1,top:4,left:4}),TooltipContent=styled.div({width:200,margin:5,".react-colorful__saturation":{borderRadius:"4px 4px 0 0"},".react-colorful__hue":{boxShadow:"inset 0 0 0 1px rgb(0 0 0 / 5%)"},".react-colorful__last-control":{borderRadius:"0 0 4px 4px"}}),Note=styled(TooltipNote)(({theme})=>({fontFamily:theme.typography.fonts.base})),Swatches=styled.div({display:"grid",gridTemplateColumns:"repeat(9, 16px)",gap:6,padding:3,marginTop:5,width:200}),SwatchColor=styled.div(({theme,active})=>({width:16,height:16,boxShadow:active?`${theme.appBorderColor} 0 0 0 1px inset, ${theme.textMutedColor}50 0 0 0 4px`:`${theme.appBorderColor} 0 0 0 1px inset`,borderRadius:theme.appBorderRadius})),swatchBackground=`url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')`,Swatch=({value,active,onClick,style,...props})=>{let backgroundImage=`linear-gradient(${value}, ${value}), ${swatchBackground}, linear-gradient(#fff, #fff)`;return React.createElement(SwatchColor,{...props,active,onClick,style:{...style,backgroundImage}})},Input=styled(Form.Input)(({theme})=>({width:"100%",paddingLeft:30,paddingRight:30,boxSizing:"border-box",fontFamily:theme.typography.fonts.base})),ToggleIcon=styled(Icons)(({theme})=>({position:"absolute",zIndex:1,top:6,right:7,width:20,height:20,padding:4,boxSizing:"border-box",cursor:"pointer",color:theme.input.color})),ColorSpace=(ColorSpace2=>(ColorSpace2.RGB="rgb",ColorSpace2.HSL="hsl",ColorSpace2.HEX="hex",ColorSpace2))(ColorSpace||{}),COLOR_SPACES=Object.values(ColorSpace),COLOR_REGEXP=/\(([0-9]+),\s*([0-9]+)%?,\s*([0-9]+)%?,?\s*([0-9.]+)?\)/,RGB_REGEXP=/^\s*rgba?\(([0-9]+),\s*([0-9]+),\s*([0-9]+),?\s*([0-9.]+)?\)\s*$/i,HSL_REGEXP=/^\s*hsla?\(([0-9]+),\s*([0-9]+)%,\s*([0-9]+)%,?\s*([0-9.]+)?\)\s*$/i,HEX_REGEXP=/^\s*#?([0-9a-f]{3}|[0-9a-f]{6})\s*$/i,SHORTHEX_REGEXP=/^\s*#?([0-9a-f]{3})\s*$/i,ColorPicker={["hex"]:HexColorPicker,["rgb"]:RgbaStringColorPicker,["hsl"]:HslaStringColorPicker},fallbackColor={["hex"]:"transparent",["rgb"]:"rgba(0, 0, 0, 0)",["hsl"]:"hsla(0, 0%, 0%, 0)"},stringToArgs=value=>{let match=value?.match(COLOR_REGEXP);if(!match)return[0,0,0,1];let[,x,y,z,a=1]=match;return[x,y,z,a].map(Number)},parseValue=value=>{if(!value)return;let valid=!0;if(RGB_REGEXP.test(value)){let[r,g,b,a]=stringToArgs(value),[h,s,l]=convert.rgb.hsl([r,g,b])||[0,0,0];return{valid,value,keyword:convert.rgb.keyword([r,g,b]),colorSpace:"rgb",["rgb"]:value,["hsl"]:`hsla(${h}, ${s}%, ${l}%, ${a})`,["hex"]:`#${convert.rgb.hex([r,g,b]).toLowerCase()}`}}if(HSL_REGEXP.test(value)){let[h,s,l,a]=stringToArgs(value),[r,g,b]=convert.hsl.rgb([h,s,l])||[0,0,0];return{valid,value,keyword:convert.hsl.keyword([h,s,l]),colorSpace:"hsl",["rgb"]:`rgba(${r}, ${g}, ${b}, ${a})`,["hsl"]:value,["hex"]:`#${convert.hsl.hex([h,s,l]).toLowerCase()}`}}let plain=value.replace("#",""),rgb=convert.keyword.rgb(plain)||convert.hex.rgb(plain),hsl=convert.rgb.hsl(rgb),mapped=value;if(/[^#a-f0-9]/i.test(value)?mapped=plain:HEX_REGEXP.test(value)&&(mapped=`#${plain}`),mapped.startsWith("#"))valid=HEX_REGEXP.test(mapped);else try{convert.keyword.hex(mapped)}catch{valid=!1}return{valid,value:mapped,keyword:convert.rgb.keyword(rgb),colorSpace:"hex",["rgb"]:`rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, 1)`,["hsl"]:`hsla(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%, 1)`,["hex"]:mapped}},getRealValue=(value,color,colorSpace)=>{if(!value||!color?.valid)return fallbackColor[colorSpace];if(colorSpace!=="hex")return color?.[colorSpace]||fallbackColor[colorSpace];if(!color.hex.startsWith("#"))try{return`#${convert.keyword.hex(color.hex)}`}catch{return fallbackColor.hex}let short=color.hex.match(SHORTHEX_REGEXP);if(!short)return HEX_REGEXP.test(color.hex)?color.hex:fallbackColor.hex;let[r,g,b]=short[1].split("");return`#${r}${r}${g}${g}${b}${b}`},useColorInput=(initialValue,onChange)=>{let[value,setValue]=useState(initialValue||""),[color,setColor]=useState(()=>parseValue(value)),[colorSpace,setColorSpace]=useState(color?.colorSpace||"hex");useEffect(()=>{let nextValue=initialValue||"",nextColor=parseValue(nextValue);setValue(nextValue),setColor(nextColor),setColorSpace(nextColor?.colorSpace||"hex")},[initialValue]);let realValue=useMemo(()=>getRealValue(value,color,colorSpace).toLowerCase(),[value,color,colorSpace]),updateValue=useCallback(update=>{let parsed=parseValue(update),v=parsed?.value||update||"";setValue(v),v===""&&(setColor(void 0),onChange(void 0)),parsed&&(setColor(parsed),setColorSpace(parsed.colorSpace),onChange(parsed.value))},[onChange]),cycleColorSpace=useCallback(()=>{let next=COLOR_SPACES.indexOf(colorSpace)+1;next>=COLOR_SPACES.length&&(next=0),setColorSpace(COLOR_SPACES[next]);let update=color?.[COLOR_SPACES[next]]||"";setValue(update),onChange(update)},[color,colorSpace,onChange]);return{value,realValue,updateValue,color,colorSpace,cycleColorSpace}},id=value=>value.replace(/\s*/,"").toLowerCase(),usePresets=(presetColors,currentColor,colorSpace)=>{let[selectedColors,setSelectedColors]=useState(currentColor?.valid?[currentColor]:[]);useEffect(()=>{currentColor===void 0&&setSelectedColors([])},[currentColor]);let presets=useMemo(()=>(presetColors||[]).map(preset=>typeof preset=="string"?parseValue(preset):preset.title?{...parseValue(preset.color),keyword:preset.title}:parseValue(preset.color)).concat(selectedColors).filter(Boolean).slice(-27),[presetColors,selectedColors]),addPreset=useCallback(color=>{color?.valid&&(presets.some(preset=>id(preset[colorSpace])===id(color[colorSpace]))||setSelectedColors(arr=>arr.concat(color)))},[colorSpace,presets]);return{presets,addPreset}},ColorControl=({name,value:initialValue,onChange,onFocus,onBlur,presetColors,startOpen=!1})=>{let throttledOnChange=useCallback(throttle(onChange,200),[onChange]),{value,realValue,updateValue,color,colorSpace,cycleColorSpace}=useColorInput(initialValue,throttledOnChange),{presets,addPreset}=usePresets(presetColors,color,colorSpace),Picker=ColorPicker[colorSpace];return React.createElement(Wrapper,null,React.createElement(PickerTooltip,{startOpen,closeOnOutsideClick:!0,onVisibleChange:()=>addPreset(color),tooltip:React.createElement(TooltipContent,null,React.createElement(Picker,{color:realValue==="transparent"?"#000000":realValue,onChange:updateValue,onFocus,onBlur}),presets.length>0&&React.createElement(Swatches,null,presets.map((preset,index)=>React.createElement(WithTooltip,{key:`${preset.value}-${index}`,hasChrome:!1,tooltip:React.createElement(Note,{note:preset.keyword||preset.value})},React.createElement(Swatch,{value:preset[colorSpace],active:color&&id(preset[colorSpace])===id(color[colorSpace]),onClick:()=>updateValue(preset.value)})))))},React.createElement(Swatch,{value:realValue,style:{margin:4}})),React.createElement(Input,{id:getControlId(name),value,onChange:e=>updateValue(e.target.value),onFocus:e=>e.target.select(),placeholder:"Choose color..."}),value?React.createElement(ToggleIcon,{icon:"markup",onClick:cycleColorSpace}):null)},Color_default=ColorControl;export{ColorControl,Color_default as default};
package/dist/index.d.ts CHANGED
@@ -1,37 +1,49 @@
1
- import { Conditional, Parameters, DocsContextProps, Renderer, StrictArgTypes, StoryId, ProjectAnnotations, BaseAnnotations, ModuleExports, PreparedStory, StoryAnnotations, ModuleExport, ComponentTitle } from '@storybook/types';
1
+ import * as _storybook_types from '@storybook/types';
2
+ import { Conditional, DocsContextProps, PreparedStory, ModuleExports, ModuleExport, Parameters as Parameters$1, StrictArgTypes, Renderer as Renderer$1, Args as Args$1, StoryId, StoryAnnotations, ResolvedModuleExportType, ResolvedModuleExportFromType, ProjectAnnotations, BaseAnnotations, ComponentTitle } from '@storybook/types';
2
3
  export { DocsContextProps } from '@storybook/types';
3
- import React, { FunctionComponent, ComponentProps, ReactNode, FC, ElementType, Context } from 'react';
4
+ import React, { ComponentProps, FunctionComponent, ReactNode, FC, Context } from 'react';
5
+ import { Renderer } from '@storybook/csf';
4
6
  import { PropDescriptor } from '@storybook/preview-api';
5
7
  import { SyntaxHighlighter, ActionItem, SyntaxHighlighterFormatTypes } from '@storybook/components';
8
+ import { SourceType } from '@storybook/docs-tools';
6
9
  import { Channel } from '@storybook/channels';
7
10
  import { ThemeVars } from '@storybook/theming';
11
+ import PureMarkdown from 'markdown-to-jsx';
8
12
 
9
13
  declare enum SourceError {
10
14
  NO_STORY = "There\u2019s no story here.",
11
15
  SOURCE_UNAVAILABLE = "Oh no! The source is not available."
12
16
  }
13
- interface SourceErrorProps {
14
- isLoading?: boolean;
15
- error?: SourceError;
16
- }
17
17
  interface SourceCodeProps {
18
+ /**
19
+ * The language the syntax highlighter uses for your story’s code
20
+ */
18
21
  language?: string;
22
+ /**
23
+ * Use this to override the content of the source block.
24
+ */
19
25
  code?: string;
26
+ /**
27
+ * The (prettier) formatter the syntax highlighter uses for your story’s code.
28
+ */
20
29
  format?: ComponentProps<typeof SyntaxHighlighter>['format'];
30
+ /**
31
+ * Display the source snippet in a dark mode.
32
+ */
21
33
  dark?: boolean;
22
34
  }
23
- type SourceProps$1 = SourceErrorProps & SourceCodeProps;
35
+ interface SourceProps$1 extends SourceCodeProps {
36
+ isLoading?: boolean;
37
+ error?: SourceError;
38
+ }
24
39
  /**
25
40
  * Syntax-highlighted source code for a component (or anything!)
26
41
  */
27
42
  declare const Source$1: FunctionComponent<SourceProps$1>;
28
43
 
29
- interface DescriptionProps$1 {
30
- markdown: string;
31
- }
32
-
33
44
  interface PreviewProps {
34
45
  isLoading?: true;
46
+ layout?: Layout;
35
47
  isColumn?: boolean;
36
48
  columns?: number;
37
49
  withSource?: SourceProps$1;
@@ -41,6 +53,7 @@ interface PreviewProps {
41
53
  additionalActions?: ActionItem[];
42
54
  children?: ReactNode;
43
55
  }
56
+ type Layout = 'padded' | 'fullscreen' | 'centered';
44
57
 
45
58
  interface ArgType {
46
59
  name?: string;
@@ -49,7 +62,7 @@ interface ArgType {
49
62
  if?: Conditional;
50
63
  [key: string]: any;
51
64
  }
52
- interface ArgTypes {
65
+ interface ArgTypes$1 {
53
66
  [key: string]: ArgType;
54
67
  }
55
68
  interface Args {
@@ -75,7 +88,7 @@ interface ArgsTableOptionProps {
75
88
  sort?: SortType;
76
89
  }
77
90
  interface ArgsTableDataProps {
78
- rows: ArgTypes;
91
+ rows: ArgTypes$1;
79
92
  args?: Args;
80
93
  globals?: Globals;
81
94
  }
@@ -94,29 +107,28 @@ declare const ArgsTable$1: FC<ArgsTableProps$1>;
94
107
 
95
108
  declare const NoControlsWarning: () => JSX.Element;
96
109
 
97
- declare enum StoryError {
98
- NO_STORY = "No component or story to display"
110
+ interface CommonProps {
111
+ story: PreparedStory;
112
+ inline: boolean;
113
+ primary: boolean;
99
114
  }
100
- interface CommonProps$2 {
101
- title?: string;
115
+ interface InlineStoryProps extends CommonProps {
116
+ inline: true;
102
117
  height?: string;
103
- id: string;
118
+ autoplay: boolean;
119
+ forceInitialArgs: boolean;
120
+ renderStoryToElement: DocsContextProps['renderStoryToElement'];
104
121
  }
105
- interface InlineStoryProps extends CommonProps$2 {
106
- parameters: Parameters;
107
- storyFn: ElementType;
122
+ interface IFrameStoryProps extends CommonProps {
123
+ inline: false;
124
+ height: string;
108
125
  }
109
- type IFrameStoryProps = CommonProps$2;
110
126
  type StoryProps$2 = InlineStoryProps | IFrameStoryProps;
111
127
  /**
112
128
  * A story element, either rendered inline or in an iframe,
113
129
  * with configurable height.
114
130
  */
115
- declare const Story$1: FunctionComponent<StoryProps$2 & {
116
- inline?: boolean;
117
- error?: StoryError;
118
- children?: React.ReactNode;
119
- }>;
131
+ declare const Story$1: FunctionComponent<StoryProps$2>;
120
132
 
121
133
  interface TypesetProps {
122
134
  fontFamily?: string;
@@ -174,19 +186,24 @@ interface AnchorProps {
174
186
  }
175
187
  declare const Anchor: FC<AnchorProps>;
176
188
 
177
- declare const DocsContext: Context<DocsContextProps<Renderer>>;
189
+ type ArgTypesParameters = {
190
+ include?: PropDescriptor;
191
+ exclude?: PropDescriptor;
192
+ sort?: SortType;
193
+ };
194
+ type ArgTypesProps = ArgTypesParameters & {
195
+ of?: Renderer['component'] | ModuleExports;
196
+ };
197
+ declare const ArgTypes: FC<ArgTypesProps>;
178
198
 
179
199
  declare const PRIMARY_STORY = "^";
180
200
  type Component = any;
181
- interface StoryData {
182
- id?: string;
183
- kind?: string;
184
- name?: string;
185
- parameters?: any;
186
- }
187
- type DocsStoryProps = StoryData & {
201
+ type DocsStoryProps = {
202
+ of: ModuleExport;
188
203
  expanded?: boolean;
189
204
  withToolbar?: boolean;
205
+ __forceInitialArgs?: boolean;
206
+ __primary?: boolean;
190
207
  };
191
208
 
192
209
  interface BaseProps {
@@ -207,8 +224,8 @@ type StoryProps$1 = BaseProps & {
207
224
  showComponent?: boolean;
208
225
  };
209
226
  type ArgsTableProps = BaseProps | OfProps | ComponentsProps | StoryProps$1;
210
- declare const extractComponentArgTypes: (component: Component, context: DocsContextProps, include?: PropDescriptor, exclude?: PropDescriptor) => StrictArgTypes;
211
- declare const getComponent: (props: ArgsTableProps, context: DocsContextProps) => Component;
227
+ declare const extractComponentArgTypes: (component: Component, parameters: Parameters$1, include?: PropDescriptor, exclude?: PropDescriptor) => StrictArgTypes;
228
+ declare const getComponent: (props: ArgsTableProps, component: Component) => Component;
212
229
  declare const StoryTable: FC<StoryProps$1 & {
213
230
  component: Component;
214
231
  subcomponents: Record<string, Component>;
@@ -216,16 +233,21 @@ declare const StoryTable: FC<StoryProps$1 & {
216
233
  declare const ComponentsTable: FC<ComponentsProps>;
217
234
  declare const ArgsTable: FC<ArgsTableProps>;
218
235
 
236
+ declare const DocsContext: Context<DocsContextProps<Renderer$1>>;
237
+
238
+ type ArgsHash = string;
239
+ declare function argsHash(args: Args$1): ArgsHash;
219
240
  interface SourceItem {
220
241
  code: string;
221
- format: SyntaxHighlighterFormatTypes;
242
+ format?: SyntaxHighlighterFormatTypes;
222
243
  }
223
- type StorySources = Record<StoryId, SourceItem>;
244
+ type StorySources = Record<StoryId, Record<ArgsHash, SourceItem>>;
224
245
  interface SourceContextProps {
225
246
  sources: StorySources;
226
247
  setSource?: (id: StoryId, item: SourceItem) => void;
227
248
  }
228
249
  declare const SourceContext: Context<SourceContextProps>;
250
+ declare const UNKNOWN_ARGS_HASH = "--unknown--";
229
251
  declare const SourceContainer: FC<{
230
252
  channel: Channel;
231
253
  }>;
@@ -235,23 +257,41 @@ declare enum SourceState {
235
257
  CLOSED = "closed",
236
258
  NONE = "none"
237
259
  }
238
- interface CommonProps$1 {
239
- language?: string;
240
- dark?: boolean;
241
- format?: PureSourceProps['format'];
242
- code?: string;
243
- }
244
- type SingleSourceProps = {
245
- id: string;
246
- } & CommonProps$1;
247
- type MultiSourceProps = {
248
- ids: string[];
249
- } & CommonProps$1;
250
- type CodeProps = {
251
- code: string;
252
- } & CommonProps$1;
253
- type NoneProps = CommonProps$1;
254
- type SourceProps = SingleSourceProps | MultiSourceProps | CodeProps | NoneProps;
260
+ type SourceParameters = SourceCodeProps & {
261
+ /**
262
+ * Where to read the source code from, see `SourceType`
263
+ */
264
+ type?: SourceType;
265
+ /**
266
+ * Transform the detected source for display
267
+ */
268
+ transformSource?: (code: string, story: PreparedStory) => string;
269
+ /**
270
+ * Internal: set by our CSF loader (`enrichCsf` in `@storybook/csf-tools`).
271
+ */
272
+ originalSource?: string;
273
+ };
274
+ type SourceProps = Omit<SourceParameters, 'transformSource' | 'storySource'> & {
275
+ /**
276
+ * Pass the export defining a story to render its source
277
+ *
278
+ * ```jsx
279
+ * import { Source } from '@storybook/blocks';
280
+ * import * as ButtonStories from './Button.stories';
281
+ *
282
+ * <Source of={ButtonStories.Primary} />
283
+ * ```
284
+ */
285
+ of?: ModuleExport;
286
+ /** @deprecated use of={storyExport} instead */
287
+ id?: string;
288
+ /** @deprecated use of={storyExport} instead */
289
+ ids?: string[];
290
+ /**
291
+ * Internal prop to control if a story re-renders on args updates
292
+ */
293
+ __forceInitialArgs?: boolean;
294
+ };
255
295
  type SourceStateProps = {
256
296
  state: SourceState;
257
297
  };
@@ -262,13 +302,169 @@ declare const useSourceProps: (props: SourceProps, docsContext: DocsContextProps
262
302
  * or the source for a story if `storyId` is provided, or
263
303
  * the source for the current story if nothing is provided.
264
304
  */
265
- declare const Source: FC<PureSourceProps>;
305
+ declare const Source: FC<SourceProps>;
306
+
307
+ type PureStoryProps = ComponentProps<typeof Story$1>;
308
+ /**
309
+ * Props to define a story
310
+ *
311
+ * @deprecated Define stories in CSF files
312
+ */
313
+ type StoryDefProps = StoryAnnotations;
314
+ /**
315
+ * Props to reference another story
316
+ */
317
+ type StoryRefProps = {
318
+ /**
319
+ * @deprecated Use of={storyExport} instead
320
+ */
321
+ id?: string;
322
+ /**
323
+ * @deprecated Use of={storyExport} and define the story in the CSF file
324
+ */
325
+ story?: StoryAnnotations;
326
+ /**
327
+ * Pass the export defining a story to render that story
328
+ *
329
+ * ```jsx
330
+ * import { Meta, Story } from '@storybook/blocks';
331
+ * import * as ButtonStories from './Button.stories';
332
+ *
333
+ * <Meta of={ButtonStories} />
334
+ * <Story of={ButtonStories.Primary} />
335
+ * ```
336
+ */
337
+ of?: ModuleExport;
338
+ /**
339
+ * Pass all exports of the CSF file if this MDX file is unattached
340
+ *
341
+ * ```jsx
342
+ * import { Story } from '@storybook/blocks';
343
+ * import * as ButtonStories from './Button.stories';
344
+ *
345
+ * <Story of={ButtonStories.Primary} meta={ButtonStories} />
346
+ * ```
347
+ */
348
+ meta?: ModuleExports;
349
+ };
350
+ type StoryParameters = {
351
+ /**
352
+ * Render the story inline or in an iframe
353
+ */
354
+ inline?: boolean;
355
+ /**
356
+ * When rendering in an iframe (`inline={false}`), set the story height
357
+ */
358
+ height?: string;
359
+ /**
360
+ * Whether to run the story's play function
361
+ */
362
+ autoplay?: boolean;
363
+ /**
364
+ * Internal prop to control if a story re-renders on args updates
365
+ */
366
+ __forceInitialArgs?: boolean;
367
+ /**
368
+ * Internal prop if this story is the primary story
369
+ */
370
+ __primary?: boolean;
371
+ };
372
+ type StoryProps = (StoryDefProps | StoryRefProps) & StoryParameters;
373
+ declare const getStoryId: (props: StoryProps, context: DocsContextProps) => StoryId;
374
+ declare const getStoryProps: <TFramework extends Renderer$1>(props: StoryParameters, story: PreparedStory<TFramework>, context: DocsContextProps<TFramework>) => PureStoryProps;
375
+ declare const Story: FC<StoryProps>;
266
376
 
267
- type CanvasProps = Omit<PreviewProps, 'isExpanded' | 'isLoading'> & {
377
+ type DeprecatedCanvasProps = {
378
+ /**
379
+ * @deprecated multiple stories are not supported
380
+ */
381
+ isColumn?: boolean;
382
+ /**
383
+ * @deprecated multiple stories are not supported
384
+ */
385
+ columns?: number;
386
+ /**
387
+ * @deprecated use `sourceState` instead
388
+ */
268
389
  withSource?: SourceState;
390
+ /**
391
+ * @deprecated use `source.code` instead
392
+ */
269
393
  mdxSource?: string;
394
+ /**
395
+ * @deprecated reference stories with the `of` prop instead
396
+ */
397
+ children?: ReactNode;
398
+ };
399
+ type CanvasProps = Pick<PreviewProps, 'withToolbar' | 'additionalActions' | 'className'> & {
400
+ /**
401
+ * Pass the export defining a story to render that story
402
+ *
403
+ * ```jsx
404
+ * import { Meta, Canvas } from '@storybook/blocks';
405
+ * import * as ButtonStories from './Button.stories';
406
+ *
407
+ * <Meta of={ButtonStories} />
408
+ * <Canvas of={ButtonStories.Primary} />
409
+ * ```
410
+ */
411
+ of?: ModuleExport;
412
+ /**
413
+ * Pass all exports of the CSF file if this MDX file is unattached
414
+ *
415
+ * ```jsx
416
+ * import { Canvas } from '@storybook/blocks';
417
+ * import * as ButtonStories from './Button.stories';
418
+ *
419
+ * <Canvas of={ButtonStories.Primary} meta={ButtonStories} />
420
+ * ```
421
+ */
422
+ meta?: ModuleExports;
423
+ /**
424
+ * Specify the initial state of the source panel
425
+ * hidden: the source panel is hidden by default
426
+ * shown: the source panel is shown by default
427
+ * none: the source panel is not available and the button to show it is hidden
428
+ * @default 'hidden'
429
+ */
430
+ sourceState?: 'hidden' | 'shown' | 'none';
431
+ /**
432
+ * how to layout the story within the canvas
433
+ * padded: the story has padding within the canvas
434
+ * fullscreen: the story is rendered edge to edge within the canvas
435
+ * centered: the story is centered within the canvas
436
+ * @default 'padded'
437
+ */
438
+ layout?: Layout;
439
+ /**
440
+ * @see {SourceProps}
441
+ */
442
+ source?: Omit<SourceProps, 'dark'>;
443
+ /**
444
+ * @see {StoryProps}
445
+ */
446
+ story?: Pick<StoryProps, 'inline' | 'height' | 'autoplay' | '__forceInitialArgs' | '__primary'>;
447
+ };
448
+ declare const Canvas: FC<CanvasProps & DeprecatedCanvasProps>;
449
+
450
+ type ControlsParameters = {
451
+ include?: PropDescriptor;
452
+ exclude?: PropDescriptor;
453
+ sort?: SortType;
454
+ };
455
+ type ControlsProps = ControlsParameters & {
456
+ of?: Renderer['component'] | ModuleExports;
270
457
  };
271
- declare const Canvas: FC<CanvasProps>;
458
+ declare const Controls: FC<ControlsProps>;
459
+
460
+ type Of = Parameters<DocsContextProps['resolveOf']>[0];
461
+ /**
462
+ * A hook to resolve the `of` prop passed to a block.
463
+ * will return the resolved module
464
+ * if the resolved module is a meta it will include a preparedMeta property similar to a preparedStory
465
+ * if the resolved module is a component it will include the project annotations
466
+ */
467
+ declare const useOf: <TType extends ResolvedModuleExportType>(moduleExportOrType: Of, validTypes?: TType[]) => ResolvedModuleExportFromType<TType, _storybook_types.Renderer>;
272
468
 
273
469
  declare enum DescriptionType {
274
470
  INFO = "info",
@@ -277,32 +473,35 @@ declare enum DescriptionType {
277
473
  AUTO = "auto"
278
474
  }
279
475
  interface DescriptionProps {
280
- of?: '.' | Component;
281
476
  /**
282
- * @deprecated Manually specifying description type is deprecated. In the future all descriptions will be extracted from JSDocs on the meta, story or component.
477
+ * Specify where to get the description from. Can be a component, a CSF file or a story.
478
+ * If not specified, the description will be extracted from the meta of the attached CSF file.
479
+ */
480
+ of?: Of;
481
+ /**
482
+ * @deprecated Manually specifying description type is deprecated. See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#description-block-parametersnotes-and-parametersinfo
283
483
  */
284
484
  type?: DescriptionType;
285
485
  /**
286
- * @deprecated The 'markdown' prop on the Description block is deprecated. Write the markdown directly in the .mdx file instead
486
+ * @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
287
487
  */
288
488
  markdown?: string;
289
489
  /**
290
- * @deprecated The 'children' prop on the Description block is deprecated. Write the markdown directly in the .mdx file instead
490
+ * @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
291
491
  */
292
492
  children?: string;
293
493
  }
294
- declare const useDescriptionProps: ({ of, type, markdown, children }: DescriptionProps, { storyById }: DocsContextProps<any>) => DescriptionProps$1;
295
494
  declare const DescriptionContainer: FC<DescriptionProps>;
296
495
 
297
- type DocsProps<TFramework extends Renderer = Renderer> = {
298
- docsParameter: Parameters;
496
+ type DocsProps<TFramework extends Renderer$1 = Renderer$1> = {
497
+ docsParameter: Parameters$1;
299
498
  context: DocsContextProps<TFramework>;
300
499
  };
301
500
  declare const Docs: FunctionComponent<DocsProps>;
302
501
 
303
502
  declare const DocsPage: FC;
304
503
 
305
- interface DocsContainerProps<TFramework extends Renderer = Renderer> {
504
+ interface DocsContainerProps<TFramework extends Renderer$1 = Renderer$1> {
306
505
  context: DocsContextProps<TFramework>;
307
506
  theme?: ThemeVars;
308
507
  children?: ReactNode;
@@ -311,7 +510,7 @@ declare const DocsContainer: FunctionComponent<DocsContainerProps>;
311
510
 
312
511
  declare const DocsStory: FC<DocsStoryProps>;
313
512
 
314
- type ExternalDocsProps<TFramework extends Renderer = Renderer> = {
513
+ type ExternalDocsProps<TFramework extends Renderer$1 = Renderer$1> = {
315
514
  projectAnnotationsList: ProjectAnnotations<TFramework>[];
316
515
  };
317
516
  declare const ExternalDocs: FunctionComponent<ExternalDocsProps>;
@@ -326,6 +525,9 @@ interface HeadingProps {
326
525
  }
327
526
  declare const Heading: FC<HeadingProps>;
328
527
 
528
+ type MarkdownProps = typeof PureMarkdown extends React.ComponentType<infer Props> ? Props : never;
529
+ declare const Markdown: (props: MarkdownProps) => JSX.Element;
530
+
329
531
  type MetaProps = BaseAnnotations & {
330
532
  of?: ModuleExports;
331
533
  };
@@ -336,6 +538,9 @@ type MetaProps = BaseAnnotations & {
336
538
  declare const Meta: FC<MetaProps>;
337
539
 
338
540
  interface PrimaryProps {
541
+ /**
542
+ * @deprecated Primary block should only be used to render the primary story, which is automatically found.
543
+ */
339
544
  name?: string;
340
545
  }
341
546
  declare const Primary: FC<PrimaryProps>;
@@ -346,28 +551,6 @@ interface StoriesProps {
346
551
  }
347
552
  declare const Stories: FC<StoriesProps>;
348
553
 
349
- declare const storyBlockIdFromId: (storyId: string) => string;
350
- type PureStoryProps = ComponentProps<typeof Story$1>;
351
- type CommonProps = StoryAnnotations & {
352
- height?: string;
353
- inline?: boolean;
354
- };
355
- type StoryDefProps = {
356
- name: string;
357
- };
358
- type StoryRefProps = {
359
- id?: string;
360
- of?: ModuleExport;
361
- meta?: ModuleExports;
362
- };
363
- type StoryImportProps = {
364
- name: string;
365
- };
366
- type StoryProps = (StoryDefProps | StoryRefProps | StoryImportProps) & CommonProps;
367
- declare const getStoryId: (props: StoryProps, context: DocsContextProps) => StoryId;
368
- declare const getStoryProps: <TFramework extends Renderer>({ height, inline }: StoryProps, story: PreparedStory<TFramework>) => PureStoryProps;
369
- declare const Story: FC<StoryProps>;
370
-
371
554
  declare const Subheading: FC<HeadingProps>;
372
555
 
373
556
  interface SubtitleProps {
@@ -381,6 +564,8 @@ interface TitleProps {
381
564
  declare const extractTitle: (title: ComponentTitle) => string;
382
565
  declare const Title: FunctionComponent<TitleProps>;
383
566
 
567
+ declare const Unstyled: React.FC;
568
+
384
569
  declare const Wrapper: FC;
385
570
 
386
571
  declare const assertIsFn: (val: any) => any;
@@ -459,7 +644,6 @@ interface TextConfig {
459
644
  }
460
645
  type ControlType = 'array' | 'boolean' | 'color' | 'date' | 'number' | 'range' | 'object' | OptionsControlType | 'text';
461
646
  type Control = BooleanConfig | ColorConfig | DateConfig | NumberConfig | ObjectConfig | OptionsConfig | RangeConfig | TextConfig;
462
- type Controls = Record<string, Control>;
463
647
 
464
648
  type ColorControlProps = ControlProps<ColorValue> & ColorConfig;
465
649
 
@@ -524,4 +708,4 @@ type ColorProps = ColorControlProps;
524
708
  declare const LazyColorControl: React.LazyExoticComponent<React.FC<ColorControlProps>>;
525
709
  declare const ColorControl: (props: ComponentProps<typeof LazyColorControl>) => JSX.Element;
526
710
 
527
- 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, getStoryId, getStoryProps, parse, parseDate, parseTime, storyBlockIdFromId, useDescriptionProps, useSourceProps };
711
+ 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, NoControlsWarning, 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 };