@overlastic/vue 0.8.1 → 0.8.3

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.
package/dist/index.d.ts CHANGED
@@ -1,25 +1,52 @@
1
1
  import * as vue_demi from 'vue-demi';
2
2
  import { Ref, AppContext, App } from 'vue-demi';
3
- import * as _overlastic_core from '@overlastic/core';
4
- import { Deferred, ImperativeOverlay, GlobalMountOptions, MountOptions } from '@overlastic/core';
5
3
  import * as vue from 'vue';
6
- import { Component, PropType, VNode } from 'vue';
4
+ import { PropType, VNode, Component, VNodeProps } from 'vue';
5
+ import { Deferred, MountOptions, ImperativeOverlay } from '@overlastic/core';
6
+
7
+ declare const Field: vue.DefineComponent<{
8
+ is: {
9
+ type: PropType<string | number | VNode | Component>;
10
+ default: string;
11
+ };
12
+ }, () => string | number | VNode<vue.RendererNode, vue.RendererElement, {
13
+ [key: string]: any;
14
+ }> | null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
15
+ is: {
16
+ type: PropType<string | number | VNode | Component>;
17
+ default: string;
18
+ };
19
+ }>>, {
20
+ is: string | number | VNode<vue.RendererNode, vue.RendererElement, {
21
+ [key: string]: any;
22
+ }> | Component;
23
+ }, {}>;
24
+
25
+ declare const OverlaysProvider: vue_demi.DefineComponent<{}, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
26
+ [key: string]: any;
27
+ }>, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{}>>, {}, {}>;
7
28
 
8
29
  interface PromptifyEvents {
9
30
  /**
10
- * reject event name used by the template
31
+ * cancel event name used by the template
32
+ *
33
+ * @default 'cancel'
34
+ */
35
+ cancel?: string;
36
+ /**
37
+ * confirm event name used by the template
11
38
  *
12
- * @default 'reject'
39
+ * @default 'confirm'
13
40
  */
14
- reject?: string;
41
+ confirm?: string;
15
42
  /**
16
- * resolve event name used by the template
43
+ * confirm event name used by the template
17
44
  *
18
- * @default 'resolve'
45
+ * @default 'close'
19
46
  */
20
- resolve?: string;
47
+ close?: string;
21
48
  }
