abledom 0.0.4 → 0.0.5

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/dist/esm/index.js CHANGED
@@ -107,8 +107,8 @@ var DOMBuilder = class {
107
107
  (_a = this._stack[0]) == null ? void 0 : _a.appendChild(document.createTextNode(text));
108
108
  return this;
109
109
  }
110
- builder(buildDOM) {
111
- buildDOM(this._stack[0]);
110
+ element(callback) {
111
+ callback(this._stack[0]);
112
112
  return this;
113
113
  }
114
114
  };
@@ -323,7 +323,7 @@ var _NotificationUI = class _NotificationUI {
323
323
  );
324
324
  };
325
325
  }
326
- ).builder(log_default).closeTag().openTag(
326
+ ).element(log_default).closeTag().openTag(
327
327
  "button",
328
328
  {
329
329
  class: "button",
@@ -347,12 +347,12 @@ var _NotificationUI = class _NotificationUI {
347
347
  revealButton.style.display = "none";
348
348
  }
349
349
  }
350
- ).builder(reveal_default).closeTag().text(notification.message).openTag("a", {
350
+ ).element(reveal_default).closeTag().text(notification.message).openTag("a", {
351
351
  class: "button close",
352
352
  href: "/",
353
353
  title: "Open help",
354
354
  target: "_blank"
355
- }).builder(help_default).closeTag().openTag(
355
+ }).element(help_default).closeTag().openTag(
356
356
  "button",
357
357
  {
358
358
  class: "button close",
@@ -365,7 +365,7 @@ var _NotificationUI = class _NotificationUI {
365
365
  (_a = _NotificationUI._highlight) == null ? void 0 : _a.hide();
366
366
  };
367
367
  }
368
- ).builder(close_default).closeTag().closeTag().closeTag();
368
+ ).element(close_default).closeTag().closeTag().closeTag();
369
369
  }
