Skip to content

Commit 19d82d8

Browse files
authored
refactor(web-components): replace compose() with plain definition objects (#36337)
## Previous Behavior Component definitions across `@fluentui/web-components` and `@fluentui/chart-web-components` were created with the `Element.compose()` API. Each `define.ts` then registered the element by calling `definition.define(FluentDesignSystem.registry)`, and benchmarks imported the composed `definition` directly to register elements. ## New Behavior Each component definition is now a plain `PartialFASTElementDefinition` object that includes `name`, `registry`, `styles`, and `template`. Registration happens by calling `Element.define(definition)` in each `define.ts`, and benchmarks import the component's `define.js` side-effect module instead of composing the definition themselves. The generated API report and `tensile.config.js` are updated to match. Behavior is functionally equivalent; this is an internal refactor that removes the `compose()` pattern.
1 parent 04cc9d4 commit 19d82d8

148 files changed

Lines changed: 582 additions & 678 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/vr-tests-web-components/project.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"projectType": "application",
55
"implicitDependencies": [],
6+
"targets": {
7+
"build-storybook": {
8+
"dependsOn": ["^build"]
9+
}
10+
},
611
"tags": ["web-components"]
712
}

apps/vr-tests-web-components/src/stories/accordion/accordion.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import * as React from 'react';
22
import { default as parse } from 'html-react-parser';
33
import { Steps } from 'storywright';
4-
import { accordionDefinition, accordionItemDefinition, FluentDesignSystem } from '@fluentui/web-components';
54
import { DARK_MODE, getStoryVariant, RTL } from '../../utilities/WCThemeDecorator.js';
65

7-
accordionDefinition.define(FluentDesignSystem.registry);
8-
accordionItemDefinition.define(FluentDesignSystem.registry);
6+
import '@fluentui/web-components/accordion/define.js';
7+
import '@fluentui/web-components/accordion-item/define.js';
98

109
export default {
1110
title: 'Accordion',

apps/vr-tests-web-components/src/stories/avatar/avatar.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react';
22
import { default as parse } from 'html-react-parser';
33
import { Steps } from 'storywright';
4-
import { AvatarDefinition, FluentDesignSystem } from '@fluentui/web-components';
54
import { DARK_MODE, getStoryVariant, RTL } from '../../utilities/WCThemeDecorator.js';
65

7-
AvatarDefinition.define(FluentDesignSystem.registry);
6+
import '@fluentui/web-components/avatar/define.js';
87

98
export default {
109
title: 'Avatar',

apps/vr-tests-web-components/src/stories/badge/badge.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react';
22
import { default as parse } from 'html-react-parser';
33
import { Steps } from 'storywright';
4-
import { BadgeDefinition, FluentDesignSystem } from '@fluentui/web-components';
54
import { DARK_MODE, getStoryVariant } from '../../utilities/WCThemeDecorator.js';
65

7-
BadgeDefinition.define(FluentDesignSystem.registry);
6+
import '@fluentui/web-components/badge/define.js';
87

98
export default {
109
title: 'Badge',

apps/vr-tests-web-components/src/stories/button/button.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react';
22
import { default as parse } from 'html-react-parser';
33
import { Steps } from 'storywright';
4-
import { ButtonDefinition, FluentDesignSystem } from '@fluentui/web-components';
54
import { DARK_MODE, getStoryVariant, RTL } from '../../utilities/WCThemeDecorator.js';
65

7-
ButtonDefinition.define(FluentDesignSystem.registry);
6+
import '@fluentui/web-components/button/define.js';
87

98
const buttonId = 'button-id';
109

apps/vr-tests-web-components/src/stories/checkbox/checkbox-indeterminate.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react';
22
import { default as parse } from 'html-react-parser';
33
import { Steps, type StoryParameters } from 'storywright';
4-
import { CheckboxDefinition, FluentDesignSystem } from '@fluentui/web-components';
54
import { DARK_MODE, getStoryVariant } from '../../utilities/WCThemeDecorator.js';
65

7-
CheckboxDefinition.define(FluentDesignSystem.registry);
6+
import '@fluentui/web-components/checkbox/define.js';
87

98
export default {
109
title: 'Checkbox',

apps/vr-tests-web-components/src/stories/checkbox/checkbox.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react';
22
import { default as parse } from 'html-react-parser';
33
import { Steps } from 'storywright';
4-
import { CheckboxDefinition, FluentDesignSystem } from '@fluentui/web-components';
54
import { DARK_MODE, getStoryVariant, RTL } from '../../utilities/WCThemeDecorator.js';
65

7-
CheckboxDefinition.define(FluentDesignSystem.registry);
6+
import '@fluentui/web-components/checkbox/define.js';
87

98
export default {
109
title: 'Checkbox',

apps/vr-tests-web-components/src/stories/divider/divider.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react';
22
import { default as parse } from 'html-react-parser';
33
import { Steps } from 'storywright';
4-
import { DividerDefinition, FluentDesignSystem } from '@fluentui/web-components';
54
import { DARK_MODE, getStoryVariant, RTL } from '../../utilities/WCThemeDecorator.js';
65

7-
DividerDefinition.define(FluentDesignSystem.registry);
6+
import '@fluentui/web-components/divider/define.js';
87

98
export default {
109
title: 'Divider',

apps/vr-tests-web-components/src/stories/label/label.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react';
22
import { default as parse } from 'html-react-parser';
33
import { Steps } from 'storywright';
4-
import { LabelDefinition, FluentDesignSystem } from '@fluentui/web-components';
54
import { DARK_MODE, getStoryVariant, RTL } from '../../utilities/WCThemeDecorator.js';
65

7-
LabelDefinition.define(FluentDesignSystem.registry);
6+
import '@fluentui/web-components/label/define.js';
87

98
export default {
109
title: 'Label',

apps/vr-tests-web-components/src/stories/link/link.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import * as React from 'react';
22
import { default as parse } from 'html-react-parser';
33
import { Steps } from 'storywright';
4-
import { LinkDefinition, FluentDesignSystem } from '@fluentui/web-components';
54

6-
LinkDefinition.define(FluentDesignSystem.registry);
5+
import '@fluentui/web-components/link/define.js';
76

87
const linkId = 'link-id';
98

0 commit comments

Comments
 (0)