feat(react): extend native props
I've noticed that all the custom web-components are extending HTMLElement, so we should treat them as well as HTMLElement when passing props(native events, attributes and more...), NOT just limited incomponentBaseInterface.
So this PR did two things:
- Make
componentBaseInterfaceextendHTMLElementprops. - An useful typescript utility type
ReactifyPropsthat transforms web-component props to the corresponding react props. (so we don't need towrite/change/addin two places)
And, with an example usage in the Dialog component.
thank you for suggestion,the web-components custom event in react is alse as a prop, how to deal with this situation
We will refer to your suggestion, thank you
thank you for suggestion,the web-components custom event in react is alse as a prop, how to deal with this situation
It's already handled by 'on${Capitalize<K>}' in ReactifyProps type, which transforms event names like click / confirm to onClick / onConfirm.
And those custom events defined in web-components will have higher priority if it's overlapping native events.
thank you for suggestion,the web-components custom event in react is alse as a prop, how to deal with this situation
It's already handled by
'on${Capitalize<K>}'inReactifyPropstype, which transforms event names likeclick/confirmtoonClick/onConfirm. And those custom events defined in web-components will have higher priority if it's overlapping native events.
such as in picker, custom event close is not a key of picker。
but you suggestion is also usefull, we well refactor type code with extends React.DetailedHTMLProps< React.HTMLAttributes<HTMLElement>, HTMLElement >
Okay, I'am getting your idea now.
I thought that events / state(prop) types are already defined in the quark web-component module like <Dialog>, but it's not.
As a suggestion, in my opinion a idea type structure would be:
- Define
stateandeventtype in web-component. - Frameworks specific type derives from them. ( React、Vue、Angular...)
I've made a simplified show case online.
As a suggestion, in my opinion a idea type structure would be:
- Define
stateandeventtype in web-component.- Frameworks specific type derives from them. ( React、Vue、Angular...)
we will reference your suggestion, thank you