Skip to content

Commit 5aa6dcd

Browse files
committed
migrate subcomponent DOM properties & shadow parts table
1 parent ede3c47 commit 5aa6dcd

File tree

37 files changed

+435
-300
lines changed

37 files changed

+435
-300
lines changed

.storybook/components/ArgTypesWithNote.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DomRefTable } from '@sb/components/DomRefTable.js';
2-
import { ArgTypes } from '@storybook/addon-docs/blocks';
2+
import { ArgTypes, type Controls } from '@storybook/addon-docs/blocks';
33
import MessageStripDesign from '@ui5/webcomponents/dist/types/MessageStripDesign.js';
44
import { MessageStrip } from '@ui5/webcomponents-react';
55
import type { ComponentProps, ReactNode } from 'react';
@@ -17,16 +17,20 @@ interface ArgTypesWithNotePropTypes {
1717
* If `true` all headings are rendered as `Heading`s instead of `Subheading`s.
1818
*/
1919
isHeading?: boolean;
20+
/**
21+
* Story meta module.
22+
*/
23+
metaOf: ComponentProps<typeof Controls>['of'];
2024
}
2125

2226
export function ArgTypesWithNote(props: ComponentProps<typeof ArgTypes> & ArgTypesWithNotePropTypes) {
23-
const { hideHTMLPropsNote, noteText, isHeading, ...rest } = props;
27+
const { hideHTMLPropsNote, noteText, isHeading, metaOf, ...rest } = props;
2428

2529
if (hideHTMLPropsNote) {
2630
return (
2731
<>
2832
<ArgTypes {...rest} />
29-
<DomRefTable of={rest.of} isSubheading={!isHeading} />
33+
<DomRefTable of={rest.of} metaOf={metaOf} isSubheading={!isHeading} />
3034
</>
3135
);
3236
}
@@ -36,7 +40,7 @@ export function ArgTypesWithNote(props: ComponentProps<typeof ArgTypes> & ArgTyp
3640
{noteText ?? 'This component supports all HTML attributes.'}
3741
</MessageStrip>
3842
<ArgTypes {...rest} />
39-
<DomRefTable of={rest.of} isSubheading={!isHeading} />
43+
<DomRefTable of={rest.of} metaOf={metaOf} isSubheading={!isHeading} />
4044
</div>
4145
);
4246
}

