Skip to content

Commit

Permalink
build: export event types in react wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Nov 21, 2023
1 parent 1533a80 commit 562f39c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function generateReactWrappers(): PluginOption {
createDir(targetDir);

const reactTemplate = `/* autogenerated */
import { createComponent } from '@lit/react';
import { createComponent, type EventName } from '@lit/react';
import { ${declaration.name} as ${declaration.name}Element } from '@sbb-esta/lyne-components/${
module.path
}';
Expand All @@ -98,7 +98,14 @@ export const ${declaration.name} = createComponent({
react,${
declaration.events
? `
events: {${declaration.events!.map((e) => `\n 'on${e.name}': '${e.name}',`).join('')}
events: {${declaration
.events!.map(
(e) =>
`\n 'on${e.name.charAt(0).toUpperCase() + e.name.slice(1)}': '${e.name}' as EventName<${
e.type.text
}>,`,
)
.join('')}
},
`
: ''
Expand Down

0 comments on commit 562f39c

Please sign in to comment.