Skip to content

Commit 5b506e0

Browse files
authored
chore: add deprecation message in component pages (#10902)
1 parent f7611dd commit 5b506e0

30 files changed

+98
-38
lines changed

packages/main/src/TableHeaderCellActionAI.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import "@ui5/webcomponents-icons/dist/ai.js";
1919
* @extends TableHeaderCellActionBase
2020
* @since 2.8.0
2121
* @public
22+
* @experimental
2223
*/
2324
@customElement({ tag: "ui5-table-header-cell-action-ai" })
2425

packages/main/src/TableRowAction.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import TableRowActionBase from "./TableRowActionBase.js";
99
* @extends TableRowActionBase
1010
* @since 2.7.0
1111
* @public
12+
* @experimental
1213
*/
1314
@customElement({ tag: "ui5-table-row-action" })
1415

packages/main/src/TableRowActionNavigation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
1919
* @extends TableRowActionBase
2020
* @since 2.7.0
2121
* @public
22+
* @experimental
2223
*/
2324
@customElement({ tag: "ui5-table-row-action-navigation" })
2425

packages/main/src/types/TableCellHorizontalAlign.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Alignment of the <ui5-table-cell> component.
33
*
44
* @public
5+
* @experimental
56
*/
67
enum TableCellHorizontalAlign {
78
/**

packages/main/src/types/TableGrowingMode.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Growing mode of the <ui5-table> component.
33
*
44
* @public
5+
* @experimental
56
*/
67
enum TableGrowingMode {
78
/**

packages/main/src/types/TableOverflowMode.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Column mode of the <ui5-table> component.
33
*
44
* @public
5+
* @experimental
56
*/
67
enum TableOverflowMode {
78
/**

packages/main/src/types/TableSelectionMode.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Selection modes of the <ui5-table> component.
33
*
44
* @public
5+
* @experimental
56
*/
67
enum TableSelectionMode {
78
/**

packages/tools/lib/cem/utils.mjs

+7-7
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ const allowedTags = {
241241
eventParam: [...commonTags],
242242
method: [...commonTags, "param", "returns", "override"],
243243
class: [...commonTags, "constructor", "class", "abstract", "experimental", "implements", "extends", "slot", "csspart"],
244-
enum: [...commonTags],
244+
enum: [...commonTags, "experimental",],
245245
enumMember: [...commonTags, "experimental",],
246246
interface: [...commonTags, "experimental",],
247247
};
@@ -264,17 +264,17 @@ const findDecorator = (node, decoratorName) => {
264264

265265
const findAllDecorators = (node, decoratorName) => {
266266
if (typeof decoratorName === "string") {
267-
return node?.decorators?.filter(decorator => decorator?.expression?.expression?.text === decoratorName ) || [];
267+
return node?.decorators?.filter(decorator => decorator?.expression?.expression?.text === decoratorName) || [];
268268
}
269269

270270
if (Array.isArray(decoratorName)) {
271271
return node?.decorators?.filter(decorator => {
272-
if (decorator?.expression?.expression?.text) {
273-
return decoratorName.includes(decorator.expression.expression.text);
274-
}
275-
276-
return false;
272+
if (decorator?.expression?.expression?.text) {
273+
return decoratorName.includes(decorator.expression.expression.text);
277274
}
275+
276+
return false;
277+
}
278278
) || [];
279279
}
280280

packages/website/build-scripts/api-reference-generation/component-file.mjs

+45-7
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ const parseDeclaration = (declaration, packageName) => {
263263

264264
let sections = [];
265265

266-
if (declaration._ui5experimental) {
266+
if (declaration.deprecated) {
267+
sections.push(`:::warning
268+
${deprecatedText(declaration)}
269+
:::`)
270+
} else if (declaration._ui5experimental) {
267271
sections.push(`:::info
268272
${experimentalText(declaration)}
269273
:::`)
@@ -296,22 +300,29 @@ ${declaration._implementations.map(_implementation => `| ${_implementation.split
296300

297301
let fileContent = sections.join("\n\n");
298302

299-
if (declaration._ui5experimental) {
303+
304+
if (declaration.deprecated) {
305+
fileContent = addDeprecatedClassName(fileContent, declaration);
306+
} else if (declaration._ui5experimental) {
300307
fileContent = addExperimentalClassName(fileContent, declaration);
301308
}
302309

303310

304311
return fileContent;
305312
}
306313

307-
308-
309314
const experimentalText = declaration => {
310-
return typeof declaration._ui5experimental === "boolean" ?
315+
return typeof declaration._ui5experimental === "boolean" ?
311316
"The following entity is available under an experimental flag and its API and behavior are subject to change."
312317
: declaration._ui5experimental;
313318
}
314319

320+
const deprecatedText = declaration => {
321+
return typeof declaration.deprecated === "boolean" ?
322+
"The following entity is deprecated and will be removed in the next major version."
323+
: declaration.deprecated;
324+
}
325+
315326

316327
const parseComponentDeclaration = (declaration, fileContent) => {
317328
if (!declaration || !fileContent) {
@@ -326,7 +337,15 @@ const parseComponentDeclaration = (declaration, fileContent) => {
326337
fileContent = enhanceFrontMatter(fileContent, "ui5_since", `${declaration._ui5since}`)
327338
}
328339

329-
if (declaration._ui5experimental) {
340+
if (declaration.deprecated) {
341+
fileContent = addDeprecatedClassName(fileContent, declaration);
342+
343+
fileContent = fileContent.replace("<%COMPONENT_OVERVIEW%>", `:::warning
344+
${deprecatedText(declaration)}
345+
:::
346+
347+
${parseDeclarationDescription(declaration.description)}`)
348+
} else if (declaration._ui5experimental) {
330349
fileContent = addExperimentalClassName(fileContent, declaration);
331350

332351
fileContent = fileContent.replace("<%COMPONENT_OVERVIEW%>", `:::info
@@ -352,6 +371,25 @@ ${parseDeclarationDescription(declaration.description)}`)
352371
}
353372

354373
const experimentalCssClass = "expComponentBadge";
374+
const deprecatedCssClass = "deprComponentBadge";
375+
376+
const addDeprecatedClassName = (fileContent, declaration) => {
377+
if (!declaration.deprecated) {
378+
return fileContent;
379+
}
380+
381+
const frontMatter = fileContent.match(/^---\n(?:.+\n)*---/);
382+
383+
if (!frontMatter) {
384+
return `---
385+
sidebar_class_name: ${deprecatedCssClass}
386+
---
387+
388+
${fileContent}`
389+
}
390+
391+
return enhanceFrontMatter(fileContent, "sidebar_class_name", deprecatedCssClass)
392+
}
355393

356394
const addExperimentalClassName = (fileContent, declaration) => {
357395
if (!declaration._ui5experimental) {
@@ -390,7 +428,7 @@ ${fileContent}`
390428
if (classLine && !hasExperimentalClass) {
391429
frontMatterLines[classLineIndex] = `${classLine} ${value}`;
392430
} else if (!classLine) {
393-
frontMatterLines.splice(frontMatterLines.length - 1, 0, `${front_matter_name}: ${value}`);
431+
frontMatterLines.splice(frontMatterLines.length - 1, 0, `${front_matter_name}: ${value}`);
394432
}
395433

396434
return fileContent.replace(frontMatter[0], frontMatterLines.join("\n"));

packages/website/docs/_components_pages/ai/Button/Button.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
slug: ../Button
3-
sidebar_class_name: newComponentBadge expComponentBadge
3+
sidebar_class_name: newComponentBadge
44
---
55

66
import ButtonMenu from "../../../_samples/ai/Button/ButtonMenu/ButtonMenu.md";

packages/website/docs/_components_pages/ai/Button/ButtonState.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
slug: ../ButtonState
3-
sidebar_class_name: newComponentBadge expComponentBadge
3+
sidebar_class_name: newComponentBadge
44
---
55

66
<%COMPONENT_OVERVIEW%>

packages/website/docs/_components_pages/ai/PromptInput.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_class_name: newComponentBadge expComponentBadge
2+
sidebar_class_name: newComponentBadge
33
---
44

55
import Basic from "../../_samples/ai/PromptInput/Basic/Basic.md";

packages/website/docs/_components_pages/main/Table/Table.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
slug: ../../Table
3-
sidebar_class_name: expComponentBadge
43
---
54

65
import Basic from "../../../_samples/main/Table/Basic/Basic.md";

packages/website/docs/_components_pages/main/Table/TableCell.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
slug: ../../TableCell
3-
sidebar_class_name: expComponentBadge
43
---
54

65
import HAlign from "../../../_samples/main/Table/HAlign/HAlign.md";

packages/website/docs/_components_pages/main/Table/TableGrowing.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
slug: ../../TableGrowing
3-
sidebar_class_name: expComponentBadge
43
---
54

65
import Growing from "../../../_samples/main/Table/Growing/Growing.md";

packages/website/docs/_components_pages/main/Table/TableHeaderCell.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
slug: ../../TableHeaderCell
3-
sidebar_class_name: expComponentBadge
43
---
54

65
import Popin from "../../../_samples/main/Table/Popin/Popin.md";

packages/website/docs/_components_pages/main/Table/TableHeaderCellActionAI.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
slug: ../../TableHeaderCellActionAI
3-
sidebar_class_name: expComponentBadge
43
---
54

65
import HeaderCellActionAI from "../../../_samples/main/Table/HeaderCellActionAI/HeaderCellActionAI.md";

packages/website/docs/_components_pages/main/Table/TableHeaderRow.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
slug: ../../TableHeaderRow
3-
sidebar_class_name: expComponentBadge
43
---
54

65
import StickyHeader from "../../../_samples/main/Table/StickyHeader/StickyHeader.md";

packages/website/docs/_components_pages/main/Table/TableRow.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
slug: ../../TableRow
3-
sidebar_class_name: expComponentBadge
43
---
54

65
import Interactive from "../../../_samples/main/Table/Interactive/Interactive.md";

packages/website/docs/_components_pages/main/Table/TableRowAction.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
slug: ../../TableRowAction
3-
sidebar_class_name: newComponentBadge expComponentBadge
3+
sidebar_class_name: newComponentBadge
44
---
55

66
import RowAction from "../../../_samples/main/Table/RowAction/RowAction.md";

packages/website/docs/_components_pages/main/Table/TableRowActionNavigation.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
slug: ../../TableRowActionNavigation
3-
sidebar_class_name: newComponentBadge expComponentBadge
3+
sidebar_class_name: newComponentBadge
44
---
55

66
import RowActionNavigation from "../../../_samples/main/Table/RowActionNavigation/RowActionNavigation.md";

packages/website/docs/_components_pages/main/Table/TableSelection.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
slug: ../../TableSelection
3-
sidebar_class_name: expComponentBadge
43
---
54

65
import Selection from "../../../_samples/main/Table/Selection/Selection.md";

packages/website/docs/_components_pages/main/Table/TableVirtualizer.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
slug: ../../TableVirtualizer
3-
sidebar_class_name: newComponentBadge expComponentBadge
3+
sidebar_class_name: newComponentBadge
44
---
55

66
import Virtualizer from "../../../_samples/main/Table/Virtualizer/Virtualizer.md";

packages/website/docs/components/patterns/AI Acknowledgement.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_class_name: newComponentBadge expComponentBadge
2+
sidebar_class_name: newComponentBadge
33
---
44

55
import Basic from "../../_samples/patterns/AIAcknowledgement/Basic/Basic.md";

packages/website/docs/components/patterns/AI CustomPrompt/AI CustomPrompt.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_class_name: newComponentBadge expComponentBadge
2+
sidebar_class_name: newComponentBadge
33
---
44

55
:::info

packages/website/docs/components/patterns/AI GuidedPrompt.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_class_name: newComponentBadge expComponentBadge
2+
sidebar_class_name: newComponentBadge
33
---
44

55
import Popover from "../../_samples/patterns/AIGuidedPrompt/Popover/Popover.md";

packages/website/docs/components/patterns/AI QuickPrompt.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_class_name: newComponentBadge expComponentBadge
2+
sidebar_class_name: newComponentBadge
33
---
44

55
import Basic from "../../_samples/patterns/AIQuickPrompt/Basic.md";

packages/website/docs/components/patterns/AI Regenerate.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_class_name: newComponentBadge expComponentBadge
2+
sidebar_class_name: newComponentBadge
33
---
44

55
import Basic from "../../_samples/patterns/AIRegenerate/Basic/Basic.md";

packages/website/docs/components/patterns/SelectionAssistant/Selection Assistant.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_class_name: newComponentBadge expComponentBadge
2+
sidebar_class_name: newComponentBadge
33
---
44

55
import Input from "../../../components/patterns/SelectionAssistant/InputSelectionAssistant/Basic/Basic.md";

packages/website/src/css/custom.css

+27-4
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ code {
209209
}
210210

211211
.newComponentBadge,
212-
.expComponentBadge {
212+
.expComponentBadge,
213+
.deprComponentBadge {
213214
position: relative;
214215
}
215216

@@ -227,7 +228,27 @@ code {
227228
pointer-events: none;
228229
}
229230

230-
.newComponentBadge.expComponentBadge:before {
231+
.deprComponentBadge:before {
232+
color: #fff;
233+
position: absolute;
234+
top: 0.25rem;
235+
inset-inline-end: 1rem;
236+
border-radius: 0.5rem;
237+
padding: 0.125rem 0.25rem;
238+
box-sizing: border-box;
239+
font-size: 0.75rem;
240+
content: "depr";
241+
background: #ffb700e0;
242+
pointer-events: none;
243+
}
244+
245+
.deprComponentBadge.expComponentBadge:before {
246+
display: none;
247+
}
248+
249+
250+
.newComponentBadge.expComponentBadge:before,
251+
.newComponentBadge.deprComponentBadge:before {
231252
inset-inline-end: 3.25rem;
232253
}
233254

@@ -246,11 +267,13 @@ code {
246267
}
247268

248269
.theme-doc-sidebar-item-category.newComponentBadge:after,
249-
.theme-doc-sidebar-item-category.expComponentBadge:before {
270+
.theme-doc-sidebar-item-category.expComponentBadge:before,
271+
.theme-doc-sidebar-item-category.deprComponentBadge:before {
250272
inset-inline-end: 2.25rem;
251273
}
252274

253-
.theme-doc-sidebar-item-category.newComponentBadge.expComponentBadge:before {
275+
.theme-doc-sidebar-item-category.newComponentBadge.expComponentBadge:before,
276+
.theme-doc-sidebar-item-category.newComponentBadge.deprComponentBadge:before {
254277
inset-inline-end: 4.5rem;
255278
}
256279

0 commit comments

Comments
 (0)