Skip to content

Commit 801e64a

Browse files
feat: update @ui5/webcomponents to 1.0.0-rc.10 (#946)
Full Changelog can be found at https://github.com/SAP/ui5-webcomponents/releases/tag/v1.0.0-rc.10 BREAKING CHANGE: Icon import paths changed from e.g. `@ui5/webcomponents/dist/icons/add.js` to `@ui5/webcomponents-icons/dist/icons/add.js`. (`icon` directory got removed)
1 parent efce1dd commit 801e64a

File tree

144 files changed

+2156
-1273
lines changed

Some content is hidden

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

144 files changed

+2156
-1273
lines changed

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
"@storybook/cli": "6.0.28",
3131
"@storybook/react": "6.0.28",
3232
"@storybook/theming": "6.0.28",
33-
"@ui5/webcomponents": "1.0.0-rc.9",
34-
"@ui5/webcomponents-fiori": "1.0.0-rc.9",
35-
"@ui5/webcomponents-icons": "1.0.0-rc.9",
33+
"@ui5/webcomponents": "1.0.0-rc.10",
34+
"@ui5/webcomponents-fiori": "1.0.0-rc.10",
35+
"@ui5/webcomponents-icons": "1.0.0-rc.10",
3636
"react": "17.0.1",
3737
"react-dom": "17.0.1",
3838
"react-syntax-highlighter": "^15.2.1",
@@ -62,7 +62,7 @@
6262
"@types/react-dom": "^16.9.6",
6363
"@typescript-eslint/eslint-plugin": "^4.4.0",
6464
"@typescript-eslint/parser": "^4.4.0",
65-
"@ui5/webcomponents-tools": "^1.0.0-rc.9",
65+
"@ui5/webcomponents-tools": "1.0.0-rc.10",
6666
"babel-loader": "^8.1.0",
6767
"chalk": "^4.0.0",
6868
"dedent": "^0.7.0",
@@ -92,6 +92,7 @@
9292
"rollup": "^2.23.0",
9393
"rollup-plugin-terser": "^7.0.2",
9494
"targz": "^1.0.1",
95+
"turndown": "^7.0.0",
9596
"typescript": "^4.0.3"
9697
},
9798
"resolutions": {

packages/base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"smoothscroll-polyfill": "0.4.4"
3434
},
3535
"peerDependencies": {
36-
"@ui5/webcomponents-base": "1.0.0-rc.9",
36+
"@ui5/webcomponents-base": "0.26.0",
3737
"react": "^16.8.0 || ^17.0.0",
3838
"react-jss": "^10.0.4"
3939
},

packages/charts/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"recharts": "2.0.0-beta.8"
2727
},
2828
"peerDependencies": {
29-
"@ui5/webcomponents-react": "^0.11.0",
30-
"@ui5/webcomponents-react-base": "^0.11.0",
29+
"@ui5/webcomponents-react": "^0.12.0",
30+
"@ui5/webcomponents-react-base": "^0.12.0",
3131
"react": "^16.8.0 || ^17.0.0",
3232
"react-jss": "^10.0.4"
3333
},

