Skip to content

feat(react): support universal web components in v0.9 renderer - #2283

Draft
josemontespg wants to merge 1 commit into
angular-custom-grid-samplefrom
react-universal-components
Draft

feat(react): support universal web components in v0.9 renderer#2283
josemontespg wants to merge 1 commit into
angular-custom-grid-samplefrom
react-universal-components

Conversation

@josemontespg

@josemontespg josemontespg commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Enables the A2UI React Renderer (@a2ui/react) to optionally render canonical W3C Custom Element Web Components from @a2ui/web_core alongside existing native React components, maintaining 100% backwards compatibility by defaulting to native React components (useUniversalComponents: false).

Key Changes

  1. Multi-Catalog Architecture (@a2ui/react/v0_9):

    • NativeBasicCatalog: Populated with native React component implementations.
    • UniversalBasicCatalog: Populated with universal W3C Custom Elements from @a2ui/web_core.
    • BasicCatalog: Dynamic catalog selecting between native and universal based on the useUniversalComponents option.
    • Default basicCatalog instance preserves native React rendering as the default behavior.
  2. React to Web Component Bridge (toWebComponent):

    • Idempotently converts React components into W3C Custom Elements.
    • Manages React Root lifecycle safely with microtask-deferred unmounting to prevent teardown during DOM re-parenting.
    • Forwards ComponentContext and buildChild to allow custom React components to host and be hosted within universal container elements.
  3. Global React Configuration (A2UIProvider & useA2UI):

    • Introduced <A2UIProvider useUniversalComponents={boolean}> context provider and useA2UI() hook for global renderer configuration.
  4. Surface Host Component Dual-Mode Rendering (A2uiSurface.tsx):

    • ResolvedChild dynamically resolves both ReactComponentImplementation (JSX render function) and WebComponentImplementation (W3C Custom Element tag with context binding).
  5. React Explorer Query Parameter Support (a2ui_explorer):

    • Supports ?useUniversalComponent=true or ?useUniversalComponents=true query parameter to test both modes interactively.

Pre-launch Checklist

  • I read the [Contributors Guide].
  • I read the [Style Guide].
  • My code changes have tests.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for universal W3C Custom Element components alongside native React components, adding the toWebComponent adapter, A2UIProvider context, and a multi-catalog architecture (BasicCatalog, NativeBasicCatalog, UniversalBasicCatalog). The review feedback highlights several critical improvements: adding SSR guards and handling tag name collisions in toWebComponent, optimizing WebComponentNode to prevent ref callback thrashing, and ensuring that overridden components in both NativeBasicCatalog and UniversalBasicCatalog have their names aligned with their override keys to prevent silent rendering failures.

Comment thread renderers/react/src/v0_9/catalog/to_web_component.tsx
Comment thread renderers/react/src/v0_9/A2uiSurface.tsx
Comment thread renderers/react/src/v0_9/catalog/basic/index.ts
Comment thread renderers/react/src/v0_9/catalog/basic/index.ts
@josemontespg
josemontespg force-pushed the react-universal-components branch from 9d58099 to d3bb540 Compare August 14, 2026 22:42
@josemontespg
josemontespg force-pushed the react-universal-components branch 3 times, most recently from 5b38793 to 1b4f5df Compare August 14, 2026 23:13
@josemontespg
josemontespg force-pushed the react-universal-components branch from 1b4f5df to 1298cd8 Compare August 14, 2026 23:24
@josemontespg
josemontespg force-pushed the react-universal-components branch from 1298cd8 to f2cf7a9 Compare August 14, 2026 23:28
@josemontespg
josemontespg force-pushed the react-universal-components branch from f2cf7a9 to fc5931a Compare August 14, 2026 23:37
@josemontespg
josemontespg force-pushed the react-universal-components branch from fc5931a to 686cdb4 Compare August 14, 2026 23:42
@josemontespg
josemontespg force-pushed the react-universal-components branch from 686cdb4 to eae46de Compare August 17, 2026 17:18
Comment thread renderers/angular/a2ui_explorer/src/app/app.spec.ts

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to the previous PR that is adding the keyboard shortcuts

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Rebased PR #2283 onto PR #2282; all Angular explorer sidebar components are in PR #2282.

Comment thread renderers/lit/a2ui_explorer/src/local-gallery.css.ts
Comment thread renderers/lit/a2ui_explorer/src/local-gallery.ts
Comment thread renderers/lit/a2ui_explorer/tests/sidebar-and-navigation.test.ts
@josemontespg
josemontespg force-pushed the react-universal-components branch from eae46de to da74f18 Compare August 17, 2026 19:20
@josemontespg
josemontespg changed the base branch from angular-explorer-collapsible-sidebars to angular-custom-grid-sample August 17, 2026 19:33
@josemontespg
josemontespg force-pushed the react-universal-components branch 2 times, most recently from 5dde6f5 to 5a40ced Compare August 17, 2026 20:31
@josemontespg
josemontespg force-pushed the react-universal-components branch from 5a40ced to dfa3c12 Compare August 17, 2026 20:57
@josemontespg
josemontespg force-pushed the react-universal-components branch from dfa3c12 to db4a5a4 Compare August 17, 2026 20:57
@josemontespg
josemontespg force-pushed the react-universal-components branch from db4a5a4 to dbffd3d Compare August 17, 2026 21:27
@josemontespg
josemontespg changed the base branch from angular-custom-grid-sample to custom-components August 17, 2026 22:49
@josemontespg
josemontespg changed the base branch from custom-components to angular-custom-grid-sample August 17, 2026 22:52
@josemontespg
josemontespg force-pushed the react-universal-components branch from dbffd3d to 89d5ccb Compare August 18, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant