Skip to content

Commit

Permalink
Merge branch 'main' into tokenizer-standalone-feat
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoplashkov committed May 7, 2024
2 parents a319d2d + 7a0e84e commit 83a2c1b
Show file tree
Hide file tree
Showing 501 changed files with 20,840 additions and 4,943 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
suite: ['base', 'main:suite-1', 'main:suite-2', 'fiori']
suite: ['base', 'compat', 'main:suite-1', 'main:suite-2', 'fiori']
steps:
- uses: actions/checkout@v4

Expand Down
24 changes: 1 addition & 23 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,18 @@
.gitignore
!packages/create-package/template/.gitignore
!packages/website/.gitignore
tmp
temp
target
dist
jsdoc-dist
**/src/generated
.dev-server-port
# TODO remove this as the tools no longer generate it, kept for clean up (in the clean task as well)
.port

# jsdoc temporary folders
packages/base/jsdoc-dist
packages/main/jsdoc-dist
packages/fiori/jsdoc-dist

# scoping feature generated entry points for vite consumption
packages/compat/test/pages/scoped
packages/main/test/pages/scoped
packages/fiori/test/pages/scoped
packages/main/test/pages/resources/css
packages/fiori/test/pages/resources/css

# Ignore default target directory for the npm package 'ui5-codecompletion'
.ui5

# Ignore npm files/folders
node_modules
npm-debug.log
package-lock.json

# Ignore Mac files
.DS_Store
Expand All @@ -50,14 +34,8 @@ yarn-error.log*
yarn-debug.log*
.yarn-integrity

# Ignore default target directory for the npm package 'ui5-schemas'
.tmp

# Ignore rollup CJS output file of icon-collection-bundler
icon-collection-bundler.cjs.js

# Playground
.jekyll-cache
packages/playground/_site/
packages/playground/.sass-cache/
packages/playground/assets/js/ui5-webcomponents/
Expand Down
2 changes: 1 addition & 1 deletion docs/3-customizing/01-styles.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ One of the core principles of Web Components is the encapsulation. The HTML and


## Styles on Tag Level
We designed some components such as Title, Label, Badge, Button, Input, and a few more in such a way that it is possible to set styles/classes on the custom elements that will take effect.
We designed some components such as Title, Label, Tag, Button, Input, and a few more in such a way that it is possible to set styles/classes on the custom elements that will take effect.

