plossy 0.3.0 → 0.4.0
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/README.md +2 -0
- package/dist/plossy.bootstrap.css +1 -1
- package/dist/plossy.bootstrap.min.css +1 -1
- package/dist/plossy.core.css +227 -145
- package/dist/plossy.core.min.css +2 -2
- package/dist/plossy.css +552 -461
- package/dist/plossy.d.ts +25 -3
- package/dist/plossy.esm.js +195 -53
- package/dist/plossy.js +194 -53
- package/dist/plossy.min.css +2 -2
- package/dist/plossy.min.js +11 -11
- package/dist/presets/editorial.css +42 -41
- package/dist/presets/editorial.min.css +2 -2
- package/dist/presets/elegant.css +40 -40
- package/dist/presets/elegant.min.css +2 -2
- package/dist/presets/flat.css +42 -41
- package/dist/presets/flat.min.css +2 -2
- package/dist/presets/glass.css +23 -22
- package/dist/presets/glass.min.css +2 -2
- package/dist/presets/paper.css +42 -41
- package/dist/presets/paper.min.css +2 -2
- package/dist/presets/pop.css +48 -47
- package/dist/presets/pop.min.css +2 -2
- package/dist/presets/round.css +10 -10
- package/dist/presets/round.min.css +2 -2
- package/dist/presets/tender.css +45 -42
- package/dist/presets/tender.min.css +2 -2
- package/dist/presets/toy.css +42 -41
- package/dist/presets/toy.min.css +2 -2
- package/package.json +3 -2
package/dist/plossy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Plossy v0.
|
|
2
|
+
* Plossy v0.4.0 | MIT License
|
|
3
3
|
*
|
|
4
4
|
* Includes icons from Lucide (https://lucide.dev), some of them derived from Feather.
|
|
5
5
|
* Full third-party notices (also shipped as LICENSE-LUCIDE):
|
|
@@ -56,8 +56,18 @@
|
|
|
56
56
|
// src/js/core.js
|
|
57
57
|
var registry = /* @__PURE__ */ new Map();
|
|
58
58
|
var store = /* @__PURE__ */ new WeakMap();
|
|
59
|
+
var meta = /* @__PURE__ */ new WeakMap();
|
|
60
|
+
var dormant = /* @__PURE__ */ new WeakMap();
|
|
61
|
+
var dormantCount = 0;
|
|
62
|
+
var liveCount = 0;
|
|
63
|
+
var dormantGone = typeof FinalizationRegistry === "function" ? new FinalizationRegistry(() => dormantCount--) : null;
|
|
59
64
|
var started = false;
|
|
60
65
|
var selector = "";
|
|
66
|
+
var PERSIST = "data-pl-persist";
|
|
67
|
+
var config = {
|
|
68
|
+
/** Niszczy instancje elementów usuniętych z dokumentu. `false` — dawne zachowanie (instancje żyją dalej). */
|
|
69
|
+
autoDestroy: true
|
|
70
|
+
};
|
|
61
71
|
var api = {};
|
|
62
72
|
var $ = (sel, ctx = document) => typeof sel === "string" ? ctx.querySelector(sel) : sel || null;
|
|
63
73
|
var $$ = (sel, ctx = document) => typeof sel === "string" ? [...ctx.querySelectorAll(sel)] : sel ? sel instanceof Element ? [sel] : [...sel] : [];
|
|
@@ -119,34 +129,46 @@
|
|
|
119
129
|
}
|
|
120
130
|
var Component = class {
|
|
121
131
|
constructor(el, options = {}) {
|
|
122
|
-
const
|
|
132
|
+
const name = this.constructor.componentName;
|
|
123
133
|
this.el = el;
|
|
124
|
-
this
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
meta.set(this, { options, declarative: el.hasAttribute(`data-pl-${name}`), destroyed: false });
|
|
135
|
+
const destroy = this.destroy;
|
|
136
|
+
Object.defineProperty(this, "destroy", {
|
|
137
|
+
configurable: true,
|
|
138
|
+
writable: true,
|
|
139
|
+
value: () => {
|
|
140
|
+
const state = meta.get(this);
|
|
141
|
+
forget(this);
|
|
142
|
+
if (state.destroyed) return;
|
|
143
|
+
state.destroyed = true;
|
|
144
|
+
destroy.call(this);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
mount(this);
|
|
134
148
|
}
|
|
135
149
|
/** Punkt wejścia komponentu. Stan instancji ustawiaj tutaj (nie w polach klasy). */
|
|
136
150
|
init() {
|
|
137
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* AbortSignal bieżącego „życia" instancji — przerywany w destroy(), nowy po ponownym init().
|
|
154
|
+
* Przekazuj go do fetch() i sprawdzaj po każdym await (`if (signal.aborted) return`).
|
|
155
|
+
*/
|
|
156
|
+
get signal() {
|
|
157
|
+
return this._life.signal;
|
|
158
|
+
}
|
|
138
159
|
/** addEventListener z automatycznym sprzątaniem w destroy(). Zwraca funkcję odpinającą. */
|
|
139
160
|
on(target, type, handler, options) {
|
|
140
|
-
if (!target) return () => {
|
|
161
|
+
if (!target || meta.get(this)?.destroyed) return () => {
|
|
141
162
|
};
|
|
142
163
|
target.addEventListener(type, handler, options);
|
|
143
164
|
const off = () => target.removeEventListener(type, handler, options);
|
|
144
165
|
this._cleanup.push(off);
|
|
145
166
|
return off;
|
|
146
167
|
}
|
|
147
|
-
/** Rejestruje dowolną funkcję sprzątającą. */
|
|
168
|
+
/** Rejestruje dowolną funkcję sprzątającą. Po destroy() wywołuje ją od razu. */
|
|
148
169
|
onDestroy(fn) {
|
|
149
|
-
|
|
170
|
+
if (meta.get(this)?.destroyed) fn();
|
|
171
|
+
else this._cleanup.push(fn);
|
|
150
172
|
}
|
|
151
173
|
/**
|
|
152
174
|
* Wysyła zdarzenie `pl:{type}` na elemencie komponentu (bąbelkuje).
|
|
@@ -162,19 +184,114 @@
|
|
|
162
184
|
return !event.defaultPrevented;
|
|
163
185
|
}
|
|
164
186
|
destroy() {
|
|
165
|
-
|
|
166
|
-
|
|
187
|
+
const state = meta.get(this);
|
|
188
|
+
if (state) state.destroyed = true;
|
|
189
|
+
this._life?.abort();
|
|
190
|
+
const name = this.constructor.componentName;
|
|
191
|
+
for (const fn of this._cleanup.splice(0)) {
|
|
192
|
+
try {
|
|
193
|
+
fn();
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error(`[Plossy] ${name}:`, error);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const map = store.get(this.el);
|
|
199
|
+
if (map?.get(name) === this) {
|
|
200
|
+
map.delete(name);
|
|
201
|
+
liveCount--;
|
|
202
|
+
}
|
|
167
203
|
}
|
|
168
204
|
};
|
|
169
205
|
/** Domyślne opcje — nadpisywane w klasach potomnych. */
|
|
170
206
|
__publicField(Component, "defaults", {});
|
|
171
207
|
/** Nazwa opcji, do której trafia „goła" wartość atrybutu (np. data-pl-toggle="#cel"). */
|
|
172
208
|
__publicField(Component, "primary", null);
|
|
209
|
+
function mount(instance) {
|
|
210
|
+
const C = instance.constructor;
|
|
211
|
+
const el = instance.el;
|
|
212
|
+
const state = meta.get(instance);
|
|
213
|
+
instance.options = {
|
|
214
|
+
...C.defaults,
|
|
215
|
+
...parseOptions(el.getAttribute(`data-pl-${C.componentName}`), C.defaults, C.primary),
|
|
216
|
+
...state.options
|
|
217
|
+
};
|
|
218
|
+
instance._cleanup = [];
|
|
219
|
+
instance._life = new AbortController();
|
|
220
|
+
state.destroyed = false;
|
|
221
|
+
let map = store.get(el);
|
|
222
|
+
if (!map) store.set(el, map = /* @__PURE__ */ new Map());
|
|
223
|
+
if (!map.has(C.componentName)) liveCount++;
|
|
224
|
+
map.set(C.componentName, instance);
|
|
225
|
+
instance.init();
|
|
226
|
+
}
|
|
173
227
|
function getInstance(el, name) {
|
|
174
228
|
return store.get(el)?.get(name) || null;
|
|
175
229
|
}
|
|
176
230
|
function create(el, name, options) {
|
|
177
|
-
return getInstance(el, name) || new (registry.get(name))(el, options);
|
|
231
|
+
return getInstance(el, name) || wake(el, name) || new (registry.get(name))(el, options);
|
|
232
|
+
}
|
|
233
|
+
function keep(instance) {
|
|
234
|
+
const el = instance.el;
|
|
235
|
+
let map = dormant.get(el);
|
|
236
|
+
if (!map) {
|
|
237
|
+
dormant.set(el, map = /* @__PURE__ */ new Map());
|
|
238
|
+
dormantCount++;
|
|
239
|
+
dormantGone?.register(el, null, map);
|
|
240
|
+
}
|
|
241
|
+
map.set(instance.constructor.componentName, instance);
|
|
242
|
+
}
|
|
243
|
+
function forget(instance) {
|
|
244
|
+
const map = dormant.get(instance.el);
|
|
245
|
+
const name = instance.constructor.componentName;
|
|
246
|
+
if (map?.get(name) !== instance) return;
|
|
247
|
+
map.delete(name);
|
|
248
|
+
if (!map.size) {
|
|
249
|
+
dormant.delete(instance.el);
|
|
250
|
+
dormantCount--;
|
|
251
|
+
dormantGone?.unregister(map);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function wake(el, only) {
|
|
255
|
+
const map = dormant.get(el);
|
|
256
|
+
if (!map) return null;
|
|
257
|
+
let woken = null;
|
|
258
|
+
for (const [name, instance] of [...map]) {
|
|
259
|
+
if (only && name !== only) continue;
|
|
260
|
+
forget(instance);
|
|
261
|
+
if (getInstance(el, name) || meta.get(instance).declarative && !el.hasAttribute(`data-pl-${name}`)) continue;
|
|
262
|
+
try {
|
|
263
|
+
mount(instance);
|
|
264
|
+
woken = instance;
|
|
265
|
+
} catch (error) {
|
|
266
|
+
console.error(`[Plossy] ${name}:`, error);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return woken;
|
|
270
|
+
}
|
|
271
|
+
var subtree = (root) => root instanceof Element ? [root, ...root.querySelectorAll("*")] : [...root.querySelectorAll("*")];
|
|
272
|
+
function release(root) {
|
|
273
|
+
if (!liveCount || root.isConnected) return;
|
|
274
|
+
for (const el of subtree(root).reverse()) {
|
|
275
|
+
const map = store.get(el);
|
|
276
|
+
if (!map || el.isConnected || el.closest(`[${PERSIST}]`)) continue;
|
|
277
|
+
for (const [name, instance] of [...map]) {
|
|
278
|
+
if (map.get(name) !== instance) continue;
|
|
279
|
+
try {
|
|
280
|
+
instance.destroy();
|
|
281
|
+
} catch (error) {
|
|
282
|
+
console.error(`[Plossy] ${name}:`, error);
|
|
283
|
+
}
|
|
284
|
+
keep(instance);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
var removed = /* @__PURE__ */ new Set();
|
|
289
|
+
var releaseTimer = 0;
|
|
290
|
+
function flushRemoved() {
|
|
291
|
+
releaseTimer = 0;
|
|
292
|
+
const roots = [...removed];
|
|
293
|
+
removed.clear();
|
|
294
|
+
if (config.autoDestroy) roots.forEach(release);
|
|
178
295
|
}
|
|
179
296
|
function register(name, Class) {
|
|
180
297
|
Class.componentName = name;
|
|
@@ -191,6 +308,7 @@
|
|
|
191
308
|
return Class;
|
|
192
309
|
}
|
|
193
310
|
function scan(root = document) {
|
|
311
|
+
if (dormantCount) subtree(root).forEach((el) => wake(el));
|
|
194
312
|
if (!selector) return;
|
|
195
313
|
const nodes = [...root.querySelectorAll(selector)];
|
|
196
314
|
if (root instanceof Element && root.matches(selector)) nodes.unshift(root);
|
|
@@ -213,10 +331,16 @@
|
|
|
213
331
|
scan(document);
|
|
214
332
|
new MutationObserver((records) => {
|
|
215
333
|
for (const record of records) {
|
|
334
|
+
if (config.autoDestroy && !record.target.closest?.(`[${PERSIST}]`)) {
|
|
335
|
+
for (const node of record.removedNodes) {
|
|
336
|
+
if (node.nodeType === 1) removed.add(node);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
216
339
|
for (const node of record.addedNodes) {
|
|
217
|
-
if (node.nodeType === 1) scan(node);
|
|
340
|
+
if (node.nodeType === 1 && node.isConnected) scan(node);
|
|
218
341
|
}
|
|
219
342
|
}
|
|
343
|
+
if (removed.size && !releaseTimer) releaseTimer = setTimeout(flushRemoved);
|
|
220
344
|
}).observe(document.documentElement, { childList: true, subtree: true });
|
|
221
345
|
};
|
|
222
346
|
if (document.readyState === "loading") {
|
|
@@ -369,6 +493,7 @@
|
|
|
369
493
|
register,
|
|
370
494
|
scan,
|
|
371
495
|
getInstance,
|
|
496
|
+
config,
|
|
372
497
|
Component,
|
|
373
498
|
util: {
|
|
374
499
|
$,
|
|
@@ -1450,8 +1575,8 @@
|
|
|
1450
1575
|
const { file } = entry;
|
|
1451
1576
|
const ext = file.name.includes(".") ? file.name.split(".").pop().toUpperCase() : "";
|
|
1452
1577
|
const base = [formatSize(file.size), ext].filter(Boolean).join(" \xB7 ");
|
|
1453
|
-
const
|
|
1454
|
-
if (
|
|
1578
|
+
const meta2 = $(".pl-upload-meta", entry.el);
|
|
1579
|
+
if (meta2) meta2.textContent = text ? `${text}` : base;
|
|
1455
1580
|
entry.base = base;
|
|
1456
1581
|
}
|
|
1457
1582
|
find(target) {
|
|
@@ -1557,14 +1682,14 @@
|
|
|
1557
1682
|
}
|
|
1558
1683
|
/** Usuwa wszystkie pliki. */
|
|
1559
1684
|
clear(silent = false) {
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1685
|
+
const removed2 = this.entries.splice(0);
|
|
1686
|
+
removed2.forEach((entry) => {
|
|
1562
1687
|
this.release(entry);
|
|
1563
1688
|
entry.el.remove();
|
|
1564
1689
|
});
|
|
1565
1690
|
this.clearErrors();
|
|
1566
1691
|
this.sync();
|
|
1567
|
-
if (!silent)
|
|
1692
|
+
if (!silent) removed2.forEach((entry) => this.emit("remove", { file: entry.file }));
|
|
1568
1693
|
}
|
|
1569
1694
|
/** Utrzymuje `input.files` w zgodzie z listą — zwykły formularz wyśle to, co widać. */
|
|
1570
1695
|
sync() {
|
|
@@ -2504,13 +2629,15 @@
|
|
|
2504
2629
|
});
|
|
2505
2630
|
if (this.isSelect) {
|
|
2506
2631
|
this.on(this.el, "focus", () => input.focus());
|
|
2507
|
-
this.on(this.el.form, "reset", () => setTimeout(() => this.refresh()));
|
|
2632
|
+
this.on(this.el.form, "reset", () => setTimeout(() => !this.signal.aborted && this.refresh()));
|
|
2508
2633
|
} else {
|
|
2509
2634
|
this.on(input, "change", () => {
|
|
2510
2635
|
if (!this.syncing) this.emit("change", { value: input.value, item: null });
|
|
2511
2636
|
});
|
|
2512
2637
|
}
|
|
2513
|
-
|
|
2638
|
+
const { signal } = this;
|
|
2639
|
+
this.load = debounce((query) => !signal.aborted && this.fetch(query), options.delay);
|
|
2640
|
+
this.onDestroy(() => clearTimeout(this.typedTimer));
|
|
2514
2641
|
}
|
|
2515
2642
|
// ── Wartość ─────────────────────────────────────────────────────────────
|
|
2516
2643
|
get hasValue() {
|
|
@@ -2636,9 +2763,9 @@
|
|
|
2636
2763
|
setOptions(list, silent = false) {
|
|
2637
2764
|
const items = normalize(list);
|
|
2638
2765
|
if (this.isSelect) {
|
|
2639
|
-
const
|
|
2766
|
+
const keep2 = new Set(this.selected.map((item) => item.value));
|
|
2640
2767
|
[...this.el.options].forEach((option) => {
|
|
2641
|
-
if (option !== this.placeholderOption && !
|
|
2768
|
+
if (option !== this.placeholderOption && !keep2.has(option.value)) option.remove();
|
|
2642
2769
|
});
|
|
2643
2770
|
this.el.querySelectorAll("optgroup:empty").forEach((group) => group.remove());
|
|
2644
2771
|
for (const item of items) {
|
|
@@ -2683,16 +2810,17 @@
|
|
|
2683
2810
|
async fetch(query) {
|
|
2684
2811
|
const { options } = this;
|
|
2685
2812
|
const token2 = ++this.request;
|
|
2813
|
+
const { signal } = this;
|
|
2686
2814
|
try {
|
|
2687
2815
|
const source = options.source;
|
|
2688
|
-
const result = typeof source === "function" ? await source(query) : await fetch(`${source}${encodeURIComponent(query)}
|
|
2689
|
-
if (token2 !== this.request) return;
|
|
2816
|
+
const result = typeof source === "function" ? await source(query, { signal }) : await fetch(`${source}${encodeURIComponent(query)}`, { signal }).then((response) => response.json());
|
|
2817
|
+
if (signal.aborted || token2 !== this.request) return;
|
|
2690
2818
|
const items = normalize(result);
|
|
2691
2819
|
this.items = items.map((item) => this.selected.find((other) => other.value === item.value) || item);
|
|
2692
2820
|
this.setLoading(false);
|
|
2693
2821
|
if (this.isOpen) this.renderList(null, void 0, true);
|
|
2694
2822
|
} catch (error) {
|
|
2695
|
-
if (token2 !== this.request) return;
|
|
2823
|
+
if (signal.aborted || token2 !== this.request) return;
|
|
2696
2824
|
this.setLoading(false);
|
|
2697
2825
|
this.renderMessage("Nie uda\u0142o si\u0119 pobra\u0107 wynik\xF3w");
|
|
2698
2826
|
this.emit("error", { error });
|
|
@@ -2941,8 +3069,9 @@
|
|
|
2941
3069
|
if (this.isSelect) this.renderValue();
|
|
2942
3070
|
this.emit("close");
|
|
2943
3071
|
list.classList.add("pl-combobox-list-out");
|
|
3072
|
+
const { signal } = this;
|
|
2944
3073
|
await animationsDone(list);
|
|
2945
|
-
if (this.isOpen) return;
|
|
3074
|
+
if (signal.aborted || this.isOpen) return;
|
|
2946
3075
|
this.stopPlace?.();
|
|
2947
3076
|
this.stopPlace = null;
|
|
2948
3077
|
list.classList.remove("pl-combobox-list-out");
|
|
@@ -2967,7 +3096,7 @@
|
|
|
2967
3096
|
options: null,
|
|
2968
3097
|
// lista pozycji (JS)
|
|
2969
3098
|
source: null,
|
|
2970
|
-
// funkcja async (q) => [...] lub adres URL (doklejane ?q)
|
|
3099
|
+
// funkcja async (q, { signal }) => [...] lub adres URL (doklejane ?q)
|
|
2971
3100
|
minLength: 0,
|
|
2972
3101
|
// minimalna długość zapytania dla `source`
|
|
2973
3102
|
delay: 220,
|
|
@@ -3648,8 +3777,9 @@
|
|
|
3648
3777
|
if (focus || picker.contains(document.activeElement)) el.focus({ preventScroll: true });
|
|
3649
3778
|
this.emit("close");
|
|
3650
3779
|
picker.classList.add("pl-datepicker-out");
|
|
3780
|
+
const { signal } = this;
|
|
3651
3781
|
await animationsDone(picker);
|
|
3652
|
-
if (this.isOpen) return;
|
|
3782
|
+
if (signal.aborted || this.isOpen) return;
|
|
3653
3783
|
this.stopPlace?.();
|
|
3654
3784
|
this.stopPlace = null;
|
|
3655
3785
|
picker.classList.remove("pl-datepicker-out");
|
|
@@ -4513,6 +4643,7 @@
|
|
|
4513
4643
|
});
|
|
4514
4644
|
const { el, toggleEl } = this;
|
|
4515
4645
|
const token2 = ++this.token;
|
|
4646
|
+
const { signal } = this;
|
|
4516
4647
|
this.isOpen = true;
|
|
4517
4648
|
open.push(this);
|
|
4518
4649
|
el.classList.remove("pl-leave");
|
|
@@ -4530,7 +4661,7 @@
|
|
|
4530
4661
|
});
|
|
4531
4662
|
this.emit("show");
|
|
4532
4663
|
animationsDone(el).then(() => {
|
|
4533
|
-
if (token2 === this.token && this.isOpen) this.emit("shown");
|
|
4664
|
+
if (!signal.aborted && token2 === this.token && this.isOpen) this.emit("shown");
|
|
4534
4665
|
});
|
|
4535
4666
|
}
|
|
4536
4667
|
/** Zamyka drop; `refocus` przenosi fokus z powrotem na przełącznik. */
|
|
@@ -4543,6 +4674,7 @@
|
|
|
4543
4674
|
});
|
|
4544
4675
|
const { el, toggleEl } = this;
|
|
4545
4676
|
const token2 = ++this.token;
|
|
4677
|
+
const { signal } = this;
|
|
4546
4678
|
const hadFocus = el.contains(document.activeElement);
|
|
4547
4679
|
this.isOpen = false;
|
|
4548
4680
|
const index = open.indexOf(this);
|
|
@@ -4558,7 +4690,7 @@
|
|
|
4558
4690
|
el.classList.remove("pl-open");
|
|
4559
4691
|
this.emit("hide");
|
|
4560
4692
|
await animationsDone(el);
|
|
4561
|
-
if (token2 !== this.token) return;
|
|
4693
|
+
if (signal.aborted || token2 !== this.token) return;
|
|
4562
4694
|
this.teardown();
|
|
4563
4695
|
this.emit("hidden");
|
|
4564
4696
|
}
|
|
@@ -4958,6 +5090,7 @@
|
|
|
4958
5090
|
if (other !== this && !other.pop?.contains(el)) other.hide();
|
|
4959
5091
|
});
|
|
4960
5092
|
const token2 = ++this.token;
|
|
5093
|
+
const { signal } = this;
|
|
4961
5094
|
this.isOpen = true;
|
|
4962
5095
|
open2.push(this);
|
|
4963
5096
|
pop.classList.remove("pl-leave");
|
|
@@ -4974,7 +5107,7 @@
|
|
|
4974
5107
|
}
|
|
4975
5108
|
this.emit("show");
|
|
4976
5109
|
animationsDone(pop).then(() => {
|
|
4977
|
-
if (token2 === this.token && this.isOpen) this.emit("shown");
|
|
5110
|
+
if (!signal.aborted && token2 === this.token && this.isOpen) this.emit("shown");
|
|
4978
5111
|
});
|
|
4979
5112
|
}
|
|
4980
5113
|
/** Zamyka popover; `refocus` wymusza powrót fokusu na element wyzwalający. */
|
|
@@ -4987,6 +5120,7 @@
|
|
|
4987
5120
|
if (other !== this && pop.contains(other.el)) other.hide();
|
|
4988
5121
|
});
|
|
4989
5122
|
const token2 = ++this.token;
|
|
5123
|
+
const { signal } = this;
|
|
4990
5124
|
const hadFocus = pop.contains(document.activeElement);
|
|
4991
5125
|
this.isOpen = false;
|
|
4992
5126
|
const index = open2.indexOf(this);
|
|
@@ -5003,7 +5137,7 @@
|
|
|
5003
5137
|
pop.classList.remove("pl-open");
|
|
5004
5138
|
this.emit("hide");
|
|
5005
5139
|
await animationsDone(pop);
|
|
5006
|
-
if (token2 !== this.token) return;
|
|
5140
|
+
if (signal.aborted || token2 !== this.token) return;
|
|
5007
5141
|
this.teardown();
|
|
5008
5142
|
this.emit("hidden");
|
|
5009
5143
|
}
|
|
@@ -5135,8 +5269,9 @@
|
|
|
5135
5269
|
if (!this.options.stack) {
|
|
5136
5270
|
[...opened].filter((other) => other !== this && !other.el.contains(el)).forEach((other) => other.hide());
|
|
5137
5271
|
}
|
|
5138
|
-
this.opener = opener instanceof Element ? opener : document.activeElement;
|
|
5139
5272
|
if (!el.isConnected) document.body.append(el);
|
|
5273
|
+
if (getInstance(el, this.constructor.componentName) !== this) scan(el);
|
|
5274
|
+
this.opener = opener instanceof Element ? opener : document.activeElement;
|
|
5140
5275
|
el.classList.remove("pl-closing");
|
|
5141
5276
|
if (el.open) el.close();
|
|
5142
5277
|
this.state = "open";
|
|
@@ -5166,7 +5301,10 @@
|
|
|
5166
5301
|
this.state = "closing";
|
|
5167
5302
|
this.el.classList.add("pl-closing");
|
|
5168
5303
|
this.emit("hide");
|
|
5169
|
-
|
|
5304
|
+
const { signal } = this;
|
|
5305
|
+
this.closing = settle([this.el, this.panel]).then(() => {
|
|
5306
|
+
if (!signal.aborted) this.finish();
|
|
5307
|
+
});
|
|
5170
5308
|
return this.closing;
|
|
5171
5309
|
}
|
|
5172
5310
|
/** Domyka okno po animacji (lub natychmiast, gdy zamknęła je przeglądarka). */
|
|
@@ -5501,8 +5639,8 @@
|
|
|
5501
5639
|
action.className = "pl-notification-action";
|
|
5502
5640
|
action.textContent = String(options.action.label);
|
|
5503
5641
|
action.addEventListener("click", () => {
|
|
5504
|
-
const
|
|
5505
|
-
if (!
|
|
5642
|
+
const keep2 = options.action.onClick?.(this.handle) === false;
|
|
5643
|
+
if (!keep2) this.close();
|
|
5506
5644
|
});
|
|
5507
5645
|
content.append(action);
|
|
5508
5646
|
}
|
|
@@ -6643,6 +6781,7 @@
|
|
|
6643
6781
|
if (panel) tab.setAttribute("aria-controls", panel.id || (panel.id = uid("pl-panel")));
|
|
6644
6782
|
});
|
|
6645
6783
|
const token2 = ++this.token;
|
|
6784
|
+
const { signal } = this;
|
|
6646
6785
|
const detail = { index, previous, item: items[index] };
|
|
6647
6786
|
if (animate && previous > -1) this.emit("hide", { index: previous, item: items[previous] });
|
|
6648
6787
|
const pending = [];
|
|
@@ -6668,7 +6807,7 @@
|
|
|
6668
6807
|
if (hash && hash !== location.hash) history.replaceState(null, "", hash);
|
|
6669
6808
|
}
|
|
6670
6809
|
Promise.all(pending).then(() => {
|
|
6671
|
-
if (token2 === this.token) this.emit("shown", detail);
|
|
6810
|
+
if (!signal.aborted && token2 === this.token) this.emit("shown", detail);
|
|
6672
6811
|
});
|
|
6673
6812
|
}
|
|
6674
6813
|
async animateIn(panel, forward) {
|
|
@@ -7613,7 +7752,8 @@
|
|
|
7613
7752
|
this.index = 0;
|
|
7614
7753
|
this.pauses = /* @__PURE__ */ new Set();
|
|
7615
7754
|
this.autoplayOn = Boolean(this.options.autoplay);
|
|
7616
|
-
this.generatedNavs = /* @__PURE__ */ new
|
|
7755
|
+
this.generatedNavs = /* @__PURE__ */ new Set();
|
|
7756
|
+
this.onDestroy(() => this.generatedNavs.forEach((nav) => nav.replaceChildren()));
|
|
7617
7757
|
this._timer = 0;
|
|
7618
7758
|
this._remaining = 0;
|
|
7619
7759
|
this._startedAt = 0;
|
|
@@ -8100,13 +8240,13 @@
|
|
|
8100
8240
|
d.tracker.add(event.clientX, event.timeStamp);
|
|
8101
8241
|
this.render();
|
|
8102
8242
|
});
|
|
8103
|
-
const
|
|
8243
|
+
const release2 = (event) => {
|
|
8104
8244
|
const d = this.drag;
|
|
8105
8245
|
if (!d || event.pointerId !== d.id) return;
|
|
8106
8246
|
this.endDrag(event.type === "pointercancel", event.timeStamp);
|
|
8107
8247
|
};
|
|
8108
|
-
this.on(window, "pointerup",
|
|
8109
|
-
this.on(window, "pointercancel",
|
|
8248
|
+
this.on(window, "pointerup", release2);
|
|
8249
|
+
this.on(window, "pointercancel", release2);
|
|
8110
8250
|
this.on(
|
|
8111
8251
|
c,
|
|
8112
8252
|
"click",
|
|
@@ -8414,7 +8554,7 @@
|
|
|
8414
8554
|
d.tracker.add(event.clientX, event.timeStamp);
|
|
8415
8555
|
this.renderTransition();
|
|
8416
8556
|
});
|
|
8417
|
-
const
|
|
8557
|
+
const release2 = (event) => {
|
|
8418
8558
|
const d = this.drag;
|
|
8419
8559
|
if (!d || event.pointerId !== d.id) return;
|
|
8420
8560
|
this.drag = null;
|
|
@@ -8433,8 +8573,8 @@
|
|
|
8433
8573
|
if (forward && this.commit()) this.run(1, v);
|
|
8434
8574
|
else this.run(0, v);
|
|
8435
8575
|
};
|
|
8436
|
-
this.on(window, "pointerup",
|
|
8437
|
-
this.on(window, "pointercancel",
|
|
8576
|
+
this.on(window, "pointerup", release2);
|
|
8577
|
+
this.on(window, "pointercancel", release2);
|
|
8438
8578
|
this.on(
|
|
8439
8579
|
c,
|
|
8440
8580
|
"click",
|
|
@@ -9238,8 +9378,9 @@
|
|
|
9238
9378
|
this.ready = true;
|
|
9239
9379
|
if (this.wanted) this.play();
|
|
9240
9380
|
});
|
|
9381
|
+
const { signal } = this;
|
|
9241
9382
|
setTimeout(() => {
|
|
9242
|
-
if (this.ready) return;
|
|
9383
|
+
if (signal.aborted || this.ready) return;
|
|
9243
9384
|
this.ready = true;
|
|
9244
9385
|
if (this.wanted) this.play();
|
|
9245
9386
|
}, 1500);
|
|
@@ -9315,9 +9456,9 @@
|
|
|
9315
9456
|
this.emit("play");
|
|
9316
9457
|
}
|
|
9317
9458
|
/** `keep` — zachowaj zamiar odtwarzania (wznowienie po powrocie na kartę). */
|
|
9318
|
-
pause(
|
|
9459
|
+
pause(keep2 = false) {
|
|
9319
9460
|
const { el, options } = this;
|
|
9320
|
-
if (!
|
|
9461
|
+
if (!keep2) this.wanted = false;
|
|
9321
9462
|
if (!this.ready) return;
|
|
9322
9463
|
if (this.native) {
|
|
9323
9464
|
el.pause();
|