mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-18 05:02:24 +08:00
Addon-docs: Eval argTypes default value
This commit is contained in:
parent
fa914a7f57
commit
0815d27d05
@ -12,10 +12,17 @@ export const extractArgTypes: ArgTypesExtractor = (component) => {
|
||||
const { rows } = props as PropsTableRowsProps;
|
||||
if (rows) {
|
||||
return rows.reduce((acc: ArgTypes, row: PropDef) => {
|
||||
const { type, sbType, defaultValue, jsDocTags, required } = row;
|
||||
const { type, sbType, defaultValue: defaultSummary, jsDocTags, required } = row;
|
||||
let defaultValue = defaultSummary && trim(defaultSummary.detail || defaultSummary.summary);
|
||||
try {
|
||||
// eslint-disable-next-line no-eval
|
||||
defaultValue = eval(defaultValue);
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch {}
|
||||
|
||||
acc[row.name] = {
|
||||
...row,
|
||||
defaultValue: defaultValue && trim(defaultValue.detail || defaultValue.summary),
|
||||
defaultValue,
|
||||
type: { required, ...sbType },
|
||||
table: {
|
||||
type,
|
||||
|
@ -3,7 +3,7 @@ module.exports = {
|
||||
// FIXME: Breaks e2e tests './intro.stories.mdx',
|
||||
'../../lib/ui/src/**/*.stories.(js|tsx|mdx)',
|
||||
'../../lib/components/src/**/*.stories.(js|tsx|mdx)',
|
||||
'./stories/**/*.stories.(js|tsx|mdx)',
|
||||
'./stories/**/*.stories.(js|ts|tsx|mdx)',
|
||||
'./../../addons/docs/**/*.stories.tsx',
|
||||
],
|
||||
addons: [
|
||||
|
Loading…
x
Reference in New Issue
Block a user