mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
Rename @storybook/addon-actions to storybook/actions
This commit is contained in:
parent
37dab1d632
commit
99692917e1
@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { action } from "@storybook/addon-actions";
|
||||
import { action } from "storybook/actions";
|
||||
import { Button } from "@storybook/react/demo";
|
||||
|
||||
const meta = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { action } from "@storybook/addon-actions";
|
||||
import { action } from "storybook/actions";
|
||||
import { Button } from "@storybook/react/demo";
|
||||
|
||||
export default {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { action } from "@storybook/addon-actions";
|
||||
import { action } from "storybook/actions";
|
||||
import { Button } from "@storybook/react/demo";
|
||||
|
||||
export default {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { action } from "@storybook/addon-actions";
|
||||
import { action } from "storybook/actions";
|
||||
import { Button } from "@storybook/react/demo";
|
||||
|
||||
export default {
|
||||
|
@ -2,8 +2,7 @@ import React from 'react';
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
|
||||
import { action } from 'storybook/actions';
|
||||
import { expect, fireEvent, fn, userEvent, within } from 'storybook/test';
|
||||
|
||||
import { SaveStory } from './SaveStory';
|
||||
|
@ -20,8 +20,6 @@ export default {
|
||||
};
|
||||
```
|
||||
|
||||
Note that `@storybook/addon-interactions` must be listed **after** `@storybook/addon-actions` or `@storybook/addon-essentials`.
|
||||
|
||||
## Usage
|
||||
|
||||
Interactions relies on "instrumented" versions of Vitest and Testing Library, that you import from `storybook/test` instead of their original package. You can then use these libraries in your `play` function.
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { CallStates } from 'storybook/internal/instrumenter';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { parameters } from '../preview';
|
||||
import { Subnav } from './Subnav';
|
||||
|
@ -1,24 +1,2 @@
|
||||
import { isAbsolute, join } from 'node:path';
|
||||
|
||||
import { checkAddonOrder, serverRequire } from 'storybook/internal/common';
|
||||
|
||||
export function previewAnnotations(entry: string[] = [], options: { configDir: string }) {
|
||||
checkAddonOrder({
|
||||
before: {
|
||||
name: '@storybook/addon-actions',
|
||||
inEssentials: true,
|
||||
},
|
||||
after: {
|
||||
name: '@storybook/addon-interactions',
|
||||
inEssentials: false,
|
||||
},
|
||||
configFile: isAbsolute(options.configDir)
|
||||
? join(options.configDir, 'main')
|
||||
: join(process.cwd(), options.configDir, 'main'),
|
||||
getConfig: (configFile) => serverRequire(configFile),
|
||||
});
|
||||
return entry;
|
||||
}
|
||||
|
||||
// This annotation is read by addon-test, so it can throw an error if both addons are used
|
||||
export const ADDON_INTERACTIONS_IN_USE = true;
|
||||
|
@ -80,7 +80,7 @@ export const third = () => <LinkTo story="index">Go back</LinkTo>;
|
||||
If you want to get an URL for a particular story, you may use `hrefTo` function. It returns a promise, which resolves to string containing a relative URL:
|
||||
|
||||
```js
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
import { hrefTo } from '@storybook/addon-links';
|
||||
|
||||
export default {
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { CallStates } from 'storybook/internal/instrumenter';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { parameters } from '../preview';
|
||||
import { Subnav } from './Subnav';
|
||||
|
||||
export default {
|
||||
|
@ -43,23 +43,6 @@ type Event = {
|
||||
};
|
||||
};
|
||||
|
||||
export const checkActionsLoaded = (configDir: string) => {
|
||||
checkAddonOrder({
|
||||
before: {
|
||||
name: '@storybook/addon-actions',
|
||||
inEssentials: true,
|
||||
},
|
||||
after: {
|
||||
name: '@storybook/addon-test',
|
||||
inEssentials: false,
|
||||
},
|
||||
configFile: isAbsolute(configDir)
|
||||
? join(configDir, 'main')
|
||||
: join(process.cwd(), configDir, 'main'),
|
||||
getConfig: (configFile) => serverRequire(configFile),
|
||||
});
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export const experimental_serverChannel = async (channel: Channel, options: Options) => {
|
||||
const core = await options.presets.apply('core');
|
||||
@ -198,14 +181,6 @@ export const staticDirs: PresetPropertyFn<'staticDirs'> = async (values = [], op
|
||||
];
|
||||
};
|
||||
|
||||
export const previewAnnotations: PresetProperty<'previewAnnotations'> = async (
|
||||
entry = [],
|
||||
options
|
||||
) => {
|
||||
checkActionsLoaded(options.configDir);
|
||||
return entry;
|
||||
};
|
||||
|
||||
export const managerEntries: PresetProperty<'managerEntries'> = async (entry = [], options) => {
|
||||
// Throw an error when addon-interactions is used.
|
||||
// This is done by reading an annotation defined in addon-interactions, which although not ideal,
|
||||
|
@ -220,7 +220,6 @@ export abstract class JsPackageManager {
|
||||
* ```ts
|
||||
* addDependencies(options, [
|
||||
* `@storybook/react@${storybookVersion}`,
|
||||
* `@storybook/addon-actions@${actionsVersion}`,
|
||||
* `@storybook/addon-links@${linksVersion}`,
|
||||
* ]);
|
||||
* ```
|
||||
@ -277,7 +276,7 @@ export abstract class JsPackageManager {
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* removeDependencies(options, [`@storybook/react`, `@storybook/addon-actions`]);
|
||||
* removeDependencies(options, [`@storybook/react`]);
|
||||
* ```
|
||||
*
|
||||
* @param {Object} options Contains `skipInstall`, `packageJson` and `installAsDevDependencies`
|
||||
|
@ -30,8 +30,7 @@ vi.mock('storybook/internal/node-logger', () => ({
|
||||
vi.mock('./utils/safeResolve', () => {
|
||||
const KNOWN_FILES = [
|
||||
'@storybook/react',
|
||||
'@storybook/addon-actions/manager',
|
||||
'@storybook/addon-actions/register.js',
|
||||
'storybook/actions/manager',
|
||||
'./local/preset',
|
||||
'./local/addons',
|
||||
'/absolute/preset',
|
||||
@ -411,18 +410,10 @@ describe('resolveAddonName', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should resolve managerEntries', () => {
|
||||
expect(resolveAddonName({} as any, '@storybook/addon-actions/register.js', {})).toEqual({
|
||||
name: '@storybook/addon-actions/register.js',
|
||||
managerEntries: [normalize('@storybook/addon-actions/register')],
|
||||
type: 'virtual',
|
||||
});
|
||||
});
|
||||
|
||||
it('should resolve managerEntries from new /manager path', () => {
|
||||
expect(resolveAddonName({} as any, '@storybook/addon-actions/manager', {})).toEqual({
|
||||
name: '@storybook/addon-actions/manager',
|
||||
managerEntries: [normalize('@storybook/addon-actions/manager')],
|
||||
expect(resolveAddonName({} as any, 'storybook/actions/manager', {})).toEqual({
|
||||
name: 'storybook/actions/manager',
|
||||
managerEntries: [normalize('storybook/actions/manager')],
|
||||
type: 'virtual',
|
||||
});
|
||||
});
|
||||
@ -453,7 +444,6 @@ describe('loadPreset', () => {
|
||||
mockPreset('@storybook/react', {});
|
||||
mockPreset('@storybook/preset-typescript', {});
|
||||
mockPreset('@storybook/addon-docs/preset', {});
|
||||
mockPreset('@storybook/addon-actions/register.js', {});
|
||||
mockPreset('addon-foo/register.js', {});
|
||||
mockPreset('@storybook/addon-cool', {});
|
||||
mockPreset('@storybook/addon-interactions/preset', {});
|
||||
@ -524,7 +514,6 @@ describe('loadPreset', () => {
|
||||
presets: ['@storybook/preset-typescript'],
|
||||
addons: [
|
||||
'@storybook/addon-docs/preset',
|
||||
'@storybook/addon-actions/register.js',
|
||||
'addon-foo/register.js',
|
||||
'addon-bar',
|
||||
'addon-baz/register.js',
|
||||
@ -545,13 +534,6 @@ describe('loadPreset', () => {
|
||||
options: {},
|
||||
preset: {},
|
||||
},
|
||||
{
|
||||
name: '@storybook/addon-actions/register.js',
|
||||
options: {},
|
||||
preset: {
|
||||
managerEntries: [normalize('@storybook/addon-actions/register')],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'addon-foo/register.js',
|
||||
options: {},
|
||||
@ -593,7 +575,6 @@ describe('loadPreset', () => {
|
||||
presets: ['@storybook/preset-typescript'],
|
||||
addons: [
|
||||
'@storybook/addon-docs/preset',
|
||||
'@storybook/addon-actions/register.js',
|
||||
'addon-foo/register.js',
|
||||
'addon-bar',
|
||||
'addon-baz/register.js',
|
||||
|
@ -68,7 +68,6 @@ function resolvePresetFunction<T = any>(
|
||||
*
|
||||
* Valid inputs:
|
||||
*
|
||||
* - `'@storybook/addon-actions/manager' => { type: 'virtual', item }`
|
||||
* - `'@storybook/addon-docs/preset' => { type: 'presets', item }`
|
||||
* - `'@storybook/addon-docs' => { type: 'presets', item: '@storybook/addon-docs/preset' }`
|
||||
* - `{ name: '@storybook/addon-docs(/preset)?', options: { } } => { type: 'presets', item: { name:
|
||||
|
@ -6,19 +6,19 @@ describe('getAddonNames', () => {
|
||||
it('should extract addon names from simple strings', () => {
|
||||
const config = {
|
||||
stories: [],
|
||||
addons: ['@storybook/addon-actions', '@storybook/addon-outline'],
|
||||
addons: ['@storybook/addon-highlight', '@storybook/addon-outline'],
|
||||
};
|
||||
const result = getAddonNames(config);
|
||||
expect(result).toEqual(['@storybook/addon-actions', '@storybook/addon-outline']);
|
||||
expect(result).toEqual(['@storybook/addon-highlight', '@storybook/addon-outline']);
|
||||
});
|
||||
|
||||
it('should extract addon names from object notation', () => {
|
||||
const config = {
|
||||
stories: [],
|
||||
addons: [{ name: '@storybook/addon-actions' }, { name: '@storybook/addon-outline' }],
|
||||
addons: [{ name: '@storybook/addon-highlight' }, { name: '@storybook/addon-outline' }],
|
||||
};
|
||||
const result = getAddonNames(config);
|
||||
expect(result).toEqual(['@storybook/addon-actions', '@storybook/addon-outline']);
|
||||
expect(result).toEqual(['@storybook/addon-highlight', '@storybook/addon-outline']);
|
||||
});
|
||||
|
||||
it('should filter out relative paths for local addons', () => {
|
||||
@ -34,12 +34,12 @@ describe('getAddonNames', () => {
|
||||
const config = {
|
||||
stories: [],
|
||||
addons: [
|
||||
'/sandbox/react-vite-default-ts/node_modules/@storybook/addon-actions',
|
||||
'/sandbox/react-vite-default-ts/node_modules/@storybook/addon-highlight',
|
||||
'/sandbox/react-vite-default-ts/node_modules/@storybook/addon-outline',
|
||||
],
|
||||
};
|
||||
const result = getAddonNames(config);
|
||||
expect(result).toEqual(['@storybook/addon-actions', '@storybook/addon-outline']);
|
||||
expect(result).toEqual(['@storybook/addon-highlight', '@storybook/addon-outline']);
|
||||
});
|
||||
|
||||
it('should extract addon names from pnpm paths', () => {
|
||||
@ -68,7 +68,7 @@ describe('getAddonNames', () => {
|
||||
const config = {
|
||||
stories: [],
|
||||
addons: [
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-hightlight',
|
||||
{ name: '@storybook/addon-outline' },
|
||||
'./local-addon',
|
||||
'/sandbox/react-vite-default-ts/node_modules/@storybook/addon-controls',
|
||||
@ -76,7 +76,7 @@ describe('getAddonNames', () => {
|
||||
};
|
||||
const result = getAddonNames(config);
|
||||
expect(result).toEqual([
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-hightlight',
|
||||
'@storybook/addon-outline',
|
||||
'@storybook/addon-controls',
|
||||
]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { global as globalThis } from '@storybook/global';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
export default {
|
||||
component: globalThis.Components.Button,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { global as globalThis } from '@storybook/global';
|
||||
|
||||
import { actions, configureActions } from '@storybook/addon-actions';
|
||||
import { actions, configureActions } from 'storybook/actions';
|
||||
|
||||
const configs = actions('actionA', 'actionB', 'actionC');
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { global as globalThis } from '@storybook/global';
|
||||
|
||||
import { withActions } from '@storybook/addon-actions/decorator';
|
||||
import { withActions } from 'storybook/actions/decorator';
|
||||
|
||||
export default {
|
||||
component: globalThis.Components.Button,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
import { Meta, StoryObj, moduleMetadata } from '@storybook/angular';
|
||||
|
||||
import { APP_INITIALIZER } from '@angular/core';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
import { action } from 'storybook/actions';
|
||||
import { fn } from 'storybook/test';
|
||||
|
||||
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
||||
|
@ -1,7 +1,6 @@
|
||||
import type { Decorator } from '@storybook/svelte';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
|
||||
import { action } from 'storybook/actions';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
import { setAfterNavigateArgument } from './mocks/app/navigation';
|
||||
|
@ -4,7 +4,7 @@ import { styled } from 'storybook/internal/theming';
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import * as ArgRow from './ArgRow.stories';
|
||||
import { ArgsTable, ArgsTableError } from './ArgsTable';
|
||||
|
@ -1,8 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
|
||||
import { action } from 'storybook/actions';
|
||||
import { expect, fn, mocked, userEvent, within } from 'storybook/test';
|
||||
|
||||
import { __definePreview } from '../preview';
|
||||
|
@ -1,9 +1,8 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
|
||||
import type { HandlerFunction } from '@storybook/addon-actions';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
|
||||
import { action } from 'storybook/actions';
|
||||
import type { HandlerFunction } from 'storybook/actions';
|
||||
import { expect, fn, mocked, userEvent, within } from 'storybook/test';
|
||||
|
||||
import type { StoryFn as CSF2Story, StoryObj as CSF3Story, Meta } from '..';
|
||||
|
@ -1,6 +1,4 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
/* eslint-disable import/namespace */
|
||||
import { cleanup, render, screen } from '@testing-library/react';
|
||||
import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
@ -11,9 +9,8 @@ import { addons } from 'storybook/internal/preview-api';
|
||||
|
||||
import type { Meta, ReactRenderer } from '@storybook/react';
|
||||
|
||||
import * as addonActionsPreview from '@storybook/addon-actions/preview';
|
||||
|
||||
import { expectTypeOf } from 'expect-type';
|
||||
import * as addonActionsPreview from 'storybook/actions/preview';
|
||||
|
||||
import { composeStories, composeStory, setProjectAnnotations } from '..';
|
||||
import type { Button } from './Button';
|
||||
|
@ -1,6 +1,4 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
/* eslint-disable import/namespace */
|
||||
import { cleanup, render, screen } from '@testing-library/react';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
@ -10,9 +8,8 @@ import { addons } from 'storybook/internal/preview-api';
|
||||
|
||||
import type { Meta } from '@storybook/react';
|
||||
|
||||
import * as addonActionsPreview from '@storybook/addon-actions/preview';
|
||||
|
||||
import { expectTypeOf } from 'expect-type';
|
||||
import * as addonActionsPreview from 'storybook/actions/preview';
|
||||
|
||||
import { composeStories, composeStory, setProjectAnnotations } from '..';
|
||||
import type { Button } from './Button';
|
||||
|
@ -1,6 +1,4 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
/* eslint-disable import/namespace */
|
||||
import { cleanup, render, screen } from '@testing-library/react';
|
||||
import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
@ -11,9 +9,8 @@ import { addons } from 'storybook/internal/preview-api';
|
||||
|
||||
import type { Meta, ReactRenderer } from '@storybook/react';
|
||||
|
||||
import * as addonActionsPreview from '@storybook/addon-actions/preview';
|
||||
|
||||
import { expectTypeOf } from 'expect-type';
|
||||
import * as addonActionsPreview from 'storybook/actions/preview';
|
||||
|
||||
import { composeStories, composeStory, setProjectAnnotations } from '..';
|
||||
import type { Button } from './Button';
|
||||
|
@ -1,6 +1,6 @@
|
||||
```ts filename="Button.stories.ts" renderer="angular" language="ts"
|
||||
import type { Meta } from '@storybook/angular';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import Button from './button.component';
|
||||
|
||||
@ -16,7 +16,7 @@ export default meta;
|
||||
```
|
||||
|
||||
```js filename="Button.stories.js" renderer="common" language="js"
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import Button from './Button';
|
||||
|
||||
@ -32,7 +32,7 @@ export default {
|
||||
```ts filename="Button.stories.ts" renderer="common" language="ts-4-9"
|
||||
// Replace your-framework with the name of your framework
|
||||
import type { Meta } from '@storybook/your-framework';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import Button from './Button';
|
||||
|
||||
@ -50,7 +50,7 @@ export default meta;
|
||||
```ts filename="Button.stories.ts" renderer="common" language="ts"
|
||||
// Replace your-framework with the name of your framework
|
||||
import type { Meta } from '@storybook/your-framework';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import Button from './Button';
|
||||
|
||||
@ -66,7 +66,7 @@ export default meta;
|
||||
```
|
||||
|
||||
```ts filename="Button.stories.js" renderer="web-components" language="js"
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
export default {
|
||||
component: 'demo-button',
|
||||
@ -79,7 +79,7 @@ export default {
|
||||
|
||||
```ts filename="Button.stories.ts" renderer="web-components" language="ts"
|
||||
import type { Meta } from '@storybook/angular';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
const meta: Meta = {
|
||||
component: 'demo-button',
|
||||
|
@ -1,7 +1,7 @@
|
||||
```ts filename="Button.stories.ts" renderer="angular" language="ts"
|
||||
import type { Meta } from '@storybook/angular';
|
||||
|
||||
import { withActions } from '@storybook/addon-actions/decorator';
|
||||
import { withActions } from 'storybook/actions/decorator';
|
||||
|
||||
import { Button } from './button.component';
|
||||
|
||||
@ -21,7 +21,7 @@ export default meta;
|
||||
```js filename="Button.stories.js|jsx" renderer="common" language="js"
|
||||
import { Button } from './Button';
|
||||
|
||||
import { withActions } from '@storybook/addon-actions/decorator';
|
||||
import { withActions } from 'storybook/actions/decorator';
|
||||
|
||||
export default {
|
||||
component: Button,
|
||||
@ -38,7 +38,7 @@ export default {
|
||||
// Replace your-framework with the name of your framework
|
||||
import type { Meta } from '@storybook/your-framework';
|
||||
|
||||
import { withActions } from '@storybook/addon-actions/decorator';
|
||||
import { withActions } from 'storybook/actions/decorator';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -59,7 +59,7 @@ export default meta;
|
||||
// Replace your-framework with the name of your framework
|
||||
import type { Meta } from '@storybook/your-framework';
|
||||
|
||||
import { withActions } from '@storybook/addon-actions/decorator';
|
||||
import { withActions } from 'storybook/actions/decorator';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -77,7 +77,7 @@ export default meta;
|
||||
```
|
||||
|
||||
```js filename="Button.stories.js" renderer="web-components" language="js"
|
||||
import { withActions } from '@storybook/addon-actions/decorator';
|
||||
import { withActions } from 'storybook/actions/decorator';
|
||||
|
||||
export default {
|
||||
component: 'demo-button',
|
||||
@ -92,7 +92,7 @@ export default {
|
||||
|
||||
```ts filename="Button.stories.ts" renderer="web-components" language="ts"
|
||||
import type { Meta } from '@storybook/web-components';
|
||||
import { withActions } from '@storybook/addon-actions/decorator';
|
||||
import { withActions } from 'storybook/actions/decorator';
|
||||
|
||||
const meta: Meta = {
|
||||
component: 'demo-button',
|
||||
|
@ -2,7 +2,7 @@
|
||||
import type { Meta, StoryObj } from '@storybook/angular';
|
||||
import { argsToTemplate } from '@storybook/angular';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './button.component';
|
||||
|
||||
@ -32,7 +32,7 @@ export const Text: Story = {
|
||||
```
|
||||
|
||||
```js filename="Button.stories.js|jsx" renderer="react" language="js"
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -52,7 +52,7 @@ export const Text = {
|
||||
```ts filename="Button.stories.ts|tsx" renderer="react" language="ts-4-9"
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -75,7 +75,7 @@ export const Text = {
|
||||
```ts filename="Button.stories.ts|tsx" renderer="react" language="ts"
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -96,7 +96,7 @@ export const Text = {
|
||||
```
|
||||
|
||||
```js filename="Button.stories.js|jsx" renderer="solid" language="js"
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -116,7 +116,7 @@ export const Text = {
|
||||
```tsx filename="Button.stories.ts|tsx" renderer="solid" language="ts-4-9"
|
||||
import type { Meta, StoryObj } from 'storybook-solidjs';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -139,7 +139,7 @@ export const Text = {
|
||||
```ts filename="Button.stories.ts|tsx" renderer="solid" language="ts"
|
||||
import type { Meta, StoryObj } from 'storybook-solidjs';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -162,7 +162,7 @@ export const Text = {
|
||||
```js filename="Button.stories.js" renderer="svelte" language="js"
|
||||
import Button from './Button.svelte';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
export default {
|
||||
component: Button,
|
||||
@ -187,7 +187,7 @@ export const Text = {
|
||||
|
||||
```ts filename="Button.stories.ts" renderer="svelte" language="ts-4-9"
|
||||
import type { Meta, StoryObj } from '@storybook/svelte';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import Button from './Button.svelte';
|
||||
|
||||
@ -217,7 +217,7 @@ export const Primary: Story = {
|
||||
|
||||
```ts filename="Button.stories.ts" renderer="svelte" language="ts"
|
||||
import type { Meta, StoryObj } from '@storybook/svelte';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import Button from './Button.svelte';
|
||||
|
||||
@ -248,7 +248,7 @@ export const Text: Story = {
|
||||
```js filename="Button.stories.js" renderer="vue" language="js"
|
||||
import Button from './Button.vue';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
export default {
|
||||
component: Button,
|
||||
@ -276,7 +276,7 @@ import type { Meta, StoryObj } from '@storybook/vue3';
|
||||
|
||||
import Button from './Button.vue';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
const meta = {
|
||||
component: Button,
|
||||
@ -307,7 +307,7 @@ import type { Meta, StoryObj } from '@storybook/vue3';
|
||||
|
||||
import Button from './Button.vue';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
const meta: Meta<typeof Button> = {
|
||||
component: Button,
|
||||
@ -336,7 +336,7 @@ export const Primary: Story = {
|
||||
```js filename="Button.stories.js" renderer="web-components" language="js"
|
||||
import { html } from 'lit';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
export default {
|
||||
component: 'custom-button',
|
||||
@ -354,7 +354,7 @@ export const Text = {
|
||||
|
||||
```ts filename="Button.stories.ts" renderer="web-components" language="ts"
|
||||
import type { Meta, StoryObj } from '@storybook/web-components';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { html } from 'lit';
|
||||
|
||||
|
@ -3,7 +3,7 @@ import type { Meta, StoryObj } from '@storybook/angular';
|
||||
|
||||
import { Button } from './button.component';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
const meta: Meta<Button> = {
|
||||
component: Button,
|
||||
@ -24,7 +24,7 @@ export const Text: Story = {
|
||||
```
|
||||
|
||||
```js filename="Button.stories.js|jsx" renderer="react" language="js"
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -40,7 +40,7 @@ export const Text = {
|
||||
```ts filename="Button.stories.ts|tsx" renderer="react" language="ts-4-9"
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -59,7 +59,7 @@ export const Basic: Story = {
|
||||
```ts filename="Button.stories.ts|tsx" renderer="react" language="ts"
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -76,7 +76,7 @@ export const Basic: Story = {
|
||||
```
|
||||
|
||||
```js filename="Button.stories.js|jsx" renderer="solid" language="js"
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -92,7 +92,7 @@ export const Text = {
|
||||
```tsx filename="Button.stories.ts|tsx" renderer="solid" language="ts-4-9"
|
||||
import type { Meta, StoryObj } from 'storybook-solidjs';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -111,7 +111,7 @@ export const Basic: Story = {
|
||||
```tsx filename="Button.stories.ts|tsx" renderer="solid" language="ts"
|
||||
import type { Meta, StoryObj } from 'storybook-solidjs';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
@ -128,7 +128,7 @@ export const Basic: Story = {
|
||||
```
|
||||
|
||||
```js filename="Button.stories.js" renderer="svelte" language="js"
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import Button from './Button.svelte';
|
||||
|
||||
@ -151,7 +151,7 @@ export const Text = {
|
||||
|
||||
```ts filename="Button.stories.ts" renderer="svelte" language="ts-4-9"
|
||||
import type { Meta, StoryObj } from '@storybook/svelte';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import Button from './Button.svelte';
|
||||
|
||||
@ -176,7 +176,7 @@ export const Primary: Story = {
|
||||
|
||||
```ts filename="Button.stories.ts" renderer="svelte" language="ts"
|
||||
import type { Meta, StoryObj } from '@storybook/svelte';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import Button from './Button.svelte';
|
||||
|
||||
@ -203,7 +203,7 @@ export const Text: Story = {
|
||||
```js filename="Button.stories.js" renderer="vue" language="js"
|
||||
import Button from './Button.vue';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
export default {
|
||||
component: Button,
|
||||
@ -227,7 +227,7 @@ import type { Meta, StoryObj } from '@storybook/vue3';
|
||||
|
||||
import Button from './Button.vue';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
const meta = {
|
||||
component: Button,
|
||||
@ -254,7 +254,7 @@ import type { Meta, StoryObj } from '@storybook/vue3';
|
||||
|
||||
import Button from './Button.vue';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
const meta: Meta<typeof Button> = {
|
||||
component: Button,
|
||||
@ -279,7 +279,7 @@ export const Text: Story = {
|
||||
```js filename="Button.stories.js" renderer="web-components" language="js"
|
||||
import { html } from 'lit';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
export default {
|
||||
component: 'custom-button',
|
||||
@ -292,7 +292,7 @@ export const Text = {
|
||||
|
||||
```ts filename="Button.stories.ts" renderer="web-components" language="ts"
|
||||
import type { Meta, StoryObj } from '@storybook/web-components';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
|
||||
import { html } from 'lit';
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
```shell renderer="common" language="js" packageManager="npm"
|
||||
npm install @storybook/addon-actions --save-dev
|
||||
npm install @storybook/addon-viewport --save-dev
|
||||
```
|
||||
|
||||
```shell renderer="common" language="js" packageManager="pnpm"
|
||||
pnpm add --save-dev @storybook/addon-actions
|
||||
pnpm add --save-dev @storybook/addon-viewport
|
||||
```
|
||||
|
||||
```shell renderer="common" language="js" packageManager="yarn"
|
||||
yarn add --dev @storybook/addon-actions
|
||||
yarn add --dev @storybook/addon-viewport
|
||||
```
|
@ -5,7 +5,6 @@ export default {
|
||||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
addons: [
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-viewport',
|
||||
{
|
||||
name: '@storybook/addon-docs',
|
||||
@ -36,7 +35,6 @@ const config: StorybookConfig = {
|
||||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
addons: [
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-viewport',
|
||||
{
|
||||
name: '@storybook/addon-docs',
|
||||
|
@ -3,7 +3,7 @@ export default {
|
||||
// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
|
||||
framework: '@storybook/your-framework',
|
||||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
addons: ['@storybook/addon-links', '@storybook/addon-actions'],
|
||||
addons: ['@storybook/addon-links', '@storybook/addon-viewport'],
|
||||
};
|
||||
```
|
||||
|
||||
@ -14,7 +14,7 @@ import type { StorybookConfig } from '@storybook/your-framework';
|
||||
const config: StorybookConfig = {
|
||||
framework: '@storybook/your-framework',
|
||||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
addons: ['@storybook/addon-links', '@storybook/addon-actions'],
|
||||
addons: ['@storybook/addon-links', '@storybook/addon-viewport'],
|
||||
};
|
||||
|
||||
export default config;
|
@ -36,7 +36,7 @@ export const Hover = {
|
||||
|
||||
Channels enable two-way communication between the manager and the preview pane, using a NodeJS [EventEmitter](https://nodejs.org/api/events.html) compatible API. Your addons can plug into specific channels and respond to these events.
|
||||
|
||||
For example, the [Actions addon](https://storybook.js.org/addons/@storybook/addon-actions) captures user events and displays their data in a panel.
|
||||
For example, [Actions](https://storybook.js.org/docs/essentials/actions) captures user events and displays their data in a panel.
|
||||
|
||||
Use the [`useChannel`](./addons-api.mdx#usechannel) hook to access the channel data within your addon.
|
||||
|
||||
|
@ -104,7 +104,6 @@ Because a framework is a node package, it must contain a `package.json` file. He
|
||||
"<builder>": "^x.x.x"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@storybook/addon-actions": "^7.0.0",
|
||||
"<meta-framework>": "^x.x.x || ^x.x.x",
|
||||
"<renderer>": "^x.x.x || ^x.x.x",
|
||||
"<builder>": "^x.x.x"
|
||||
|
@ -7,7 +7,7 @@ sidebar:
|
||||
|
||||
<YouTubeCallout id="BTIuTuoHsQc" title="STOP logging with Storybook Actions" />
|
||||
|
||||
The actions addon is used to display data received by event handler (callback) arguments in your stories.
|
||||
Actions are used to display data received by event handler (callback) arguments in your stories.
|
||||
|
||||
<Video src="../_assets/essentials/addon-actions-demo-optimized.mp4" />
|
||||
|
||||
@ -27,7 +27,7 @@ The recommended way to write actions is to use the `fn` utility from `storybook/
|
||||
|
||||
If your component calls an arg (because of either the user's interaction or the `play` function) and that arg is spied on , the event will show up in the action panel:
|
||||
|
||||

|
||||

|
||||
|
||||
### Automatically matching args
|
||||
|
||||
@ -49,10 +49,6 @@ If you need more granular control over which `argTypes` are matched, you can adj
|
||||
|
||||
{/* prettier-ignore-end */}
|
||||
|
||||
<Callout variant="info" icon="💡">
|
||||
If you're generating argTypes with another addon (like [docs](../writing-docs/index.mdx), which is the common behavior), ensure the actions addon **AFTER** the other addon. You can do this by listing it later in the addons registration code in [`.storybook/main.js`](../configure/index.mdx#configure-story-rendering). This is default in [essentials](./index.mdx).
|
||||
</Callout>
|
||||
|
||||
## Action event handlers
|
||||
|
||||
It is also possible to detect if your component is emitting the correct HTML events using the `parameters.actions.handles` [parameter](../writing-stories/parameters.mdx).
|
||||
@ -69,7 +65,7 @@ This will bind a standard HTML event handler to the outermost HTML element rende
|
||||
|
||||
### Parameters
|
||||
|
||||
This addon contributes the following [parameters](../writing-stories/parameters.mdx) to Storybook, under the `actions` namespace:
|
||||
This contributes the following [parameters](../writing-stories/parameters.mdx) to Storybook, under the `actions` namespace:
|
||||
|
||||
#### `argTypesRegex`
|
||||
|
||||
@ -81,7 +77,7 @@ Create actions for each arg that matches the regex. Please note the significant
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Disable this addon's behavior. If you wish to disable this addon for the entire Storybook, you should do so when registering `addon-essentials`. See the [essential addon's docs](../essentials/index.mdx#disabling-addons) for more information.
|
||||
Disable the action panel.
|
||||
|
||||
This parameter is most useful to allow overriding at more specific levels. For example, if this parameter is set to `true` at the project level, it could then be re-enabled by setting it to `false` at the meta (component) or story level.
|
||||
|
||||
@ -95,10 +91,8 @@ See the [action event handlers](#action-event-handlers) section, above, for more
|
||||
|
||||
### Exports
|
||||
|
||||
This addon contributes the following exports to Storybook:
|
||||
|
||||
```js
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { action } from 'storybook/actions';
|
||||
```
|
||||
|
||||
#### `action`
|
||||
|
@ -8,7 +8,6 @@ sidebar:
|
||||
|
||||
A major strength of Storybook are [addons](https://storybook.js.org/addons) that extend Storybook’s UI and behavior. Storybook ships by default with a set of “essential” addons that add to the initial user experience. There are many third-party addons as well as “official” addons developed by the Storybook core team.
|
||||
|
||||
* [Actions](./actions.mdx)
|
||||
* [Backgrounds](./backgrounds.mdx)
|
||||
* [Controls](./controls.mdx)
|
||||
* [Docs](../writing-docs/index.mdx)
|
||||
@ -45,13 +44,13 @@ If you need to reconfigure any of the [individual Essentials addons](https://sto
|
||||
|
||||
{/* prettier-ignore-start */}
|
||||
|
||||
<CodeSnippets path="storybook-addon-actions-install.md" />
|
||||
<CodeSnippets path="storybook-addon-viewport-install.md" />
|
||||
|
||||
{/* prettier-ignore-end */}
|
||||
|
||||
{/* prettier-ignore-start */}
|
||||
|
||||
<CodeSnippets path="storybook-main-register-individual-actions-addon.md" />
|
||||
<CodeSnippets path="storybook-main-register-individual-viewport-addon.md" />
|
||||
|
||||
{/* prettier-ignore-end */}
|
||||
|
||||
@ -65,7 +64,6 @@ Below is an abridged configuration and table with all the available options for
|
||||
|
||||
| Addon | Option | Description |
|
||||
| ------------------------------ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `@storybook/addon-actions` | N/A | N/A |
|
||||
| `@storybook/addon-viewport` | N/A | N/A |
|
||||
| `@storybook/addon-docs` | `csfPluginOptions` | Provides additional configuration for Storybook's CSF plugin. Can be disabled with `null`. |
|
||||
| | `mdxPluginOptions` | Provides additional configuration options and plugin configuration for [MDX documentation](../writing-docs/mdx.mdx#markdown-tables-arent-rendering-correctly). |
|
||||
|
@ -37,12 +37,6 @@ Next, update [`.storybook/main.js|ts`](../configure/index.mdx#configure-story-re
|
||||
|
||||
{/* prettier-ignore-end */}
|
||||
|
||||
<Callout variant="info" icon="💡">
|
||||
|
||||
Make sure to list `@storybook/addon-interactions` **after** the [`@storybook/addon-essentials`](./index.mdx) addon (or the [`@storybook/addon-actions`](./actions.mdx) if you've installed it individually).
|
||||
|
||||
</Callout>
|
||||
|
||||
Now when you run Storybook, the Interactions addon will be enabled.
|
||||
|
||||

|
||||
|
@ -440,7 +440,6 @@ export async function setupVitest(details: TemplateDetails, options: PassedOptio
|
||||
import { setProjectAnnotations } from '${storybookPackage}'
|
||||
import * as rendererDocsAnnotations from '${template.expected.renderer}/dist/entry-preview-docs.mjs'
|
||||
import * as addonA11yAnnotations from '@storybook/addon-a11y/preview'
|
||||
import * as addonActionsAnnotations from '@storybook/addon-actions/preview'
|
||||
import * as addonTestAnnotations from '@storybook/addon-test/preview'
|
||||
import '../src/stories/components'
|
||||
import * as coreAnnotations from '../template-stories/core/preview'
|
||||
|
@ -11,7 +11,6 @@ module.exports = {
|
||||
addons: [
|
||||
'@storybook/addon-a11y',
|
||||
'@storybook/addon-storysource',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-docs',
|
||||
'@storybook/addon-controls',
|
||||
'@storybook/addon-links',
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,6 @@ const mainConfig: StorybookConfig = {
|
||||
addons: [
|
||||
'@storybook/addon-docs',
|
||||
'@storybook/addon-a11y',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-backgrounds',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addon-controls',
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user