Custom Elements Manifest
This article describes the prerequisites for Custom Elements Manifest generation and how the custom analyzer works for UI5 Web Components project and third-party projects.
To produce a custom-elements.json file for a specific package, all public and exported classes, enumerations, interfaces, etc. must have valid JSDoc based on the guidelines in this article. The analyzer doesn't fully rely on TypeScript, so some aspects need to be described explicitly with JSDoc.
Note: The generated custom-elements.json contains only public API - everything else is stripped out.
JSDoc Validation
UI5 Web Components packages that have JSDoc can be validated to ensure they follow the correct format and completeness. This validation can be enabled by setting dev to true inside the package-scripts.js file in the root folder.
const options = {
...
dev: true,
...
};
JSDoc Tags Reference
Table of Contents
- Class tags
- Property and getter (readonly property) tags
- Slot tags
- Event tags
- Method tags
- CSS Part
- Enum and enum member tags
- Interface tags
Class tags
/**
* @class
* Class description showcase
*
* @slot {ShowcaseType[]} default - Unnamed slot description showcase
*
* @csspart testPart - CSS Part description showcase
*
* @constructor
* @extends UI5Element
* @since 1.2.0
* @deprecated 1.4.0
* @public
* @abstract
* @implements {ShowcaseType}
* @implements {ShowcaseType2}
*/
@customElement("ui5-test-component")
class TestComponent extends UI5Element implements ShowcaseType, ShowcaseType2 {
Notes:
- If the component implements more than 1 interface, use
@implementstag for every interface instead of separating them with commas
Property and getter (readonly property) tags
/**
* Property description showcase
*
* @public
* @since 1.2.0
* @deprecated 1.4.0
* @default "myDefaultValue"
* @formProperty
* @formEvents change input
*/
@property()
property!: string;
Notes:
- Type is automatically calculated from the accessor name
- Default value is automatically calculated from the accessor name
Slot tags
Property slot
A property slot is a slot that has an accessor.
/**
* Property slot description showcase
*
* @public
* @since 1.2.0
* @deprecated 1.4.0
*/
@slot({ type: HTMLElement, "default": true })
propertySlot!: Array<IIcon>;
Notes:
- Type is automatically calculated from the accessor type
- If the default is set to true inside the decorator, the slot will appear as default
Unnamed slot
An unnamed slot is the default slot that doesn't have an accessor. This slot is declared inside the class comment using the @slot tag.
/**
* @class
* ...
*
* @slot {ShowcaseType[]} default - Unnamed slot description showcase
* ...
*/
@customElement("ui5-test-component")
class TestComponent extends UI5Element {
Event declaration tags
/**
* Event description showcase
* @public
* @since 1.2.0
* @deprecated 1.4.0
* @param {ShowcaseType} testParameter description
* @allowPreventDefault
* @native
*/
@event("eventWithDetails", {
detail: {
/**
* @public
* @since 1.2.0
* @deprecated 1.4.0
*/
testParameter: { type: HTMLElement }
},
})
class TestComponent extends UI5Element {
eventDetails!: {
"click": ClickEventDetail,
};
By default, all events are treated as custom events without specific type for the event deatils. If you need to provide custom event details types, they should be described in the eventDetails property of the class.
Event parameter tags
You can specify additional metadata for event parameters:
@event("eventWithDetails", {
detail: {
/**
* @public
* @since 1.2.0
* @deprecated 1.4.0
*/
testParameter: { type: HTMLElement }
},
})
class TestComponent extends UI5Element {
Notes:
- With these tags, only deprecated, since, and privacy status can be changed. If you want to change the description, use the
@paramtag in the event description - You must specify the privacy of the parameter with a privacy tag and also describe the parameter in the event comment
Method tags
/**
* Shows the popover.
* @param param1 parameter description showcase
* @param [param2] optional parameter description showcase
* @public
* @since 1.2.0
* @deprecated 1.4.0
* @returns description of return
*/
static methodName(param1: Array<ShowcaseType>, param2 = ShowcaseType.Type1): boolean {}
Notes:
- Parameter types and return types are generated automatically
CSS Part
You can define CSS parts inside the class comment using the @csspart tag.
/**
* @class
* ...
*
* @csspart testPart - CSS Part description showcase
* ...
*/
@customElement("ui5-test-component")
class TestComponent extends UI5Element {
Enum and enum member tags
/**
* Enum description showcase
*
* @public
* @since 1.2.0
* @deprecated 1.4.0
*/
enum ShowcaseType {
/**
* Enum member description showcase
*
* @public
* @since 1.2.0
* @deprecated 1.4.0
*/
Type1 = "Type1",
}
Interface tags
/**
* Interface description showcase
*
* @public
* @since 1.2.0
* @deprecated 1.4.0
*/
interface ShowcaseType {
property: string;
}