(klass: T)
| 27 | * const ReactButton = createReactComponent(Button); |
| 28 | */ |
| 29 | export default function createReactComponent<T extends typeof UI5Element>(klass: T) { |
| 30 | const tag = klass.getMetadata().getTag(); |
| 31 | |
| 32 | return function Component(props: InstanceType<T>["_jsxProps"]) { |
| 33 | const patchedProps: Record<string, unknown> = {}; |
| 34 | |
| 35 | Object.entries(props as Record<string, unknown>).forEach(([key, value]) => { |
| 36 | if (key.startsWith("on") && typeof value === "function") { |
| 37 | // React 19 wraps DOM events (change, click, input, etc.) in SyntheticEvent, |
| 38 | // hiding CustomEvent.detail under nativeEvent.detail. |
| 39 | // Patch all event handlers to restore detail from nativeEvent. |
| 40 | const originalHandler = value; |
| 41 | patchedProps[key] = (e: Event) => { |
| 42 | const nativeDetail = (e as unknown as { nativeEvent?: { detail: unknown } }).nativeEvent?.detail; |
| 43 | if (nativeDetail !== undefined) { |
| 44 | (e as unknown as { detail: unknown }).detail = nativeDetail; |
| 45 | } |
| 46 | originalHandler(e); |
| 47 | }; |
| 48 | } else { |
| 49 | patchedProps[key] = value; |
| 50 | } |
| 51 | }); |
| 52 | |
| 53 | return createElement(tag, patchedProps); |
| 54 | }; |
| 55 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…