Skip to content

Commit

Permalink
typing openModal
Browse files Browse the repository at this point in the history
  • Loading branch information
kolirt committed Jul 15, 2023
1 parent 5bdf4e0 commit 6e4c9c8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/vue-modal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare type ModalStyle = {

export declare const ModalTarget: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{}>>, {}, {}>;

export declare function openModal(component: Component, props?: {}, options?: OpenModalOptions): Promise<unknown>;
export declare function openModal<T = unknown>(component: Component, props?: {}, options?: OpenModalOptions): Promise<T>;

declare type OpenModalOptions = {
force?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {addModal, state as stateData} from './data'
import {$emit, $off, $on} from './event'

/*, options?: Options*/
export async function openModal(component: Component, props?: {}, options?: OpenModalOptions) {
export async function openModal<T = unknown>(component: Component, props?: {}, options?: OpenModalOptions) {
if (options?.force && stateData.modals.length) {
await closeAllModals(false)
}
Expand All @@ -14,7 +14,7 @@ export async function openModal(component: Component, props?: {}, options?: Open
addModal(component, props/*, options*/)
$emit(Events.Open)

return new Promise((resolve, reject) => {
return new Promise<T>((resolve, reject) => {
function onClosed(data: any) {
if (data.index === index) {
$off(Events.Closed, onClosed)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kolirt/vue-modal",
"version": "0.0.9",
"version": "0.0.10",
"description": "Simple Vue3 modal package",
"author": "kolirt",
"license": "MIT",
Expand Down

0 comments on commit 6e4c9c8

Please sign in to comment.