@overlastic/svelte 0.8.0 → 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.
@@ -4,6 +4,7 @@ var OverlaysSvelte = (() => {
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
8
  var __export = (target, all) => {
8
9
  for (var name in all)
9
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -17,16 +18,35 @@ var OverlaysSvelte = (() => {
17
18
  return to;
18
19
  };
19
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
22
 
21
23
  // src/index.ts
22
- var src_exports = {};
23
- __export(src_exports, {
24
+ var index_exports = {};
25
+ __export(index_exports, {
24
26
  Overlay: () => Overlay,
25
27
  defineOverlay: () => defineOverlay,
26
28
  renderOverlay: () => renderOverlay,
27
- useExtendOverlay: () => useExtendOverlay
29
+ useDisclosure: () => useDisclosure
28
30
  });
29
31
 
32
+ // ../@core/src/deferred.ts
33
+ function createDeferred() {
34
+ let confirm, cancel;
35
+ const promise = new Promise((_confirm, _cancel) => {
36
+ confirm = _confirm;
37
+ cancel = _cancel;
38
+ });
39
+ promise.confirm = (v) => {
40
+ confirm(v);
41
+ return promise;
42
+ };
43
+ promise.close = () => {
44
+ confirm();
45
+ };
46
+ promise.cancel = cancel;
47
+ return promise;
48
+ }
49
+
30
50
  // ../@core/src/define/global.ts
31
51
  var UnifiedOverlayProviderID = "unified-overlay";
32
52
  function defineGlobalElement(id = "", root = document.body) {
@@ -56,21 +76,6 @@ var OverlaysSvelte = (() => {
56
76
  return context.spaces[id] || 0;
57
77
  }
58
78
 
59
- // ../@core/src/deferred.ts
60
- function createDeferred() {
61
- let resolve, reject;
62
- const promise = new Promise((_resolve, _reject) => {
63
- resolve = _resolve;
64
- reject = _reject;
65
- });
66
- promise.resolve = (v) => {
67
- resolve(v);
68
- return promise;
69
- };
70
- promise.reject = reject;
71
- return promise;
72
- }
73
-
74
79
  // ../@core/src/events/index.ts
75
80
  function watchClickPosition() {
76
81
  if (typeof window === "undefined" && typeof document === "undefined")
@@ -98,7 +103,8 @@ var OverlaysSvelte = (() => {
98
103
  const deferred = createDeferred();
99
104
  const name = defineName(options3.id, options3.autoIncrement);
100
105
  const index = getIndex(options3.id);
101
- const container = globalContainer ? defineGlobalElement(name, options3.root) : document.body;
106
+ const root = globalContainer ? options3.root : document.body;
107
+ const container = defineGlobalElement(name, root);
102
108
  mount(instance2, props, Object.assign(options3, {
103
109
  position: context.position,
104
110
  id: name,
@@ -131,63 +137,372 @@ var OverlaysSvelte = (() => {
131
137
 
132
138
  // ../@core/src/utils/util.ts
133
139
  function delay(milliseconds) {
134
- return new Promise((resolve) => setTimeout(resolve, milliseconds));
140
+ return new Promise((confirm) => setTimeout(confirm, milliseconds));
135
141
  }
136
142
 
137
- // src/internal/index.ts
138
- var injectOverlayKey = Symbol("overlays:svelte");
139
- var injectOptionsKey = Symbol("overlays:options");
143
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/globals.js
144
+ var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : (
145
+ // @ts-ignore Node typings have this
146
+ global
147
+ );
140
148
 
141
- // src/define/constructor.ts
142
- var constructor = createConstructor((Inst, props, options) => {
143
- const { container, deferred, context: _context = /* @__PURE__ */ new Map() } = options;
144
- function vanish() {
145
- app.$destroy();
146
- container.remove();
149
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/ResizeObserverSingleton.js
150
+ var ResizeObserverSingleton = class _ResizeObserverSingleton {
151
+ /** @param {ResizeObserverOptions} options */
152
+ constructor(options) {
153
+ /**
154
+ * @private
155
+ * @readonly
156
+ * @type {WeakMap<Element, import('./private.js').Listener>}
157
+ */
158
+ __publicField(this, "_listeners", "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0);
159
+ /**
160
+ * @private
161
+ * @type {ResizeObserver}
162
+ */
163
+ __publicField(this, "_observer");
164
+ /** @type {ResizeObserverOptions} */
165
+ __publicField(this, "options");
166
+ this.options = options;
147
167
  }
148
- const context2 = new Map([..._context.entries()]);
149
- context2.set(injectOverlayKey, {
150
- resolve: deferred.resolve,
151
- reject: deferred.reject,
152
- deferred,
153
- visible: false,
154
- vanish
155
- });
156
- const app = new Inst({
157
- target: container,
158
- props,
159
- context: context2
160
- });
161
- });
168
+ /**
169
+ * @param {Element} element
170
+ * @param {import('./private.js').Listener} listener
171
+ * @returns {() => void}
172
+ */
173
+ observe(element2, listener) {
174
+ this._listeners.set(element2, listener);
175
+ this._getObserver().observe(element2, this.options);
176
+ return () => {
177
+ this._listeners.delete(element2);
178
+ this._observer.unobserve(element2);
179
+ };
180
+ }
181
+ /**
182
+ * @private
183
+ */
184
+ _getObserver() {
185
+ var _a;
186
+ return (_a = this._observer) != null ? _a : this._observer = new ResizeObserver((entries) => {
187
+ var _a2;
188
+ for (const entry of entries) {
189
+ _ResizeObserverSingleton.entries.set(entry.target, entry);
190
+ (_a2 = this._listeners.get(entry.target)) == null ? void 0 : _a2(entry);
191
+ }
192
+ });
193
+ }
194
+ };
195
+ ResizeObserverSingleton.entries = "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0;
162
196
 
163
- // src/define/index.ts
164
- var defineOverlay = constructor.define;
165
- var renderOverlay = constructor.render;
197
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/dom.js
198
+ function insert(target, node, anchor) {
199
+ target.insertBefore(node, anchor || null);
200
+ }
201
+ function detach(node) {
202
+ if (node.parentNode) {
203
+ node.parentNode.removeChild(node);
204
+ }
205
+ }
206
+ function element(name) {
207
+ return document.createElement(name);
208
+ }
209
+ function attr(node, attribute, value) {
210
+ if (value == null) node.removeAttribute(attribute);
211
+ else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value);
212
+ }
213
+ function get_custom_elements_slots(element2) {
214
+ const result = {};
215
+ element2.childNodes.forEach(
216
+ /** @param {Element} node */
217
+ (node) => {
218
+ result[node.slot || "default"] = true;
219
+ }
220
+ );
221
+ return result;
222
+ }
223
+
224
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/lifecycle.js
225
+ var current_component;
226
+ function get_current_component() {
227
+ if (!current_component) throw new Error("Function called outside component initialization");
228
+ return current_component;
229
+ }
230
+ function setContext(key, context2) {
231
+ get_current_component().$$.context.set(key, context2);
232
+ return context2;
233
+ }
234
+ function getContext(key) {
235
+ return get_current_component().$$.context.get(key);
236
+ }
237
+
238
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/shared/boolean_attributes.js
239
+ var _boolean_attributes = (
240
+ /** @type {const} */
241
+ [
242
+ "allowfullscreen",
243
+ "allowpaymentrequest",
244
+ "async",
245
+ "autofocus",
246
+ "autoplay",
247
+ "checked",
248
+ "controls",
249
+ "default",
250
+ "defer",
251
+ "disabled",
252
+ "formnovalidate",
253
+ "hidden",
254
+ "inert",
255
+ "ismap",
256
+ "loop",
257
+ "multiple",
258
+ "muted",
259
+ "nomodule",
260
+ "novalidate",
261
+ "open",
262
+ "playsinline",
263
+ "readonly",
264
+ "required",
265
+ "reversed",
266
+ "selected"
267
+ ]
268
+ );
269
+ var boolean_attributes = /* @__PURE__ */ new Set([..._boolean_attributes]);
270
+
271
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/Component.js
272
+ var SvelteElement;
273
+ if (typeof HTMLElement === "function") {
274
+ SvelteElement = class extends HTMLElement {
275
+ constructor($$componentCtor, $$slots, use_shadow_dom) {
276
+ super();
277
+ /** The Svelte component constructor */
278
+ __publicField(this, "$$ctor");
279
+ /** Slots */
280
+ __publicField(this, "$$s");
281
+ /** The Svelte component instance */
282
+ __publicField(this, "$$c");
283
+ /** Whether or not the custom element is connected */
284
+ __publicField(this, "$$cn", false);
285
+ /** Component props data */
286
+ __publicField(this, "$$d", {});
287
+ /** `true` if currently in the process of reflecting component props back to attributes */
288
+ __publicField(this, "$$r", false);
289
+ /** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
290
+ __publicField(this, "$$p_d", {});
291
+ /** @type {Record<string, Function[]>} Event listeners */
292
+ __publicField(this, "$$l", {});
293
+ /** @type {Map<Function, Function>} Event listener unsubscribe functions */
294
+ __publicField(this, "$$l_u", /* @__PURE__ */ new Map());
295
+ this.$$ctor = $$componentCtor;
296
+ this.$$s = $$slots;
297
+ if (use_shadow_dom) {
298
+ this.attachShadow({ mode: "open" });
299
+ }
300
+ }
301
+ addEventListener(type, listener, options) {
302
+ this.$$l[type] = this.$$l[type] || [];
303
+ this.$$l[type].push(listener);
304
+ if (this.$$c) {
305
+ const unsub = this.$$c.$on(type, listener);
306
+ this.$$l_u.set(listener, unsub);
307
+ }
308
+ super.addEventListener(type, listener, options);
309
+ }
310
+ removeEventListener(type, listener, options) {
311
+ super.removeEventListener(type, listener, options);
312
+ if (this.$$c) {
313
+ const unsub = this.$$l_u.get(listener);
314
+ if (unsub) {
315
+ unsub();
316
+ this.$$l_u.delete(listener);
317
+ }
318
+ }
319
+ }
320
+ async connectedCallback() {
321
+ this.$$cn = true;
322
+ if (!this.$$c) {
323
+ let create_slot3 = function(name) {
324
+ return () => {
325
+ let node;
326
+ const obj = {
327
+ c: function create() {
328
+ node = element("slot");
329
+ if (name !== "default") {
330
+ attr(node, "name", name);
331
+ }
332
+ },
333
+ /**
334
+ * @param {HTMLElement} target
335
+ * @param {HTMLElement} [anchor]
336
+ */
337
+ m: function mount(target, anchor) {
338
+ insert(target, node, anchor);
339
+ },
340
+ d: function destroy(detaching) {
341
+ if (detaching) {
342
+ detach(node);
343
+ }
344
+ }
345
+ };
346
+ return obj;
347
+ };
348
+ };
349
+ var create_slot2 = create_slot3;
350
+ await Promise.resolve();
351
+ if (!this.$$cn || this.$$c) {
352
+ return;
353
+ }
354
+ const $$slots = {};
355
+ const existing_slots = get_custom_elements_slots(this);
356
+ for (const name of this.$$s) {
357
+ if (name in existing_slots) {
358
+ $$slots[name] = [create_slot3(name)];
359
+ }
360
+ }
361
+ for (const attribute of this.attributes) {
362
+ const name = this.$$g_p(attribute.name);
363
+ if (!(name in this.$$d)) {
364
+ this.$$d[name] = get_custom_element_value(name, attribute.value, this.$$p_d, "toProp");
365
+ }
366
+ }
367
+ for (const key in this.$$p_d) {
368
+ if (!(key in this.$$d) && this[key] !== void 0) {
369
+ this.$$d[key] = this[key];
370
+ delete this[key];
371
+ }
372
+ }
373
+ this.$$c = new this.$$ctor({
374
+ target: this.shadowRoot || this,
375
+ props: {
376
+ ...this.$$d,
377
+ $$slots,
378
+ $$scope: {
379
+ ctx: []
380
+ }
381
+ }
382
+ });
383
+ const reflect_attributes = () => {
384
+ this.$$r = true;
385
+ for (const key in this.$$p_d) {
386
+ this.$$d[key] = this.$$c.$$.ctx[this.$$c.$$.props[key]];
387
+ if (this.$$p_d[key].reflect) {
388
+ const attribute_value = get_custom_element_value(
389
+ key,
390
+ this.$$d[key],
391
+ this.$$p_d,
392
+ "toAttribute"
393
+ );
394
+ if (attribute_value == null) {
395
+ this.removeAttribute(this.$$p_d[key].attribute || key);
396
+ } else {
397
+ this.setAttribute(this.$$p_d[key].attribute || key, attribute_value);
398
+ }
399
+ }
400
+ }
401
+ this.$$r = false;
402
+ };
403
+ this.$$c.$$.after_update.push(reflect_attributes);
404
+ reflect_attributes();
405
+ for (const type in this.$$l) {
406
+ for (const listener of this.$$l[type]) {
407
+ const unsub = this.$$c.$on(type, listener);
408
+ this.$$l_u.set(listener, unsub);
409
+ }
410
+ }
411
+ this.$$l = {};
412
+ }
413
+ }
414
+ // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
415
+ // and setting attributes through setAttribute etc, this is helpful
416
+ attributeChangedCallback(attr2, _oldValue, newValue) {
417
+ var _a;
418
+ if (this.$$r) return;
419
+ attr2 = this.$$g_p(attr2);
420
+ this.$$d[attr2] = get_custom_element_value(attr2, newValue, this.$$p_d, "toProp");
421
+ (_a = this.$$c) == null ? void 0 : _a.$set({ [attr2]: this.$$d[attr2] });
422
+ }
423
+ disconnectedCallback() {
424
+ this.$$cn = false;
425
+ Promise.resolve().then(() => {
426
+ if (!this.$$cn && this.$$c) {
427
+ this.$$c.$destroy();
428
+ this.$$c = void 0;
429
+ }
430
+ });
431
+ }
432
+ $$g_p(attribute_name) {
433
+ return Object.keys(this.$$p_d).find(
434
+ (key) => this.$$p_d[key].attribute === attribute_name || !this.$$p_d[key].attribute && key.toLowerCase() === attribute_name
435
+ ) || attribute_name;
436
+ }
437
+ };
438
+ }
439
+ function get_custom_element_value(prop, value, props_definition, transform) {
440
+ var _a;
441
+ const type = (_a = props_definition[prop]) == null ? void 0 : _a.type;
442
+ value = type === "Boolean" && typeof value !== "boolean" ? value != null : value;
443
+ if (!transform || !props_definition[prop]) {
444
+ return value;
445
+ } else if (transform === "toAttribute") {
446
+ switch (type) {
447
+ case "Object":
448
+ case "Array":
449
+ return value == null ? null : JSON.stringify(value);
450
+ case "Boolean":
451
+ return value ? "" : null;
452
+ case "Number":
453
+ return value == null ? null : value;
454
+ default:
455
+ return value;
456
+ }
457
+ } else {
458
+ switch (type) {
459
+ case "Object":
460
+ case "Array":
461
+ return value && JSON.parse(value);
462
+ case "Boolean":
463
+ return value;
464
+ // conversion already handled above
465
+ case "Number":
466
+ return value != null ? +value : value;
467
+ default:
468
+ return value;
469
+ }
470
+ }
471
+ }
472
+
473
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/ssr.js
474
+ function onMount2() {
475
+ }
166
476
 
167
- // ../../node_modules/.pnpm/svelte@3.57.0/node_modules/svelte/internal/index.mjs
168
- function noop() {
477
+ // src/components/index.ts
478
+ var __defProp2 = Object.defineProperty;
479
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
480
+ var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? `${key}` : key, value);
481
+ function noop2() {
169
482
  }
170
483
  function assign(tar, src) {
171
- for (const k in src)
172
- tar[k] = src[k];
173
- return tar;
484
+ for (const k in src) tar[k] = src[k];
485
+ return (
486
+ /** @type {T & S} */
487
+ tar
488
+ );
174
489
  }
175
- function run(fn) {
490
+ function run2(fn) {
176
491
  return fn();
177
492
  }
178
- function blank_object() {
493
+ function blank_object2() {
179
494
  return /* @__PURE__ */ Object.create(null);
180
495
  }
181
- function run_all(fns) {
182
- fns.forEach(run);
496
+ function run_all2(fns) {
497
+ fns.forEach(run2);
183
498
  }
184
- function is_function(thing) {
499
+ function is_function2(thing) {
185
500
  return typeof thing === "function";
186
501
  }
187
502
  function safe_not_equal(a, b) {
188
- return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function");
503
+ return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
189
504
  }
190
- function is_empty(obj) {
505
+ function is_empty2(obj) {
191
506
  return Object.keys(obj).length === 0;
192
507
  }
193
508
  function create_slot(definition, ctx, $$scope, fn) {
@@ -200,21 +515,8 @@ var OverlaysSvelte = (() => {
200
515
  return definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;
201
516
  }
202
517
  function get_slot_changes(definition, $$scope, dirty, fn) {
203
- if (definition[2] && fn) {
204
- const lets = definition[2](fn(dirty));
205
- if ($$scope.dirty === void 0) {
206
- return lets;
207
- }
208
- if (typeof lets === "object") {
209
- const merged = [];
210
- const len = Math.max($$scope.dirty.length, lets.length);
211
- for (let i = 0; i < len; i += 1) {
212
- merged[i] = $$scope.dirty[i] | lets[i];
213
- }
214
- return merged;
215
- }
216
- return $$scope.dirty | lets;
217
- }
518
+ if (definition[2] && fn)
519
+ ;
218
520
  return $$scope.dirty;
219
521
  }
220
522
  function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
@@ -234,17 +536,10 @@ var OverlaysSvelte = (() => {
234
536
  }
235
537
  return -1;
236
538
  }
237
- var is_hydrating = false;
238
- function start_hydrating() {
239
- is_hydrating = true;
240
- }
241
- function end_hydrating() {
242
- is_hydrating = false;
243
- }
244
- function insert(target, node, anchor) {
539
+ function insert2(target, node, anchor) {
245
540
  target.insertBefore(node, anchor || null);
246
541
  }
247
- function detach(node) {
542
+ function detach2(node) {
248
543
  if (node.parentNode) {
249
544
  node.parentNode.removeChild(node);
250
545
  }
@@ -255,65 +550,52 @@ var OverlaysSvelte = (() => {
255
550
  function empty() {
256
551
  return text("");
257
552
  }
258
- function children(element) {
259
- return Array.from(element.childNodes);
553
+ function children2(element2) {
554
+ return Array.from(element2.childNodes);
260
555
  }
261
- var current_component;
262
- function set_current_component(component) {
263
- current_component = component;
556
+ var current_component2;
557
+ function set_current_component2(component) {
558
+ current_component2 = component;
264
559
  }
265
- function get_current_component() {
266
- if (!current_component)
267
- throw new Error("Function called outside component initialization");
268
- return current_component;
269
- }
270
- function setContext(key, context2) {
271
- get_current_component().$$.context.set(key, context2);
272
- return context2;
273
- }
274
- function getContext(key) {
275
- return get_current_component().$$.context.get(key);
276
- }
277
- var dirty_components = [];
560
+ var dirty_components2 = [];
278
561
  var binding_callbacks = [];
279
562
  var render_callbacks = [];
280
563
  var flush_callbacks = [];
281
564
  var resolved_promise = /* @__PURE__ */ Promise.resolve();
282
565
  var update_scheduled = false;
283
- function schedule_update() {
566
+ function schedule_update2() {
284
567
  if (!update_scheduled) {
285
568
  update_scheduled = true;
286
- resolved_promise.then(flush);
569
+ resolved_promise.then(flush2);
287
570
  }
288
571
  }
289
- function add_render_callback(fn) {
572
+ function add_render_callback2(fn) {
290
573
  render_callbacks.push(fn);
291
574
  }
292
575
  var seen_callbacks = /* @__PURE__ */ new Set();
293
576
  var flushidx = 0;
294
- function flush() {
577
+ function flush2() {
295
578
  if (flushidx !== 0) {
296
579
  return;
297
580
  }
298
- const saved_component = current_component;
581
+ const saved_component = current_component2;
299
582
  do {
300
583
  try {
301
- while (flushidx < dirty_components.length) {
302
- const component = dirty_components[flushidx];
584
+ while (flushidx < dirty_components2.length) {
585
+ const component = dirty_components2[flushidx];
303
586
  flushidx++;
304
- set_current_component(component);
587
+ set_current_component2(component);
305
588
  update(component.$$);
306
589
  }
307
590
  } catch (e) {
308
- dirty_components.length = 0;
591
+ dirty_components2.length = 0;
309
592
  flushidx = 0;
310
593
  throw e;
311
594
  }
312
- set_current_component(null);
313
- dirty_components.length = 0;
595
+ set_current_component2(null);
596
+ dirty_components2.length = 0;
314
597
  flushidx = 0;
315
- while (binding_callbacks.length)
316
- binding_callbacks.pop()();
598
+ while (binding_callbacks.length) binding_callbacks.pop()();
317
599
  for (let i = 0; i < render_callbacks.length; i += 1) {
318
600
  const callback = render_callbacks[i];
319
601
  if (!seen_callbacks.has(callback)) {
@@ -322,34 +604,34 @@ var OverlaysSvelte = (() => {
322
604
  }
323
605
  }
324
606
  render_callbacks.length = 0;
325
- } while (dirty_components.length);
607
+ } while (dirty_components2.length);
326
608
  while (flush_callbacks.length) {
327
609
  flush_callbacks.pop()();
328
610
  }
329
611
  update_scheduled = false;
330
612
  seen_callbacks.clear();
331
- set_current_component(saved_component);
613
+ set_current_component2(saved_component);
332
614
  }
333
615
  function update($$) {
334
616
  if ($$.fragment !== null) {
335
617
  $$.update();
336
- run_all($$.before_update);
618
+ run_all2($$.before_update);
337
619
  const dirty = $$.dirty;
338
620
  $$.dirty = [-1];
339
621
  $$.fragment && $$.fragment.p($$.ctx, dirty);
340
- $$.after_update.forEach(add_render_callback);
622
+ $$.after_update.forEach(add_render_callback2);
341
623
  }
342
624
  }
343
- function flush_render_callbacks(fns) {
625
+ function flush_render_callbacks2(fns) {
344
626
  const filtered = [];
345
627
  const targets = [];
346
- render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c));
628
+ render_callbacks.forEach((c) => !fns.includes(c) ? filtered.push(c) : targets.push(c));
347
629
  targets.forEach((c) => c());
348
630
  render_callbacks = filtered;
349
631
  }
350
632
  var outroing = /* @__PURE__ */ new Set();
351
633
  var outros;
352
- function group_outros() {
634
+ function group_outros2() {
353
635
  outros = {
354
636
  r: 0,
355
637
  c: [],
@@ -357,19 +639,19 @@ var OverlaysSvelte = (() => {
357
639
  // parent group
358
640
  };
359
641
  }
360
- function check_outros() {
642
+ function check_outros2() {
361
643
  if (!outros.r) {
362
- run_all(outros.c);
644
+ run_all2(outros.c);
363
645
  }
364
646
  outros = outros.p;
365
647
  }
366
- function transition_in(block, local) {
648
+ function transition_in2(block, local) {
367
649
  if (block && block.i) {
368
650
  outroing.delete(block);
369
651
  block.i(local);
370
652
  }
371
653
  }
372
- function transition_out(block, local, detach2, callback) {
654
+ function transition_out2(block, local, detach22, callback) {
373
655
  if (block && block.o) {
374
656
  if (outroing.has(block))
375
657
  return;
@@ -377,7 +659,7 @@ var OverlaysSvelte = (() => {
377
659
  outros.c.push(() => {
378
660
  outroing.delete(block);
379
661
  if (callback) {
380
- if (detach2)
662
+ if (detach22)
381
663
  block.d(1);
382
664
  callback();
383
665
  }
@@ -387,57 +669,25 @@ var OverlaysSvelte = (() => {
387
669
  callback();
388
670
  }
389
671
  }
390
- var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : global;
391
- var _boolean_attributes = [
392
- "allowfullscreen",
393
- "allowpaymentrequest",
394
- "async",
395
- "autofocus",
396
- "autoplay",
397
- "checked",
398
- "controls",
399
- "default",
400
- "defer",
401
- "disabled",
402
- "formnovalidate",
403
- "hidden",
404
- "inert",
405
- "ismap",
406
- "itemscope",
407
- "loop",
408
- "multiple",
409
- "muted",
410
- "nomodule",
411
- "novalidate",
412
- "open",
413
- "playsinline",
414
- "readonly",
415
- "required",
416
- "reversed",
417
- "selected"
418
- ];
419
- var boolean_attributes = /* @__PURE__ */ new Set([..._boolean_attributes]);
420
- function mount_component(component, target, anchor, customElement) {
672
+ function mount_component(component, target, anchor) {
421
673
  const { fragment, after_update } = component.$$;
422
674
  fragment && fragment.m(target, anchor);
423
- if (!customElement) {
424
- add_render_callback(() => {
425
- const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
426
- if (component.$$.on_destroy) {
427
- component.$$.on_destroy.push(...new_on_destroy);
428
- } else {
429
- run_all(new_on_destroy);
430
- }
431
- component.$$.on_mount = [];
432
- });
433
- }
434
- after_update.forEach(add_render_callback);
675
+ add_render_callback2(() => {
676
+ const new_on_destroy = component.$$.on_mount.map(run2).filter(is_function2);
677
+ if (component.$$.on_destroy) {
678
+ component.$$.on_destroy.push(...new_on_destroy);
679
+ } else {
680
+ run_all2(new_on_destroy);
681
+ }
682
+ component.$$.on_mount = [];
683
+ });
684
+ after_update.forEach(add_render_callback2);
435
685
  }
436
686
  function destroy_component(component, detaching) {
437
687
  const $$ = component.$$;
438
688
  if ($$.fragment !== null) {
439
- flush_render_callbacks($$.after_update);
440
- run_all($$.on_destroy);
689
+ flush_render_callbacks2($$.after_update);
690
+ run_all2($$.on_destroy);
441
691
  $$.fragment && $$.fragment.d(detaching);
442
692
  $$.on_destroy = $$.fragment = null;
443
693
  $$.ctx = [];
@@ -445,23 +695,23 @@ var OverlaysSvelte = (() => {
445
695
  }
446
696
  function make_dirty(component, i) {
447
697
  if (component.$$.dirty[0] === -1) {
448
- dirty_components.push(component);
449
- schedule_update();
698
+ dirty_components2.push(component);
699
+ schedule_update2();
450
700
  component.$$.dirty.fill(0);
451
701
  }
452
702
  component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
453
703
  }
454
- function init(component, options, instance2, create_fragment2, not_equal, props, append_styles, dirty = [-1]) {
455
- const parent_component = current_component;
456
- set_current_component(component);
704
+ function init(component, options, instance2, create_fragment2, not_equal, props, append_styles = null, dirty = [-1]) {
705
+ const parent_component = current_component2;
706
+ set_current_component2(component);
457
707
  const $$ = component.$$ = {
458
708
  fragment: null,
459
709
  ctx: [],
460
710
  // state
461
711
  props,
462
- update: noop,
712
+ update: noop2,
463
713
  not_equal,
464
- bound: blank_object(),
714
+ bound: blank_object2(),
465
715
  // lifecycle
466
716
  on_mount: [],
467
717
  on_destroy: [],
@@ -470,7 +720,7 @@ var OverlaysSvelte = (() => {
470
720
  after_update: [],
471
721
  context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
472
722
  // everything else
473
- callbacks: blank_object(),
723
+ callbacks: blank_object2(),
474
724
  dirty,
475
725
  skip_bound: false,
476
726
  root: options.target || parent_component.$$.root
@@ -489,78 +739,42 @@ var OverlaysSvelte = (() => {
489
739
  }) : [];
490
740
  $$.update();
491
741
  ready = true;
492
- run_all($$.before_update);
742
+ run_all2($$.before_update);
493
743
  $$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false;
494
744
  if (options.target) {
495
745
  if (options.hydrate) {
496
- start_hydrating();
497
- const nodes = children(options.target);
746
+ const nodes = children2(options.target);
498
747
  $$.fragment && $$.fragment.l(nodes);
499
- nodes.forEach(detach);
748
+ nodes.forEach(detach2);
500
749
  } else {
501
750
  $$.fragment && $$.fragment.c();
502
751
  }
503
752
  if (options.intro)
504
- transition_in(component.$$.fragment);
505
- mount_component(component, options.target, options.anchor, options.customElement);
506
- end_hydrating();
507
- flush();
753
+ transition_in2(component.$$.fragment);
754
+ mount_component(component, options.target, options.anchor);
755
+ flush2();
508
756
  }
509
- set_current_component(parent_component);
757
+ set_current_component2(parent_component);
510
758
  }
511
- var SvelteElement;
512
- if (typeof HTMLElement === "function") {
513
- SvelteElement = class extends HTMLElement {
514
- constructor() {
515
- super();
516
- this.attachShadow({ mode: "open" });
517
- }
518
- connectedCallback() {
519
- const { on_mount } = this.$$;
520
- this.$$.on_disconnect = on_mount.map(run).filter(is_function);
521
- for (const key in this.$$.slotted) {
522
- this.appendChild(this.$$.slotted[key]);
523
- }
524
- }
525
- attributeChangedCallback(attr, _oldValue, newValue) {
526
- this[attr] = newValue;
527
- }
528
- disconnectedCallback() {
529
- run_all(this.$$.on_disconnect);
530
- }
531
- $destroy() {
532
- destroy_component(this, 1);
533
- this.$destroy = noop;
534
- }
535
- $on(type, callback) {
536
- if (!is_function(callback)) {
537
- return noop;
538
- }
539
- const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
540
- callbacks.push(callback);
541
- return () => {
542
- const index = callbacks.indexOf(callback);
543
- if (index !== -1)
544
- callbacks.splice(index, 1);
545
- };
546
- }
547
- $set($$props) {
548
- if (this.$$set && !is_empty($$props)) {
549
- this.$$.skip_bound = true;
550
- this.$$set($$props);
551
- this.$$.skip_bound = false;
552
- }
553
- }
554
- };
555
- }
556
- var SvelteComponent = class {
759
+ var SvelteComponent2 = class {
760
+ constructor() {
761
+ __publicField2(this, "$$");
762
+ __publicField2(this, "$$set");
763
+ }
764
+ /** @returns {void} */
557
765
  $destroy() {
558
766
  destroy_component(this, 1);
559
- this.$destroy = noop;
767
+ this.$destroy = noop2;
560
768
  }
769
+ /**
770
+ * @template {Extract<keyof Events, string>} K
771
+ * @param {K} type
772
+ * @param {((e: Events[K]) => void) | null | undefined} callback
773
+ * @returns {() => void}
774
+ */
561
775
  $on(type, callback) {
562
- if (!is_function(callback)) {
563
- return noop;
776
+ if (!is_function2(callback)) {
777
+ return noop2;
564
778
  }
565
779
  const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
566
780
  callbacks.push(callback);
@@ -570,49 +784,23 @@ var OverlaysSvelte = (() => {
570
784
  callbacks.splice(index, 1);
571
785
  };
572
786
  }
573
- $set($$props) {
574
- if (this.$$set && !is_empty($$props)) {
787
+ /**
788
+ * @param {Partial<Props>} props
789
+ * @returns {void}
790
+ */
791
+ $set(props) {
792
+ if (this.$$set && !is_empty2(props)) {
575
793
  this.$$.skip_bound = true;
576
- this.$$set($$props);
794
+ this.$$set(props);
577
795
  this.$$.skip_bound = false;
578
796
  }
579
797
  }
580
798
  };
581
- var SvelteComponentDev = class extends SvelteComponent {
582
- constructor(options) {
583
- if (!options || !options.target && !options.$$inline) {
584
- throw new Error("'target' is a required option");
585
- }
586
- super();
587
- }
588
- $destroy() {
589
- super.$destroy();
590
- this.$destroy = () => {
591
- console.warn("Component was already destroyed");
592
- };
593
- }
594
- $capture_state() {
595
- }
596
- $inject_state() {
597
- }
598
- };
599
- var SvelteComponentTyped = class extends SvelteComponentDev {
600
- constructor(options) {
601
- super(options);
602
- }
603
- };
604
-
605
- // ../../node_modules/.pnpm/svelte@3.57.0/node_modules/svelte/ssr.mjs
606
- function onMount() {
607
- }
608
-
609
- // src/composable/define.ts
610
- function useExtendOverlay(options = {}) {
611
- setContext(injectOptionsKey, options);
612
- return getContext(injectOverlayKey);
613
- }
614
-
615
- // src/components/index.ts
799
+ var PUBLIC_VERSION = "4";
800
+ if (typeof window !== "undefined")
801
+ (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
802
+ var injectOverlayKey = Symbol("overlays:svelte");
803
+ var injectOptionsKey = Symbol("overlays:options");
616
804
  function create_if_block(ctx) {
617
805
  let current;
618
806
  const default_slot_template = (
@@ -632,8 +820,9 @@ var OverlaysSvelte = (() => {
632
820
  default_slot.c();
633
821
  },
634
822
  m(target, anchor) {
635
- if (default_slot)
823
+ if (default_slot) {
636
824
  default_slot.m(target, anchor);
825
+ }
637
826
  current = true;
638
827
  },
639
828
  p(ctx2, dirty) {
@@ -663,11 +852,11 @@ var OverlaysSvelte = (() => {
663
852
  i(local) {
664
853
  if (current)
665
854
  return;
666
- transition_in(default_slot, local);
855
+ transition_in2(default_slot, local);
667
856
  current = true;
668
857
  },
669
858
  o(local) {
670
- transition_out(default_slot, local);
859
+ transition_out2(default_slot, local);
671
860
  current = false;
672
861
  },
673
862
  d(detaching) {
@@ -692,7 +881,7 @@ var OverlaysSvelte = (() => {
692
881
  m(target, anchor) {
693
882
  if (if_block)
694
883
  if_block.m(target, anchor);
695
- insert(target, if_block_anchor, anchor);
884
+ insert2(target, if_block_anchor, anchor);
696
885
  current = true;
697
886
  },
698
887
  p(ctx2, [dirty]) {
@@ -702,53 +891,53 @@ var OverlaysSvelte = (() => {
702
891
  ) {
703
892
  if (if_block) {
704
893
  if_block.p(ctx2, dirty);
705
- if (dirty & 1)
706
- transition_in(if_block, 1);
894
+ if (dirty & 1) {
895
+ transition_in2(if_block, 1);
896
+ }
707
897
  } else {
708
898
  if_block = create_if_block(ctx2);
709
899
  if_block.c();
710
- transition_in(if_block, 1);
900
+ transition_in2(if_block, 1);
711
901
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
712
902
  }
713
903
  } else if (if_block) {
714
- group_outros();
715
- transition_out(if_block, 1, 1, () => {
904
+ group_outros2();
905
+ transition_out2(if_block, 1, 1, () => {
716
906
  if_block = null;
717
907
  });
718
- check_outros();
908
+ check_outros2();
719
909
  }
720
910
  },
721
- i() {
911
+ i(local) {
722
912
  if (current)
723
913
  return;
724
- transition_in(if_block);
914
+ transition_in2(if_block);
725
915
  current = true;
726
916
  },
727
- o() {
728
- transition_out(if_block);
917
+ o(local) {
918
+ transition_out2(if_block);
729
919
  current = false;
730
920
  },
731
921
  d(detaching) {
922
+ if (detaching) {
923
+ detach2(if_block_anchor);
924
+ }
732
925
  if (if_block)
733
926
  if_block.d(detaching);
734
- if (detaching)
735
- detach(if_block_anchor);
736
927
  }
737
928
  };
738
929
  }
739
930
  function instance($$self, $$props, $$invalidate) {
740
931
  let { $$slots: slots = {}, $$scope } = $$props;
741
932
  let { visible = false } = $$props;
742
- const { duration = 0, immediate = true } = getContext(injectOptionsKey) || {};
933
+ const { duration = 0 } = getContext(injectOptionsKey) || {};
743
934
  const { deferred, vanish } = getContext(injectOverlayKey);
744
- async function destroy() {
935
+ deferred == null ? void 0 : deferred.finally(async () => {
745
936
  $$invalidate(0, visible = false);
746
937
  await delay(duration);
747
- vanish == null ? void 0 : vanish();
748
- return Promise.resolve();
749
- }
750
- onMount(() => immediate && $$invalidate(0, visible = true));
751
- deferred == null ? void 0 : deferred.then(destroy).catch(destroy);
938
+ vanish();
939
+ });
940
+ onMount2(() => $$invalidate(0, visible = true));
752
941
  $$self.$$set = ($$props2) => {
753
942
  if ("visible" in $$props2)
754
943
  $$invalidate(0, visible = $$props2.visible);
@@ -757,11 +946,48 @@ var OverlaysSvelte = (() => {
757
946
  };
758
947
  return [visible, $$scope, slots];
759
948
  }
760
- var Overlay = class extends SvelteComponentTyped {
949
+ var _Overlay = class extends SvelteComponent2 {
761
950
  constructor(options) {
762
- super(options);
763
- init(this, options, instance, create_fragment, safe_not_equal, { visible: 0 }, noop);
951
+ super();
952
+ init(this, options, instance, create_fragment, safe_not_equal, { visible: 0 });
764
953
  }
765
954
  };
766
- return __toCommonJS(src_exports);
955
+ var Overlay = _Overlay;
956
+
957
+ // src/internal/index.ts
958
+ var injectOverlayKey2 = Symbol("overlays:svelte");
959
+ var injectOptionsKey2 = Symbol("overlays:options");
960
+
961
+ // src/composable/define.ts
962
+ function useDisclosure(options = {}) {
963
+ setContext(injectOptionsKey2, options);
964
+ return getContext(injectOverlayKey2);
965
+ }
966
+
967
+ // src/define/constructor.ts
968
+ var constructor = createConstructor((Inst, props, options) => {
969
+ const { container, deferred, context: _context = /* @__PURE__ */ new Map() } = options;
970
+ function vanish() {
971
+ app.$destroy();
972
+ container.remove();
973
+ }
974
+ const context2 = new Map([..._context.entries()]);
975
+ context2.set(injectOverlayKey2, {
976
+ confirm: deferred.confirm,
977
+ cannel: deferred.cancel,
978
+ deferred,
979
+ visible: false,
980
+ vanish
981
+ });
982
+ const app = new Inst({
983
+ target: container,
984
+ props,
985
+ context: context2
986
+ });
987
+ });
988
+
989
+ // src/define/index.ts
990
+ var defineOverlay = constructor.define;
991
+ var renderOverlay = constructor.render;
992
+ return __toCommonJS(index_exports);
767
993
  })();