@ui5/webcomponents-base 2.20.0 → 2.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/.tsbuildinfobuild +1 -1
- package/dist/createReactComponent.d.ts +26 -0
- package/dist/createReactComponent.js +51 -0
- package/dist/createReactComponent.js.map +1 -0
- package/dist/custom-elements-internal.json +15 -0
- package/dist/custom-elements.json +15 -0
- package/dist/generated/VersionInfo.js +3 -3
- package/dist/generated/VersionInfo.js.map +1 -1
- package/dist/prod/createReactComponent.js +2 -0
- package/dist/prod/createReactComponent.js.map +7 -0
- package/dist/prod/generated/VersionInfo.js +1 -1
- package/dist/prod/generated/VersionInfo.js.map +1 -1
- package/dist/prod/sap/base/Log.js +15 -29
- package/dist/prod/sap/base/assert.js +1 -1
- package/dist/prod/sap/base/config/MemoryConfigurationProvider.js +1 -1
- package/dist/prod/sap/base/security/URLListValidator.js +9 -5
- package/dist/prod/sap/base/security/encodeCSS.js +1 -1
- package/dist/prod/sap/base/security/encodeXML.js +1 -1
- package/dist/prod/sap/base/security/sanitizeHTML.js +1 -1
- package/dist/prod/sap/base/strings/toHex.js +1 -1
- package/dist/prod/sap/base/util/now.js +7 -13
- package/dist/prod/sap/base/util/uid.js +1 -1
- package/dist/prod/sap/ui/thirdparty/caja-html-sanitizer.js +15 -3
- package/dist/react18/createReactComponent.d.ts +38 -0
- package/dist/react18/createReactComponent.js +112 -0
- package/dist/react18/createReactComponent.js.map +1 -0
- package/dist/sap/base/Log.js +15 -29
- package/dist/sap/base/assert.js +1 -1
- package/dist/sap/base/config/MemoryConfigurationProvider.js +1 -1
- package/dist/sap/base/security/URLListValidator.js +9 -5
- package/dist/sap/base/security/encodeCSS.js +1 -1
- package/dist/sap/base/security/encodeXML.js +1 -1
- package/dist/sap/base/security/sanitizeHTML.js +1 -1
- package/dist/sap/base/strings/toHex.js +1 -1
- package/dist/sap/base/util/now.js +7 -13
- package/dist/sap/base/util/uid.js +1 -1
- package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +15 -3
- package/package.json +12 -4
- package/src/react18/createReactComponent.tsx +140 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createReactComponent.js","sourceRoot":"","sources":["../../src/react18/createReactComponent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACN,MAAM,EACN,SAAS,EACT,UAAU,GACV,MAAM,OAAO,CAAC;AAaf,+BAA+B;AAC/B,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAU,EAAE;IAChD,OAAO,QAAQ;SACb,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc;SACvB,OAAO,CAAC,UAAU,EAAE,CAAC,KAAa,EAAE,MAAc,EAAE,KAAa,EAAU,EAAE;QAC7E,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,uDAAuD;AACvD,MAAM,kBAAkB,GAAG,CAAC,OAAmB,EAAE,SAAiB,EAAE,OAAqB,EAAgB,EAAE;IAC1G,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC7C,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,SAAS,oBAAoB,CAC5B,cAAoC;IAIpC,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC;IAEtD,MAAM,SAAS,GAAG,UAAU,CAA+C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACzF,MAAM,EAAE,QAAQ,EAA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AAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACzD,IAAI,CAAC,EAAE,CAAC,CAAC;IAEX,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,eAAe,oBAAoB,CAAC","sourcesContent":["/**\n * React wrapper factory for UI5 Web Components.\n *\n * This lightweight factory creates typed React components that wrap UI5 Web Components.\n * It handles:\n * - Event prop conversion (onXxx → ui5-xxx event listeners)\n * - Ref forwarding\n * - Children handling\n *\n * Note: The function supports react >= 18.\n * Note: This is for documentation samples only - for production React apps,\n * use the official @ui5/webcomponents-react library.\n */\n\nimport * as React from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from \"react\";\nimport type UI5Element from \"../UI5Element.js\";\n\ntype EventHandler<E = Event> = (event: E) => void;\n\n// Interface for UI5 Web Component classes with _jsxProps support\ninterface UI5ComponentClass<T extends UI5Element = UI5Element> {\n\tnew (): T;\n\tgetMetadata(): {\n\t\tgetTag(): string;\n\t};\n}\n\n// Helper to convert event name\nconst toEventName = (propName: string): string => {\n\treturn propName\n\t\t.slice(2) // Remove \"on\"\n\t\t.replace(/([A-Z])/g, (match: string, letter: string, index: number): string => {\n\t\t\treturn index === 0 ? letter.toLowerCase() : `-${letter.toLowerCase()}`;\n\t\t});\n};\n\n// Helper to create cleanup function for event listener\nconst createEventCleanup = (element: UI5Element, eventName: string, handler: EventHandler): (() => void) => {\n\telement.addEventListener(eventName, handler);\n\treturn () => element.removeEventListener(eventName, handler);\n};\n\n/**\n * Creates a React component wrapper for a UI5 Web Component.\n * Uses the component's _jsxProps type for full TypeScript support.\n *\n * @param ComponentClass - The UI5 Web Component class (e.g., Button from \"@ui5/webcomponents/dist/Button.js\")\n * @returns A React component that renders the custom element with proper TypeScript types\n * @since 2.21.0\n * @example\n * import Button from \"@ui5/webcomponents/dist/Button.js\";\n * const ReactButton = createReactComponent(Button);\n * // ReactButton props are typed based on Button's _jsxProps\n */\nfunction createReactComponent<T extends UI5Element>(\n\tComponentClass: UI5ComponentClass<T>,\n): React.ForwardRefExoticComponent<\n\tReact.PropsWithoutRef<T[\"_jsxProps\"] & { children?: ReactNode }> & React.RefAttributes<T>\n> {\n\tconst tagName = ComponentClass.getMetadata().getTag();\n\n\tconst Component = forwardRef<T, T[\"_jsxProps\"] & { children?: ReactNode }>((props, ref) => {\n\t\tconst { children, ...restProps } = props;\n\t\tconst elementRef = useRef<T>(null);\n\n\t\t// Forward ref\n\t\tuseEffect(() => {\n\t\t\tif (ref) {\n\t\t\t\tif (typeof ref === \"function\") {\n\t\t\t\t\tref(elementRef.current);\n\t\t\t\t} else {\n\t\t\t\t\tref.current = elementRef.current;\n\t\t\t\t}\n\t\t\t}\n\t\t}, [ref]);\n\n\t\t// Handle event props and boolean props imperatively\n\t\tuseEffect(() => {\n\t\t\tconst element = elementRef.current;\n\t\t\tif (!element) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst eventCleanups: Array<() => void> = [];\n\n\t\t\tObject.keys(restProps).forEach(propName => {\n\t\t\t\tconst propValue = (restProps as Record<string, unknown>)[propName];\n\t\t\t\tif (propName.startsWith(\"on\") && typeof propValue === \"function\") {\n\t\t\t\t\t// Convert React event naming (onClick, onSelectionChange) to DOM event naming\n\t\t\t\t\t// onClick -> click, onSelectionChange -> selection-change\n\t\t\t\t\tconst eventName = toEventName(propName);\n\t\t\t\t\tconst handler = propValue as EventHandler;\n\t\t\t\t\teventCleanups.push(createEventCleanup(element, eventName, handler));\n\t\t\t\t} else if (typeof propValue === \"boolean\") {\n\t\t\t\t\t// React 18 sets false booleans as empty string attributes on custom elements.\n\t\t\t\t\t// Set as property directly to avoid this.\n\t\t\t\t\t(element as any)[propName] = propValue;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn () => {\n\t\t\t\teventCleanups.forEach(cleanup => cleanup());\n\t\t\t};\n\t\t}, [restProps]);\n\n\t\t// Filter out event handlers and booleans from DOM props\n\t\tconst domProps: Record<string, unknown> = {};\n\t\tObject.keys(restProps).forEach(propName => {\n\t\t\tconst propValue = (restProps as Record<string, unknown>)[propName];\n\t\t\tif (propName.startsWith(\"on\") && typeof propValue === \"function\") { return; }\n\t\t\tif (typeof propValue === \"boolean\") { return; } // handled in useEffect\n\t\t\t// className → class for React compatibility\n\t\t\tif (propName === \"className\") {\n\t\t\t\t// eslint-disable-next-line dot-notation\n\t\t\t\tdomProps[\"class\"] = propValue;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Convert camelCase to kebab-case for HTML attributes\n\t\t\tconst attrName = propName.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\t\t\tdomProps[attrName] = propValue;\n\t\t});\n\n\t\treturn React.createElement(tagName, { ref: elementRef, ...domProps }, children);\n\t});\n\n\tComponent.displayName = tagName\n\t\t.split(\"-\")\n\t\t.map(part => part.charAt(0).toUpperCase() + part.slice(1))\n\t\t.join(\"\");\n\n\treturn Component;\n}\n\nexport default createReactComponent;\n"]}
|
package/dist/sap/base/Log.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* OpenUI5
|
|
3
|
-
* (c) Copyright
|
|
3
|
+
* (c) Copyright 2026 SAP SE or an SAP affiliate company.
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
5
5
|
*/
|
|
6
|
-
import BaseConfig from "./config.js";
|
|
7
6
|
import now from "./util/now.js";
|
|
8
7
|
/**
|
|
9
8
|
* A Logging API for JavaScript.
|
|
@@ -202,8 +201,8 @@ function getLogEntryListenerInstance() {
|
|
|
202
201
|
* Name of the component that produced the log entry
|
|
203
202
|
* @param {function} [fnSupportInfo]
|
|
204
203
|
* Callback that returns an additional support object to be logged in support mode.
|
|
205
|
-
* This function is only called if support info mode is turned on
|
|
206
|
-
*
|
|
204
|
+
* This function is only called if support info mode is turned on via
|
|
205
|
+
* the Support Assistant. To avoid negative effects regarding execution times and
|
|
207
206
|
* memory consumption, the returned object should be a simple immutable JSON object with mostly
|
|
208
207
|
* static and stable content.
|
|
209
208
|
* @public
|
|
@@ -225,8 +224,8 @@ Log.fatal = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
|
225
224
|
* Name of the component that produced the log entry
|
|
226
225
|
* @param {function} [fnSupportInfo]
|
|
227
226
|
* Callback that returns an additional support object to be logged in support mode.
|
|
228
|
-
* This function is only called if support info mode is turned on
|
|
229
|
-
*
|
|
227
|
+
* This function is only called if support info mode is turned on via
|
|
228
|
+
* the Support Assistant. To avoid negative effects regarding execution times and
|
|
230
229
|
* memory consumption, the returned object should be a simple immutable JSON object with mostly
|
|
231
230
|
* static and stable content.
|
|
232
231
|
* @public
|
|
@@ -248,8 +247,8 @@ Log.error = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
|
248
247
|
* Name of the component that produced the log entry
|
|
249
248
|
* @param {function} [fnSupportInfo]
|
|
250
249
|
* Callback that returns an additional support object to be logged in support mode.
|
|
251
|
-
* This function is only called if support info mode is turned on
|
|
252
|
-
*
|
|
250
|
+
* This function is only called if support info mode is turned on via
|
|
251
|
+
* the Support Assistant. To avoid negative effects regarding execution times and
|
|
253
252
|
* memory consumption, the returned object should be a simple immutable JSON object with mostly
|
|
254
253
|
* static and stable content.
|
|
255
254
|
* @public
|
|
@@ -271,8 +270,8 @@ Log.warning = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
|
271
270
|
* Name of the component that produced the log entry
|
|
272
271
|
* @param {function} [fnSupportInfo]
|
|
273
272
|
* Callback that returns an additional support object to be logged in support mode.
|
|
274
|
-
* This function is only called if support info mode is turned on
|
|
275
|
-
*
|
|
273
|
+
* This function is only called if support info mode is turned on via
|
|
274
|
+
* the Support Assistant. To avoid negative effects regarding execution times and
|
|
276
275
|
* memory consumption, the returned object should be a simple immutable JSON object with mostly
|
|
277
276
|
* static and stable content.
|
|
278
277
|
* @public
|
|
@@ -294,8 +293,8 @@ Log.info = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
|
294
293
|
* Name of the component that produced the log entry
|
|
295
294
|
* @param {function} [fnSupportInfo]
|
|
296
295
|
* Callback that returns an additional support object to be logged in support mode.
|
|
297
|
-
* This function is only called if support info mode is turned on
|
|
298
|
-
*
|
|
296
|
+
* This function is only called if support info mode is turned on via
|
|
297
|
+
* the Support Assistant. To avoid negative effects regarding execution times and
|
|
299
298
|
* memory consumption, the returned object should be a simple immutable JSON object with mostly
|
|
300
299
|
* static and stable content.
|
|
301
300
|
* @public
|
|
@@ -317,8 +316,8 @@ Log.debug = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
|
317
316
|
* Name of the component that produced the log entry
|
|
318
317
|
* @param {function} [fnSupportInfo]
|
|
319
318
|
* Callback that returns an additional support object to be logged in support mode.
|
|
320
|
-
* This function is only called if support info mode is turned on
|
|
321
|
-
*
|
|
319
|
+
* This function is only called if support info mode is turned on via
|
|
320
|
+
* the Support Assistant. To avoid negative effects regarding execution times and
|
|
322
321
|
* memory consumption, the returned object should be a simple immutable JSON object with mostly
|
|
323
322
|
* static and stable content.
|
|
324
323
|
* @public
|
|
@@ -418,8 +417,8 @@ Log.logSupportInfo = function (bEnabled) {
|
|
|
418
417
|
* @param {string} [sComponent]
|
|
419
418
|
* The log component under which the message should be logged
|
|
420
419
|
* @param {function} [fnSupportInfo] Callback that returns an additional support object to be
|
|
421
|
-
* logged in support mode. This function is only called if support info mode is turned on
|
|
422
|
-
*
|
|
420
|
+
* logged in support mode. This function is only called if support info mode is turned on via
|
|
421
|
+
* the Support Assistant. To avoid negative effects regarding execution times and
|
|
423
422
|
* memory consumption, the returned object should be a simple immutable JSON object with mostly
|
|
424
423
|
* static and stable content.
|
|
425
424
|
* @returns {module:sap/base/Log.Entry}
|
|
@@ -734,17 +733,4 @@ Log.getLogger = function (sComponent, iDefaultLogLevel) {
|
|
|
734
733
|
}
|
|
735
734
|
return new Logger(sComponent);
|
|
736
735
|
};
|
|
737
|
-
|
|
738
|
-
// set LogLevel
|
|
739
|
-
const sLogLevel = BaseConfig.get({
|
|
740
|
-
name: "sapUiLogLevel",
|
|
741
|
-
type: BaseConfig.Type.String,
|
|
742
|
-
defaultValue: undefined,
|
|
743
|
-
external: true
|
|
744
|
-
});
|
|
745
|
-
if (sLogLevel) {
|
|
746
|
-
Log.setLevel(Log.Level[sLogLevel.toUpperCase()] || parseInt(sLogLevel));
|
|
747
|
-
} else if (!globalThis["sap-ui-optimized"]) {
|
|
748
|
-
Log.setLevel(Log.Level.DEBUG);
|
|
749
|
-
}
|
|
750
736
|
export default Log;
|
package/dist/sap/base/assert.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// validation regexes
|
|
2
2
|
/*!
|
|
3
3
|
* OpenUI5
|
|
4
|
-
* (c) Copyright
|
|
4
|
+
* (c) Copyright 2026 SAP SE or an SAP affiliate company.
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var rBasicUrl = /^(?:([^:\/?#]+):)?((?:[\/\\]{2,}((
|
|
8
|
+
var rBasicUrl = /^(?:([^:\/?#]+):)?((?:[\/\\]{2,}(?:(?:[^@\/?#]*@)?(\[[^\]]+\]|[^\/?#:]+)(?::([0-9]+))?)?)?([^?#]*))(?:\?([^#]*))?(?:#(.*))?$/;
|
|
9
9
|
var rCheckPath = /^([a-z0-9-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*$/i;
|
|
10
10
|
var rCheckQuery = /^([a-z0-9-._~!$&'()*+,;=:@\/?]|%[0-9a-f]{2})*$/i;
|
|
11
11
|
var rCheckFragment = rCheckQuery;
|
|
@@ -104,7 +104,8 @@ oURLListValidator.clear = function () {
|
|
|
104
104
|
* @param {string} [protocol] The protocol of the URL, can be falsy to allow all protocols for an entry e.g. "", "http", "mailto"
|
|
105
105
|
* @param {string} [host] The host of the URL, can be falsy to allow all hosts. A wildcard asterisk can be set at the beginning, e.g. "examples.com", "*.example.com"
|
|
106
106
|
* @param {string} [port] The port of the URL, can be falsy to allow all ports, e.g. "", "8080"
|
|
107
|
-
* @param {string} [path] the path of the URL,
|
|
107
|
+
* @param {string} [path] the path of the URL, e.g. "/my-news". Can be falsy to allow all paths. A wildcard asterisk can be set at the end to ensure a path starts with the given string, e.g. "/my-example*".
|
|
108
|
+
* When using wildcards, make sure to only provide normalized URLs to the validate function in order to mitigate the risk of path traversal attacks.
|
|
108
109
|
* @public
|
|
109
110
|
*/
|
|
110
111
|
oURLListValidator.add = function (protocol, host, port, path) {
|
|
@@ -139,13 +140,16 @@ oURLListValidator.entries = function () {
|
|
|
139
140
|
* Validates a URL. Check if it's not a script or other security issue.
|
|
140
141
|
*
|
|
141
142
|
* <b>Note</b>:
|
|
142
|
-
* It is strongly recommended to validate only absolute URLs. There's almost no case
|
|
143
|
+
* It is strongly recommended to validate only absolute, normalized URLs. There's almost no case
|
|
143
144
|
* where checking only the path of a URL would allow to ensure its validity.
|
|
144
|
-
* For compatibility reasons, this API cannot automatically resolve URLs relative to
|
|
145
|
+
* For compatibility reasons, this API does not normalize URLs and cannot automatically resolve URLs relative to
|
|
145
146
|
* <code>document.baseURI</code>, but callers should do so. In that case, and when the
|
|
146
147
|
* allow list is not empty, an entry for the origin of <code>document.baseURI</code>
|
|
147
148
|
* must be added to the allow list.
|
|
148
149
|
*
|
|
150
|
+
* Any measures to mitigate path traversal or similar attack vectors must be taken by the caller, e.g. by using the
|
|
151
|
+
* {@link https://developer.mozilla.org/docs/Web/API/URL URL} API to normalize the URL beforehand.
|
|
152
|
+
*
|
|
149
153
|
* <h3>Details</h3>
|
|
150
154
|
* Splits the given URL into components and checks for allowed characters according to RFC 3986:
|
|
151
155
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @returns {string} padded hex representation of the given character code
|
|
16
16
|
*/ /*!
|
|
17
17
|
* OpenUI5
|
|
18
|
-
* (c) Copyright
|
|
18
|
+
* (c) Copyright 2026 SAP SE or an SAP affiliate company.
|
|
19
19
|
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
20
20
|
*/
|
|
21
21
|
/*
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
// @evo-todo window.performance does not exist on node.js, but there is a module performance-now. Maybe use it
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* Returns a high resolution timestamp in microseconds
|
|
5
|
-
* The timestamp is based on 01/01/1970 00:00:00 (UNIX epoch) as float with microsecond precision
|
|
6
|
-
* with millisecond precision, if high resolution timestamps are not available.
|
|
2
|
+
* Returns a high resolution timestamp in microseconds.
|
|
3
|
+
* The timestamp is based on 01/01/1970 00:00:00 (UNIX epoch) as float with microsecond precision.
|
|
7
4
|
* The fractional part of the timestamp represents fractions of a millisecond.
|
|
8
5
|
* Converting to a <code>Date</code> is possible by using <code>require(["sap/base/util/now"], function(now){new Date(now());}</code>
|
|
9
6
|
*
|
|
@@ -11,18 +8,15 @@
|
|
|
11
8
|
* @since 1.58
|
|
12
9
|
* @public
|
|
13
10
|
* @alias module:sap/base/util/now
|
|
14
|
-
* @returns {float} timestamp in microseconds
|
|
11
|
+
* @returns {float} timestamp in microseconds
|
|
15
12
|
*/ /*!
|
|
16
13
|
* OpenUI5
|
|
17
|
-
* (c) Copyright
|
|
14
|
+
* (c) Copyright 2026 SAP SE or an SAP affiliate company.
|
|
18
15
|
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
19
16
|
*/
|
|
20
17
|
/*global performance */
|
|
21
18
|
|
|
22
|
-
var fnNow =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return iNavigationStart + performance.now();
|
|
26
|
-
};
|
|
27
|
-
}();
|
|
19
|
+
var fnNow = function now() {
|
|
20
|
+
return performance.timeOrigin + performance.now();
|
|
21
|
+
};
|
|
28
22
|
export default fnNow;
|
|
@@ -118,7 +118,11 @@ var cssSchema = (function () {
|
|
|
118
118
|
'inset' ], [ 'invert' ], [ 'justify' ], [ 'local' ], [ 'medium' ], [
|
|
119
119
|
'mix' ], [ 'none' ], [ 'normal' ], [ 'once' ], [ 'repeat' ], [ 'scroll'
|
|
120
120
|
], [ 'separate' ], [ 'small-caps' ], [ 'spell-out' ], [ 'transparent' ],
|
|
121
|
-
[ 'visible' ]
|
|
121
|
+
[ 'visible' ],
|
|
122
|
+
// ##### BEGIN: MODIFIED BY SAP
|
|
123
|
+
[ 'flex', 'inline-flex', 'grid', 'inline-grid', 'flow-root', 'contents' ], [ 'initial', 'revert', 'revert-layer', 'unset' ]
|
|
124
|
+
// ##### END: MODIFIED BY SAP
|
|
125
|
+
];
|
|
122
126
|
return {
|
|
123
127
|
'-moz-border-radius': {
|
|
124
128
|
'cssExtra': c[ 0 ],
|
|
@@ -440,7 +444,9 @@ var cssSchema = (function () {
|
|
|
440
444
|
},
|
|
441
445
|
'display': {
|
|
442
446
|
'cssPropBits': 32,
|
|
443
|
-
|
|
447
|
+
// ##### BEGIN: MODIFIED BY SAP
|
|
448
|
+
'cssLitGroup': [ L[ 2 ], L[ 47 ], L[ 54 ], L[ 64 ], L[ 65 ] ]
|
|
449
|
+
// ##### END: MODIFIED BY SAP
|
|
444
450
|
},
|
|
445
451
|
'elevation': {
|
|
446
452
|
'cssPropBits': 5,
|
|
@@ -707,6 +713,12 @@ var cssSchema = (function () {
|
|
|
707
713
|
'cssPropBits': 0,
|
|
708
714
|
'cssLitGroup': [ L[ 18 ], L[ 47 ], L[ 54 ] ]
|
|
709
715
|
},
|
|
716
|
+
// ##### BEGIN: MODIFIED BY SAP
|
|
717
|
+
'text-decoration-line': {
|
|
718
|
+
'cssPropBits': 0,
|
|
719
|
+
'cssLitGroup': [ L[ 18 ], L[ 47 ], L[ 54 ] ]
|
|
720
|
+
},
|
|
721
|
+
// ##### END: MODIFIED BY SAP
|
|
710
722
|
'text-indent': {
|
|
711
723
|
'cssPropBits': 5,
|
|
712
724
|
'cssLitGroup': [ L[ 47 ] ]
|
|
@@ -2004,7 +2016,7 @@ if (typeof window !== 'undefined') {
|
|
|
2004
2016
|
}
|
|
2005
2017
|
/*!
|
|
2006
2018
|
* OpenUI5
|
|
2007
|
-
* (c) Copyright
|
|
2019
|
+
* (c) Copyright 2026 SAP SE or an SAP affiliate company.
|
|
2008
2020
|
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
2009
2021
|
*/
|
|
2010
2022
|
// Based on coding from the HTML4 Sanitizer by Google Inc.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/webcomponents-base",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.2",
|
|
4
4
|
"description": "UI5 Web Components: webcomponents.base",
|
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@custom-elements-manifest/analyzer": "^0.10.10",
|
|
66
|
-
"@openui5/sap.ui.core": "1.
|
|
66
|
+
"@openui5/sap.ui.core": "1.146.0",
|
|
67
67
|
"@sap-theming/theming-base-content": "11.33.0",
|
|
68
68
|
"@ui5/cypress-internal": "0.1.0",
|
|
69
|
-
"@ui5/webcomponents-tools": "2.20.
|
|
69
|
+
"@ui5/webcomponents-tools": "2.20.2",
|
|
70
70
|
"clean-css": "^5.2.2",
|
|
71
71
|
"cypress": "15.9.0",
|
|
72
72
|
"mocha": "^11.7.2",
|
|
@@ -76,6 +76,14 @@
|
|
|
76
76
|
"typescript": "^5.6.2",
|
|
77
77
|
"vite": "5.4.21"
|
|
78
78
|
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"react": ">=18"
|
|
81
|
+
},
|
|
82
|
+
"peerDependenciesMeta": {
|
|
83
|
+
"react": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
79
87
|
"customElements": "dist/custom-elements.json",
|
|
80
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "3a88b2ca0c00cdacda2c8bf1fb6239f1c816ecc4"
|
|
81
89
|
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React wrapper factory for UI5 Web Components.
|
|
3
|
+
*
|
|
4
|
+
* This lightweight factory creates typed React components that wrap UI5 Web Components.
|
|
5
|
+
* It handles:
|
|
6
|
+
* - Event prop conversion (onXxx → ui5-xxx event listeners)
|
|
7
|
+
* - Ref forwarding
|
|
8
|
+
* - Children handling
|
|
9
|
+
*
|
|
10
|
+
* Note: The function supports react >= 18.
|
|
11
|
+
* Note: This is for documentation samples only - for production React apps,
|
|
12
|
+
* use the official @ui5/webcomponents-react library.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as React from "react";
|
|
16
|
+
import type { ReactNode } from "react";
|
|
17
|
+
import {
|
|
18
|
+
useRef,
|
|
19
|
+
useEffect,
|
|
20
|
+
forwardRef,
|
|
21
|
+
} from "react";
|
|
22
|
+
import type UI5Element from "../UI5Element.js";
|
|
23
|
+
|
|
24
|
+
type EventHandler<E = Event> = (event: E) => void;
|
|
25
|
+
|
|
26
|
+
// Interface for UI5 Web Component classes with _jsxProps support
|
|
27
|
+
interface UI5ComponentClass<T extends UI5Element = UI5Element> {
|
|
28
|
+
new (): T;
|
|
29
|
+
getMetadata(): {
|
|
30
|
+
getTag(): string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Helper to convert event name
|
|
35
|
+
const toEventName = (propName: string): string => {
|
|
36
|
+
return propName
|
|
37
|
+
.slice(2) // Remove "on"
|
|
38
|
+
.replace(/([A-Z])/g, (match: string, letter: string, index: number): string => {
|
|
39
|
+
return index === 0 ? letter.toLowerCase() : `-${letter.toLowerCase()}`;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Helper to create cleanup function for event listener
|
|
44
|
+
const createEventCleanup = (element: UI5Element, eventName: string, handler: EventHandler): (() => void) => {
|
|
45
|
+
element.addEventListener(eventName, handler);
|
|
46
|
+
return () => element.removeEventListener(eventName, handler);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a React component wrapper for a UI5 Web Component.
|
|
51
|
+
* Uses the component's _jsxProps type for full TypeScript support.
|
|
52
|
+
*
|
|
53
|
+
* @param ComponentClass - The UI5 Web Component class (e.g., Button from "@ui5/webcomponents/dist/Button.js")
|
|
54
|
+
* @returns A React component that renders the custom element with proper TypeScript types
|
|
55
|
+
* @since 2.21.0
|
|
56
|
+
* @example
|
|
57
|
+
* import Button from "@ui5/webcomponents/dist/Button.js";
|
|
58
|
+
* const ReactButton = createReactComponent(Button);
|
|
59
|
+
* // ReactButton props are typed based on Button's _jsxProps
|
|
60
|
+
*/
|
|
61
|
+
function createReactComponent<T extends UI5Element>(
|
|
62
|
+
ComponentClass: UI5ComponentClass<T>,
|
|
63
|
+
): React.ForwardRefExoticComponent<
|
|
64
|
+
React.PropsWithoutRef<T["_jsxProps"] & { children?: ReactNode }> & React.RefAttributes<T>
|
|
65
|
+
> {
|
|
66
|
+
const tagName = ComponentClass.getMetadata().getTag();
|
|
67
|
+
|
|
68
|
+
const Component = forwardRef<T, T["_jsxProps"] & { children?: ReactNode }>((props, ref) => {
|
|
69
|
+
const { children, ...restProps } = props;
|
|
70
|
+
const elementRef = useRef<T>(null);
|
|
71
|
+
|
|
72
|
+
// Forward ref
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (ref) {
|
|
75
|
+
if (typeof ref === "function") {
|
|
76
|
+
ref(elementRef.current);
|
|
77
|
+
} else {
|
|
78
|
+
ref.current = elementRef.current;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, [ref]);
|
|
82
|
+
|
|
83
|
+
// Handle event props and boolean props imperatively
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const element = elementRef.current;
|
|
86
|
+
if (!element) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const eventCleanups: Array<() => void> = [];
|
|
91
|
+
|
|
92
|
+
Object.keys(restProps).forEach(propName => {
|
|
93
|
+
const propValue = (restProps as Record<string, unknown>)[propName];
|
|
94
|
+
if (propName.startsWith("on") && typeof propValue === "function") {
|
|
95
|
+
// Convert React event naming (onClick, onSelectionChange) to DOM event naming
|
|
96
|
+
// onClick -> click, onSelectionChange -> selection-change
|
|
97
|
+
const eventName = toEventName(propName);
|
|
98
|
+
const handler = propValue as EventHandler;
|
|
99
|
+
eventCleanups.push(createEventCleanup(element, eventName, handler));
|
|
100
|
+
} else if (typeof propValue === "boolean") {
|
|
101
|
+
// React 18 sets false booleans as empty string attributes on custom elements.
|
|
102
|
+
// Set as property directly to avoid this.
|
|
103
|
+
(element as any)[propName] = propValue;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return () => {
|
|
108
|
+
eventCleanups.forEach(cleanup => cleanup());
|
|
109
|
+
};
|
|
110
|
+
}, [restProps]);
|
|
111
|
+
|
|
112
|
+
// Filter out event handlers and booleans from DOM props
|
|
113
|
+
const domProps: Record<string, unknown> = {};
|
|
114
|
+
Object.keys(restProps).forEach(propName => {
|
|
115
|
+
const propValue = (restProps as Record<string, unknown>)[propName];
|
|
116
|
+
if (propName.startsWith("on") && typeof propValue === "function") { return; }
|
|
117
|
+
if (typeof propValue === "boolean") { return; } // handled in useEffect
|
|
118
|
+
// className → class for React compatibility
|
|
119
|
+
if (propName === "className") {
|
|
120
|
+
// eslint-disable-next-line dot-notation
|
|
121
|
+
domProps["class"] = propValue;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// Convert camelCase to kebab-case for HTML attributes
|
|
125
|
+
const attrName = propName.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
126
|
+
domProps[attrName] = propValue;
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return React.createElement(tagName, { ref: elementRef, ...domProps }, children);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
Component.displayName = tagName
|
|
133
|
+
.split("-")
|
|
134
|
+
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
135
|
+
.join("");
|
|
136
|
+
|
|
137
|
+
return Component;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default createReactComponent;
|