@overlastic/vue 0.4.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.
- package/LICENSE +23 -0
- package/README.md +86 -0
- package/dist/index.cjs +284 -0
- package/dist/index.d.cts +114 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.global.js +17042 -0
- package/dist/index.js +249 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-PRESENT Hairyf<https://github.com/hairyf>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
> overlays only supports Vue3 | Vue2 Composition-api
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
With pnpm:
|
|
8
|
+
```sh
|
|
9
|
+
pnpm add @overlastic/vue
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
With yarn:
|
|
13
|
+
```sh
|
|
14
|
+
yarn add @overlastic/vue
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Global
|
|
18
|
+
|
|
19
|
+
You can register overlays globally, which will inherit the application context for all popups.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
// main.js
|
|
23
|
+
import { createApp } from 'vue'
|
|
24
|
+
import unoverlay from '@overlastic/vue'
|
|
25
|
+
|
|
26
|
+
const app = createApp({})
|
|
27
|
+
app.use(unoverlay)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Step 1: Define Component
|
|
35
|
+
|
|
36
|
+
overlays is suitable for most components. Using usePrograms can provide finer control over the component process.
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<!-- overlay.vue -->
|
|
40
|
+
<script setup>
|
|
41
|
+
import { defineEmits, defineProps } from 'vue'
|
|
42
|
+
import { usePrograms } from '@overlastic/vue'
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
title: String,
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// Get Overlay information from usePrograms
|
|
48
|
+
const { visible, resolve, reject } = usePrograms({
|
|
49
|
+
// Duration of popup layer duration to avoid premature destruction of the component
|
|
50
|
+
duration: 1000,
|
|
51
|
+
})
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<div v-if="visible" @click="resolve(`${title}:confirmed`)">
|
|
56
|
+
{{ title }}
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Step 2: Create Overlay
|
|
62
|
+
|
|
63
|
+
You can use the `defineOverlay` method to convert the component into a modal dialog in Javascript / Typescript, which allows you to call it.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { defineOverlay } from '@overlastic/vue'
|
|
67
|
+
import OverlayComponent from './overlay.vue'
|
|
68
|
+
|
|
69
|
+
// Convert to imperative callback
|
|
70
|
+
const callback = defineOverlay(OverlayComponent)
|
|
71
|
+
// Call the component and get the value of the resolve callback
|
|
72
|
+
const value = await callback({ title: 'callbackOverlay' })
|
|
73
|
+
// value === "callbackOverlay:confirmed"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You can also use `renderOverlay` to directly call the component and skip the `defineOverlay` method.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { renderOverlay } from '@overlastic/vue'
|
|
80
|
+
import OverlayComponent from './overlay.vue'
|
|
81
|
+
|
|
82
|
+
const value = await renderOverlay(OverlayComponent, {
|
|
83
|
+
title: 'usePrograms'
|
|
84
|
+
})
|
|
85
|
+
// value === "usePrograms:confirmed"
|
|
86
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Field: () => Field,
|
|
24
|
+
OverlaysProvider: () => OverlaysProvider,
|
|
25
|
+
Provider: () => Provider,
|
|
26
|
+
default: () => src_default,
|
|
27
|
+
defineOverlay: () => defineOverlay,
|
|
28
|
+
install: () => install,
|
|
29
|
+
renderOverlay: () => renderOverlay,
|
|
30
|
+
useOverlay: () => useOverlay,
|
|
31
|
+
useOverlayHolder: () => useOverlayHolder,
|
|
32
|
+
usePrograms: () => usePrograms
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
|
35
|
+
|
|
36
|
+
// src/internal/index.ts
|
|
37
|
+
var context = {
|
|
38
|
+
appContext: null
|
|
39
|
+
};
|
|
40
|
+
var ScriptsInjectionKey = Symbol("OverlayScripts");
|
|
41
|
+
var InstancesInjectionKey = Symbol("OverlayInstances");
|
|
42
|
+
|
|
43
|
+
// src/composable/usePrograms.ts
|
|
44
|
+
var import_vue_demi = require("vue-demi");
|
|
45
|
+
var import_core = require("@vueuse/core");
|
|
46
|
+
var import_core2 = require("@overlastic/core");
|
|
47
|
+
function usePrograms(options = {}) {
|
|
48
|
+
const { duration = 0, immediate = true, model = "visible", automatic = true } = options;
|
|
49
|
+
const overlay = (0, import_vue_demi.inject)(ScriptsInjectionKey, useDeclarative(model, options));
|
|
50
|
+
const dec = Reflect.get(overlay, "in_dec");
|
|
51
|
+
const { visible, deferred, vanish } = overlay;
|
|
52
|
+
async function destroy() {
|
|
53
|
+
visible.value = false;
|
|
54
|
+
await (0, import_core2.delay)(duration);
|
|
55
|
+
vanish == null ? void 0 : vanish();
|
|
56
|
+
return Promise.resolve();
|
|
57
|
+
}
|
|
58
|
+
if (!dec && automatic)
|
|
59
|
+
deferred == null ? void 0 : deferred.then(destroy).catch(destroy);
|
|
60
|
+
if (!dec && immediate)
|
|
61
|
+
(0, import_vue_demi.onMounted)(() => visible.value = true);
|
|
62
|
+
(0, import_vue_demi.provide)(ScriptsInjectionKey, null);
|
|
63
|
+
return overlay;
|
|
64
|
+
}
|
|
65
|
+
function useDeclarative(model, options = {}) {
|
|
66
|
+
const { reject = "reject", resolve = "resolve" } = options.events || {};
|
|
67
|
+
const instance = (0, import_vue_demi.getCurrentInstance)();
|
|
68
|
+
if (!instance)
|
|
69
|
+
throw new Error("Please use usePrograms in component setup");
|
|
70
|
+
const visible = (0, import_core.useVModel)(instance.props, model, instance.emit, { passive: true });
|
|
71
|
+
const _reject = (value) => {
|
|
72
|
+
instance == null ? void 0 : instance.emit(reject, value);
|
|
73
|
+
visible.value = false;
|
|
74
|
+
};
|
|
75
|
+
const _resolve = (value) => {
|
|
76
|
+
instance == null ? void 0 : instance.emit(resolve, value);
|
|
77
|
+
visible.value = false;
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
reject: _reject,
|
|
81
|
+
resolve: _resolve,
|
|
82
|
+
vanish: import_core2.noop,
|
|
83
|
+
visible,
|
|
84
|
+
in_dec: true
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/composable/useScripts.ts
|
|
89
|
+
var import_vue_demi2 = require("vue-demi");
|
|
90
|
+
function useScripts(options) {
|
|
91
|
+
const { reject: _reject } = options.deferred || {};
|
|
92
|
+
const { vanish: _vanish } = options;
|
|
93
|
+
const visible = (0, import_vue_demi2.ref)(false);
|
|
94
|
+
function vanish() {
|
|
95
|
+
_vanish == null ? void 0 : _vanish();
|
|
96
|
+
_reject == null ? void 0 : _reject();
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
resolve: options.deferred.resolve,
|
|
100
|
+
reject: options.deferred.reject,
|
|
101
|
+
deferred: options.deferred,
|
|
102
|
+
visible,
|
|
103
|
+
vanish
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/composable/useOverlayHolder.ts
|
|
108
|
+
var import_vue_demi3 = require("vue-demi");
|
|
109
|
+
var import_core3 = require("@overlastic/core");
|
|
110
|
+
var import_pascal_case = require("pascal-case");
|
|
111
|
+
function useOverlayHolder(component, options = {}) {
|
|
112
|
+
const { callback, scripts, props, refresh } = useRefreshMetadata();
|
|
113
|
+
const name = (0, import_core3.defineName)(options.id, options.autoIncrement);
|
|
114
|
+
function render() {
|
|
115
|
+
return (0, import_vue_demi3.h)(
|
|
116
|
+
import_vue_demi3.Teleport,
|
|
117
|
+
{ to: options.root || document.body, disabled: options.root === false },
|
|
118
|
+
(0, import_vue_demi3.h)("div", { id: name }, [(0, import_vue_demi3.h)(component, props.value)])
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
const Holder = (0, import_vue_demi3.defineComponent)({
|
|
122
|
+
name: (0, import_pascal_case.pascalCase)(name),
|
|
123
|
+
setup() {
|
|
124
|
+
(0, import_vue_demi3.provide)(ScriptsInjectionKey, scripts);
|
|
125
|
+
return () => refresh.value ? render() : null;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return [Holder, callback];
|
|
129
|
+
}
|
|
130
|
+
function useRefreshMetadata() {
|
|
131
|
+
const visible = (0, import_vue_demi3.ref)(false);
|
|
132
|
+
const refresh = (0, import_vue_demi3.ref)(false);
|
|
133
|
+
const props = (0, import_vue_demi3.ref)();
|
|
134
|
+
const scripts = { vanish, visible };
|
|
135
|
+
function vanish() {
|
|
136
|
+
refresh.value = false;
|
|
137
|
+
props.value = {};
|
|
138
|
+
scripts.reject();
|
|
139
|
+
}
|
|
140
|
+
function callback(_props) {
|
|
141
|
+
scripts.deferred = (0, import_core3.createDeferred)();
|
|
142
|
+
scripts.resolve = scripts.deferred.resolve;
|
|
143
|
+
scripts.reject = scripts.deferred.reject;
|
|
144
|
+
props.value = _props;
|
|
145
|
+
refresh.value = true;
|
|
146
|
+
return scripts.deferred;
|
|
147
|
+
}
|
|
148
|
+
return { callback, scripts, props, refresh };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/composable/useOverlay.ts
|
|
152
|
+
var import_core4 = require("@overlastic/core");
|
|
153
|
+
var import_vue = require("vue");
|
|
154
|
+
var import_pascal_case2 = require("pascal-case");
|
|
155
|
+
var { define } = (0, import_core4.createConstructor)((Instance, props, options) => {
|
|
156
|
+
const { container, id, deferred, render, vanish: _vanish } = options;
|
|
157
|
+
const InstanceWithProvider = (0, import_vue.defineComponent)({
|
|
158
|
+
name: (0, import_pascal_case2.pascalCase)(id),
|
|
159
|
+
setup: () => {
|
|
160
|
+
const scripts = useScripts({ vanish, deferred });
|
|
161
|
+
(0, import_vue.provide)(ScriptsInjectionKey, scripts);
|
|
162
|
+
},
|
|
163
|
+
render: () => (0, import_vue.h)(Instance, props)
|
|
164
|
+
});
|
|
165
|
+
function vanish() {
|
|
166
|
+
_vanish(InstanceWithProvider);
|
|
167
|
+
container.remove();
|
|
168
|
+
}
|
|
169
|
+
render(Instance, props);
|
|
170
|
+
});
|
|
171
|
+
function useOverlay(Instance) {
|
|
172
|
+
const { render, vanish } = (0, import_vue.inject)(InstancesInjectionKey);
|
|
173
|
+
return define(Instance, { render, vanish });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// src/define/constructor.ts
|
|
177
|
+
var import_core5 = require("@overlastic/core");
|
|
178
|
+
var import_pascal_case3 = require("pascal-case");
|
|
179
|
+
var import_vue_demi4 = require("vue-demi");
|
|
180
|
+
|
|
181
|
+
// src/utils/index.ts
|
|
182
|
+
function inheritParent(app, appContext) {
|
|
183
|
+
var _a;
|
|
184
|
+
const parent = (appContext == null ? void 0 : appContext.app) || ((_a = context.appContext) == null ? void 0 : _a.app);
|
|
185
|
+
if (parent) {
|
|
186
|
+
app.config.globalProperties = parent.config.globalProperties;
|
|
187
|
+
Object.assign(app._context, parent._context);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/define/constructor.ts
|
|
192
|
+
var constructor = (0, import_core5.createConstructor)((Instance, props, options) => {
|
|
193
|
+
const { container, id, deferred, appContext } = options;
|
|
194
|
+
function vanish() {
|
|
195
|
+
app.unmount();
|
|
196
|
+
container.remove();
|
|
197
|
+
}
|
|
198
|
+
const InstanceWithProvider = (0, import_vue_demi4.defineComponent)({
|
|
199
|
+
name: (0, import_pascal_case3.pascalCase)(id),
|
|
200
|
+
setup: () => {
|
|
201
|
+
const scripts = useScripts({
|
|
202
|
+
vanish,
|
|
203
|
+
deferred
|
|
204
|
+
});
|
|
205
|
+
(0, import_vue_demi4.provide)(ScriptsInjectionKey, scripts);
|
|
206
|
+
},
|
|
207
|
+
render: () => (0, import_vue_demi4.h)(Instance, props)
|
|
208
|
+
});
|
|
209
|
+
const app = (0, import_vue_demi4.createApp)(InstanceWithProvider);
|
|
210
|
+
inheritParent(app, appContext);
|
|
211
|
+
app.mount(container);
|
|
212
|
+
return vanish;
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// src/define/index.ts
|
|
216
|
+
var defineOverlay = constructor.define;
|
|
217
|
+
var renderOverlay = constructor.render;
|
|
218
|
+
|
|
219
|
+
// src/components/index.ts
|
|
220
|
+
var import_vue_demi5 = require("vue-demi");
|
|
221
|
+
var Provider = (0, import_vue_demi5.defineComponent)({
|
|
222
|
+
setup(_, { slots }) {
|
|
223
|
+
const { appContext } = (0, import_vue_demi5.getCurrentInstance)();
|
|
224
|
+
context.appContext = appContext;
|
|
225
|
+
return () => {
|
|
226
|
+
var _a;
|
|
227
|
+
return (_a = slots.default) == null ? void 0 : _a.call(slots);
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
var Field = (0, import_vue_demi5.defineComponent)({
|
|
232
|
+
name: "Field",
|
|
233
|
+
props: {
|
|
234
|
+
is: {
|
|
235
|
+
type: [String, Number, Object],
|
|
236
|
+
default: ""
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
setup(props) {
|
|
240
|
+
return () => {
|
|
241
|
+
if (typeof props.is === "string" || typeof props.is === "number")
|
|
242
|
+
return props.is;
|
|
243
|
+
return props.is ? (0, import_vue_demi5.h)(props.is) : null;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
var OverlaysProvider = (0, import_vue_demi5.defineComponent)({
|
|
248
|
+
setup(_, { slots }) {
|
|
249
|
+
const instances = (0, import_vue_demi5.ref)([]);
|
|
250
|
+
function render(Instance, props) {
|
|
251
|
+
instances.value.push({ Instance, props });
|
|
252
|
+
}
|
|
253
|
+
function vanish(instance) {
|
|
254
|
+
instances.value = instances.value.filter(({ Instance }) => Instance === instance);
|
|
255
|
+
}
|
|
256
|
+
(0, import_vue_demi5.provide)(InstancesInjectionKey, { render, vanish });
|
|
257
|
+
return () => {
|
|
258
|
+
var _a;
|
|
259
|
+
return (0, import_vue_demi5.h)(import_vue_demi5.Fragment, [
|
|
260
|
+
...instances.value.map(({ Instance, props }, index) => (0, import_vue_demi5.h)(Instance, { ...props, key: index })),
|
|
261
|
+
(_a = slots.default) == null ? void 0 : _a.call(slots)
|
|
262
|
+
]);
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// src/index.ts
|
|
268
|
+
function install(app) {
|
|
269
|
+
context.appContext = app._context;
|
|
270
|
+
}
|
|
271
|
+
var unoverlay = { install };
|
|
272
|
+
var src_default = unoverlay;
|
|
273
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
274
|
+
0 && (module.exports = {
|
|
275
|
+
Field,
|
|
276
|
+
OverlaysProvider,
|
|
277
|
+
Provider,
|
|
278
|
+
defineOverlay,
|
|
279
|
+
install,
|
|
280
|
+
renderOverlay,
|
|
281
|
+
useOverlay,
|
|
282
|
+
useOverlayHolder,
|
|
283
|
+
usePrograms
|
|
284
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as vue_demi from 'vue-demi';
|
|
2
|
+
import { Ref, Component, AppContext, PropType, VNode, App } from 'vue-demi';
|
|
3
|
+
import * as _overlastic_core from '@overlastic/core';
|
|
4
|
+
import { Deferred, ImperativeOverlay, GlobalMountOptions } from '@overlastic/core';
|
|
5
|
+
import * as vue from 'vue';
|
|
6
|
+
import { DefineComponent, Component as Component$1 } from 'vue';
|
|
7
|
+
|
|
8
|
+
interface PromptifyEvents {
|
|
9
|
+
/**
|
|
10
|
+
* reject event name used by the template
|
|
11
|
+
*
|
|
12
|
+
* @default 'reject'
|
|
13
|
+
*/
|
|
14
|
+
reject?: string;
|
|
15
|
+
/**
|
|
16
|
+
* resolve event name used by the template
|
|
17
|
+
*
|
|
18
|
+
* @default 'resolve'
|
|
19
|
+
*/
|
|
20
|
+
resolve?: string;
|
|
21
|
+
}
|
|
22
|
+
interface ProgramsOptions {
|
|
23
|
+
/** animation duration to avoid premature destruction of components */
|
|
24
|
+
duration?: number;
|
|
25
|
+
/** whether to set visible to true immediately */
|
|
26
|
+
immediate?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* v-model fields used by template
|
|
29
|
+
*
|
|
30
|
+
* @default 'visible'
|
|
31
|
+
*/
|
|
32
|
+
model?: string;
|
|
33
|
+
/**
|
|
34
|
+
* template use event name
|
|
35
|
+
*/
|
|
36
|
+
events?: PromptifyEvents;
|
|
37
|
+
/**
|
|
38
|
+
* whether to automatically handle components based on visible and duration
|
|
39
|
+
*
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
automatic?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface ProgramsReturn {
|
|
45
|
+
/** the notification reject, modify visible, and destroy it after the duration ends */
|
|
46
|
+
reject: Function;
|
|
47
|
+
/** the notification resolve, modify visible, and destroy it after the duration ends */
|
|
48
|
+
resolve: Function;
|
|
49
|
+
/** destroy the current instance (immediately) */
|
|
50
|
+
vanish: Function;
|
|
51
|
+
/** visible control popup display and hide */
|
|
52
|
+
visible: Ref<boolean>;
|
|
53
|
+
/** current deferred */
|
|
54
|
+
deferred?: Deferred<any>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 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
|
|
60
|
+
* @function vanish destroy the current instance (immediately)
|
|
61
|
+
* @field visible control overlay display and hide
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
declare function usePrograms(options?: ProgramsOptions): ProgramsReturn;
|
|
65
|
+
|
|
66
|
+
type InjectionHolder<Props, Resolved> = [Component, ImperativeOverlay<Props, Resolved>];
|
|
67
|
+
declare function useOverlayHolder<Props, Resolved = void>(component: Component, options?: Omit<GlobalMountOptions, 'appContext'>): InjectionHolder<Props, Resolved>;
|
|
68
|
+
|
|
69
|
+
interface Options {
|
|
70
|
+
render: (instance: Component$1, props: any) => void;
|
|
71
|
+
vanish: (instance: Component$1) => void;
|
|
72
|
+
}
|
|
73
|
+
declare function useOverlay<Props, Resolved>(Instance: DefineComponent<Props>): _overlastic_core.ImperativeOverlay<Props, Resolved, Options>;
|
|
74
|
+
|
|
75
|
+
interface VMountOptions {
|
|
76
|
+
/** current app context */
|
|
77
|
+
appContext?: AppContext;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare const defineOverlay: <Props, Resolved = void>(instance: vue.Component, options?: _overlastic_core.MountOptions<VMountOptions> | undefined) => _overlastic_core.ImperativeOverlay<Props, Resolved, VMountOptions>;
|
|
81
|
+
declare const renderOverlay: <Props, Resolved = void>(instance: vue.Component, props?: Props | undefined, options?: _overlastic_core.MountOptions<VMountOptions> | undefined) => Promise<Resolved>;
|
|
82
|
+
|
|
83
|
+
declare const Provider: Component;
|
|
84
|
+
declare const Field: vue_demi.DefineComponent<{
|
|
85
|
+
is: {
|
|
86
|
+
type: PropType<string | number | VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
}> | Component>;
|
|
89
|
+
default: string;
|
|
90
|
+
};
|
|
91
|
+
}, () => string | number | VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
92
|
+
[key: string]: any;
|
|
93
|
+
}> | null, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
|
|
94
|
+
is: {
|
|
95
|
+
type: PropType<string | number | VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
}> | Component>;
|
|
98
|
+
default: string;
|
|
99
|
+
};
|
|
100
|
+
}>>, {
|
|
101
|
+
is: string | number | VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
}> | Component;
|
|
104
|
+
}, {}>;
|
|
105
|
+
declare const OverlaysProvider: vue_demi.DefineComponent<{}, () => VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
106
|
+
[key: string]: any;
|
|
107
|
+
}>, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{}>>, {}, {}>;
|
|
108
|
+
|
|
109
|
+
declare function install(app: App): void;
|
|
110
|
+
declare const unoverlay: {
|
|
111
|
+
install: typeof install;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { Field, type InjectionHolder, OverlaysProvider, type ProgramsOptions, type ProgramsReturn, Provider, unoverlay as default, defineOverlay, install, renderOverlay, useOverlay, useOverlayHolder, usePrograms };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as vue_demi from 'vue-demi';
|
|
2
|
+
import { Ref, Component, AppContext, PropType, VNode, App } from 'vue-demi';
|
|
3
|
+
import * as _overlastic_core from '@overlastic/core';
|
|
4
|
+
import { Deferred, ImperativeOverlay, GlobalMountOptions } from '@overlastic/core';
|
|
5
|
+
import * as vue from 'vue';
|
|
6
|
+
import { DefineComponent, Component as Component$1 } from 'vue';
|
|
7
|
+
|
|
8
|
+
interface PromptifyEvents {
|
|
9
|
+
/**
|
|
10
|
+
* reject event name used by the template
|
|
11
|
+
*
|
|
12
|
+
* @default 'reject'
|
|
13
|
+
*/
|
|
14
|
+
reject?: string;
|
|
15
|
+
/**
|
|
16
|
+
* resolve event name used by the template
|
|
17
|
+
*
|
|
18
|
+
* @default 'resolve'
|
|
19
|
+
*/
|
|
20
|
+
resolve?: string;
|
|
21
|
+
}
|
|
22
|
+
interface ProgramsOptions {
|
|
23
|
+
/** animation duration to avoid premature destruction of components */
|
|
24
|
+
duration?: number;
|
|
25
|
+
/** whether to set visible to true immediately */
|
|
26
|
+
immediate?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* v-model fields used by template
|
|
29
|
+
*
|
|
30
|
+
* @default 'visible'
|
|
31
|
+
*/
|
|
32
|
+
model?: string;
|
|
33
|
+
/**
|
|
34
|
+
* template use event name
|
|
35
|
+
*/
|
|
36
|
+
events?: PromptifyEvents;
|
|
37
|
+
/**
|
|
38
|
+
* whether to automatically handle components based on visible and duration
|
|
39
|
+
*
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
automatic?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface ProgramsReturn {
|
|
45
|
+
/** the notification reject, modify visible, and destroy it after the duration ends */
|
|
46
|
+
reject: Function;
|
|
47
|
+
/** the notification resolve, modify visible, and destroy it after the duration ends */
|
|
48
|
+
resolve: Function;
|
|
49
|
+
/** destroy the current instance (immediately) */
|
|
50
|
+
vanish: Function;
|
|
51
|
+
/** visible control popup display and hide */
|
|
52
|
+
visible: Ref<boolean>;
|
|
53
|
+
/** current deferred */
|
|
54
|
+
deferred?: Deferred<any>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 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
|
|
60
|
+
* @function vanish destroy the current instance (immediately)
|
|
61
|
+
* @field visible control overlay display and hide
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
declare function usePrograms(options?: ProgramsOptions): ProgramsReturn;
|
|
65
|
+
|
|
66
|
+
type InjectionHolder<Props, Resolved> = [Component, ImperativeOverlay<Props, Resolved>];
|
|
67
|
+
declare function useOverlayHolder<Props, Resolved = void>(component: Component, options?: Omit<GlobalMountOptions, 'appContext'>): InjectionHolder<Props, Resolved>;
|
|
68
|
+
|
|
69
|
+
interface Options {
|
|
70
|
+
render: (instance: Component$1, props: any) => void;
|
|
71
|
+
vanish: (instance: Component$1) => void;
|
|
72
|
+
}
|
|
73
|
+
declare function useOverlay<Props, Resolved>(Instance: DefineComponent<Props>): _overlastic_core.ImperativeOverlay<Props, Resolved, Options>;
|
|
74
|
+
|
|
75
|
+
interface VMountOptions {
|
|
76
|
+
/** current app context */
|
|
77
|
+
appContext?: AppContext;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare const defineOverlay: <Props, Resolved = void>(instance: vue.Component, options?: _overlastic_core.MountOptions<VMountOptions> | undefined) => _overlastic_core.ImperativeOverlay<Props, Resolved, VMountOptions>;
|
|
81
|
+
declare const renderOverlay: <Props, Resolved = void>(instance: vue.Component, props?: Props | undefined, options?: _overlastic_core.MountOptions<VMountOptions> | undefined) => Promise<Resolved>;
|
|
82
|
+
|
|
83
|
+
declare const Provider: Component;
|
|
84
|
+
declare const Field: vue_demi.DefineComponent<{
|
|
85
|
+
is: {
|
|
86
|
+
type: PropType<string | number | VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
}> | Component>;
|
|
89
|
+
default: string;
|
|
90
|
+
};
|
|
91
|
+
}, () => string | number | VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
92
|
+
[key: string]: any;
|
|
93
|
+
}> | null, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
|
|
94
|
+
is: {
|
|
95
|
+
type: PropType<string | number | VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
}> | Component>;
|
|
98
|
+
default: string;
|
|
99
|
+
};
|
|
100
|
+
}>>, {
|
|
101
|
+
is: string | number | VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
}> | Component;
|
|
104
|
+
}, {}>;
|
|
105
|
+
declare const OverlaysProvider: vue_demi.DefineComponent<{}, () => VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
106
|
+
[key: string]: any;
|
|
107
|
+
}>, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{}>>, {}, {}>;
|
|
108
|
+
|
|
109
|
+
declare function install(app: App): void;
|
|
110
|
+
declare const unoverlay: {
|
|
111
|
+
install: typeof install;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { Field, type InjectionHolder, OverlaysProvider, type ProgramsOptions, type ProgramsReturn, Provider, unoverlay as default, defineOverlay, install, renderOverlay, useOverlay, useOverlayHolder, usePrograms };
|