@signal24/vue-foundation 4.3.6 → 4.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Writable } from 'type-fest';
|
|
2
2
|
import { type AllowedComponentProps, type ComponentInternalInstance, type ComponentPublicInstance, type ComputedOptions, type MethodOptions, type Raw, type VNode, type VNodeProps } from 'vue';
|
|
3
|
-
interface ModalInjection<C extends
|
|
3
|
+
interface ModalInjection<C extends ModalComponent> {
|
|
4
4
|
id: string;
|
|
5
|
-
component:
|
|
6
|
-
props:
|
|
5
|
+
component: ModalComponentUnwrapped<C>;
|
|
6
|
+
props: ModalComponentProps<C>;
|
|
7
7
|
vnode: VNode;
|
|
8
8
|
}
|
|
9
9
|
export declare const ModalContainer: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
@@ -15,19 +15,30 @@ export type Vue__ComponentPublicInstanceConstructor<T extends ComponentPublicIns
|
|
|
15
15
|
__isSuspense?: never;
|
|
16
16
|
new (...args: any[]): T;
|
|
17
17
|
};
|
|
18
|
-
export type
|
|
19
|
-
export type
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
export type ObjectComponentConfig<T extends Vue__ComponentPublicInstanceConstructor> = T extends Vue__ComponentPublicInstanceConstructor<infer P> ? P : never;
|
|
19
|
+
export type ObjectComponentProps<T extends Vue__ComponentPublicInstanceConstructor> = Writable<Omit<ObjectComponentConfig<T>['$props'], keyof VNodeProps | keyof AllowedComponentProps>>;
|
|
20
|
+
type ObjectOrDefault<T> = T extends object ? T : PropsWithCallback<{}>;
|
|
21
|
+
export type ModalComponent = Vue__ComponentPublicInstanceConstructor | ((props: any) => any);
|
|
22
|
+
export type ModalComponentConfig<T> = T extends Vue__ComponentPublicInstanceConstructor ? {
|
|
23
|
+
props: ObjectComponentProps<T>;
|
|
24
|
+
component: Raw<T>;
|
|
25
|
+
} : T extends (props: infer P) => any ? {
|
|
26
|
+
props: Omit<ObjectOrDefault<P>, keyof VNodeProps | keyof AllowedComponentProps>;
|
|
27
|
+
component: T;
|
|
28
|
+
} : never;
|
|
29
|
+
export type ModalComponentUnwrapped<T extends ModalComponent> = ModalComponentConfig<T>['component'];
|
|
30
|
+
export type ModalComponentProps<T extends ModalComponent> = ModalComponentConfig<T>['props'];
|
|
23
31
|
interface PropsWithCallback<T> {
|
|
24
32
|
callback?: (result: T) => void;
|
|
25
33
|
}
|
|
26
|
-
type ComponentReturn<
|
|
27
|
-
export
|
|
34
|
+
type ComponentReturn<M extends ModalComponent> = ModalComponentProps<M> extends PropsWithCallback<infer R> ? R : never;
|
|
35
|
+
export type AnyComponentPublicInstance = {
|
|
36
|
+
$: ComponentInternalInstance;
|
|
37
|
+
};
|
|
38
|
+
export declare function createModalInjection<C extends ModalComponent>(component: C, props: ModalComponentProps<C>): ModalInjection<C>;
|
|
28
39
|
export declare function removeModalInjection(injection: ModalInjection<any>): void;
|
|
29
40
|
export declare function removeModalInjectionByInstance(instance: AnyComponentPublicInstance): void;
|
|
30
41
|
export declare function removeModalInjectionByInternalInstance(instance: ComponentInternalInstance): void;
|
|
31
42
|
export declare function removeModalInjectionByVnode(vnode: VNode): boolean;
|
|
32
|
-
export declare function presentModal<C extends
|
|
43
|
+
export declare function presentModal<C extends ModalComponent, R extends ComponentReturn<C>>(component: C, props: Omit<ModalComponentProps<C>, 'callback'>): Promise<R | undefined>;
|
|
33
44
|
export {};
|
package/package.json
CHANGED
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
type VNodeProps
|
|
16
16
|
} from 'vue';
|
|
17
17
|
|
|
18
|
-
interface ModalInjection<C extends
|
|
18
|
+
interface ModalInjection<C extends ModalComponent> {
|
|
19
19
|
id: string;
|
|
20
|
-
component:
|
|
21
|
-
props:
|
|
20
|
+
component: ModalComponentUnwrapped<C>;
|
|
21
|
+
props: ModalComponentProps<C>;
|
|
22
22
|
vnode: VNode;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -51,21 +51,37 @@ export type Vue__ComponentPublicInstanceConstructor<
|
|
|
51
51
|
new (...args: any[]): T;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export type
|
|
54
|
+
export type ObjectComponentConfig<T extends Vue__ComponentPublicInstanceConstructor> = T extends Vue__ComponentPublicInstanceConstructor<infer P>
|
|
55
55
|
? P
|
|
56
56
|
: never;
|
|
57
|
-
export type
|
|
58
|
-
Omit<
|
|
57
|
+
export type ObjectComponentProps<T extends Vue__ComponentPublicInstanceConstructor> = Writable<
|
|
58
|
+
Omit<ObjectComponentConfig<T>['$props'], keyof VNodeProps | keyof AllowedComponentProps>
|
|
59
59
|
>;
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
type ObjectOrDefault<T> = T extends object ? T : PropsWithCallback<{}>;
|
|
62
|
+
export type ModalComponent = Vue__ComponentPublicInstanceConstructor | ((props: any) => any);
|
|
63
|
+
export type ModalComponentConfig<T> = T extends Vue__ComponentPublicInstanceConstructor
|
|
64
|
+
? {
|
|
65
|
+
props: ObjectComponentProps<T>;
|
|
66
|
+
component: Raw<T>;
|
|
67
|
+
}
|
|
68
|
+
: T extends (props: infer P) => any
|
|
69
|
+
? {
|
|
70
|
+
props: Omit<ObjectOrDefault<P>, keyof VNodeProps | keyof AllowedComponentProps>;
|
|
71
|
+
component: T;
|
|
72
|
+
}
|
|
73
|
+
: never;
|
|
74
|
+
export type ModalComponentUnwrapped<T extends ModalComponent> = ModalComponentConfig<T>['component'];
|
|
75
|
+
export type ModalComponentProps<T extends ModalComponent> = ModalComponentConfig<T>['props'];
|
|
62
76
|
|
|
63
77
|
interface PropsWithCallback<T> {
|
|
64
78
|
callback?: (result: T) => void;
|
|
65
79
|
}
|
|
66
|
-
type ComponentReturn<
|
|
80
|
+
type ComponentReturn<M extends ModalComponent> = ModalComponentProps<M> extends PropsWithCallback<infer R> ? R : never;
|
|
81
|
+
|
|
82
|
+
export type AnyComponentPublicInstance = { $: ComponentInternalInstance };
|
|
67
83
|
|
|
68
|
-
export function createModalInjection<C extends
|
|
84
|
+
export function createModalInjection<C extends ModalComponent>(component: C, props: ModalComponentProps<C>): ModalInjection<C> {
|
|
69
85
|
// create or reconfigure the existing modal target
|
|
70
86
|
// re-injecting every time keeps the modal container at the very end of the DOM
|
|
71
87
|
const targetEl = document.getElementById('vf-modal-target') ?? document.createElement('div');
|
|
@@ -115,9 +131,9 @@ export function removeModalInjectionByVnode(vnode: VNode) {
|
|
|
115
131
|
return false;
|
|
116
132
|
}
|
|
117
133
|
|
|
118
|
-
export async function presentModal<C extends
|
|
134
|
+
export async function presentModal<C extends ModalComponent, R extends ComponentReturn<C>>(
|
|
119
135
|
component: C,
|
|
120
|
-
props: Omit<
|
|
136
|
+
props: Omit<ModalComponentProps<C>, 'callback'>
|
|
121
137
|
): Promise<R | undefined> {
|
|
122
138
|
return new Promise<R>(resolve => {
|
|
123
139
|
let modalInjection: ModalInjection<C> | null = null;
|
|
@@ -125,7 +141,7 @@ export async function presentModal<C extends Vue__ComponentPublicInstanceConstru
|
|
|
125
141
|
removeModalInjection(modalInjection!);
|
|
126
142
|
resolve(result);
|
|
127
143
|
};
|
|
128
|
-
const resolvedProps = { ...props, callback } as
|
|
144
|
+
const resolvedProps = { ...props, callback } as ModalComponentProps<C>;
|
|
129
145
|
modalInjection = createModalInjection(component, resolvedProps);
|
|
130
146
|
});
|
|
131
147
|
}
|