Skip to content

Pr help/burtonsmith/add cem to wc library #34198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 278 Changed
vr-tests-react-components/Positioning.Positioning end.chromium.png 880 Changed
vr-tests-web-components/Accordion 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Accordion. - Dark Mode.normal.chromium_1.png 3151 Changed
vr-tests-web-components/Badge 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Badge. - Dark Mode.normal.chromium.png 444 Changed
vr-tests-web-components/Checkbox 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Checkbox. - Dark Mode.normal.chromium_1.png 3 Changed
vr-tests-web-components/MenuList 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/MenuList. - RTL.2nd selected.chromium.png 17 Changed
vr-tests-web-components/MenuList. - RTL.normal.chromium_1.png 39082 Changed
vr-tests-web-components/Switch 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Switch. - Dark Mode.normal.chromium_1.png 92 Changed
vr-tests-web-components/TextInput 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/TextInput. - Dark Mode.normal.chromium_1.png 286 Changed
vr-tests/Callout 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests/Callout.No beak.default.chromium.png 2177 Changed
vr-tests/Callout.No callout width specified.default.chromium.png 2126 Changed
vr-tests/Keytip 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests/Keytip.Disabled.default.chromium.png 24 Changed
vr-tests/Keytip.Root.default.chromium.png 51 Changed
vr-tests/react-charting-AreaChart 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests/react-charting-AreaChart.Custom Accessibility.default.chromium.png 11 Changed
vr-tests/react-charting-LineChart 4 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests/react-charting-LineChart.Multiple - RTL.default.chromium.png 200 Changed
vr-tests/react-charting-LineChart.Multiple - Dark Mode.default.chromium.png 181 Changed
vr-tests/react-charting-LineChart.Multiple.default.chromium.png 192 Changed
vr-tests/react-charting-LineChart.Events.default.chromium.png 1 Changed

There were 1 duplicate changes discarded. Check the build logs for more information.

