Closed Jenesius closed 1 year ago
I found next solution but its not work for me: link. Trying found something else.
type SimpleComponent<T> = {
props?: T,
[name: any]: any
}
export default function openModal<P extends SimpleComponent<T>, T>(component: P, props: T, options: PartialModalOptions = {}):Promise<Modal>
But in current solution props is required. Need to fix it.
Changes:
type SimpleComponent<T = {}> = Component & {
props?: T,
}
export default function openModal<P extends SimpleComponent>(component: P, props: P["props"] | UnwrapRef<P["props"]> = {}, options: PartialModalOptions = {}):Promise<Modal>
{
return closeModal()
.then(() => {
if (modalQueue.value.length) throw ModalError.QueueNoEmpty();
})
.then(() => pushModal(component, props, options))
}
Now is working. Continue with fixs and tests
Is not working for default vue component(without typescipt annotation)
TS2322: Type 'number' is not assignable to type 'NumberConstructor'.
11 | let output = null;
12 |
> 13 | const modal = await openModal(ModalButton, {value});
Maybe ExtractPropTypes will helpfull..
I Stopped on providing computed and ref values to modals. I think is main func and should be suported by library
Done! But I think it will work not for everyone. Need check it for big project
After adding ComputedRef/ Ref I see the next problem:
After declaration types the TS provide me props and ComputedValues: value or effect
For setup component
is contuine don't worked.
I will merge current branch today after testing. Also I will update preview GIF and add design pack.
When we provide Component we can get the types for props:
Its will be amazing!