<b>For example:</b>
```css
Expand Down
2 changes: 1 addition & 1 deletion docs/5-development/04-understanding-hbs-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ Examples:

```handlebars
{{#if hasText}}
<label class="ui5-badge-text"><bdi><slot></slot></bdi></label>
<label class="ui5-tag-text"><bdi><slot></slot></bdi></label>
{{/if}}
```

Expand Down
17 changes: 16 additions & 1 deletion docs/Migrating to version 2.0 guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ import "@ui5/webcomponents-icons/dist/Assets.js"

## Main package (@ui5/webcomponents)

### ui5-badge

| Changed item | Old | New |
|-------------------------------|-------------------|--------------|
| tag | `ui5-badge` | `ui5-tag` |

- The Badge `ui5-badge` has been renamed to Tag `ui5-tag`. If you have previously used the `ui5-badge`:
```html
<ui5-badge></ui5-badge>
```
Now use `ui5-tag` instead:
```html
<ui5-tag></ui5-tag>
```


### ui5-breadcrumbs

| Changed item | Old | New |
Expand All @@ -75,7 +91,6 @@ Now use `separators` instead:
<ui5-breadcrumbs separators="Slash">
```


### ui5-busy-indicator

| Changed item | Old | New |
Expand Down
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"packages/tools",
"packages/playground",
"packages/website",
"packages/create-package"
"packages/create-package",
"packages/compat"
],
"version": "2.0.0-rc.2",
"command": {
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@
"scripts": {
"generate": "wsrun --exclude-missing generate",
"generateAPI": "wsrun --exclude-missing generateAPI",
"ts": "tsc -b packages/fiori/tsconfig.json",
"ts": "tsc -b packages/compat/tsconfig.json packages/fiori/tsconfig.json",
"bundle": "wsrun --exclude-missing bundle",
"clean": "wsrun --exclude-missing clean",
"scopePrepare:main": "yarn workspace @ui5/webcomponents nps scope.prepare",
"scopePrepare:compat": "yarn workspace @ui5/webcomponents-compat nps scope.prepare",
"scopePrepare:fiori": "yarn workspace @ui5/webcomponents-fiori nps scope.prepare",
"watch:base": "yarn workspace @ui5/webcomponents-base nps watch",
"watch:main": "yarn workspace @ui5/webcomponents nps watch",
"watch:compat": "yarn workspace @ui5/webcomponents-compat nps watch",
"watch:fiori": "yarn workspace @ui5/webcomponents-fiori nps watch",
"watch:allWithDelay": "node -e \"setTimeout(function(){}, 5000)\" && npm-run-all --parallel watch:base watch:main watch:fiori",
"watch:allWithDelay": "node -e \"setTimeout(function(){}, 5000)\" && npm-run-all --parallel watch:base watch:main watch:compat watch:fiori",
"scopeWatch:main": "yarn workspace @ui5/webcomponents nps scope.watch",
"scopeWatch:compat": "yarn workspace @ui5/webcomponents-compat nps scope.watch",
"scopeWatch:fiori": "yarn workspace @ui5/webcomponents-fiori nps scope.watch",
"startWithScope": "npm-run-all --sequential generate scopePrepare:main scopePrepare:fiori scopeStart:all",
"startWithScope": "npm-run-all --sequential generate scopePrepare:main scopePrepare:compat scopePrepare:fiori scopeStart:all",
"start:all": "npm-run-all --parallel watch:allWithDelay dev",
"dev": "node packages/tools/lib/dev-server/dev-server.js",
"scopeStart:all": "npm-run-all --parallel watch:base scopeWatch:main scopeWatch:fiori dev",
"scopeStart:all": "npm-run-all --parallel watch:base scopeWatch:main scopeWatch:compat scopeWatch:fiori dev",
"start:storybook": "yarn ci:releasebuild && yarn workspace @ui5/webcomponents-playground start",
"start:website": "yarn ci:releasebuild && yarn workspace @ui5/webcomponents-website start",

Expand All @@ -44,6 +47,7 @@
"ci:test:main:suite-1": "yarn workspace @ui5/webcomponents test:ssr && yarn workspace @ui5/webcomponents test:suite-1",
"ci:test:main:suite-2": "yarn workspace @ui5/webcomponents test:suite-2",
"ci:test:fiori": "yarn workspace @ui5/webcomponents-fiori test:ssr && yarn workspace @ui5/webcomponents-fiori test",
"ci:test:compat": "yarn workspace @ui5/webcomponents-compat test:ssr && yarn workspace @ui5/webcomponents-compat test",

"lint": "wsrun --exclude-missing lint",
"lint:scope": "wsrun --exclude-missing lint:scope",
Expand Down Expand Up @@ -81,6 +85,7 @@
"packages/base",
"packages/localization",
"packages/main",
"packages/compat",
"packages/fiori",
"packages/icons",
"packages/icons-business-suite",
Expand Down
6 changes: 6 additions & 0 deletions packages/base/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
test/
src/**/*.ts
node_modules/
.eslintignore
.eslintrc.cjs
used-modules.txt
bundle.esm.js
lib/
12 changes: 10 additions & 2 deletions packages/base/src/features/OpenUI5Support.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import patchPatcher from "./patchPatcher.js";
import type { OpenUI5Patcher } from "./patchPatcher.js";
import patchPopup from "./patchPopup.js";
import type { OpenUI5Popup } from "./patchPopup.js";
import { registerFeature } from "../FeaturesRegistry.js";
import { setTheme } from "../config/Theme.js";
import { CLDRData } from "../asset-registries/LocaleData.js";
Expand Down Expand Up @@ -84,7 +88,7 @@ class OpenUI5Support {
return new Promise<void>(resolve => {
window.sap.ui.require(["sap/ui/core/Core"], async (Core: OpenUI5Core) => {
const callback = () => {
let deps: Array<string> = ["sap/ui/core/LocaleData"];
let deps: Array<string> = ["sap/ui/core/Popup", "sap/ui/core/Patcher", "sap/ui/core/LocaleData"];
if (OpenUI5Support.isAtLeastVersion116()) { // for versions since 1.116.0 and onward, use the modular core
deps = [
...deps,
Expand All @@ -95,7 +99,11 @@ class OpenUI5Support {
"sap/ui/core/date/CalendarUtils",
];
}
window.sap.ui.require(deps, resolve);
window.sap.ui.require(deps, (Popup: OpenUI5Popup, Patcher: OpenUI5Patcher) => {
patchPatcher(Patcher);
patchPopup(Popup);
resolve();
});
};
if (OpenUI5Support.isAtLeastVersion116()) {
await Core.ready();
Expand Down
19 changes: 19 additions & 0 deletions packages/base/src/features/patchPatcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
type OpenUI5Patcher = {
prototype: {
_mAttributes: { [key: string]: string },
openEnd: () => OpenUI5Patcher,
}
};

const patchPatcher = (Patcher: OpenUI5Patcher) => {
const origOpenEnd = Patcher.prototype.openEnd;
Patcher.prototype.openEnd = function openEnd() {
if (this._mAttributes.popover) {
delete this._mAttributes.popover; // The "popover" attribute will be managed externally, don't let Patcher remove it
}
return origOpenEnd.apply(this);
};
};

export default patchPatcher;
export type { OpenUI5Patcher };
71 changes: 71 additions & 0 deletions packages/base/src/features/patchPopup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// OpenUI5's Element.js subset
type Element = {
getDomRef: () => HTMLElement | null,
}

// The lifecycle of Popup.js is open -> _opened -> close -> _closed, we're interested in the first (open) and last (_closed)
type OpenUI5Popup = {
prototype: {
open: (...args: any[]) => void,
_closed: (...args: any[]) => void,
getOpenState: () => "CLOSED" | "CLOSING" | "OPEN" | "OPENING",
getContent: () => Element, // this is the OpenUI5 Element/Control instance that opens the Popup (usually sap.m.Popover/sap.m.Dialog)
}
};

const openNativePopover = (domRef: HTMLElement) => {
domRef.setAttribute("popover", "manual");
domRef.showPopover();
};

const closeNativePopover = (domRef: HTMLElement) => {
if (domRef.hasAttribute("popover")) {
domRef.hidePopover();
domRef.removeAttribute("popover");
}
};

const patchOpen = (Popup: OpenUI5Popup) => {
const origOpen = Popup.prototype.open;
Popup.prototype.open = function open(...args: any[]) {
origOpen.apply(this, args); // call open first to initiate opening
const topLayerAlreadyInUse = !!document.body.querySelector(":popover-open"); // check if there is already something in the top layer
const openingInitiated = ["OPENING", "OPEN"].includes(this.getOpenState());
if (openingInitiated && topLayerAlreadyInUse) {
const element = this.getContent();
if (element) {
const domRef = element.getDomRef();
if (domRef) {
openNativePopover(domRef);
}
}
}
};
};

const patchClosed = (Popup: OpenUI5Popup) => {
const _origClosed = Popup.prototype._closed;
Popup.prototype._closed = function _closed(...args: any[]) {
const element = this.getContent();
const domRef = element.getDomRef();
_origClosed.apply(this, args); // only then call _close
if (domRef) {
closeNativePopover(domRef); // unset the popover attribute and close the native popover, but only if still in DOM
}
};
};

const createGlobalStyles = () => {
const stylesheet = new CSSStyleSheet();
stylesheet.replaceSync(`.sapMPopup-CTX:popover-open { inset: unset; }`);
document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
};

const patchPopup = (Popup: OpenUI5Popup) => {
patchOpen(Popup); // Popup.prototype.open
patchClosed(Popup); // Popup.prototype._closed
createGlobalStyles(); // Ensures correct popover positioning by OpenUI5 (otherwise 0,0 is the center of the screen)
};

export default patchPopup;
export type { OpenUI5Popup };
1 change: 1 addition & 0 deletions packages/compat/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_BUNDLE_PATH="../../dist/bundle.esm.js"
12 changes: 12 additions & 0 deletions packages/compat/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Note: Changes to this file also must be applied to the top level .eslintignore file.
target
dist
src/generated
lib
test
bundle.*.js
rollup.config*.js
wdio.conf.cjs
postcss.config.cjs
package-scripts.cjs
.eslintrc.cjs
3 changes: 3 additions & 0 deletions packages/compat/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = require("@ui5/webcomponents-tools/components-package/eslint.js");

module.exports = config;
8 changes: 8 additions & 0 deletions packages/compat/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
src/generated
src/**/*.ts
node_modules/
test/
.eslintrc.cjs
.eslintignore
main.*js
config/
2 changes: 2 additions & 0 deletions packages/compat/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enforce public npm registry
registry = https://registry.npmjs.org/
3 changes: 3 additions & 0 deletions packages/compat/.npsrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"config": "./package-scripts.cjs"
}
Empty file added packages/compat/CHANGELOG.md
Empty file.
45 changes: 45 additions & 0 deletions packages/compat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/main/docs/images/UI5_logo_wide.png)


# UI5 Web Components - Compatibility

[![npm Package Version](https://badge.fury.io/js/%40ui5%2Fwebcomponents.svg)](https://www.npmjs.com/package/@ui5/webcomponents)

Provides Table web component for compatibility (previously part of the "@ui5/webcomponents" package), while brand new Table web component is being developed and will replace it in the "@ui5/webcomponents" package.


**Note:** The package is available since 2.0 and will be available until the next major release (3.0) when it will be removed as the Table "@ui5/webcomponents" will finally replace it.


## Provided components

| Web Component | Tag name | Module import |
|--------------------------|-----------------------------|------------------------------------------------------------|
| Table | `ui5-table` | `import "@ui5/webcomponents-compat/dist/Table.js";` |
| Table Column | `ui5-table-column` | `import "@ui5/webcomponents-compat/dist/TableColumn.js";` |
| Table Row | `ui5-table-row` | `import "@ui5/webcomponents-compat/dist/TableRow.js";` |
| Table Group Row | `ui5-table-group-row` | `import "@ui5/webcomponents-compat/dist/TableGroupRow.js";` |
| Table Cell | `ui5-table-cell` | `import "@ui5/webcomponents-compat/dist/TableCell.js";` |


## Provided assets


| Assets | Module | Notes
|------------|-----------|-----------
| `i18n`, `themes` | `@ui5/webcomponents-compat/dist/Assets.js` | Theming parameters and translations for the components


## Resources
- [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/main/README.md)
- [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/)

## Support
We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://ui5-slack-invite.cfapps.eu10.hana.ondemand.com/).

## Contribute
Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md).

## License
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the [LICENSE](https://github.com/SAP/ui5-webcomponents/blob/main/LICENSE.txt) file.
3 changes: 3 additions & 0 deletions packages/compat/config/wdio.conf.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const wdio = require("@ui5/webcomponents-tools/components-package/wdio.js");
wdio.config.services.push("devtools");
module.exports = wdio;
11 changes: 11 additions & 0 deletions packages/compat/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es2017",
"allowSyntheticDefaultImports": false,
"baseUrl": "./",
"paths": {
"@ui5/webcomponents-base/dist/*": ["../base/src/*"]
}
},
"exclude": ["node_modules", "dist"]
}
Loading

0 comments on commit 83a2c1b

Please sign in to comment.