packages/cra-template-seed/template.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"package": {
33
"dependencies": {
44
"@testing-library/jest-dom": "^5.11.4",
5-
"@testing-library/react": "^10.4.9",
6-
"@testing-library/user-event": "^12.1.4",
7-
"@ui5/webcomponents": "1.0.0-rc.9",
8-
"@ui5/webcomponents-fiori": "1.0.0-rc.9",
9-
"@ui5/webcomponents-icons": "1.0.0-rc.9",
10-
"@ui5/webcomponents-react": "^0.11.0",
11-
"@ui5/webcomponents-react-base": "^0.11.0",
5+
"@testing-library/react": "^11.1.0",
6+
"@testing-library/user-event": "^12.1.10",
7+
"@ui5/webcomponents": "1.0.0-rc.10",
8+
"@ui5/webcomponents-fiori": "1.0.0-rc.10",
9+
"@ui5/webcomponents-icons": "1.0.0-rc.10",
10+
"@ui5/webcomponents-react": "^0.12.0",
11+
"@ui5/webcomponents-react-base": "^0.12.0",
1212
"axios": "^0.20.0",
1313
"husky": "^4.2.5",
1414
"i18next": "^19.7.0",

packages/cra-template/template.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"package": {
33
"dependencies": {
4-
"@ui5/webcomponents": "1.0.0-rc.9",
5-
"@ui5/webcomponents-fiori": "1.0.0-rc.9",
6-
"@ui5/webcomponents-icons": "1.0.0-rc.9",
7-
"@ui5/webcomponents-react": "^0.11.0",
8-
"@testing-library/react": "^9.3.2",
9-
"@testing-library/jest-dom": "^4.2.4",
10-
"@testing-library/user-event": "^7.1.2",
4+
"@ui5/webcomponents": "1.0.0-rc.10",
5+
"@ui5/webcomponents-fiori": "1.0.0-rc.10",
6+
"@ui5/webcomponents-icons": "1.0.0-rc.10",
7+
"@ui5/webcomponents-react": "^0.12.0",
8+
"@testing-library/jest-dom": "^5.11.4",
9+
"@testing-library/react": "^11.1.0",
10+
"@testing-library/user-event": "^12.1.10",
1111
"jest-environment-jsdom-sixteen": "^1.0.3"
1212
},
1313
"scripts": {

packages/main/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "SAP SE (https://www.sap.com)",
1515
"license": "Apache-2.0",
1616
"sideEffects": [
17-
"@ui5/webcomponents-icons/dist/icons/*",
17+
"@ui5/webcomponents-icons/dist/*",
1818
"@ui5/webcomponents/dist/*",
1919
"@ui5/webcomponents-fiori/dist/*",
2020
"./dist/Assets.js",
@@ -41,10 +41,10 @@
4141
"react-virtual": "2.3.1"
4242
},
4343
"peerDependencies": {
44-
"@ui5/webcomponents": "1.0.0-rc.9",
45-
"@ui5/webcomponents-base": "1.0.0-rc.9",
46-
"@ui5/webcomponents-fiori": "1.0.0-rc.9",
47-
"@ui5/webcomponents-icons": "1.0.0-rc.9",
44+
"@ui5/webcomponents": "1.0.0-rc.10",
45+
"@ui5/webcomponents-base": "0.26.0",
46+
"@ui5/webcomponents-fiori": "1.0.0-rc.10",
47+
"@ui5/webcomponents-icons": "1.0.0-rc.10",
4848
"react": "^16.8.0 || ^17.0.0",
4949
"react-dom": "^16.8.0 || ^17.0.0"
5050
},

packages/main/scripts/create-web-components-wrapper.mjs

Lines changed: 66 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
2-
3-
//TODO:
4-
console.warn(
5-
'----------------------\nCurrently there are two tag-names missing or faulty: "ui5-notification-overflow-action" and "ui5-timeline-item"\nThese have to be adjusted manually!\n----------------------'
6-
);
7-
8-
// To only create a single component, replace "false" with the component (module) name
9-
// or execute the following command: "yarn create-webcomponents-wrapper [name]"
10-
const CREATE_SINGLE_COMPONENT = process.argv[2] || false;
11-
12-
const EXCLUDE_LIST = ['NotificationListItem'];
13-
142
import mainWebComponentsSpec from '@ui5/webcomponents/dist/api.json';
153
import fioriWebComponentsSpec from '@ui5/webcomponents-fiori/dist/api.json';
164
import dedent from 'dedent';
@@ -19,6 +7,19 @@ import prettierConfigRaw from '../../../prettier.config.cjs';
197
import path from 'path';
208
import PATHS from '../../../config/paths.js';
219
import fs from 'fs';
10+
import TurndownService from 'turndown';
11+
12+
const turndownService = new TurndownService({
13+
headingStyle: 'atx',
14+
codeBlockStyle: 'fenced'
15+
});
16+
turndownService.keep(['ui5-link']);
17+
18+
// To only create a single component, replace "false" with the component (module) name
19+
// or execute the following command: "yarn create-webcomponents-wrapper [name]"
20+
const CREATE_SINGLE_COMPONENT = process.argv[2] || false;
21+
22+
const EXCLUDE_LIST = ['NotificationListItem'];
2223

2324
const prettierConfig = {
2425
...prettierConfigRaw,
@@ -102,26 +103,44 @@ COMPONENTS_WITHOUT_DEMOS.add('SideNavigationSubItem');
102103
COMPONENTS_WITHOUT_DEMOS.add('SuggestionItem');
103104
COMPONENTS_WITHOUT_DEMOS.add('UploadCollectionItem');
104105
COMPONENTS_WITHOUT_DEMOS.add('NotificationOverflowAction');
106+
COMPONENTS_WITHOUT_DEMOS.add('WizardStep');
105107

106108
const componentsFromFioriPackage = new Set(fioriWebComponentsSpec.symbols.map((componentSpec) => componentSpec.module));
107109

110+
const allWebComponents = [
111+
...mainWebComponentsSpec.symbols.filter((spec) => !spec.module.startsWith('types/')),
112+
...fioriWebComponentsSpec.symbols.filter((spec) => !spec.module.startsWith('types/'))
113+
];
114+
115+
const htmlTagToModuleNameMap = new Map();
116+
for (const spec of allWebComponents) {
117+
htmlTagToModuleNameMap.set(spec.tagname, spec.module);
118+
}
119+
108120
const capitalizeFirstLetter = (s) => s.charAt(0).toUpperCase() + s.slice(1);
109121
const snakeToCamel = (str) => str.replace(/([-_]\w)/g, (g) => g[1].toUpperCase());
110122
const filterNonPublicAttributes = (prop) =>
111123
prop.visibility === 'public' && prop.readonly !== 'true' && prop.static !== true;
112124

113125
const replaceTagNameWithModuleName = (description) => {
126+
let parsedDescription = description.replace(/(ui5-[\w-]+)/g, (fullMatch, tag, ...args) => {
127+
if (tag === 'ui5-link') return tag;
128+
return htmlTagToModuleNameMap.get(tag);
129+
});
130+
131+
parsedDescription = parsedDescription.replace(/`ui5-link/g, `\`${htmlTagToModuleNameMap.get('ui5-link')}`);
132+
114133
// replace all tag occurrences in description with module name
115-
[...description.matchAll(new RegExp(`<code>ui5-`, 'g'))].forEach(() => {
134+
[...parsedDescription.matchAll(new RegExp(`<code>ui5-`, 'g'))].forEach(() => {
116135
const start = description.indexOf(`<code>ui5-`) + 6;
117136
const end = description.indexOf(`</code>`, start);
118137
const tagName = description.slice(start, end);
119-
const webComponentWithTagName = allWebComponents.find((item) => item.tagname === tagName);
120-
if (webComponentWithTagName) {
121-
description = description.replace(webComponentWithTagName.tagname, webComponentWithTagName.module);
138+
if (htmlTagToModuleNameMap.has(tagName)) {
139+
description = description.replace(tagName, htmlTagToModuleNameMap.get(tagName));
122140
}
123141
});
124-
return description;
142+
143+
return parsedDescription;
125144
};
126145

127146
const getTypeScriptTypeForProperty = (property) => {
@@ -407,31 +426,45 @@ const createWebComponentWrapper = (
407426
}
408427
let componentDescription;
409428
try {
410-
componentDescription = prettier
411-
.format(description, {
412-
...prettierConfigRaw,
413-
parser: 'html'
414-
})
415-
.replace(/\s\s+/g, ' ');
429+
componentDescription = turndownService.turndown(description).replace(/\n/g, '\n * ');
416430
} catch (e) {
417431
console.warn(
418432
`----------------------\nHeader description of ${name} couldn't be generated. \nThere is probably a syntax error in the associated description that can't be fixed automatically.\n----------------------`
419433
);
420434
componentDescription = '';
421435
}
436+
437+
const regularImports = importStatements
438+
.filter((imp) => !imp.includes("from 'react'"))
439+
.sort((a, b) => {
440+
const importNameA = /import \{ (\w+) \}/.exec(a)[1];
441+
const importNameB = /import \{ (\w+) \}/.exec(b)[1];
442+
return importNameA.localeCompare(importNameB);
443+
});
444+
const reactImports = [
445+
'FC',
446+
...importStatements
447+
.filter((imp) => imp.includes("from 'react'"))
448+
.map((imp) => {
449+
const match = /import \{ (\w+) \}/.exec(imp);
450+
return match[1];
451+
})
452+
].sort((a, b) => a.localeCompare(b));
453+
422454
return prettier.format(
423455
`
456+
${regularImports.join('\n')}
424457
import { withWebComponent, WithWebComponentPropTypes } from '@ui5/webcomponents-react/lib/withWebComponent';
425458
import '@ui5/webcomponents${componentsFromFioriPackage.has(name) ? '-fiori' : ''}/dist/${name}';
426-
import { FC } from 'react';
427-
${importStatements.join('\n')}
459+
import { ${reactImports.join(', ')} } from 'react';
428460
429461
export interface ${name}PropTypes extends ${tsExtendsStatement} {
430462
${types.join('\n')}
431463
}
432464
433465
/**
434466
* ${componentDescription}
467+
*
435468
* <a href="https://sap.github.io/ui5-webcomponents/playground/components/${name}" target="_blank">UI5 Web Components Playground</a>
436469
*/
437470
const ${name}: FC<${name}PropTypes> = withWebComponent<${name}PropTypes>(
@@ -494,7 +527,7 @@ const createWebComponentDemo = (componentSpec, componentProps, description) => {
494527
enumImports.push(prop.importStatement);
495528
}
496529
if (componentSpec.module === 'Icon' && prop.name === 'name') {
497-
enumImports.push(`import "@ui5/webcomponents-icons/dist/icons/employee.js";`);
530+
enumImports.push(`import "@ui5/webcomponents-icons/dist/employee.js";`);
498531
args.push(`name: 'employee'`);
499532
}
500533
if (prop.name === 'primaryCalendarType') {
@@ -516,7 +549,7 @@ const createWebComponentDemo = (componentSpec, componentProps, description) => {
516549
customArgTypes.push(`children: {control: {disable:true}}`);
517550
}
518551
} else if (prop.name === 'icon') {
519-
enumImports.push(`import "@ui5/webcomponents-icons/dist/icons/employee.js";`);
552+
enumImports.push(`import "@ui5/webcomponents-icons/dist/employee.js";`);
520553
enumImports.push(`import { Icon } from '@ui5/webcomponents-react/lib/Icon';`);
521554
if (prop.tsType === 'string') {
522555
args.push(`icon: 'employee'`);
@@ -613,11 +646,6 @@ const createWebComponentDemo = (componentSpec, componentProps, description) => {
613646
)}${formattedDescription}`;
614647
};
615648

616-
const allWebComponents = [
617-
...mainWebComponentsSpec.symbols.filter((spec) => !spec.module.startsWith('types/')),
618-
...fioriWebComponentsSpec.symbols.filter((spec) => !spec.module.startsWith('types/'))
619-
];
620-
621649
const assignComponentPropertiesToMaps = (componentSpec, { properties, slots, events }) => {
622650
(componentSpec.properties || []).forEach((prop) => {
623651
if (!properties.has(prop.name)) {
@@ -699,10 +727,9 @@ resolvedWebComponents.forEach((componentSpec) => {
699727
if (!componentSpec.tagname) {
700728
return property.description || '';
701729
}
702-
let formattedDescription = (property.description || '')
703-
.replace(/\n\n<br><br> /g, '<br/><br/>\n *\n * ')
704-
.replace(/\n\n/g, '<br/><br/>\n *\n * ')
705-
.replace(new RegExp(componentSpec.tagname, 'g'), `${componentSpec.module}`);
730+
let formattedDescription = turndownService
731+
.turndown((property.description || '').trim())
732+
.replace(/\n/g, '\n * ');
706733

707734
const customDescriptionReplace = CUSTOM_DESCRIPTION_REPLACE[componentSpec.module];
708735
if (customDescriptionReplace && customDescriptionReplace[property.name]) {
@@ -746,7 +773,9 @@ resolvedWebComponents.forEach((componentSpec) => {
746773
importStatements.push(...eventParameters.importStatements);
747774
propTypes.push(dedent`
748775
/**
749-
* ${replaceTagNameWithModuleName(eventSpec.description)}
776+
* ${replaceTagNameWithModuleName(
777+
turndownService.turndown((eventSpec.description || '').trim()).replace(/\n/g, '\n * ')
778+
)}
750779
*/
751780
on${capitalizeFirstLetter(snakeToCamel(eventSpec.name))}?: ${eventParameters.tsType};
752781
`);

packages/main/src/components/AnalyticalCard/AnalyticalCard.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
22
import { createSelectArgTypes } from '@shared/stories/createSelectArgTypes';
33
import { DocsHeader } from '@shared/stories/DocsHeader';
4-
import '@ui5/webcomponents-icons/dist/icons/person-placeholder.js';
4+
import '@ui5/webcomponents-icons/dist/person-placeholder.js';
55
import { AnalyticalCard } from '@ui5/webcomponents-react/lib/AnalyticalCard';
66
import { AnalyticalCardHeader } from '@ui5/webcomponents-react/lib/AnalyticalCardHeader';
77
import { DeviationIndicator } from '@ui5/webcomponents-react/lib/DeviationIndicator';

packages/main/src/components/AnalyticalTable/AnalyticalTable.stories.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { TableSelectionBehavior } from '@ui5/webcomponents-react/lib/TableSelect
66
import { TableSelectionMode } from '@ui5/webcomponents-react/lib/TableSelectionMode';
77
import generateData from './demo/generateData';
88
import { DocsHeader } from '@shared/stories/DocsHeader';
9-
import '@ui5/webcomponents-icons/dist/icons/delete';
10-
import '@ui5/webcomponents-icons/dist/icons/edit';
11-
import '@ui5/webcomponents-icons/dist/icons/settings';
9+
import '@ui5/webcomponents-icons/dist/delete';
10+
import '@ui5/webcomponents-icons/dist/edit';
11+
import '@ui5/webcomponents-icons/dist/settings';
1212
import { Button } from '@ui5/webcomponents-react/lib/Button';
1313
import { FlexBox } from '@ui5/webcomponents-react/lib/FlexBox';
1414
import { TextAlign } from '@ui5/webcomponents-react/lib/TextAlign';

packages/main/src/components/AnalyticalTable/ColumnHeader/ColumnHeaderModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '@ui5/webcomponents-icons/dist/icons/decline';
1+
import '@ui5/webcomponents-icons/dist/decline';
22
import { useI18nText } from '@ui5/webcomponents-react-base/lib/hooks';
33
import { ThemingParameters } from '@ui5/webcomponents-react-base/lib/ThemingParameters';
44
import { enrichEventWithDetails } from '@ui5/webcomponents-react-base/lib/Utils';

0 commit comments

Comments
 (0)