22
- interface ExtendOverlayOptions {
49
+ interface UseDisclosureOptions {
23
50
  /** animation duration to avoid premature destruction of components */
24
51
  duration?: number;
25
52
  /** whether to set visible to true immediately */
@@ -41,11 +68,13 @@ interface ExtendOverlayOptions {
41
68
  */
42
69
  automatic?: boolean;
43
70
  }
44
- interface ExtendOverlayReturn {
45
- /** the notification reject, modify visible, and destroy it after the duration ends */
46
- reject: (reason?: any) => void;
47
- /** the notification resolve, modify visible, and destroy it after the duration ends */
48
- resolve: (value?: any) => void;
71
+ interface UseDisclosureReturn {
72
+ /** the notification cancel, modify visible, and destroy it after the duration ends */
73
+ cancel: (reason?: any) => void;
74
+ /** the notification confirm, modify visible, and destroy it after the duration ends */
75
+ confirm: (value?: any) => void;
76
+ /** the notification confirm, modify visible, and destroy it after the duration ends */
77
+ close: () => void;
49
78
  /** destroy the current instance (immediately) */
50
79
  vanish: () => void;
51
80
  /** visible control popup display and hide */
@@ -55,61 +84,39 @@ interface ExtendOverlayReturn {
55
84
  }
56
85
  /**
57
86
  * get overlay layer meta information
58
- * @function reject the notification reject, modify visible, and destroy it after the duration ends
59
- * @function resolve the notification resolve, modify visible, and destroy it after the duration ends
87
+ * @function cancel the notification cancel, modify visible, and destroy it after the duration ends
88
+ * @function confirm the notification confirm, modify visible, and destroy it after the duration ends
60
89
  * @function vanish destroy the current instance (immediately)
61
90
  * @field visible control overlay display and hide
62
91
  */
63
- declare function useExtendOverlay(options?: ExtendOverlayOptions): ExtendOverlayReturn;
92
+ declare function useDisclosure(options?: UseDisclosureOptions): UseDisclosureReturn;
64
93
 
65
94
  type AbstractFn = abstract new (...args: any) => any;
66
95
 
67
- type InjectionHolder<Component extends AbstractFn, Resolved> = [Component, ImperativeOverlay<InstanceType<Component>['$props'], Resolved>];
68
- declare function useOverlayHolder<Component extends AbstractFn, Resolved = any>(component: Component, options?: Omit<GlobalMountOptions, 'appContext'>): InjectionHolder<Component, Resolved>;
69
-
70
- interface Options {
71
- render: (instance: Component, props: any) => void;
72
- vanish: (instance: Component) => void;
73
- }
74
- declare function useOverlayInject<Component extends AbstractFn, Resolved>(Instance: Component): _overlastic_core.ImperativeOverlay<InstanceType<Component>["$props"], Resolved, Options>;
96
+ type KnownKeys<T> = {
97
+ [K in keyof T]: T[K] extends unknown ? (unknown extends T[K] ? never : K) : never;
98
+ }[keyof T];
99
+ type PickKnown<T> = Pick<T, KnownKeys<T>>;
100
+ type ExtractEvent<T extends AbstractFn> = Parameters<Required<InstanceType<T>['$props']>['onConfirm']>[0];
101
+ type ExtractProps<T extends AbstractFn> = PickKnown<Omit<InstanceType<T>['$props'], keyof VNodeProps | `on${string}` | 'visible'>>;
102
+ declare function useOverlay<Comp extends AbstractFn, Resolved = ExtractEvent<Comp>>(Instance: Comp, options?: MountOptions<{
103
+ type?: 'inject';
104
+ }>): ImperativeOverlay<ExtractProps<Comp>, Resolved>;
105
+ declare function useOverlay<Comp extends AbstractFn, Resolved = ExtractEvent<Comp>>(Instance: Comp, options?: MountOptions<{
106
+ type?: 'holder';
107
+ }>): [Comp, ImperativeOverlay<ExtractProps<Comp>, Resolved>];
75
108
 
76
109
  interface VMountOptions {
77
110
  /** current app context */
78
111
  appContext?: AppContext;
79
112
  }
80
113
 
81
- declare const defineOverlay: <Component extends AbstractFn, Resolved = any>(instance: Component, options?: MountOptions<VMountOptions> | undefined) => ImperativeOverlay<InstanceType<Component>['$props'], Resolved, VMountOptions>;
82
- declare const renderOverlay: <Component extends AbstractFn, Resolved = any>(instance: Component, props?: InstanceType<Component>['$props'] | undefined, options?: MountOptions<VMountOptions> | undefined) => Promise<Resolved>;
83
-
84
- declare const Field: vue.DefineComponent<{
85
- is: {
86
- type: PropType<string | number | VNode<vue.RendererNode, vue.RendererElement, {
87
- [key: string]: any;
88
- }> | Component>;
89
- default: string;
90
- };
91
- }, () => string | number | VNode<vue.RendererNode, vue.RendererElement, {
92
- [key: string]: any;
93
- }> | null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
94
- is: {
95
- type: PropType<string | number | VNode<vue.RendererNode, vue.RendererElement, {
96
- [key: string]: any;
97
- }> | Component>;
98
- default: string;
99
- };
100
- }>>, {
101
- is: string | number | VNode<vue.RendererNode, vue.RendererElement, {
102
- [key: string]: any;
103
- }> | Component;
104
- }, {}>;
105
-
106
- declare const OverlaysProvider: vue_demi.DefineComponent<{}, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
107
- [key: string]: any;
108
- }>, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{}>>, {}, {}>;
114
+ declare const defineOverlay: <Component extends AbstractFn, Resolved = any>(instance: Component, options?: MountOptions<VMountOptions> | undefined) => ImperativeOverlay<InstanceType<Component>["$props"], Resolved, VMountOptions>;
115
+ declare const renderOverlay: <Component extends AbstractFn, Resolved = any>(instance: Component, props?: InstanceType<Component>["$props"] | undefined, options?: MountOptions<VMountOptions> | undefined) => Promise<Resolved>;
109
116
 
110
117
  declare function install(app: App): void;
111
118
  declare const unoverlay: {
112
119
  install: typeof install;
113
120
  };
114
121
 
115
- export { type ExtendOverlayOptions, type ExtendOverlayReturn, Field, type InjectionHolder, OverlaysProvider, unoverlay as default, defineOverlay, install, renderOverlay, useExtendOverlay, useOverlayHolder, useOverlayInject };
122
+ export { Field, OverlaysProvider, type UseDisclosureOptions, type UseDisclosureReturn, unoverlay as default, defineOverlay, install, renderOverlay, useDisclosure, useOverlay };