.storybook/components/DomRefTable.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,22 @@ function Name(props: CEM.ClassMember) {
5151
export function DomRefTable({
5252
of,
5353
isSubheading,
54+
metaOf,
5455
}: {
5556
of: ComponentProps<typeof Controls>['of'];
5657
isSubheading?: boolean;
58+
metaOf?: ComponentProps<typeof Controls>['of'];
5759
}) {
58-
const { story: storyContext } = useOf<'story'>(of);
59-
const storyTags: string[] = storyContext.tags;
60+
const resolvedOf = useOf<'story' | 'component'>(of);
61+
const resolvedMetaOf = useOf<'meta'>(metaOf);
62+
63+
const { story: storyContext, component: componentContext } = resolvedOf;
64+
const storyTags: string[] = storyContext?.tags ?? resolvedMetaOf?.preparedMeta?.tags;
6065
const cemModuleName = storyTags?.find((tag) => tag.startsWith('cem-module:'));
6166
const componentName = of?.displayName ?? storyContext.component.displayName;
6267
const popoverRef = useRef(null);
6368

64-
const knownAttributes = new Set(Object.keys(of?.__docgenInfo?.props ?? storyContext.argTypes));
69+
const knownAttributes = new Set(Object.keys(componentContext?.__docgenInfo?.props ?? storyContext.argTypes));
6570
const cem = useGetCem(storyTags);
6671
const moduleName = cemModuleName ? cemModuleName.split(':')[1] : componentName;
6772

packages/ai/src/components/Button/Button.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ import { excludePropsForAbstract } from '@sb/utils';
123123
## ButtonState
124124

125125
<Description of={ButtonState} />
126-
<ArgTypesWithNote of={ButtonState} hideHTMLPropsNote exclude={excludePropsForAbstract} />
126+
<ArgTypesWithNote metaOf={ComponentStories} of={ButtonState} hideHTMLPropsNote exclude={excludePropsForAbstract} />
127127

128128
<Footer />
129129
```

packages/ai/src/components/PromptInput/PromptInput.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import { excludePropsForAbstract } from '@sb/utils';
2424
## SuggestionItem
2525

2626
<Description of={SuggestionItem} />
27-
<ArgTypesWithNote hideHTMLPropsNote exclude={excludePropsForAbstract} of={SuggestionItem} />
27+
<ArgTypesWithNote metaOf={ComponentStories} hideHTMLPropsNote exclude={excludePropsForAbstract} of={SuggestionItem} />
2828

2929
## SuggestionItemGroup
3030

3131
<Description of={SuggestionItemGroup} />
32-
<ArgTypesWithNote of={SuggestionItemGroup} hideHTMLPropsNote exclude={excludePropsForAbstract} />
32+
<ArgTypesWithNote metaOf={ComponentStories} of={SuggestionItemGroup} hideHTMLPropsNote exclude={excludePropsForAbstract} />
3333

3434
<Footer />

packages/compat/src/components/Toolbar/Toolbar.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,24 +238,24 @@ const ToolbarComponent = () => {
238238
239239
<Description of={OverflowToolbarButton} />
240240
241-
<ArgTypesWithNote of={OverflowToolbarButton} />
241+
<ArgTypesWithNote metaOf={ComponentStories} of={OverflowToolbarButton} />
242242
243243
## OverflowToolbarToggleButton
244244
245245
<Description of={OverflowToolbarToggleButton} />
246246
247-
<ArgTypesWithNote of={OverflowToolbarToggleButton} />
247+
<ArgTypesWithNote metaOf={ComponentStories} of={OverflowToolbarToggleButton} />
248248
249249
## ToolbarSpacer
250250
251251
<Description of={ToolbarSpacer} />
252252
253-
<ArgTypesWithNote of={ToolbarSpacer} />
253+
<ArgTypesWithNote metaOf={ComponentStories} of={ToolbarSpacer} />
254254
255255
## ToolbarSeparator
256256
257257
<Description of={ToolbarSeparator} />
258258
259-
<ArgTypesWithNote of={ToolbarSeparator} />
259+
<ArgTypesWithNote metaOf={ComponentStories} of={ToolbarSeparator} />
260260
261261
<Footer />

packages/main/src/components/AnalyticalCardHeader/AnalyticalCardHeader.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ import * as ComponentStories from './AnalyticalCardHeader.stories';
2727

2828
<Description of={NumericSideIndicator} />
2929

30-
<ArgTypesWithNote of={NumericSideIndicator} />
30+
<ArgTypesWithNote metaOf={ComponentStories} of={NumericSideIndicator} />
3131

3232
<Footer />

packages/main/src/components/FilterBar/FilterBar.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,6 @@ const handleInput = (event) => {
412412
## FilterGroupItem
413413

414414
<Description of={FilterGroupItem} />
415-
<ArgTypesWithNote of={FilterGroupItem} exclude={['data-index']} />
415+
<ArgTypesWithNote metaOf={ComponentStories} of={FilterGroupItem} exclude={['data-index']} />
416416

417417
<Footer />

packages/main/src/components/MessageView/MessageView.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ function MyComponent() {
104104

105105
<Description of={MessageItem} />
106106

107-
<ArgTypesWithNote of={MessageItem} />
107+
<ArgTypesWithNote metaOf={ComponentStories} of={MessageItem} />
108108

109109
## MessageViewButton
110110

111111
<Description of={MessageViewButton} />
112112

113-
<ArgTypesWithNote of={MessageViewButton} />
113+
<ArgTypesWithNote metaOf={ComponentStories} of={MessageViewButton} />
114114

115115
<Footer />

packages/main/src/components/ObjectPage/ObjectPage.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,24 +180,24 @@ function ObjectPageWithLegacyToolbar(props) {
180180

181181
<Description of={ObjectPageTitle} />
182182

183-
<ArgTypesWithNote of={ObjectPageTitle} />
183+
<ArgTypesWithNote metaOf={ComponentStories} of={ObjectPageTitle} />
184184

185185
## ObjectPageHeader
186186

187187
<Description of={ObjectPageHeader} />
188188

189-
<ArgTypesWithNote of={ObjectPageHeader} />
189+
<ArgTypesWithNote metaOf={ComponentStories} of={ObjectPageHeader} />
190190

191191
## ObjectPageSection
192192

193193
<Description of={ObjectPageSection} />
194194

195-
<ArgTypesWithNote of={ObjectPageSection} />
195+
<ArgTypesWithNote metaOf={ComponentStories} of={ObjectPageSection} />
196196

197197
## ObjectPageSubSection
198198

199199
<Description of={ObjectPageSubSection} />
200200

201-
<ArgTypesWithNote of={ObjectPageSubSection} />
201+
<ArgTypesWithNote metaOf={ComponentStories} of={ObjectPageSubSection} />
202202

203203
<Footer />

packages/main/src/components/SplitterLayout/SplitterLayout.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ function SplitterLayoutComponent(props) {
8585

8686
<Description of={SplitterElement} />
8787

88-
<ArgTypesWithNote of={SplitterElement} />
88+
<ArgTypesWithNote metaOf={ComponentStories} of={SplitterElement} />
8989

9090
<Footer />

0 commit comments

Comments
 (0)