@overlastic/vanilla 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.cjs +17 -19
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.global.js +65 -62
- package/dist/index.js +13 -15
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -18,16 +18,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
defineOverlay: () => defineOverlay,
|
|
24
24
|
renderOverlay: () => renderOverlay,
|
|
25
|
-
|
|
25
|
+
useDisclosure: () => useDisclosure
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
28
|
-
|
|
29
|
-
// src/define/constructor.ts
|
|
30
|
-
var import_core = require("@overlastic/core");
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
31
28
|
|
|
32
29
|
// src/internal/index.ts
|
|
33
30
|
var context = {
|
|
@@ -50,15 +47,25 @@ function useOptions() {
|
|
|
50
47
|
return context.options || {};
|
|
51
48
|
}
|
|
52
49
|
|
|
50
|
+
// src/composable/define.ts
|
|
51
|
+
function useDisclosure(options) {
|
|
52
|
+
const trigger = context.trigger;
|
|
53
|
+
if (!trigger)
|
|
54
|
+
throw new Error("Please execute in the overlays constructor");
|
|
55
|
+
setupOptions(options);
|
|
56
|
+
return trigger;
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
// src/define/constructor.ts
|
|
60
|
+
var import_core = require("@overlastic/core");
|
|
54
61
|
var constructor = (0, import_core.createConstructor)((Inst, props, options) => {
|
|
55
62
|
const { container, deferred } = options;
|
|
56
63
|
function vanish() {
|
|
57
64
|
container.remove();
|
|
58
65
|
}
|
|
59
66
|
setupTrigger({
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
confirm: deferred.confirm,
|
|
68
|
+
cancel: deferred.cancel,
|
|
62
69
|
deferred,
|
|
63
70
|
vanish
|
|
64
71
|
});
|
|
@@ -81,18 +88,9 @@ function parseElement(component, props) {
|
|
|
81
88
|
// src/define/index.ts
|
|
82
89
|
var defineOverlay = constructor.define;
|
|
83
90
|
var renderOverlay = constructor.render;
|
|
84
|
-
|
|
85
|
-
// src/composable/define.ts
|
|
86
|
-
function useExtendOverlay(options) {
|
|
87
|
-
const trigger = context.trigger;
|
|
88
|
-
if (!trigger)
|
|
89
|
-
throw new Error("Please execute in the overlays constructor");
|
|
90
|
-
setupOptions(options);
|
|
91
|
-
return trigger;
|
|
92
|
-
}
|
|
93
91
|
// Annotate the CommonJS export names for ESM import in node:
|
|
94
92
|
0 && (module.exports = {
|
|
95
93
|
defineOverlay,
|
|
96
94
|
renderOverlay,
|
|
97
|
-
|
|
95
|
+
useDisclosure
|
|
98
96
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as _overlastic_core from '@overlastic/core';
|
|
2
2
|
import { Deferred } from '@overlastic/core';
|
|
3
3
|
|
|
4
|
+
interface ExtendOverlayOptions {
|
|
5
|
+
/** animation duration to avoid premature destruction of components */
|
|
6
|
+
duration?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function useDisclosure(options?: ExtendOverlayOptions): Context<void>;
|
|
9
|
+
|
|
4
10
|
interface EFComponent<T = any> {
|
|
5
11
|
(props: T): HTMLElement;
|
|
6
12
|
}
|
|
@@ -10,16 +16,10 @@ declare const defineOverlay: <Props, Resolved = void>(instance: ElementComponent
|
|
|
10
16
|
declare const renderOverlay: <Props, Resolved = void>(instance: ElementComponent, props?: Props | undefined, options?: _overlastic_core.GlobalMountOptions | undefined) => Promise<Resolved>;
|
|
11
17
|
|
|
12
18
|
interface Context<T = void> {
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
confirm: Deferred<T>['confirm'];
|
|
20
|
+
cancel: Deferred<T>['cancel'];
|
|
15
21
|
deferred: Deferred<T>;
|
|
16
22
|
vanish: () => void;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
/** animation duration to avoid premature destruction of components */
|
|
21
|
-
duration?: number;
|
|
22
|
-
}
|
|
23
|
-
declare function useExtendOverlay(options?: ExtendOverlayOptions): Context<void>;
|
|
24
|
-
|
|
25
|
-
export { type Context, type ExtendOverlayOptions, defineOverlay, renderOverlay, useExtendOverlay };
|
|
25
|
+
export { type Context, type ExtendOverlayOptions, defineOverlay, renderOverlay, useDisclosure };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as _overlastic_core from '@overlastic/core';
|
|
2
2
|
import { Deferred } from '@overlastic/core';
|
|
3
3
|
|
|
4
|
+
interface ExtendOverlayOptions {
|
|
5
|
+
/** animation duration to avoid premature destruction of components */
|
|
6
|
+
duration?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function useDisclosure(options?: ExtendOverlayOptions): Context<void>;
|
|
9
|
+
|
|
4
10
|
interface EFComponent<T = any> {
|
|
5
11
|
(props: T): HTMLElement;
|
|
6
12
|
}
|
|
@@ -10,16 +16,10 @@ declare const defineOverlay: <Props, Resolved = void>(instance: ElementComponent
|
|
|
10
16
|
declare const renderOverlay: <Props, Resolved = void>(instance: ElementComponent, props?: Props | undefined, options?: _overlastic_core.GlobalMountOptions | undefined) => Promise<Resolved>;
|
|
11
17
|
|
|
12
18
|
interface Context<T = void> {
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
confirm: Deferred<T>['confirm'];
|
|
20
|
+
cancel: Deferred<T>['cancel'];
|
|
15
21
|
deferred: Deferred<T>;
|
|
16
22
|
vanish: () => void;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
/** animation duration to avoid premature destruction of components */
|
|
21
|
-
duration?: number;
|
|
22
|
-
}
|
|
23
|
-
declare function useExtendOverlay(options?: ExtendOverlayOptions): Context<void>;
|
|
24
|
-
|
|
25
|
-
export { type Context, type ExtendOverlayOptions, defineOverlay, renderOverlay, useExtendOverlay };
|
|
25
|
+
export { type Context, type ExtendOverlayOptions, defineOverlay, renderOverlay, useDisclosure };
|
package/dist/index.global.js
CHANGED
|
@@ -19,13 +19,61 @@ var OverlaysVanilla = (() => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
|
|
21
21
|
// src/index.ts
|
|
22
|
-
var
|
|
23
|
-
__export(
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
24
|
defineOverlay: () => defineOverlay,
|
|
25
25
|
renderOverlay: () => renderOverlay,
|
|
26
|
-
|
|
26
|
+
useDisclosure: () => useDisclosure
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
+
// src/internal/index.ts
|
|
30
|
+
var context = {
|
|
31
|
+
trigger: void 0,
|
|
32
|
+
options: void 0
|
|
33
|
+
};
|
|
34
|
+
function setupTrigger(c) {
|
|
35
|
+
context.trigger = c;
|
|
36
|
+
}
|
|
37
|
+
function clearTrigger() {
|
|
38
|
+
context.trigger = void 0;
|
|
39
|
+
}
|
|
40
|
+
function setupOptions(o = {}) {
|
|
41
|
+
context.options = o;
|
|
42
|
+
}
|
|
43
|
+
function clearOptions() {
|
|
44
|
+
context.options = void 0;
|
|
45
|
+
}
|
|
46
|
+
function useOptions() {
|
|
47
|
+
return context.options || {};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/composable/define.ts
|
|
51
|
+
function useDisclosure(options) {
|
|
52
|
+
const trigger = context.trigger;
|
|
53
|
+
if (!trigger)
|
|
54
|
+
throw new Error("Please execute in the overlays constructor");
|
|
55
|
+
setupOptions(options);
|
|
56
|
+
return trigger;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ../@core/src/deferred.ts
|
|
60
|
+
function createDeferred() {
|
|
61
|
+
let confirm, cancel;
|
|
62
|
+
const promise = new Promise((_confirm, _cancel) => {
|
|
63
|
+
confirm = _confirm;
|
|
64
|
+
cancel = _cancel;
|
|
65
|
+
});
|
|
66
|
+
promise.confirm = (v) => {
|
|
67
|
+
confirm(v);
|
|
68
|
+
return promise;
|
|
69
|
+
};
|
|
70
|
+
promise.close = () => {
|
|
71
|
+
confirm();
|
|
72
|
+
};
|
|
73
|
+
promise.cancel = cancel;
|
|
74
|
+
return promise;
|
|
75
|
+
}
|
|
76
|
+
|
|
29
77
|
// ../@core/src/define/global.ts
|
|
30
78
|
var UnifiedOverlayProviderID = "unified-overlay";
|
|
31
79
|
function defineGlobalElement(id = "", root = document.body) {
|
|
@@ -38,36 +86,21 @@ var OverlaysVanilla = (() => {
|
|
|
38
86
|
}
|
|
39
87
|
|
|
40
88
|
// ../@core/src/internal/index.ts
|
|
41
|
-
var
|
|
89
|
+
var context2 = {
|
|
42
90
|
position: null,
|
|
43
91
|
spaces: {}
|
|
44
92
|
};
|
|
45
93
|
|
|
46
94
|
// ../@core/src/define/name-index.ts
|
|
47
95
|
function defineName(id = UnifiedOverlayProviderID, auto = true) {
|
|
48
|
-
if (!
|
|
49
|
-
|
|
96
|
+
if (!context2.spaces[id])
|
|
97
|
+
context2.spaces[id] = 0;
|
|
50
98
|
if (auto)
|
|
51
|
-
return `${id}--${++
|
|
99
|
+
return `${id}--${++context2.spaces[id]}`;
|
|
52
100
|
return id;
|
|
53
101
|
}
|
|
54
102
|
function getIndex(id = UnifiedOverlayProviderID) {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// ../@core/src/deferred.ts
|
|
59
|
-
function createDeferred() {
|
|
60
|
-
let resolve, reject;
|
|
61
|
-
const promise = new Promise((_resolve, _reject) => {
|
|
62
|
-
resolve = _resolve;
|
|
63
|
-
reject = _reject;
|
|
64
|
-
});
|
|
65
|
-
promise.resolve = (v) => {
|
|
66
|
-
resolve(v);
|
|
67
|
-
return promise;
|
|
68
|
-
};
|
|
69
|
-
promise.reject = reject;
|
|
70
|
-
return promise;
|
|
103
|
+
return context2.spaces[id] || 0;
|
|
71
104
|
}
|
|
72
105
|
|
|
73
106
|
// ../@core/src/events/index.ts
|
|
@@ -78,14 +111,14 @@ var OverlaysVanilla = (() => {
|
|
|
78
111
|
if (event.target instanceof Element) {
|
|
79
112
|
const { left, top, width, height } = event.target.getBoundingClientRect();
|
|
80
113
|
if (left > 0 || top > 0) {
|
|
81
|
-
|
|
114
|
+
context2.position = { x: left + width / 2, y: top + height / 2 };
|
|
82
115
|
} else {
|
|
83
|
-
|
|
116
|
+
context2.position = null;
|
|
84
117
|
}
|
|
85
118
|
} else {
|
|
86
|
-
|
|
119
|
+
context2.position = null;
|
|
87
120
|
}
|
|
88
|
-
setTimeout(() =>
|
|
121
|
+
setTimeout(() => context2.position = null, 64);
|
|
89
122
|
});
|
|
90
123
|
}
|
|
91
124
|
|
|
@@ -100,7 +133,7 @@ var OverlaysVanilla = (() => {
|
|
|
100
133
|
const root = globalContainer ? options3.root : document.body;
|
|
101
134
|
const container = defineGlobalElement(name, root);
|
|
102
135
|
mount(instance, props, Object.assign(options3, {
|
|
103
|
-
position:
|
|
136
|
+
position: context2.position,
|
|
104
137
|
id: name,
|
|
105
138
|
deferred,
|
|
106
139
|
index,
|
|
@@ -131,28 +164,7 @@ var OverlaysVanilla = (() => {
|
|
|
131
164
|
|
|
132
165
|
// ../@core/src/utils/util.ts
|
|
133
166
|
function delay(milliseconds) {
|
|
134
|
-
return new Promise((
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// src/internal/index.ts
|
|
138
|
-
var context2 = {
|
|
139
|
-
trigger: void 0,
|
|
140
|
-
options: void 0
|
|
141
|
-
};
|
|
142
|
-
function setupTrigger(c) {
|
|
143
|
-
context2.trigger = c;
|
|
144
|
-
}
|
|
145
|
-
function clearTrigger() {
|
|
146
|
-
context2.trigger = void 0;
|
|
147
|
-
}
|
|
148
|
-
function setupOptions(o = {}) {
|
|
149
|
-
context2.options = o;
|
|
150
|
-
}
|
|
151
|
-
function clearOptions() {
|
|
152
|
-
context2.options = void 0;
|
|
153
|
-
}
|
|
154
|
-
function useOptions() {
|
|
155
|
-
return context2.options || {};
|
|
167
|
+
return new Promise((confirm) => setTimeout(confirm, milliseconds));
|
|
156
168
|
}
|
|
157
169
|
|
|
158
170
|
// src/define/constructor.ts
|
|
@@ -162,8 +174,8 @@ var OverlaysVanilla = (() => {
|
|
|
162
174
|
container.remove();
|
|
163
175
|
}
|
|
164
176
|
setupTrigger({
|
|
165
|
-
|
|
166
|
-
|
|
177
|
+
confirm: deferred.confirm,
|
|
178
|
+
cancel: deferred.cancel,
|
|
167
179
|
deferred,
|
|
168
180
|
vanish
|
|
169
181
|
});
|
|
@@ -186,14 +198,5 @@ var OverlaysVanilla = (() => {
|
|
|
186
198
|
// src/define/index.ts
|
|
187
199
|
var defineOverlay = constructor.define;
|
|
188
200
|
var renderOverlay = constructor.render;
|
|
189
|
-
|
|
190
|
-
// src/composable/define.ts
|
|
191
|
-
function useExtendOverlay(options) {
|
|
192
|
-
const trigger = context2.trigger;
|
|
193
|
-
if (!trigger)
|
|
194
|
-
throw new Error("Please execute in the overlays constructor");
|
|
195
|
-
setupOptions(options);
|
|
196
|
-
return trigger;
|
|
197
|
-
}
|
|
198
|
-
return __toCommonJS(src_exports);
|
|
201
|
+
return __toCommonJS(index_exports);
|
|
199
202
|
})();
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/define/constructor.ts
|
|
2
|
-
import { createConstructor, delay } from "@overlastic/core";
|
|
3
|
-
|
|
4
1
|
// src/internal/index.ts
|
|
5
2
|
var context = {
|
|
6
3
|
trigger: void 0,
|
|
@@ -22,15 +19,25 @@ function useOptions() {
|
|
|
22
19
|
return context.options || {};
|
|
23
20
|
}
|
|
24
21
|
|
|
22
|
+
// src/composable/define.ts
|
|
23
|
+
function useDisclosure(options) {
|
|
24
|
+
const trigger = context.trigger;
|
|
25
|
+
if (!trigger)
|
|
26
|
+
throw new Error("Please execute in the overlays constructor");
|
|
27
|
+
setupOptions(options);
|
|
28
|
+
return trigger;
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
// src/define/constructor.ts
|
|
32
|
+
import { createConstructor, delay } from "@overlastic/core";
|
|
26
33
|
var constructor = createConstructor((Inst, props, options) => {
|
|
27
34
|
const { container, deferred } = options;
|
|
28
35
|
function vanish() {
|
|
29
36
|
container.remove();
|
|
30
37
|
}
|
|
31
38
|
setupTrigger({
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
confirm: deferred.confirm,
|
|
40
|
+
cancel: deferred.cancel,
|
|
34
41
|
deferred,
|
|
35
42
|
vanish
|
|
36
43
|
});
|
|
@@ -53,17 +60,8 @@ function parseElement(component, props) {
|
|
|
53
60
|
// src/define/index.ts
|
|
54
61
|
var defineOverlay = constructor.define;
|
|
55
62
|
var renderOverlay = constructor.render;
|
|
56
|
-
|
|
57
|
-
// src/composable/define.ts
|
|
58
|
-
function useExtendOverlay(options) {
|
|
59
|
-
const trigger = context.trigger;
|
|
60
|
-
if (!trigger)
|
|
61
|
-
throw new Error("Please execute in the overlays constructor");
|
|
62
|
-
setupOptions(options);
|
|
63
|
-
return trigger;
|
|
64
|
-
}
|
|
65
63
|
export {
|
|
66
64
|
defineOverlay,
|
|
67
65
|
renderOverlay,
|
|
68
|
-
|
|
66
|
+
useDisclosure
|
|
69
67
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@overlastic/vanilla",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/hairyf/overlastic#readme",
|
|
7
7
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@overlastic/core": "^0.8.
|
|
28
|
+
"@overlastic/core": "^0.8.3"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsup src/index.ts",
|