-
Notifications
You must be signed in to change notification settings - Fork 277
refactor(website): rename createComponent to createReactComponent and add React 19 variant #13205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
6598483
docs: add react editor
ilhan007 a43be18
chore: update deps
ilhan007 6022542
chore: update
ilhan007 8745b20
chore: lint
ilhan007 3db9756
Merge branch 'main' into docs-rect-editor
ilhan007 1f6255d
Merge branch 'main' into docs-rect-editor
ilhan007 5c11379
fix(website): fix all React sample files to compile and work correctly
ilhan007 1b6f24f
fix(website): remove createReactComponent from base barrel export
ilhan007 e1730d5
chore: fix lint indentation in base index.ts
ilhan007 d1fe226
fix(website): restore createReactComponent barrel export, fix react r…
ilhan007 e624068
fix(website): apply theme changes to React playground preview
ilhan007 639161e
fix(website): register theme asset loaders for React playground
ilhan007 a26432c
fix(website): add missing component imports to React playground
ilhan007 2b4400d
fix(website): convert remaining raw ui5 tags to React components
ilhan007 fadd27d
fix(website): add DynamicDateRange option imports for React playground
ilhan007 ed5a052
fix(website): define createReactComponent locally in ReactPlayground
ilhan007 3bbef25
fix(website): match React preview font rendering with HTML preview
ilhan007 4e8239b
chore(website): remove generate-react-samples script
ilhan007 a6d33aa
fix(ui5-webcomponents-base): remove createReactComponent from barrel …
ilhan007 ccacce2
fix(ui5-webcomponents-base): fix lint errors in base package
ilhan007 2bde49d
fix(ui5-webcomponents-base): restore createReactComponent in barrel e…
ilhan007 37361b2
fix(ui5-webcomponents-base): move createReactComponent to direct path…
ilhan007 1e9cc06
chore: remove .claude/settings.json from tracking
ilhan007 269e020
fix(website): fix missing events in Monaco types and replace startsSe…
ilhan007 91a9707
fix(website): suppress webpack error overlay and Algolia search in ed…
ilhan007 9aa8fab
docs(website): add React version label to editor tab bar
ilhan007 6536e5b
refactor(ui5-webcomponents-base): rename createReactComponent to crea…
ilhan007 695a175
feat(website): add copy button for React code samples
ilhan007 d27ef1e
Merge branch 'main' into docs-rect-editor
ilhan007 85e5e28
fix(website): type event currentTarget with component props in Monaco
ilhan007 8b3a334
chore(website): remove sap-icon:// prefix from React samples
ilhan007 0f07e83
feat(website): type event handlers with UI5CustomEvent and add sample…
ilhan007 3ccc76a
fix(website): add curly braces to satisfy lint rules in createComponent
ilhan007 01602eb
fix(website): add class prop support, fix font override, wire up unus…
ilhan007 ed55ce8
fix(website): fix boolean prop and typed event access in React samples
ilhan007 118fea5
Merge branch 'main' into docs-rect-editor
ilhan007 ee94caa
feat(website): add React samples for ShellBar Overflow and MultiCombo…
ilhan007 f405ca8
refactor(website): use declarative open/opener props and fix inherite…
ilhan007 b646acd
Merge branch 'main' into docs-rect-editor
ilhan007 04f4cda
refactor(website): rename createComponent to createReactComponent and…
ilhan007 d406e31
chore: update DP sample
ilhan007 35d6d4b
chore: update
ilhan007 98b66e1
fix(ui5-base): fix lint errors in createReactComponent.ts
ilhan007 67f3b06
Merge branch 'main' into docs-rect-editor
ilhan007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /** | ||
| * React wrapper factory for UI5 Web Components. | ||
| * | ||
| * This lightweight factory creates typed React components that wrap UI5 Web Components. | ||
| * It handles: | ||
| * - Event prop conversion (onXxx → ui5-xxx event listeners) | ||
| * - Ref forwarding | ||
| * - Children handling | ||
| * | ||
| * Note: Supports React >=19. | ||
| * | ||
| * Note: This is for documentation samples only - for production React apps, | ||
| * use the official @ui5/webcomponents-react library. | ||
| */ | ||
|
|
||
| import { createElement } from "react"; | ||
| import type UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js"; | ||
|
|
||
| /** | ||
| * Creates a React component wrapper for a UI5 Web Component. | ||
| * | ||
| * @param ComponentClass - The UI5 Web Component class (e.g., Button from "@ui5/webcomponents/dist/Button.js") | ||
| * @returns A React component that renders the custom element with proper TypeScript types | ||
| * @since 2.21.0 | ||
| * @example | ||
| * import Button from "@ui5/webcomponents/dist/Button.js"; | ||
| * const ReactButton = createReactComponent(Button); | ||
| */ | ||
| export default function createReactComponent<T extends typeof UI5Element>(klass: T) { | ||
| const tag = klass.getMetadata().getTag(); | ||
|
|
||
| return function Component(props: InstanceType<T>["_jsxProps"]) { | ||
| const patchedProps: Record<string, unknown> = {}; | ||
|
|
||
| Object.entries(props as Record<string, unknown>).forEach(([key, value]) => { | ||
| if (key.startsWith("on") && typeof value === "function") { | ||
| // React 19 wraps DOM events (change, click, input, etc.) in SyntheticEvent, | ||
| // hiding CustomEvent.detail under nativeEvent.detail. | ||
| // Patch all event handlers to restore detail from nativeEvent. | ||
| const originalHandler = value; | ||
| patchedProps[key] = (e: Event) => { | ||
| const nativeDetail = (e as unknown as { nativeEvent?: { detail: unknown } }).nativeEvent?.detail; | ||
| if (nativeDetail !== undefined) { | ||
| (e as unknown as { detail: unknown }).detail = nativeDetail; | ||
| } | ||
| originalHandler(e); | ||
| }; | ||
| } else { | ||
| patchedProps[key] = value; | ||
| } | ||
| }); | ||
|
|
||
| return createElement(tag, patchedProps); | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/website/docs/_samples/ai/TextArea/Extended/sample.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
packages/website/docs/_samples/compat/Table/ActiveRows/sample.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
packages/website/docs/_samples/compat/Table/Basic/sample.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
packages/website/docs/_samples/compat/Table/GrowingOnButtonPress/sample.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
packages/website/docs/_samples/compat/Table/GrowingOnScroll/sample.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
packages/website/docs/_samples/compat/Table/MultipleSelection/sample.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when playing around, I found that if you attach the event with lower case like
onchange, react will attach it to the dom element directly and the detail will be directly on the event object. This is only necessary for events that match native events, instead of all events like here, because events that don't match native events are also directly attached to the dom and have the detail directly.