@overlastic/svelte 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 +404 -77
- package/dist/index.d.cts +14 -20
- package/dist/index.d.ts +14 -20
- package/dist/index.global.js +525 -300
- package/dist/index.js +385 -74
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -18,66 +18,351 @@ 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
|
Overlay: () => Overlay,
|
|
24
24
|
defineOverlay: () => defineOverlay,
|
|
25
25
|
renderOverlay: () => renderOverlay,
|
|
26
|
-
|
|
26
|
+
useDisclosure: () => useDisclosure
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
29
|
|
|
30
|
-
// src/
|
|
30
|
+
// src/components/index.ts
|
|
31
31
|
var import_core = require("@overlastic/core");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
var import_svelte = require("svelte");
|
|
33
|
+
var __defProp2 = Object.defineProperty;
|
|
34
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
35
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? `${key}` : key, value);
|
|
36
|
+
function noop() {
|
|
37
|
+
}
|
|
38
|
+
function assign(tar, src) {
|
|
39
|
+
for (const k in src) tar[k] = src[k];
|
|
40
|
+
return (
|
|
41
|
+
/** @type {T & S} */
|
|
42
|
+
tar
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function run(fn) {
|
|
46
|
+
return fn();
|
|
47
|
+
}
|
|
48
|
+
function blank_object() {
|
|
49
|
+
return /* @__PURE__ */ Object.create(null);
|
|
50
|
+
}
|
|
51
|
+
function run_all(fns) {
|
|
52
|
+
fns.forEach(run);
|
|
53
|
+
}
|
|
54
|
+
function is_function(thing) {
|
|
55
|
+
return typeof thing === "function";
|
|
56
|
+
}
|
|
57
|
+
function safe_not_equal(a, b) {
|
|
58
|
+
return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
|
|
59
|
+
}
|
|
60
|
+
function is_empty(obj) {
|
|
61
|
+
return Object.keys(obj).length === 0;
|
|
62
|
+
}
|
|
63
|
+
function create_slot(definition, ctx, $$scope, fn) {
|
|
64
|
+
if (definition) {
|
|
65
|
+
const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);
|
|
66
|
+
return definition[0](slot_ctx);
|
|
43
67
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
}
|
|
69
|
+
function get_slot_context(definition, ctx, $$scope, fn) {
|
|
70
|
+
return definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;
|
|
71
|
+
}
|
|
72
|
+
function get_slot_changes(definition, $$scope, dirty, fn) {
|
|
73
|
+
if (definition[2] && fn)
|
|
74
|
+
;
|
|
75
|
+
return $$scope.dirty;
|
|
76
|
+
}
|
|
77
|
+
function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
|
|
78
|
+
if (slot_changes) {
|
|
79
|
+
const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
|
|
80
|
+
slot.p(slot_context, slot_changes);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function get_all_dirty_from_scope($$scope) {
|
|
84
|
+
if ($$scope.ctx.length > 32) {
|
|
85
|
+
const dirty = [];
|
|
86
|
+
const length = $$scope.ctx.length / 32;
|
|
87
|
+
for (let i = 0; i < length; i++) {
|
|
88
|
+
dirty[i] = -1;
|
|
89
|
+
}
|
|
90
|
+
return dirty;
|
|
91
|
+
}
|
|
92
|
+
return -1;
|
|
93
|
+
}
|
|
94
|
+
function insert(target, node, anchor) {
|
|
95
|
+
target.insertBefore(node, anchor || null);
|
|
96
|
+
}
|
|
97
|
+
function detach(node) {
|
|
98
|
+
if (node.parentNode) {
|
|
99
|
+
node.parentNode.removeChild(node);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function text(data) {
|
|
103
|
+
return document.createTextNode(data);
|
|
104
|
+
}
|
|
105
|
+
function empty() {
|
|
106
|
+
return text("");
|
|
107
|
+
}
|
|
108
|
+
function children(element) {
|
|
109
|
+
return Array.from(element.childNodes);
|
|
110
|
+
}
|
|
111
|
+
var current_component;
|
|
112
|
+
function set_current_component(component) {
|
|
113
|
+
current_component = component;
|
|
114
|
+
}
|
|
115
|
+
var dirty_components = [];
|
|
116
|
+
var binding_callbacks = [];
|
|
117
|
+
var render_callbacks = [];
|
|
118
|
+
var flush_callbacks = [];
|
|
119
|
+
var resolved_promise = /* @__PURE__ */ Promise.resolve();
|
|
120
|
+
var update_scheduled = false;
|
|
121
|
+
function schedule_update() {
|
|
122
|
+
if (!update_scheduled) {
|
|
123
|
+
update_scheduled = true;
|
|
124
|
+
resolved_promise.then(flush);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function add_render_callback(fn) {
|
|
128
|
+
render_callbacks.push(fn);
|
|
129
|
+
}
|
|
130
|
+
var seen_callbacks = /* @__PURE__ */ new Set();
|
|
131
|
+
var flushidx = 0;
|
|
132
|
+
function flush() {
|
|
133
|
+
if (flushidx !== 0) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const saved_component = current_component;
|
|
137
|
+
do {
|
|
138
|
+
try {
|
|
139
|
+
while (flushidx < dirty_components.length) {
|
|
140
|
+
const component = dirty_components[flushidx];
|
|
141
|
+
flushidx++;
|
|
142
|
+
set_current_component(component);
|
|
143
|
+
update(component.$$);
|
|
144
|
+
}
|
|
145
|
+
} catch (e) {
|
|
146
|
+
dirty_components.length = 0;
|
|
147
|
+
flushidx = 0;
|
|
148
|
+
throw e;
|
|
149
|
+
}
|
|
150
|
+
set_current_component(null);
|
|
151
|
+
dirty_components.length = 0;
|
|
152
|
+
flushidx = 0;
|
|
153
|
+
while (binding_callbacks.length) binding_callbacks.pop()();
|
|
154
|
+
for (let i = 0; i < render_callbacks.length; i += 1) {
|
|
155
|
+
const callback = render_callbacks[i];
|
|
156
|
+
if (!seen_callbacks.has(callback)) {
|
|
157
|
+
seen_callbacks.add(callback);
|
|
158
|
+
callback();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
render_callbacks.length = 0;
|
|
162
|
+
} while (dirty_components.length);
|
|
163
|
+
while (flush_callbacks.length) {
|
|
164
|
+
flush_callbacks.pop()();
|
|
165
|
+
}
|
|
166
|
+
update_scheduled = false;
|
|
167
|
+
seen_callbacks.clear();
|
|
168
|
+
set_current_component(saved_component);
|
|
169
|
+
}
|
|
170
|
+
function update($$) {
|
|
171
|
+
if ($$.fragment !== null) {
|
|
172
|
+
$$.update();
|
|
173
|
+
run_all($$.before_update);
|
|
174
|
+
const dirty = $$.dirty;
|
|
175
|
+
$$.dirty = [-1];
|
|
176
|
+
$$.fragment && $$.fragment.p($$.ctx, dirty);
|
|
177
|
+
$$.after_update.forEach(add_render_callback);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function flush_render_callbacks(fns) {
|
|
181
|
+
const filtered = [];
|
|
182
|
+
const targets = [];
|
|
183
|
+
render_callbacks.forEach((c) => !fns.includes(c) ? filtered.push(c) : targets.push(c));
|
|
184
|
+
targets.forEach((c) => c());
|
|
185
|
+
render_callbacks = filtered;
|
|
186
|
+
}
|
|
187
|
+
var outroing = /* @__PURE__ */ new Set();
|
|
188
|
+
var outros;
|
|
189
|
+
function group_outros() {
|
|
190
|
+
outros = {
|
|
191
|
+
r: 0,
|
|
192
|
+
c: [],
|
|
193
|
+
p: outros
|
|
194
|
+
// parent group
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function check_outros() {
|
|
198
|
+
if (!outros.r) {
|
|
199
|
+
run_all(outros.c);
|
|
200
|
+
}
|
|
201
|
+
outros = outros.p;
|
|
202
|
+
}
|
|
203
|
+
function transition_in(block, local) {
|
|
204
|
+
if (block && block.i) {
|
|
205
|
+
outroing.delete(block);
|
|
206
|
+
block.i(local);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function transition_out(block, local, detach2, callback) {
|
|
210
|
+
if (block && block.o) {
|
|
211
|
+
if (outroing.has(block))
|
|
212
|
+
return;
|
|
213
|
+
outroing.add(block);
|
|
214
|
+
outros.c.push(() => {
|
|
215
|
+
outroing.delete(block);
|
|
216
|
+
if (callback) {
|
|
217
|
+
if (detach2)
|
|
218
|
+
block.d(1);
|
|
219
|
+
callback();
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
block.o(local);
|
|
223
|
+
} else if (callback) {
|
|
224
|
+
callback();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function mount_component(component, target, anchor) {
|
|
228
|
+
const { fragment, after_update } = component.$$;
|
|
229
|
+
fragment && fragment.m(target, anchor);
|
|
230
|
+
add_render_callback(() => {
|
|
231
|
+
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
|
|
232
|
+
if (component.$$.on_destroy) {
|
|
233
|
+
component.$$.on_destroy.push(...new_on_destroy);
|
|
234
|
+
} else {
|
|
235
|
+
run_all(new_on_destroy);
|
|
236
|
+
}
|
|
237
|
+
component.$$.on_mount = [];
|
|
51
238
|
});
|
|
52
|
-
|
|
53
|
-
|
|
239
|
+
after_update.forEach(add_render_callback);
|
|
240
|
+
}
|
|
241
|
+
function destroy_component(component, detaching) {
|
|
242
|
+
const $$ = component.$$;
|
|
243
|
+
if ($$.fragment !== null) {
|
|
244
|
+
flush_render_callbacks($$.after_update);
|
|
245
|
+
run_all($$.on_destroy);
|
|
246
|
+
$$.fragment && $$.fragment.d(detaching);
|
|
247
|
+
$$.on_destroy = $$.fragment = null;
|
|
248
|
+
$$.ctx = [];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function make_dirty(component, i) {
|
|
252
|
+
if (component.$$.dirty[0] === -1) {
|
|
253
|
+
dirty_components.push(component);
|
|
254
|
+
schedule_update();
|
|
255
|
+
component.$$.dirty.fill(0);
|
|
256
|
+
}
|
|
257
|
+
component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
|
|
258
|
+
}
|
|
259
|
+
function init(component, options, instance2, create_fragment2, not_equal, props, append_styles = null, dirty = [-1]) {
|
|
260
|
+
const parent_component = current_component;
|
|
261
|
+
set_current_component(component);
|
|
262
|
+
const $$ = component.$$ = {
|
|
263
|
+
fragment: null,
|
|
264
|
+
ctx: [],
|
|
265
|
+
// state
|
|
54
266
|
props,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
267
|
+
update: noop,
|
|
268
|
+
not_equal,
|
|
269
|
+
bound: blank_object(),
|
|
270
|
+
// lifecycle
|
|
271
|
+
on_mount: [],
|
|
272
|
+
on_destroy: [],
|
|
273
|
+
on_disconnect: [],
|
|
274
|
+
before_update: [],
|
|
275
|
+
after_update: [],
|
|
276
|
+
context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
|
|
277
|
+
// everything else
|
|
278
|
+
callbacks: blank_object(),
|
|
279
|
+
dirty,
|
|
280
|
+
skip_bound: false,
|
|
281
|
+
root: options.target || parent_component.$$.root
|
|
282
|
+
};
|
|
283
|
+
append_styles && append_styles($$.root);
|
|
284
|
+
let ready = false;
|
|
285
|
+
$$.ctx = instance2 ? instance2(component, options.props || {}, (i, ret, ...rest) => {
|
|
286
|
+
const value = rest.length ? rest[0] : ret;
|
|
287
|
+
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
|
|
288
|
+
if (!$$.skip_bound && $$.bound[i])
|
|
289
|
+
$$.bound[i](value);
|
|
290
|
+
if (ready)
|
|
291
|
+
make_dirty(component, i);
|
|
292
|
+
}
|
|
293
|
+
return ret;
|
|
294
|
+
}) : [];
|
|
295
|
+
$$.update();
|
|
296
|
+
ready = true;
|
|
297
|
+
run_all($$.before_update);
|
|
298
|
+
$$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false;
|
|
299
|
+
if (options.target) {
|
|
300
|
+
if (options.hydrate) {
|
|
301
|
+
const nodes = children(options.target);
|
|
302
|
+
$$.fragment && $$.fragment.l(nodes);
|
|
303
|
+
nodes.forEach(detach);
|
|
304
|
+
} else {
|
|
305
|
+
$$.fragment && $$.fragment.c();
|
|
306
|
+
}
|
|
307
|
+
if (options.intro)
|
|
308
|
+
transition_in(component.$$.fragment);
|
|
309
|
+
mount_component(component, options.target, options.anchor);
|
|
310
|
+
flush();
|
|
311
|
+
}
|
|
312
|
+
set_current_component(parent_component);
|
|
68
313
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
314
|
+
var SvelteComponent = class {
|
|
315
|
+
constructor() {
|
|
316
|
+
__publicField(this, "$$");
|
|
317
|
+
__publicField(this, "$$set");
|
|
318
|
+
}
|
|
319
|
+
/** @returns {void} */
|
|
320
|
+
$destroy() {
|
|
321
|
+
destroy_component(this, 1);
|
|
322
|
+
this.$destroy = noop;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* @template {Extract<keyof Events, string>} K
|
|
326
|
+
* @param {K} type
|
|
327
|
+
* @param {((e: Events[K]) => void) | null | undefined} callback
|
|
328
|
+
* @returns {() => void}
|
|
329
|
+
*/
|
|
330
|
+
$on(type, callback) {
|
|
331
|
+
if (!is_function(callback)) {
|
|
332
|
+
return noop;
|
|
333
|
+
}
|
|
334
|
+
const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
|
|
335
|
+
callbacks.push(callback);
|
|
336
|
+
return () => {
|
|
337
|
+
const index = callbacks.indexOf(callback);
|
|
338
|
+
if (index !== -1)
|
|
339
|
+
callbacks.splice(index, 1);
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* @param {Partial<Props>} props
|
|
344
|
+
* @returns {void}
|
|
345
|
+
*/
|
|
346
|
+
$set(props) {
|
|
347
|
+
if (this.$$set && !is_empty(props)) {
|
|
348
|
+
this.$$.skip_bound = true;
|
|
349
|
+
this.$$set(props);
|
|
350
|
+
this.$$.skip_bound = false;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var PUBLIC_VERSION = "4";
|
|
355
|
+
if (typeof window !== "undefined")
|
|
356
|
+
(window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
|
|
357
|
+
var injectOverlayKey = Symbol("overlays:svelte");
|
|
358
|
+
var injectOptionsKey = Symbol("overlays:options");
|
|
74
359
|
function create_if_block(ctx) {
|
|
75
360
|
let current;
|
|
76
361
|
const default_slot_template = (
|
|
77
362
|
/* #slots */
|
|
78
363
|
ctx[2].default
|
|
79
364
|
);
|
|
80
|
-
const default_slot =
|
|
365
|
+
const default_slot = create_slot(
|
|
81
366
|
default_slot_template,
|
|
82
367
|
ctx,
|
|
83
368
|
/* $$scope */
|
|
@@ -90,23 +375,24 @@ function create_if_block(ctx) {
|
|
|
90
375
|
default_slot.c();
|
|
91
376
|
},
|
|
92
377
|
m(target, anchor) {
|
|
93
|
-
if (default_slot)
|
|
378
|
+
if (default_slot) {
|
|
94
379
|
default_slot.m(target, anchor);
|
|
380
|
+
}
|
|
95
381
|
current = true;
|
|
96
382
|
},
|
|
97
383
|
p(ctx2, dirty) {
|
|
98
384
|
if (default_slot) {
|
|
99
385
|
if (default_slot.p && (!current || dirty & 2)) {
|
|
100
|
-
|
|
386
|
+
update_slot_base(
|
|
101
387
|
default_slot,
|
|
102
388
|
default_slot_template,
|
|
103
389
|
ctx2,
|
|
104
390
|
/* $$scope */
|
|
105
391
|
ctx2[1],
|
|
106
|
-
!current ?
|
|
392
|
+
!current ? get_all_dirty_from_scope(
|
|
107
393
|
/* $$scope */
|
|
108
394
|
ctx2[1]
|
|
109
|
-
) :
|
|
395
|
+
) : get_slot_changes(
|
|
110
396
|
default_slot_template,
|
|
111
397
|
/* $$scope */
|
|
112
398
|
ctx2[1],
|
|
@@ -121,11 +407,11 @@ function create_if_block(ctx) {
|
|
|
121
407
|
i(local) {
|
|
122
408
|
if (current)
|
|
123
409
|
return;
|
|
124
|
-
|
|
410
|
+
transition_in(default_slot, local);
|
|
125
411
|
current = true;
|
|
126
412
|
},
|
|
127
413
|
o(local) {
|
|
128
|
-
|
|
414
|
+
transition_out(default_slot, local);
|
|
129
415
|
current = false;
|
|
130
416
|
},
|
|
131
417
|
d(detaching) {
|
|
@@ -145,12 +431,12 @@ function create_fragment(ctx) {
|
|
|
145
431
|
c() {
|
|
146
432
|
if (if_block)
|
|
147
433
|
if_block.c();
|
|
148
|
-
if_block_anchor =
|
|
434
|
+
if_block_anchor = empty();
|
|
149
435
|
},
|
|
150
436
|
m(target, anchor) {
|
|
151
437
|
if (if_block)
|
|
152
438
|
if_block.m(target, anchor);
|
|
153
|
-
|
|
439
|
+
insert(target, if_block_anchor, anchor);
|
|
154
440
|
current = true;
|
|
155
441
|
},
|
|
156
442
|
p(ctx2, [dirty]) {
|
|
@@ -160,53 +446,53 @@ function create_fragment(ctx) {
|
|
|
160
446
|
) {
|
|
161
447
|
if (if_block) {
|
|
162
448
|
if_block.p(ctx2, dirty);
|
|
163
|
-
if (dirty & 1)
|
|
164
|
-
|
|
449
|
+
if (dirty & 1) {
|
|
450
|
+
transition_in(if_block, 1);
|
|
451
|
+
}
|
|
165
452
|
} else {
|
|
166
453
|
if_block = create_if_block(ctx2);
|
|
167
454
|
if_block.c();
|
|
168
|
-
|
|
455
|
+
transition_in(if_block, 1);
|
|
169
456
|
if_block.m(if_block_anchor.parentNode, if_block_anchor);
|
|
170
457
|
}
|
|
171
458
|
} else if (if_block) {
|
|
172
|
-
|
|
173
|
-
|
|
459
|
+
group_outros();
|
|
460
|
+
transition_out(if_block, 1, 1, () => {
|
|
174
461
|
if_block = null;
|
|
175
462
|
});
|
|
176
|
-
|
|
463
|
+
check_outros();
|
|
177
464
|
}
|
|
178
465
|
},
|
|
179
|
-
i() {
|
|
466
|
+
i(local) {
|
|
180
467
|
if (current)
|
|
181
468
|
return;
|
|
182
|
-
|
|
469
|
+
transition_in(if_block);
|
|
183
470
|
current = true;
|
|
184
471
|
},
|
|
185
|
-
o() {
|
|
186
|
-
|
|
472
|
+
o(local) {
|
|
473
|
+
transition_out(if_block);
|
|
187
474
|
current = false;
|
|
188
475
|
},
|
|
189
476
|
d(detaching) {
|
|
477
|
+
if (detaching) {
|
|
478
|
+
detach(if_block_anchor);
|
|
479
|
+
}
|
|
190
480
|
if (if_block)
|
|
191
481
|
if_block.d(detaching);
|
|
192
|
-
if (detaching)
|
|
193
|
-
(0, import_internal3.detach)(if_block_anchor);
|
|
194
482
|
}
|
|
195
483
|
};
|
|
196
484
|
}
|
|
197
485
|
function instance($$self, $$props, $$invalidate) {
|
|
198
486
|
let { $$slots: slots = {}, $$scope } = $$props;
|
|
199
487
|
let { visible = false } = $$props;
|
|
200
|
-
const { duration = 0
|
|
201
|
-
const { deferred, vanish } = (0,
|
|
202
|
-
|
|
488
|
+
const { duration = 0 } = (0, import_svelte.getContext)(injectOptionsKey) || {};
|
|
489
|
+
const { deferred, vanish } = (0, import_svelte.getContext)(injectOverlayKey);
|
|
490
|
+
deferred == null ? void 0 : deferred.finally(async () => {
|
|
203
491
|
$$invalidate(0, visible = false);
|
|
204
|
-
await (0,
|
|
205
|
-
vanish
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
(0, import_svelte2.onMount)(() => immediate && $$invalidate(0, visible = true));
|
|
209
|
-
deferred == null ? void 0 : deferred.then(destroy).catch(destroy);
|
|
492
|
+
await (0, import_core.delay)(duration);
|
|
493
|
+
vanish();
|
|
494
|
+
});
|
|
495
|
+
(0, import_svelte.onMount)(() => $$invalidate(0, visible = true));
|
|
210
496
|
$$self.$$set = ($$props2) => {
|
|
211
497
|
if ("visible" in $$props2)
|
|
212
498
|
$$invalidate(0, visible = $$props2.visible);
|
|
@@ -215,16 +501,57 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
215
501
|
};
|
|
216
502
|
return [visible, $$scope, slots];
|
|
217
503
|
}
|
|
218
|
-
var
|
|
504
|
+
var _Overlay = class extends SvelteComponent {
|
|
219
505
|
constructor(options) {
|
|
220
|
-
super(
|
|
221
|
-
|
|
506
|
+
super();
|
|
507
|
+
init(this, options, instance, create_fragment, safe_not_equal, { visible: 0 });
|
|
222
508
|
}
|
|
223
509
|
};
|
|
510
|
+
var Overlay = _Overlay;
|
|
511
|
+
|
|
512
|
+
// src/composable/define.ts
|
|
513
|
+
var import_svelte2 = require("svelte");
|
|
514
|
+
|
|
515
|
+
// src/internal/index.ts
|
|
516
|
+
var injectOverlayKey2 = Symbol("overlays:svelte");
|
|
517
|
+
var injectOptionsKey2 = Symbol("overlays:options");
|
|
518
|
+
|
|
519
|
+
// src/composable/define.ts
|
|
520
|
+
function useDisclosure(options = {}) {
|
|
521
|
+
(0, import_svelte2.setContext)(injectOptionsKey2, options);
|
|
522
|
+
return (0, import_svelte2.getContext)(injectOverlayKey2);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// src/define/constructor.ts
|
|
526
|
+
var import_core2 = require("@overlastic/core");
|
|
527
|
+
var constructor = (0, import_core2.createConstructor)((Inst, props, options) => {
|
|
528
|
+
const { container, deferred, context: _context = /* @__PURE__ */ new Map() } = options;
|
|
529
|
+
function vanish() {
|
|
530
|
+
app.$destroy();
|
|
531
|
+
container.remove();
|
|
532
|
+
}
|
|
533
|
+
const context = new Map([..._context.entries()]);
|
|
534
|
+
context.set(injectOverlayKey2, {
|
|
535
|
+
confirm: deferred.confirm,
|
|
536
|
+
cannel: deferred.cancel,
|
|
537
|
+
deferred,
|
|
538
|
+
visible: false,
|
|
539
|
+
vanish
|
|
540
|
+
});
|
|
541
|
+
const app = new Inst({
|
|
542
|
+
target: container,
|
|
543
|
+
props,
|
|
544
|
+
context
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
// src/define/index.ts
|
|
549
|
+
var defineOverlay = constructor.define;
|
|
550
|
+
var renderOverlay = constructor.render;
|
|
224
551
|
// Annotate the CommonJS export names for ESM import in node:
|
|
225
552
|
0 && (module.exports = {
|
|
226
553
|
Overlay,
|
|
227
554
|
defineOverlay,
|
|
228
555
|
renderOverlay,
|
|
229
|
-
|
|
556
|
+
useDisclosure
|
|
230
557
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import * as _overlastic_core from '@overlastic/core';
|
|
2
2
|
import { Deferred } from '@overlastic/core';
|
|
3
|
-
import { ComponentConstructorOptions } from 'svelte';
|
|
4
|
-
import { SvelteComponentTyped } from 'svelte/internal';
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
/** current app context */
|
|
8
|
-
context?: Map<any, any>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare const defineOverlay: <Props, Resolved = void>(instance: any, options?: _overlastic_core.MountOptions<SMountOptions> | undefined) => _overlastic_core.ImperativeOverlay<Props, Resolved, SMountOptions>;
|
|
12
|
-
declare const renderOverlay: <Props, Resolved = void>(instance: any, props?: Props | undefined, options?: _overlastic_core.MountOptions<SMountOptions> | undefined) => Promise<Resolved>;
|
|
4
|
+
declare const Overlay: any;
|
|
13
5
|
|
|
14
|
-
interface
|
|
15
|
-
/** the notification
|
|
16
|
-
|
|
6
|
+
interface UseDisclosureReturn {
|
|
7
|
+
/** the notification cancel, modify visible, and destroy it after the duration ends */
|
|
8
|
+
cancel: (reason?: any) => void;
|
|
17
9
|
/** the notification resolve, modify visible, and destroy it after the duration ends */
|
|
18
|
-
|
|
10
|
+
confirm: (value?: any) => void;
|
|
19
11
|
/** destroy the current instance (immediately) */
|
|
20
12
|
vanish: () => void;
|
|
21
13
|
/** visible control popup display and hide */
|
|
@@ -23,18 +15,20 @@ interface ExtendOverlayReturn {
|
|
|
23
15
|
deferred?: Deferred<any>;
|
|
24
16
|
}
|
|
25
17
|
|
|
26
|
-
interface
|
|
18
|
+
interface UseDisclosureOptions {
|
|
27
19
|
/** animation duration to avoid premature destruction of components */
|
|
28
20
|
duration?: number;
|
|
29
21
|
/** whether to set visible to true immediately */
|
|
30
22
|
immediate?: boolean;
|
|
31
23
|
}
|
|
32
|
-
declare function
|
|
24
|
+
declare function useDisclosure(options?: UseDisclosureOptions): UseDisclosureReturn;
|
|
33
25
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
constructor(options: ComponentConstructorOptions);
|
|
26
|
+
interface SMountOptions {
|
|
27
|
+
/** current app context */
|
|
28
|
+
context?: Map<any, any>;
|
|
38
29
|
}
|
|
39
30
|
|
|
40
|
-
|
|
31
|
+
declare const defineOverlay: <Props, Resolved = void>(instance: any, options?: _overlastic_core.MountOptions<SMountOptions> | undefined) => _overlastic_core.ImperativeOverlay<Props, Resolved, SMountOptions>;
|
|
32
|
+
declare const renderOverlay: <Props, Resolved = void>(instance: any, props?: Props | undefined, options?: _overlastic_core.MountOptions<SMountOptions> | undefined) => Promise<Resolved>;
|
|
33
|
+
|
|
34
|
+
export { Overlay, type UseDisclosureOptions, type UseDisclosureReturn, defineOverlay, renderOverlay, useDisclosure };
|