From 4d21678d46f9a11be6dad5f56a5ef6d75f2f17d9 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 12 May 2021 15:52:10 +1000 Subject: [PATCH 1/7] Add a concept of `argsEnhancers` --- lib/client-api/src/story_store.ts | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/client-api/src/story_store.ts b/lib/client-api/src/story_store.ts index 12a6f175dbeb..ec46e11d3766 100644 --- a/lib/client-api/src/story_store.ts +++ b/lib/client-api/src/story_store.ts @@ -29,6 +29,7 @@ import { PublishedStoreItem, ErrorLike, GetStorybookKind, + ArgsEnhancer, ArgTypesEnhancer, StoreSelectionSpecifier, StoreSelection, @@ -124,6 +125,8 @@ export default class StoryStore { // Keyed on storyId _stories: StoreData; + _argsEnhancers: ArgsEnhancer[]; + _argTypesEnhancers: ArgTypesEnhancer[]; _selectionSpecifier?: StoreSelectionSpecifier; @@ -140,6 +143,7 @@ export default class StoryStore { this._globalMetadata = { parameters: {}, decorators: [], loaders: [] }; this._kinds = {}; this._stories = {}; + this._argsEnhancers = []; this._argTypesEnhancers = [ensureArgTypes]; this._error = undefined; this._channel = params.channel; @@ -312,9 +316,16 @@ export default class StoryStore { this._kinds[kind].loaders.push(...loaders); } + addArgsEnhancer(argsEnhancer: ArgsEnhancer) { + if (Object.keys(this._stories).length > 0) + throw new Error('Cannot add an args enhancer to the store after a story has been added.'); + + this._argsEnhancers.push(argsEnhancer); + } + addArgTypesEnhancer(argTypesEnhancer: ArgTypesEnhancer) { if (Object.keys(this._stories).length > 0) - throw new Error('Cannot add a parameter enhancer to the store after a story has been added.'); + throw new Error('Cannot add an argTypes enhancer to the store after a story has been added.'); this._argTypesEnhancers.push(argTypesEnhancer); } @@ -481,7 +492,21 @@ export default class StoryStore { return acc; }, {} as Args); - const initialArgs = { ...defaultArgs, ...passedArgs }; + const initialArgsBeforeEnhancers = { ...defaultArgs, ...passedArgs }; + const initialArgs = this._argsEnhancers.reduce( + (accumulatedArgs: Args, enhancer) => ({ + ...accumulatedArgs, + ...enhancer({ + ...identification, + parameters: combinedParameters, + args: initialArgsBeforeEnhancers, + argTypes, + globals: {}, + }), + }), + initialArgsBeforeEnhancers + ); + _stories[id] = { ...identification, From a2d419e6257a44075f5a2b80a8bdc504c961ac70 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 12 May 2021 15:54:13 +1000 Subject: [PATCH 2/7] Add a concept of `argsEnhancers` --- .../storyshots-core/src/frameworks/Loader.ts | 1 + .../src/frameworks/configure.ts | 16 +++++++--- .../preview/virtualModuleEntry.template.js | 11 ++++++- .../preview/virtualModuleEntry.template.js | 11 ++++++- lib/client-api/src/client_api.ts | 12 ++++++++ lib/client-api/src/story_store.test.ts | 30 +++++++++++++++++++ lib/client-api/src/types.ts | 1 + 7 files changed, 76 insertions(+), 6 deletions(-) diff --git a/addons/storyshots/storyshots-core/src/frameworks/Loader.ts b/addons/storyshots/storyshots-core/src/frameworks/Loader.ts index a257e0e0e8ba..e62a43b399d5 100644 --- a/addons/storyshots/storyshots-core/src/frameworks/Loader.ts +++ b/addons/storyshots/storyshots-core/src/frameworks/Loader.ts @@ -12,6 +12,7 @@ export interface ClientApi extends ClientStoryApi { getStorybook: ClientApiThing['getStorybook']; setAddon: ClientApiThing['setAddon']; raw: ClientApiThing['raw']; + addArgsEnhancer: ClientApiThing['addArgsEnhancer']; addArgTypesEnhancer: ClientApiThing['addArgTypesEnhancer']; } diff --git a/addons/storyshots/storyshots-core/src/frameworks/configure.ts b/addons/storyshots/storyshots-core/src/frameworks/configure.ts index e80b4f2d6782..4c456d3c174b 100644 --- a/addons/storyshots/storyshots-core/src/frameworks/configure.ts +++ b/addons/storyshots/storyshots-core/src/frameworks/configure.ts @@ -3,7 +3,7 @@ import path from 'path'; import { toRequireContext } from '@storybook/core-common'; import registerRequireContextHook from 'babel-plugin-require-context-hook/register'; import global from 'global'; -import { ArgTypesEnhancer, DecoratorFunction } from '@storybook/client-api'; +import { ArgsEnhancer, ArgTypesEnhancer, DecoratorFunction } from '@storybook/client-api'; import { ClientApi } from './Loader'; import { StoryshotsOptions } from '../api/StoryshotsOptions'; @@ -85,9 +85,14 @@ function configure( if (preview) { // This is essentially the same code as lib/core/src/server/preview/virtualModuleEntry.template - const { parameters, decorators, globals, globalTypes, argTypesEnhancers } = jest.requireActual( - preview - ); + const { + parameters, + decorators, + globals, + globalTypes, + argsEnhancers, + argTypesEnhancers, + } = jest.requireActual(preview); if (decorators) { decorators.forEach((decorator: DecoratorFunction) => storybook.addDecorator(decorator)); @@ -95,6 +100,9 @@ function configure( if (parameters || globals || globalTypes) { storybook.addParameters({ ...parameters, globals, globalTypes }); } + if (argsEnhancers) { + argsEnhancers.forEach((enhancer: ArgsEnhancer) => storybook.addArgsEnhancer(enhancer)); + } if (argTypesEnhancers) { argTypesEnhancers.forEach((enhancer: ArgTypesEnhancer) => storybook.addArgTypesEnhancer(enhancer) diff --git a/lib/builder-webpack4/src/preview/virtualModuleEntry.template.js b/lib/builder-webpack4/src/preview/virtualModuleEntry.template.js index 214d3fe8a164..fa6d2b0ccb9e 100644 --- a/lib/builder-webpack4/src/preview/virtualModuleEntry.template.js +++ b/lib/builder-webpack4/src/preview/virtualModuleEntry.template.js @@ -1,5 +1,11 @@ /* eslint-disable import/no-unresolved */ -import { addDecorator, addParameters, addLoader, addArgTypesEnhancer } from '{{clientApi}}'; +import { + addDecorator, + addParameters, + addLoader, + addArgsEnhancer, + addArgTypesEnhancer, +} from '{{clientApi}}'; import { logger } from '{{clientLogger}}'; import * as config from '{{configFilename}}'; @@ -22,6 +28,9 @@ Object.keys(config).forEach((key) => { case 'argTypesEnhancers': { return value.forEach((enhancer) => addArgTypesEnhancer(enhancer)); } + case 'argsEnhancers': { + return value.forEach((enhancer) => addArgsEnhancer(enhancer)); + } case 'globals': case 'globalTypes': { const v = {}; diff --git a/lib/builder-webpack5/src/preview/virtualModuleEntry.template.js b/lib/builder-webpack5/src/preview/virtualModuleEntry.template.js index 214d3fe8a164..fa6d2b0ccb9e 100644 --- a/lib/builder-webpack5/src/preview/virtualModuleEntry.template.js +++ b/lib/builder-webpack5/src/preview/virtualModuleEntry.template.js @@ -1,5 +1,11 @@ /* eslint-disable import/no-unresolved */ -import { addDecorator, addParameters, addLoader, addArgTypesEnhancer } from '{{clientApi}}'; +import { + addDecorator, + addParameters, + addLoader, + addArgsEnhancer, + addArgTypesEnhancer, +} from '{{clientApi}}'; import { logger } from '{{clientLogger}}'; import * as config from '{{configFilename}}'; @@ -22,6 +28,9 @@ Object.keys(config).forEach((key) => { case 'argTypesEnhancers': { return value.forEach((enhancer) => addArgTypesEnhancer(enhancer)); } + case 'argsEnhancers': { + return value.forEach((enhancer) => addArgsEnhancer(enhancer)); + } case 'globals': case 'globalTypes': { const v = {}; diff --git a/lib/client-api/src/client_api.ts b/lib/client-api/src/client_api.ts index dd30236e7730..37946fe8f950 100644 --- a/lib/client-api/src/client_api.ts +++ b/lib/client-api/src/client_api.ts @@ -10,6 +10,7 @@ import { DecoratorFunction, ClientApiAddons, StoryApi, + ArgsEnhancer, ArgTypesEnhancer, } from './types'; import { applyHooks } from './hooks'; @@ -65,6 +66,13 @@ export const addLoader = (loader: LoaderFunction, deprecationWarning = true) => singleton.addLoader(loader); }; +export const addArgsEnhancer = (enhancer: ArgsEnhancer) => { + if (!singleton) + throw new Error(`Singleton client API not yet initialized, cannot call addArgsEnhancer`); + + singleton.addArgsEnhancer(enhancer); +}; + export const addArgTypesEnhancer = (enhancer: ArgTypesEnhancer) => { if (!singleton) throw new Error(`Singleton client API not yet initialized, cannot call addArgTypesEnhancer`); @@ -136,6 +144,10 @@ export default class ClientApi { this._storyStore.addGlobalMetadata({ loaders: [loader] }); }; + addArgsEnhancer = (enhancer: ArgsEnhancer) => { + this._storyStore.addArgsEnhancer(enhancer); + }; + addArgTypesEnhancer = (enhancer: ArgTypesEnhancer) => { this._storyStore.addArgTypesEnhancer(enhancer); }; diff --git a/lib/client-api/src/story_store.test.ts b/lib/client-api/src/story_store.test.ts index 1283125d5752..e34f3683fcb7 100644 --- a/lib/client-api/src/story_store.test.ts +++ b/lib/client-api/src/story_store.test.ts @@ -648,6 +648,36 @@ describe('preview.story_store', () => { }); }); + describe('argsEnhancer', () => { + it('allows you to add args', () => { + const store = new StoryStore({ channel }); + + const enhancer = jest.fn((context) => ({ c: 'd' })); + store.addArgsEnhancer(enhancer); + + addStoryToStore(store, 'a', '1', (args: any) => 0, { args: { a: 'b' } }); + + expect(enhancer).toHaveBeenCalledWith(expect.objectContaining({ args: { a: 'b' } })); + expect(store.getRawStory('a', '1').args).toEqual({ a: 'b', c: 'd' }); + }); + + it('does not pass result of earlier enhancers into subsequent ones, but composes their output', () => { + const store = new StoryStore({ channel }); + + const enhancerOne = jest.fn((context) => ({ c: 'd' })); + store.addArgsEnhancer(enhancerOne); + + const enhancerTwo = jest.fn((context) => ({ e: 'f' })); + store.addArgsEnhancer(enhancerTwo); + + addStoryToStore(store, 'a', '1', (args: any) => 0, { args: { a: 'b' } }); + + expect(enhancerOne).toHaveBeenCalledWith(expect.objectContaining({ args: { a: 'b' } })); + expect(enhancerTwo).toHaveBeenCalledWith(expect.objectContaining({ args: { a: 'b' } })); + expect(store.getRawStory('a', '1').args).toEqual({ a: 'b', c: 'd', e: 'f' }); + }); + }); + describe('argTypesEnhancer', () => { it('records when the given story processes args', () => { const store = new StoryStore({ channel }); diff --git a/lib/client-api/src/types.ts b/lib/client-api/src/types.ts index cdd76b118082..d34201120b45 100644 --- a/lib/client-api/src/types.ts +++ b/lib/client-api/src/types.ts @@ -30,6 +30,7 @@ export interface StoryMetadata { loaders?: LoaderFunction[]; } export type ArgTypesEnhancer = (context: StoryContext) => ArgTypes; +export type ArgsEnhancer = (context: StoryContext) => Args; type StorySpecifier = StoryId | { name: StoryName; kind: StoryKind } | '*'; From f33a2f577dcc284e1fbe71cae16ebd7470e8d3d0 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 12 May 2021 16:14:09 +1000 Subject: [PATCH 3/7] Update actions to use an argsEnhancer --- addons/actions/src/preset/addArgs.ts | 2 +- .../actions/src/preset/addArgsHelpers.test.ts | 84 +++++++++---------- addons/actions/src/preset/addArgsHelpers.ts | 50 ++++++----- 3 files changed, 69 insertions(+), 67 deletions(-) diff --git a/addons/actions/src/preset/addArgs.ts b/addons/actions/src/preset/addArgs.ts index 6b65f3e3dd1b..df078d72209e 100644 --- a/addons/actions/src/preset/addArgs.ts +++ b/addons/actions/src/preset/addArgs.ts @@ -1,3 +1,3 @@ import { addActionsFromArgTypes, inferActionsFromArgTypesRegex } from './addArgsHelpers'; -export const argTypesEnhancers = [addActionsFromArgTypes, inferActionsFromArgTypesRegex]; +export const argsEnhancers = [addActionsFromArgTypes, inferActionsFromArgTypesRegex]; diff --git a/addons/actions/src/preset/addArgsHelpers.test.ts b/addons/actions/src/preset/addArgsHelpers.test.ts index 09593ec4a2f0..7d45753fa401 100644 --- a/addons/actions/src/preset/addArgsHelpers.test.ts +++ b/addons/actions/src/preset/addArgsHelpers.test.ts @@ -6,71 +6,65 @@ const withDefaultValue = (argTypes) => describe('actions parameter enhancers', () => { describe('actions.argTypesRegex parameter', () => { - const baseParameters = { - argTypes: { onClick: {}, onFocus: {}, somethingElse: {} }, - actions: { argTypesRegex: '^on.*' }, - }; + const parameters = { actions: { argTypesRegex: '^on.*' } }; + const argTypes = { onClick: {}, onFocus: {}, somethingElse: {} }; it('should add actions that match a pattern', () => { - const parameters = baseParameters; - const argTypes = inferActionsFromArgTypesRegex({ parameters } as StoryContext); - expect(withDefaultValue(argTypes)).toEqual(['onClick', 'onFocus']); + const args = inferActionsFromArgTypesRegex(({ + argTypes, + parameters, + } as unknown) as StoryContext); + expect(args).toEqual({ + onClick: expect.any(Function), + onFocus: expect.any(Function), + }); }); it('should override pre-existing argTypes', () => { - const parameters = { - ...baseParameters, + const args = inferActionsFromArgTypesRegex(({ + parameters, argTypes: { onClick: { defaultValue: 'pre-existing value' }, }, - }; - const argTypes = inferActionsFromArgTypesRegex({ parameters } as StoryContext); - expect(withDefaultValue(argTypes)).toEqual(['onClick']); - expect(argTypes.onClick.defaultValue).not.toBeNull(); - expect(argTypes.onClick.defaultValue).not.toEqual('pre-existing value'); + } as unknown) as StoryContext); + expect(args).toEqual({ + onClick: expect.any(Function), + }); }); it('should do nothing if actions are disabled', () => { - const parameters = { - ...baseParameters, - actions: { ...baseParameters.actions, disable: true }, - }; - const result = inferActionsFromArgTypesRegex({ parameters } as StoryContext); - expect(result).toEqual(parameters.argTypes); + const args = inferActionsFromArgTypesRegex(({ + parameters: { + ...parameters, + actions: { ...parameters.actions, disable: true }, + }, + argTypes, + } as unknown) as StoryContext); + expect(args).toEqual({}); }); }); describe('argTypes.action parameter', () => { - const baseParameters = { - argTypes: { - onClick: { action: 'clicked!' }, - onBlur: { action: 'blurred!' }, - }, + const argTypes = { + onClick: { action: 'clicked!' }, + onBlur: { action: 'blurred!' }, }; it('should add actions based on action.args', () => { - const parameters = baseParameters; - const argTypes = addActionsFromArgTypes({ parameters } as StoryContext); - expect(withDefaultValue(argTypes)).toEqual(['onClick', 'onBlur']); - }); - - it('should override pre-existing args', () => { - const parameters = { - ...baseParameters, - argTypes: { - onClick: { defaultValue: 'pre-existing value', action: 'onClick' }, - onBlur: { action: 'onBlur' }, - }, - }; - const argTypes = addActionsFromArgTypes({ parameters } as StoryContext); - expect(withDefaultValue(argTypes)).toEqual(['onClick', 'onBlur']); - expect(argTypes.onClick.defaultValue).not.toBeNull(); - expect(argTypes.onClick.defaultValue).not.toEqual('pre-existing value'); + expect( + addActionsFromArgTypes(({ argTypes, parameters: {} } as unknown) as StoryContext) + ).toEqual({ + onClick: expect.any(Function), + onBlur: expect.any(Function), + }); }); it('should do nothing if actions are disabled', () => { - const parameters = { ...baseParameters, actions: { disable: true } }; - const result = addActionsFromArgTypes({ parameters } as StoryContext); - expect(result).toEqual(parameters.argTypes); + expect( + addActionsFromArgTypes(({ + argTypes, + parameters: { actions: { disable: true } }, + } as unknown) as StoryContext) + ).toEqual({}); }); }); }); diff --git a/addons/actions/src/preset/addArgsHelpers.ts b/addons/actions/src/preset/addArgsHelpers.ts index 91cbf930a86f..307d107fc2a7 100644 --- a/addons/actions/src/preset/addArgsHelpers.ts +++ b/addons/actions/src/preset/addArgsHelpers.ts @@ -1,5 +1,6 @@ import mapValues from 'lodash/mapValues'; -import { ArgTypesEnhancer } from '@storybook/client-api'; +import { Args, ArgTypes } from '@storybook/addons'; +import { ArgsEnhancer } from '@storybook/client-api'; import { action } from '../index'; // interface ActionsParameter { @@ -12,35 +13,42 @@ import { action } from '../index'; * matches a regex, such as `^on.*` for react-style `onClick` etc. */ -export const inferActionsFromArgTypesRegex: ArgTypesEnhancer = (context) => { - const { actions, argTypes } = context.parameters; +export const inferActionsFromArgTypesRegex: ArgsEnhancer = (context) => { + const { + parameters: { actions }, + argTypes, + } = context; if (!actions || actions.disable || !actions.argTypesRegex || !argTypes) { - return argTypes; + return {}; } const argTypesRegex = new RegExp(actions.argTypesRegex); - return mapValues(argTypes, (argType, name) => { - if (!argTypesRegex.test(name)) { - return argType; - } - return { ...argType, defaultValue: action(name) }; - }); + const argTypesMatchingRegex = Object.entries(argTypes).filter( + ([name]) => !!argTypesRegex.test(name) + ); + + return argTypesMatchingRegex.reduce((acc, [name, argType]) => { + acc[name] = action(name); + return acc; + }, {} as Args); }; + /** * Add action args for list of strings. */ - -export const addActionsFromArgTypes: ArgTypesEnhancer = (context) => { - const { argTypes, actions } = context.parameters; +export const addActionsFromArgTypes: ArgsEnhancer = (context) => { + const { + argTypes, + parameters: { actions }, + } = context; if (actions?.disable || !argTypes) { - return argTypes; + return {}; } - return mapValues(argTypes, (argType, name) => { - if (!argType.action) { - return argType; - } - const message = typeof argType.action === 'string' ? argType.action : name; - return { ...argType, defaultValue: action(message) }; - }); + const argTypesWithAction = Object.entries(argTypes).filter(([name, argType]) => !!argType.action); + + return argTypesWithAction.reduce((acc, [name, argType]) => { + acc[name] = action(typeof argType.action === 'string' ? argType.action : name); + return acc; + }, {} as Args); }; From fb572cd0bcdd5bf74cef150691aff988e9e727b0 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Fri, 14 May 2021 15:03:32 +1000 Subject: [PATCH 4/7] Add a warning for `argType.defaultValue` --- MIGRATION.md | 16 ++++++++++++++++ lib/client-api/src/story_store.ts | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/MIGRATION.md b/MIGRATION.md index 291e0008cb84..25e09c4fa13d 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -3,6 +3,7 @@ - [From version 6.2.x to 6.3.0](#from-version-62x-to-630) - [6.3 deprecations](#63-deprecations) - [Deprecated scoped blocks imports](#deprecated-scoped-blocks-imports) + - [Deprecated argType.defaulValue](#deprecated-argtype-defaultValue) - [From version 6.1.x to 6.2.0](#from-version-61x-to-620) - [MDX pattern tweaked](#mdx-pattern-tweaked) - [6.2 Angular overhaul](#62-angular-overhaul) @@ -173,6 +174,21 @@ import { Meta, Story } from '@storybook/addon-docs/blocks'; import { Meta, Story } from '@storybook/addon-docs'; ``` +#### Deprecated `argType.defaultValue` + +Previously, unset `args` were set to the `argType.defaultValue` if set or inferred from the component's prop types (etc.). In 6.3 we no longer infer default values and instead set arg values to `undefined` when unset, allowing the framework to supply the default value. + +If you were using `argType.defaultValue` to fix issues with the above inference, it should no longer be necessary, you can remove that code. If you were using it to set a default value for an arg, there is a simpler way; simply set a value for the arg at the component level: + +```js +export default { + component: MyComponent, + args: { + argName: 'default-value', + }, +}; +``` + ## From version 6.1.x to 6.2.0 ### MDX pattern tweaked diff --git a/lib/client-api/src/story_store.ts b/lib/client-api/src/story_store.ts index ec46e11d3766..84b39a2004fa 100644 --- a/lib/client-api/src/story_store.ts +++ b/lib/client-api/src/story_store.ts @@ -87,6 +87,14 @@ const storyFnWarning = deprecate( https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-storyfn` ); +const argTypeDefaultValueWarning = deprecate( + () => {}, + dedent` + \`argType.defaultValue\` is deprecated and will be removed in Storybook 7.0. + + https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-argtype-defaultValue` +); + interface AllowUnsafeOption { allowUnsafe?: boolean; } @@ -491,6 +499,9 @@ export default class StoryStore { } return acc; }, {} as Args); + if (defaultArgs !== {}) { + argTypeDefaultValueWarning(); + } const initialArgsBeforeEnhancers = { ...defaultArgs, ...passedArgs }; const initialArgs = this._argsEnhancers.reduce( From 0150c5e05ac4014e48dc90b5cd7a4cdb6b0e6b97 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Fri, 14 May 2021 15:04:23 +1000 Subject: [PATCH 5/7] Fix deepscan issues --- addons/actions/src/preset/addArgsHelpers.test.ts | 3 --- addons/actions/src/preset/addArgsHelpers.ts | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/actions/src/preset/addArgsHelpers.test.ts b/addons/actions/src/preset/addArgsHelpers.test.ts index 7d45753fa401..6132e1a49b6f 100644 --- a/addons/actions/src/preset/addArgsHelpers.test.ts +++ b/addons/actions/src/preset/addArgsHelpers.test.ts @@ -1,9 +1,6 @@ import { StoryContext } from '@storybook/addons'; import { inferActionsFromArgTypesRegex, addActionsFromArgTypes } from './addArgsHelpers'; -const withDefaultValue = (argTypes) => - Object.keys(argTypes).filter((key) => !!argTypes[key].defaultValue); - describe('actions parameter enhancers', () => { describe('actions.argTypesRegex parameter', () => { const parameters = { actions: { argTypesRegex: '^on.*' } }; diff --git a/addons/actions/src/preset/addArgsHelpers.ts b/addons/actions/src/preset/addArgsHelpers.ts index 307d107fc2a7..13e775042c3c 100644 --- a/addons/actions/src/preset/addArgsHelpers.ts +++ b/addons/actions/src/preset/addArgsHelpers.ts @@ -1,5 +1,4 @@ -import mapValues from 'lodash/mapValues'; -import { Args, ArgTypes } from '@storybook/addons'; +import { Args } from '@storybook/addons'; import { ArgsEnhancer } from '@storybook/client-api'; import { action } from '../index'; From a74f9d83448a2a7661034e97800595a12d6c9b21 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Fri, 14 May 2021 15:12:34 +1000 Subject: [PATCH 6/7] Thanks deepscan! --- lib/client-api/src/story_store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client-api/src/story_store.ts b/lib/client-api/src/story_store.ts index 84b39a2004fa..ae881b45e94e 100644 --- a/lib/client-api/src/story_store.ts +++ b/lib/client-api/src/story_store.ts @@ -499,7 +499,7 @@ export default class StoryStore { } return acc; }, {} as Args); - if (defaultArgs !== {}) { + if (Object.keys(defaultArgs).length > 0) { argTypeDefaultValueWarning(); } From 8644131659f121bb6b1552fb3f9e49ddc14be2cd Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Fri, 14 May 2021 16:49:23 +1000 Subject: [PATCH 7/7] Fix missing export --- lib/client-api/src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/client-api/src/index.ts b/lib/client-api/src/index.ts index 844d7234d529..2ff983a94d12 100644 --- a/lib/client-api/src/index.ts +++ b/lib/client-api/src/index.ts @@ -2,6 +2,7 @@ import ClientApi, { addDecorator, addParameters, addLoader, + addArgsEnhancer, addArgTypesEnhancer, } from './client_api'; import { defaultDecorateStory } from './decorators'; @@ -24,6 +25,7 @@ export * from './inferControls'; export type { PropDescriptor } from './filterArgTypes'; export { + addArgsEnhancer, addArgTypesEnhancer, addDecorator, addLoader,