plossy 0.3.1 → 0.5.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 +136 -18
- package/dist/plossy.bootstrap.css +1 -1
- package/dist/plossy.bootstrap.min.css +1 -1
- package/dist/plossy.core.css +3 -3
- package/dist/plossy.core.min.css +2 -2
- package/dist/plossy.css +3 -3
- package/dist/plossy.d.ts +56 -14
- package/dist/plossy.esm.js +616 -231
- package/dist/plossy.js +610 -231
- package/dist/plossy.min.css +2 -2
- package/dist/plossy.min.js +13 -13
- package/dist/presets/editorial.css +1 -1
- package/dist/presets/editorial.min.css +1 -1
- package/dist/presets/elegant.css +1 -1
- package/dist/presets/elegant.min.css +1 -1
- package/dist/presets/flat.css +1 -1
- package/dist/presets/flat.min.css +1 -1
- package/dist/presets/glass.css +1 -1
- package/dist/presets/glass.min.css +1 -1
- package/dist/presets/paper.css +1 -1
- package/dist/presets/paper.min.css +1 -1
- package/dist/presets/pop.css +1 -1
- package/dist/presets/pop.min.css +1 -1
- package/dist/presets/round.css +1 -1
- package/dist/presets/round.min.css +1 -1
- package/dist/presets/tender.css +1 -1
- package/dist/presets/tender.min.css +1 -1
- package/dist/presets/toy.css +1 -1
- package/dist/presets/toy.min.css +1 -1
- package/package.json +2 -1
package/dist/plossy.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Plossy v0.
|
|
2
|
+
* Plossy v0.5.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):
|
|
@@ -52,11 +52,272 @@ var __defProp = Object.defineProperty;
|
|
|
52
52
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
53
53
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
54
54
|
|
|
55
|
+
// src/js/locale/en.js
|
|
56
|
+
var en_default = {
|
|
57
|
+
// Shared
|
|
58
|
+
close: "Close",
|
|
59
|
+
clear: "Clear",
|
|
60
|
+
previous: "Previous",
|
|
61
|
+
next: "Next",
|
|
62
|
+
loading: "Loading",
|
|
63
|
+
// Combobox
|
|
64
|
+
"combobox.empty": "No results",
|
|
65
|
+
"combobox.loading": "Searching\u2026",
|
|
66
|
+
"combobox.create": "Add",
|
|
67
|
+
"combobox.options": "Options",
|
|
68
|
+
"combobox.remove": "Remove: {label}",
|
|
69
|
+
"combobox.minLength": { one: "Type at least {n} character to search", other: "Type at least {n} characters to search" },
|
|
70
|
+
"combobox.error": "Couldn\u2019t load results",
|
|
71
|
+
// Datepicker
|
|
72
|
+
"datepicker.dialog": "Choose a date",
|
|
73
|
+
"datepicker.prevMonth": "Previous month",
|
|
74
|
+
"datepicker.nextMonth": "Next month",
|
|
75
|
+
"datepicker.prevYear": "Previous year",
|
|
76
|
+
"datepicker.nextYear": "Next year",
|
|
77
|
+
"datepicker.prevYears": "Previous years",
|
|
78
|
+
"datepicker.nextYears": "Next years",
|
|
79
|
+
"datepicker.pickMonth": "Choose a month",
|
|
80
|
+
"datepicker.pickYear": "Choose a year",
|
|
81
|
+
"datepicker.today": "Today",
|
|
82
|
+
"datepicker.clear": "Clear",
|
|
83
|
+
// Countdown (screen reader text)
|
|
84
|
+
"countdown.days": "days",
|
|
85
|
+
"countdown.hours": "hr",
|
|
86
|
+
"countdown.minutes": "min",
|
|
87
|
+
"countdown.seconds": "s",
|
|
88
|
+
// Slider, Slideshow
|
|
89
|
+
"slider.carousel": "carousel",
|
|
90
|
+
"slider.slide": "slide",
|
|
91
|
+
"slider.position": "{n} of {count}",
|
|
92
|
+
"slider.previous": "Previous slide",
|
|
93
|
+
"slider.next": "Next slide",
|
|
94
|
+
"slider.goto": "Slide {n}",
|
|
95
|
+
// Lightbox
|
|
96
|
+
"lightbox.label": "Gallery",
|
|
97
|
+
"lightbox.role": "gallery",
|
|
98
|
+
"lightbox.thumbs": "Thumbnails",
|
|
99
|
+
"lightbox.item": "Item {n}",
|
|
100
|
+
"lightbox.error": "Couldn\u2019t load the content.",
|
|
101
|
+
"lightbox.embed": "Embedded content",
|
|
102
|
+
// Modal (Plossy.modal.alert / confirm / prompt)
|
|
103
|
+
"modal.ok": "OK",
|
|
104
|
+
"modal.cancel": "Cancel",
|
|
105
|
+
"modal.close": "Close",
|
|
106
|
+
// Notification, Offcanvas, To top
|
|
107
|
+
"notification.close": "Close notification",
|
|
108
|
+
"offcanvas.label": "Side panel",
|
|
109
|
+
"totop.label": "Back to top",
|
|
110
|
+
// Quantity, Rating, OTP
|
|
111
|
+
"quantity.label": "Quantity",
|
|
112
|
+
"quantity.minus": "Decrease",
|
|
113
|
+
"quantity.plus": "Increase",
|
|
114
|
+
"rating.label": "Rating",
|
|
115
|
+
"otp.label": "One-time code",
|
|
116
|
+
"otp.char": "Character {n} of {count}",
|
|
117
|
+
// Password toggle, password strength
|
|
118
|
+
"password.show": "Show password",
|
|
119
|
+
"password.hide": "Hide password",
|
|
120
|
+
"strength.levels": "Weak, Fair, Good, Strong",
|
|
121
|
+
"strength.meter": "Password strength",
|
|
122
|
+
"strength.empty": "No password",
|
|
123
|
+
"strength.met": "met",
|
|
124
|
+
"strength.unmet": "not met",
|
|
125
|
+
"strength.rule.length": { one: "At least {n} character", other: "At least {n} characters" },
|
|
126
|
+
"strength.rule.case": "Lowercase and uppercase letter",
|
|
127
|
+
"strength.rule.digit": "At least one digit",
|
|
128
|
+
"strength.rule.symbol": "A special character (e.g. ! @ # ?)",
|
|
129
|
+
// Form validation
|
|
130
|
+
"validation.required": "This field is required.",
|
|
131
|
+
"validation.checkbox": "Check this box to continue.",
|
|
132
|
+
"validation.radio": "Choose one of the options.",
|
|
133
|
+
"validation.file": "Choose a file.",
|
|
134
|
+
"validation.select": "Choose an item from the list.",
|
|
135
|
+
"validation.email": "Enter a valid email address, e.g. jane@example.com.",
|
|
136
|
+
"validation.url": "Enter a valid URL, e.g. https://example.com.",
|
|
137
|
+
"validation.type": "Enter a value in the correct format.",
|
|
138
|
+
"validation.pattern": "Enter a value in the required format.",
|
|
139
|
+
"validation.minlength": { one: "Enter at least {n} character (currently {length}).", other: "Enter at least {n} characters (currently {length})." },
|
|
140
|
+
"validation.maxlength": { one: "Enter at most {n} character (currently {length}).", other: "Enter at most {n} characters (currently {length})." },
|
|
141
|
+
"validation.min": "The value can\u2019t be less than {min}.",
|
|
142
|
+
"validation.max": "The value can\u2019t be greater than {max}.",
|
|
143
|
+
"validation.step": "Enter a value that matches the allowed step.",
|
|
144
|
+
"validation.bad": "Enter a valid value.",
|
|
145
|
+
// Upload
|
|
146
|
+
"upload.choose": "Choose files",
|
|
147
|
+
"upload.type": "The file \u201C{name}\u201D has a format that isn\u2019t allowed.",
|
|
148
|
+
"upload.size": "The file \u201C{name}\u201D is too large ({size}). The maximum size is {max} MB.",
|
|
149
|
+
"upload.count": { one: "You can add at most {n} file.", other: "You can add at most {n} files." },
|
|
150
|
+
"upload.remove": "Remove file {name}",
|
|
151
|
+
"upload.progress": "Upload progress: {name}",
|
|
152
|
+
"upload.uploading": "Uploading\u2026 {percent}%",
|
|
153
|
+
"upload.done": "Uploaded",
|
|
154
|
+
"upload.failed": "Couldn\u2019t upload the file.",
|
|
155
|
+
"upload.failedStatus": "Couldn\u2019t upload the file (error {status}).",
|
|
156
|
+
"upload.failedNetwork": "Couldn\u2019t upload the file \u2014 check your connection.",
|
|
157
|
+
// Sortable (screen reader announcements)
|
|
158
|
+
"sortable.help": "Press space to pick up an item. Use the arrow keys to move it, space or Enter to drop it, and Escape to cancel.",
|
|
159
|
+
"sortable.role": "sortable item",
|
|
160
|
+
"sortable.lifted": "Picked up: {label}. Position {n} of {count}. Use the arrow keys to move, space to drop, Escape to cancel.",
|
|
161
|
+
"sortable.moved": "Position {n} of {count}.",
|
|
162
|
+
"sortable.cancelled": "Cancelled. {label} returns to position {n} of {count}.",
|
|
163
|
+
"sortable.dropped": "Dropped: {label}. Position {n} of {count}."
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/js/locale/pl.js
|
|
167
|
+
var pl_default = {
|
|
168
|
+
close: "Zamknij",
|
|
169
|
+
clear: "Wyczy\u015B\u0107",
|
|
170
|
+
previous: "Poprzedni",
|
|
171
|
+
next: "Nast\u0119pny",
|
|
172
|
+
loading: "Wczytywanie",
|
|
173
|
+
"combobox.empty": "Brak wynik\xF3w",
|
|
174
|
+
"combobox.loading": "Szukam\u2026",
|
|
175
|
+
"combobox.create": "Dodaj",
|
|
176
|
+
"combobox.options": "Opcje",
|
|
177
|
+
"combobox.remove": "Usu\u0144: {label}",
|
|
178
|
+
"combobox.minLength": "Wpisz co najmniej {n} zn., aby wyszuka\u0107",
|
|
179
|
+
"combobox.error": "Nie uda\u0142o si\u0119 pobra\u0107 wynik\xF3w",
|
|
180
|
+
"datepicker.dialog": "Wybierz dat\u0119",
|
|
181
|
+
"datepicker.prevMonth": "Poprzedni miesi\u0105c",
|
|
182
|
+
"datepicker.nextMonth": "Nast\u0119pny miesi\u0105c",
|
|
183
|
+
"datepicker.prevYear": "Poprzedni rok",
|
|
184
|
+
"datepicker.nextYear": "Nast\u0119pny rok",
|
|
185
|
+
"datepicker.prevYears": "Poprzednie lata",
|
|
186
|
+
"datepicker.nextYears": "Nast\u0119pne lata",
|
|
187
|
+
"datepicker.pickMonth": "Wybierz miesi\u0105c",
|
|
188
|
+
"datepicker.pickYear": "Wybierz rok",
|
|
189
|
+
"datepicker.today": "Dzi\u015B",
|
|
190
|
+
"datepicker.clear": "Wyczy\u015B\u0107",
|
|
191
|
+
"countdown.days": "dni",
|
|
192
|
+
"countdown.hours": "godz.",
|
|
193
|
+
"countdown.minutes": "min",
|
|
194
|
+
"countdown.seconds": "s",
|
|
195
|
+
"slider.carousel": "karuzela",
|
|
196
|
+
"slider.slide": "slajd",
|
|
197
|
+
"slider.position": "{n} z {count}",
|
|
198
|
+
"slider.previous": "Poprzedni slajd",
|
|
199
|
+
"slider.next": "Nast\u0119pny slajd",
|
|
200
|
+
"slider.goto": "Slajd {n}",
|
|
201
|
+
"lightbox.label": "Galeria",
|
|
202
|
+
"lightbox.role": "galeria",
|
|
203
|
+
"lightbox.thumbs": "Miniatury",
|
|
204
|
+
"lightbox.item": "Pozycja {n}",
|
|
205
|
+
"lightbox.error": "Nie uda\u0142o si\u0119 wczyta\u0107 zawarto\u015Bci.",
|
|
206
|
+
"lightbox.embed": "Osadzona tre\u015B\u0107",
|
|
207
|
+
"modal.ok": "OK",
|
|
208
|
+
"modal.cancel": "Anuluj",
|
|
209
|
+
"modal.close": "Zamknij",
|
|
210
|
+
"notification.close": "Zamknij powiadomienie",
|
|
211
|
+
"offcanvas.label": "Panel boczny",
|
|
212
|
+
"totop.label": "Wr\xF3\u0107 na g\xF3r\u0119 strony",
|
|
213
|
+
"quantity.label": "Ilo\u015B\u0107",
|
|
214
|
+
"quantity.minus": "Mniej",
|
|
215
|
+
"quantity.plus": "Wi\u0119cej",
|
|
216
|
+
"rating.label": "Ocena",
|
|
217
|
+
"otp.label": "Kod jednorazowy",
|
|
218
|
+
"otp.char": "Znak {n} z {count}",
|
|
219
|
+
"password.show": "Poka\u017C has\u0142o",
|
|
220
|
+
"password.hide": "Ukryj has\u0142o",
|
|
221
|
+
"strength.levels": "S\u0142abe, \u015Arednie, Dobre, Silne",
|
|
222
|
+
"strength.meter": "Si\u0142a has\u0142a",
|
|
223
|
+
"strength.empty": "Brak has\u0142a",
|
|
224
|
+
"strength.met": "spe\u0142nione",
|
|
225
|
+
"strength.unmet": "niespe\u0142nione",
|
|
226
|
+
"strength.rule.length": "Co najmniej {n} znak\xF3w",
|
|
227
|
+
"strength.rule.case": "Ma\u0142a i wielka litera",
|
|
228
|
+
"strength.rule.digit": "Co najmniej jedna cyfra",
|
|
229
|
+
"strength.rule.symbol": "Znak specjalny (np. ! @ # ?)",
|
|
230
|
+
"validation.required": "To pole jest wymagane.",
|
|
231
|
+
"validation.checkbox": "Zaznacz to pole, aby kontynuowa\u0107.",
|
|
232
|
+
"validation.radio": "Wybierz jedn\u0105 z opcji.",
|
|
233
|
+
"validation.file": "Wybierz plik.",
|
|
234
|
+
"validation.select": "Wybierz pozycj\u0119 z listy.",
|
|
235
|
+
"validation.email": "Podaj poprawny adres e-mail, np. jan@example.com.",
|
|
236
|
+
"validation.url": "Podaj poprawny adres URL, np. https://example.com.",
|
|
237
|
+
"validation.type": "Podaj warto\u015B\u0107 w poprawnym formacie.",
|
|
238
|
+
"validation.pattern": "Podaj warto\u015B\u0107 w wymaganym formacie.",
|
|
239
|
+
"validation.minlength": {
|
|
240
|
+
one: "Wpisz co najmniej {n} znak (obecnie {length}).",
|
|
241
|
+
few: "Wpisz co najmniej {n} znaki (obecnie {length}).",
|
|
242
|
+
many: "Wpisz co najmniej {n} znak\xF3w (obecnie {length}).",
|
|
243
|
+
other: "Wpisz co najmniej {n} znaku (obecnie {length})."
|
|
244
|
+
},
|
|
245
|
+
"validation.maxlength": {
|
|
246
|
+
one: "Wpisz najwy\u017Cej {n} znak (obecnie {length}).",
|
|
247
|
+
few: "Wpisz najwy\u017Cej {n} znaki (obecnie {length}).",
|
|
248
|
+
many: "Wpisz najwy\u017Cej {n} znak\xF3w (obecnie {length}).",
|
|
249
|
+
other: "Wpisz najwy\u017Cej {n} znaku (obecnie {length})."
|
|
250
|
+
},
|
|
251
|
+
"validation.min": "Warto\u015B\u0107 nie mo\u017Ce by\u0107 mniejsza ni\u017C {min}.",
|
|
252
|
+
"validation.max": "Warto\u015B\u0107 nie mo\u017Ce by\u0107 wi\u0119ksza ni\u017C {max}.",
|
|
253
|
+
"validation.step": "Podaj warto\u015B\u0107 zgodn\u0105 z dozwolonym krokiem.",
|
|
254
|
+
"validation.bad": "Podaj poprawn\u0105 warto\u015B\u0107.",
|
|
255
|
+
"upload.choose": "Wybierz pliki",
|
|
256
|
+
"upload.type": "Plik \u201E{name}\u201D ma niedozwolony format.",
|
|
257
|
+
"upload.size": "Plik \u201E{name}\u201D jest za du\u017Cy ({size}). Maksymalny rozmiar to {max} MB.",
|
|
258
|
+
"upload.count": {
|
|
259
|
+
one: "Mo\u017Cna doda\u0107 najwy\u017Cej {n} plik.",
|
|
260
|
+
few: "Mo\u017Cna doda\u0107 najwy\u017Cej {n} pliki.",
|
|
261
|
+
many: "Mo\u017Cna doda\u0107 najwy\u017Cej {n} plik\xF3w.",
|
|
262
|
+
other: "Mo\u017Cna doda\u0107 najwy\u017Cej {n} pliku."
|
|
263
|
+
},
|
|
264
|
+
"upload.remove": "Usu\u0144 plik {name}",
|
|
265
|
+
"upload.progress": "Post\u0119p przesy\u0142ania: {name}",
|
|
266
|
+
"upload.uploading": "Przesy\u0142anie\u2026 {percent}%",
|
|
267
|
+
"upload.done": "Przes\u0142ano",
|
|
268
|
+
"upload.failed": "Nie uda\u0142o si\u0119 przes\u0142a\u0107 pliku.",
|
|
269
|
+
"upload.failedStatus": "Nie uda\u0142o si\u0119 przes\u0142a\u0107 pliku (b\u0142\u0105d {status}).",
|
|
270
|
+
"upload.failedNetwork": "Nie uda\u0142o si\u0119 przes\u0142a\u0107 pliku \u2014 sprawd\u017A po\u0142\u0105czenie.",
|
|
271
|
+
"sortable.help": "Naci\u015Bnij spacj\u0119, aby podnie\u015B\u0107 element. Strza\u0142kami zmie\u0144 jego pozycj\u0119, spacj\u0105 lub Enterem upu\u015B\u0107, klawiszem Escape anuluj.",
|
|
272
|
+
"sortable.role": "element sortowalny",
|
|
273
|
+
"sortable.lifted": "Podniesiono: {label}. Pozycja {n} z {count}. Strza\u0142kami zmie\u0144 pozycj\u0119, spacj\u0105 upu\u015B\u0107, Escape anuluje.",
|
|
274
|
+
"sortable.moved": "Pozycja {n} z {count}.",
|
|
275
|
+
"sortable.cancelled": "Anulowano. {label} wraca na pozycj\u0119 {n} z {count}.",
|
|
276
|
+
"sortable.dropped": "Upuszczono: {label}. Pozycja {n} z {count}."
|
|
277
|
+
};
|
|
278
|
+
|
|
55
279
|
// src/js/core.js
|
|
56
280
|
var registry = /* @__PURE__ */ new Map();
|
|
57
281
|
var store = /* @__PURE__ */ new WeakMap();
|
|
282
|
+
var meta = /* @__PURE__ */ new WeakMap();
|
|
283
|
+
var dormant = /* @__PURE__ */ new WeakMap();
|
|
284
|
+
var dormantCount = 0;
|
|
285
|
+
var liveCount = 0;
|
|
286
|
+
var dormantGone = typeof FinalizationRegistry === "function" ? new FinalizationRegistry(() => dormantCount--) : null;
|
|
58
287
|
var started = false;
|
|
59
288
|
var selector = "";
|
|
289
|
+
var PERSIST = "data-pl-persist";
|
|
290
|
+
var config = {
|
|
291
|
+
/** Niszczy instancje elementów usuniętych z dokumentu. `false` — dawne zachowanie (instancje żyją dalej). */
|
|
292
|
+
autoDestroy: true,
|
|
293
|
+
/** Język tekstów interfejsu (np. 'pl'). `null` — według atrybutu `lang` elementu lub strony, domyślnie angielski. */
|
|
294
|
+
locale: null
|
|
295
|
+
};
|
|
296
|
+
var locales = { en: en_default, pl: pl_default };
|
|
297
|
+
function langOf(el) {
|
|
298
|
+
if (config.locale) return String(config.locale);
|
|
299
|
+
const owner = el?.closest?.("[lang]") || document.documentElement;
|
|
300
|
+
return owner.getAttribute("lang") || "en";
|
|
301
|
+
}
|
|
302
|
+
function localeOf(el) {
|
|
303
|
+
const tag = langOf(el).toLowerCase();
|
|
304
|
+
if (locales[tag]) return tag;
|
|
305
|
+
const base = tag.split("-")[0];
|
|
306
|
+
return locales[base] ? base : "en";
|
|
307
|
+
}
|
|
308
|
+
function t(key, vars = {}, el = null) {
|
|
309
|
+
const lang = localeOf(el);
|
|
310
|
+
let text = locales[lang][key] ?? locales.en[key] ?? key;
|
|
311
|
+
if (typeof text === "object") {
|
|
312
|
+
const form = new Intl.PluralRules(lang).select(Number(vars.n) || 0);
|
|
313
|
+
text = text[form] ?? text.other;
|
|
314
|
+
}
|
|
315
|
+
return String(text).replace(/\{(\w+)\}/g, (match, name) => name in vars ? String(vars[name]) : match);
|
|
316
|
+
}
|
|
317
|
+
function addLocale(code, messages) {
|
|
318
|
+
const key = String(code).toLowerCase();
|
|
319
|
+
locales[key] = { ...locales[key] || {}, ...messages };
|
|
320
|
+
}
|
|
60
321
|
var api = {};
|
|
61
322
|
var $ = (sel, ctx = document) => typeof sel === "string" ? ctx.querySelector(sel) : sel || null;
|
|
62
323
|
var $$ = (sel, ctx = document) => typeof sel === "string" ? [...ctx.querySelectorAll(sel)] : sel ? sel instanceof Element ? [sel] : [...sel] : [];
|
|
@@ -118,34 +379,46 @@ function parseOptions(str, defaults = {}, primary = null) {
|
|
|
118
379
|
}
|
|
119
380
|
var Component = class {
|
|
120
381
|
constructor(el, options = {}) {
|
|
121
|
-
const
|
|
382
|
+
const name = this.constructor.componentName;
|
|
122
383
|
this.el = el;
|
|
123
|
-
this
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
384
|
+
meta.set(this, { options, declarative: el.hasAttribute(`data-pl-${name}`), destroyed: false });
|
|
385
|
+
const destroy = this.destroy;
|
|
386
|
+
Object.defineProperty(this, "destroy", {
|
|
387
|
+
configurable: true,
|
|
388
|
+
writable: true,
|
|
389
|
+
value: () => {
|
|
390
|
+
const state = meta.get(this);
|
|
391
|
+
forget(this);
|
|
392
|
+
if (state.destroyed) return;
|
|
393
|
+
state.destroyed = true;
|
|
394
|
+
destroy.call(this);
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
mount(this);
|
|
133
398
|
}
|
|
134
399
|
/** Punkt wejścia komponentu. Stan instancji ustawiaj tutaj (nie w polach klasy). */
|
|
135
400
|
init() {
|
|
136
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* AbortSignal bieżącego „życia" instancji — przerywany w destroy(), nowy po ponownym init().
|
|
404
|
+
* Przekazuj go do fetch() i sprawdzaj po każdym await (`if (signal.aborted) return`).
|
|
405
|
+
*/
|
|
406
|
+
get signal() {
|
|
407
|
+
return this._life.signal;
|
|
408
|
+
}
|
|
137
409
|
/** addEventListener z automatycznym sprzątaniem w destroy(). Zwraca funkcję odpinającą. */
|
|
138
410
|
on(target, type, handler, options) {
|
|
139
|
-
if (!target) return () => {
|
|
411
|
+
if (!target || meta.get(this)?.destroyed) return () => {
|
|
140
412
|
};
|
|
141
413
|
target.addEventListener(type, handler, options);
|
|
142
414
|
const off = () => target.removeEventListener(type, handler, options);
|
|
143
415
|
this._cleanup.push(off);
|
|
144
416
|
return off;
|
|
145
417
|
}
|
|
146
|
-
/** Rejestruje dowolną funkcję sprzątającą. */
|
|
418
|
+
/** Rejestruje dowolną funkcję sprzątającą. Po destroy() wywołuje ją od razu. */
|
|
147
419
|
onDestroy(fn) {
|
|
148
|
-
|
|
420
|
+
if (meta.get(this)?.destroyed) fn();
|
|
421
|
+
else this._cleanup.push(fn);
|
|
149
422
|
}
|
|
150
423
|
/**
|
|
151
424
|
* Wysyła zdarzenie `pl:{type}` na elemencie komponentu (bąbelkuje).
|
|
@@ -161,19 +434,114 @@ var Component = class {
|
|
|
161
434
|
return !event.defaultPrevented;
|
|
162
435
|
}
|
|
163
436
|
destroy() {
|
|
164
|
-
|
|
165
|
-
|
|
437
|
+
const state = meta.get(this);
|
|
438
|
+
if (state) state.destroyed = true;
|
|
439
|
+
this._life?.abort();
|
|
440
|
+
const name = this.constructor.componentName;
|
|
441
|
+
for (const fn of this._cleanup.splice(0)) {
|
|
442
|
+
try {
|
|
443
|
+
fn();
|
|
444
|
+
} catch (error) {
|
|
445
|
+
console.error(`[Plossy] ${name}:`, error);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
const map = store.get(this.el);
|
|
449
|
+
if (map?.get(name) === this) {
|
|
450
|
+
map.delete(name);
|
|
451
|
+
liveCount--;
|
|
452
|
+
}
|
|
166
453
|
}
|
|
167
454
|
};
|
|
168
455
|
/** Domyślne opcje — nadpisywane w klasach potomnych. */
|
|
169
456
|
__publicField(Component, "defaults", {});
|
|
170
457
|
/** Nazwa opcji, do której trafia „goła" wartość atrybutu (np. data-pl-toggle="#cel"). */
|
|
171
458
|
__publicField(Component, "primary", null);
|
|
459
|
+
function mount(instance) {
|
|
460
|
+
const C = instance.constructor;
|
|
461
|
+
const el = instance.el;
|
|
462
|
+
const state = meta.get(instance);
|
|
463
|
+
instance.options = {
|
|
464
|
+
...C.defaults,
|
|
465
|
+
...parseOptions(el.getAttribute(`data-pl-${C.componentName}`), C.defaults, C.primary),
|
|
466
|
+
...state.options
|
|
467
|
+
};
|
|
468
|
+
instance._cleanup = [];
|
|
469
|
+
instance._life = new AbortController();
|
|
470
|
+
state.destroyed = false;
|
|
471
|
+
let map = store.get(el);
|
|
472
|
+
if (!map) store.set(el, map = /* @__PURE__ */ new Map());
|
|
473
|
+
if (!map.has(C.componentName)) liveCount++;
|
|
474
|
+
map.set(C.componentName, instance);
|
|
475
|
+
instance.init();
|
|
476
|
+
}
|
|
172
477
|
function getInstance(el, name) {
|
|
173
478
|
return store.get(el)?.get(name) || null;
|
|
174
479
|
}
|
|
175
480
|
function create(el, name, options) {
|
|
176
|
-
return getInstance(el, name) || new (registry.get(name))(el, options);
|
|
481
|
+
return getInstance(el, name) || wake(el, name) || new (registry.get(name))(el, options);
|
|
482
|
+
}
|
|
483
|
+
function keep(instance) {
|
|
484
|
+
const el = instance.el;
|
|
485
|
+
let map = dormant.get(el);
|
|
486
|
+
if (!map) {
|
|
487
|
+
dormant.set(el, map = /* @__PURE__ */ new Map());
|
|
488
|
+
dormantCount++;
|
|
489
|
+
dormantGone?.register(el, null, map);
|
|
490
|
+
}
|
|
491
|
+
map.set(instance.constructor.componentName, instance);
|
|
492
|
+
}
|
|
493
|
+
function forget(instance) {
|
|
494
|
+
const map = dormant.get(instance.el);
|
|
495
|
+
const name = instance.constructor.componentName;
|
|
496
|
+
if (map?.get(name) !== instance) return;
|
|
497
|
+
map.delete(name);
|
|
498
|
+
if (!map.size) {
|
|
499
|
+
dormant.delete(instance.el);
|
|
500
|
+
dormantCount--;
|
|
501
|
+
dormantGone?.unregister(map);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function wake(el, only) {
|
|
505
|
+
const map = dormant.get(el);
|
|
506
|
+
if (!map) return null;
|
|
507
|
+
let woken = null;
|
|
508
|
+
for (const [name, instance] of [...map]) {
|
|
509
|
+
if (only && name !== only) continue;
|
|
510
|
+
forget(instance);
|
|
511
|
+
if (getInstance(el, name) || meta.get(instance).declarative && !el.hasAttribute(`data-pl-${name}`)) continue;
|
|
512
|
+
try {
|
|
513
|
+
mount(instance);
|
|
514
|
+
woken = instance;
|
|
515
|
+
} catch (error) {
|
|
516
|
+
console.error(`[Plossy] ${name}:`, error);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return woken;
|
|
520
|
+
}
|
|
521
|
+
var subtree = (root) => root instanceof Element ? [root, ...root.querySelectorAll("*")] : [...root.querySelectorAll("*")];
|
|
522
|
+
function release(root) {
|
|
523
|
+
if (!liveCount || root.isConnected) return;
|
|
524
|
+
for (const el of subtree(root).reverse()) {
|
|
525
|
+
const map = store.get(el);
|
|
526
|
+
if (!map || el.isConnected || el.closest(`[${PERSIST}]`)) continue;
|
|
527
|
+
for (const [name, instance] of [...map]) {
|
|
528
|
+
if (map.get(name) !== instance) continue;
|
|
529
|
+
try {
|
|
530
|
+
instance.destroy();
|
|
531
|
+
} catch (error) {
|
|
532
|
+
console.error(`[Plossy] ${name}:`, error);
|
|
533
|
+
}
|
|
534
|
+
keep(instance);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
var removed = /* @__PURE__ */ new Set();
|
|
539
|
+
var releaseTimer = 0;
|
|
540
|
+
function flushRemoved() {
|
|
541
|
+
releaseTimer = 0;
|
|
542
|
+
const roots = [...removed];
|
|
543
|
+
removed.clear();
|
|
544
|
+
if (config.autoDestroy) roots.forEach(release);
|
|
177
545
|
}
|
|
178
546
|
function register(name, Class) {
|
|
179
547
|
Class.componentName = name;
|
|
@@ -190,6 +558,7 @@ function register(name, Class) {
|
|
|
190
558
|
return Class;
|
|
191
559
|
}
|
|
192
560
|
function scan(root = document) {
|
|
561
|
+
if (dormantCount) subtree(root).forEach((el) => wake(el));
|
|
193
562
|
if (!selector) return;
|
|
194
563
|
const nodes = [...root.querySelectorAll(selector)];
|
|
195
564
|
if (root instanceof Element && root.matches(selector)) nodes.unshift(root);
|
|
@@ -212,10 +581,16 @@ function start() {
|
|
|
212
581
|
scan(document);
|
|
213
582
|
new MutationObserver((records) => {
|
|
214
583
|
for (const record of records) {
|
|
584
|
+
if (config.autoDestroy && !record.target.closest?.(`[${PERSIST}]`)) {
|
|
585
|
+
for (const node of record.removedNodes) {
|
|
586
|
+
if (node.nodeType === 1) removed.add(node);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
215
589
|
for (const node of record.addedNodes) {
|
|
216
|
-
if (node.nodeType === 1) scan(node);
|
|
590
|
+
if (node.nodeType === 1 && node.isConnected) scan(node);
|
|
217
591
|
}
|
|
218
592
|
}
|
|
593
|
+
if (removed.size && !releaseTimer) releaseTimer = setTimeout(flushRemoved);
|
|
219
594
|
}).observe(document.documentElement, { childList: true, subtree: true });
|
|
220
595
|
};
|
|
221
596
|
if (document.readyState === "loading") {
|
|
@@ -368,6 +743,9 @@ Object.assign(api, {
|
|
|
368
743
|
register,
|
|
369
744
|
scan,
|
|
370
745
|
getInstance,
|
|
746
|
+
config,
|
|
747
|
+
addLocale,
|
|
748
|
+
locales,
|
|
371
749
|
Component,
|
|
372
750
|
util: {
|
|
373
751
|
$,
|
|
@@ -375,6 +753,8 @@ Object.assign(api, {
|
|
|
375
753
|
uid,
|
|
376
754
|
clamp,
|
|
377
755
|
parseOptions,
|
|
756
|
+
t,
|
|
757
|
+
langOf,
|
|
378
758
|
queryTargets,
|
|
379
759
|
focusables,
|
|
380
760
|
animationsDone,
|
|
@@ -599,7 +979,6 @@ var UNITS = [
|
|
|
599
979
|
["minutes", 60],
|
|
600
980
|
["seconds", 1]
|
|
601
981
|
];
|
|
602
|
-
var LABELS = { days: "dni", hours: "godz.", minutes: "min", seconds: "s" };
|
|
603
982
|
var Countdown = class extends Component {
|
|
604
983
|
init() {
|
|
605
984
|
this.timer = null;
|
|
@@ -634,7 +1013,7 @@ var Countdown = class extends Component {
|
|
|
634
1013
|
if (date !== "" && date !== null && date !== void 0) {
|
|
635
1014
|
const time = typeof date === "number" ? date : Date.parse(date);
|
|
636
1015
|
if (!Number.isNaN(time)) return time;
|
|
637
|
-
console.warn(`[Plossy] countdown:
|
|
1016
|
+
console.warn(`[Plossy] countdown: invalid date "${date}"`);
|
|
638
1017
|
}
|
|
639
1018
|
return Date.now() + Math.max(0, Number(seconds) || 0) * 1e3;
|
|
640
1019
|
}
|
|
@@ -716,7 +1095,7 @@ var Countdown = class extends Component {
|
|
|
716
1095
|
}
|
|
717
1096
|
if (!changed) return;
|
|
718
1097
|
this.el.style.setProperty("--pl-countdown-progress", this.total ? String(1 - ms / this.total) : "0");
|
|
719
|
-
const key = Object.entries(values).filter(([unit]) => unit !== "seconds" || Object.keys(values).length === 1).map(([unit, value]) => `${value} ${
|
|
1098
|
+
const key = Object.entries(values).filter(([unit]) => unit !== "seconds" || Object.keys(values).length === 1).map(([unit, value]) => `${value} ${t(`countdown.${unit}`, {}, this.el)}`).join(" ");
|
|
720
1099
|
if (key !== this.srKey) {
|
|
721
1100
|
this.srKey = key;
|
|
722
1101
|
this.sr.textContent = key;
|
|
@@ -1173,7 +1552,7 @@ var Totop = class extends Component {
|
|
|
1173
1552
|
const { el } = this;
|
|
1174
1553
|
this.active = null;
|
|
1175
1554
|
if (!el.hasAttribute("aria-label") && !el.textContent.trim()) {
|
|
1176
|
-
el.setAttribute("aria-label", "
|
|
1555
|
+
el.setAttribute("aria-label", t("totop.label", {}, el));
|
|
1177
1556
|
}
|
|
1178
1557
|
if (!el.matches("a[href], button")) {
|
|
1179
1558
|
if (!el.hasAttribute("role")) el.setAttribute("role", "button");
|
|
@@ -1265,14 +1644,14 @@ register("totop", Totop);
|
|
|
1265
1644
|
// src/js/components/upload.js
|
|
1266
1645
|
var svg = (name) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${icons_default[name] || ""}</svg>`;
|
|
1267
1646
|
var escapeHtml = (str) => String(str).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
1268
|
-
function formatSize(bytes) {
|
|
1647
|
+
function formatSize(bytes, lang = "en") {
|
|
1269
1648
|
const units = ["B", "KB", "MB", "GB"];
|
|
1270
1649
|
let i = 0;
|
|
1271
1650
|
while (bytes >= 1024 && i < units.length - 1) {
|
|
1272
1651
|
bytes /= 1024;
|
|
1273
1652
|
i++;
|
|
1274
1653
|
}
|
|
1275
|
-
return `${bytes.toLocaleString(
|
|
1654
|
+
return `${bytes.toLocaleString(lang, { maximumFractionDigits: i ? 1 : 0 })} ${units[i]}`;
|
|
1276
1655
|
}
|
|
1277
1656
|
function typeIcon(file) {
|
|
1278
1657
|
const type = file.type || "";
|
|
@@ -1308,7 +1687,7 @@ var Upload = class extends Component {
|
|
|
1308
1687
|
this.input.type = "file";
|
|
1309
1688
|
this.input.tabIndex = -1;
|
|
1310
1689
|
this.input.name = options.name;
|
|
1311
|
-
this.input.setAttribute("aria-label", "
|
|
1690
|
+
this.input.setAttribute("aria-label", t("upload.choose", {}, el));
|
|
1312
1691
|
this.input.hidden = true;
|
|
1313
1692
|
el.append(this.input);
|
|
1314
1693
|
if (!el.hasAttribute("tabindex")) el.tabIndex = 0;
|
|
@@ -1400,14 +1779,14 @@ var Upload = class extends Component {
|
|
|
1400
1779
|
for (const file of files) {
|
|
1401
1780
|
let error = null;
|
|
1402
1781
|
if (!matchesAccept(file, options.accept)) {
|
|
1403
|
-
error = { type: "type", message:
|
|
1782
|
+
error = { type: "type", message: t("upload.type", { name: file.name }, this.el) };
|
|
1404
1783
|
} else if (options.maxSize && file.size > options.maxSize * 1024 * 1024) {
|
|
1405
1784
|
error = {
|
|
1406
1785
|
type: "size",
|
|
1407
|
-
message:
|
|
1786
|
+
message: t("upload.size", { name: file.name, size: formatSize(file.size, langOf(this.el)), max: options.maxSize }, this.el)
|
|
1408
1787
|
};
|
|
1409
1788
|
} else if (options.maxFiles && this.entries.length + accepted.length >= options.maxFiles) {
|
|
1410
|
-
error = { type: "count", message:
|
|
1789
|
+
error = { type: "count", message: t("upload.count", { n: options.maxFiles }, this.el) };
|
|
1411
1790
|
}
|
|
1412
1791
|
if (error) {
|
|
1413
1792
|
if (error.type !== "count" || !errors.some((other) => other.type === "count")) errors.push({ ...error, file });
|
|
@@ -1438,7 +1817,7 @@ var Upload = class extends Component {
|
|
|
1438
1817
|
thumb = `<img src="${entry.objectUrl}" alt="">`;
|
|
1439
1818
|
}
|
|
1440
1819
|
const name = escapeHtml(file.name);
|
|
1441
|
-
item.innerHTML = `<span class="pl-upload-thumb">${thumb}</span><span class="pl-upload-info"><span class="pl-upload-name" title="${name}">${name}</span><span class="pl-upload-meta"></span></span><button class="pl-upload-remove" type="button" aria-label="
|
|
1820
|
+
item.innerHTML = `<span class="pl-upload-thumb">${thumb}</span><span class="pl-upload-info"><span class="pl-upload-name" title="${name}">${name}</span><span class="pl-upload-meta"></span></span><button class="pl-upload-remove" type="button" aria-label="${escapeHtml(t("upload.remove", { name: file.name }, this.el))}">${svg("x")}</button><span class="pl-upload-progress" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-label="${escapeHtml(t("upload.progress", { name: file.name }, this.el))}"><span class="pl-upload-bar"></span></span>`;
|
|
1442
1821
|
entry.el = item;
|
|
1443
1822
|
this.list.append(item);
|
|
1444
1823
|
this.describe(entry);
|
|
@@ -1448,9 +1827,9 @@ var Upload = class extends Component {
|
|
|
1448
1827
|
describe(entry, text) {
|
|
1449
1828
|
const { file } = entry;
|
|
1450
1829
|
const ext = file.name.includes(".") ? file.name.split(".").pop().toUpperCase() : "";
|
|
1451
|
-
const base = [formatSize(file.size), ext].filter(Boolean).join(" \xB7 ");
|
|
1452
|
-
const
|
|
1453
|
-
if (
|
|
1830
|
+
const base = [formatSize(file.size, langOf(this.el)), ext].filter(Boolean).join(" \xB7 ");
|
|
1831
|
+
const meta2 = $(".pl-upload-meta", entry.el);
|
|
1832
|
+
if (meta2) meta2.textContent = text ? `${text}` : base;
|
|
1454
1833
|
entry.base = base;
|
|
1455
1834
|
}
|
|
1456
1835
|
find(target) {
|
|
@@ -1468,7 +1847,7 @@ var Upload = class extends Component {
|
|
|
1468
1847
|
entry.el.classList.remove("pl-upload-item-error");
|
|
1469
1848
|
entry.el.style.setProperty("--pl-upload-value", percent / 100);
|
|
1470
1849
|
$(".pl-upload-progress", entry.el)?.setAttribute("aria-valuenow", percent);
|
|
1471
|
-
this.describe(entry,
|
|
1850
|
+
this.describe(entry, t("upload.uploading", { percent }, this.el));
|
|
1472
1851
|
this.emit("progress", { file: entry.file, percent, ...detail });
|
|
1473
1852
|
}
|
|
1474
1853
|
/** Oznacza plik jako przesłany. */
|
|
@@ -1481,12 +1860,12 @@ var Upload = class extends Component {
|
|
|
1481
1860
|
entry.el.classList.remove("pl-upload-item-uploading", "pl-upload-item-error");
|
|
1482
1861
|
entry.el.classList.add("pl-upload-item-done");
|
|
1483
1862
|
this.describe(entry);
|
|
1484
|
-
this.describe(entry, `${entry.base} \xB7
|
|
1863
|
+
this.describe(entry, `${entry.base} \xB7 ${t("upload.done", {}, this.el)}`);
|
|
1485
1864
|
this.emit("complete", { file: entry.file, response, xhr });
|
|
1486
1865
|
if (this.entries.every((other) => other.status === "done")) this.emit("completeall", { files: this.files });
|
|
1487
1866
|
}
|
|
1488
1867
|
/** Oznacza plik jako nieprzesłany. */
|
|
1489
|
-
fail(target, message = "
|
|
1868
|
+
fail(target, message = t("upload.failed", {}, this.el), xhr = null) {
|
|
1490
1869
|
const entry = this.find(target);
|
|
1491
1870
|
if (!entry) return;
|
|
1492
1871
|
entry.status = "error";
|
|
@@ -1522,12 +1901,12 @@ var Upload = class extends Component {
|
|
|
1522
1901
|
}
|
|
1523
1902
|
this.complete(entry, response, xhr);
|
|
1524
1903
|
} else {
|
|
1525
|
-
this.fail(entry,
|
|
1904
|
+
this.fail(entry, t("upload.failedStatus", { status: xhr.status }, this.el), xhr);
|
|
1526
1905
|
}
|
|
1527
1906
|
});
|
|
1528
1907
|
xhr.addEventListener("error", () => {
|
|
1529
1908
|
entry.xhr = null;
|
|
1530
|
-
this.fail(entry, "
|
|
1909
|
+
this.fail(entry, t("upload.failedNetwork", {}, this.el), xhr);
|
|
1531
1910
|
});
|
|
1532
1911
|
if (!this.emit("beforesend", { file: entry.file, xhr, data }, true)) {
|
|
1533
1912
|
entry.xhr = null;
|
|
@@ -1556,14 +1935,14 @@ var Upload = class extends Component {
|
|
|
1556
1935
|
}
|
|
1557
1936
|
/** Usuwa wszystkie pliki. */
|
|
1558
1937
|
clear(silent = false) {
|
|
1559
|
-
const
|
|
1560
|
-
|
|
1938
|
+
const removed2 = this.entries.splice(0);
|
|
1939
|
+
removed2.forEach((entry) => {
|
|
1561
1940
|
this.release(entry);
|
|
1562
1941
|
entry.el.remove();
|
|
1563
1942
|
});
|
|
1564
1943
|
this.clearErrors();
|
|
1565
1944
|
this.sync();
|
|
1566
|
-
if (!silent)
|
|
1945
|
+
if (!silent) removed2.forEach((entry) => this.emit("remove", { file: entry.file }));
|
|
1567
1946
|
}
|
|
1568
1947
|
/** Utrzymuje `input.files` w zgodzie z listą — zwykły formularz wyśle to, co widać. */
|
|
1569
1948
|
sync() {
|
|
@@ -1619,12 +1998,6 @@ __publicField(Upload, "defaults", {
|
|
|
1619
1998
|
messages: true
|
|
1620
1999
|
// pokazuj komunikaty błędów pod strefą
|
|
1621
2000
|
});
|
|
1622
|
-
function plural(n) {
|
|
1623
|
-
if (n === 1) return "plik";
|
|
1624
|
-
const mod10 = n % 10;
|
|
1625
|
-
const mod100 = n % 100;
|
|
1626
|
-
return mod10 >= 2 && mod10 <= 4 && !(mod100 >= 12 && mod100 <= 14) ? "pliki" : "plik\xF3w";
|
|
1627
|
-
}
|
|
1628
2001
|
register("upload", Upload);
|
|
1629
2002
|
|
|
1630
2003
|
// src/js/components/otp.js
|
|
@@ -1649,7 +2022,7 @@ var Otp = class extends Component {
|
|
|
1649
2022
|
const disabled = this.input.disabled;
|
|
1650
2023
|
const initial = this.sanitize(this.input.value || "");
|
|
1651
2024
|
el.setAttribute("role", "group");
|
|
1652
|
-
if (!el.hasAttribute("aria-label") && !el.hasAttribute("aria-labelledby")) el.setAttribute("aria-label", options.label);
|
|
2025
|
+
if (!el.hasAttribute("aria-label") && !el.hasAttribute("aria-labelledby")) el.setAttribute("aria-label", options.label ?? t("otp.label", {}, el));
|
|
1653
2026
|
this.boxes = [];
|
|
1654
2027
|
this.generated = [];
|
|
1655
2028
|
let group = null;
|
|
@@ -1677,7 +2050,7 @@ var Otp = class extends Component {
|
|
|
1677
2050
|
box.spellcheck = false;
|
|
1678
2051
|
box.disabled = disabled;
|
|
1679
2052
|
box.style.setProperty("--pl-otp-index", i);
|
|
1680
|
-
box.setAttribute("aria-label",
|
|
2053
|
+
box.setAttribute("aria-label", t("otp.char", { n: i + 1, count: length }, this.el));
|
|
1681
2054
|
group.append(box);
|
|
1682
2055
|
this.boxes.push(box);
|
|
1683
2056
|
}
|
|
@@ -1704,20 +2077,20 @@ var Otp = class extends Component {
|
|
|
1704
2077
|
const box = event.target;
|
|
1705
2078
|
if (!box.classList?.contains("pl-otp-box")) return;
|
|
1706
2079
|
const index = this.boxes.indexOf(box);
|
|
1707
|
-
let
|
|
2080
|
+
let chars = this.sanitize(box.value);
|
|
1708
2081
|
const prev = this.prev?.[index];
|
|
1709
|
-
if (prev &&
|
|
2082
|
+
if (prev && chars.length === 2) chars = chars.replace(prev, "") || prev;
|
|
1710
2083
|
box.value = "";
|
|
1711
|
-
if (
|
|
2084
|
+
if (chars) this.fill(chars.length >= this.options.length ? 0 : index, chars);
|
|
1712
2085
|
else this.update();
|
|
1713
2086
|
});
|
|
1714
2087
|
this.on(el, "paste", (event) => {
|
|
1715
2088
|
const box = event.target;
|
|
1716
2089
|
if (!box.classList?.contains("pl-otp-box")) return;
|
|
1717
2090
|
event.preventDefault();
|
|
1718
|
-
const
|
|
1719
|
-
if (!
|
|
1720
|
-
this.fill(
|
|
2091
|
+
const chars = this.sanitize(event.clipboardData?.getData("text") || "");
|
|
2092
|
+
if (!chars) return this.reject(box);
|
|
2093
|
+
this.fill(chars.length >= this.options.length ? 0 : this.boxes.indexOf(box), chars);
|
|
1721
2094
|
});
|
|
1722
2095
|
this.on(el, "keydown", (event) => {
|
|
1723
2096
|
const box = event.target;
|
|
@@ -1789,10 +2162,10 @@ var Otp = class extends Component {
|
|
|
1789
2162
|
return this.boxes.every((box) => box.value);
|
|
1790
2163
|
}
|
|
1791
2164
|
/** Wpisuje znaki od pozycji `index` i przenosi fokus dalej. */
|
|
1792
|
-
fill(index,
|
|
2165
|
+
fill(index, chars) {
|
|
1793
2166
|
index = Math.max(0, index);
|
|
1794
2167
|
let last = index;
|
|
1795
|
-
[...
|
|
2168
|
+
[...chars].slice(0, this.boxes.length - index).forEach((char, offset) => {
|
|
1796
2169
|
const box = this.boxes[index + offset];
|
|
1797
2170
|
box.value = char;
|
|
1798
2171
|
this.pop(box);
|
|
@@ -1818,9 +2191,9 @@ var Otp = class extends Component {
|
|
|
1818
2191
|
setTimeout(() => box.classList.remove("pl-otp-shake"), 450);
|
|
1819
2192
|
}
|
|
1820
2193
|
write(code, silent = false) {
|
|
1821
|
-
const
|
|
2194
|
+
const chars = [...this.sanitize(code)];
|
|
1822
2195
|
this.boxes.forEach((box, i) => {
|
|
1823
|
-
box.value =
|
|
2196
|
+
box.value = chars[i] || "";
|
|
1824
2197
|
});
|
|
1825
2198
|
this.update(silent);
|
|
1826
2199
|
}
|
|
@@ -1909,24 +2282,21 @@ __publicField(Otp, "defaults", {
|
|
|
1909
2282
|
autofocus: false,
|
|
1910
2283
|
submit: false,
|
|
1911
2284
|
// po wpisaniu całego kodu wysyła formularz
|
|
1912
|
-
label:
|
|
2285
|
+
label: null
|
|
2286
|
+
// domyślnie z tekstów języka strony
|
|
1913
2287
|
});
|
|
1914
2288
|
__publicField(Otp, "primary", "length");
|
|
1915
2289
|
register("otp", Otp);
|
|
1916
2290
|
|
|
1917
2291
|
// src/js/components/strength.js
|
|
1918
|
-
var RULES =
|
|
1919
|
-
length: (min) => `Co najmniej ${min} znak\xF3w`,
|
|
1920
|
-
case: () => "Ma\u0142a i wielka litera",
|
|
1921
|
-
digit: () => "Co najmniej jedna cyfra",
|
|
1922
|
-
symbol: () => "Znak specjalny (np. ! @ # ?)"
|
|
1923
|
-
};
|
|
2292
|
+
var RULES = ["length", "case", "digit", "symbol"];
|
|
1924
2293
|
var Strength = class extends Component {
|
|
1925
2294
|
init() {
|
|
1926
2295
|
var _a;
|
|
1927
2296
|
const { el, options } = this;
|
|
1928
2297
|
el.classList.add("pl-strength");
|
|
1929
2298
|
this.input = options.input && $(options.input) || $("input", el);
|
|
2299
|
+
options.labels ?? (options.labels = t("strength.levels", {}, el));
|
|
1930
2300
|
if (typeof options.labels === "string") options.labels = options.labels.split(",").map((label) => label.trim());
|
|
1931
2301
|
this.created = [];
|
|
1932
2302
|
this.score = 0;
|
|
@@ -1943,7 +2313,7 @@ var Strength = class extends Component {
|
|
|
1943
2313
|
for (let i = 0; i < 4; i++) this.meter.append(this.make("span", "pl-strength-segment"));
|
|
1944
2314
|
}
|
|
1945
2315
|
this.meter.setAttribute("role", "meter");
|
|
1946
|
-
this.meter.setAttribute("aria-label", "
|
|
2316
|
+
this.meter.setAttribute("aria-label", t("strength.meter", {}, el));
|
|
1947
2317
|
this.meter.setAttribute("aria-valuemin", "0");
|
|
1948
2318
|
this.meter.setAttribute("aria-valuemax", "4");
|
|
1949
2319
|
this.labelEl = $(".pl-strength-label", el);
|
|
@@ -1960,10 +2330,10 @@ var Strength = class extends Component {
|
|
|
1960
2330
|
this.created.push(this.rulesEl);
|
|
1961
2331
|
}
|
|
1962
2332
|
if (this.rulesEl && !this.rulesEl.children.length) {
|
|
1963
|
-
for (const
|
|
2333
|
+
for (const rule of RULES) {
|
|
1964
2334
|
const item = this.make("li", "pl-strength-rule");
|
|
1965
2335
|
item.dataset.rule = rule;
|
|
1966
|
-
item.textContent =
|
|
2336
|
+
item.textContent = t(`strength.rule.${rule}`, { n: options.minLength }, el);
|
|
1967
2337
|
this.rulesEl.append(item);
|
|
1968
2338
|
}
|
|
1969
2339
|
}
|
|
@@ -2014,13 +2384,13 @@ var Strength = class extends Component {
|
|
|
2014
2384
|
this.el.dataset.score = score;
|
|
2015
2385
|
[...this.meter.children].forEach((segment, i) => segment.classList.toggle("pl-active", i < score));
|
|
2016
2386
|
this.meter.setAttribute("aria-valuenow", score);
|
|
2017
|
-
this.meter.setAttribute("aria-valuetext", label || "
|
|
2387
|
+
this.meter.setAttribute("aria-valuetext", label || t("strength.empty", {}, this.el));
|
|
2018
2388
|
if (this.labelEl) this.labelEl.textContent = label;
|
|
2019
2389
|
if (this.rulesEl) {
|
|
2020
2390
|
for (const item of this.rulesEl.querySelectorAll("[data-rule]")) {
|
|
2021
2391
|
const met = !!rules[item.dataset.rule];
|
|
2022
2392
|
item.classList.toggle("pl-active", met);
|
|
2023
|
-
item.setAttribute("aria-label", `${item.textContent} \u2014 ${met ? "
|
|
2393
|
+
item.setAttribute("aria-label", `${item.textContent} \u2014 ${t(met ? "strength.met" : "strength.unmet", {}, this.el)}`);
|
|
2024
2394
|
}
|
|
2025
2395
|
}
|
|
2026
2396
|
const changed = score !== this.score;
|
|
@@ -2035,7 +2405,8 @@ __publicField(Strength, "defaults", {
|
|
|
2035
2405
|
// lista wymagań odhaczanych na żywo
|
|
2036
2406
|
label: true,
|
|
2037
2407
|
// etykieta słowna
|
|
2038
|
-
labels:
|
|
2408
|
+
labels: null,
|
|
2409
|
+
// cztery poziomy; domyślnie z tekstów języka strony
|
|
2039
2410
|
input: "",
|
|
2040
2411
|
// selektor pola, gdy leży poza komponentem
|
|
2041
2412
|
emptyLabel: ""
|
|
@@ -2053,7 +2424,7 @@ var Rating = class extends Component {
|
|
|
2053
2424
|
el.classList.toggle("pl-rating-readonly", !!options.readonly);
|
|
2054
2425
|
el.style.setProperty("--pl-rating-max", max);
|
|
2055
2426
|
el.setAttribute("role", "radiogroup");
|
|
2056
|
-
if (!el.hasAttribute("aria-label") && !el.hasAttribute("aria-labelledby")) el.setAttribute("aria-label", options.label);
|
|
2427
|
+
if (!el.hasAttribute("aria-label") && !el.hasAttribute("aria-labelledby")) el.setAttribute("aria-label", options.label ?? t("rating.label", {}, el));
|
|
2057
2428
|
const name = options.name || uid("pl-rating");
|
|
2058
2429
|
const make = (value) => {
|
|
2059
2430
|
const input = document.createElement("input");
|
|
@@ -2145,7 +2516,8 @@ __publicField(Rating, "defaults", {
|
|
|
2145
2516
|
readonly: false,
|
|
2146
2517
|
clearable: true,
|
|
2147
2518
|
// ponowne kliknięcie wybranej gwiazdki zeruje ocenę
|
|
2148
|
-
label:
|
|
2519
|
+
label: null,
|
|
2520
|
+
// domyślnie z tekstów języka strony
|
|
2149
2521
|
star: "gwiazdka|gwiazdki|gwiazdek"
|
|
2150
2522
|
// odmiana do etykiet ARIA
|
|
2151
2523
|
});
|
|
@@ -2167,12 +2539,12 @@ var Quantity = class extends Component {
|
|
|
2167
2539
|
}
|
|
2168
2540
|
this.input.classList.add("pl-quantity-input");
|
|
2169
2541
|
if (!this.input.hasAttribute("inputmode")) this.input.inputMode = "numeric";
|
|
2170
|
-
if (!this.input.hasAttribute("aria-label") && !this.input.labels?.length) this.input.setAttribute("aria-label", "
|
|
2542
|
+
if (!this.input.hasAttribute("aria-label") && !this.input.labels?.length) this.input.setAttribute("aria-label", t("quantity.label", {}, el));
|
|
2171
2543
|
const make = (dir) => {
|
|
2172
2544
|
const button = document.createElement("button");
|
|
2173
2545
|
button.type = "button";
|
|
2174
2546
|
button.className = `pl-quantity-button ${dir < 0 ? "pl-quantity-minus" : "pl-quantity-plus"}`;
|
|
2175
|
-
button.setAttribute("aria-label", dir < 0 ? options.minusLabel : options.plusLabel);
|
|
2547
|
+
button.setAttribute("aria-label", dir < 0 ? options.minusLabel ?? t("quantity.minus", {}, el) : options.plusLabel ?? t("quantity.plus", {}, el));
|
|
2176
2548
|
button.tabIndex = -1;
|
|
2177
2549
|
this.on(button, "pointerdown", (event) => {
|
|
2178
2550
|
if (event.button) return;
|
|
@@ -2288,8 +2660,9 @@ __publicField(Quantity, "defaults", {
|
|
|
2288
2660
|
step: null,
|
|
2289
2661
|
repeat: true,
|
|
2290
2662
|
// przytrzymanie przycisku powtarza zmianę
|
|
2291
|
-
minusLabel:
|
|
2292
|
-
|
|
2663
|
+
minusLabel: null,
|
|
2664
|
+
// domyślnie z tekstów języka strony
|
|
2665
|
+
plusLabel: null
|
|
2293
2666
|
});
|
|
2294
2667
|
register("quantity", Quantity);
|
|
2295
2668
|
|
|
@@ -2307,6 +2680,9 @@ function normalize(list) {
|
|
|
2307
2680
|
var Combobox = class extends Component {
|
|
2308
2681
|
init() {
|
|
2309
2682
|
const { el, options } = this;
|
|
2683
|
+
options.emptyText ?? (options.emptyText = t("combobox.empty", {}, el));
|
|
2684
|
+
options.loadingText ?? (options.loadingText = t("combobox.loading", {}, el));
|
|
2685
|
+
options.createText ?? (options.createText = t("combobox.create", {}, el));
|
|
2310
2686
|
this.isSelect = el.tagName === "SELECT";
|
|
2311
2687
|
this.multiple = this.isSelect && el.multiple;
|
|
2312
2688
|
this.isOpen = false;
|
|
@@ -2379,7 +2755,7 @@ var Combobox = class extends Component {
|
|
|
2379
2755
|
this.clearButton.type = "button";
|
|
2380
2756
|
this.clearButton.className = "pl-combobox-clear";
|
|
2381
2757
|
this.clearButton.tabIndex = -1;
|
|
2382
|
-
this.clearButton.setAttribute("aria-label", "
|
|
2758
|
+
this.clearButton.setAttribute("aria-label", t("clear", {}, el));
|
|
2383
2759
|
this.clearButton.innerHTML = svg2("x");
|
|
2384
2760
|
this.clearButton.hidden = true;
|
|
2385
2761
|
if (options.clearable) control.append(this.clearButton);
|
|
@@ -2394,7 +2770,7 @@ var Combobox = class extends Component {
|
|
|
2394
2770
|
list.hidden = true;
|
|
2395
2771
|
if (this.multiple) list.setAttribute("aria-multiselectable", "true");
|
|
2396
2772
|
if (input.getAttribute("aria-labelledby")) list.setAttribute("aria-labelledby", input.getAttribute("aria-labelledby"));
|
|
2397
|
-
else list.setAttribute("aria-label", this.placeholder || "
|
|
2773
|
+
else list.setAttribute("aria-label", this.placeholder || t("combobox.options", {}, el));
|
|
2398
2774
|
wrapper.append(control, list);
|
|
2399
2775
|
this.onDestroy(() => {
|
|
2400
2776
|
this.stopPlace?.();
|
|
@@ -2503,13 +2879,15 @@ var Combobox = class extends Component {
|
|
|
2503
2879
|
});
|
|
2504
2880
|
if (this.isSelect) {
|
|
2505
2881
|
this.on(this.el, "focus", () => input.focus());
|
|
2506
|
-
this.on(this.el.form, "reset", () => setTimeout(() => this.refresh()));
|
|
2882
|
+
this.on(this.el.form, "reset", () => setTimeout(() => !this.signal.aborted && this.refresh()));
|
|
2507
2883
|
} else {
|
|
2508
2884
|
this.on(input, "change", () => {
|
|
2509
2885
|
if (!this.syncing) this.emit("change", { value: input.value, item: null });
|
|
2510
2886
|
});
|
|
2511
2887
|
}
|
|
2512
|
-
|
|
2888
|
+
const { signal } = this;
|
|
2889
|
+
this.load = debounce((query) => !signal.aborted && this.fetch(query), options.delay);
|
|
2890
|
+
this.onDestroy(() => clearTimeout(this.typedTimer));
|
|
2513
2891
|
}
|
|
2514
2892
|
// ── Wartość ─────────────────────────────────────────────────────────────
|
|
2515
2893
|
get hasValue() {
|
|
@@ -2532,7 +2910,7 @@ var Combobox = class extends Component {
|
|
|
2532
2910
|
const chip = document.createElement("span");
|
|
2533
2911
|
chip.className = "pl-combobox-chip";
|
|
2534
2912
|
chip.dataset.value = item.value;
|
|
2535
|
-
chip.innerHTML = `<span class="pl-combobox-chip-label">${escapeHtml2(item.label)}</span><button class="pl-combobox-chip-remove" type="button" tabindex="-1" aria-label="
|
|
2913
|
+
chip.innerHTML = `<span class="pl-combobox-chip-label">${escapeHtml2(item.label)}</span><button class="pl-combobox-chip-remove" type="button" tabindex="-1" aria-label="${escapeHtml2(t("combobox.remove", { label: item.label }, this.el))}">${svg2("x")}</button>`;
|
|
2536
2914
|
control.insertBefore(chip, input);
|
|
2537
2915
|
}
|
|
2538
2916
|
chips.forEach((chip) => chip.remove());
|
|
@@ -2635,9 +3013,9 @@ var Combobox = class extends Component {
|
|
|
2635
3013
|
setOptions(list, silent = false) {
|
|
2636
3014
|
const items = normalize(list);
|
|
2637
3015
|
if (this.isSelect) {
|
|
2638
|
-
const
|
|
3016
|
+
const keep2 = new Set(this.selected.map((item) => item.value));
|
|
2639
3017
|
[...this.el.options].forEach((option) => {
|
|
2640
|
-
if (option !== this.placeholderOption && !
|
|
3018
|
+
if (option !== this.placeholderOption && !keep2.has(option.value)) option.remove();
|
|
2641
3019
|
});
|
|
2642
3020
|
this.el.querySelectorAll("optgroup:empty").forEach((group) => group.remove());
|
|
2643
3021
|
for (const item of items) {
|
|
@@ -2669,7 +3047,7 @@ var Combobox = class extends Component {
|
|
|
2669
3047
|
this.request++;
|
|
2670
3048
|
this.setLoading(false);
|
|
2671
3049
|
this.items = this.isSelect ? [...this.selected] : [];
|
|
2672
|
-
this.renderList(options.minLength > 0 ?
|
|
3050
|
+
this.renderList(options.minLength > 0 ? t("combobox.minLength", { n: options.minLength }, this.el) : options.emptyText);
|
|
2673
3051
|
return;
|
|
2674
3052
|
}
|
|
2675
3053
|
this.setLoading(true);
|
|
@@ -2682,18 +3060,19 @@ var Combobox = class extends Component {
|
|
|
2682
3060
|
async fetch(query) {
|
|
2683
3061
|
const { options } = this;
|
|
2684
3062
|
const token2 = ++this.request;
|
|
3063
|
+
const { signal } = this;
|
|
2685
3064
|
try {
|
|
2686
3065
|
const source = options.source;
|
|
2687
|
-
const result = typeof source === "function" ? await source(query) : await fetch(`${source}${encodeURIComponent(query)}
|
|
2688
|
-
if (token2 !== this.request) return;
|
|
3066
|
+
const result = typeof source === "function" ? await source(query, { signal }) : await fetch(`${source}${encodeURIComponent(query)}`, { signal }).then((response) => response.json());
|
|
3067
|
+
if (signal.aborted || token2 !== this.request) return;
|
|
2689
3068
|
const items = normalize(result);
|
|
2690
3069
|
this.items = items.map((item) => this.selected.find((other) => other.value === item.value) || item);
|
|
2691
3070
|
this.setLoading(false);
|
|
2692
3071
|
if (this.isOpen) this.renderList(null, void 0, true);
|
|
2693
3072
|
} catch (error) {
|
|
2694
|
-
if (token2 !== this.request) return;
|
|
3073
|
+
if (signal.aborted || token2 !== this.request) return;
|
|
2695
3074
|
this.setLoading(false);
|
|
2696
|
-
this.renderMessage("
|
|
3075
|
+
this.renderMessage(t("combobox.error", {}, this.el));
|
|
2697
3076
|
this.emit("error", { error });
|
|
2698
3077
|
}
|
|
2699
3078
|
}
|
|
@@ -2940,8 +3319,9 @@ var Combobox = class extends Component {
|
|
|
2940
3319
|
if (this.isSelect) this.renderValue();
|
|
2941
3320
|
this.emit("close");
|
|
2942
3321
|
list.classList.add("pl-combobox-list-out");
|
|
3322
|
+
const { signal } = this;
|
|
2943
3323
|
await animationsDone(list);
|
|
2944
|
-
if (this.isOpen) return;
|
|
3324
|
+
if (signal.aborted || this.isOpen) return;
|
|
2945
3325
|
this.stopPlace?.();
|
|
2946
3326
|
this.stopPlace = null;
|
|
2947
3327
|
list.classList.remove("pl-combobox-list-out");
|
|
@@ -2966,16 +3346,17 @@ __publicField(Combobox, "defaults", {
|
|
|
2966
3346
|
options: null,
|
|
2967
3347
|
// lista pozycji (JS)
|
|
2968
3348
|
source: null,
|
|
2969
|
-
// funkcja async (q) => [...] lub adres URL (doklejane ?q)
|
|
3349
|
+
// funkcja async (q, { signal }) => [...] lub adres URL (doklejane ?q)
|
|
2970
3350
|
minLength: 0,
|
|
2971
3351
|
// minimalna długość zapytania dla `source`
|
|
2972
3352
|
delay: 220,
|
|
2973
3353
|
// opóźnienie zapytań `source` (ms)
|
|
2974
3354
|
placement: "bottom-start",
|
|
2975
3355
|
offset: 6,
|
|
2976
|
-
emptyText:
|
|
2977
|
-
|
|
2978
|
-
|
|
3356
|
+
emptyText: null,
|
|
3357
|
+
// domyślnie z tekstów języka strony
|
|
3358
|
+
loadingText: null,
|
|
3359
|
+
createText: null
|
|
2979
3360
|
});
|
|
2980
3361
|
register("combobox", Combobox);
|
|
2981
3362
|
|
|
@@ -3006,26 +3387,16 @@ function toDate(value) {
|
|
|
3006
3387
|
return date.getMonth() === Number(match[2]) - 1 ? date : null;
|
|
3007
3388
|
}
|
|
3008
3389
|
var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dd|d/g;
|
|
3009
|
-
var
|
|
3010
|
-
dialog: "Wybierz dat\u0119",
|
|
3011
|
-
prevMonth: "Poprzedni miesi\u0105c",
|
|
3012
|
-
nextMonth: "Nast\u0119pny miesi\u0105c",
|
|
3013
|
-
prevYear: "Poprzedni rok",
|
|
3014
|
-
nextYear: "Nast\u0119pny rok",
|
|
3015
|
-
prevYears: "Poprzednie lata",
|
|
3016
|
-
nextYears: "Nast\u0119pne lata",
|
|
3017
|
-
pickMonth: "Wybierz miesi\u0105c",
|
|
3018
|
-
pickYear: "Wybierz rok",
|
|
3019
|
-
today: "Dzi\u015B",
|
|
3020
|
-
clear: "Wyczy\u015B\u0107"
|
|
3021
|
-
};
|
|
3390
|
+
var LABEL_KEYS = ["dialog", "prevMonth", "nextMonth", "prevYear", "nextYear", "prevYears", "nextYears", "pickMonth", "pickYear", "today", "clear"];
|
|
3022
3391
|
var Datepicker = class extends Component {
|
|
3023
3392
|
init() {
|
|
3024
3393
|
const { el, options } = this;
|
|
3025
3394
|
this.isInput = el.tagName === "INPUT";
|
|
3026
3395
|
this.inline = !!options.inline || !this.isInput;
|
|
3027
3396
|
this.input = this.isInput ? el : null;
|
|
3028
|
-
|
|
3397
|
+
options.locale ?? (options.locale = langOf(el));
|
|
3398
|
+
const defaults = Object.fromEntries(LABEL_KEYS.map((key) => [key, t(`datepicker.${key}`, {}, el)]));
|
|
3399
|
+
this.labels = { ...defaults, ...options.labels || {} };
|
|
3029
3400
|
this.isOpen = false;
|
|
3030
3401
|
this.view = "days";
|
|
3031
3402
|
this.start = null;
|
|
@@ -3086,7 +3457,7 @@ var Datepicker = class extends Component {
|
|
|
3086
3457
|
try {
|
|
3087
3458
|
return new Intl.DateTimeFormat(options.locale, opts);
|
|
3088
3459
|
} catch {
|
|
3089
|
-
return new Intl.DateTimeFormat("
|
|
3460
|
+
return new Intl.DateTimeFormat("en", opts);
|
|
3090
3461
|
}
|
|
3091
3462
|
};
|
|
3092
3463
|
this.fmt = {
|
|
@@ -3647,8 +4018,9 @@ var Datepicker = class extends Component {
|
|
|
3647
4018
|
if (focus || picker.contains(document.activeElement)) el.focus({ preventScroll: true });
|
|
3648
4019
|
this.emit("close");
|
|
3649
4020
|
picker.classList.add("pl-datepicker-out");
|
|
4021
|
+
const { signal } = this;
|
|
3650
4022
|
await animationsDone(picker);
|
|
3651
|
-
if (this.isOpen) return;
|
|
4023
|
+
if (signal.aborted || this.isOpen) return;
|
|
3652
4024
|
this.stopPlace?.();
|
|
3653
4025
|
this.stopPlace = null;
|
|
3654
4026
|
picker.classList.remove("pl-datepicker-out");
|
|
@@ -3671,7 +4043,8 @@ __publicField(Datepicker, "defaults", {
|
|
|
3671
4043
|
// dni tygodnia: 0 = niedziela … 6 = sobota, np. "0,6"
|
|
3672
4044
|
disabledDates: "",
|
|
3673
4045
|
// konkretne daty ISO rozdzielone przecinkami
|
|
3674
|
-
locale:
|
|
4046
|
+
locale: null,
|
|
4047
|
+
// domyślnie język strony (atrybut lang)
|
|
3675
4048
|
format: "dd.MM.yyyy",
|
|
3676
4049
|
separator: " \u2013 ",
|
|
3677
4050
|
// łącznik dat zakresu
|
|
@@ -3690,7 +4063,6 @@ __publicField(Datepicker, "defaults", {
|
|
|
3690
4063
|
register("datepicker", Datepicker);
|
|
3691
4064
|
|
|
3692
4065
|
// src/js/components/range.js
|
|
3693
|
-
var numberFormat = typeof Intl !== "undefined" ? new Intl.NumberFormat("pl-PL", { maximumFractionDigits: 6 }) : null;
|
|
3694
4066
|
var Range = class extends Component {
|
|
3695
4067
|
init() {
|
|
3696
4068
|
const { el, options } = this;
|
|
@@ -3798,7 +4170,8 @@ var Range = class extends Component {
|
|
|
3798
4170
|
return max > min ? clamp((Number(input.value) - min) / (max - min), 0, 1) : 0;
|
|
3799
4171
|
}
|
|
3800
4172
|
format(value) {
|
|
3801
|
-
|
|
4173
|
+
this.numberFormat ?? (this.numberFormat = new Intl.NumberFormat(langOf(this.el), { maximumFractionDigits: 6 }));
|
|
4174
|
+
const text = this.numberFormat.format(value);
|
|
3802
4175
|
return `${this.options.prefix}${text}${this.options.suffix}`;
|
|
3803
4176
|
}
|
|
3804
4177
|
/** Wartość (liczba) albo para [od, do] w trybie dual. */
|
|
@@ -4013,7 +4386,7 @@ var PasswordToggle = class extends Component {
|
|
|
4013
4386
|
const { el, options } = this;
|
|
4014
4387
|
const visible = this.visible;
|
|
4015
4388
|
el.setAttribute("aria-pressed", String(visible));
|
|
4016
|
-
el.setAttribute("aria-label", visible ? options.labelHide : options.labelShow);
|
|
4389
|
+
el.setAttribute("aria-label", visible ? options.labelHide ?? t("password.hide", {}, el) : options.labelShow ?? t("password.show", {}, el));
|
|
4017
4390
|
el.classList.toggle("pl-active", visible);
|
|
4018
4391
|
const icon = el.matches("[data-pl-icon]") ? el : $("[data-pl-icon]", el);
|
|
4019
4392
|
if (icon) {
|
|
@@ -4044,8 +4417,9 @@ __publicField(PasswordToggle, "defaults", {
|
|
|
4044
4417
|
// selektor pola; domyślnie pole hasła w tym samym opakowaniu
|
|
4045
4418
|
iconShow: "eye",
|
|
4046
4419
|
iconHide: "eye-off",
|
|
4047
|
-
labelShow:
|
|
4048
|
-
|
|
4420
|
+
labelShow: null,
|
|
4421
|
+
// domyślnie z tekstów języka strony
|
|
4422
|
+
labelHide: null
|
|
4049
4423
|
});
|
|
4050
4424
|
__publicField(PasswordToggle, "primary", "target");
|
|
4051
4425
|
register("password-toggle", PasswordToggle);
|
|
@@ -4101,7 +4475,7 @@ var FormClear = class extends Component {
|
|
|
4101
4475
|
init() {
|
|
4102
4476
|
const { el } = this;
|
|
4103
4477
|
if (el.matches("button") && !el.hasAttribute("type")) el.type = "button";
|
|
4104
|
-
if (!el.hasAttribute("aria-label") && !el.textContent.trim()) el.setAttribute("aria-label", "
|
|
4478
|
+
if (!el.hasAttribute("aria-label") && !el.textContent.trim()) el.setAttribute("aria-label", t("clear", {}, el));
|
|
4105
4479
|
this.on(el, "click", (event) => {
|
|
4106
4480
|
event.preventDefault();
|
|
4107
4481
|
this.clear();
|
|
@@ -4121,38 +4495,31 @@ var FormClear = class extends Component {
|
|
|
4121
4495
|
__publicField(FormClear, "defaults", { target: "" });
|
|
4122
4496
|
__publicField(FormClear, "primary", "target");
|
|
4123
4497
|
register("form-clear", FormClear);
|
|
4124
|
-
var plural2 = (n, one, few, many) => {
|
|
4125
|
-
const mod10 = n % 10;
|
|
4126
|
-
const mod100 = n % 100;
|
|
4127
|
-
if (n === 1) return one;
|
|
4128
|
-
if (mod10 >= 2 && mod10 <= 4 && (mod100 < 12 || mod100 > 14)) return few;
|
|
4129
|
-
return many;
|
|
4130
|
-
};
|
|
4131
|
-
var chars = (n) => `${n} ${plural2(n, "znak", "znaki", "znak\xF3w")}`;
|
|
4132
4498
|
function messageFor(field) {
|
|
4133
4499
|
const v = field.validity;
|
|
4134
4500
|
const custom = (key) => field.getAttribute(`data-pl-message-${key}`);
|
|
4501
|
+
const text = (key, vars) => t(`validation.${key}`, vars, field);
|
|
4135
4502
|
if (v.valueMissing) {
|
|
4136
4503
|
if (custom("required")) return custom("required");
|
|
4137
|
-
if (field.type === "checkbox") return "
|
|
4138
|
-
if (field.type === "radio") return "
|
|
4139
|
-
if (field.type === "file") return "
|
|
4140
|
-
if (field.matches("select")) return "
|
|
4141
|
-
return "
|
|
4504
|
+
if (field.type === "checkbox") return text("checkbox");
|
|
4505
|
+
if (field.type === "radio") return text("radio");
|
|
4506
|
+
if (field.type === "file") return text("file");
|
|
4507
|
+
if (field.matches("select")) return text("select");
|
|
4508
|
+
return text("required");
|
|
4142
4509
|
}
|
|
4143
4510
|
if (v.typeMismatch) {
|
|
4144
4511
|
if (custom("type")) return custom("type");
|
|
4145
|
-
if (field.type === "email") return "
|
|
4146
|
-
if (field.type === "url") return "
|
|
4147
|
-
return "
|
|
4148
|
-
}
|
|
4149
|
-
if (v.patternMismatch) return custom("pattern") || field.title || "
|
|
4150
|
-
if (v.tooShort) return custom("minlength") ||
|
|
4151
|
-
if (v.tooLong) return custom("maxlength") ||
|
|
4152
|
-
if (v.rangeUnderflow) return custom("min") ||
|
|
4153
|
-
if (v.rangeOverflow) return custom("max") ||
|
|
4154
|
-
if (v.stepMismatch) return custom("step") || "
|
|
4155
|
-
if (v.badInput) return custom("type") || "
|
|
4512
|
+
if (field.type === "email") return text("email");
|
|
4513
|
+
if (field.type === "url") return text("url");
|
|
4514
|
+
return text("type");
|
|
4515
|
+
}
|
|
4516
|
+
if (v.patternMismatch) return custom("pattern") || field.title || text("pattern");
|
|
4517
|
+
if (v.tooShort) return custom("minlength") || text("minlength", { n: field.minLength, length: field.value.length });
|
|
4518
|
+
if (v.tooLong) return custom("maxlength") || text("maxlength", { n: field.maxLength, length: field.value.length });
|
|
4519
|
+
if (v.rangeUnderflow) return custom("min") || text("min", { min: field.min });
|
|
4520
|
+
if (v.rangeOverflow) return custom("max") || text("max", { max: field.max });
|
|
4521
|
+
if (v.stepMismatch) return custom("step") || text("step");
|
|
4522
|
+
if (v.badInput) return custom("type") || text("bad");
|
|
4156
4523
|
if (v.customError) return field.validationMessage;
|
|
4157
4524
|
return "";
|
|
4158
4525
|
}
|
|
@@ -4512,6 +4879,7 @@ var Drop = class extends Component {
|
|
|
4512
4879
|
});
|
|
4513
4880
|
const { el, toggleEl } = this;
|
|
4514
4881
|
const token2 = ++this.token;
|
|
4882
|
+
const { signal } = this;
|
|
4515
4883
|
this.isOpen = true;
|
|
4516
4884
|
open.push(this);
|
|
4517
4885
|
el.classList.remove("pl-leave");
|
|
@@ -4529,7 +4897,7 @@ var Drop = class extends Component {
|
|
|
4529
4897
|
});
|
|
4530
4898
|
this.emit("show");
|
|
4531
4899
|
animationsDone(el).then(() => {
|
|
4532
|
-
if (token2 === this.token && this.isOpen) this.emit("shown");
|
|
4900
|
+
if (!signal.aborted && token2 === this.token && this.isOpen) this.emit("shown");
|
|
4533
4901
|
});
|
|
4534
4902
|
}
|
|
4535
4903
|
/** Zamyka drop; `refocus` przenosi fokus z powrotem na przełącznik. */
|
|
@@ -4542,6 +4910,7 @@ var Drop = class extends Component {
|
|
|
4542
4910
|
});
|
|
4543
4911
|
const { el, toggleEl } = this;
|
|
4544
4912
|
const token2 = ++this.token;
|
|
4913
|
+
const { signal } = this;
|
|
4545
4914
|
const hadFocus = el.contains(document.activeElement);
|
|
4546
4915
|
this.isOpen = false;
|
|
4547
4916
|
const index = open.indexOf(this);
|
|
@@ -4557,7 +4926,7 @@ var Drop = class extends Component {
|
|
|
4557
4926
|
el.classList.remove("pl-open");
|
|
4558
4927
|
this.emit("hide");
|
|
4559
4928
|
await animationsDone(el);
|
|
4560
|
-
if (token2 !== this.token) return;
|
|
4929
|
+
if (signal.aborted || token2 !== this.token) return;
|
|
4561
4930
|
this.teardown();
|
|
4562
4931
|
this.emit("hidden");
|
|
4563
4932
|
}
|
|
@@ -4880,7 +5249,7 @@ var Popover = class extends Component {
|
|
|
4880
5249
|
const button = document.createElement("button");
|
|
4881
5250
|
button.type = "button";
|
|
4882
5251
|
button.className = "pl-close";
|
|
4883
|
-
button.setAttribute("aria-label", "
|
|
5252
|
+
button.setAttribute("aria-label", t("close", {}, this.el));
|
|
4884
5253
|
button.setAttribute("data-pl-popover-close", "");
|
|
4885
5254
|
return button;
|
|
4886
5255
|
};
|
|
@@ -4957,6 +5326,7 @@ var Popover = class extends Component {
|
|
|
4957
5326
|
if (other !== this && !other.pop?.contains(el)) other.hide();
|
|
4958
5327
|
});
|
|
4959
5328
|
const token2 = ++this.token;
|
|
5329
|
+
const { signal } = this;
|
|
4960
5330
|
this.isOpen = true;
|
|
4961
5331
|
open2.push(this);
|
|
4962
5332
|
pop.classList.remove("pl-leave");
|
|
@@ -4973,7 +5343,7 @@ var Popover = class extends Component {
|
|
|
4973
5343
|
}
|
|
4974
5344
|
this.emit("show");
|
|
4975
5345
|
animationsDone(pop).then(() => {
|
|
4976
|
-
if (token2 === this.token && this.isOpen) this.emit("shown");
|
|
5346
|
+
if (!signal.aborted && token2 === this.token && this.isOpen) this.emit("shown");
|
|
4977
5347
|
});
|
|
4978
5348
|
}
|
|
4979
5349
|
/** Zamyka popover; `refocus` wymusza powrót fokusu na element wyzwalający. */
|
|
@@ -4986,6 +5356,7 @@ var Popover = class extends Component {
|
|
|
4986
5356
|
if (other !== this && pop.contains(other.el)) other.hide();
|
|
4987
5357
|
});
|
|
4988
5358
|
const token2 = ++this.token;
|
|
5359
|
+
const { signal } = this;
|
|
4989
5360
|
const hadFocus = pop.contains(document.activeElement);
|
|
4990
5361
|
this.isOpen = false;
|
|
4991
5362
|
const index = open2.indexOf(this);
|
|
@@ -5002,7 +5373,7 @@ var Popover = class extends Component {
|
|
|
5002
5373
|
pop.classList.remove("pl-open");
|
|
5003
5374
|
this.emit("hide");
|
|
5004
5375
|
await animationsDone(pop);
|
|
5005
|
-
if (token2 !== this.token) return;
|
|
5376
|
+
if (signal.aborted || token2 !== this.token) return;
|
|
5006
5377
|
this.teardown();
|
|
5007
5378
|
this.emit("hidden");
|
|
5008
5379
|
}
|
|
@@ -5134,8 +5505,9 @@ var Overlay = class extends Component {
|
|
|
5134
5505
|
if (!this.options.stack) {
|
|
5135
5506
|
[...opened].filter((other) => other !== this && !other.el.contains(el)).forEach((other) => other.hide());
|
|
5136
5507
|
}
|
|
5137
|
-
this.opener = opener instanceof Element ? opener : document.activeElement;
|
|
5138
5508
|
if (!el.isConnected) document.body.append(el);
|
|
5509
|
+
if (getInstance(el, this.constructor.componentName) !== this) scan(el);
|
|
5510
|
+
this.opener = opener instanceof Element ? opener : document.activeElement;
|
|
5139
5511
|
el.classList.remove("pl-closing");
|
|
5140
5512
|
if (el.open) el.close();
|
|
5141
5513
|
this.state = "open";
|
|
@@ -5165,7 +5537,10 @@ var Overlay = class extends Component {
|
|
|
5165
5537
|
this.state = "closing";
|
|
5166
5538
|
this.el.classList.add("pl-closing");
|
|
5167
5539
|
this.emit("hide");
|
|
5168
|
-
|
|
5540
|
+
const { signal } = this;
|
|
5541
|
+
this.closing = settle([this.el, this.panel]).then(() => {
|
|
5542
|
+
if (!signal.aborted) this.finish();
|
|
5543
|
+
});
|
|
5169
5544
|
return this.closing;
|
|
5170
5545
|
}
|
|
5171
5546
|
/** Domyka okno po animacji (lub natychmiast, gdy zamknęła je przeglądarka). */
|
|
@@ -5220,7 +5595,7 @@ var Modal = class extends Overlay {
|
|
|
5220
5595
|
__publicField(Modal, "defaults", { ...Overlay.defaults });
|
|
5221
5596
|
register("modal", Modal);
|
|
5222
5597
|
delegateOpen("modal");
|
|
5223
|
-
var labels = {
|
|
5598
|
+
var labels = {};
|
|
5224
5599
|
var escapeHtml3 = (value) => String(value ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
5225
5600
|
function dialog(content, options = {}) {
|
|
5226
5601
|
const { cls = "", ...rest } = options;
|
|
@@ -5245,8 +5620,8 @@ function ask(kind, message, options = {}, value = "") {
|
|
|
5245
5620
|
const {
|
|
5246
5621
|
title = "",
|
|
5247
5622
|
html = false,
|
|
5248
|
-
ok = labels.ok,
|
|
5249
|
-
cancel = labels.cancel,
|
|
5623
|
+
ok = labels.ok ?? t("modal.ok"),
|
|
5624
|
+
cancel = labels.cancel ?? t("modal.cancel"),
|
|
5250
5625
|
tone = "primary",
|
|
5251
5626
|
cls = "pl-modal-small pl-modal-center",
|
|
5252
5627
|
placeholder = "",
|
|
@@ -5310,7 +5685,7 @@ var Offcanvas = class extends Overlay {
|
|
|
5310
5685
|
this.side = side;
|
|
5311
5686
|
SIDES.forEach((name) => el.classList.toggle(`pl-offcanvas-${name}`, name === side));
|
|
5312
5687
|
el.classList.toggle("pl-offcanvas-no-overlay", !this.options.overlay);
|
|
5313
|
-
if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) el.setAttribute("aria-label", "
|
|
5688
|
+
if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) el.setAttribute("aria-label", t("offcanvas.label", {}, el));
|
|
5314
5689
|
this.on(el, "click", (event) => {
|
|
5315
5690
|
if (!this.options.anchorClose) return;
|
|
5316
5691
|
const link = event.target.closest('a[href^="#"]');
|
|
@@ -5500,8 +5875,8 @@ var Toast = class {
|
|
|
5500
5875
|
action.className = "pl-notification-action";
|
|
5501
5876
|
action.textContent = String(options.action.label);
|
|
5502
5877
|
action.addEventListener("click", () => {
|
|
5503
|
-
const
|
|
5504
|
-
if (!
|
|
5878
|
+
const keep2 = options.action.onClick?.(this.handle) === false;
|
|
5879
|
+
if (!keep2) this.close();
|
|
5505
5880
|
});
|
|
5506
5881
|
content.append(action);
|
|
5507
5882
|
}
|
|
@@ -5510,7 +5885,7 @@ var Toast = class {
|
|
|
5510
5885
|
const close = document.createElement("button");
|
|
5511
5886
|
close.type = "button";
|
|
5512
5887
|
close.className = "pl-close pl-notification-close";
|
|
5513
|
-
close.setAttribute("aria-label", "
|
|
5888
|
+
close.setAttribute("aria-label", t("notification.close"));
|
|
5514
5889
|
close.addEventListener("click", () => this.close());
|
|
5515
5890
|
el.append(close);
|
|
5516
5891
|
}
|
|
@@ -5778,20 +6153,20 @@ var LightboxPanel = class {
|
|
|
5778
6153
|
const el = document.createElement("dialog");
|
|
5779
6154
|
el.className = `pl-lightbox pl-lightbox-${animation === "fade" ? "fade" : "slide"}`;
|
|
5780
6155
|
el.dataset.plTheme = "dark";
|
|
5781
|
-
el.setAttribute("aria-label", "
|
|
5782
|
-
el.setAttribute("aria-roledescription", "
|
|
6156
|
+
el.setAttribute("aria-label", t("lightbox.label", {}, el));
|
|
6157
|
+
el.setAttribute("aria-roledescription", t("lightbox.role", {}, el));
|
|
5783
6158
|
el.innerHTML = `
|
|
5784
6159
|
<div class="pl-lightbox-backdrop"></div>
|
|
5785
6160
|
<div class="pl-lightbox-toolbar">
|
|
5786
6161
|
${counter && many ? '<span class="pl-lightbox-counter" aria-live="polite"></span>' : ""}
|
|
5787
|
-
<button class="pl-close pl-lightbox-close" type="button" aria-label="
|
|
6162
|
+
<button class="pl-close pl-lightbox-close" type="button" aria-label="${t("close", {}, el)}"></button>
|
|
5788
6163
|
</div>
|
|
5789
6164
|
<div class="pl-lightbox-stage"></div>
|
|
5790
|
-
${many ? `<button class="pl-lightbox-nav pl-lightbox-previous pl-slidenav-previous" type="button" aria-label="
|
|
5791
|
-
<button class="pl-lightbox-nav pl-lightbox-next pl-slidenav-next" type="button" aria-label="
|
|
6165
|
+
${many ? `<button class="pl-lightbox-nav pl-lightbox-previous pl-slidenav-previous" type="button" aria-label="${t("previous", {}, el)}">${ICONS2.previous}</button>
|
|
6166
|
+
<button class="pl-lightbox-nav pl-lightbox-next pl-slidenav-next" type="button" aria-label="${t("next", {}, el)}">${ICONS2.next}</button>` : ""}
|
|
5792
6167
|
<div class="pl-lightbox-footer">
|
|
5793
6168
|
<div class="pl-lightbox-caption"></div>
|
|
5794
|
-
${thumbs && many ?
|
|
6169
|
+
${thumbs && many ? `<div class="pl-lightbox-thumbs" role="tablist" aria-label="${t("lightbox.thumbs", {}, el)}"></div>` : ""}
|
|
5795
6170
|
</div>`;
|
|
5796
6171
|
this.el = el;
|
|
5797
6172
|
this.stage = el.querySelector(".pl-lightbox-stage");
|
|
@@ -5806,7 +6181,7 @@ var LightboxPanel = class {
|
|
|
5806
6181
|
button.type = "button";
|
|
5807
6182
|
button.className = "pl-lightbox-thumb";
|
|
5808
6183
|
button.setAttribute("role", "tab");
|
|
5809
|
-
button.setAttribute("aria-label",
|
|
6184
|
+
button.setAttribute("aria-label", `${t("lightbox.item", { n: i + 1 }, this.el)}${item.caption ? `: ${item.caption}` : ""}`);
|
|
5810
6185
|
const src = item.thumb || (item.type === "image" ? item.source : "");
|
|
5811
6186
|
if (src) {
|
|
5812
6187
|
const img = document.createElement("img");
|
|
@@ -5916,7 +6291,7 @@ var LightboxPanel = class {
|
|
|
5916
6291
|
const spinner = document.createElement("div");
|
|
5917
6292
|
spinner.className = "pl-lightbox-spinner";
|
|
5918
6293
|
spinner.setAttribute("role", "status");
|
|
5919
|
-
spinner.setAttribute("aria-label", "
|
|
6294
|
+
spinner.setAttribute("aria-label", t("loading", {}, this.el));
|
|
5920
6295
|
const done = () => {
|
|
5921
6296
|
wrap.classList.remove("pl-loading");
|
|
5922
6297
|
spinner.remove();
|
|
@@ -5925,7 +6300,7 @@ var LightboxPanel = class {
|
|
|
5925
6300
|
done();
|
|
5926
6301
|
const error = document.createElement("div");
|
|
5927
6302
|
error.className = "pl-lightbox-error";
|
|
5928
|
-
error.textContent = "
|
|
6303
|
+
error.textContent = t("lightbox.error", {}, this.el);
|
|
5929
6304
|
wrap.querySelector(".pl-lightbox-media")?.replaceWith(error);
|
|
5930
6305
|
};
|
|
5931
6306
|
let media;
|
|
@@ -5942,7 +6317,7 @@ var LightboxPanel = class {
|
|
|
5942
6317
|
media = document.createElement("iframe");
|
|
5943
6318
|
media.allow = "autoplay; fullscreen; picture-in-picture; encrypted-media";
|
|
5944
6319
|
media.allowFullscreen = true;
|
|
5945
|
-
media.title = item.caption || "
|
|
6320
|
+
media.title = item.caption || t("lightbox.embed", {}, this.el);
|
|
5946
6321
|
media.addEventListener("load", done, { once: true });
|
|
5947
6322
|
media.src = embedUrl(item.source);
|
|
5948
6323
|
} else {
|
|
@@ -6642,6 +7017,7 @@ var Switcher = class extends Component {
|
|
|
6642
7017
|
if (panel) tab.setAttribute("aria-controls", panel.id || (panel.id = uid("pl-panel")));
|
|
6643
7018
|
});
|
|
6644
7019
|
const token2 = ++this.token;
|
|
7020
|
+
const { signal } = this;
|
|
6645
7021
|
const detail = { index, previous, item: items[index] };
|
|
6646
7022
|
if (animate && previous > -1) this.emit("hide", { index: previous, item: items[previous] });
|
|
6647
7023
|
const pending = [];
|
|
@@ -6667,7 +7043,7 @@ var Switcher = class extends Component {
|
|
|
6667
7043
|
if (hash && hash !== location.hash) history.replaceState(null, "", hash);
|
|
6668
7044
|
}
|
|
6669
7045
|
Promise.all(pending).then(() => {
|
|
6670
|
-
if (token2 === this.token) this.emit("shown", detail);
|
|
7046
|
+
if (!signal.aborted && token2 === this.token) this.emit("shown", detail);
|
|
6671
7047
|
});
|
|
6672
7048
|
}
|
|
6673
7049
|
async animateIn(panel, forward) {
|
|
@@ -6732,12 +7108,12 @@ register("switcher", Switcher);
|
|
|
6732
7108
|
|
|
6733
7109
|
// src/js/components/scroll.js
|
|
6734
7110
|
var EASINGS = {
|
|
6735
|
-
linear: (
|
|
6736
|
-
"ease-in": (
|
|
6737
|
-
"ease-out": (
|
|
6738
|
-
"ease-in-out": (
|
|
7111
|
+
linear: (t2) => t2,
|
|
7112
|
+
"ease-in": (t2) => t2 * t2 * t2,
|
|
7113
|
+
"ease-out": (t2) => 1 - (1 - t2) ** 4,
|
|
7114
|
+
"ease-in-out": (t2) => t2 < 0.5 ? 8 * t2 ** 4 : 1 - (-2 * t2 + 2) ** 4 / 2,
|
|
6739
7115
|
// Lekkie przestrzelenie i powrót.
|
|
6740
|
-
spring: (
|
|
7116
|
+
spring: (t2) => 1 + 2.2 * (t2 - 1) ** 3 + 1.2 * (t2 - 1) ** 2
|
|
6741
7117
|
};
|
|
6742
7118
|
var running = /* @__PURE__ */ new WeakMap();
|
|
6743
7119
|
function scrollParent(el) {
|
|
@@ -6791,9 +7167,9 @@ function scrollTo(target, options = {}) {
|
|
|
6791
7167
|
finish(false);
|
|
6792
7168
|
};
|
|
6793
7169
|
const step = (now) => {
|
|
6794
|
-
const
|
|
6795
|
-
container.scrollTop = start2 + distance * ease(
|
|
6796
|
-
if (
|
|
7170
|
+
const t2 = clamp((now - startTime) / time, 0, 1);
|
|
7171
|
+
container.scrollTop = start2 + distance * ease(t2);
|
|
7172
|
+
if (t2 < 1) frame = requestAnimationFrame(step);
|
|
6797
7173
|
else {
|
|
6798
7174
|
container.scrollTop = end;
|
|
6799
7175
|
finish(true);
|
|
@@ -7586,9 +7962,9 @@ function rubber(distance, dimension, factor = 0.55) {
|
|
|
7586
7962
|
function velocityTracker() {
|
|
7587
7963
|
let samples = [];
|
|
7588
7964
|
return {
|
|
7589
|
-
add(x,
|
|
7590
|
-
samples.push({ x, t });
|
|
7591
|
-
while (samples.length > 2 &&
|
|
7965
|
+
add(x, t2) {
|
|
7966
|
+
samples.push({ x, t: t2 });
|
|
7967
|
+
while (samples.length > 2 && t2 - samples[0].t > 100) samples.shift();
|
|
7592
7968
|
},
|
|
7593
7969
|
get(now) {
|
|
7594
7970
|
if (samples.length < 2) return 0;
|
|
@@ -7612,15 +7988,16 @@ var Carousel = class extends Component {
|
|
|
7612
7988
|
this.index = 0;
|
|
7613
7989
|
this.pauses = /* @__PURE__ */ new Set();
|
|
7614
7990
|
this.autoplayOn = Boolean(this.options.autoplay);
|
|
7615
|
-
this.generatedNavs = /* @__PURE__ */ new
|
|
7991
|
+
this.generatedNavs = /* @__PURE__ */ new Set();
|
|
7992
|
+
this.onDestroy(() => this.generatedNavs.forEach((nav) => nav.replaceChildren()));
|
|
7616
7993
|
this._timer = 0;
|
|
7617
7994
|
this._remaining = 0;
|
|
7618
7995
|
this._startedAt = 0;
|
|
7619
|
-
const
|
|
7996
|
+
const carousel = t("slider.carousel", {}, el);
|
|
7620
7997
|
if (!el.hasAttribute("role")) el.setAttribute("role", "region");
|
|
7621
|
-
el.setAttribute("aria-roledescription",
|
|
7998
|
+
el.setAttribute("aria-roledescription", carousel);
|
|
7622
7999
|
if (!el.hasAttribute("aria-label") && !el.hasAttribute("aria-labelledby")) {
|
|
7623
|
-
el.setAttribute("aria-label",
|
|
8000
|
+
el.setAttribute("aria-label", carousel[0].toUpperCase() + carousel.slice(1));
|
|
7624
8001
|
}
|
|
7625
8002
|
if (!el.hasAttribute("tabindex")) el.tabIndex = 0;
|
|
7626
8003
|
(_a = this.list).id || (_a.id = uid(`pl-${p}`));
|
|
@@ -7680,20 +8057,19 @@ var Carousel = class extends Component {
|
|
|
7680
8057
|
}
|
|
7681
8058
|
/** Opisuje slajdy dla czytników ekranu. */
|
|
7682
8059
|
labelSlides() {
|
|
7683
|
-
const L = this.constructor.labels;
|
|
7684
8060
|
const slides = this.slides;
|
|
8061
|
+
const role = t("slider.slide", {}, this.el);
|
|
7685
8062
|
slides.forEach((slide, i) => {
|
|
7686
8063
|
if (!slide.matches("li")) slide.setAttribute("role", "group");
|
|
7687
|
-
slide.setAttribute("aria-roledescription",
|
|
8064
|
+
slide.setAttribute("aria-roledescription", role);
|
|
7688
8065
|
if (slide.hasAttribute("aria-label") && !slide.dataset.plAuto) return;
|
|
7689
8066
|
slide.dataset.plAuto = "1";
|
|
7690
|
-
slide.setAttribute("aria-label",
|
|
8067
|
+
slide.setAttribute("aria-label", t("slider.position", { n: i + 1, count: slides.length }, this.el));
|
|
7691
8068
|
});
|
|
7692
8069
|
}
|
|
7693
8070
|
/** Buduje kropki w pustych `.pl-{p}-nav` i numeruje pozycje własnych nawigacji. */
|
|
7694
8071
|
buildNav() {
|
|
7695
8072
|
const p = this.constructor.prefix;
|
|
7696
|
-
const L = this.constructor.labels;
|
|
7697
8073
|
const indexes = this.navIndexes();
|
|
7698
8074
|
for (const nav of $$(`.pl-${p}-nav`, this.el)) {
|
|
7699
8075
|
if (!this.owns(nav)) continue;
|
|
@@ -7701,7 +8077,7 @@ var Carousel = class extends Component {
|
|
|
7701
8077
|
this.generatedNavs.add(nav);
|
|
7702
8078
|
const current2 = [...nav.children].map((li) => li.getAttribute(this.attr)).join();
|
|
7703
8079
|
if (current2 !== indexes.join()) {
|
|
7704
|
-
nav.innerHTML = indexes.map((i) => `<li ${this.attr}="${i}"><a href="#" role="button" aria-label="${
|
|
8080
|
+
nav.innerHTML = indexes.map((i) => `<li ${this.attr}="${i}"><a href="#" role="button" aria-label="${t("slider.goto", { n: i + 1 }, this.el)}"></a></li>`).join("");
|
|
7705
8081
|
}
|
|
7706
8082
|
} else {
|
|
7707
8083
|
[...nav.children].forEach((item, i) => {
|
|
@@ -7804,14 +8180,6 @@ var Carousel = class extends Component {
|
|
|
7804
8180
|
}
|
|
7805
8181
|
};
|
|
7806
8182
|
__publicField(Carousel, "prefix", "slider");
|
|
7807
|
-
__publicField(Carousel, "labels", {
|
|
7808
|
-
carousel: "karuzela",
|
|
7809
|
-
slide: "slajd",
|
|
7810
|
-
of: "z",
|
|
7811
|
-
previous: "Poprzedni slajd",
|
|
7812
|
-
next: "Nast\u0119pny slajd",
|
|
7813
|
-
goto: "Slajd"
|
|
7814
|
-
});
|
|
7815
8183
|
var Slider = class extends Carousel {
|
|
7816
8184
|
init() {
|
|
7817
8185
|
if (!this.setup()) return;
|
|
@@ -8099,13 +8467,13 @@ var Slider = class extends Carousel {
|
|
|
8099
8467
|
d.tracker.add(event.clientX, event.timeStamp);
|
|
8100
8468
|
this.render();
|
|
8101
8469
|
});
|
|
8102
|
-
const
|
|
8470
|
+
const release2 = (event) => {
|
|
8103
8471
|
const d = this.drag;
|
|
8104
8472
|
if (!d || event.pointerId !== d.id) return;
|
|
8105
8473
|
this.endDrag(event.type === "pointercancel", event.timeStamp);
|
|
8106
8474
|
};
|
|
8107
|
-
this.on(window, "pointerup",
|
|
8108
|
-
this.on(window, "pointercancel",
|
|
8475
|
+
this.on(window, "pointerup", release2);
|
|
8476
|
+
this.on(window, "pointercancel", release2);
|
|
8109
8477
|
this.on(
|
|
8110
8478
|
c,
|
|
8111
8479
|
"click",
|
|
@@ -8413,7 +8781,7 @@ var Slideshow = class extends Carousel {
|
|
|
8413
8781
|
d.tracker.add(event.clientX, event.timeStamp);
|
|
8414
8782
|
this.renderTransition();
|
|
8415
8783
|
});
|
|
8416
|
-
const
|
|
8784
|
+
const release2 = (event) => {
|
|
8417
8785
|
const d = this.drag;
|
|
8418
8786
|
if (!d || event.pointerId !== d.id) return;
|
|
8419
8787
|
this.drag = null;
|
|
@@ -8432,8 +8800,8 @@ var Slideshow = class extends Carousel {
|
|
|
8432
8800
|
if (forward && this.commit()) this.run(1, v);
|
|
8433
8801
|
else this.run(0, v);
|
|
8434
8802
|
};
|
|
8435
|
-
this.on(window, "pointerup",
|
|
8436
|
-
this.on(window, "pointercancel",
|
|
8803
|
+
this.on(window, "pointerup", release2);
|
|
8804
|
+
this.on(window, "pointercancel", release2);
|
|
8437
8805
|
this.on(
|
|
8438
8806
|
c,
|
|
8439
8807
|
"click",
|
|
@@ -8511,7 +8879,7 @@ function a11yNodes() {
|
|
|
8511
8879
|
helpText = document.createElement("div");
|
|
8512
8880
|
helpText.id = "pl-sortable-help";
|
|
8513
8881
|
helpText.hidden = true;
|
|
8514
|
-
helpText.textContent = "
|
|
8882
|
+
helpText.textContent = t("sortable.help");
|
|
8515
8883
|
liveRegion = document.createElement("div");
|
|
8516
8884
|
liveRegion.setAttribute("aria-live", "assertive");
|
|
8517
8885
|
liveRegion.setAttribute("aria-atomic", "true");
|
|
@@ -8605,7 +8973,7 @@ var Sortable = class extends Component {
|
|
|
8605
8973
|
if (!item.dataset.plSortableTab && item.hasAttribute("tabindex")) continue;
|
|
8606
8974
|
item.dataset.plSortableTab = item === current2 ? "0" : "-1";
|
|
8607
8975
|
item.tabIndex = item === current2 ? 0 : -1;
|
|
8608
|
-
item.setAttribute("aria-roledescription", "
|
|
8976
|
+
item.setAttribute("aria-roledescription", t("sortable.role", {}, this.el));
|
|
8609
8977
|
item.setAttribute("aria-describedby", help.id);
|
|
8610
8978
|
}
|
|
8611
8979
|
}
|
|
@@ -8743,22 +9111,22 @@ var Sortable = class extends Component {
|
|
|
8743
9111
|
return;
|
|
8744
9112
|
}
|
|
8745
9113
|
if (animating.has(target)) return;
|
|
8746
|
-
const
|
|
9114
|
+
const t2 = target.getBoundingClientRect();
|
|
8747
9115
|
const r = item.getBoundingClientRect();
|
|
8748
9116
|
let before;
|
|
8749
9117
|
if (item.parentElement === sortable.el) {
|
|
8750
9118
|
before = Boolean(item.compareDocumentPosition(target) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
8751
|
-
const sameRow =
|
|
8752
|
-
if (sameRow &&
|
|
8753
|
-
if (before ? s.x >
|
|
8754
|
-
} else if (!sameRow &&
|
|
8755
|
-
if (before ? s.y >
|
|
9119
|
+
const sameRow = t2.top < r.bottom - 1 && t2.bottom > r.top + 1;
|
|
9120
|
+
if (sameRow && t2.width > r.width + 1) {
|
|
9121
|
+
if (before ? s.x > t2.left + r.width : s.x < t2.right - r.width) return;
|
|
9122
|
+
} else if (!sameRow && t2.height > r.height + 1) {
|
|
9123
|
+
if (before ? s.y > t2.top + r.height : s.y < t2.bottom - r.height) return;
|
|
8756
9124
|
}
|
|
8757
9125
|
} else {
|
|
8758
9126
|
const sibling = target.nextElementSibling || target.previousElementSibling;
|
|
8759
9127
|
const sr = sibling?.getBoundingClientRect();
|
|
8760
|
-
const horizontal = sr ? sr.top <
|
|
8761
|
-
before = horizontal ? s.x <
|
|
9128
|
+
const horizontal = sr ? sr.top < t2.bottom - 1 && sr.bottom > t2.top + 1 : false;
|
|
9129
|
+
before = horizontal ? s.x < t2.left + t2.width / 2 : s.y < t2.top + t2.height / 2;
|
|
8762
9130
|
}
|
|
8763
9131
|
this.insert(sortable, before ? target : target.nextElementSibling);
|
|
8764
9132
|
}
|
|
@@ -8889,7 +9257,7 @@ var Sortable = class extends Component {
|
|
|
8889
9257
|
if (!this.emit("start", { item, index, from: index }, true)) return;
|
|
8890
9258
|
this.kb = { item, next: item.nextElementSibling, index };
|
|
8891
9259
|
item.classList.add("pl-sortable-grabbed");
|
|
8892
|
-
announce(
|
|
9260
|
+
announce(t("sortable.lifted", { label: this.label(item), n: index + 1, count }, this.el));
|
|
8893
9261
|
} else if (arrow || key === "Home" || key === "End") {
|
|
8894
9262
|
const next = key === "Home" ? this.items[0] : key === "End" ? this.items[count - 1] : this.neighbor(item, key);
|
|
8895
9263
|
if (next) {
|
|
@@ -8909,7 +9277,7 @@ var Sortable = class extends Component {
|
|
|
8909
9277
|
item.focus({ preventScroll: true });
|
|
8910
9278
|
this.kbMoving = false;
|
|
8911
9279
|
item.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
8912
|
-
announce(
|
|
9280
|
+
announce(t("sortable.moved", { n: this.items.indexOf(item) + 1, count }, this.el));
|
|
8913
9281
|
} else if (key === " " || key === "Enter") {
|
|
8914
9282
|
event.preventDefault();
|
|
8915
9283
|
this.dropKey();
|
|
@@ -8936,7 +9304,7 @@ var Sortable = class extends Component {
|
|
|
8936
9304
|
const to = this.items.indexOf(item);
|
|
8937
9305
|
const count = this.items.length;
|
|
8938
9306
|
announce(
|
|
8939
|
-
cancelled ?
|
|
9307
|
+
cancelled ? t("sortable.cancelled", { label: this.label(item), n: to + 1, count }, this.el) : t("sortable.dropped", { label: this.label(item), n: to + 1, count }, this.el)
|
|
8940
9308
|
);
|
|
8941
9309
|
if (to !== k.index) this.emit("moved", { item, from: k.index, to });
|
|
8942
9310
|
this.emit("stop", { item, from: k.index, to, target: this, cancelled });
|
|
@@ -8959,7 +9327,6 @@ register("sortable", Sortable);
|
|
|
8959
9327
|
// src/js/components/filter.js
|
|
8960
9328
|
var EASE3 = "cubic-bezier(0.33, 0.5, 0.2, 1)";
|
|
8961
9329
|
var CONTROL = "[data-pl-filter-control]";
|
|
8962
|
-
var collator = typeof Intl !== "undefined" ? new Intl.Collator("pl", { numeric: true, sensitivity: "base" }) : null;
|
|
8963
9330
|
function parseControl(control) {
|
|
8964
9331
|
const raw = control.getAttribute("data-pl-filter-control") || "";
|
|
8965
9332
|
const parsed = parseOptions(raw, { filter: "", group: "", sort: "", order: "asc" }, "filter");
|
|
@@ -9085,7 +9452,8 @@ var Filter = class extends Component {
|
|
|
9085
9452
|
const [attribute, order] = this.state.sort;
|
|
9086
9453
|
let sorted = children;
|
|
9087
9454
|
if (attribute) {
|
|
9088
|
-
const
|
|
9455
|
+
const collator = new Intl.Collator(langOf(this.el), { numeric: true, sensitivity: "base" });
|
|
9456
|
+
const compare = (a, b) => collator.compare(a, b);
|
|
9089
9457
|
sorted = [...children].sort(
|
|
9090
9458
|
(a, b) => compare(a.getAttribute(attribute) || "", b.getAttribute(attribute) || "") * (order === "desc" ? -1 : 1)
|
|
9091
9459
|
);
|
|
@@ -9237,8 +9605,9 @@ var Video = class extends Component {
|
|
|
9237
9605
|
this.ready = true;
|
|
9238
9606
|
if (this.wanted) this.play();
|
|
9239
9607
|
});
|
|
9608
|
+
const { signal } = this;
|
|
9240
9609
|
setTimeout(() => {
|
|
9241
|
-
if (this.ready) return;
|
|
9610
|
+
if (signal.aborted || this.ready) return;
|
|
9242
9611
|
this.ready = true;
|
|
9243
9612
|
if (this.wanted) this.play();
|
|
9244
9613
|
}, 1500);
|
|
@@ -9314,9 +9683,9 @@ var Video = class extends Component {
|
|
|
9314
9683
|
this.emit("play");
|
|
9315
9684
|
}
|
|
9316
9685
|
/** `keep` — zachowaj zamiar odtwarzania (wznowienie po powrocie na kartę). */
|
|
9317
|
-
pause(
|
|
9686
|
+
pause(keep2 = false) {
|
|
9318
9687
|
const { el, options } = this;
|
|
9319
|
-
if (!
|
|
9688
|
+
if (!keep2) this.wanted = false;
|
|
9320
9689
|
if (!this.ready) return;
|
|
9321
9690
|
if (this.native) {
|
|
9322
9691
|
el.pause();
|
|
@@ -9348,9 +9717,9 @@ register("video", Video);
|
|
|
9348
9717
|
|
|
9349
9718
|
// src/js/components/counter.js
|
|
9350
9719
|
var EASINGS2 = {
|
|
9351
|
-
linear: (
|
|
9352
|
-
"ease-out": (
|
|
9353
|
-
"ease-in-out": (
|
|
9720
|
+
linear: (t2) => t2,
|
|
9721
|
+
"ease-out": (t2) => 1 - (1 - t2) ** 4,
|
|
9722
|
+
"ease-in-out": (t2) => t2 < 0.5 ? 8 * t2 ** 4 : 1 - (-2 * t2 + 2) ** 4 / 2
|
|
9354
9723
|
};
|
|
9355
9724
|
var Counter = class extends Component {
|
|
9356
9725
|
init() {
|
|
@@ -9359,21 +9728,30 @@ var Counter = class extends Component {
|
|
|
9359
9728
|
this.timer = 0;
|
|
9360
9729
|
this.done = false;
|
|
9361
9730
|
const text = el.textContent.trim();
|
|
9731
|
+
options.locale ?? (options.locale = langOf(el));
|
|
9362
9732
|
if (options.to === null || options.to === "") {
|
|
9363
|
-
const
|
|
9733
|
+
const decimal = (() => {
|
|
9734
|
+
try {
|
|
9735
|
+
return new Intl.NumberFormat(options.locale).format(1.5).replace(/\d/g, "") || ".";
|
|
9736
|
+
} catch {
|
|
9737
|
+
return ".";
|
|
9738
|
+
}
|
|
9739
|
+
})();
|
|
9740
|
+
const digits = text.replace(new RegExp(`[^\\d\\-${decimal === "." ? "\\." : decimal}]`, "g"), "");
|
|
9741
|
+
const parsed = parseFloat(decimal === "." ? digits : digits.replace(decimal, "."));
|
|
9364
9742
|
this.to = Number.isNaN(parsed) ? 0 : parsed;
|
|
9365
9743
|
} else {
|
|
9366
9744
|
this.to = Number(options.to) || 0;
|
|
9367
9745
|
}
|
|
9368
9746
|
this.from = Number(options.from) || 0;
|
|
9369
9747
|
try {
|
|
9370
|
-
this.formatter = new Intl.NumberFormat(options.locale || "
|
|
9748
|
+
this.formatter = new Intl.NumberFormat(options.locale || "en", {
|
|
9371
9749
|
minimumFractionDigits: options.decimals,
|
|
9372
9750
|
maximumFractionDigits: options.decimals,
|
|
9373
9751
|
useGrouping: "always"
|
|
9374
9752
|
});
|
|
9375
9753
|
} catch {
|
|
9376
|
-
this.formatter = new Intl.NumberFormat("
|
|
9754
|
+
this.formatter = new Intl.NumberFormat("en", { minimumFractionDigits: options.decimals, maximumFractionDigits: options.decimals });
|
|
9377
9755
|
}
|
|
9378
9756
|
this.visual = document.createElement("span");
|
|
9379
9757
|
this.visual.setAttribute("aria-hidden", "true");
|
|
@@ -9460,9 +9838,9 @@ var Counter = class extends Component {
|
|
|
9460
9838
|
const run = () => {
|
|
9461
9839
|
const startTime = performance.now();
|
|
9462
9840
|
const step = (now) => {
|
|
9463
|
-
const
|
|
9464
|
-
if (
|
|
9465
|
-
this.render(from + (end - from) * ease(
|
|
9841
|
+
const t2 = Math.min((now - startTime) / duration, 1);
|
|
9842
|
+
if (t2 < 1) {
|
|
9843
|
+
this.render(from + (end - from) * ease(t2));
|
|
9466
9844
|
this.frame = requestAnimationFrame(step);
|
|
9467
9845
|
} else {
|
|
9468
9846
|
this.frame = 0;
|
|
@@ -9483,12 +9861,13 @@ __publicField(Counter, "defaults", {
|
|
|
9483
9861
|
delay: 0,
|
|
9484
9862
|
decimals: 0,
|
|
9485
9863
|
separator: null,
|
|
9486
|
-
// separator tysięcy; domyślnie wg
|
|
9864
|
+
// separator tysięcy; domyślnie wg języka (pl: spacja niełamiąca, en: przecinek)
|
|
9487
9865
|
decimal: null,
|
|
9488
|
-
// separator dziesiętny; domyślnie wg
|
|
9866
|
+
// separator dziesiętny; domyślnie wg języka (pl: przecinek, en: kropka)
|
|
9489
9867
|
prefix: "",
|
|
9490
9868
|
suffix: "",
|
|
9491
|
-
locale:
|
|
9869
|
+
locale: null,
|
|
9870
|
+
// domyślnie język strony (atrybut lang)
|
|
9492
9871
|
easing: "ease-out",
|
|
9493
9872
|
// linear | ease-out | ease-in-out
|
|
9494
9873
|
once: true,
|
|
@@ -9677,17 +10056,22 @@ export {
|
|
|
9677
10056
|
$,
|
|
9678
10057
|
$$,
|
|
9679
10058
|
Component,
|
|
10059
|
+
addLocale,
|
|
9680
10060
|
animateClass,
|
|
9681
10061
|
animationsDone,
|
|
9682
10062
|
api,
|
|
9683
10063
|
autoPlace,
|
|
9684
10064
|
camel,
|
|
9685
10065
|
clamp,
|
|
10066
|
+
config,
|
|
9686
10067
|
debounce,
|
|
9687
10068
|
index_default as default,
|
|
9688
10069
|
focusables,
|
|
9689
10070
|
getInstance,
|
|
9690
10071
|
hideLayer,
|
|
10072
|
+
langOf,
|
|
10073
|
+
localeOf,
|
|
10074
|
+
locales,
|
|
9691
10075
|
lockScroll,
|
|
9692
10076
|
parseOptions,
|
|
9693
10077
|
place,
|
|
@@ -9698,6 +10082,7 @@ export {
|
|
|
9698
10082
|
scan,
|
|
9699
10083
|
showLayer,
|
|
9700
10084
|
start,
|
|
10085
|
+
t,
|
|
9701
10086
|
toggleHeight,
|
|
9702
10087
|
uid,
|
|
9703
10088
|
unlockScroll
|