beercss 3.9.7 → 3.10.1

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.
Files changed (46) hide show
  1. package/README.md +40 -41
  2. package/custom-element/index.js +7 -0
  3. package/dist/cdn/beer.css +475 -542
  4. package/dist/cdn/beer.custom-element.js +38 -0
  5. package/dist/cdn/beer.custom-element.min.js +1 -0
  6. package/dist/cdn/beer.js +77 -150
  7. package/dist/cdn/beer.min.css +1 -1
  8. package/dist/cdn/beer.min.js +1 -1
  9. package/dist/cdn/beer.scoped.css +4348 -0
  10. package/dist/cdn/beer.scoped.min.css +1 -0
  11. package/package.json +5 -3
  12. package/scoped/index.js +6 -0
  13. package/src/cdn/beer.css +3 -3
  14. package/src/cdn/beer.ts +1 -1
  15. package/src/cdn/customElement.js +38 -0
  16. package/src/cdn/elements/badges.css +7 -21
  17. package/src/cdn/elements/buttons.css +7 -16
  18. package/src/cdn/elements/cards.css +2 -1
  19. package/src/cdn/elements/chips.css +5 -8
  20. package/src/cdn/elements/dialogs.css +52 -26
  21. package/src/cdn/elements/fields.css +25 -36
  22. package/src/cdn/elements/fields.ts +1 -1
  23. package/src/cdn/elements/grids.css +7 -7
  24. package/src/cdn/elements/icons.css +13 -13
  25. package/src/cdn/elements/layouts.css +17 -30
  26. package/src/cdn/elements/mainLayouts.css +163 -0
  27. package/src/cdn/elements/media.css +24 -46
  28. package/src/cdn/elements/menus.css +27 -27
  29. package/src/cdn/elements/navigations.css +31 -11
  30. package/src/cdn/elements/pages.css +6 -7
  31. package/src/cdn/elements/selections.css +13 -13
  32. package/src/cdn/elements/sliders.css +12 -13
  33. package/src/cdn/elements/sliders.ts +4 -4
  34. package/src/cdn/elements/tables.css +1 -0
  35. package/src/cdn/elements/tabs.css +1 -0
  36. package/src/cdn/elements/tooltips.css +10 -11
  37. package/src/cdn/helpers/blurs.css +7 -7
  38. package/src/cdn/helpers/forms.css +17 -56
  39. package/src/cdn/helpers/margins.css +11 -11
  40. package/src/cdn/helpers/paddings.css +10 -10
  41. package/src/cdn/helpers/ripples.css +4 -4
  42. package/src/cdn/helpers/shadows.css +4 -4
  43. package/src/cdn/helpers/spaces.css +4 -4
  44. package/src/cdn/settings/fonts.css +4 -4
  45. package/src/cdn/utils.ts +2 -2
  46. package/src/cdn/elements/containers.css +0 -176
