@overlastic/vue 0.4.7 → 0.5.1
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 -23
- package/README.md +29 -86
- package/dist/index.cjs +31 -41
- package/dist/index.d.cts +17 -18
- package/dist/index.d.ts +17 -18
- package/dist/index.global.js +72 -82
- package/dist/index.js +27 -36
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,23 +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
|
-
|
|
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
CHANGED
|
@@ -1,86 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
```
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://overlastic.vercel.app/" target="blank">
|
|
3
|
+
<img src="https://github.com/hairyf/overlastic/raw/master/docs/public/circle.svg" width="120" alt="Nest Logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
A create modal | dialog | popup promise deferred library
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/@overlastic/vue"><img src="https://img.shields.io/npm/v/@overlastic/vue.svg" alt="NPM Version" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/@overlastic/vue"><img src="https://img.shields.io/npm/l/@overlastic/vue.svg" alt="Package License" /></a>
|
|
14
|
+
<a href="https://www.npmjs.com/@overlastic/vue"><img src="https://img.shields.io/npm/dm/@overlastic/vue.svg" alt="NPM Downloads" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
## Description
|
|
18
|
+
|
|
19
|
+
Create messages or dialog overlays using Overlastic in Vue APP.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
$ npm install --save @overlastic/vue
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
[Overview & Tutorial](https://overlastic.vercel.app/en/vue/)
|
package/dist/index.cjs
CHANGED
|
@@ -21,15 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Field: () => Field,
|
|
24
|
-
|
|
25
|
-
Provider: () => Provider,
|
|
24
|
+
OverlayProvider: () => OverlayProvider,
|
|
26
25
|
default: () => src_default,
|
|
27
26
|
defineOverlay: () => defineOverlay,
|
|
28
27
|
install: () => install,
|
|
29
28
|
renderOverlay: () => renderOverlay,
|
|
30
29
|
useOverlay: () => useOverlay,
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
useOverlayDefine: () => useOverlayDefine,
|
|
31
|
+
useOverlayHolder: () => useOverlayHolder
|
|
33
32
|
});
|
|
34
33
|
module.exports = __toCommonJS(src_exports);
|
|
35
34
|
|
|
@@ -40,11 +39,11 @@ var context = {
|
|
|
40
39
|
var ScriptsInjectionKey = Symbol("OverlayScripts");
|
|
41
40
|
var InstancesInjectionKey = Symbol("OverlayInstances");
|
|
42
41
|
|
|
43
|
-
// src/composable/
|
|
42
|
+
// src/composable/define.ts
|
|
44
43
|
var import_vue_demi = require("vue-demi");
|
|
45
44
|
var import_core = require("@vueuse/core");
|
|
46
45
|
var import_core2 = require("@overlastic/core");
|
|
47
|
-
function
|
|
46
|
+
function useOverlayDefine(options = {}) {
|
|
48
47
|
const { duration = 0, immediate = true, model = "visible", automatic = true } = options;
|
|
49
48
|
const overlay = (0, import_vue_demi.inject)(ScriptsInjectionKey, useDeclarative(model, options));
|
|
50
49
|
const dec = Reflect.get(overlay, "in_dec");
|
|
@@ -66,7 +65,7 @@ function useDeclarative(model, options = {}) {
|
|
|
66
65
|
const { reject = "reject", resolve = "resolve" } = options.events || {};
|
|
67
66
|
const instance = (0, import_vue_demi.getCurrentInstance)();
|
|
68
67
|
if (!instance)
|
|
69
|
-
throw new Error("Please use
|
|
68
|
+
throw new Error("Please use useOverlayDefine in component setup");
|
|
70
69
|
const visible = (0, import_core.useVModel)(instance.props, model, instance.emit, { passive: true });
|
|
71
70
|
const _reject = (value) => {
|
|
72
71
|
instance == null ? void 0 : instance.emit(reject, value);
|
|
@@ -85,7 +84,7 @@ function useDeclarative(model, options = {}) {
|
|
|
85
84
|
};
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
// src/composable/
|
|
87
|
+
// src/composable/scripts.ts
|
|
89
88
|
var import_vue_demi2 = require("vue-demi");
|
|
90
89
|
function useScripts(options) {
|
|
91
90
|
const { reject: _reject } = options.deferred || {};
|
|
@@ -104,7 +103,7 @@ function useScripts(options) {
|
|
|
104
103
|
};
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
// src/composable/
|
|
106
|
+
// src/composable/holder.ts
|
|
108
107
|
var import_vue_demi3 = require("vue-demi");
|
|
109
108
|
var import_core3 = require("@overlastic/core");
|
|
110
109
|
var import_pascal_case = require("pascal-case");
|
|
@@ -112,11 +111,7 @@ function useOverlayHolder(component, options = {}) {
|
|
|
112
111
|
const { callback, scripts, props, refresh } = useRefreshMetadata();
|
|
113
112
|
const name = (0, import_core3.defineName)(options.id, options.autoIncrement);
|
|
114
113
|
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
|
-
);
|
|
114
|
+
return (0, import_vue_demi3.h)(import_vue_demi3.Teleport, { to: options.root || document.body, disabled: options.root === false }, (0, import_vue_demi3.h)("div", { id: name }, [(0, import_vue_demi3.h)(component, props.value)]));
|
|
120
115
|
}
|
|
121
116
|
const Holder = (0, import_vue_demi3.defineComponent)({
|
|
122
117
|
name: (0, import_pascal_case.pascalCase)(name),
|
|
@@ -148,12 +143,12 @@ function useRefreshMetadata() {
|
|
|
148
143
|
return { callback, scripts, props, refresh };
|
|
149
144
|
}
|
|
150
145
|
|
|
151
|
-
// src/composable/
|
|
146
|
+
// src/composable/overlay.ts
|
|
152
147
|
var import_core4 = require("@overlastic/core");
|
|
153
148
|
var import_vue = require("vue");
|
|
154
149
|
var import_pascal_case2 = require("pascal-case");
|
|
155
150
|
var { define } = (0, import_core4.createConstructor)((Instance, props, options) => {
|
|
156
|
-
const {
|
|
151
|
+
const { id, deferred, render, vanish: _vanish } = options;
|
|
157
152
|
const InstanceWithProvider = (0, import_vue.defineComponent)({
|
|
158
153
|
name: (0, import_pascal_case2.pascalCase)(id),
|
|
159
154
|
setup: () => {
|
|
@@ -164,10 +159,9 @@ var { define } = (0, import_core4.createConstructor)((Instance, props, options)
|
|
|
164
159
|
});
|
|
165
160
|
function vanish() {
|
|
166
161
|
_vanish(InstanceWithProvider);
|
|
167
|
-
container.remove();
|
|
168
162
|
}
|
|
169
|
-
render(
|
|
170
|
-
});
|
|
163
|
+
render(InstanceWithProvider, props);
|
|
164
|
+
}, { container: false });
|
|
171
165
|
function useOverlay(Instance) {
|
|
172
166
|
const { render, vanish } = (0, import_vue.inject)(InstancesInjectionKey);
|
|
173
167
|
return define(Instance, { render, vanish });
|
|
@@ -216,19 +210,9 @@ var constructor = (0, import_core5.createConstructor)((Instance, props, options)
|
|
|
216
210
|
var defineOverlay = constructor.define;
|
|
217
211
|
var renderOverlay = constructor.render;
|
|
218
212
|
|
|
219
|
-
// src/components/
|
|
220
|
-
var
|
|
221
|
-
var
|
|
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)({
|
|
213
|
+
// src/components/Field.ts
|
|
214
|
+
var import_vue2 = require("vue");
|
|
215
|
+
var Field = (0, import_vue2.defineComponent)({
|
|
232
216
|
name: "Field",
|
|
233
217
|
props: {
|
|
234
218
|
is: {
|
|
@@ -240,24 +224,31 @@ var Field = (0, import_vue_demi5.defineComponent)({
|
|
|
240
224
|
return () => {
|
|
241
225
|
if (typeof props.is === "string" || typeof props.is === "number")
|
|
242
226
|
return props.is;
|
|
243
|
-
return props.is ? (0,
|
|
227
|
+
return props.is ? (0, import_vue2.h)(props.is) : null;
|
|
244
228
|
};
|
|
245
229
|
}
|
|
246
230
|
});
|
|
247
|
-
|
|
231
|
+
|
|
232
|
+
// src/components/OverlayProvider.ts
|
|
233
|
+
var import_vue_demi5 = require("vue-demi");
|
|
234
|
+
var import_vue3 = require("vue");
|
|
235
|
+
var OverlayProvider = (0, import_vue_demi5.defineComponent)({
|
|
248
236
|
setup(_, { slots }) {
|
|
249
237
|
const instances = (0, import_vue_demi5.ref)([]);
|
|
250
238
|
function render(Instance, props) {
|
|
251
|
-
|
|
239
|
+
console.log({ Instance, props });
|
|
240
|
+
instances.value.push({ Instance: (0, import_vue3.markRaw)(Instance), props });
|
|
252
241
|
}
|
|
253
242
|
function vanish(instance) {
|
|
254
|
-
instances.value = instances.value.filter(({ Instance }) => Instance
|
|
243
|
+
instances.value = instances.value.filter(({ Instance }) => Instance !== instance);
|
|
255
244
|
}
|
|
256
245
|
(0, import_vue_demi5.provide)(InstancesInjectionKey, { render, vanish });
|
|
257
246
|
return () => {
|
|
258
247
|
var _a;
|
|
259
248
|
return (0, import_vue_demi5.h)(import_vue_demi5.Fragment, [
|
|
260
|
-
...instances.value.map(
|
|
249
|
+
...instances.value.map(
|
|
250
|
+
({ Instance, props }, index) => (0, import_vue_demi5.h)(Instance, { ...props, key: index })
|
|
251
|
+
),
|
|
261
252
|
(_a = slots.default) == null ? void 0 : _a.call(slots)
|
|
262
253
|
]);
|
|
263
254
|
};
|
|
@@ -273,12 +264,11 @@ var src_default = unoverlay;
|
|
|
273
264
|
// Annotate the CommonJS export names for ESM import in node:
|
|
274
265
|
0 && (module.exports = {
|
|
275
266
|
Field,
|
|
276
|
-
|
|
277
|
-
Provider,
|
|
267
|
+
OverlayProvider,
|
|
278
268
|
defineOverlay,
|
|
279
269
|
install,
|
|
280
270
|
renderOverlay,
|
|
281
271
|
useOverlay,
|
|
282
|
-
|
|
283
|
-
|
|
272
|
+
useOverlayDefine,
|
|
273
|
+
useOverlayHolder
|
|
284
274
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
|
-
import { Ref, Component, AppContext,
|
|
2
|
+
import { Ref, Component, AppContext, App } from 'vue-demi';
|
|
3
3
|
import * as _overlastic_core from '@overlastic/core';
|
|
4
4
|
import { Deferred, ImperativeOverlay, GlobalMountOptions } from '@overlastic/core';
|
|
5
5
|
import * as vue from 'vue';
|
|
6
|
-
import {
|
|
6
|
+
import { Component as Component$1, PropType, VNode } from 'vue';
|
|
7
7
|
|
|
8
8
|
interface PromptifyEvents {
|
|
9
9
|
/**
|
|
@@ -19,7 +19,7 @@ interface PromptifyEvents {
|
|
|
19
19
|
*/
|
|
20
20
|
resolve?: string;
|
|
21
21
|
}
|
|
22
|
-
interface
|
|
22
|
+
interface OverlayDefineOptions {
|
|
23
23
|
/** animation duration to avoid premature destruction of components */
|
|
24
24
|
duration?: number;
|
|
25
25
|
/** whether to set visible to true immediately */
|
|
@@ -59,9 +59,8 @@ interface ProgramsReturn {
|
|
|
59
59
|
* @function resolve the notification resolve, modify visible, and destroy it after the duration ends
|
|
60
60
|
* @function vanish destroy the current instance (immediately)
|
|
61
61
|
* @field visible control overlay display and hide
|
|
62
|
-
* @returns
|
|
63
62
|
*/
|
|
64
|
-
declare function
|
|
63
|
+
declare function useOverlayDefine(options?: OverlayDefineOptions): ProgramsReturn;
|
|
65
64
|
|
|
66
65
|
type InjectionHolder<Props, Resolved> = [Component, ImperativeOverlay<Props, Resolved>];
|
|
67
66
|
declare function useOverlayHolder<Props, Resolved = void>(component: Component, options?: Omit<GlobalMountOptions, 'appContext'>): InjectionHolder<Props, Resolved>;
|
|
@@ -70,7 +69,7 @@ interface Options {
|
|
|
70
69
|
render: (instance: Component$1, props: any) => void;
|
|
71
70
|
vanish: (instance: Component$1) => void;
|
|
72
71
|
}
|
|
73
|
-
declare function useOverlay<Props, Resolved>(Instance:
|
|
72
|
+
declare function useOverlay<Props, Resolved>(Instance: any): _overlastic_core.ImperativeOverlay<Props, Resolved, Options>;
|
|
74
73
|
|
|
75
74
|
interface VMountOptions {
|
|
76
75
|
/** current app context */
|
|
@@ -80,29 +79,29 @@ interface VMountOptions {
|
|
|
80
79
|
declare const defineOverlay: <Props, Resolved = void>(instance: vue.Component, options?: _overlastic_core.MountOptions<VMountOptions> | undefined) => _overlastic_core.ImperativeOverlay<Props, Resolved, VMountOptions>;
|
|
81
80
|
declare const renderOverlay: <Props, Resolved = void>(instance: vue.Component, props?: Props | undefined, options?: _overlastic_core.MountOptions<VMountOptions> | undefined) => Promise<Resolved>;
|
|
82
81
|
|
|
83
|
-
declare const
|
|
84
|
-
declare const Field: vue_demi.DefineComponent<{
|
|
82
|
+
declare const Field: vue.DefineComponent<{
|
|
85
83
|
is: {
|
|
86
|
-
type: PropType<string | number | VNode<
|
|
84
|
+
type: PropType<string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
87
85
|
[key: string]: any;
|
|
88
|
-
}> | Component>;
|
|
86
|
+
}> | Component$1>;
|
|
89
87
|
default: string;
|
|
90
88
|
};
|
|
91
|
-
}, () => string | number | VNode<
|
|
89
|
+
}, () => string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
92
90
|
[key: string]: any;
|
|
93
|
-
}> | null, unknown, {}, {},
|
|
91
|
+
}> | null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
94
92
|
is: {
|
|
95
|
-
type: PropType<string | number | VNode<
|
|
93
|
+
type: PropType<string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
96
94
|
[key: string]: any;
|
|
97
|
-
}> | Component>;
|
|
95
|
+
}> | Component$1>;
|
|
98
96
|
default: string;
|
|
99
97
|
};
|
|
100
98
|
}>>, {
|
|
101
|
-
is: string | number | VNode<
|
|
99
|
+
is: string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
102
100
|
[key: string]: any;
|
|
103
|
-
}> | Component;
|
|
101
|
+
}> | Component$1;
|
|
104
102
|
}, {}>;
|
|
105
|
-
|
|
103
|
+
|
|
104
|
+
declare const OverlayProvider: vue_demi.DefineComponent<{}, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
106
105
|
[key: string]: any;
|
|
107
106
|
}>, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{}>>, {}, {}>;
|
|
108
107
|
|
|
@@ -111,4 +110,4 @@ declare const unoverlay: {
|
|
|
111
110
|
install: typeof install;
|
|
112
111
|
};
|
|
113
112
|
|
|
114
|
-
export { Field, type InjectionHolder,
|
|
113
|
+
export { Field, type InjectionHolder, type OverlayDefineOptions, OverlayProvider, type ProgramsReturn, unoverlay as default, defineOverlay, install, renderOverlay, useOverlay, useOverlayDefine, useOverlayHolder };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
|
-
import { Ref, Component, AppContext,
|
|
2
|
+
import { Ref, Component, AppContext, App } from 'vue-demi';
|
|
3
3
|
import * as _overlastic_core from '@overlastic/core';
|
|
4
4
|
import { Deferred, ImperativeOverlay, GlobalMountOptions } from '@overlastic/core';
|
|
5
5
|
import * as vue from 'vue';
|
|
6
|
-
import {
|
|
6
|
+
import { Component as Component$1, PropType, VNode } from 'vue';
|
|
7
7
|
|
|
8
8
|
interface PromptifyEvents {
|
|
9
9
|
/**
|
|
@@ -19,7 +19,7 @@ interface PromptifyEvents {
|
|
|
19
19
|
*/
|
|
20
20
|
resolve?: string;
|
|
21
21
|
}
|
|
22
|
-
interface
|
|
22
|
+
interface OverlayDefineOptions {
|
|
23
23
|
/** animation duration to avoid premature destruction of components */
|
|
24
24
|
duration?: number;
|
|
25
25
|
/** whether to set visible to true immediately */
|
|
@@ -59,9 +59,8 @@ interface ProgramsReturn {
|
|
|
59
59
|
* @function resolve the notification resolve, modify visible, and destroy it after the duration ends
|
|
60
60
|
* @function vanish destroy the current instance (immediately)
|
|
61
61
|
* @field visible control overlay display and hide
|
|
62
|
-
* @returns
|
|
63
62
|
*/
|
|
64
|
-
declare function
|
|
63
|
+
declare function useOverlayDefine(options?: OverlayDefineOptions): ProgramsReturn;
|
|
65
64
|
|
|
66
65
|
type InjectionHolder<Props, Resolved> = [Component, ImperativeOverlay<Props, Resolved>];
|
|
67
66
|
declare function useOverlayHolder<Props, Resolved = void>(component: Component, options?: Omit<GlobalMountOptions, 'appContext'>): InjectionHolder<Props, Resolved>;
|
|
@@ -70,7 +69,7 @@ interface Options {
|
|
|
70
69
|
render: (instance: Component$1, props: any) => void;
|
|
71
70
|
vanish: (instance: Component$1) => void;
|
|
72
71
|
}
|
|
73
|
-
declare function useOverlay<Props, Resolved>(Instance:
|
|
72
|
+
declare function useOverlay<Props, Resolved>(Instance: any): _overlastic_core.ImperativeOverlay<Props, Resolved, Options>;
|
|
74
73
|
|
|
75
74
|
interface VMountOptions {
|
|
76
75
|
/** current app context */
|
|
@@ -80,29 +79,29 @@ interface VMountOptions {
|
|
|
80
79
|
declare const defineOverlay: <Props, Resolved = void>(instance: vue.Component, options?: _overlastic_core.MountOptions<VMountOptions> | undefined) => _overlastic_core.ImperativeOverlay<Props, Resolved, VMountOptions>;
|
|
81
80
|
declare const renderOverlay: <Props, Resolved = void>(instance: vue.Component, props?: Props | undefined, options?: _overlastic_core.MountOptions<VMountOptions> | undefined) => Promise<Resolved>;
|
|
82
81
|
|
|
83
|
-
declare const
|
|
84
|
-
declare const Field: vue_demi.DefineComponent<{
|
|
82
|
+
declare const Field: vue.DefineComponent<{
|
|
85
83
|
is: {
|
|
86
|
-
type: PropType<string | number | VNode<
|
|
84
|
+
type: PropType<string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
87
85
|
[key: string]: any;
|
|
88
|
-
}> | Component>;
|
|
86
|
+
}> | Component$1>;
|
|
89
87
|
default: string;
|
|
90
88
|
};
|
|
91
|
-
}, () => string | number | VNode<
|
|
89
|
+
}, () => string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
92
90
|
[key: string]: any;
|
|
93
|
-
}> | null, unknown, {}, {},
|
|
91
|
+
}> | null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
94
92
|
is: {
|
|
95
|
-
type: PropType<string | number | VNode<
|
|
93
|
+
type: PropType<string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
96
94
|
[key: string]: any;
|
|
97
|
-
}> | Component>;
|
|
95
|
+
}> | Component$1>;
|
|
98
96
|
default: string;
|
|
99
97
|
};
|
|
100
98
|
}>>, {
|
|
101
|
-
is: string | number | VNode<
|
|
99
|
+
is: string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
102
100
|
[key: string]: any;
|
|
103
|
-
}> | Component;
|
|
101
|
+
}> | Component$1;
|
|
104
102
|
}, {}>;
|
|
105
|
-
|
|
103
|
+
|
|
104
|
+
declare const OverlayProvider: vue_demi.DefineComponent<{}, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
106
105
|
[key: string]: any;
|
|
107
106
|
}>, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{}>>, {}, {}>;
|
|
108
107
|
|
|
@@ -111,4 +110,4 @@ declare const unoverlay: {
|
|
|
111
110
|
install: typeof install;
|
|
112
111
|
};
|
|
113
112
|
|
|
114
|
-
export { Field, type InjectionHolder,
|
|
113
|
+
export { Field, type InjectionHolder, type OverlayDefineOptions, OverlayProvider, type ProgramsReturn, unoverlay as default, defineOverlay, install, renderOverlay, useOverlay, useOverlayDefine, useOverlayHolder };
|
package/dist/index.global.js
CHANGED
|
@@ -7659,7 +7659,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
7659
7659
|
}
|
|
7660
7660
|
function renderComponentRoot(instance) {
|
|
7661
7661
|
const {
|
|
7662
|
-
type:
|
|
7662
|
+
type: Component2,
|
|
7663
7663
|
vnode,
|
|
7664
7664
|
proxy,
|
|
7665
7665
|
withProxy,
|
|
@@ -7697,7 +7697,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
7697
7697
|
);
|
|
7698
7698
|
fallthroughAttrs = attrs;
|
|
7699
7699
|
} else {
|
|
7700
|
-
const render22 =
|
|
7700
|
+
const render22 = Component2;
|
|
7701
7701
|
if (process.env.NODE_ENV !== "production" && attrs === props) {
|
|
7702
7702
|
markAttrsAccessed();
|
|
7703
7703
|
}
|
|
@@ -7718,7 +7718,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
7718
7718
|
/* we know it doesn't need it */
|
|
7719
7719
|
)
|
|
7720
7720
|
);
|
|
7721
|
-
fallthroughAttrs =
|
|
7721
|
+
fallthroughAttrs = Component2.props ? attrs : getFunctionalFallthrough(attrs);
|
|
7722
7722
|
}
|
|
7723
7723
|
} catch (err) {
|
|
7724
7724
|
blockStack.length = 0;
|
|
@@ -9155,25 +9155,25 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
9155
9155
|
function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
|
9156
9156
|
const instance = currentRenderingInstance || currentInstance;
|
|
9157
9157
|
if (instance) {
|
|
9158
|
-
const
|
|
9158
|
+
const Component2 = instance.type;
|
|
9159
9159
|
if (type === COMPONENTS) {
|
|
9160
9160
|
const selfName = getComponentName(
|
|
9161
|
-
|
|
9161
|
+
Component2,
|
|
9162
9162
|
false
|
|
9163
9163
|
/* do not include inferred name to avoid breaking existing code */
|
|
9164
9164
|
);
|
|
9165
9165
|
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
|
|
9166
|
-
return
|
|
9166
|
+
return Component2;
|
|
9167
9167
|
}
|
|
9168
9168
|
}
|
|
9169
9169
|
const res = (
|
|
9170
9170
|
// local registration
|
|
9171
9171
|
// check instance[type] first which is resolved for options API
|
|
9172
|
-
resolve(instance[type] ||
|
|
9172
|
+
resolve(instance[type] || Component2[type], name) || // global registration
|
|
9173
9173
|
resolve(instance.appContext[type], name)
|
|
9174
9174
|
);
|
|
9175
9175
|
if (!res && maybeSelfReference) {
|
|
9176
|
-
return
|
|
9176
|
+
return Component2;
|
|
9177
9177
|
}
|
|
9178
9178
|
if (process.env.NODE_ENV !== "production" && warnMissing && !res) {
|
|
9179
9179
|
const extra = type === COMPONENTS ? `
|
|
@@ -9752,7 +9752,7 @@ If this is a native custom element, make sure to exclude it from component resol
|
|
|
9752
9752
|
}
|
|
9753
9753
|
function callHook(hook, instance, type) {
|
|
9754
9754
|
callWithAsyncErrorHandling(
|
|
9755
|
-
isArray(hook) ? hook.map((
|
|
9755
|
+
isArray(hook) ? hook.map((h8) => h8.bind(instance.proxy)) : hook.bind(instance.proxy),
|
|
9756
9756
|
instance,
|
|
9757
9757
|
type
|
|
9758
9758
|
);
|
|
@@ -13072,24 +13072,24 @@ Component that was made reactive: `,
|
|
|
13072
13072
|
}
|
|
13073
13073
|
function setupStatefulComponent(instance, isSSR) {
|
|
13074
13074
|
var _a;
|
|
13075
|
-
const
|
|
13075
|
+
const Component2 = instance.type;
|
|
13076
13076
|
if (process.env.NODE_ENV !== "production") {
|
|
13077
|
-
if (
|
|
13078
|
-
validateComponentName(
|
|
13077
|
+
if (Component2.name) {
|
|
13078
|
+
validateComponentName(Component2.name, instance.appContext.config);
|
|
13079
13079
|
}
|
|
13080
|
-
if (
|
|
13081
|
-
const names = Object.keys(
|
|
13080
|
+
if (Component2.components) {
|
|
13081
|
+
const names = Object.keys(Component2.components);
|
|
13082
13082
|
for (let i = 0; i < names.length; i++) {
|
|
13083
13083
|
validateComponentName(names[i], instance.appContext.config);
|
|
13084
13084
|
}
|
|
13085
13085
|
}
|
|
13086
|
-
if (
|
|
13087
|
-
const names = Object.keys(
|
|
13086
|
+
if (Component2.directives) {
|
|
13087
|
+
const names = Object.keys(Component2.directives);
|
|
13088
13088
|
for (let i = 0; i < names.length; i++) {
|
|
13089
13089
|
validateDirectiveName(names[i]);
|
|
13090
13090
|
}
|
|
13091
13091
|
}
|
|
13092
|
-
if (
|
|
13092
|
+
if (Component2.compilerOptions && isRuntimeOnly()) {
|
|
13093
13093
|
warn2(
|
|
13094
13094
|
`"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`
|
|
13095
13095
|
);
|
|
@@ -13100,7 +13100,7 @@ Component that was made reactive: `,
|
|
|
13100
13100
|
if (process.env.NODE_ENV !== "production") {
|
|
13101
13101
|
exposePropsOnRenderContext(instance);
|
|
13102
13102
|
}
|
|
13103
|
-
const { setup } =
|
|
13103
|
+
const { setup } = Component2;
|
|
13104
13104
|
if (setup) {
|
|
13105
13105
|
const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
|
|
13106
13106
|
setCurrentInstance(instance);
|
|
@@ -13124,7 +13124,7 @@ Component that was made reactive: `,
|
|
|
13124
13124
|
} else {
|
|
13125
13125
|
instance.asyncDep = setupResult;
|
|
13126
13126
|
if (process.env.NODE_ENV !== "production" && !instance.suspense) {
|
|
13127
|
-
const name = (_a =
|
|
13127
|
+
const name = (_a = Component2.name) != null ? _a : "Anonymous";
|
|
13128
13128
|
warn2(
|
|
13129
13129
|
`Component <${name}>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.`
|
|
13130
13130
|
);
|
|
@@ -13173,16 +13173,16 @@ Component that was made reactive: `,
|
|
|
13173
13173
|
};
|
|
13174
13174
|
}
|
|
13175
13175
|
function finishComponentSetup(instance, isSSR, skipOptions) {
|
|
13176
|
-
const
|
|
13176
|
+
const Component2 = instance.type;
|
|
13177
13177
|
if (!instance.render) {
|
|
13178
|
-
if (!isSSR && compile2 && !
|
|
13179
|
-
const template =
|
|
13178
|
+
if (!isSSR && compile2 && !Component2.render) {
|
|
13179
|
+
const template = Component2.template || resolveMergedOptions(instance).template;
|
|
13180
13180
|
if (template) {
|
|
13181
13181
|
if (process.env.NODE_ENV !== "production") {
|
|
13182
13182
|
startMeasure(instance, `compile`);
|
|
13183
13183
|
}
|
|
13184
13184
|
const { isCustomElement, compilerOptions } = instance.appContext.config;
|
|
13185
|
-
const { delimiters, compilerOptions: componentCompilerOptions } =
|
|
13185
|
+
const { delimiters, compilerOptions: componentCompilerOptions } = Component2;
|
|
13186
13186
|
const finalCompilerOptions = extend(
|
|
13187
13187
|
extend(
|
|
13188
13188
|
{
|
|
@@ -13193,13 +13193,13 @@ Component that was made reactive: `,
|
|
|
13193
13193
|
),
|
|
13194
13194
|
componentCompilerOptions
|
|
13195
13195
|
);
|
|
13196
|
-
|
|
13196
|
+
Component2.render = compile2(template, finalCompilerOptions);
|
|
13197
13197
|
if (process.env.NODE_ENV !== "production") {
|
|
13198
13198
|
endMeasure(instance, `compile`);
|
|
13199
13199
|
}
|
|
13200
13200
|
}
|
|
13201
13201
|
}
|
|
13202
|
-
instance.render =
|
|
13202
|
+
instance.render = Component2.render || NOOP;
|
|
13203
13203
|
if (installWithProxy) {
|
|
13204
13204
|
installWithProxy(instance);
|
|
13205
13205
|
}
|
|
@@ -13211,8 +13211,8 @@ Component that was made reactive: `,
|
|
|
13211
13211
|
resetTracking();
|
|
13212
13212
|
unsetCurrentInstance();
|
|
13213
13213
|
}
|
|
13214
|
-
if (process.env.NODE_ENV !== "production" && !
|
|
13215
|
-
if (!compile2 &&
|
|
13214
|
+
if (process.env.NODE_ENV !== "production" && !Component2.render && instance.render === NOOP && !isSSR) {
|
|
13215
|
+
if (!compile2 && Component2.template) {
|
|
13216
13216
|
warn2(
|
|
13217
13217
|
`Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".`
|
|
13218
13218
|
/* should not happen */
|
|
@@ -13319,13 +13319,13 @@ Component that was made reactive: `,
|
|
|
13319
13319
|
}));
|
|
13320
13320
|
}
|
|
13321
13321
|
}
|
|
13322
|
-
function getComponentName(
|
|
13323
|
-
return isFunction(
|
|
13322
|
+
function getComponentName(Component2, includeInferred = true) {
|
|
13323
|
+
return isFunction(Component2) ? Component2.displayName || Component2.name : Component2.name || includeInferred && Component2.__name;
|
|
13324
13324
|
}
|
|
13325
|
-
function formatComponentName(instance,
|
|
13326
|
-
let name = getComponentName(
|
|
13327
|
-
if (!name &&
|
|
13328
|
-
const match =
|
|
13325
|
+
function formatComponentName(instance, Component2, isRoot = false) {
|
|
13326
|
+
let name = getComponentName(Component2);
|
|
13327
|
+
if (!name && Component2.__file) {
|
|
13328
|
+
const match = Component2.__file.match(/([^/\\]+)\.\w+$/);
|
|
13329
13329
|
if (match) {
|
|
13330
13330
|
name = match[1];
|
|
13331
13331
|
}
|
|
@@ -13333,7 +13333,7 @@ Component that was made reactive: `,
|
|
|
13333
13333
|
if (!name && instance && instance.parent) {
|
|
13334
13334
|
const inferFromRegistry = (registry) => {
|
|
13335
13335
|
for (const key in registry) {
|
|
13336
|
-
if (registry[key] ===
|
|
13336
|
+
if (registry[key] === Component2) {
|
|
13337
13337
|
return key;
|
|
13338
13338
|
}
|
|
13339
13339
|
}
|
|
@@ -16495,15 +16495,14 @@ ${codeFrame}` : message);
|
|
|
16495
16495
|
var src_exports = {};
|
|
16496
16496
|
__export(src_exports, {
|
|
16497
16497
|
Field: () => Field,
|
|
16498
|
-
|
|
16499
|
-
Provider: () => Provider,
|
|
16498
|
+
OverlayProvider: () => OverlayProvider,
|
|
16500
16499
|
default: () => src_default,
|
|
16501
16500
|
defineOverlay: () => defineOverlay,
|
|
16502
16501
|
install: () => install2,
|
|
16503
16502
|
renderOverlay: () => renderOverlay,
|
|
16504
16503
|
useOverlay: () => useOverlay,
|
|
16505
|
-
|
|
16506
|
-
|
|
16504
|
+
useOverlayDefine: () => useOverlayDefine,
|
|
16505
|
+
useOverlayHolder: () => useOverlayHolder
|
|
16507
16506
|
});
|
|
16508
16507
|
|
|
16509
16508
|
// src/internal/index.ts
|
|
@@ -16720,14 +16719,15 @@ ${codeFrame}` : message);
|
|
|
16720
16719
|
}
|
|
16721
16720
|
|
|
16722
16721
|
// ../@core/src/constructor.ts
|
|
16723
|
-
function createConstructor(mount) {
|
|
16724
|
-
|
|
16725
|
-
|
|
16722
|
+
function createConstructor(mount, options = {}) {
|
|
16723
|
+
const { container: globalContainer } = options;
|
|
16724
|
+
function define2(instance, options2) {
|
|
16725
|
+
function executor(props, options3) {
|
|
16726
16726
|
const deferred = createDeferred();
|
|
16727
|
-
const name = defineName(
|
|
16728
|
-
const index = getIndex(
|
|
16729
|
-
const container = defineGlobalElement(name,
|
|
16730
|
-
mount(instance, props, Object.assign(
|
|
16727
|
+
const name = defineName(options3.id, options3.autoIncrement);
|
|
16728
|
+
const index = getIndex(options3.id);
|
|
16729
|
+
const container = globalContainer ? defineGlobalElement(name, options3.root) : document.body;
|
|
16730
|
+
mount(instance, props, Object.assign(options3, {
|
|
16731
16731
|
position: context2.position,
|
|
16732
16732
|
id: name,
|
|
16733
16733
|
deferred,
|
|
@@ -16737,21 +16737,21 @@ ${codeFrame}` : message);
|
|
|
16737
16737
|
return deferred;
|
|
16738
16738
|
}
|
|
16739
16739
|
let inst;
|
|
16740
|
-
function only(props,
|
|
16740
|
+
function only(props, options3) {
|
|
16741
16741
|
if (!inst) {
|
|
16742
|
-
inst = executor(props,
|
|
16742
|
+
inst = executor(props, options3);
|
|
16743
16743
|
inst.finally(() => inst = void 0);
|
|
16744
16744
|
}
|
|
16745
16745
|
return inst;
|
|
16746
16746
|
}
|
|
16747
16747
|
function caller(props, overrides) {
|
|
16748
|
-
const opts = { ...
|
|
16748
|
+
const opts = { ...options2, ...overrides };
|
|
16749
16749
|
return opts.only ? only(props, opts) : executor(props, opts);
|
|
16750
16750
|
}
|
|
16751
16751
|
return caller;
|
|
16752
16752
|
}
|
|
16753
|
-
function render2(instance, props,
|
|
16754
|
-
return define2(instance,
|
|
16753
|
+
function render2(instance, props, options2) {
|
|
16754
|
+
return define2(instance, options2)(props);
|
|
16755
16755
|
}
|
|
16756
16756
|
return { define: define2, render: render2 };
|
|
16757
16757
|
}
|
|
@@ -16764,8 +16764,8 @@ ${codeFrame}` : message);
|
|
|
16764
16764
|
return new Promise((resolve2) => setTimeout(resolve2, milliseconds));
|
|
16765
16765
|
}
|
|
16766
16766
|
|
|
16767
|
-
// src/composable/
|
|
16768
|
-
function
|
|
16767
|
+
// src/composable/define.ts
|
|
16768
|
+
function useOverlayDefine(options = {}) {
|
|
16769
16769
|
const { duration = 0, immediate = true, model = "visible", automatic = true } = options;
|
|
16770
16770
|
const overlay = (0, lib_exports.inject)(ScriptsInjectionKey, useDeclarative(model, options));
|
|
16771
16771
|
const dec = Reflect.get(overlay, "in_dec");
|
|
@@ -16787,7 +16787,7 @@ ${codeFrame}` : message);
|
|
|
16787
16787
|
const { reject = "reject", resolve: resolve2 = "resolve" } = options.events || {};
|
|
16788
16788
|
const instance = (0, lib_exports.getCurrentInstance)();
|
|
16789
16789
|
if (!instance)
|
|
16790
|
-
throw new Error("Please use
|
|
16790
|
+
throw new Error("Please use useOverlayDefine in component setup");
|
|
16791
16791
|
const visible = useVModel(instance.props, model, instance.emit, { passive: true });
|
|
16792
16792
|
const _reject = (value) => {
|
|
16793
16793
|
instance == null ? void 0 : instance.emit(reject, value);
|
|
@@ -16806,7 +16806,7 @@ ${codeFrame}` : message);
|
|
|
16806
16806
|
};
|
|
16807
16807
|
}
|
|
16808
16808
|
|
|
16809
|
-
// src/composable/
|
|
16809
|
+
// src/composable/scripts.ts
|
|
16810
16810
|
function useScripts(options) {
|
|
16811
16811
|
const { reject: _reject } = options.deferred || {};
|
|
16812
16812
|
const { vanish: _vanish } = options;
|
|
@@ -16884,16 +16884,12 @@ ${codeFrame}` : message);
|
|
|
16884
16884
|
return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
|
|
16885
16885
|
}
|
|
16886
16886
|
|
|
16887
|
-
// src/composable/
|
|
16887
|
+
// src/composable/holder.ts
|
|
16888
16888
|
function useOverlayHolder(component, options = {}) {
|
|
16889
16889
|
const { callback, scripts, props, refresh } = useRefreshMetadata();
|
|
16890
16890
|
const name = defineName(options.id, options.autoIncrement);
|
|
16891
16891
|
function render2() {
|
|
16892
|
-
return (0, lib_exports.h)(
|
|
16893
|
-
lib_exports.Teleport,
|
|
16894
|
-
{ to: options.root || document.body, disabled: options.root === false },
|
|
16895
|
-
(0, lib_exports.h)("div", { id: name }, [(0, lib_exports.h)(component, props.value)])
|
|
16896
|
-
);
|
|
16892
|
+
return (0, lib_exports.h)(lib_exports.Teleport, { to: options.root || document.body, disabled: options.root === false }, (0, lib_exports.h)("div", { id: name }, [(0, lib_exports.h)(component, props.value)]));
|
|
16897
16893
|
}
|
|
16898
16894
|
const Holder = (0, lib_exports.defineComponent)({
|
|
16899
16895
|
name: pascalCase(name),
|
|
@@ -16925,9 +16921,9 @@ ${codeFrame}` : message);
|
|
|
16925
16921
|
return { callback, scripts, props, refresh };
|
|
16926
16922
|
}
|
|
16927
16923
|
|
|
16928
|
-
// src/composable/
|
|
16924
|
+
// src/composable/overlay.ts
|
|
16929
16925
|
var { define } = createConstructor((Instance, props, options) => {
|
|
16930
|
-
const {
|
|
16926
|
+
const { id, deferred, render: render2, vanish: _vanish } = options;
|
|
16931
16927
|
const InstanceWithProvider = (0, vue_exports.defineComponent)({
|
|
16932
16928
|
name: pascalCase(id),
|
|
16933
16929
|
setup: () => {
|
|
@@ -16938,10 +16934,9 @@ ${codeFrame}` : message);
|
|
|
16938
16934
|
});
|
|
16939
16935
|
function vanish() {
|
|
16940
16936
|
_vanish(InstanceWithProvider);
|
|
16941
|
-
container.remove();
|
|
16942
16937
|
}
|
|
16943
|
-
render2(
|
|
16944
|
-
});
|
|
16938
|
+
render2(InstanceWithProvider, props);
|
|
16939
|
+
}, { container: false });
|
|
16945
16940
|
function useOverlay(Instance) {
|
|
16946
16941
|
const { render: render2, vanish } = (0, vue_exports.inject)(InstancesInjectionKey);
|
|
16947
16942
|
return define(Instance, { render: render2, vanish });
|
|
@@ -16985,18 +16980,8 @@ ${codeFrame}` : message);
|
|
|
16985
16980
|
var defineOverlay = constructor.define;
|
|
16986
16981
|
var renderOverlay = constructor.render;
|
|
16987
16982
|
|
|
16988
|
-
// src/components/
|
|
16989
|
-
var
|
|
16990
|
-
setup(_, { slots }) {
|
|
16991
|
-
const { appContext } = (0, lib_exports.getCurrentInstance)();
|
|
16992
|
-
context.appContext = appContext;
|
|
16993
|
-
return () => {
|
|
16994
|
-
var _a;
|
|
16995
|
-
return (_a = slots.default) == null ? void 0 : _a.call(slots);
|
|
16996
|
-
};
|
|
16997
|
-
}
|
|
16998
|
-
});
|
|
16999
|
-
var Field = (0, lib_exports.defineComponent)({
|
|
16983
|
+
// src/components/Field.ts
|
|
16984
|
+
var Field = (0, vue_exports.defineComponent)({
|
|
17000
16985
|
name: "Field",
|
|
17001
16986
|
props: {
|
|
17002
16987
|
is: {
|
|
@@ -17008,24 +16993,29 @@ ${codeFrame}` : message);
|
|
|
17008
16993
|
return () => {
|
|
17009
16994
|
if (typeof props.is === "string" || typeof props.is === "number")
|
|
17010
16995
|
return props.is;
|
|
17011
|
-
return props.is ? (0,
|
|
16996
|
+
return props.is ? (0, vue_exports.h)(props.is) : null;
|
|
17012
16997
|
};
|
|
17013
16998
|
}
|
|
17014
16999
|
});
|
|
17015
|
-
|
|
17000
|
+
|
|
17001
|
+
// src/components/OverlayProvider.ts
|
|
17002
|
+
var OverlayProvider = (0, lib_exports.defineComponent)({
|
|
17016
17003
|
setup(_, { slots }) {
|
|
17017
17004
|
const instances = (0, lib_exports.ref)([]);
|
|
17018
17005
|
function render2(Instance, props) {
|
|
17019
|
-
|
|
17006
|
+
console.log({ Instance, props });
|
|
17007
|
+
instances.value.push({ Instance: (0, vue_exports.markRaw)(Instance), props });
|
|
17020
17008
|
}
|
|
17021
17009
|
function vanish(instance) {
|
|
17022
|
-
instances.value = instances.value.filter(({ Instance }) => Instance
|
|
17010
|
+
instances.value = instances.value.filter(({ Instance }) => Instance !== instance);
|
|
17023
17011
|
}
|
|
17024
17012
|
(0, lib_exports.provide)(InstancesInjectionKey, { render: render2, vanish });
|
|
17025
17013
|
return () => {
|
|
17026
17014
|
var _a;
|
|
17027
17015
|
return (0, lib_exports.h)(lib_exports.Fragment, [
|
|
17028
|
-
...instances.value.map(
|
|
17016
|
+
...instances.value.map(
|
|
17017
|
+
({ Instance, props }, index) => (0, lib_exports.h)(Instance, { ...props, key: index })
|
|
17018
|
+
),
|
|
17029
17019
|
(_a = slots.default) == null ? void 0 : _a.call(slots)
|
|
17030
17020
|
]);
|
|
17031
17021
|
};
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,11 @@ var context = {
|
|
|
5
5
|
var ScriptsInjectionKey = Symbol("OverlayScripts");
|
|
6
6
|
var InstancesInjectionKey = Symbol("OverlayInstances");
|
|
7
7
|
|
|
8
|
-
// src/composable/
|
|
8
|
+
// src/composable/define.ts
|
|
9
9
|
import { getCurrentInstance, inject, onMounted, provide } from "vue-demi";
|
|
10
10
|
import { useVModel } from "@vueuse/core";
|
|
11
11
|
import { delay, noop } from "@overlastic/core";
|
|
12
|
-
function
|
|
12
|
+
function useOverlayDefine(options = {}) {
|
|
13
13
|
const { duration = 0, immediate = true, model = "visible", automatic = true } = options;
|
|
14
14
|
const overlay = inject(ScriptsInjectionKey, useDeclarative(model, options));
|
|
15
15
|
const dec = Reflect.get(overlay, "in_dec");
|
|
@@ -31,7 +31,7 @@ function useDeclarative(model, options = {}) {
|
|
|
31
31
|
const { reject = "reject", resolve = "resolve" } = options.events || {};
|
|
32
32
|
const instance = getCurrentInstance();
|
|
33
33
|
if (!instance)
|
|
34
|
-
throw new Error("Please use
|
|
34
|
+
throw new Error("Please use useOverlayDefine in component setup");
|
|
35
35
|
const visible = useVModel(instance.props, model, instance.emit, { passive: true });
|
|
36
36
|
const _reject = (value) => {
|
|
37
37
|
instance == null ? void 0 : instance.emit(reject, value);
|
|
@@ -50,7 +50,7 @@ function useDeclarative(model, options = {}) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// src/composable/
|
|
53
|
+
// src/composable/scripts.ts
|
|
54
54
|
import { ref } from "vue-demi";
|
|
55
55
|
function useScripts(options) {
|
|
56
56
|
const { reject: _reject } = options.deferred || {};
|
|
@@ -69,7 +69,7 @@ function useScripts(options) {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
// src/composable/
|
|
72
|
+
// src/composable/holder.ts
|
|
73
73
|
import { Teleport, defineComponent, h, provide as provide2, ref as ref2 } from "vue-demi";
|
|
74
74
|
import { createDeferred, defineName } from "@overlastic/core";
|
|
75
75
|
import { pascalCase } from "pascal-case";
|
|
@@ -77,11 +77,7 @@ function useOverlayHolder(component, options = {}) {
|
|
|
77
77
|
const { callback, scripts, props, refresh } = useRefreshMetadata();
|
|
78
78
|
const name = defineName(options.id, options.autoIncrement);
|
|
79
79
|
function render() {
|
|
80
|
-
return h(
|
|
81
|
-
Teleport,
|
|
82
|
-
{ to: options.root || document.body, disabled: options.root === false },
|
|
83
|
-
h("div", { id: name }, [h(component, props.value)])
|
|
84
|
-
);
|
|
80
|
+
return h(Teleport, { to: options.root || document.body, disabled: options.root === false }, h("div", { id: name }, [h(component, props.value)]));
|
|
85
81
|
}
|
|
86
82
|
const Holder = defineComponent({
|
|
87
83
|
name: pascalCase(name),
|
|
@@ -113,12 +109,12 @@ function useRefreshMetadata() {
|
|
|
113
109
|
return { callback, scripts, props, refresh };
|
|
114
110
|
}
|
|
115
111
|
|
|
116
|
-
// src/composable/
|
|
112
|
+
// src/composable/overlay.ts
|
|
117
113
|
import { createConstructor } from "@overlastic/core";
|
|
118
114
|
import { defineComponent as defineComponent2, h as h2, inject as inject2, provide as provide3 } from "vue";
|
|
119
115
|
import { pascalCase as pascalCase2 } from "pascal-case";
|
|
120
116
|
var { define } = createConstructor((Instance, props, options) => {
|
|
121
|
-
const {
|
|
117
|
+
const { id, deferred, render, vanish: _vanish } = options;
|
|
122
118
|
const InstanceWithProvider = defineComponent2({
|
|
123
119
|
name: pascalCase2(id),
|
|
124
120
|
setup: () => {
|
|
@@ -129,10 +125,9 @@ var { define } = createConstructor((Instance, props, options) => {
|
|
|
129
125
|
});
|
|
130
126
|
function vanish() {
|
|
131
127
|
_vanish(InstanceWithProvider);
|
|
132
|
-
container.remove();
|
|
133
128
|
}
|
|
134
|
-
render(
|
|
135
|
-
});
|
|
129
|
+
render(InstanceWithProvider, props);
|
|
130
|
+
}, { container: false });
|
|
136
131
|
function useOverlay(Instance) {
|
|
137
132
|
const { render, vanish } = inject2(InstancesInjectionKey);
|
|
138
133
|
return define(Instance, { render, vanish });
|
|
@@ -181,18 +176,8 @@ var constructor = createConstructor2((Instance, props, options) => {
|
|
|
181
176
|
var defineOverlay = constructor.define;
|
|
182
177
|
var renderOverlay = constructor.render;
|
|
183
178
|
|
|
184
|
-
// src/components/
|
|
185
|
-
import {
|
|
186
|
-
var Provider = defineComponent4({
|
|
187
|
-
setup(_, { slots }) {
|
|
188
|
-
const { appContext } = getCurrentInstance2();
|
|
189
|
-
context.appContext = appContext;
|
|
190
|
-
return () => {
|
|
191
|
-
var _a;
|
|
192
|
-
return (_a = slots.default) == null ? void 0 : _a.call(slots);
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
});
|
|
179
|
+
// src/components/Field.ts
|
|
180
|
+
import { defineComponent as defineComponent4, h as h4 } from "vue";
|
|
196
181
|
var Field = defineComponent4({
|
|
197
182
|
name: "Field",
|
|
198
183
|
props: {
|
|
@@ -209,20 +194,27 @@ var Field = defineComponent4({
|
|
|
209
194
|
};
|
|
210
195
|
}
|
|
211
196
|
});
|
|
212
|
-
|
|
197
|
+
|
|
198
|
+
// src/components/OverlayProvider.ts
|
|
199
|
+
import { Fragment, defineComponent as defineComponent5, h as h5, provide as provide5, ref as ref3 } from "vue-demi";
|
|
200
|
+
import { markRaw } from "vue";
|
|
201
|
+
var OverlayProvider = defineComponent5({
|
|
213
202
|
setup(_, { slots }) {
|
|
214
203
|
const instances = ref3([]);
|
|
215
204
|
function render(Instance, props) {
|
|
216
|
-
|
|
205
|
+
console.log({ Instance, props });
|
|
206
|
+
instances.value.push({ Instance: markRaw(Instance), props });
|
|
217
207
|
}
|
|
218
208
|
function vanish(instance) {
|
|
219
|
-
instances.value = instances.value.filter(({ Instance }) => Instance
|
|
209
|
+
instances.value = instances.value.filter(({ Instance }) => Instance !== instance);
|
|
220
210
|
}
|
|
221
211
|
provide5(InstancesInjectionKey, { render, vanish });
|
|
222
212
|
return () => {
|
|
223
213
|
var _a;
|
|
224
|
-
return
|
|
225
|
-
...instances.value.map(
|
|
214
|
+
return h5(Fragment, [
|
|
215
|
+
...instances.value.map(
|
|
216
|
+
({ Instance, props }, index) => h5(Instance, { ...props, key: index })
|
|
217
|
+
),
|
|
226
218
|
(_a = slots.default) == null ? void 0 : _a.call(slots)
|
|
227
219
|
]);
|
|
228
220
|
};
|
|
@@ -237,13 +229,12 @@ var unoverlay = { install };
|
|
|
237
229
|
var src_default = unoverlay;
|
|
238
230
|
export {
|
|
239
231
|
Field,
|
|
240
|
-
|
|
241
|
-
Provider,
|
|
232
|
+
OverlayProvider,
|
|
242
233
|
src_default as default,
|
|
243
234
|
defineOverlay,
|
|
244
235
|
install,
|
|
245
236
|
renderOverlay,
|
|
246
237
|
useOverlay,
|
|
247
|
-
|
|
248
|
-
|
|
238
|
+
useOverlayDefine,
|
|
239
|
+
useOverlayHolder
|
|
249
240
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@overlastic/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/hairyf/overlastic#readme",
|
|
7
7
|
"repository": {
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@vueuse/core": "^10.9.0",
|
|
29
|
-
"pascal-case": "
|
|
29
|
+
"pascal-case": "3.1.2",
|
|
30
30
|
"vue": "^3.3.2",
|
|
31
31
|
"vue-demi": ">=0.14.7",
|
|
32
|
-
"@overlastic/core": "^0.
|
|
32
|
+
"@overlastic/core": "^0.5.1"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsup src/index.ts",
|