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.d.ts
CHANGED
|
@@ -40,16 +40,32 @@ export class Component<O = Record<string, any>> {
|
|
|
40
40
|
|
|
41
41
|
/** Punkt wejścia komponentu — nadpisywany w klasach potomnych. */
|
|
42
42
|
init(): void;
|
|
43
|
+
/** Sygnał bieżącego „życia" instancji: przerywany w `destroy()`, nowy po ponownym `init()`. */
|
|
44
|
+
readonly signal: AbortSignal;
|
|
43
45
|
/** `addEventListener` z automatycznym sprzątaniem w `destroy()`. Zwraca funkcję odpinającą. */
|
|
44
46
|
on(target: EventTarget | null | undefined, type: string, handler: (event: any) => void, options?: boolean | AddEventListenerOptions): () => void;
|
|
45
|
-
/** Rejestruje funkcję sprzątającą wywoływaną w `destroy()
|
|
47
|
+
/** Rejestruje funkcję sprzątającą wywoływaną w `destroy()` (po `destroy()` — wywołuje ją od razu). */
|
|
46
48
|
onDestroy(fn: () => void): void;
|
|
47
49
|
/** Wysyła zdarzenie `pl:{type}` na elemencie. Zwraca `false`, gdy anulowano je przez `preventDefault()`. */
|
|
48
50
|
emit(type: string, detail?: Record<string, any>, cancelable?: boolean): boolean;
|
|
49
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Odpina zdarzenia i usuwa instancję z elementu. Kolejne wywołania nic nie robią.
|
|
53
|
+
* Wywoływane automatycznie, gdy element zostanie usunięty z dokumentu (zob. `PlossyConfig.autoDestroy`).
|
|
54
|
+
*/
|
|
50
55
|
destroy(): void;
|
|
51
56
|
}
|
|
52
57
|
|
|
58
|
+
/** Ustawienia globalne — `Plossy.config`. */
|
|
59
|
+
export interface PlossyConfig {
|
|
60
|
+
/**
|
|
61
|
+
* Niszczy instancje elementów usuniętych z dokumentu (domyślnie `true`). Elementy przenoszone
|
|
62
|
+
* w obrębie DOM zachowują instancje; po ponownym wstawieniu elementu wraca ta sama instancja.
|
|
63
|
+
* Nie są niszczone elementy z atrybutem `data-pl-persist` (i ich potomkowie) ani dzieci wyjmowane
|
|
64
|
+
* z kontenera z tym atrybutem. `false` — dawne zachowanie.
|
|
65
|
+
*/
|
|
66
|
+
autoDestroy: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
// ── Opcje komponentów ─────────────────────────────────────────────────────
|
|
54
70
|
|
|
55
71
|
export interface ComboboxItem {
|
|
@@ -97,7 +113,10 @@ export interface ComboboxOptions {
|
|
|
97
113
|
/** Lista pozycji (JS) */
|
|
98
114
|
options?: Array<string | ComboboxItem> | string | null;
|
|
99
115
|
/** Funkcja async (q) => [...] lub adres URL (doklejane ?q) */
|
|
100
|
-
source?:
|
|
116
|
+
source?:
|
|
117
|
+
| string
|
|
118
|
+
| ((query: string, context: { signal: AbortSignal }) => ComboboxItem[] | string[] | Promise<ComboboxItem[] | string[]>)
|
|
119
|
+
| null;
|
|
101
120
|
/** Minimalna długość zapytania dla `source`. */
|
|
102
121
|
minLength?: number;
|
|
103
122
|
/** Opóźnienie zapytań `source` (ms) */
|
|
@@ -1101,6 +1120,8 @@ export interface PlossyApi {
|
|
|
1101
1120
|
/** Inicjalizuje komponenty w podanym fragmencie (zwykle dzieje się to samo). */
|
|
1102
1121
|
scan(root?: ParentNode): void;
|
|
1103
1122
|
getInstance<C = Component<any>>(el: Element, name: string): C | null;
|
|
1123
|
+
/** Ustawienia globalne. */
|
|
1124
|
+
config: PlossyConfig;
|
|
1104
1125
|
Component: typeof Component;
|
|
1105
1126
|
util: PlossyUtil;
|
|
1106
1127
|
|
|
@@ -1117,6 +1138,7 @@ export const api: PlossyApi;
|
|
|
1117
1138
|
export const register: PlossyApi['register'];
|
|
1118
1139
|
export const scan: PlossyApi['scan'];
|
|
1119
1140
|
export const getInstance: PlossyApi['getInstance'];
|
|
1141
|
+
export const config: PlossyConfig;
|
|
1120
1142
|
/** Uruchamia automatyczną inicjalizację (przy imporcie w przeglądarce dzieje się to samo). */
|
|
1121
1143
|
export function start(): void;
|
|
1122
1144
|
|
package/dist/plossy.esm.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):
|
|
@@ -55,8 +55,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
55
55
|
// src/js/core.js
|
|
56
56
|
var registry = /* @__PURE__ */ new Map();
|
|
57
57
|
var store = /* @__PURE__ */ new WeakMap();
|
|
58
|
+
var meta = /* @__PURE__ */ new WeakMap();
|
|
59
|
+
var dormant = /* @__PURE__ */ new WeakMap();
|
|
60
|
+
var dormantCount = 0;
|
|
61
|
+
var liveCount = 0;
|
|
62
|
+
var dormantGone = typeof FinalizationRegistry === "function" ? new FinalizationRegistry(() => dormantCount--) : null;
|
|
58
63
|
var started = false;
|
|
59
64
|
var selector = "";
|
|
65
|
+
var PERSIST = "data-pl-persist";
|
|
66
|
+
var config = {
|
|
67
|
+
/** Niszczy instancje elementów usuniętych z dokumentu. `false` — dawne zachowanie (instancje żyją dalej). */
|
|
68
|
+
autoDestroy: true
|
|
69
|
+
};
|
|
60
70
|
var api = {};
|
|
61
71
|
var $ = (sel, ctx = document) => typeof sel === "string" ? ctx.querySelector(sel) : sel || null;
|
|
62
72
|
var $$ = (sel, ctx = document) => typeof sel === "string" ? [...ctx.querySelectorAll(sel)] : sel ? sel instanceof Element ? [sel] : [...sel] : [];
|
|
@@ -118,34 +128,46 @@ function parseOptions(str, defaults = {}, primary = null) {
|
|
|
118
128
|
}
|
|
119
129
|
var Component = class {
|
|
120
130
|
constructor(el, options = {}) {
|
|
121
|
-
const
|
|
131
|
+
const name = this.constructor.componentName;
|
|
122
132
|
this.el = el;
|
|
123
|
-
this
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
meta.set(this, { options, declarative: el.hasAttribute(`data-pl-${name}`), destroyed: false });
|
|
134
|
+
const destroy = this.destroy;
|
|
135
|
+
Object.defineProperty(this, "destroy", {
|
|
136
|
+
configurable: true,
|
|
137
|
+
writable: true,
|
|
138
|
+
value: () => {
|
|
139
|
+
const state = meta.get(this);
|
|
140
|
+
forget(this);
|
|
141
|
+
if (state.destroyed) return;
|
|
142
|
+
state.destroyed = true;
|
|
143
|
+
destroy.call(this);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
mount(this);
|
|
133
147
|
}
|
|
134
148
|
/** Punkt wejścia komponentu. Stan instancji ustawiaj tutaj (nie w polach klasy). */
|
|
135
149
|
init() {
|
|
136
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* AbortSignal bieżącego „życia" instancji — przerywany w destroy(), nowy po ponownym init().
|
|
153
|
+
* Przekazuj go do fetch() i sprawdzaj po każdym await (`if (signal.aborted) return`).
|
|
154
|
+
*/
|
|
155
|
+
get signal() {
|
|
156
|
+
return this._life.signal;
|
|
157
|
+
}
|
|
137
158
|
/** addEventListener z automatycznym sprzątaniem w destroy(). Zwraca funkcję odpinającą. */
|
|
138
159
|
on(target, type, handler, options) {
|
|
139
|
-
if (!target) return () => {
|
|
160
|
+
if (!target || meta.get(this)?.destroyed) return () => {
|
|
140
161
|
};
|
|
141
162
|
target.addEventListener(type, handler, options);
|
|
142
163
|
const off = () => target.removeEventListener(type, handler, options);
|
|
143
164
|
this._cleanup.push(off);
|
|
144
165
|
return off;
|
|
145
166
|
}
|
|
146
|
-
/** Rejestruje dowolną funkcję sprzątającą. */
|
|
167
|
+
/** Rejestruje dowolną funkcję sprzątającą. Po destroy() wywołuje ją od razu. */
|
|
147
168
|
onDestroy(fn) {
|
|
148
|
-
|
|
169
|
+
if (meta.get(this)?.destroyed) fn();
|
|
170
|
+
else this._cleanup.push(fn);
|
|
149
171
|
}
|
|
150
172
|
/**
|
|
151
173
|
* Wysyła zdarzenie `pl:{type}` na elemencie komponentu (bąbelkuje).
|
|
@@ -161,19 +183,114 @@ var Component = class {
|
|
|
161
183
|
return !event.defaultPrevented;
|
|
162
184
|
}
|
|
163
185
|
destroy() {
|
|
164
|
-
|
|
165
|
-
|
|
186
|
+
const state = meta.get(this);
|
|
187
|
+
if (state) state.destroyed = true;
|
|
188
|
+
this._life?.abort();
|
|
189
|
+
const name = this.constructor.componentName;
|
|
190
|
+
for (const fn of this._cleanup.splice(0)) {
|
|
191
|
+
try {
|
|
192
|
+
fn();
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error(`[Plossy] ${name}:`, error);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const map = store.get(this.el);
|
|
198
|
+
if (map?.get(name) === this) {
|
|
199
|
+
map.delete(name);
|
|
200
|
+
liveCount--;
|
|
201
|
+
}
|
|
166
202
|
}
|
|
167
203
|
};
|
|
168
204
|
/** Domyślne opcje — nadpisywane w klasach potomnych. */
|
|
169
205
|
__publicField(Component, "defaults", {});
|
|
170
206
|
/** Nazwa opcji, do której trafia „goła" wartość atrybutu (np. data-pl-toggle="#cel"). */
|
|
171
207
|
__publicField(Component, "primary", null);
|
|
208
|
+
function mount(instance) {
|
|
209
|
+
const C = instance.constructor;
|
|
210
|
+
const el = instance.el;
|
|
211
|
+
const state = meta.get(instance);
|
|
212
|
+
instance.options = {
|
|
213
|
+
...C.defaults,
|
|
214
|
+
...parseOptions(el.getAttribute(`data-pl-${C.componentName}`), C.defaults, C.primary),
|
|
215
|
+
...state.options
|
|
216
|
+
};
|
|
217
|
+
instance._cleanup = [];
|
|
218
|
+
instance._life = new AbortController();
|
|
219
|
+
state.destroyed = false;
|
|
220
|
+
let map = store.get(el);
|
|
221
|
+
if (!map) store.set(el, map = /* @__PURE__ */ new Map());
|
|
222
|
+
if (!map.has(C.componentName)) liveCount++;
|
|
223
|
+
map.set(C.componentName, instance);
|
|
224
|
+
instance.init();
|
|
225
|
+
}
|
|
172
226
|
function getInstance(el, name) {
|
|
173
227
|
return store.get(el)?.get(name) || null;
|
|
174
228
|
}
|
|
175
229
|
function create(el, name, options) {
|
|
176
|
-
return getInstance(el, name) || new (registry.get(name))(el, options);
|
|
230
|
+
return getInstance(el, name) || wake(el, name) || new (registry.get(name))(el, options);
|
|
231
|
+
}
|
|
232
|
+
function keep(instance) {
|
|
233
|
+
const el = instance.el;
|
|
234
|
+
let map = dormant.get(el);
|
|
235
|
+
if (!map) {
|
|
236
|
+
dormant.set(el, map = /* @__PURE__ */ new Map());
|
|
237
|
+
dormantCount++;
|
|
238
|
+
dormantGone?.register(el, null, map);
|
|
239
|
+
}
|
|
240
|
+
map.set(instance.constructor.componentName, instance);
|
|
241
|
+
}
|
|
242
|
+
function forget(instance) {
|
|
243
|
+
const map = dormant.get(instance.el);
|
|
244
|
+
const name = instance.constructor.componentName;
|
|
245
|
+
if (map?.get(name) !== instance) return;
|
|
246
|
+
map.delete(name);
|
|
247
|
+
if (!map.size) {
|
|
248
|
+
dormant.delete(instance.el);
|
|
249
|
+
dormantCount--;
|
|
250
|
+
dormantGone?.unregister(map);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function wake(el, only) {
|
|
254
|
+
const map = dormant.get(el);
|
|
255
|
+
if (!map) return null;
|
|
256
|
+
let woken = null;
|
|
257
|
+
for (const [name, instance] of [...map]) {
|
|
258
|
+
if (only && name !== only) continue;
|
|
259
|
+
forget(instance);
|
|
260
|
+
if (getInstance(el, name) || meta.get(instance).declarative && !el.hasAttribute(`data-pl-${name}`)) continue;
|
|
261
|
+
try {
|
|
262
|
+
mount(instance);
|
|
263
|
+
woken = instance;
|
|
264
|
+
} catch (error) {
|
|
265
|
+
console.error(`[Plossy] ${name}:`, error);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return woken;
|
|
269
|
+
}
|
|
270
|
+
var subtree = (root) => root instanceof Element ? [root, ...root.querySelectorAll("*")] : [...root.querySelectorAll("*")];
|
|
271
|
+
function release(root) {
|
|
272
|
+
if (!liveCount || root.isConnected) return;
|
|
273
|
+
for (const el of subtree(root).reverse()) {
|
|
274
|
+
const map = store.get(el);
|
|
275
|
+
if (!map || el.isConnected || el.closest(`[${PERSIST}]`)) continue;
|
|
276
|
+
for (const [name, instance] of [...map]) {
|
|
277
|
+
if (map.get(name) !== instance) continue;
|
|
278
|
+
try {
|
|
279
|
+
instance.destroy();
|
|
280
|
+
} catch (error) {
|
|
281
|
+
console.error(`[Plossy] ${name}:`, error);
|
|
282
|
+
}
|
|
283
|
+
keep(instance);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
var removed = /* @__PURE__ */ new Set();
|
|
288
|
+
var releaseTimer = 0;
|
|
289
|
+
function flushRemoved() {
|
|
290
|
+
releaseTimer = 0;
|
|
291
|
+
const roots = [...removed];
|
|
292
|
+
removed.clear();
|
|
293
|
+
if (config.autoDestroy) roots.forEach(release);
|
|
177
294
|
}
|
|
178
295
|
function register(name, Class) {
|
|
179
296
|
Class.componentName = name;
|
|
@@ -190,6 +307,7 @@ function register(name, Class) {
|
|
|
190
307
|
return Class;
|
|
191
308
|
}
|
|
192
309
|
function scan(root = document) {
|
|
310
|
+
if (dormantCount) subtree(root).forEach((el) => wake(el));
|
|
193
311
|
if (!selector) return;
|
|
194
312
|
const nodes = [...root.querySelectorAll(selector)];
|
|
195
313
|
if (root instanceof Element && root.matches(selector)) nodes.unshift(root);
|
|
@@ -212,10 +330,16 @@ function start() {
|
|
|
212
330
|
scan(document);
|
|
213
331
|
new MutationObserver((records) => {
|
|
214
332
|
for (const record of records) {
|
|
333
|
+
if (config.autoDestroy && !record.target.closest?.(`[${PERSIST}]`)) {
|
|
334
|
+
for (const node of record.removedNodes) {
|
|
335
|
+
if (node.nodeType === 1) removed.add(node);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
215
338
|
for (const node of record.addedNodes) {
|
|
216
|
-
if (node.nodeType === 1) scan(node);
|
|
339
|
+
if (node.nodeType === 1 && node.isConnected) scan(node);
|
|
217
340
|
}
|
|
218
341
|
}
|
|
342
|
+
if (removed.size && !releaseTimer) releaseTimer = setTimeout(flushRemoved);
|
|
219
343
|
}).observe(document.documentElement, { childList: true, subtree: true });
|
|
220
344
|
};
|
|
221
345
|
if (document.readyState === "loading") {
|
|
@@ -368,6 +492,7 @@ Object.assign(api, {
|
|
|
368
492
|
register,
|
|
369
493
|
scan,
|
|
370
494
|
getInstance,
|
|
495
|
+
config,
|
|
371
496
|
Component,
|
|
372
497
|
util: {
|
|
373
498
|
$,
|
|
@@ -1449,8 +1574,8 @@ var Upload = class extends Component {
|
|
|
1449
1574
|
const { file } = entry;
|
|
1450
1575
|
const ext = file.name.includes(".") ? file.name.split(".").pop().toUpperCase() : "";
|
|
1451
1576
|
const base = [formatSize(file.size), ext].filter(Boolean).join(" \xB7 ");
|
|
1452
|
-
const
|
|
1453
|
-
if (
|
|
1577
|
+
const meta2 = $(".pl-upload-meta", entry.el);
|
|
1578
|
+
if (meta2) meta2.textContent = text ? `${text}` : base;
|
|
1454
1579
|
entry.base = base;
|
|
1455
1580
|
}
|
|
1456
1581
|
find(target) {
|
|
@@ -1556,14 +1681,14 @@ var Upload = class extends Component {
|
|
|
1556
1681
|
}
|
|
1557
1682
|
/** Usuwa wszystkie pliki. */
|
|
1558
1683
|
clear(silent = false) {
|
|
1559
|
-
const
|
|
1560
|
-
|
|
1684
|
+
const removed2 = this.entries.splice(0);
|
|
1685
|
+
removed2.forEach((entry) => {
|
|
1561
1686
|
this.release(entry);
|
|
1562
1687
|
entry.el.remove();
|
|
1563
1688
|
});
|
|
1564
1689
|
this.clearErrors();
|
|
1565
1690
|
this.sync();
|
|
1566
|
-
if (!silent)
|
|
1691
|
+
if (!silent) removed2.forEach((entry) => this.emit("remove", { file: entry.file }));
|
|
1567
1692
|
}
|
|
1568
1693
|
/** Utrzymuje `input.files` w zgodzie z listą — zwykły formularz wyśle to, co widać. */
|
|
1569
1694
|
sync() {
|
|
@@ -2503,13 +2628,15 @@ var Combobox = class extends Component {
|
|
|
2503
2628
|
});
|
|
2504
2629
|
if (this.isSelect) {
|
|
2505
2630
|
this.on(this.el, "focus", () => input.focus());
|
|
2506
|
-
this.on(this.el.form, "reset", () => setTimeout(() => this.refresh()));
|
|
2631
|
+
this.on(this.el.form, "reset", () => setTimeout(() => !this.signal.aborted && this.refresh()));
|
|
2507
2632
|
} else {
|
|
2508
2633
|
this.on(input, "change", () => {
|
|
2509
2634
|
if (!this.syncing) this.emit("change", { value: input.value, item: null });
|
|
2510
2635
|
});
|
|
2511
2636
|
}
|
|
2512
|
-
|
|
2637
|
+
const { signal } = this;
|
|
2638
|
+
this.load = debounce((query) => !signal.aborted && this.fetch(query), options.delay);
|
|
2639
|
+
this.onDestroy(() => clearTimeout(this.typedTimer));
|
|
2513
2640
|
}
|
|
2514
2641
|
// ── Wartość ─────────────────────────────────────────────────────────────
|
|
2515
2642
|
get hasValue() {
|
|
@@ -2635,9 +2762,9 @@ var Combobox = class extends Component {
|
|
|
2635
2762
|
setOptions(list, silent = false) {
|
|
2636
2763
|
const items = normalize(list);
|
|
2637
2764
|
if (this.isSelect) {
|
|
2638
|
-
const
|
|
2765
|
+
const keep2 = new Set(this.selected.map((item) => item.value));
|
|
2639
2766
|
[...this.el.options].forEach((option) => {
|
|
2640
|
-
if (option !== this.placeholderOption && !
|
|
2767
|
+
if (option !== this.placeholderOption && !keep2.has(option.value)) option.remove();
|
|
2641
2768
|
});
|
|
2642
2769
|
this.el.querySelectorAll("optgroup:empty").forEach((group) => group.remove());
|
|
2643
2770
|
for (const item of items) {
|
|
@@ -2682,16 +2809,17 @@ var Combobox = class extends Component {
|
|
|
2682
2809
|
async fetch(query) {
|
|
2683
2810
|
const { options } = this;
|
|
2684
2811
|
const token2 = ++this.request;
|
|
2812
|
+
const { signal } = this;
|
|
2685
2813
|
try {
|
|
2686
2814
|
const source = options.source;
|
|
2687
|
-
const result = typeof source === "function" ? await source(query) : await fetch(`${source}${encodeURIComponent(query)}
|
|
2688
|
-
if (token2 !== this.request) return;
|
|
2815
|
+
const result = typeof source === "function" ? await source(query, { signal }) : await fetch(`${source}${encodeURIComponent(query)}`, { signal }).then((response) => response.json());
|
|
2816
|
+
if (signal.aborted || token2 !== this.request) return;
|
|
2689
2817
|
const items = normalize(result);
|
|
2690
2818
|
this.items = items.map((item) => this.selected.find((other) => other.value === item.value) || item);
|
|
2691
2819
|
this.setLoading(false);
|
|
2692
2820
|
if (this.isOpen) this.renderList(null, void 0, true);
|
|
2693
2821
|
} catch (error) {
|
|
2694
|
-
if (token2 !== this.request) return;
|
|
2822
|
+
if (signal.aborted || token2 !== this.request) return;
|
|
2695
2823
|
this.setLoading(false);
|
|
2696
2824
|
this.renderMessage("Nie uda\u0142o si\u0119 pobra\u0107 wynik\xF3w");
|
|
2697
2825
|
this.emit("error", { error });
|
|
@@ -2940,8 +3068,9 @@ var Combobox = class extends Component {
|
|
|
2940
3068
|
if (this.isSelect) this.renderValue();
|
|
2941
3069
|
this.emit("close");
|
|
2942
3070
|
list.classList.add("pl-combobox-list-out");
|
|
3071
|
+
const { signal } = this;
|
|
2943
3072
|
await animationsDone(list);
|
|
2944
|
-
if (this.isOpen) return;
|
|
3073
|
+
if (signal.aborted || this.isOpen) return;
|
|
2945
3074
|
this.stopPlace?.();
|
|
2946
3075
|
this.stopPlace = null;
|
|
2947
3076
|
list.classList.remove("pl-combobox-list-out");
|
|
@@ -2966,7 +3095,7 @@ __publicField(Combobox, "defaults", {
|
|
|
2966
3095
|
options: null,
|
|
2967
3096
|
// lista pozycji (JS)
|
|
2968
3097
|
source: null,
|
|
2969
|
-
// funkcja async (q) => [...] lub adres URL (doklejane ?q)
|
|
3098
|
+
// funkcja async (q, { signal }) => [...] lub adres URL (doklejane ?q)
|
|
2970
3099
|
minLength: 0,
|
|
2971
3100
|
// minimalna długość zapytania dla `source`
|
|
2972
3101
|
delay: 220,
|
|
@@ -3647,8 +3776,9 @@ var Datepicker = class extends Component {
|
|
|
3647
3776
|
if (focus || picker.contains(document.activeElement)) el.focus({ preventScroll: true });
|
|
3648
3777
|
this.emit("close");
|
|
3649
3778
|
picker.classList.add("pl-datepicker-out");
|
|
3779
|
+
const { signal } = this;
|
|
3650
3780
|
await animationsDone(picker);
|
|
3651
|
-
if (this.isOpen) return;
|
|
3781
|
+
if (signal.aborted || this.isOpen) return;
|
|
3652
3782
|
this.stopPlace?.();
|
|
3653
3783
|
this.stopPlace = null;
|
|
3654
3784
|
picker.classList.remove("pl-datepicker-out");
|
|
@@ -4512,6 +4642,7 @@ var Drop = class extends Component {
|
|
|
4512
4642
|
});
|
|
4513
4643
|
const { el, toggleEl } = this;
|
|
4514
4644
|
const token2 = ++this.token;
|
|
4645
|
+
const { signal } = this;
|
|
4515
4646
|
this.isOpen = true;
|
|
4516
4647
|
open.push(this);
|
|
4517
4648
|
el.classList.remove("pl-leave");
|
|
@@ -4529,7 +4660,7 @@ var Drop = class extends Component {
|
|
|
4529
4660
|
});
|
|
4530
4661
|
this.emit("show");
|
|
4531
4662
|
animationsDone(el).then(() => {
|
|
4532
|
-
if (token2 === this.token && this.isOpen) this.emit("shown");
|
|
4663
|
+
if (!signal.aborted && token2 === this.token && this.isOpen) this.emit("shown");
|
|
4533
4664
|
});
|
|
4534
4665
|
}
|
|
4535
4666
|
/** Zamyka drop; `refocus` przenosi fokus z powrotem na przełącznik. */
|
|
@@ -4542,6 +4673,7 @@ var Drop = class extends Component {
|
|
|
4542
4673
|
});
|
|
4543
4674
|
const { el, toggleEl } = this;
|
|
4544
4675
|
const token2 = ++this.token;
|
|
4676
|
+
const { signal } = this;
|
|
4545
4677
|
const hadFocus = el.contains(document.activeElement);
|
|
4546
4678
|
this.isOpen = false;
|
|
4547
4679
|
const index = open.indexOf(this);
|
|
@@ -4557,7 +4689,7 @@ var Drop = class extends Component {
|
|
|
4557
4689
|
el.classList.remove("pl-open");
|
|
4558
4690
|
this.emit("hide");
|
|
4559
4691
|
await animationsDone(el);
|
|
4560
|
-
if (token2 !== this.token) return;
|
|
4692
|
+
if (signal.aborted || token2 !== this.token) return;
|
|
4561
4693
|
this.teardown();
|
|
4562
4694
|
this.emit("hidden");
|
|
4563
4695
|
}
|
|
@@ -4957,6 +5089,7 @@ var Popover = class extends Component {
|
|
|
4957
5089
|
if (other !== this && !other.pop?.contains(el)) other.hide();
|
|
4958
5090
|
});
|
|
4959
5091
|
const token2 = ++this.token;
|
|
5092
|
+
const { signal } = this;
|
|
4960
5093
|
this.isOpen = true;
|
|
4961
5094
|
open2.push(this);
|
|
4962
5095
|
pop.classList.remove("pl-leave");
|
|
@@ -4973,7 +5106,7 @@ var Popover = class extends Component {
|
|
|
4973
5106
|
}
|
|
4974
5107
|
this.emit("show");
|
|
4975
5108
|
animationsDone(pop).then(() => {
|
|
4976
|
-
if (token2 === this.token && this.isOpen) this.emit("shown");
|
|
5109
|
+
if (!signal.aborted && token2 === this.token && this.isOpen) this.emit("shown");
|
|
4977
5110
|
});
|
|
4978
5111
|
}
|
|
4979
5112
|
/** Zamyka popover; `refocus` wymusza powrót fokusu na element wyzwalający. */
|
|
@@ -4986,6 +5119,7 @@ var Popover = class extends Component {
|
|
|
4986
5119
|
if (other !== this && pop.contains(other.el)) other.hide();
|
|
4987
5120
|
});
|
|
4988
5121
|
const token2 = ++this.token;
|
|
5122
|
+
const { signal } = this;
|
|
4989
5123
|
const hadFocus = pop.contains(document.activeElement);
|
|
4990
5124
|
this.isOpen = false;
|
|
4991
5125
|
const index = open2.indexOf(this);
|
|
@@ -5002,7 +5136,7 @@ var Popover = class extends Component {
|
|
|
5002
5136
|
pop.classList.remove("pl-open");
|
|
5003
5137
|
this.emit("hide");
|
|
5004
5138
|
await animationsDone(pop);
|
|
5005
|
-
if (token2 !== this.token) return;
|
|
5139
|
+
if (signal.aborted || token2 !== this.token) return;
|
|
5006
5140
|
this.teardown();
|
|
5007
5141
|
this.emit("hidden");
|
|
5008
5142
|
}
|
|
@@ -5134,8 +5268,9 @@ var Overlay = class extends Component {
|
|
|
5134
5268
|
if (!this.options.stack) {
|
|
5135
5269
|
[...opened].filter((other) => other !== this && !other.el.contains(el)).forEach((other) => other.hide());
|
|
5136
5270
|
}
|
|
5137
|
-
this.opener = opener instanceof Element ? opener : document.activeElement;
|
|
5138
5271
|
if (!el.isConnected) document.body.append(el);
|
|
5272
|
+
if (getInstance(el, this.constructor.componentName) !== this) scan(el);
|
|
5273
|
+
this.opener = opener instanceof Element ? opener : document.activeElement;
|
|
5139
5274
|
el.classList.remove("pl-closing");
|
|
5140
5275
|
if (el.open) el.close();
|
|
5141
5276
|
this.state = "open";
|
|
@@ -5165,7 +5300,10 @@ var Overlay = class extends Component {
|
|
|
5165
5300
|
this.state = "closing";
|
|
5166
5301
|
this.el.classList.add("pl-closing");
|
|
5167
5302
|
this.emit("hide");
|
|
5168
|
-
|
|
5303
|
+
const { signal } = this;
|
|
5304
|
+
this.closing = settle([this.el, this.panel]).then(() => {
|
|
5305
|
+
if (!signal.aborted) this.finish();
|
|
5306
|
+
});
|
|
5169
5307
|
return this.closing;
|
|
5170
5308
|
}
|
|
5171
5309
|
/** Domyka okno po animacji (lub natychmiast, gdy zamknęła je przeglądarka). */
|
|
@@ -5500,8 +5638,8 @@ var Toast = class {
|
|
|
5500
5638
|
action.className = "pl-notification-action";
|
|
5501
5639
|
action.textContent = String(options.action.label);
|
|
5502
5640
|
action.addEventListener("click", () => {
|
|
5503
|
-
const
|
|
5504
|
-
if (!
|
|
5641
|
+
const keep2 = options.action.onClick?.(this.handle) === false;
|
|
5642
|
+
if (!keep2) this.close();
|
|
5505
5643
|
});
|
|
5506
5644
|
content.append(action);
|
|
5507
5645
|
}
|
|
@@ -6642,6 +6780,7 @@ var Switcher = class extends Component {
|
|
|
6642
6780
|
if (panel) tab.setAttribute("aria-controls", panel.id || (panel.id = uid("pl-panel")));
|
|
6643
6781
|
});
|
|
6644
6782
|
const token2 = ++this.token;
|
|
6783
|
+
const { signal } = this;
|
|
6645
6784
|
const detail = { index, previous, item: items[index] };
|
|
6646
6785
|
if (animate && previous > -1) this.emit("hide", { index: previous, item: items[previous] });
|
|
6647
6786
|
const pending = [];
|
|
@@ -6667,7 +6806,7 @@ var Switcher = class extends Component {
|
|
|
6667
6806
|
if (hash && hash !== location.hash) history.replaceState(null, "", hash);
|
|
6668
6807
|
}
|
|
6669
6808
|
Promise.all(pending).then(() => {
|
|
6670
|
-
if (token2 === this.token) this.emit("shown", detail);
|
|
6809
|
+
if (!signal.aborted && token2 === this.token) this.emit("shown", detail);
|
|
6671
6810
|
});
|
|
6672
6811
|
}
|
|
6673
6812
|
async animateIn(panel, forward) {
|
|
@@ -7612,7 +7751,8 @@ var Carousel = class extends Component {
|
|
|
7612
7751
|
this.index = 0;
|
|
7613
7752
|
this.pauses = /* @__PURE__ */ new Set();
|
|
7614
7753
|
this.autoplayOn = Boolean(this.options.autoplay);
|
|
7615
|
-
this.generatedNavs = /* @__PURE__ */ new
|
|
7754
|
+
this.generatedNavs = /* @__PURE__ */ new Set();
|
|
7755
|
+
this.onDestroy(() => this.generatedNavs.forEach((nav) => nav.replaceChildren()));
|
|
7616
7756
|
this._timer = 0;
|
|
7617
7757
|
this._remaining = 0;
|
|
7618
7758
|
this._startedAt = 0;
|
|
@@ -8099,13 +8239,13 @@ var Slider = class extends Carousel {
|
|
|
8099
8239
|
d.tracker.add(event.clientX, event.timeStamp);
|
|
8100
8240
|
this.render();
|
|
8101
8241
|
});
|
|
8102
|
-
const
|
|
8242
|
+
const release2 = (event) => {
|
|
8103
8243
|
const d = this.drag;
|
|
8104
8244
|
if (!d || event.pointerId !== d.id) return;
|
|
8105
8245
|
this.endDrag(event.type === "pointercancel", event.timeStamp);
|
|
8106
8246
|
};
|
|
8107
|
-
this.on(window, "pointerup",
|
|
8108
|
-
this.on(window, "pointercancel",
|
|
8247
|
+
this.on(window, "pointerup", release2);
|
|
8248
|
+
this.on(window, "pointercancel", release2);
|
|
8109
8249
|
this.on(
|
|
8110
8250
|
c,
|
|
8111
8251
|
"click",
|
|
@@ -8413,7 +8553,7 @@ var Slideshow = class extends Carousel {
|
|
|
8413
8553
|
d.tracker.add(event.clientX, event.timeStamp);
|
|
8414
8554
|
this.renderTransition();
|
|
8415
8555
|
});
|
|
8416
|
-
const
|
|
8556
|
+
const release2 = (event) => {
|
|
8417
8557
|
const d = this.drag;
|
|
8418
8558
|
if (!d || event.pointerId !== d.id) return;
|
|
8419
8559
|
this.drag = null;
|
|
@@ -8432,8 +8572,8 @@ var Slideshow = class extends Carousel {
|
|
|
8432
8572
|
if (forward && this.commit()) this.run(1, v);
|
|
8433
8573
|
else this.run(0, v);
|
|
8434
8574
|
};
|
|
8435
|
-
this.on(window, "pointerup",
|
|
8436
|
-
this.on(window, "pointercancel",
|
|
8575
|
+
this.on(window, "pointerup", release2);
|
|
8576
|
+
this.on(window, "pointercancel", release2);
|
|
8437
8577
|
this.on(
|
|
8438
8578
|
c,
|
|
8439
8579
|
"click",
|
|
@@ -9237,8 +9377,9 @@ var Video = class extends Component {
|
|
|
9237
9377
|
this.ready = true;
|
|
9238
9378
|
if (this.wanted) this.play();
|
|
9239
9379
|
});
|
|
9380
|
+
const { signal } = this;
|
|
9240
9381
|
setTimeout(() => {
|
|
9241
|
-
if (this.ready) return;
|
|
9382
|
+
if (signal.aborted || this.ready) return;
|
|
9242
9383
|
this.ready = true;
|
|
9243
9384
|
if (this.wanted) this.play();
|
|
9244
9385
|
}, 1500);
|
|
@@ -9314,9 +9455,9 @@ var Video = class extends Component {
|
|
|
9314
9455
|
this.emit("play");
|
|
9315
9456
|
}
|
|
9316
9457
|
/** `keep` — zachowaj zamiar odtwarzania (wznowienie po powrocie na kartę). */
|
|
9317
|
-
pause(
|
|
9458
|
+
pause(keep2 = false) {
|
|
9318
9459
|
const { el, options } = this;
|
|
9319
|
-
if (!
|
|
9460
|
+
if (!keep2) this.wanted = false;
|
|
9320
9461
|
if (!this.ready) return;
|
|
9321
9462
|
if (this.native) {
|
|
9322
9463
|
el.pause();
|
|
@@ -9683,6 +9824,7 @@ export {
|
|
|
9683
9824
|
autoPlace,
|
|
9684
9825
|
camel,
|
|
9685
9826
|
clamp,
|
|
9827
|
+
config,
|
|
9686
9828
|
debounce,
|
|
9687
9829
|
index_default as default,
|
|
9688
9830
|
focusables,
|