370
370
  toggle(show, initial = false) {
371
371
  var _a;
@@ -401,7 +401,6 @@ var NotificationsUI = class {
401
401
  __publicField(this, "_alignBottomRightButton");
402
402
  __publicField(this, "_isMuted", false);
403
403
  __publicField(this, "_notifications", /* @__PURE__ */ new Set());
404
- var _a;
405
404
  const container = this._container = win.document.createElement("div");
406
405
  container.__abledomui = true;
407
406
  container.id = "abledom-report";
@@ -414,83 +413,111 @@ var NotificationsUI = class {
414
413
  container.appendChild(notificationsContainer);
415
414
  const menuElement = this._menuElement = win.document.createElement("div");
416
415
  menuElement.className = "abledom-menu-container";
417
- new DOMBuilder(menuElement).openTag("div", { class: "abledom-menu" }).openTag("span", {
418
- class: "notifications-count",
419
- title: "Number of notifications"
420
- }).closeTag().openTag("button", {
421
- class: "button",
422
- title: "Show all notifications"
423
- }).builder(showall_default).closeTag().openTag("button", {
424
- class: "button",
425
- title: "Hide all notifications"
426
- }).builder(hideall_default).closeTag().openTag("button", {
427
- class: "button",
428
- title: "Mute newly appearing notifications"
429
- }).builder(muteall_default).closeTag().openTag("button", {
430
- class: "button align-button align-button-first pressed",
431
- title: "Attach notifications to bottom left"
432
- }).builder(alignbottomleft_default).closeTag().openTag("button", {
433
- class: "button align-button",
434
- title: "Attach notifications to top left"
435
- }).builder(aligntopleft_default).closeTag().openTag("button", {
436
- class: "button align-button",
437
- title: "Attach notifications to top right"
438
- }).builder(aligntopright_default).closeTag().openTag("button", {
439
- class: "button align-button align-button-last",
440
- title: "Attach notifications to bottom right"
441
- }).builder(alignbottomright_default).closeTag().closeTag();
442
- const [
443
- notificationCountElement,
444
- showAllButton,
445
- hideAllButton,
446
- muteButton,
447
- alignBottomLeftButton,
448
- alignTopLeftButton,
449
- alignTopRightButton,
450
- alignBottomRightButton
451
- ] = ((_a = menuElement.firstElementChild) == null ? void 0 : _a.childNodes) || [];
452
- if (notificationCountElement instanceof HTMLSpanElement && showAllButton instanceof HTMLButtonElement && hideAllButton instanceof HTMLButtonElement && muteButton instanceof HTMLButtonElement && alignBottomLeftButton instanceof HTMLButtonElement && alignTopLeftButton instanceof HTMLButtonElement && alignTopRightButton instanceof HTMLButtonElement && alignBottomRightButton instanceof HTMLButtonElement) {
453
- container.appendChild(menuElement);
454
- this._notificationCountElement = notificationCountElement;
455
- this._showAllButton = showAllButton;
456
- this._hideAllButton = hideAllButton;
457
- this._alignBottomLeftButton = alignBottomLeftButton;
458
- this._alignTopLeftButton = alignTopLeftButton;
459
- this._alignTopRightButton = alignTopRightButton;
460
- this._alignBottomRightButton = alignBottomRightButton;
461
- showAllButton.onclick = () => {
462
- this.showAll();
463
- };
464
- hideAllButton.onclick = () => {
465
- this.hideAll();
466
- };
467
- muteButton.onclick = () => {
468
- const isMuted = this._isMuted = muteButton.classList.toggle(pressedClass);
469
- if (isMuted) {
470
- muteButton.setAttribute(
471
- "title",
472
- "Unmute newly appearing notifications"
473
- );
474
- } else {
475
- muteButton.setAttribute(
476
- "title",
477
- "Mute newly appearing notifications"
478
- );
479
- }
480
- };
481
- alignBottomLeftButton.onclick = () => {
482
- this.setUIAlignment("bottom-left" /* BottomLeft */);
483
- };
484
- alignBottomRightButton.onclick = () => {
485
- this.setUIAlignment("bottom-right" /* BottomRight */);
486
- };
487
- alignTopLeftButton.onclick = () => {
488
- this.setUIAlignment("top-left" /* TopLeft */);
489
- };
490
- alignTopRightButton.onclick = () => {
491
- this.setUIAlignment("top-right" /* TopRight */);
492
- };
493
- }
416
+ container.appendChild(menuElement);
417
+ new DOMBuilder(menuElement).openTag("div", { class: "abledom-menu" }).openTag(
418
+ "span",
419
+ {
420
+ class: "notifications-count",
421
+ title: "Number of notifications"
422
+ },
423
+ (notificationCountElement) => {
424
+ this._notificationCountElement = notificationCountElement;
425
+ }
426
+ ).closeTag().openTag(
427
+ "button",
428
+ {
429
+ class: "button",
430
+ title: "Show all notifications"
431
+ },
432
+ (showAllButton) => {
433
+ this._showAllButton = showAllButton;
434
+ showAllButton.onclick = () => {
435
+ this.showAll();
436
+ };
437
+ }
438
+ ).element(showall_default).closeTag().openTag(
439
+ "button",
440
+ {
441
+ class: "button",
442
+ title: "Hide all notifications"
443
+ },
444
+ (hideAllButton) => {
445
+ this._hideAllButton = hideAllButton;
446
+ hideAllButton.onclick = () => {
447
+ this.hideAll();
448
+ };
449
+ }
450
+ ).element(hideall_default).closeTag().openTag(
451
+ "button",
452
+ {
453
+ class: "button",
454
+ title: "Mute newly appearing notifications"
455
+ },
456
+ (muteButton) => {
457
+ muteButton.onclick = () => {
458
+ const isMuted = this._isMuted = muteButton.classList.toggle(pressedClass);
459
+ if (isMuted) {
460
+ muteButton.setAttribute(
461
+ "title",
462
+ "Unmute newly appearing notifications"
463
+ );
464
+ } else {
465
+ muteButton.setAttribute(
466
+ "title",
467
+ "Mute newly appearing notifications"
468
+ );
469
+ }
470
+ };
471
+ }
472
+ ).element(muteall_default).closeTag().openTag(
473
+ "button",
474
+ {
475
+ class: "button align-button align-button-first pressed",
476
+ title: "Attach notifications to bottom left"
477
+ },
478
+ (alignBottomLeftButton) => {
479
+ this._alignBottomLeftButton = alignBottomLeftButton;
480
+ alignBottomLeftButton.onclick = () => {
481
+ this.setUIAlignment("bottom-left" /* BottomLeft */);
482
+ };
483
+ }
484
+ ).element(alignbottomleft_default).closeTag().openTag(
485
+ "button",
486
+ {
487
+ class: "button align-button",
488
+ title: "Attach notifications to top left"
489
+ },
490
+ (alignTopLeftButton) => {
491
+ this._alignTopLeftButton = alignTopLeftButton;
492
+ alignTopLeftButton.onclick = () => {
493
+ this.setUIAlignment("top-left" /* TopLeft */);
494
+ };
495
+ }
496
+ ).element(aligntopleft_default).closeTag().openTag(
497
+ "button",
498
+ {
499
+ class: "button align-button",
500
+ title: "Attach notifications to top right"
501
+ },
502
+ (alignTopRightButton) => {
503
+ this._alignTopRightButton = alignTopRightButton;
504
+ alignTopRightButton.onclick = () => {
505
+ this.setUIAlignment("top-right" /* TopRight */);
506
+ };
507
+ }
508
+ ).element(aligntopright_default).closeTag().openTag(
509
+ "button",
510
+ {
511
+ class: "button align-button align-button-last",
512
+ title: "Attach notifications to bottom right"
513
+ },
514
+ (alignBottomRightButton) => {
515
+ this._alignBottomRightButton = alignBottomRightButton;
516
+ alignBottomRightButton.onclick = () => {
517
+ this.setUIAlignment("bottom-right" /* BottomRight */);
518
+ };
519
+ }
520
+ ).element(alignbottomright_default).closeTag().closeTag();
494
521
  win.document.body.appendChild(container);
495
522
  }
496
523
  setUIAlignment(alignment) {