11import { observable } from 'mobx' ;
2- import { HTMLProps } from 'web-utility ' ;
2+ import { JsxProps } from 'dom-renderer ' ;
33
44import { ClassComponent , WebCell , component } from './WebCell' ;
55import {
6+ FC ,
67 FunctionComponent ,
8+ PropsWithChildren ,
79 WebCellComponent ,
810 observer ,
911 reaction
1012} from './decorator' ;
1113
1214export type ComponentTag = string | WebCellComponent ;
1315
14- export type WebCellProps < T extends HTMLElement = HTMLElement > = HTMLProps < T > ;
16+ export type WebCellProps < T extends HTMLElement = HTMLElement > = JsxProps < T > ;
1517
1618export interface AsyncBoxProps extends WebCellProps {
1719 loader : ( ) => Promise < ComponentTag > ;
@@ -31,7 +33,7 @@ export class AsyncBox extends HTMLElement {
3133 accessor loader : AsyncBoxProps [ 'loader' ] ;
3234
3335 @observable
34- accessor component : ComponentTag ;
36+ accessor component : FC < PropsWithChildren > ;
3537
3638 @observable
3739 accessor delegatedProps : AsyncBoxProps [ 'delegatedProps' ] ;
@@ -43,8 +45,12 @@ export class AsyncBox extends HTMLElement {
4345 @reaction ( ( element : AsyncBox ) => element . loader )
4446 protected async load ( ) {
4547 this . component = undefined ;
46- this . component = await this . loader ( ) ;
4748
49+ const Tag = await this . loader ( ) ;
50+
51+ this . component = ( { children, ...props } ) => (
52+ < Tag { ...props } > { children } </ Tag >
53+ ) ;
4854 this . emit ( 'load' , this . component ) ;
4955 }
5056
0 commit comments