feat(web_core, lit): implement createComponentImplementation and refactor basic catalog components - #2313
Conversation
There was a problem hiding this comment.
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.
b17e8be to
66c96b4
Compare
|
All comments addressed:
|
| * @param element The CustomElementConstructor implementing the component. | ||
| * @returns A WebComponentImplementation ready to be registered in a Catalog. | ||
| */ | ||
| export function createComponentImplementation<Schema extends z.ZodTypeAny = z.ZodTypeAny>( |
There was a problem hiding this comment.
Extract this function to its own file
There was a problem hiding this comment.
Extracted createComponentImplementation to its own dedicated file: renderers/web_core/src/v0_9/catalog/create_component_implementation.ts with unit tests in create_component_implementation.test.ts.
66c96b4 to
f8fe3b2
Compare
f8fe3b2 to
0f465b3
Compare
…ctor basic catalog components
0f465b3 to
df457f9
Compare
Description
This PR implements the
createComponentImplementationhelper function in@a2ui/web_core/v0_9and re-exports it in@a2ui/lit/v0_9. It also refactors all 18 basic Lit components inrenderers/web_core/src/v0_9/basic_catalog/components/to use this new pattern.Key Changes
@a2ui/web_core/v0_9: ImplementcreateComponentImplementationwhich pairs aComponentApidefinition, element constructor, and custom element tag name into aWebComponentImplementation.@a2ui/web_core/v0_9basic catalog components: RefactorAudioPlayer,Button,Card,CheckBox,ChoicePicker,Column,DateTimeInput,Divider,Icon,Image,List,Modal,Row,Slider,Tabs,Text,TextField, andVideoto export definitions usingcreateComponentImplementation.@a2ui/lit/v0_9: Re-exportcreateComponentImplementationfrom root index.web_core/src/v0_9/catalog/types.test.tsverifying pairing ofComponentApiwith tag names.Testing
yarn --cwd renderers/web_core test,yarn --cwd renderers/lit test)yarn --cwd renderers/lit/a2ui_explorer test:ci)yarn --cwd renderers/web_core lint,yarn --cwd renderers/lit lint,yarn --cwd renderers/lit/a2ui_explorer lint)