Skip to content

Commit b5e5cee

Browse files
authored
feat(create-wrappers): document supported slot types & deep-link to UI5WC component docs (#7791)
1 parent 5c0f409 commit b5e5cee

File tree

166 files changed

+656
-202
lines changed

Some content is hidden

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

166 files changed

+656
-202
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ cypress/downloads
3131
.nx
3232

3333
debug-storybook.log
34+
35+
.vscode

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
"prettier:all": "prettier --write --config ./prettier.config.js \"**/*\"",
2222
"lint": "eslint .",
2323
"lerna:version-dryrun": "lerna version --conventional-graduate --no-git-tag-version --no-push",
24-
"wrappers:main": "node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents --out ./packages/main/src/webComponents --additionalComponentNote 'This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)'",
25-
"wrappers:fiori": "node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents-fiori --out ./packages/main/src/webComponents --additionalComponentNote 'This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)'",
26-
"wrappers:compat": "WITH_WEB_COMPONENT_IMPORT_PATH='@ui5/webcomponents-react-base/withWebComponent' node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents-compat --out ./packages/compat/src/components --additionalComponentNote 'This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)' && prettier --log-level silent --write ./packages/compat/src/components",
27-
"wrappers:ai": "node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents-ai --out ./packages/ai/src/components --additionalComponentNote 'This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)' && prettier --log-level silent --write ./packages/ai/src/components",
24+
"wrappers:main": "WITH_WEB_COMPONENT_DOCS_LINK='true' node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents --out ./packages/main/src/webComponents",
25+
"wrappers:fiori": "WITH_WEB_COMPONENT_DOCS_LINK='true' node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents-fiori --out ./packages/main/src/webComponents",
26+
"wrappers:compat": "WITH_WEB_COMPONENT_DOCS_LINK='true' WITH_WEB_COMPONENT_IMPORT_PATH='@ui5/webcomponents-react-base/withWebComponent' node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents-compat --out ./packages/compat/src/components && prettier --log-level silent --write ./packages/compat/src/components",
27+
"wrappers:ai": "WITH_WEB_COMPONENT_DOCS_LINK='true' node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents-ai --out ./packages/ai/src/components && prettier --log-level silent --write ./packages/ai/src/components",
2828
"create-webcomponents-wrapper": "(cd packages/cli && tsc) && yarn run wrappers:main && yarn run wrappers:fiori && prettier --log-level silent --write ./packages/main/src/webComponents && eslint --fix ./packages/main/src/webComponents/*/index.tsx && yarn run sb:prepare-cem",
2929
"create-webcomponents-wrapper-compat": "(cd packages/cli && tsc) && yarn run wrappers:compat && yarn run sb:prepare-cem && eslint --fix ./packages/compat/src/components/*/index.tsx",
3030
"create-webcomponents-wrapper-ai": "(cd packages/cli && tsc) && yarn run wrappers:ai && yarn run sb:prepare-cem && eslint --fix ./packages/ai/src/components/*/index.tsx",

packages/ai/src/components/Button/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ interface ButtonPropTypes
7171
* Defines the available states of the component.
7272
* **Note:** Although this slot accepts HTML Elements, it is strongly recommended that
7373
* you only use `ButtonState` components in order to preserve the intended design.
74+
*
75+
* __Supported Node Type/s:__ `Array<ButtonState>`
7476
*/
7577
children?: ReactNode | ReactNode[];
7678
/**
@@ -114,7 +116,7 @@ interface ButtonPropTypes
114116
*
115117
*
116118
*
117-
* __Note__: This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)
119+
* __Note:__ This is a UI5 Web Component! [Button UI5 Web Component Documentation](https://ui5.github.io/webcomponents/components/ai/Button) | [Repository](https://github.com/UI5/webcomponents)
118120
*
119121
* @since [2.0.0](https://github.com/UI5/webcomponents/releases/tag/v2.0.0) of __@ui5/webcomponents-ai__.
120122
* @experimental The Button and ButtonState web components are availabe since 2.0 under an experimental flag and their API and behaviour are subject to change.

packages/ai/src/components/ButtonState/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ interface ButtonStatePropTypes extends ButtonStateAttributes, Omit<CommonProps,
6262
*
6363
*
6464
*
65-
* __Note__: This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)
65+
* __Note:__ This is a UI5 Web Component! [ButtonState UI5 Web Component Documentation](https://ui5.github.io/webcomponents/components/ai/ButtonState) | [Repository](https://github.com/UI5/webcomponents)
6666
*
6767
* @since [2.0.0](https://github.com/UI5/webcomponents/releases/tag/v2.0.0) of __@ui5/webcomponents-ai__.
6868
* @abstract

packages/ai/src/components/PromptInput/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ interface PromptInputPropTypes
112112
* property is set to `true`.
113113
*
114114
* **Note:** The `<ui5-suggestion-item>`, `<ui5-suggestion-item-group>` and `ui5-suggestion-item-custom` are recommended to be used as suggestion items.
115+
*
116+
* __Supported Node Type/s:__ `Array<IInputSuggestionItem>`
115117
*/
116118
children?: ReactNode | ReactNode[];
117119

@@ -131,6 +133,8 @@ interface PromptInputPropTypes
131133
* Learn more about it [here](https://ui5.github.io/webcomponents-react/v2/?path=/docs/knowledge-base-handling-slots--docs).
132134
*
133135
* **Note:** Available since [v2.0.0](https://github.com/UI5/webcomponents/releases/tag/v2.0.0) of **@ui5/webcomponents-ai**.
136+
*
137+
* __Supported Node Type/s:__ `Array<HTMLElement>`
134138
*/
135139
valueStateMessage?: UI5WCSlotsNode;
136140
/**
@@ -177,7 +181,7 @@ interface PromptInputPropTypes
177181
*
178182
*
179183
*
180-
* __Note__: This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)
184+
* __Note:__ This is a UI5 Web Component! [PromptInput UI5 Web Component Documentation](https://ui5.github.io/webcomponents/components/ai/PromptInput) | [Repository](https://github.com/UI5/webcomponents)
181185
* @experimental The **@ui5/webcomponents-ai** package is under development and considered experimental - components' APIs are subject to change.
182186
*/
183187
const PromptInput = withWebComponent<PromptInputPropTypes, PromptInputDomRef>(

packages/cli/src/scripts/create-wrappers/ComponentRenderer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { sinceFilter, snakeCaseToCamelCase, summaryFormatter } from '../../util/
44
import { AbstractRenderer, RenderingPhase } from './AbstractRenderer.js';
55
import type { WebComponentWrapper } from './WebComponentWrapper.js';
66

7+
const WITH_WEB_COMPONENT_DOCS_LINK = process.env.WITH_WEB_COMPONENT_DOCS_LINK ?? 'false';
78
export class ComponentRenderer extends AbstractRenderer {
89
public phase = RenderingPhase.component;
910

@@ -72,6 +73,18 @@ export class ComponentRenderer extends AbstractRenderer {
7273
if (this.note) {
7374
comment += ` * __Note__: ${this.note}\n`;
7475
}
76+
if (WITH_WEB_COMPONENT_DOCS_LINK === 'true') {
77+
let ui5wcUrl = 'https://ui5.github.io/webcomponents/components/';
78+
if (context.packageName === '@ui5/webcomponents-fiori') {
79+
ui5wcUrl += 'fiori/';
80+
} else if (context.packageName === '@ui5/webcomponents-ai') {
81+
ui5wcUrl += 'ai/';
82+
} else if (context.packageName === '@ui5/webcomponents-compat') {
83+
ui5wcUrl += 'compat/';
84+
}
85+
ui5wcUrl += context.componentName;
86+
comment += ` * __Note:__ This is a UI5 Web Component! [${context.componentName} UI5 Web Component Documentation](${ui5wcUrl}) | [Repository](https://github.com/UI5/webcomponents)\n`;
87+
}
7588
if (sinceFilter(this.since)) {
7689
comment += ` *\n`;
7790
comment += ` * @since [${this.since}](https://github.com/UI5/webcomponents/releases/tag/v${this.since}) of __${context.packageName}__.\n`;

packages/cli/src/scripts/create-wrappers/PropTypesRenderer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ export class PropTypesRenderer extends AbstractRenderer {
8181
}
8282
}
8383

84+
const slotType = slot._ui5type;
85+
if (slotType) {
86+
descriptionParts.push(` *`);
87+
descriptionParts.push(` * __Supported Node Type/s:__ \`${slotType.text ?? 'unknown'}\``);
88+
}
89+
8490
return `/**\n${descriptionParts.join('\n')}\n */\n${snakeCaseToCamelCase(slot.name)}?: ${
8591
isDefaultSlot ? 'ReactNode | ReactNode[]' : 'UI5WCSlotsNode'
8692
}`;

packages/compat/src/components/Table/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ interface TablePropTypes
155155
* Defines the component rows.
156156
*
157157
* **Note:** Use `TableRow` for the intended design.
158+
*
159+
* __Supported Node Type/s:__ `Array<ITableRow>`
158160
*/
159161
children?: ReactNode | ReactNode[];
160162

@@ -168,6 +170,8 @@ interface TablePropTypes
168170
*
169171
* __Note:__ When passing a custom React component to this prop, you have to make sure your component reads the `slot` prop and appends it to the most outer element of your component.
170172
* Learn more about it [here](https://ui5.github.io/webcomponents-react/v2/?path=/docs/knowledge-base-handling-slots--docs).
173+
*
174+
* __Supported Node Type/s:__ `Array<TableColumn>`
171175
*/
172176
columns?: UI5WCSlotsNode;
173177
/**
@@ -269,7 +273,7 @@ interface TablePropTypes
269273
* - `import "@ui5/webcomponents-compat/dist/TableGroupRow.js";` (`TableGroupRow`)
270274
* - `import "@ui5/webcomponents-compat/dist/TableCell.js";` (`TableCell`)
271275
*
272-
* __Note__: This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)
276+
* __Note:__ This is a UI5 Web Component! [Table UI5 Web Component Documentation](https://ui5.github.io/webcomponents/components/compat/Table) | [Repository](https://github.com/UI5/webcomponents)
273277
* @deprecated Deprecated as of version 2.12.0, use `@ui5/webcomponents/dist/Table.js` instead.
274278
*/
275279
const Table = withWebComponent<TablePropTypes, TableDomRef>(

packages/compat/src/components/TableCell/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ interface TableCellDomRef extends Required<TableCellAttributes>, Ui5DomRef {}
1616
interface TableCellPropTypes extends TableCellAttributes, Omit<CommonProps, 'children'> {
1717
/**
1818
* Specifies the content of the component.
19+
*
20+
* __Supported Node Type/s:__ `Array<HTMLElement> | undefined`
1921
*/
2022
children?: ReactNode | ReactNode[];
2123
}
2224

2325
/**
2426
* The `TableCell` component defines the structure of the data in a single `Table` cell.
2527
*
26-
* __Note__: This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)
28+
* __Note:__ This is a UI5 Web Component! [TableCell UI5 Web Component Documentation](https://ui5.github.io/webcomponents/components/compat/TableCell) | [Repository](https://github.com/UI5/webcomponents)
2729
* @deprecated Deprecated as of version 2.12.0, use `@ui5/webcomponents/dist/TableCell.js` instead.
2830
*/
2931
const TableCell = withWebComponent<TableCellPropTypes, TableCellDomRef>(`ui5-table-cell${tagSuffix}`, [], [], [], []);

packages/compat/src/components/TableColumn/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ interface TableColumnPropTypes
5656
Omit<CommonProps, keyof TableColumnAttributes | 'children'> {
5757
/**
5858
* Defines the content of the column header
59+
*
60+
* __Supported Node Type/s:__ `Array<Node>`
5961
*/
6062
children?: ReactNode | ReactNode[];
6163
}
@@ -64,7 +66,7 @@ interface TableColumnPropTypes
6466
* The `TableColumn` component allows to define column specific properties that are applied
6567
* when rendering the `Table` component.
6668
*
67-
* __Note__: This is a UI5 Web Component! [Repository](https://github.com/UI5/webcomponents) | [Documentation](https://ui5.github.io/webcomponents/)
69+
* __Note:__ This is a UI5 Web Component! [TableColumn UI5 Web Component Documentation](https://ui5.github.io/webcomponents/components/compat/TableColumn) | [Repository](https://github.com/UI5/webcomponents)
6870
* @deprecated Deprecated as of version 2.12.0, use `@ui5/webcomponents/dist/Table.js` instead.
6971
*/
7072
const TableColumn = withWebComponent<TableColumnPropTypes, TableColumnDomRef>(

0 commit comments

Comments
 (0)