@@ -0,0 +1,38 @@
1
+ class BeerCssCustomElement extends HTMLElement {
2
+ static isCssLoaded = false;
3
+ static isJsLoaded = false;
4
+
5
+ constructor() {
6
+ super();
7
+ this.run();
8
+ }
9
+
10
+ async addJs() {
11
+ if (BeerCssCustomElement.isJsLoaded) return;
12
+ BeerCssCustomElement.isJsLoaded = true;
13
+
14
+ if (window.ui) return;
15
+ return await import("https://cdn.jsdelivr.net/npm/beercss@3.10.1/dist/cdn/beer.min.js");
16
+ }
17
+
18
+ async addCss() {
19
+ if (BeerCssCustomElement.isCssLoaded) return;
20
+ BeerCssCustomElement.isCssLoaded = true;
21
+ const isScoped = !!getComputedStyle(document.documentElement).getPropertyValue('--scoped');
22
+ if (isScoped) return;
23
+
24
+ const head = document.querySelector("head");
25
+ const element = document.createElement("link");
26
+ element.setAttribute("href", "https://cdn.jsdelivr.net/npm/beercss@3.10.1/dist/cdn/beer.scoped.min.css");
27
+ head.appendChild(element);
28
+ }
29
+
30
+ async run() {
31
+ this.classList.add("beer");
32
+ await Promise.all([this.addJs(), this.addCss(), this.addDynamicColor()]);
33
+ ui();
34
+ }
35
+ }
36
+
37
+ customElements.define('beer-css', BeerCssCustomElement);
38
+ export default BeerCssCustomElement;
@@ -0,0 +1 @@
1
+ class BeerCssCustomElement extends HTMLElement {static isCssLoaded = false;static isJsLoaded = false;constructor() {super();this.run();}async addJs() {if (BeerCssCustomElement.isJsLoaded) return;BeerCssCustomElement.isJsLoaded = true;if (window.ui) return;return await import("https://cdn.jsdelivr.net/npm/beercss@3.10.1/dist/cdn/beer.min.js");}async addCss() {if (BeerCssCustomElement.isCssLoaded) return;BeerCssCustomElement.isCssLoaded = true;const isScoped = !!getComputedStyle(document.documentElement).getPropertyValue('--scoped');if (isScoped) return;const head = document.querySelector("head");const element = document.createElement("link");element.setAttribute("href", "https://cdn.jsdelivr.net/npm/beercss@3.10.1/dist/cdn/beer.scoped.min.css");head.appendChild(element);}async run() {this.classList.add("beer");await Promise.all([this.addJs(), this.addCss(), this.addDynamicColor()]);ui();}}customElements.define('beer-css', BeerCssCustomElement);export default BeerCssCustomElement;
package/dist/cdn/beer.js CHANGED
@@ -1,9 +1,9 @@
1
1
  const _emptyNodeList = [];
2
2
  function isTouchable() {
3
- return window.matchMedia("(pointer: coarse)").matches;
3
+ return window == null ? void 0 : window.matchMedia("(pointer: coarse)").matches;
4
4
  }
5
5
  function isDark() {
6
- return window.matchMedia("(prefers-color-scheme: dark)").matches;
6
+ return window == null ? void 0 : window.matchMedia("(prefers-color-scheme: dark)").matches;
7
7
  }
