mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-10 00:12:22 +08:00
23 lines
704 B
TypeScript
23 lines
704 B
TypeScript
import { sanitize, AnyFramework } from '@storybook/csf';
|
|
|
|
import { ModuleExports, NormalizedComponentAnnotations } from '../types';
|
|
import { normalizeInputTypes } from './normalizeInputTypes';
|
|
|
|
export function normalizeComponentAnnotations<TFramework extends AnyFramework>(
|
|
defaultExport: ModuleExports['default'],
|
|
title: string = defaultExport.title,
|
|
importPath?: string
|
|
): NormalizedComponentAnnotations<TFramework> {
|
|
const { id, argTypes } = defaultExport;
|
|
return {
|
|
id: sanitize(id || title),
|
|
...defaultExport,
|
|
title,
|
|
...(argTypes && { argTypes: normalizeInputTypes(argTypes) }),
|
|
parameters: {
|
|
fileName: importPath,
|
|
...defaultExport.parameters,
|
|
},
|
|
};
|
|
}
|