Skip to content

feat(web_core, lit): implement createComponentImplementation and refactor basic catalog components - #2313

Open
josemontespg wants to merge 1 commit into
react-universal-componentsfrom
lit-create-component-implementation
Open

feat(web_core, lit): implement createComponentImplementation and refactor basic catalog components#2313
josemontespg wants to merge 1 commit into
react-universal-componentsfrom
lit-create-component-implementation

Conversation

@josemontespg

@josemontespg josemontespg commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR implements the createComponentImplementation helper function in @a2ui/web_core/v0_9 and re-exports it in @a2ui/lit/v0_9. It also refactors all 18 basic Lit components in renderers/web_core/src/v0_9/basic_catalog/components/ to use this new pattern.

Key Changes

  • @a2ui/web_core/v0_9: Implement createComponentImplementation which pairs a ComponentApi definition, element constructor, and custom element tag name into a WebComponentImplementation.
  • @a2ui/web_core/v0_9 basic catalog components: Refactor AudioPlayer, Button, Card, CheckBox, ChoicePicker, Column, DateTimeInput, Divider, Icon, Image, List, Modal, Row, Slider, Tabs, Text, TextField, and Video to export definitions using createComponentImplementation.
  • @a2ui/lit/v0_9: Re-export createComponentImplementation from root index.
  • Unit Tests: Added test suite in web_core/src/v0_9/catalog/types.test.ts verifying pairing of ComponentApi with tag names.

Testing

  • Unit tests: passed (yarn --cwd renderers/web_core test, yarn --cwd renderers/lit test)
  • Browser tests: passed (Karma headless)
  • Explorer tests: passed (yarn --cwd renderers/lit/a2ui_explorer test:ci)
  • Linters: passed (yarn --cwd renderers/web_core lint, yarn --cwd renderers/lit lint, yarn --cwd renderers/lit/a2ui_explorer lint)

@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 the createComponentImplementation helper function in @a2ui/web_core/v0_9 and refactors all basic catalog components to use it instead of manually defining their implementations. It also updates the Lit renderer to re-export this helper and refactors the corresponding test suite. A review comment points out a potential runtime TypeError in createComponentImplementation if apiOrImpl is null, since typeof null evaluates to 'object' and would crash on the 'tagName' in apiOrImpl check. A defensive guard is suggested to prevent this crash.

Comment thread renderers/web_core/src/v0_9/catalog/types.ts Outdated
@josemontespg
josemontespg marked this pull request as draft August 18, 2026 00:03
Comment thread renderers/lit/src/v0_9/tests/basic-catalog-a2ui-lit-element.test.ts Outdated
Comment thread renderers/lit/src/v0_9/types.ts Outdated
Comment thread renderers/web_core/src/v0_9/catalog/types.ts Outdated
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch 2 times, most recently from b17e8be to 66c96b4 Compare August 18, 2026 00:28
@josemontespg

Copy link
Copy Markdown
Collaborator Author

All comments addressed:

  1. Reverted test changes: Reverted all changes to basic-catalog-a2ui-lit-element.test.ts so it remains completely untouched in this PR.
  2. Types export: Removed createComponentImplementation from renderers/lit/src/v0_9/types.ts, keeping it exported only in index.ts.
  3. Simplified createComponentImplementation: Streamlined the function to a clean 2-argument signature createComponentImplementation(api, element) with no options parameter. The tag name is derived automatically via customElements.getName(element) (with a2ui-${api.name.toLowerCase()} fallback) and registered in customElements.

Comment thread renderers/web_core/src/v0_9/catalog/types.ts Outdated
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 66c96b4 to f8fe3b2 Compare August 18, 2026 00:40
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from f8fe3b2 to 0f465b3 Compare August 18, 2026 18:52
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 0f465b3 to df457f9 Compare August 18, 2026 21:35
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from df457f9 to 0fd7bdc Compare August 19, 2026 03:14
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 0fd7bdc to 3d186dd Compare August 19, 2026 17:15
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch 2 times, most recently from 06e0b06 to d23d825 Compare August 19, 2026 19:17
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from d23d825 to d0e0239 Compare August 19, 2026 19:28
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from f41ddb7 to 4408f8a Compare August 19, 2026 21:00
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 4408f8a to f9917dd Compare August 19, 2026 21:13
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from f9917dd to 940ec8a Compare August 19, 2026 21:59
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 940ec8a to 8c1753f Compare August 19, 2026 22:04
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 8c1753f to e25acad Compare August 20, 2026 17:09
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from e25acad to 87599e4 Compare August 20, 2026 17:58
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 87599e4 to 341e7a0 Compare August 20, 2026 18:18
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch 2 times, most recently from 9af5eb9 to 591a1ae Compare August 20, 2026 19:31
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 591a1ae to 7851410 Compare August 20, 2026 19:35
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 7851410 to 8437fac Compare August 20, 2026 19:39
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 8437fac to ef39574 Compare August 20, 2026 19:53
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from ef39574 to 6b650a8 Compare August 20, 2026 19:58
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 6b650a8 to 55936c1 Compare August 20, 2026 20:17
@josemontespg
josemontespg force-pushed the lit-create-component-implementation branch from 55936c1 to 999c9b8 Compare August 20, 2026 20:26
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