"type": "prerelease",
"comment": "Added custom elements manifest to project and included it in published package",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@babel/types": "7.24.6",
"@cactuslab/usepubsub": "^1.0.2",
"@ctrl/tinycolor": "3.3.4",
"@custom-elements-manifest/analyzer": "^0.10.4",
"@cypress/react": "8.0.0",
"@cypress/webpack-dev-server": "1.8.3",
"@dnd-kit/core": "^6.0.8",
Expand Down Expand Up @@ -177,6 +178,10 @@
"@types/yargs": "13.0.11",
"@types/yargs-unparser": "2.0.1",
"@typescript-eslint/rule-tester": "8.19.1",
"@wc-toolkit/cem-inheritance": "^1.0.4",
"@wc-toolkit/cem-validator": "^1.0.2",
"@wc-toolkit/module-path-resolver": "^1.0.0",
"@wc-toolkit/type-parser": "^1.0.3",
"@wojtekmaj/enzyme-adapter-react-17": "0.6.7",
"ajv": "8.4.0",
"autoprefixer": "10.2.1",
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test-results/
custom-elements.json
8 changes: 8 additions & 0 deletions packages/web-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ import { ButtonDefinition, FluentDesignSystem } from '@fluentui/web-components';
ButtonDefinition.define(FluentDesignSystem.registry);
```

## Developer Experience

For convenience we have included a [CEM (custom elements manifest)](https://github.com/webcomponents/custom-elements-manifest).

```js
import CEM from '@fluentui/custom-elements.json';
```

## Development

To start the component development environment, run `yarn start`.
Expand Down
56 changes: 56 additions & 0 deletions packages/web-components/custom-elements-manifest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { modulePathResolverPlugin } from '@wc-toolkit/module-path-resolver';
import { cemValidatorPlugin } from '@wc-toolkit/cem-validator';
import { getTsProgram, typeParserPlugin } from '@wc-toolkit/type-parser';
import { cemInheritancePlugin } from '@wc-toolkit/cem-inheritance';

export default {
/** Globs to analyze */
globs: ['src/**/*.ts'],
/** Globs to exclude */
exclude: [
'_docs/**/*',
'src/**/*.bench.ts',
'src/**/*.definition.ts',
'src/**/*.options.ts',
'src/**/*.spec.ts',
'src/**/*.stories.ts',
'src/**/*.styles.ts',
'src/**/*.template.ts',
'src/**/define.ts',
'src/**/index.ts',
],
/** Enable special handling for fast */
fast: true,
/** Provide custom plugins */
plugins: [
modulePathResolverPlugin({
modulePathTemplate: (modulePath, name, tagName) => `./dist/esm/${getBaseTag(tagName)}/${getBaseTag(tagName)}.js`,
definitionPathTemplate: (modulePath, name, tagName) => `./dist/esm/${getBaseTag(tagName)}/define.js`,
typeDefinitionPathTemplate: (modulePath, name, tagName) => `./dist/dts/${getBaseTag(tagName)}/index.d.ts`,
}),
typeParserPlugin(),
cemInheritancePlugin(),
cemValidatorPlugin({
rules: {
packageJson: {
main: 'off',
module: 'off',
types: 'off',
},
manifest: {
schemaVersion: 'off',
},
},
}),
],

/** Overrides default module creation: */
overrideModuleCreation({ ts, globs }) {
const program = getTsProgram(ts, globs, 'tsconfig.json');
return program.getSourceFiles().filter(sf => globs.find(glob => sf.fileName.includes(glob)));
},
};

function getBaseTag(tagName) {
return tagName?.replace('fluent-', '');
}
14 changes: 11 additions & 3 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"dist/dts/",
"dist/esm/",
"dist/*.js",
"dist/*.d.ts"
"dist/*.d.ts",
"custom-elements.json"
],
"exports": {
".": {
Expand Down Expand Up @@ -76,14 +77,15 @@
"./dist/web-components.min.js"
],
"scripts": {
"analyze": "cem analyze",
"verify-packaging": "node ./scripts/verify-packaging",
"type-check": "node ./scripts/type-check",
"benchmark": "yarn clean && yarn compile:benchmark && yarn compile && node ./scripts/run-benchmarks",
"compile": "node ./scripts/compile",
"compile:benchmark": "rollup -c rollup.bench.js",
"clean": "node ./scripts/clean dist",
"generate-api": "api-extractor run --local",
"build": "yarn compile && yarn rollup -c && yarn generate-api",
"build": "yarn compile && yarn rollup -c && yarn generate-api && yarn analyze",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"format": "prettier -w src/**/*.{ts,html} --ignore-path ../../.prettierignore",
Expand All @@ -96,11 +98,16 @@
"e2e:local": "node ./scripts/e2e.js --ui"
},
"devDependencies": {
"@custom-elements-manifest/analyzer": "^0.10.4",
"@fluentui/scripts-api-extractor": "*",
"@microsoft/fast-element": "2.0.0",
"@tensile-perf/web-components": "~0.2.0",
"@storybook/html": "7.6.20",
"@storybook/html-webpack5": "7.6.20",
"@wc-toolkit/cem-validator": "^1.0.2",
"@wc-toolkit/cem-inheritance": "^1.0.4",
"@wc-toolkit/module-path-resolver": "^1.0.0",
"@wc-toolkit/type-parser": "^1.0.3",
"chromedriver": "^125.0.0"
},
"dependencies": {
Expand All @@ -119,5 +126,6 @@
"patch"
],
"tag": "beta"
}
},
"customElements": "./custom-elements.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export type AccordionItemOptions = StartEndOptions<AccordionItem> & {
* An Accordion Item Custom HTML Element.
* Based on BaseAccordionItem and includes style and layout specific attributes
*
* @public
* @tag fluent-accordion-item
*
*/
export class AccordionItem extends BaseAccordionItem {
/**
Expand Down
2 changes: 2 additions & 0 deletions packages/web-components/src/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { AccordionExpandMode } from './accordion.options.js';
* An Accordion Custom HTML Element
* Implements {@link https://www.w3.org/TR/wai-aria-practices-1.1/#accordion | ARIA Accordion}.
*
* @tag fluent-accordion
*
* @slot - The default slot for the accordion items
* @fires change - Fires a custom 'change' event when the active item changes
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export type AnchorOptions = StartEndOptions<AnchorButton>;
* An Anchor Custom HTML Element.
* Based on BaseAnchor and includes style and layout specific attributes
*
* @public
* @tag fluent-anchor-button
*
*/
export class AnchorButton extends BaseAnchor {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/web-components/src/avatar/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
* An Avatar Custom HTML Element.
* Based on BaseAvatar and includes style and layout specific attributes
*
* @public
* @tag fluent-avatar
*
*/
export class Avatar extends BaseAvatar {
/**
Expand Down
4 changes: 3 additions & 1 deletion packages/web-components/src/badge/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { BadgeAppearance, BadgeColor, BadgeShape, BadgeSize } from './badge.opti

/**
* The base class used for constructing a fluent-badge custom element
* @public
*
* @tag fluent-badge
*
*/
export class Badge extends FASTElement {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/src/button/button.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { ButtonFormTarget, ButtonType } from './button.options.js';
* @slot start - Content which can be provided before the button content
* @slot end - Content which can be provided after the button content
* @slot - The default slot for button content
*
* @csspart content - The button content container
*
* @public
*/
export class BaseButton extends FASTElement {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/web-components/src/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { ButtonAppearance, ButtonShape, ButtonSize } from './button.options.js';
* A Button Custom HTML Element.
* Based on BaseButton and includes style and layout specific attributes
*
* @public
* @tag fluent-button
*
*/
export class Button extends BaseButton {
/**
Expand Down
4 changes: 3 additions & 1 deletion packages/web-components/src/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import { CheckboxShape, CheckboxSize } from './checkbox.options.js';
* A Checkbox Custom HTML Element.
* Implements the {@link https://w3c.github.io/aria/#checkbox | ARIA checkbox }.
*
* @tag fluent-checkbox
*
* @slot checked-indicator - The checked indicator
* @slot indeterminate-indicator - The indeterminate indicator
*
* @fires change - Emits a custom change event when the checked state changes
* @fires input - Emits a custom input event when the checked state changes
*
* @public
*/
export class Checkbox extends BaseCheckbox {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Button } from '../button/button.js';

/**
* The base class used for constructing a fluent-compound-button custom element
* @public
*
* @tag fluent-compound-button
*
*/
export class CompoundButton extends Button {}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {

/**
* The base class used for constructing a fluent-badge custom element
* @public
*
* @tag fluent-counter-badge
*
*/
export class CounterBadge extends FASTElement {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/dialog-body/dialog-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { attr, FASTElement } from '@microsoft/fast-element';
/**
* Dialog Body component that extends the FASTElement class.
*
* @public
* @extends FASTElement
* @tag fluent-dialog-body
*
*/
export class DialogBody extends FASTElement {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/web-components/src/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { DialogType } from './dialog.options.js';
/**
* A Dialog Custom HTML Element.
*
* @public
* @tag fluent-dialog
*
*/
export class Dialog extends FASTElement {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/web-components/src/divider/divider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { BaseDivider } from './divider.base.js';
* A Divider Custom HTML Element.
* Based on BaseDivider and includes style and layout specific attributes
*
* @public
* @tag fluent-divider
*
*/
export class Divider extends BaseDivider {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/drawer-body/drawer-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { FASTElement } from '@microsoft/fast-element';

/**
* A DrawerBody component to layout drawer content
* @extends FASTElement
*
* @tag fluent-drawer-body
*
* @slot title - The title slot
* @slot close - The close button slot
Expand All @@ -15,6 +16,5 @@ import { FASTElement } from '@microsoft/fast-element';
*
* @summary A component that provides a drawer body for displaying content in a side panel.
*
* @tag fluent-drawer-body
*/
export class DrawerBody extends FASTElement {}
14 changes: 1 addition & 13 deletions packages/web-components/src/drawer/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import { DrawerPosition, DrawerSize, DrawerType } from './drawer.options.js';
* A Drawer component that allows content to be displayed in a side panel. It can be rendered as modal or non-modal.
* @extends FASTElement
*
* @attr {DrawerType} type - Determines whether the drawer should be displayed as modal, non-modal, or alert.
* @attr {DrawerPosition} position - Sets the position of the drawer (start/end).
* @attr {DrawerSize} size - Sets the size of the drawer (small/medium/large).
* @attr {string} ariaDescribedby - The ID of the element that describes the drawer.
* @attr {string} ariaLabelledby - The ID of the element that labels the drawer.
* @tag fluent-drawer
*
* @csspart dialog - The dialog element of the drawer.
*
Expand All @@ -18,15 +14,7 @@ import { DrawerPosition, DrawerSize, DrawerType } from './drawer.options.js';
* @fires toggle - Event emitted after the dialog's open state changes.
* @fires beforetoggle - Event emitted before the dialog's open state changes.
*
* @method show - Method to show the drawer.
* @method hide - Method to hide the drawer.
* @method clickHandler - Handles click events on the drawer.
* @method emitToggle - Emits an event after the dialog's open state changes.
* @method emitBeforeToggle - Emits an event before the dialog's open state changes.
*
* @summary A component that provides a drawer for displaying content in a side panel.
*
* @tag fluent-drawer
*/
export class Drawer extends FASTElement {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/web-components/src/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { DropdownAppearance, DropdownSize } from './dropdown.options.js';
/**
* The Fluent Dropdown Element. Implements {@link @microsoft/fast-foundation#BaseDropdown}.
*
* @tag fluent-dropdown
*
* @slot - The default slot. Accepts a {@link (Listbox:class)} element.
* @slot indicator - The indicator slot.
* @slot control - The control slot. This slot is automatically populated and should not be manually manipulated.
*
* @public
*/
export class Dropdown extends BaseDropdown {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/web-components/src/field/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { LabelPosition } from './field.options.js';
* A Field Custom HTML Element.
* Based on BaseField and includes style and layout specific attributes
*
* @public
* @tag fluent-field
*
*/
export class Field extends BaseField {
/**
Expand Down
4 changes: 3 additions & 1 deletion packages/web-components/src/image/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { ImageFit, ImageShape } from './image.options.js';

/**
* The base class used for constucting a fluent image custom element
* @public
*
* @tag fluent-image
*
*/
export class Image extends FASTElement {
/**
Expand Down
4 changes: 3 additions & 1 deletion packages/web-components/src/label/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { LabelSize, LabelWeight } from './label.options.js';

/**
* The base class used for constructing a fluent-label custom element
* @public
*
* @tag fluent-label
*
*/
export class Label extends FASTElement {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/web-components/src/link/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { LinkAppearance } from './link.options.js';
* An Anchor Custom HTML Element.
* Based largely on the {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element }.
*
* @tag fluent-link
*
* @slot start - Content which can be provided before the link content
* @slot end - Content which can be provided after the link content
* @slot - The default slot for link content
*
* @public
*/
export class Link extends BaseAnchor {
/**
Expand Down
Loading
Loading