Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (storedDefaultSetup === null) {
storedDefaultSetup = { ...setup };
}
Object.assign(setup, parameters as Setup);
} else if (storedDefaultSetup !== null) {
Object.assign(setup, storedDefaultSetup);
storedDefaultSetup = null;
}
addons.getChannel().on(EVENTS.REQUEST, () => run(setup.element, setup.config, setup.options));
return getStory(context);
},
});
// TODO: REMOVE at v6.0.0
export const withA11Y = deprecate(
// @ts-ignore
(...args: any[]) => withA11y(...args),
'withA11Y has been renamed withA11y'
);
// TODO: REMOVE at v6.0.0
export const checkA11y = deprecate(
// @ts-ignore
(...args: any[]) => withA11y(...args),
'checkA11y has been renamed withA11y'
);
// TODO: REMOVE at v6.0.0
export const configureA11y = deprecate(
(config: any) => {
setup = config;
// TODO: REMOVE at v6.0.0
export const withA11Y = deprecate(
// @ts-ignore
(...args: any[]) => withA11y(...args),
'withA11Y has been renamed withA11y'
);
// TODO: REMOVE at v6.0.0
export const checkA11y = deprecate(
// @ts-ignore
(...args: any[]) => withA11y(...args),
'checkA11y has been renamed withA11y'
);
// TODO: REMOVE at v6.0.0
export const configureA11y = deprecate(
(config: any) => {
setup = config;
},
dedent`
configureA11y is deprecated, please configure addon-a11y using the addParameter api:
addParameters({
a11y: {
// ... axe options
element: '#root', // optional selector which element to inspect
},
});
`
);
import path from 'path';
import fs from 'fs';
import deprecate from 'util-deprecate';
const fallbackHeadUsage = deprecate(() => {},
'Usage of head.html has been deprecated. Please rename head.html to preview-head.html');
export function parseList(str) {
return str.split(',');
}
export function getPreviewHeadHtml(configDirPath) {
const headHtmlPath = path.resolve(configDirPath, 'preview-head.html');
const fallbackHtmlPath = path.resolve(configDirPath, 'head.html');
let headHtml = '';
if (fs.existsSync(headHtmlPath)) {
headHtml = fs.readFileSync(headHtmlPath, 'utf8');
} else if (fs.existsSync(fallbackHtmlPath)) {
headHtml = fs.readFileSync(fallbackHtmlPath, 'utf8');
fallbackHeadUsage();
}
showStoriesPanel: 'showNav';
showAddonPanel: 'showPanel';
addonPanelInRight: 'panelPosition';
} = {
goFullScreen: 'isFullscreen',
showStoriesPanel: 'showNav',
showAddonPanel: 'showPanel',
addonPanelInRight: 'panelPosition',
};
const deprecationMessage = (optionsMap: OptionsMap, prefix = '') =>
`The options { ${Object.keys(optionsMap).join(', ')} } are deprecated -- use ${
prefix ? `${prefix}'s` : ''
} { ${Object.values(optionsMap).join(', ')} } instead.`;
const applyDeprecatedThemeOptions = deprecate(({ name, url, theme }: Options): PartialThemeVars => {
const { brandTitle, brandUrl, brandImage }: PartialThemeVars = theme || {};
return {
brandTitle: brandTitle || name,
brandUrl: brandUrl || url,
brandImage: brandImage || null,
};
}, deprecationMessage(deprecatedThemeOptions));
const applyDeprecatedLayoutOptions = deprecate((options: Options): PartialLayout => {
const layoutUpdate: PartialLayout = {};
['goFullScreen', 'showStoriesPanel', 'showAddonPanel'].forEach(
(option: 'goFullScreen' | 'showStoriesPanel' | 'showAddonPanel') => {
const v = options[option];
if (typeof v !== 'undefined') {
const key = deprecatedLayoutOptions[option];
value,
groupId,
};
return manager.knob(name, finalOptions);
}
export function color(name, value, groupId) {
return manager.knob(name, { type: 'color', value, groupId });
}
export function object(name, value, groupId) {
return manager.knob(name, { type: 'object', value, groupId });
}
export const select = deprecate(
(name, options, value, groupId) =>
manager.knob(name, { type: 'select', options, value, groupId }),
'in v4 keys/values of the options argument are reversed'
);
export function selectV2(name, options, value, groupId) {
return manager.knob(name, { type: 'select', selectV2: true, options, value, groupId });
}
export function array(name, value, separator = ',', groupId) {
return manager.knob(name, { type: 'array', value, separator, groupId });
}
export function date(name, value = new Date(), groupId) {
const proxyValue = value ? value.getTime() : null;
return manager.knob(name, { type: 'date', value: proxyValue, groupId });
import path from 'path';
import fs from 'fs';
import deprecate from 'util-deprecate';
const fallbackHeadUsage = deprecate(() => {},
'Usage of head.html has been deprecated. Please rename head.html to preview-head.html');
export function getPreviewHeadHtml(configDirPath) {
const headHtmlPath = path.resolve(configDirPath, 'preview-head.html');
const fallbackHtmlPath = path.resolve(configDirPath, 'head.html');
let headHtml = '';
if (fs.existsSync(headHtmlPath)) {
headHtml = fs.readFileSync(headHtmlPath, 'utf8');
} else if (fs.existsSync(fallbackHtmlPath)) {
headHtml = fs.readFileSync(fallbackHtmlPath, 'utf8');
fallbackHeadUsage();
}
return headHtml;
}
import addons from '@storybook/addons';
import deprecate from 'util-deprecate';
import EVENTS, { ADDON_ID } from './constants';
addons.register(
ADDON_ID,
deprecate(api => {
const channel = addons.getChannel();
channel.on(EVENTS.SET, data => {
api.setOptions(data.options);
});
}, 'storybook-addon-options is deprecated and will stop working soon')
);
import deprecate from 'util-deprecate';
import { createDefaultWebpackConfig } from '@storybook/core/server';
module.exports = deprecate(
createDefaultWebpackConfig,
"importing default webpack config generator from '@storybook/mithril/dist/server/config/defaults/webpack.config.js' is deprecated. Use third argument of your exported function instead. See https://storybook.js.org/configurations/custom-webpack-config/#full-control-mode--default"
);
import deprecate from 'util-deprecate';
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
deprecate(
() => {},
'@storybook/react-native/addons is deprecated. See https://storybook.js.org/addons/using-addons/'
)();
color,
object,
array,
date,
select,
files,
button,
withKnobs as commonWithKnobs,
withKnobsOptions as commonWithKnobsOptions,
} from '.';
export { knob, text, boolean, number, color, object, array, date, select, files, button };
export const selectV2 = deprecate(select, 'selectV2 has been renamed to select');
export const withKnobs = deprecate(
commonWithKnobs,
"addon-knobs: framework-specific imports are deprecated, just use `import {withKnobs} from '@storybook/addon-knobs`"
);
export const withKnobsOptions = deprecate(
commonWithKnobsOptions,
"addon-knobs: framework-specific imports are deprecated, just use `import {withKnobsOptions} from '@storybook/addon-knobs`"
);