8
8
  async function wait(milliseconds) {
9
9
  await new Promise((resolve) => setTimeout(resolve, milliseconds));
@@ -41,26 +41,18 @@ function hasType(element, name) {
41
41
  return ((_a = element == null ? void 0 : element.type) == null ? void 0 : _a.toLowerCase()) === name;
42
42
  }
43
43
  function addClass(element, name) {
44
- if (element instanceof NodeList)
45
- for (let i = 0; i < element.length; i++)
46
- element[i].classList.add(name);
47
- else
48
- element == null ? void 0 : element.classList.add(name);
44
+ if (element instanceof NodeList) for (let i = 0; i < element.length; i++) element[i].classList.add(name);
45
+ else element == null ? void 0 : element.classList.add(name);
49
46
  }
50
47
  function removeClass(element, name) {
51
- if (element instanceof NodeList)
52
- for (let i = 0; i < element.length; i++)
53
- element[i].classList.remove(name);
54
- else
55
- element == null ? void 0 : element.classList.remove(name);
48
+ if (element instanceof NodeList) for (let i = 0; i < element.length; i++) element[i].classList.remove(name);
49
+ else element == null ? void 0 : element.classList.remove(name);
56
50
  }
57
51
  function on(element, name, callback, useCapture = true) {
58
- if (element == null ? void 0 : element.addEventListener)
59
- element.addEventListener(name, callback, useCapture);
52
+ if (element == null ? void 0 : element.addEventListener) element.addEventListener(name, callback, useCapture);
60
53
  }
61
54
  function off(element, name, callback, useCapture = true) {
62
- if (element == null ? void 0 : element.removeEventListener)
63
- element.removeEventListener(name, callback, useCapture);
55
+ if (element == null ? void 0 : element.removeEventListener) element.removeEventListener(name, callback, useCapture);
64
56
  }
65
57
  function insertBefore(newElement, element) {
66
58
  var _a;
@@ -95,26 +87,21 @@ function queryDataUi(id) {
95
87
  return query('[data-ui="#' + id + '"]');
96
88
  }
97
89
  function updateAllClickable(element) {
98
- if (element.id && hasClass(element, "page"))
99
- element = queryDataUi(element.id) ?? element;
90
+ if (element.id && hasClass(element, "page")) element = queryDataUi(element.id) ?? element;
100
91
  const container = parent(element);
101
- if (!hasClass(container, "tabs") && !hasClass(container, "tabbed") && !hasTag(container, "nav"))
102
- return;
92
+ if (!hasClass(container, "tabs") && !hasClass(container, "tabbed") && !hasTag(container, "nav")) return;
103
93
  const as = queryAll("a", container);
104
- for (let i = 0; i < as.length; i++)
105
- removeClass(as[i], "active");
94
+ for (let i = 0; i < as.length; i++) removeClass(as[i], "active");
106
95
  addClass(element, "active");
107
96
  }
108
97
  function updatePlaceholder(element) {
109
- if (!element.placeholder)
110
- element.placeholder = " ";
98
+ if (!element.placeholder) element.placeholder = " ";
111
99
  }
112
100
  function onClickLabel(e) {
113
101
  const label = e.currentTarget;
114
102
  const field = parent(label);
115
103
  const input = query("input:not([type=file], [type=checkbox], [type=radio]), select, textarea", field);
116
- if (input)
117
- input.focus();
104
+ if (input) input.focus();
118
105
  }
119
106
  function onFocusInput(e) {
120
107
  const input = e.currentTarget;
@@ -148,13 +135,11 @@ function onPasswordIconClick(e) {
148
135
  var _a;
149
136
  const icon = e.currentTarget;
150
137
  const input = query("input", parent(icon));
151
- if (input && ((_a = icon.textContent) == null ? void 0 : _a.includes("visibility")))
152
- input.type = input.type === "password" ? "text" : "password";
138
+ if (input && ((_a = icon.textContent) == null ? void 0 : _a.includes("visibility"))) input.type = input.type === "password" ? "text" : "password";
153
139
  }
154
140
  function updateAllLabels() {
155
141
  const labels = queryAll(".field > label");
156
- for (let i = 0; i < labels.length; i++)
157
- on(labels[i], "click", onClickLabel);
142
+ for (let i = 0; i < labels.length; i++) on(labels[i], "click", onClickLabel);
158
143
  }
159
144
  function updateAllInputs() {
160
145
  const inputs = queryAll(".field > input:not([type=file], [type=color], [type=range])");
@@ -196,25 +181,21 @@ function updateAllTextareas() {
196
181
  }
197
182
  function updateAllPasswordIcons() {
198
183
  const icons = queryAll("input[type=password] ~ :is(i, a)");
199
- for (let i = 0; i < icons.length; i++)
200
- on(icons[i], "click", onPasswordIconClick);
184
+ for (let i = 0; i < icons.length; i++) on(icons[i], "click", onPasswordIconClick);
201
185
  }
202
186
  function updateInput(input) {
203
- if (hasType(input, "number") && !input.value)
204
- input.value = "";
187
+ if (hasType(input, "number") && !input.value) input.value = "";
205
188
  updatePlaceholder(input);
206
189
  }
207
190
  function updateFile(input, e) {
208
191
  if ((e == null ? void 0 : e.key) === "Enter") {
209
192
  const previousInput = prev(input);
210
- if (!hasType(previousInput, "file"))
211
- return;
193
+ if (!hasType(previousInput, "file")) return;
212
194
  previousInput.click();
213
195
  return;
214
196
  }
215
197
  const nextInput = next(input);
216
- if (!hasType(nextInput, "text"))
217
- return;
198
+ if (!hasType(nextInput, "text")) return;
218
199
  nextInput.value = input.files ? Array.from(input.files).map((x) => x.name).join(", ") : "";
219
200
  nextInput.readOnly = true;
220
201
  on(nextInput, "keydown", onKeydownFile, false);
@@ -223,14 +204,12 @@ function updateFile(input, e) {
223
204
  function updateColor(input, e) {
224
205
  if ((e == null ? void 0 : e.key) === "Enter") {
225
206
  const previousInput = prev(input);
226
- if (!hasType(previousInput, "color"))
227
- return;
207
+ if (!hasType(previousInput, "color")) return;
228
208
  previousInput.click();
229
209
  return;
230
210
  }
231
211
  const nextInput = next(input);
232
- if (!hasType(nextInput, "text"))
233
- return;
212
+ if (!hasType(nextInput, "text")) return;
234
213
  nextInput.readOnly = true;
235
214
  nextInput.value = input.value;
236
215
  on(nextInput, "keydown", onKeydownColor, false);
@@ -240,8 +219,7 @@ function updateTextarea(textarea) {
240
219
  updatePlaceholder(textarea);
241
220
  const field = parent(textarea);
242
221
  field.removeAttribute("style");
243
- if (hasClass(field, "min"))
244
- field.style.setProperty("---size", `${Math.min(192, Math.max(textarea.scrollHeight, field.offsetHeight))}px`);
222
+ if (hasClass(field, "min")) field.style.setProperty("--_size", `${Math.min(192, Math.max(textarea.scrollHeight, field.offsetHeight))}px`);
245
223
  }
246
224
  function updateAllFields() {
247
225
  updateAllLabels();
@@ -254,8 +232,7 @@ function updateAllFields() {
254
232
  }
255
233
  function onInputDocument(e) {
256
234
  const input = e.target;
257
- if (!hasTag(input, "input") && !hasTag(input, "select"))
258
- return;
235
+ if (!hasTag(input, "input") && !hasTag(input, "select")) return;
259
236
  if (input.type === "range") {
260
237
  input.focus();
261
238
  updateRange(input);
@@ -264,37 +241,28 @@ function onInputDocument(e) {
264
241
  }
265
242
  }
266
243
  function onFocusRange(e) {
267
- if (!isTouchable())
268
- return;
244
+ if (!isTouchable()) return;
269
245
  const input = e.target;
270
246
  const label = parent(input);
271
- if (hasClass(label, "vertical"))
272
- document.body.classList.add("no-scroll");
247
+ if (hasClass(label, "vertical")) document.body.classList.add("no-scroll");
273
248
  }
274
249
  function onBlurRange(e) {
275
- if (!isTouchable())
276
- return;
250
+ if (!isTouchable()) return;
277
251
  const input = e.target;
278
252
  const label = parent(input);
279
- if (hasClass(label, "vertical"))
280
- document.body.classList.remove("no-scroll");
253
+ if (hasClass(label, "vertical")) document.body.classList.remove("no-scroll");
281
254
  }
282
255
  function updateAllRanges() {
283
256
  const body = document.body;
284
257
  const ranges = queryAll(".slider > input[type=range]");
285
- if (!ranges.length)
286
- off(body, "input", onInputDocument, false);
287
- else
288
- on(body, "input", onInputDocument, false);
289
- for (let i = 0; i < ranges.length; i++)
290
- updateRange(ranges[i]);
258
+ if (!ranges.length) off(body, "input", onInputDocument, false);
259
+ else on(body, "input", onInputDocument, false);
260
+ for (let i = 0; i < ranges.length; i++) updateRange(ranges[i]);
291
261
  }
292
262
  function rootSizeInPixels() {
293
263
  const size = getComputedStyle(document.documentElement).getPropertyValue("--size") || "16px";
294
- if (size.includes("%"))
295
- return parseInt(size) * 16 / 100;
296
- if (size.includes("em"))
297
- return parseInt(size) * 16;
264
+ if (size.includes("%")) return parseInt(size) * 16 / 100;
265
+ if (size.includes("em")) return parseInt(size) * 16;
298
266
  return parseInt(size);
299
267
  }
300
268
  function updateRange(input) {
@@ -303,8 +271,7 @@ function updateRange(input) {
303
271
  const label = parent(input);
304
272
  const bar = query("span", label);
305
273
  const inputs = queryAll("input", label);
306
- if (!inputs.length || !bar)
307
- return;
274
+ if (!inputs.length || !bar) return;
308
275
  const rootSize = rootSizeInPixels();
309
276
  const thumb = hasClass(label, "max") ? 0 : 0.25 * rootSize * 100 / inputs[0].offsetWidth;
310
277
  const percents = [];
@@ -332,10 +299,10 @@ function updateRange(input) {
332
299
  value2 = values[0];
333
300
  }
334
301
  }
335
- label.style.setProperty("---start", `${start2}%`);
336
- label.style.setProperty("---end", `${end}%`);
337
- label.style.setProperty("---value1", `'${value1}'`);
338
- label.style.setProperty("---value2", `'${value2}'`);
302
+ label.style.setProperty("--_start", `${start2}%`);
303
+ label.style.setProperty("--_end", `${end}%`);
304
+ label.style.setProperty("--_value1", `'${value1}'`);
305
+ label.style.setProperty("--_value2", `'${value2}'`);
339
306
  }
340
307
  function updateAllSliders() {
341
308
  updateAllRanges();
@@ -349,8 +316,7 @@ function getMode() {
349
316
  return ((_a = document == null ? void 0 : document.body) == null ? void 0 : _a.classList.contains("dark")) ? "dark" : "light";
350
317
  }
351
318
  function lastTheme() {
352
- if (_lastTheme.light && _lastTheme.dark)
353
- return _lastTheme;
319
+ if (_lastTheme.light && _lastTheme.dark) return _lastTheme;
354
320
  const body = document.body;
355
321
  const light = document.createElement("body");
356
322
  light.className = "light";
@@ -372,8 +338,7 @@ function lastTheme() {
372
338
  function updateTheme(source) {
373
339
  const context = globalThis;
374
340
  const body = document.body;
375
- if (!source || !context.materialDynamicColors)
376
- return lastTheme();
341
+ if (!source || !context.materialDynamicColors) return lastTheme();
377
342
  const mode = getMode();
378
343
  if (source.light && source.dark) {
379
344
  _lastTheme.light = source.light;
@@ -401,17 +366,13 @@ function updateTheme(source) {
401
366
  function updateMode(value) {
402
367
  const context = globalThis;
403
368
  const body = document.body;
404
- if (!body)
405
- return value;
406
- if (!value)
407
- return getMode();
408
- if (value === "auto")
409
- value = isDark() ? "dark" : "light";
369
+ if (!body) return value;
370
+ if (!value) return getMode();
371
+ if (value === "auto") value = isDark() ? "dark" : "light";
410
372
  body.classList.remove("light", "dark");
411
373
  body.classList.add(value);
412
374
  const lastThemeStyle = value === "light" ? _lastTheme.light : _lastTheme.dark;
413
- if (context.materialDynamicColors)
414
- body.setAttribute("style", lastThemeStyle);
375
+ if (context.materialDynamicColors) body.setAttribute("style", lastThemeStyle);
415
376
  return getMode();
416
377
  }
417
378
  const _dialogs = [];
@@ -432,77 +393,60 @@ function closeDialog(dialog, overlay) {
432
393
  dialog.close();
433
394
  _dialogs.pop();
434
395
  const previousDialog = _dialogs[_dialogs.length - 1];
435
- if (previousDialog)
436
- previousDialog.focus();
437
- else if (isTouchable())
438
- document.body.classList.remove("no-scroll");
396
+ if (previousDialog) previousDialog.focus();
397
+ else if (isTouchable()) document.body.classList.remove("no-scroll");
439
398
  }
440
399
  async function openDialog(dialog, overlay, isModal, from) {
441
- if (!hasTag(from, "button") && !hasClass(from, "button") && !hasClass(from, "chip"))
442
- addClass(from, "active");
400
+ if (!hasTag(from, "button") && !hasClass(from, "button") && !hasClass(from, "chip")) addClass(from, "active");
443
401
  addClass(overlay, "active");
444
402
  addClass(dialog, "active");
445
- if (isModal)
446
- dialog.showModal();
447
- else
448
- dialog.show();
403
+ if (isModal) dialog.showModal();
404
+ else dialog.show();
449
405
  await wait(90);
450
- if (!isModal)
451
- on(dialog, "keydown", onKeydownDialog, false);
406
+ if (!isModal) on(dialog, "keydown", onKeydownDialog, false);
452
407
  _dialogs.push(dialog);
453
- if (isTouchable())
454
- document.body.classList.add("no-scroll");
408
+ if (isTouchable()) document.body.classList.add("no-scroll");
455
409
  focusOnDialogOrElement(dialog);
456
410
  }
457
411
  function onClickOverlay(e) {
458
412
  const overlay = e.currentTarget;
459
413
  const dialog = next(overlay);
460
- if (hasTag(dialog, "dialog"))
461
- closeDialog(dialog, overlay);
414
+ if (hasTag(dialog, "dialog")) closeDialog(dialog, overlay);
462
415
  }
463
416
  async function updateDialog(from, dialog) {
464
417
  blurActiveElement();
465
418
  let overlay = prev(dialog);
466
419
  const isActive = hasClass(dialog, "active") || dialog.open;
467
420
  const isModal = hasClass(dialog, "modal");
468
- if (!isModal)
469
- off(dialog, "keydown", onKeydownDialog, false);
421
+ if (!isModal) off(dialog, "keydown", onKeydownDialog, false);
470
422
  if (!hasClass(overlay, "overlay")) {
471
423
  overlay = create({ class: "overlay" });
472
424
  insertBefore(overlay, dialog);
473
425
  await wait(90);
474
426
  }
475
- if (!isModal)
476
- on(overlay, "click", onClickOverlay, false);
477
- if (isActive)
478
- closeDialog(dialog, overlay);
479
- else
480
- void openDialog(dialog, overlay, isModal, from);
427
+ if (!isModal) on(overlay, "click", onClickOverlay, false);
428
+ if (isActive) closeDialog(dialog, overlay);
429
+ else void openDialog(dialog, overlay, isModal, from);
481
430
  }
482
431
  let _timeoutMenu;
483
432
  function onClickDocument(e) {
484
433
  off(document.body, "click", onClickDocument);
485
434
  const body = e.target;
486
435
  const menus = queryAll("menu.active");
487
- for (let i = 0; i < menus.length; i++)
488
- updateMenu(body, menus[i], e);
436
+ for (let i = 0; i < menus.length; i++) updateMenu(body, menus[i], e);
489
437
  }
490
438
  function focusOnMenuOrInput(menu) {
491
439
  setTimeout(() => {
492
440
  const input = query(".field > input", menu);
493
- if (input)
494
- input.focus();
495
- else
496
- menu.focus();
441
+ if (input) input.focus();
442
+ else menu.focus();
497
443
  }, 90);
498
444
  }
499
445
  function updateMenu(from, menu, e) {
500
- if (_timeoutMenu)
501
- clearTimeout(_timeoutMenu);
446
+ if (_timeoutMenu) clearTimeout(_timeoutMenu);
502
447
  _timeoutMenu = setTimeout(() => {
503
448
  on(document.body, "click", onClickDocument);
504
- if (!hasTag(document.activeElement, "input"))
505
- blurActiveElement();
449
+ if (!hasTag(document.activeElement, "input")) blurActiveElement();
506
450
  const isActive = hasClass(menu, "active");
507
451
  const isEvent = (e == null ? void 0 : e.target) === from;
508
452
  const isChild = !!from.closest("menu");
@@ -519,28 +463,23 @@ let _timeoutSnackbar;
519
463
  function onClickSnackbar(e) {
520
464
  const snackbar = e.currentTarget;
521
465
  removeClass(snackbar, "active");
522
- if (_timeoutSnackbar)
523
- clearTimeout(_timeoutSnackbar);
466
+ if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
524
467
  }
525
468
  function updateSnackbar(snackbar, milliseconds) {
526
469
  blurActiveElement();
527
470
  const activeSnackbars = queryAll(".snackbar.active");
528
- for (let i = 0; i < activeSnackbars.length; i++)
529
- removeClass(activeSnackbars[i], "active");
471
+ for (let i = 0; i < activeSnackbars.length; i++) removeClass(activeSnackbars[i], "active");
530
472
  addClass(snackbar, "active");
531
473
  on(snackbar, "click", onClickSnackbar);
532
- if (_timeoutSnackbar)
533
- clearTimeout(_timeoutSnackbar);
534
- if (milliseconds === -1)
535
- return;
474
+ if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
475
+ if (milliseconds === -1) return;
536
476
  _timeoutSnackbar = setTimeout(() => {
537
477
  removeClass(snackbar, "active");
538
478
  }, milliseconds ?? 6e3);
539
479
  }
540
480
  function updatePage(page) {
541
481
  const container = parent(page);
542
- if (container)
543
- removeClass(queryAll(":scope > .page", container), "active");
482
+ if (container) removeClass(queryAll(":scope > .page", container), "active");
544
483
  addClass(page, "active");
545
484
  }
546
485
  function onPointerDownRipple(e) {
@@ -567,22 +506,19 @@ function updateRipple(e) {
567
506
  }
568
507
  function updateAllRipples() {
569
508
  const ripples = queryAll(".slow-ripple, .ripple, .fast-ripple");
570
- for (let i = 0; i < ripples.length; i++)
571
- on(ripples[i], "pointerdown", onPointerDownRipple);
509
+ for (let i = 0; i < ripples.length; i++) on(ripples[i], "pointerdown", onPointerDownRipple);
572
510
  }
573
511
  const _context = globalThis;
574
512
  let _timeoutMutation;
575
513
  let _mutation;
576
514
  function onMutation() {
577
- if (_timeoutMutation)
578
- clearTimeout(_timeoutMutation);
515
+ if (_timeoutMutation) clearTimeout(_timeoutMutation);
579
516
  _timeoutMutation = setTimeout(async () => await _ui(), 180);
580
517
  }
581
518
  async function run(from, to, options, e) {
582
519
  if (!to) {
583
520
  to = query(from.getAttribute("data-ui"));
584
- if (!to)
585
- return;
521
+ if (!to) return;
586
522
  }
587
523
  updateAllClickable(from);
588
524
  if (hasTag(to, "dialog")) {
@@ -612,12 +548,10 @@ function onClickElement(e) {
612
548
  void run(e.currentTarget, null, null, e);
613
549
  }
614
550
  function onKeydownElement(e) {
615
- if (e.key === "Enter")
616
- void run(e.currentTarget, null, null, e);
551
+ if (e.key === "Enter") void run(e.currentTarget, null, null, e);
617
552
  }
618
553
  function setup() {
619
- if (_context.ui || _mutation)
620
- return;
554
+ if (_context.ui || _mutation || !_context.MutationObserver) return;
621
555
  _mutation = new MutationObserver(onMutation);
622
556
  _mutation.observe(document.body, { childList: true, subtree: true });
623
557
  onMutation();
@@ -626,8 +560,7 @@ function updateAllDataUis() {
626
560
  const elements = queryAll("[data-ui]");
627
561
  for (let i = 0, n = elements.length; i < n; i++) {
628
562
  on(elements[i], "click", onClickElement);
629
- if (hasTag(elements[i], "a") && !elements[i].getAttribute("href"))
630
- on(elements[i], "keydown", onKeydownElement);
563
+ if (hasTag(elements[i], "a") && !elements[i].getAttribute("href")) on(elements[i], "keydown", onKeydownElement);
631
564
  }
632
565
  }
633
566
  function _ui(selector, options) {
@@ -636,15 +569,11 @@ function _ui(selector, options) {
636
569
  setup();
637
570
  return;
638
571
  }
639
- if (selector === "guid")
640
- return guid();
641
- if (selector === "mode")
642
- return updateMode(options);
643
- if (selector === "theme")
644
- return updateTheme(options);
572
+ if (selector === "guid") return guid();
573
+ if (selector === "mode") return updateMode(options);
574
+ if (selector === "theme") return updateTheme(options);
645
575
  const to = query(selector);
646
- if (!to)
647
- return;
576
+ if (!to) return;
648
577
  void run(to, to, options);
649
578
  }
650
579
  updateAllDataUis();
@@ -654,11 +583,9 @@ function _ui(selector, options) {
654
583
  }
655
584
  function start() {
656
585
  var _a;
657
- if (_context.ui)
658
- return;
586
+ if (_context.ui) return;
659
587
  const body = (_a = _context.document) == null ? void 0 : _a.body;
660
- if (body && !body.classList.contains("dark") && !body.classList.contains("light"))
661
- updateMode("auto");
588
+ if (body && !body.classList.contains("dark") && !body.classList.contains("light")) updateMode("auto");
662
589
  setup();
663
590
  _context.ui = _ui;
664
591
  }