Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions code/addons/docs/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type { JSX } from 'react';
import type { ComponentType } from 'react';

import type { ModuleExport, ModuleExports } from 'storybook/internal/types';

import type { ThemeVars } from 'storybook/theming';

import type { DocsContainerProps } from './blocks/blocks';
import type { TocParameters } from './blocks/components';

type StoryBlockParameters = {
/** Whether a story's play function runs when shown in docs page */
autoplay?: boolean;
Expand Down Expand Up @@ -135,7 +140,7 @@ type SourceBlockParameters = {
*/
of: ModuleExport;
/** Source code transformations */
transform?: (code: string, storyContext: any) => string;
transform?: (code: string, storyContext: any) => string | Promise<string>;
/**
* Specifies how the source code is rendered.
*
Expand Down Expand Up @@ -166,13 +171,27 @@ export interface DocsParameters {
*/
canvas?: Partial<CanvasBlockParameters>;

/**
* Enable the Code panel.
*
* @see https://storybook.js.org/docs/writing-docs/code-panel
*/
codePanel?: boolean;

/**
* Controls block configuration
*
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-controls
*/
controls?: ControlsBlockParameters;

/**
* Customize the Docs Container
*
* @see https://storybook.js.org/docs/writing-docs/autodocs#customize-the-docs-container
*/
container?: ComponentType<DocsContainerProps>;

/**
* Component/story description when shown in docs page
*
Expand All @@ -188,7 +207,7 @@ export interface DocsParameters {
*
* @see https://storybook.js.org/docs/writing-docs/autodocs#write-a-custom-template
*/
page?: unknown;
page?: ComponentType;

/**
* Source code configuration when shown in docs page
Expand All @@ -211,12 +230,26 @@ export interface DocsParameters {
*/
subtitle?: string;

/**
* Override the default theme
*
* @see https://storybook.js.org/docs/writing-docs/autodocs#override-the-default-theme
*/
theme?: ThemeVars;

/**
* The title displayed when shown in docs page
*
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-title
*/
title?: string;

/**
* Configure the table of contents
*
* @see https://storybook.js.org/docs/writing-docs/autodocs#configure-the-table-of-contents
*/
toc?: true | TocParameters;
};
}

Expand Down
24 changes: 16 additions & 8 deletions code/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@
"types": "./dist/actions/decorator.d.ts",
"import": "./dist/actions/decorator.js"
},
"./internal/controls/preview": {
"types": "./dist/controls/preview.d.ts",
"import": "./dist/controls/preview.js",
"require": "./dist/controls/preview.cjs"
},
"./controls/preview": {
"types": "./dist/controls/preview.d.ts",
"import": "./dist/controls/preview.js",
"require": "./dist/controls/preview.cjs"
},
"./internal/component-testing": {
"types": "./dist/component-testing/index.d.ts",
"import": "./dist/component-testing/index.js",
Expand Down Expand Up @@ -226,11 +236,6 @@
"import": "./dist/controls/index.js",
"require": "./dist/controls/index.cjs"
},
"./internal/controls/preview": {
"types": "./dist/controls/preview.d.ts",
"import": "./dist/controls/preview.js",
"require": "./dist/controls/preview.cjs"
},
"./internal/controls/decorator": {
"types": "./dist/controls/decorator.d.ts",
"import": "./dist/controls/decorator.js"
Expand Down Expand Up @@ -487,6 +492,12 @@
"actions/decorator": [
"./dist/actions/decorator.d.ts"
],
"internal/controls/preview": [
"./dist/controls/preview.d.ts"
],
"controls/preview": [
"./dist/controls/preview.d.ts"
],
"internal/component-testing": [
"./dist/component-testing/index.d.ts"
],
Expand All @@ -508,9 +519,6 @@
"internal/controls": [
"./dist/controls/index.d.ts"
],
"internal/controls/preview": [
"./dist/controls/preview.d.ts"
],
"internal/controls/decorator": [
"./dist/controls/decorator.d.ts"
],
Expand Down
2 changes: 2 additions & 0 deletions code/core/scripts/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ async function run() {
'storybook/actions/preview',
'storybook/actions/decorator',

'storybook/controls/preview',

'storybook/viewport',
'storybook/viewport/preview',

Expand Down
2 changes: 2 additions & 0 deletions code/core/scripts/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const getEntries = (cwd: string) => {
define('src/actions/preview.ts', ['browser', 'node'], true, ['react'], [], [], true),
define('src/actions/decorator.ts', ['browser'], true, ['react'], [], [], true),

define('src/controls/preview.ts', ['browser', 'node'], true, ['react'], [], [], true),

define('src/component-testing/index.ts', ['browser', 'node'], true, ['react'], [], []),
define('src/component-testing/preview.ts', ['browser', 'node'], true, ['react'], [], []),
define('src/viewport/index.ts', ['browser', 'node'], true, ['react'], [], [], true),
Expand Down
2 changes: 2 additions & 0 deletions code/core/src/controls/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { definePreviewAddon } from 'storybook/internal/csf';

import type { ControlsTypes } from './types';

export type { ControlsTypes };

export default definePreviewAddon<ControlsTypes>({
// Controls addon doesn't need any preview-side configuration
// It operates entirely through the manager UI
Expand Down
2 changes: 2 additions & 0 deletions code/core/src/csf/core-annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { StorybookTypes } from 'storybook/internal/types';

import actionAnnotations, { type ActionsTypes } from 'storybook/actions/preview';
import backgroundsAnnotations, { type BackgroundTypes } from 'storybook/backgrounds/preview';
import { type ControlsTypes } from 'storybook/controls/preview';
import highlightAnnotations, { type HighlightTypes } from 'storybook/highlight/preview';
import measureAnnotations, { type MeasureTypes } from 'storybook/measure/preview';
import outlineAnnotations, { type OutlineTypes } from 'storybook/outline/preview';
Expand All @@ -12,6 +13,7 @@ import viewportAnnotations, { type ViewportTypes } from 'storybook/viewport/prev
export type CoreTypes = StorybookTypes &
ActionsTypes &
BackgroundTypes &
ControlsTypes &
HighlightTypes &
MeasureTypes &
OutlineTypes &
Expand Down