Skip to content

Commit

Permalink
Merge branch 'next' into jean-storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Oct 4, 2022
2 parents a017d1e + 7efe75a commit 16dccf7
Show file tree
Hide file tree
Showing 38 changed files with 169 additions and 78 deletions.
6 changes: 5 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
- [7.0 feature flags removed](#70-feature-flags-removed)
- [Vite builder uses vite config automatically](#vite-builder-uses-vite-config-automatically)
- [Removed docs.getContainer and getPage parameters](#removed-docsgetcontainer-and-getpage-parameters)
- [Removed STORYBOOK_REACT_CLASSES global](#removed-storybook_react_classes-global)
- [Icons API changed](#icons-api-changed)
- ['config' preset entry replaced with 'previewAnnotations'](#config-preset-entry-replaced-with-previewannotations)
- [Vue2 DOM structure changed](#vue2-dom-structure-changed)
- [Docs Changes](#docs-changes)
- [Standalone docs files](#standalone-docs-files)
- [Referencing stories in docs files](#referencing-stories-in-docs-files)
Expand Down Expand Up @@ -530,6 +530,10 @@ If you were using `viteFinal` in 6.5 to simply merge in your project's standard

It is no longer possible to set `parameters.docs.getContainer()` and `getPage()`. Instead use `parameters.docs.container` or `parameters.docs.page` directly.

#### Removed STORYBOOK_REACT_CLASSES global

This was a legacy global variable from the early days of react docgen. If you were using this variable, you can instead use docgen information which is added directly to components using `.__docgenInfo`.

#### Icons API changed

For addon authors who use the `Icons` component, its API has been updated in Storybook 7.
Expand Down
1 change: 1 addition & 0 deletions code/addons/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"devDependencies": {
"@storybook/jest": "^0.0.10",
"@storybook/testing-library": "0.0.14-next.0",
"@types/node": "^14.14.20 || ^16.0.0",
"formik": "^2.2.9",
"typescript": "~4.6.3"
},
Expand Down
2 changes: 2 additions & 0 deletions code/addons/interactions/src/preset/preview.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="node" />

import { addons } from '@storybook/addons';
import { FORCE_REMOUNT, STORY_RENDER_PHASE_CHANGED } from '@storybook/core-events';
import type {
Expand Down
1 change: 0 additions & 1 deletion code/addons/storyshots/storyshots-core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import loadFramework from '../frameworks/frameworkLoader';
import { StoryshotsOptions } from './StoryshotsOptions';

const { describe, window: globalWindow } = global;
global.STORYBOOK_REACT_CLASSES = global.STORYBOOK_REACT_CLASSES || {};

type TestMethod = 'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll';
const methods: TestMethod[] = ['beforeAll', 'beforeEach', 'afterEach', 'afterAll'];
Expand Down
1 change: 1 addition & 0 deletions code/frameworks/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@nrwl/workspace": "14.6.1",
"@types/autoprefixer": "^9.7.2",
"@types/tmp": "^0.2.3",
"@types/webpack-env": "^1.16.0",
"cross-spawn": "^7.0.3",
"jest": "^27.5.1",
"jest-preset-angular": "^12.0.0",
Expand Down
2 changes: 2 additions & 0 deletions code/frameworks/angular/src/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="webpack-env" />

import './globals';

export * from './public-api';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,6 @@ const newWebpackConfiguration = (
devtool: 'cheap-module-source-map',
entry: [
'/Users/joe/storybook/lib/core-server/dist/esm/globals/polyfills.js',
'/Users/joe/storybook/lib/core-server/dist/esm/globals/globals.js',
'/Users/joe/storybook/examples/angular-cli/.storybook/storybook-init-framework-entry.js',
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/common/config.js-generated-other-entry.js',
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/angular/config.js-generated-other-entry.js',
Expand Down
2 changes: 2 additions & 0 deletions code/frameworks/ember/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="webpack-env" />

export {
storiesOf,
setAddon,
Expand Down
1 change: 1 addition & 0 deletions code/lib/addons/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import global from 'global';

import type { ReactElement } from 'react';
import { Channel } from '@storybook/channels';
import { SET_CONFIG } from '@storybook/core-events';
Expand Down
2 changes: 1 addition & 1 deletion code/lib/addons/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export interface StoryApi<StoryFnReturnType = unknown> {
}

export interface ClientStoryApi<StoryFnReturnType = unknown> {
storiesOf(kind: StoryKind, module: NodeModule): StoryApi<StoryFnReturnType>;
storiesOf(kind: StoryKind, module: any): StoryApi<StoryFnReturnType>;
addDecorator(decorator: DecoratorFunction<StoryFnReturnType>): StoryApi<StoryFnReturnType>;
addParameters(parameter: Parameters): StoryApi<StoryFnReturnType>;
}
Expand Down
27 changes: 23 additions & 4 deletions code/lib/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,22 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./shortcut": {
"require": "./dist/shortcut.js",
"import": "./dist/shortcut.mjs",
"types": "./dist/shortcut.d.ts"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
Expand All @@ -29,7 +42,7 @@
],
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
"prep": "node ../../../scripts/prepare.js"
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/channels": "7.0.0-alpha.34",
Expand Down Expand Up @@ -64,5 +77,11 @@
"publishConfig": {
"access": "public"
},
"bundler": {
"entries": [
"./src/index.tsx",
"./src/shortcut.ts"
]
},
"gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f"
}
2 changes: 1 addition & 1 deletion code/lib/api/shortcut.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/esm/lib/shortcut';
export * from './dist/shortcut';
1 change: 1 addition & 0 deletions code/lib/api/src/shortcut.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/shortcut';
21 changes: 17 additions & 4 deletions code/lib/client-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@
},
"license": "MIT",
"sideEffects": false,
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
Expand All @@ -31,7 +39,7 @@
],
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
"prep": "node ../../../scripts/prepare.js"
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/addons": "7.0.0-alpha.34",
Expand All @@ -57,5 +65,10 @@
"publishConfig": {
"access": "public"
},
"bundler": {
"entries": [
"./src/index.ts"
]
},
"gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f"
}
2 changes: 2 additions & 0 deletions code/lib/client-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
setGlobalRender,
} from './ClientApi';

export type { GetStorybookKind, GetStorybookStory } from './ClientApi';

export * from './types';

export * from './queryparams';
Expand Down
28 changes: 17 additions & 11 deletions code/lib/core-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"files": [
"dist/**/*",
"dll/**/*",
"types/**/*",
"*.js",
"*.d.ts"
],
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
"prep": "node ../../../scripts/prepare.js"
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/addons": "7.0.0-alpha.34",
Expand Down Expand Up @@ -59,5 +60,10 @@
"publishConfig": {
"access": "public"
},
"bundler": {
"entries": [
"./src/index.ts"
]
},
"gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f"
}
5 changes: 0 additions & 5 deletions code/lib/core-client/src/globals/globals.ts

This file was deleted.

3 changes: 3 additions & 0 deletions code/lib/core-client/src/preview/executeLoadable.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// <reference types="node" />
/// <reference types="webpack-env" />

import { logger } from '@storybook/client-logger';
import { Path, ModuleExports } from '@storybook/store';
import { Loadable, RequireContext, LoaderFunction } from './types';
Expand Down
50 changes: 39 additions & 11 deletions code/lib/core-client/src/preview/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PreviewWeb } from '@storybook/preview-web';
import type { AnyFramework, ArgsStoryFn } from '@storybook/csf';
import { createChannel } from '@storybook/channel-postmessage';
import { addons } from '@storybook/addons';
import Events from '@storybook/core-events';
import { FORCE_RE_RENDER } from '@storybook/core-events';
import type { Path, WebProjectAnnotations } from '@storybook/store';

import { Loadable } from './types';
Expand All @@ -24,16 +24,45 @@ const removedApi = (name: string) => () => {
throw new Error(`@storybook/client-api:${name} was removed in storyStoreV7.`);
};

interface RendererImplementation<TFramework extends AnyFramework> {
decorateStory?: WebProjectAnnotations<TFramework>['applyDecorators'];
render?: ArgsStoryFn<TFramework>;
}

interface ClientAPIFacade {
/* deprecated */
addDecorator: (...args: any[]) => never;
/* deprecated */
addParameters: (...args: any[]) => never;
/* deprecated */
clearDecorators: (...args: any[]) => never;
/* deprecated */
addLoader: (...args: any[]) => never;
/* deprecated */
setAddon: (...args: any[]) => never;
/* deprecated */
getStorybook: (...args: any[]) => never;
/* deprecated */
storiesOf: (...args: any[]) => never;
/* deprecated */
raw: (...args: any[]) => never;
}

interface StartReturnValue<TFramework extends AnyFramework> {
/* deprecated */
forceReRender: () => void;
/* deprecated */
getStorybook: any;
/* deprecated */
configure: any;
/* deprecated */
clientApi: ClientApi<TFramework> | ClientAPIFacade;
}

export function start<TFramework extends AnyFramework>(
renderToDOM: WebProjectAnnotations<TFramework>['renderToDOM'],
{
decorateStory,
render,
}: {
decorateStory?: WebProjectAnnotations<TFramework>['applyDecorators'];
render?: ArgsStoryFn<TFramework>;
} = {}
) {
{ decorateStory, render }: RendererImplementation<TFramework> = {}
): StartReturnValue<TFramework> {
if (globalWindow) {
// To enable user code to detect if it is running in Storybook
globalWindow.IS_STORYBOOK = true;
Expand Down Expand Up @@ -84,9 +113,8 @@ export function start<TFramework extends AnyFramework>(
}

return {
forceReRender: () => channel.emit(Events.FORCE_RE_RENDER),
forceReRender: () => channel.emit(FORCE_RE_RENDER),
getStorybook: (): void[] => [],
raw: (): void => {},

clientApi,
// This gets called each time the user calls configure (i.e. once per HMR)
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-server/src/presets/common-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const previewAnnotations = async (base: any, options: Options) => {

if (config.length > 0) warnConfigField();

return [...config, require.resolve('@storybook/core-client/dist/esm/globals/globals'), ...base];
return [...config, ...base];
};

export const features = async (
Expand Down
22 changes: 18 additions & 4 deletions code/lib/telemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@
},
"license": "MIT",
"sideEffects": false,
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
Expand All @@ -31,7 +39,7 @@
],
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
"prep": "node ../../../scripts/prepare.js"
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/client-logger": "7.0.0-alpha.34",
Expand All @@ -50,5 +58,11 @@
"publishConfig": {
"access": "public"
},
"bundler": {
"entries": [
"./src/index.ts"
],
"platform": "node"
},
"gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f"
}
12 changes: 5 additions & 7 deletions code/lib/ui/src/containers/notifications.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React, { FC } from 'react';

import { Consumer, Combo, useStorybookApi } from '@storybook/api';
import type { Combo } from '@storybook/api';
import { Consumer } from '@storybook/api';

import NotificationList from '../components/notifications/NotificationList';

export const mapper = ({ state }: Combo) => {
const { clearNotification } = useStorybookApi();
const { notifications } = state;

const mapper = ({ state, api }: Combo) => {
return {
notifications,
clearNotification,
notifications: state.notifications,
clearNotification: api.clearNotification,
};
};

Expand Down
Loading

0 comments on commit 16dccf7

Please sign in to comment.