1- import { DocsContext , Heading } from '@storybook/blocks' ;
1+ import type { ArgTypes } from '@storybook/blocks' ;
2+ import { DocsContext , Heading , Subheading } from '@storybook/blocks' ;
23import TagDesign from '@ui5/webcomponents/dist/types/TagDesign.js' ;
34import { Tag , Link , MessageStrip , Popover } from '@ui5/webcomponents-react' ;
45import type * as CEM from '@ui5/webcomponents-tools/lib/cem/types' ;
5- import type { ReactNode } from 'react' ;
6+ import type { ComponentProps , ReactNode } from 'react' ;
67import { Fragment , useContext , useRef } from 'react' ;
78import { createPortal } from 'react-dom' ;
89import { useGetCem } from '../utils' ;
@@ -47,14 +48,20 @@ function Name(props: CEM.ClassMember) {
4748 ) ;
4849}
4950
50- export function DomRefTable ( ) {
51+ export function DomRefTable ( {
52+ of,
53+ isSubheading,
54+ } : {
55+ of ?: ComponentProps < typeof ArgTypes > [ 'of' ] ;
56+ isSubheading ?: boolean ;
57+ } ) {
5158 const docsContext = useContext ( DocsContext ) ;
5259 const storyTags : string [ ] = docsContext . attachedCSFFile ?. meta ?. tags ;
5360 const cemModuleName = storyTags ?. find ( ( tag ) => tag . startsWith ( 'cem-module:' ) ) ;
54- const componentName = docsContext . componentStories ( ) . at ( 0 ) ?. component ?. displayName ;
61+ const componentName = of ?. displayName ?? docsContext . componentStories ( ) . at ( 0 ) ?. component ?. displayName ;
5562 const popoverRef = useRef ( null ) ;
5663
57- const knownAttributes = new Set ( Object . keys ( docsContext . primaryStory ?. argTypes ?? { } ) ) ;
64+ const knownAttributes = new Set ( Object . keys ( of ?. __docgenInfo ?. props ?? docsContext . primaryStory ?. argTypes ?? { } ) ) ;
5865 const cem = useGetCem ( ) ;
5966
6067 const moduleName = cemModuleName ? cemModuleName . split ( ':' ) [ 1 ] : componentName ;
@@ -69,12 +76,13 @@ export function DomRefTable() {
6976 return ! ( knownAttributes . has ( row . name ) && ! row . type ?. text ?. includes ( 'HTMLElement' ) ) ;
7077 } ) ?? [ ] ;
7178 const cssParts : CEM . CssPart [ ] = componentMembers ?. cssParts ?? [ ] ;
79+ const HeadingComponent = isSubheading ? Subheading : Heading ;
7280
7381 return (
7482 < >
7583 { rows . length > 0 ? (
7684 < >
77- < Heading > DOM Properties & Methods </ Heading >
85+ < HeadingComponent > DOM Properties & Methods </ HeadingComponent >
7886 < p >
7987 This component exposes public properties and methods. You can use them directly on the instance of the
8088 component, e.g. by using React Refs.
@@ -150,7 +158,7 @@ export function DomRefTable() {
150158
151159 { cssParts . length > 0 ? (
152160 < >
153- < Heading > CSS Shadow Parts</ Heading >
161+ < HeadingComponent > CSS Shadow Parts</ HeadingComponent >
154162 < p >
155163 < Link target = { '_blank' } href = { 'https://developer.mozilla.org/en-US/docs/Web/CSS/::part' } >
156164 CSS Shadow Parts
0 commit comments