-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
undo deprecations removal (will do this in a separate branch so it ca…
…n be reviewed
- Loading branch information
Showing
97 changed files
with
890 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
import type { AnyFramework, DecoratorFunction } from '@storybook/csf'; | ||
import deprecate from 'util-deprecate'; | ||
import dedent from 'ts-dedent'; | ||
|
||
export { PARAM_KEY } from './constants'; | ||
export * from './highlight'; | ||
export * from './params'; | ||
|
||
if (module && module.hot && module.hot.decline) { | ||
module.hot.decline(); | ||
} | ||
|
||
export const withA11y: DecoratorFunction<AnyFramework> = deprecate( | ||
(storyFn, storyContext) => { | ||
return storyFn(storyContext); | ||
}, | ||
dedent` | ||
withA11y(options) is deprecated, please configure addon-a11y using the addParameter api: | ||
addParameters({ | ||
a11y: options, | ||
}); | ||
More at: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#removed-witha11y-decorator | ||
` | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { withActions } from '../index'; | ||
|
||
export const decorators = [withActions]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './addDecorator'; | ||
export * from './addArgs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import deprecate from 'util-deprecate'; | ||
import dedent from 'ts-dedent'; | ||
|
||
import { DecoratorFunction } from '../models'; | ||
|
||
export const decorateAction = (_decorators: DecoratorFunction[]) => { | ||
return deprecate( | ||
() => {}, | ||
dedent` | ||
decorateAction is no longer supported as of Storybook 6.0. | ||
` | ||
); | ||
}; | ||
|
||
const deprecatedCallback = deprecate(() => {}, | ||
'decorate.* is no longer supported as of Storybook 6.0.'); | ||
|
||
export const decorate = (_decorators: DecoratorFunction[]) => { | ||
return deprecate( | ||
() => { | ||
return { | ||
action: deprecatedCallback, | ||
actions: deprecatedCallback, | ||
withActions: deprecatedCallback, | ||
}; | ||
}, | ||
dedent` | ||
decorate is deprecated, please configure addon-actions using the addParameter api: | ||
addParameters({ | ||
actions: { | ||
handles: options | ||
}, | ||
}); | ||
` | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export * from './action'; | ||
export * from './actions'; | ||
export * from './configureActions'; | ||
export * from './decorateAction'; | ||
export * from './withActions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Based on http://backbonejs.org/docs/backbone.html#section-164 | ||
import global from 'global'; | ||
import { useEffect, makeDecorator } from '@storybook/addons'; | ||
import deprecate from 'util-deprecate'; | ||
import dedent from 'ts-dedent'; | ||
|
||
import { actions } from './actions'; | ||
|
||
import { PARAM_KEY } from '../constants'; | ||
|
||
const { document, Element } = global; | ||
|
||
const delegateEventSplitter = /^(\S+)\s*(.*)$/; | ||
|
||
const isIE = Element != null && !Element.prototype.matches; | ||
const matchesMethod = isIE ? 'msMatchesSelector' : 'matches'; | ||
|
||
const root = document && document.getElementById('root'); | ||
|
||
const hasMatchInAncestry = (element: any, selector: any): boolean => { | ||
if (element[matchesMethod](selector)) { | ||
return true; | ||
} | ||
const parent = element.parentElement; | ||
if (!parent) { | ||
return false; | ||
} | ||
return hasMatchInAncestry(parent, selector); | ||
}; | ||
|
||
const createHandlers = (actionsFn: (...arg: any[]) => object, ...handles: any[]) => { | ||
const actionsObject = actionsFn(...handles); | ||
return Object.entries(actionsObject).map(([key, action]) => { | ||
const [_, eventName, selector] = key.match(delegateEventSplitter); | ||
return { | ||
eventName, | ||
handler: (e: { target: any }) => { | ||
if (!selector || hasMatchInAncestry(e.target, selector)) { | ||
action(e); | ||
} | ||
}, | ||
}; | ||
}); | ||
}; | ||
|
||
const applyEventHandlers = deprecate( | ||
(actionsFn: any, ...handles: any[]) => { | ||
useEffect(() => { | ||
if (root != null) { | ||
const handlers = createHandlers(actionsFn, ...handles); | ||
handlers.forEach(({ eventName, handler }) => root.addEventListener(eventName, handler)); | ||
return () => | ||
handlers.forEach(({ eventName, handler }) => | ||
root.removeEventListener(eventName, handler) | ||
); | ||
} | ||
return undefined; | ||
}, [root, actionsFn, handles]); | ||
}, | ||
dedent` | ||
withActions(options) is deprecated, please configure addon-actions using the addParameter api: | ||
addParameters({ | ||
actions: { | ||
handles: options | ||
}, | ||
}); | ||
` | ||
); | ||
|
||
const applyDeprecatedOptions = (actionsFn: any, options: any[]) => { | ||
if (options) { | ||
applyEventHandlers(actionsFn, options); | ||
} | ||
}; | ||
|
||
export const withActions = makeDecorator({ | ||
name: 'withActions', | ||
parameterName: PARAM_KEY, | ||
skipIfNoParametersOrOptions: true, | ||
wrapper: (getStory, context, { parameters, options }) => { | ||
applyDeprecatedOptions(actions, options as any[]); | ||
|
||
if (parameters && parameters.handles) applyEventHandlers(actions, ...parameters.handles); | ||
|
||
return getStory(context); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { ColorPalette, ColorItem, IconGallery, IconItem, Typeset } from '@storybook/components'; | ||
export * from './dist/types/blocks/index.d'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import deprecate from 'util-deprecate'; | ||
import dedent from 'ts-dedent'; | ||
|
||
const warnBlocksImport = deprecate( | ||
() => {}, | ||
dedent` | ||
Importing from '@storybook/addon-docs/blocks' is deprecated, import directly from '@storybook/addon-docs' instead: | ||
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-scoped-blocks-imports | ||
` | ||
); | ||
warnBlocksImport(); | ||
|
||
export * from './dist/esm/blocks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, { ComponentProps } from 'react'; | ||
import deprecate from 'util-deprecate'; | ||
import dedent from 'ts-dedent'; | ||
import { Canvas } from './Canvas'; | ||
|
||
export const Preview = deprecate( | ||
(props: ComponentProps<typeof Canvas>) => <Canvas {...props} />, | ||
dedent` | ||
Preview doc block has been renamed to Canvas. | ||
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#previewprops-renamed | ||
` | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { ComponentProps } from 'react'; | ||
import deprecate from 'util-deprecate'; | ||
import dedent from 'ts-dedent'; | ||
import { ArgsTable } from './ArgsTable'; | ||
import { CURRENT_SELECTION } from './types'; | ||
|
||
export const Props = deprecate( | ||
(props: ComponentProps<typeof ArgsTable>) => <ArgsTable {...props} />, | ||
dedent` | ||
Props doc block has been renamed to ArgsTable. | ||
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#previewprops-renamed | ||
` | ||
); | ||
|
||
// @ts-ignore | ||
Props.defaultProps = { | ||
of: CURRENT_SELECTION, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.