How to use checkDeprecatedOptionParameters method in storybook-root

Best JavaScript code snippet using storybook-root

stories.ts

Source:stories.ts Github

copy

Full Screen

...95 `96 );97 return acc;98}, {} as Record<string, () => void>);99function checkDeprecatedOptionParameters(options?: Record<string, any>) {100 if (!options) {101 return;102 }103 Object.keys(options).forEach((option: string) => {104 if (deprecatedOptionsParameterWarnings[option]) {105 deprecatedOptionsParameterWarnings[option]();106 }107 });108}109export const init: ModuleFn = ({110 fullAPI,111 store,112 navigate,113 provider,114 storyId: initialStoryId,115 viewMode: initialViewMode,116}) => {117 const api: SubAPI = {118 storyId: toId,119 getData: (storyId, refId) => {120 const result = api.resolveStory(storyId, refId);121 return isRoot(result) ? undefined : result;122 },123 isPrepared: (storyId, refId) => {124 const data = api.getData(storyId, refId);125 if (data.isLeaf) {126 return data.prepared;127 }128 // Groups are always prepared :shrug:129 return true;130 },131 resolveStory: (storyId, refId) => {132 const { refs, storiesHash } = store.getState();133 if (refId) {134 return refs[refId].stories ? refs[refId].stories[storyId] : undefined;135 }136 return storiesHash ? storiesHash[storyId] : undefined;137 },138 getCurrentStoryData: () => {139 const { storyId, refId } = store.getState();140 return api.getData(storyId, refId);141 },142 getParameters: (storyIdOrCombo, parameterName) => {143 const { storyId, refId } =144 typeof storyIdOrCombo === 'string'145 ? { storyId: storyIdOrCombo, refId: undefined }146 : storyIdOrCombo;147 const data = api.getData(storyId, refId);148 if (isStory(data)) {149 const { parameters } = data;150 if (parameters) {151 return parameterName ? parameters[parameterName] : parameters;152 }153 return {};154 }155 return null;156 },157 getCurrentParameter: (parameterName) => {158 const { storyId, refId } = store.getState();159 const parameters = api.getParameters({ storyId, refId }, parameterName);160 // FIXME Returning falsey parameters breaks a bunch of toolbars code,161 // so this strange logic needs to be here until various client code is updated.162 return parameters || undefined;163 },164 jumpToComponent: (direction) => {165 const { storiesHash, storyId, refs, refId } = store.getState();166 const story = api.getData(storyId, refId);167 // cannot navigate when there's no current selection168 if (!story) {169 return;170 }171 const hash = refId ? refs[refId].stories || {} : storiesHash;172 const lookupList = Object.entries(hash).reduce((acc, i) => {173 const value = i[1];174 if (value.isComponent) {175 acc.push([...i[1].children]);176 }177 return acc;178 }, []);179 const index = lookupList.findIndex((i) => i.includes(storyId));180 // cannot navigate beyond fist or last181 if (index === lookupList.length - 1 && direction > 0) {182 return;183 }184 if (index === 0 && direction < 0) {185 return;186 }187 const result = lookupList[index + direction][0];188 if (result) {189 api.selectStory(result, undefined, { ref: refId });190 }191 },192 jumpToStory: (direction) => {193 const { storiesHash, storyId, refs, refId } = store.getState();194 const story = api.getData(storyId, refId);195 if (DOCS_MODE) {196 api.jumpToComponent(direction);197 return;198 }199 // cannot navigate when there's no current selection200 if (!story) {201 return;202 }203 const hash = story.refId ? refs[story.refId].stories : storiesHash;204 const lookupList = Object.keys(hash).filter(205 (k) => !(hash[k].children || Array.isArray(hash[k]))206 );207 const index = lookupList.indexOf(storyId);208 // cannot navigate beyond fist or last209 if (index === lookupList.length - 1 && direction > 0) {210 return;211 }212 if (index === 0 && direction < 0) {213 return;214 }215 const result = lookupList[index + direction];216 if (result) {217 api.selectStory(result, undefined, { ref: refId });218 }219 },220 setStories: async (input, error) => {221 // Now create storiesHash by reordering the above by group222 const hash = transformStoriesRawToStoriesHash(input, {223 provider,224 });225 await store.setState({226 storiesHash: hash,227 storiesConfigured: true,228 storiesFailed: error,229 });230 },231 selectFirstStory: () => {232 const { storiesHash } = store.getState();233 const firstStory = Object.keys(storiesHash).find(234 (k) => !(storiesHash[k].children || Array.isArray(storiesHash[k]))235 );236 if (firstStory) {237 api.selectStory(firstStory);238 return;239 }240 navigate('/');241 },242 selectStory: (kindOrId = undefined, story = undefined, options = {}) => {243 const { ref, viewMode: viewModeFromArgs } = options;244 const {245 viewMode: viewModeFromState = 'story',246 storyId,247 storiesHash,248 refs,249 } = store.getState();250 const hash = ref ? refs[ref].stories : storiesHash;251 const kindSlug = storyId?.split('--', 2)[0];252 if (!story) {253 const s = kindOrId ? hash[kindOrId] || hash[sanitize(kindOrId)] : hash[kindSlug];254 // eslint-disable-next-line no-nested-ternary255 const id = s ? (s.children ? s.children[0] : s.id) : kindOrId;256 let viewMode =257 s && !isRoot(s) && (viewModeFromArgs || s.parameters.viewMode)258 ? s.parameters.viewMode259 : viewModeFromState;260 // Some viewModes are not story-specific, and we should reset viewMode261 // to 'story' if one of those is active when navigating to another story262 if (['settings', 'about', 'release'].includes(viewMode)) {263 viewMode = 'story';264 }265 const p = s && s.refId ? `/${viewMode}/${s.refId}_${id}` : `/${viewMode}/${id}`;266 navigate(p);267 } else if (!kindOrId) {268 // This is a slugified version of the kind, but that's OK, our toId function is idempotent269 const id = toId(kindSlug, story);270 api.selectStory(id, undefined, options);271 } else {272 const id = ref ? `${ref}_${toId(kindOrId, story)}` : toId(kindOrId, story);273 if (hash[id]) {274 api.selectStory(id, undefined, options);275 } else {276 // Support legacy API with component permalinks, where kind is `x/y` but permalink is 'z'277 const k = hash[sanitize(kindOrId)];278 if (k && k.children) {279 const foundId = k.children.find((childId) => hash[childId].name === story);280 if (foundId) {281 api.selectStory(foundId, undefined, options);282 }283 }284 }285 }286 },287 findLeafStoryId(storiesHash, storyId) {288 if (storiesHash[storyId].isLeaf) {289 return storyId;290 }291 const childStoryId = storiesHash[storyId].children[0];292 return api.findLeafStoryId(storiesHash, childStoryId);293 },294 updateStoryArgs: (story, updatedArgs) => {295 const { id: storyId, refId } = story;296 fullAPI.emit(UPDATE_STORY_ARGS, {297 storyId,298 updatedArgs,299 options: {300 target: refId ? `storybook-ref-${refId}` : 'storybook-preview-iframe',301 },302 });303 },304 resetStoryArgs: (story, argNames?: [string]) => {305 const { id: storyId, refId } = story;306 fullAPI.emit(RESET_STORY_ARGS, {307 storyId,308 argNames,309 options: {310 target: refId ? `storybook-ref-${refId}` : 'storybook-preview-iframe',311 },312 });313 },314 fetchStoryList: async () => {315 try {316 const result = await fetch(STORY_INDEX_PATH);317 if (result.status !== 200) throw new Error(await result.text());318 const storyIndex = (await result.json()) as StoryIndex;319 // We can only do this if the stories.json is a proper storyIndex320 if (storyIndex.v !== 3) {321 logger.warn(`Skipping story index with version v${storyIndex.v}, awaiting SET_STORIES.`);322 return;323 }324 await fullAPI.setStoryList(storyIndex);325 } catch (err) {326 store.setState({327 storiesConfigured: true,328 storiesFailed: err,329 });330 }331 },332 setStoryList: async (storyIndex: StoryIndex) => {333 const hash = transformStoryIndexToStoriesHash(storyIndex, {334 provider,335 });336 await store.setState({337 storiesHash: hash,338 storiesConfigured: true,339 storiesFailed: null,340 });341 },342 updateStory: async (343 storyId: StoryId,344 update: StoryUpdate,345 ref?: ComposedRef346 ): Promise<void> => {347 if (!ref) {348 const { storiesHash } = store.getState();349 storiesHash[storyId] = {350 ...storiesHash[storyId],351 ...update,352 } as Story;353 await store.setState({ storiesHash });354 } else {355 const { id: refId, stories } = ref;356 stories[storyId] = {357 ...stories[storyId],358 ...update,359 } as Story;360 await fullAPI.updateRef(refId, { stories });361 }362 },363 };364 const initModule = async () => {365 // On initial load, the local iframe will select the first story (or other "selection specifier")366 // and emit STORY_SPECIFIED with the id. We need to ensure we respond to this change.367 fullAPI.on(368 STORY_SPECIFIED,369 function handler({370 storyId,371 viewMode,372 }: {373 storyId: string;374 viewMode: ViewMode;375 [k: string]: any;376 }) {377 const { sourceType } = getEventMetadata(this, fullAPI);378 if (fullAPI.isSettingsScreenActive()) return;379 if (sourceType === 'local') {380 // Special case -- if we are already at the story being specified (i.e. the user started at a given story),381 // we don't need to change URL. See https://github.com/storybookjs/storybook/issues/11677382 const state = store.getState();383 if (state.storyId !== storyId || state.viewMode !== viewMode) {384 navigate(`/${viewMode}/${storyId}`);385 }386 }387 }388 );389 fullAPI.on(STORY_CHANGED, function handler() {390 const { sourceType } = getEventMetadata(this, fullAPI);391 if (sourceType === 'local') {392 const options = fullAPI.getCurrentParameter('options');393 if (options) {394 checkDeprecatedOptionParameters(options);395 fullAPI.setOptions(options);396 }397 }398 });399 fullAPI.on(SET_STORIES, function handler(data: SetStoriesPayload) {400 const { ref } = getEventMetadata(this, fullAPI);401 const stories = data.v ? denormalizeStoryParameters(data) : data.stories;402 if (!ref) {403 if (!data.v) {404 throw new Error('Unexpected legacy SET_STORIES event from local source');405 }406 fullAPI.setStories(stories);407 const options = fullAPI.getCurrentParameter('options');408 checkDeprecatedOptionParameters(options);409 fullAPI.setOptions(options);410 } else {411 fullAPI.setRef(ref.id, { ...ref, ...data, stories }, true);412 }413 });414 fullAPI.on(415 SELECT_STORY,416 function handler({417 kind,418 story,419 storyId,420 ...rest421 }: {422 kind: string;423 story: string;424 storyId: string;425 viewMode: ViewMode;426 }) {427 const { ref } = getEventMetadata(this, fullAPI);428 if (!ref) {429 fullAPI.selectStory(storyId || kind, story, rest);430 } else {431 fullAPI.selectStory(storyId || kind, story, { ...rest, ref: ref.id });432 }433 }434 );435 fullAPI.on(STORY_PREPARED, function handler({ id, ...update }) {436 const { ref } = getEventMetadata(this, fullAPI);437 fullAPI.updateStory(id, { ...update, prepared: true }, ref);438 if (!ref) {439 if (!store.getState().hasCalledSetOptions) {440 const { options } = update.parameters;441 checkDeprecatedOptionParameters(options);442 fullAPI.setOptions(options);443 store.setState({ hasCalledSetOptions: true });444 }445 } else {446 fullAPI.updateRef(ref.id, { ready: true });447 }448 });449 fullAPI.on(450 STORY_ARGS_UPDATED,451 function handleStoryArgsUpdated({ storyId, args }: { storyId: StoryId; args: Args }) {452 const { ref } = getEventMetadata(this, fullAPI);453 fullAPI.updateStory(storyId, { args }, ref);454 }455 );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { checkDeprecatedOptionParameters } from 'storybook-root-decorator';2checkDeprecatedOptionParameters();3import { rootDecorator } from 'storybook-root-decorator';4export const decorators = [rootDecorator];5import { withOptions } from '@storybook/addon-options';6export const parameters = withOptions({7});8import { withRootDecorator } from 'storybook-root-decorator';9export const parameters = withRootDecorator({10});11import { withRootDecoratorAndOptions } from 'storybook-root-decorator';12export const parameters = withRootDecoratorAndOptions({13});14import { withRootDecoratorAndDeprecatedOptions } from 'storybook-root-decorator';15export const parameters = withRootDecoratorAndDeprecatedOptions({16});17import { withRootDecoratorAndDeprecatedOptionsAndOptions } from 'storybook-root-decorator';18export const parameters = withRootDecoratorAndDeprecatedOptionsAndOptions({19});20import { withRootDecoratorAndOptionsAndDeprecatedOptions } from 'storybook-root-decorator';21export const parameters = withRootDecoratorAndOptionsAndDeprecatedOptions({22});23import { withRootDecoratorAndDeprecatedOptionsAndOptionsAndOptions } from 'storybook-root-decorator';24export const parameters = withRootDecoratorAndDeprecatedOptionsAndOptionsAndOptions({25});26import { withRootDecoratorAndOptionsAndDeprecatedOptionsAndOptions } from 'storybook-root-decorator';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { checkDeprecatedOptionParameters } from 'storybook-root-decorator';2export const parameters = {3 options: {4 storySort: {5 },6 },7};8checkDeprecatedOptionParameters(parameters);9import { withRootDecorator } from 'storybook-root-decorator';10export const decorators = [withRootDecorator];11import { withRootDecorator } from 'storybook-root-decorator';12export const decorators = [withRootDecorator];13import { withRootDecorator } from 'storybook-root-decorator';14export const decorators = [withRootDecorator];15import { withRootDecorator } from 'storybook-root-decorator';16export const decorators = [withRootDecorator];17import { withRootDecorator } from 'storybook-root-decorator';18export const decorators = [withRootDecorator];19import { withRootDecorator } from 'storybook-root-decorator';20export const decorators = [withRootDecorator];21import { withRootDecorator } from 'storybook-root-decorator';22export const decorators = [withRootDecorator];23import { withRootDecorator } from 'storybook-root-decorator';24export const decorators = [withRootDecorator];25import { withRootDecorator } from 'storybook-root-decorator';26export const decorators = [withRootDecorator];27import { withRootDecorator } from 'storybook-root-decorator';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { checkDeprecatedOptionParameters } from 'storybook-root-decorator';2 {3 },4 {5 },6];7checkDeprecatedOptionParameters(deprecatedOptions);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { checkDeprecatedOptionParameters } from 'storybook-root-decorator';2checkDeprecatedOptionParameters({3 options: {4 },5 {6 },7});8export default {9};10export const Test = () => <div>Test</div>;11Test.story = {12 parameters: {13 options: {14 },15 },16};17import { configure, addDecorator } from '@storybook/react';18import { withRootDecorator } from 'storybook-root-decorator';19import { checkDeprecatedOptionParameters } from 'storybook-root-decorator';20addDecorator(withRootDecorator);21const req = require.context('../src/components', true, /\.stories\.js$/);22function loadStories() {23 req.keys().forEach(filename => req(filename));24}25configure(loadStories, module);26checkDeprecatedOptionParameters({27 options: {28 },29 {30 },31});32import { addParameters } from '@storybook/react';33addParameters({34 options: {35 },36});37import { addons } from '@storybook/addons';38import { checkDeprecatedOptionParameters } from 'storybook-root-decorator';39checkDeprecatedOptionParameters({40 options: {41 },42 {43 },44});45addons.setConfig({46});47const path = require('path');48const { checkDeprecatedOptionParameters } = require('storybook-root-decorator');49checkDeprecatedOptionParameters({50 options: {51 },52 {53 },

Full Screen

Using AI Code Generation

copy

Full Screen

1import { checkDeprecatedOptionParameters } from 'storybook-root';2checkDeprecatedOptionParameters('addon-actions', 'actions', {3 options: {4 }5});6import { checkDeprecatedOptionParameters } from 'storybook-root';7export function checkDeprecatedOptionParameters(8 { method, options }9) {10 if (options) {11 if (options.depth) {12 logger.warn(13 `The '${optionName}' addon option for the '${addonName}' addon has been deprecated. Please use the 'depth' option in the '${method}' method instead.`14 );15 }16 }17}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { checkDeprecatedOptionParameters } from '@storybook/storybook-deprecated-api';2checkDeprecatedOptionParameters();3start();4import { checkDeprecatedStoryParameters } from '@storybook/storybook-deprecated-api';5checkDeprecatedStoryParameters();6start();7import { checkDeprecatedKnobsUsage } from '@storybook/storybook-deprecated-api';8checkDeprecatedKnobsUsage();9start();10import { checkDeprecatedStorybookVersion } from '@storybook/storybook-deprecated-api';11checkDeprecatedStorybookVersion();12start();13import { checkDeprecatedStorybookConfig } from '@storybook/storybook-deprecated-api';14checkDeprecatedStorybookConfig();15start();16import { checkDeprecatedStoryshotsUsage } from '@storybook/storybook-deprecated-api';17checkDeprecatedStoryshotsUsage();18start();19import { checkDeprecatedAddons } from '@storybook/storybook-deprecated-api';20checkDeprecatedAddons();21start();22import { checkDeprecatedChannel } from '@storybook/storybook-deprecated-api';23checkDeprecatedChannel();24start();25import { checkDeprecatedStoriesOfUsage } from '@

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful