mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
Ensure that ensureControls
runs in the second pass
This commit is contained in:
parent
ee341ec5d2
commit
95d3fed76f
@ -75,4 +75,6 @@ const inferControls: ArgTypesEnhancer = (context) => {
|
||||
return combineParameters(withControls, filteredArgTypes);
|
||||
};
|
||||
|
||||
inferControls.secondPass = true;
|
||||
|
||||
export const argTypesEnhancers = [inferControls];
|
||||
|
@ -63,7 +63,11 @@ export type RenderContext<StoryFnReturnType> = RenderContextWithoutStoryContext
|
||||
};
|
||||
|
||||
export type ArgTypesEnhancer = (context: StoryContextForEnhancers) => ArgTypes;
|
||||
export type ArgsEnhancer = (context: StoryContextForEnhancers) => Args;
|
||||
export type ArgsEnhancer = (
|
||||
context: StoryContextForEnhancers
|
||||
) => Args & {
|
||||
secondPass?: boolean;
|
||||
};
|
||||
|
||||
export type Meta<StoryFnReturnType> = {
|
||||
decorators?: DecoratorFunction<StoryFnReturnType>[];
|
||||
|
@ -29,7 +29,11 @@ export interface StoryMetadata {
|
||||
decorators?: DecoratorFunction[];
|
||||
loaders?: LoaderFunction[];
|
||||
}
|
||||
export type ArgTypesEnhancer = (context: StoryContext) => ArgTypes;
|
||||
export type ArgTypesEnhancer = (
|
||||
context: StoryContext
|
||||
) => ArgTypes & {
|
||||
secondPass?: boolean;
|
||||
};
|
||||
export type ArgsEnhancer = (context: StoryContext) => Args;
|
||||
|
||||
export type StorySpecifier = StoryId | { name: StoryName; kind: StoryKind } | '*';
|
||||
|
@ -20,13 +20,18 @@ function getSingletonField(moduleExportList: ModuleExports[], field: string): an
|
||||
export function composeConfigs<StoryFnReturnType>(
|
||||
moduleExportList: ModuleExports[]
|
||||
): WebGlobalMeta<StoryFnReturnType> {
|
||||
const allArgTypeEnhancers = getArrayField(moduleExportList, 'argTypesEnhancers');
|
||||
|
||||
return {
|
||||
parameters: combineParameters(...getField(moduleExportList, 'parameters')),
|
||||
decorators: getArrayField(moduleExportList, 'decorators'),
|
||||
args: getObjectField(moduleExportList, 'args'),
|
||||
argsEnhancers: getArrayField(moduleExportList, 'argsEnhancers'),
|
||||
argTypes: getObjectField(moduleExportList, 'argTypes'),
|
||||
argTypesEnhancers: getArrayField(moduleExportList, 'argTypesEnhancers'),
|
||||
argTypesEnhancers: [
|
||||
...allArgTypeEnhancers.filter((e) => !e.secondPass),
|
||||
...allArgTypeEnhancers.filter((e) => e.secondPass),
|
||||
],
|
||||
globals: getObjectField(moduleExportList, 'globals'),
|
||||
globalTypes: getObjectField(moduleExportList, 'globalTypes'),
|
||||
loaders: getArrayField(moduleExportList, 'loaders'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user