mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[storybook] upgrade to 6.3.x (#119498)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
59eb8ea299
commit
ac23dce29f
12 changed files with 1212 additions and 1339 deletions
34
package.json
34
package.json
|
@ -74,6 +74,7 @@
|
||||||
"yarn": "^1.21.1"
|
"yarn": "^1.21.1"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
|
"**/@babel/runtime": "^7.16.3",
|
||||||
"**/@types/node": "16.10.2",
|
"**/@types/node": "16.10.2",
|
||||||
"**/chokidar": "^3.4.3",
|
"**/chokidar": "^3.4.3",
|
||||||
"**/deepmerge": "^4.2.2",
|
"**/deepmerge": "^4.2.2",
|
||||||
|
@ -469,21 +470,22 @@
|
||||||
"@microsoft/api-extractor": "7.18.19",
|
"@microsoft/api-extractor": "7.18.19",
|
||||||
"@octokit/rest": "^16.35.0",
|
"@octokit/rest": "^16.35.0",
|
||||||
"@percy/agent": "^0.28.6",
|
"@percy/agent": "^0.28.6",
|
||||||
"@storybook/addon-a11y": "^6.1.20",
|
"@storybook/addon-a11y": "^6.3.12",
|
||||||
"@storybook/addon-actions": "^6.1.20",
|
"@storybook/addon-actions": "^6.3.12",
|
||||||
"@storybook/addon-docs": "^6.1.20",
|
"@storybook/addon-docs": "^6.3.12",
|
||||||
"@storybook/addon-essentials": "^6.1.20",
|
"@storybook/addon-essentials": "^6.3.12",
|
||||||
"@storybook/addon-knobs": "^6.1.20",
|
"@storybook/addon-knobs": "^6.3.1",
|
||||||
"@storybook/addon-storyshots": "^6.1.20",
|
"@storybook/addon-storyshots": "^6.3.12",
|
||||||
"@storybook/addons": "^6.1.20",
|
"@storybook/addons": "^6.3.12",
|
||||||
"@storybook/api": "^6.1.20",
|
"@storybook/api": "^6.3.12",
|
||||||
"@storybook/components": "^6.1.20",
|
"@storybook/components": "^6.3.12",
|
||||||
"@storybook/core": "^6.1.20",
|
"@storybook/core": "^6.3.12",
|
||||||
"@storybook/core-events": "^6.1.20",
|
"@storybook/core-common": "^6.3.12",
|
||||||
"@storybook/node-logger": "^6.1.20",
|
"@storybook/core-events": "^6.3.12",
|
||||||
"@storybook/react": "^6.1.20",
|
"@storybook/node-logger": "^6.3.12",
|
||||||
"@storybook/testing-react": "^0.0.17",
|
"@storybook/react": "^6.3.12",
|
||||||
"@storybook/theming": "^6.1.20",
|
"@storybook/testing-react": "^0.0.22",
|
||||||
|
"@storybook/theming": "^6.3.12",
|
||||||
"@testing-library/dom": "^7.30.3",
|
"@testing-library/dom": "^7.30.3",
|
||||||
"@testing-library/jest-dom": "^5.11.10",
|
"@testing-library/jest-dom": "^5.11.10",
|
||||||
"@testing-library/react": "^11.2.6",
|
"@testing-library/react": "^11.2.6",
|
||||||
|
@ -518,6 +520,7 @@
|
||||||
"@types/elasticsearch": "^5.0.33",
|
"@types/elasticsearch": "^5.0.33",
|
||||||
"@types/enzyme": "^3.10.8",
|
"@types/enzyme": "^3.10.8",
|
||||||
"@types/eslint": "^7.28.0",
|
"@types/eslint": "^7.28.0",
|
||||||
|
"@types/express": "^4.17.13",
|
||||||
"@types/extract-zip": "^1.6.2",
|
"@types/extract-zip": "^1.6.2",
|
||||||
"@types/faker": "^5.1.5",
|
"@types/faker": "^5.1.5",
|
||||||
"@types/fancy-log": "^1.3.1",
|
"@types/fancy-log": "^1.3.1",
|
||||||
|
@ -643,6 +646,7 @@
|
||||||
"@types/write-pkg": "^3.1.0",
|
"@types/write-pkg": "^3.1.0",
|
||||||
"@types/xml-crypto": "^1.4.2",
|
"@types/xml-crypto": "^1.4.2",
|
||||||
"@types/xml2js": "^0.4.5",
|
"@types/xml2js": "^0.4.5",
|
||||||
|
"@types/yargs": "^15.0.0",
|
||||||
"@types/yauzl": "^2.9.1",
|
"@types/yauzl": "^2.9.1",
|
||||||
"@types/zen-observable": "^0.8.0",
|
"@types/zen-observable": "^0.8.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
||||||
|
|
|
@ -316,7 +316,7 @@ exports[`prepares assets for distribution: bar bundle 1`] = `
|
||||||
if (
|
if (
|
||||||
(o ? e.setAttribute(\\"media\\", o) : e.removeAttribute(\\"media\\"),
|
(o ? e.setAttribute(\\"media\\", o) : e.removeAttribute(\\"media\\"),
|
||||||
i &&
|
i &&
|
||||||
btoa &&
|
\\"undefined\\" != typeof btoa &&
|
||||||
(r += \\"\\\\n/*# sourceMappingURL=data:application/json;base64,\\".concat(
|
(r += \\"\\\\n/*# sourceMappingURL=data:application/json;base64,\\".concat(
|
||||||
btoa(unescape(encodeURIComponent(JSON.stringify(i)))),
|
btoa(unescape(encodeURIComponent(JSON.stringify(i)))),
|
||||||
\\" */\\"
|
\\" */\\"
|
||||||
|
|
|
@ -36,6 +36,7 @@ RUNTIME_DEPS = [
|
||||||
"@npm//@storybook/api",
|
"@npm//@storybook/api",
|
||||||
"@npm//@storybook/components",
|
"@npm//@storybook/components",
|
||||||
"@npm//@storybook/core",
|
"@npm//@storybook/core",
|
||||||
|
"@npm//@storybook/core-common",
|
||||||
"@npm//@storybook/node-logger",
|
"@npm//@storybook/node-logger",
|
||||||
"@npm//@storybook/react",
|
"@npm//@storybook/react",
|
||||||
"@npm//@storybook/theming",
|
"@npm//@storybook/theming",
|
||||||
|
@ -53,9 +54,11 @@ TYPES_DEPS = [
|
||||||
"@npm//@storybook/api",
|
"@npm//@storybook/api",
|
||||||
"@npm//@storybook/components",
|
"@npm//@storybook/components",
|
||||||
"@npm//@storybook/core",
|
"@npm//@storybook/core",
|
||||||
|
"@npm//@storybook/core-common",
|
||||||
"@npm//@storybook/node-logger",
|
"@npm//@storybook/node-logger",
|
||||||
"@npm//@storybook/react",
|
"@npm//@storybook/react",
|
||||||
"@npm//@storybook/theming",
|
"@npm//@storybook/theming",
|
||||||
|
"@npm//@types/express", # necessary for storybook which is missing the types
|
||||||
"@npm//@types/loader-utils",
|
"@npm//@types/loader-utils",
|
||||||
"@npm//@types/node",
|
"@npm//@types/node",
|
||||||
"@npm//@types/react",
|
"@npm//@types/react",
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { StorybookConfig } from '@storybook/core/types';
|
import { StorybookConfig } from '@storybook/core-common';
|
||||||
import { Configuration } from 'webpack';
|
import { Configuration } from 'webpack';
|
||||||
import webpackMerge from 'webpack-merge';
|
import webpackMerge from 'webpack-merge';
|
||||||
import { REPO_ROOT } from './constants';
|
import { REPO_ROOT } from './constants';
|
||||||
|
@ -20,6 +20,9 @@ export const defaultConfig: StorybookConfig = {
|
||||||
typescript: {
|
typescript: {
|
||||||
reactDocgen: false,
|
reactDocgen: false,
|
||||||
},
|
},
|
||||||
|
features: {
|
||||||
|
postcss: false,
|
||||||
|
},
|
||||||
webpackFinal: (config, options) => {
|
webpackFinal: (config, options) => {
|
||||||
if (process.env.CI) {
|
if (process.env.CI) {
|
||||||
config.parallelism = 4;
|
config.parallelism = 4;
|
||||||
|
|
|
@ -9,7 +9,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Icons, IconButton, TooltipLinkList, WithTooltip } from '@storybook/components';
|
import { Icons, IconButton, TooltipLinkList, WithTooltip } from '@storybook/components';
|
||||||
import { useGlobals } from '@storybook/api';
|
import { useGlobals } from '@storybook/api';
|
||||||
import { Link } from '@storybook/components/dist/tooltip/TooltipLinkList';
|
|
||||||
|
type PropsOf<T extends React.FC<any>> = T extends React.FC<infer P> ? P : never;
|
||||||
|
type ArrayItem<T extends any[]> = T extends Array<infer I> ? I : never;
|
||||||
|
type Link = ArrayItem<PropsOf<typeof TooltipLinkList>['links']>;
|
||||||
|
|
||||||
const defaultTheme = 'v8.light';
|
const defaultTheme = 'v8.light';
|
||||||
|
|
||||||
|
@ -22,7 +25,7 @@ export function ThemeSwitcher() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function Menu({ onHide }: { onHide: () => void }) {
|
function Menu({ onHide }: { onHide: () => void }) {
|
||||||
const links: Link[] = [
|
const links = [
|
||||||
{
|
{
|
||||||
id: 'v8.light',
|
id: 'v8.light',
|
||||||
title: 'Light',
|
title: 'Light',
|
||||||
|
@ -31,16 +34,18 @@ export function ThemeSwitcher() {
|
||||||
id: 'v8.dark',
|
id: 'v8.dark',
|
||||||
title: 'Dark',
|
title: 'Dark',
|
||||||
},
|
},
|
||||||
].map((link) => ({
|
].map(
|
||||||
...link,
|
(link): Link => ({
|
||||||
onClick: (_event, item) => {
|
...link,
|
||||||
if (item.id !== selectedTheme) {
|
onClick: (_event, item) => {
|
||||||
updateGlobals({ euiTheme: item.id });
|
if (item.id !== selectedTheme) {
|
||||||
}
|
updateGlobals({ euiTheme: item.id });
|
||||||
onHide();
|
}
|
||||||
},
|
onHide();
|
||||||
active: selectedTheme === link.id,
|
},
|
||||||
}));
|
active: selectedTheme === link.id,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
return <TooltipLinkList links={links} />;
|
return <TooltipLinkList links={links} />;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,3 +16,27 @@ declare module '@storybook/react/standalone';
|
||||||
// See https://github.com/storybookjs/storybook/issues/11684
|
// See https://github.com/storybookjs/storybook/issues/11684
|
||||||
declare module 'react-syntax-highlighter/dist/cjs/create-element';
|
declare module 'react-syntax-highlighter/dist/cjs/create-element';
|
||||||
declare module 'react-syntax-highlighter/dist/cjs/prism-light';
|
declare module 'react-syntax-highlighter/dist/cjs/prism-light';
|
||||||
|
|
||||||
|
// Storybook uses this module and its types are defined in the source but not in the type output
|
||||||
|
declare module 'file-system-cache' {
|
||||||
|
interface Options {
|
||||||
|
basePath?: string;
|
||||||
|
ns?: string | string[];
|
||||||
|
extension?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class FileSystemCache {
|
||||||
|
constructor(options: Options);
|
||||||
|
path(key: string): string;
|
||||||
|
fileExists(key: string): Promise<boolean>;
|
||||||
|
ensureBasePath(): Promise<void>;
|
||||||
|
get(key: string, defaultValue?: any): Promise<any | typeof defaultValue>;
|
||||||
|
getSync(key: string, defaultValue?: any): any | typeof defaultValue;
|
||||||
|
set(key: string, value: any): Promise<{ path: string }>;
|
||||||
|
setSync(key: string, value: any): this;
|
||||||
|
remove(key: string): Promise<void>;
|
||||||
|
clear(): Promise<void>;
|
||||||
|
save(): Promise<{ paths: string[] }>;
|
||||||
|
load(): Promise<{ files: Array<{ path: string; value: any }> }>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<!-- This is a copy of the
|
<!-- This is a copy of the
|
||||||
[Storybook IFrame template](https://github.com/storybookjs/storybook/blob/7874ca357c6cb54f3f258dc61f6becae6783fba6/lib/core/src/server/templates/index.ejs).
|
[Storybook IFrame template](https://github.com/storybookjs/storybook/blob/337fdcd0fe7436b46bcca65145ff6db2affd780f/lib/core-common/src/templates/index.ejs).
|
||||||
We use this one instead because we want to add the @kbn/ui-shared-deps-* tags here.
|
We use this one instead because we want to add the @kbn/ui-shared-deps-* tags here.
|
||||||
-->
|
-->
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
@ -37,23 +37,25 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<% if (typeof bodyHtmlSnippet !== 'undefined') { %> <%= bodyHtmlSnippet %> <% } %>
|
<% if (typeof bodyHtmlSnippet !== 'undefined') { %>
|
||||||
|
<%= bodyHtmlSnippet %>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<div id="docs-root"></div>
|
<div id="docs-root"></div>
|
||||||
|
|
||||||
<% if (typeof globals !== 'undefined' && Object.keys(globals).length) { %>
|
<% if (typeof globals !== 'undefined' && Object.keys(globals).length) { %>
|
||||||
<script>
|
<script>
|
||||||
<% for (var varName in globals) { %>
|
<% for (var varName in globals) { %>
|
||||||
<% if (globals[varName] != undefined) { %>
|
<% if (globals[varName] != undefined) { %>
|
||||||
window['<%=varName%>'] = <%= JSON.stringify(globals[varName]) %>;
|
window['<%=varName%>'] = <%= JSON.stringify(globals[varName]) %>;
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
</script>
|
</script>
|
||||||
<% } %> <% dlls.forEach(file => { %>
|
<% } %>
|
||||||
<script src="<%= file %>"></script>
|
|
||||||
<% }); %> <% files.js.forEach(file => { %>
|
<% files.js.forEach(file => { %>
|
||||||
<script src="<%= file %>"></script>
|
<script src="<%= file %>"></script>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -56,6 +56,7 @@ module.exports = (_, argv) => {
|
||||||
'@babel/runtime/helpers/interopRequireDefault',
|
'@babel/runtime/helpers/interopRequireDefault',
|
||||||
'@babel/runtime/helpers/interopRequireWildcard',
|
'@babel/runtime/helpers/interopRequireWildcard',
|
||||||
'@babel/runtime/helpers/objectSpread2',
|
'@babel/runtime/helpers/objectSpread2',
|
||||||
|
'@babel/runtime/helpers/objectWithoutProperties',
|
||||||
'@babel/runtime/helpers/objectWithoutPropertiesLoose',
|
'@babel/runtime/helpers/objectWithoutPropertiesLoose',
|
||||||
'@babel/runtime/helpers/slicedToArray',
|
'@babel/runtime/helpers/slicedToArray',
|
||||||
'@babel/runtime/helpers/toArray',
|
'@babel/runtime/helpers/toArray',
|
||||||
|
|
|
@ -9,13 +9,12 @@
|
||||||
import React, { useState, useEffect, useRef, ReactElement } from 'react';
|
import React, { useState, useEffect, useRef, ReactElement } from 'react';
|
||||||
import { act } from 'react-test-renderer';
|
import { act } from 'react-test-renderer';
|
||||||
import { Story } from '@storybook/react';
|
import { Story } from '@storybook/react';
|
||||||
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
|
|
||||||
import { EuiLoadingSpinner } from '@elastic/eui';
|
import { EuiLoadingSpinner } from '@elastic/eui';
|
||||||
|
|
||||||
export const waitFor =
|
export const waitFor =
|
||||||
(waitTarget: Promise<any>, spinner: ReactElement | null = <EuiLoadingSpinner />) =>
|
(waitTarget: Promise<any>, spinner: ReactElement | null = <EuiLoadingSpinner />) =>
|
||||||
(CurrentStory: Story) => {
|
(CurrentStory: Story) => {
|
||||||
const [storyComponent, setStory] = useState<StoryFnReactReturnType>();
|
const [storyComponent, setStory] = useState<ReactElement>();
|
||||||
const componentIsMounted = useRef(false);
|
const componentIsMounted = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
24
typings/index.d.ts
vendored
24
typings/index.d.ts
vendored
|
@ -38,3 +38,27 @@ declare module 'react-syntax-highlighter/dist/cjs/prism-light';
|
||||||
declare module 'monaco-editor/esm/vs/basic-languages/markdown/markdown';
|
declare module 'monaco-editor/esm/vs/basic-languages/markdown/markdown';
|
||||||
declare module 'monaco-editor/esm/vs/basic-languages/css/css';
|
declare module 'monaco-editor/esm/vs/basic-languages/css/css';
|
||||||
declare module 'monaco-editor/esm/vs/basic-languages/yaml/yaml';
|
declare module 'monaco-editor/esm/vs/basic-languages/yaml/yaml';
|
||||||
|
|
||||||
|
// Storybook uses this module and its types are defined in the source but not in the type output
|
||||||
|
declare module 'file-system-cache' {
|
||||||
|
interface Options {
|
||||||
|
basePath?: string;
|
||||||
|
ns?: string | string[];
|
||||||
|
extension?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class FileSystemCache {
|
||||||
|
constructor(options: Options);
|
||||||
|
path(key: string): string;
|
||||||
|
fileExists(key: string): Promise<boolean>;
|
||||||
|
ensureBasePath(): Promise<void>;
|
||||||
|
get(key: string, defaultValue?: any): Promise<any | typeof defaultValue>;
|
||||||
|
getSync(key: string, defaultValue?: any): any | typeof defaultValue;
|
||||||
|
set(key: string, value: any): Promise<{ path: string }>;
|
||||||
|
setSync(key: string, value: any): this;
|
||||||
|
remove(key: string): Promise<void>;
|
||||||
|
clear(): Promise<void>;
|
||||||
|
save(): Promise<{ paths: string[] }>;
|
||||||
|
load(): Promise<{ files: Array<{ path: string; value: any }> }>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { addDecorator } from '@storybook/react';
|
import { addDecorator } from '@storybook/react';
|
||||||
import { Title, Subtitle, Description, Primary, Stories } from '@storybook/addon-docs/blocks';
|
import { Title, Subtitle, Description, Primary, Stories } from '@storybook/addon-docs';
|
||||||
|
|
||||||
import { decorator } from './decorator';
|
import { decorator } from './decorator';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue