1- import { Description , Subtitle , Title } from '@storybook/addon-docs/blocks' ;
1+ import type { Controls } from '@storybook/addon-docs/blocks' ;
2+ import { Description , Subtitle , Title , useOf } from '@storybook/addon-docs/blocks' ;
23import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js' ;
34import MessageStripDesign from '@ui5/webcomponents/dist/types/MessageStripDesign.js' ;
45import copyIcon from '@ui5/webcomponents-icons/dist/copy.js' ;
@@ -13,6 +14,7 @@ import {
1314 ThemeProvider ,
1415} from '@ui5/webcomponents-react' ;
1516import { clsx } from 'clsx' ;
17+ import type { ComponentProps } from 'react' ;
1618import { useGetSubComponentsOfModule } from '../utils' ;
1719import classes from './DocsHeader.module.css' ;
1820import { GitHubLogo } from './GitHub-Mark' ;
@@ -52,16 +54,17 @@ interface InfoTableProps {
5254 mergeSubComponents ?: boolean ;
5355 isChart ?: boolean ;
5456 experimental ?: boolean ;
57+ of : ComponentProps < typeof Controls > [ 'of' ] ;
5558}
5659
57- export const InfoTable = ( { since, subComponents, mergeSubComponents } : InfoTableProps ) => {
58- //todo: context is not available anymore like this
59- // const context = useContext(DocsContext);
60- return null ;
61- const groups = context . componentStories ( ) . at ( 0 ) . kind . split ( '/' ) ;
62- const moduleName = groups [ groups . length - 1 ] . replace ( '(experimental)' , '' ) . trim ( ) ;
60+ export const InfoTable = ( { of, since, subComponents, mergeSubComponents } : InfoTableProps ) => {
61+ const context = useOf < 'meta' > ( of ) ;
62+ const { csfFile, preparedMeta } = context ;
63+ console . log ( context ) ;
64+ const moduleName = csfFile . meta . component . displayName ;
6365
64- const wcSubComponents = useGetSubComponentsOfModule ( moduleName . replace ( 'V2' , '' ) ) ;
66+ const wcSubComponents = useGetSubComponentsOfModule ( moduleName . replace ( 'V2' , '' ) , preparedMeta . tags ) ;
67+ console . log ( moduleName ) ;
6568 const subComps = mergeSubComponents
6669 ? [ ...( subComponents ?? [ ] ) , ...( wcSubComponents ?? [ ] ) ]
6770 : ( subComponents ?? wcSubComponents ) ;
@@ -85,7 +88,7 @@ export const InfoTable = ({ since, subComponents, mergeSubComponents }: InfoTabl
8588 < Label > Usage</ Label >
8689 </ th >
8790 < td data-import-cell = { supportsClipboardApi } >
88- < Import />
91+ < Import componentName = { moduleName } componentId = { preparedMeta . componentId } />
8992 { supportsClipboardApi && (
9093 < Button
9194 design = { ButtonDesign . Transparent }
@@ -133,7 +136,7 @@ export const InfoTable = ({ since, subComponents, mergeSubComponents }: InfoTabl
133136 ) ;
134137} ;
135138
136- export const DocsHeader = ( { since, subComponents, mergeSubComponents, isChart, experimental } : InfoTableProps ) => {
139+ export const DocsHeader = ( { of , since, subComponents, mergeSubComponents, isChart, experimental } : InfoTableProps ) => {
137140 return (
138141 < ThemeProvider >
139142 < FlexBox alignItems = { FlexBoxAlignItems . Center } className = { classes . titleRow } >
@@ -143,7 +146,7 @@ export const DocsHeader = ({ since, subComponents, mergeSubComponents, isChart,
143146 < Links />
144147 </ FlexBox >
145148 < Subtitle />
146- < InfoTable since = { since } subComponents = { subComponents } mergeSubComponents = { mergeSubComponents } />
149+ < InfoTable of = { of } since = { since } subComponents = { subComponents } mergeSubComponents = { mergeSubComponents } />
147150 < TableOfContent />
148151 < Description />
149152 { isChart && (
0 commit comments