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/index.js CHANGED
@@ -145,8 +145,8 @@ var DOMBuilder = class {
145
145
  (_a = this._stack[0]) == null ? void 0 : _a.appendChild(document.createTextNode(text));
146
146
  return this;
147
147
  }
148
- builder(buildDOM) {
149
- buildDOM(this._stack[0]);
148
+ element(callback) {
149
+ callback(this._stack[0]);
150
150
  return this;
151
151
  }
152
152
  };
@@ -361,7 +361,7 @@ var _NotificationUI = class _NotificationUI {
361
361
  );
362
362
  };
363
363
  }
364
- ).builder(log_default).closeTag().openTag(
364
+ ).element(log_default).closeTag().openTag(
365
365
  "button",
366
366
  {
367
367
  class: "button",
@@ -385,12 +385,12 @@ var _NotificationUI = class _NotificationUI {
385
385
  revealButton.style.display = "none";
386
386
  }
387
387
  }
388
- ).builder(reveal_default).closeTag().text(notification.message).openTag("a", {
388
+ ).element(reveal_default).closeTag().text(notification.message).openTag("a", {
389
389
  class: "button close",
390
390
  href: "/",
391
391
  title: "Open help",
392
392
  target: "_blank"
393
- }).builder(help_default).closeTag().openTag(
393
+ }).element(help_default).closeTag().openTag(
394
394
  "button",
395
395
  {
396
396
  class: "button close",
@@ -403,7 +403,7 @@ var _NotificationUI = class _NotificationUI {
403
403
  (_a = _NotificationUI._highlight) == null ? void 0 : _a.hide();
404
404
  };
405
405
  }
406
- ).builder(close_default).closeTag().closeTag().closeTag();
406
+ ).element(close_default).closeTag().closeTag().closeTag();
407
407
  }
408
408
  toggle(show, initial = false) {
409
409
  var _a;
@@ -439,7 +439,6 @@ var NotificationsUI = class {
439
439
  __publicField(this, "_alignBottomRightButton");
440
440
  __publicField(this, "_isMuted", false);
441
441
  __publicField(this, "_notifications", /* @__PURE__ */ new Set());
442
- var _a;
443
442
  const container = this._container = win.document.createElement("div");
444
443
  container.__abledomui = true;
445
444
  container.id = "abledom-report";
@@ -452,83 +451,111 @@ var NotificationsUI = class {
452
451
  container.appendChild(notificationsContainer);
453
452
  const menuElement = this._menuElement = win.document.createElement("div");
454
453
  menuElement.className = "abledom-menu-container";
455
- new DOMBuilder(menuElement).openTag("div", { class: "abledom-menu" }).openTag("span", {
456
- class: "notifications-count",
457
- title: "Number of notifications"
458
- }).closeTag().openTag("button", {
459
- class: "button",
460
- title: "Show all notifications"
461
- }).builder(showall_default).closeTag().openTag("button", {
462
- class: "button",
463
- title: "Hide all notifications"
464
- }).builder(hideall_default).closeTag().openTag("button", {
465
- class: "button",
466
- title: "Mute newly appearing notifications"
467
- }).builder(muteall_default).closeTag().openTag("button", {
468
- class: "button align-button align-button-first pressed",
469
- title: "Attach notifications to bottom left"
470
- }).builder(alignbottomleft_default).closeTag().openTag("button", {
471
- class: "button align-button",
472
- title: "Attach notifications to top left"
473
- }).builder(aligntopleft_default).closeTag().openTag("button", {
474
- class: "button align-button",
475
- title: "Attach notifications to top right"
476
- }).builder(aligntopright_default).closeTag().openTag("button", {
477
- class: "button align-button align-button-last",
478
- title: "Attach notifications to bottom right"
479
- }).builder(alignbottomright_default).closeTag().closeTag();
480
- const [
481
- notificationCountElement,
482
- showAllButton,
483
- hideAllButton,
484
- muteButton,
485
- alignBottomLeftButton,
486
- alignTopLeftButton,
487
- alignTopRightButton,
488
- alignBottomRightButton
489
- ] = ((_a = menuElement.firstElementChild) == null ? void 0 : _a.childNodes) || [];
490
- 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) {
491
- container.appendChild(menuElement);
492
- this._notificationCountElement = notificationCountElement;
493
- this._showAllButton = showAllButton;
494
- this._hideAllButton = hideAllButton;
495
- this._alignBottomLeftButton = alignBottomLeftButton;
496
- this._alignTopLeftButton = alignTopLeftButton;
497
- this._alignTopRightButton = alignTopRightButton;
498
- this._alignBottomRightButton = alignBottomRightButton;
499
- showAllButton.onclick = () => {
500
- this.showAll();
501
- };
502
- hideAllButton.onclick = () => {
503
- this.hideAll();
504
- };
505
- muteButton.onclick = () => {
506
- const isMuted = this._isMuted = muteButton.classList.toggle(pressedClass);
507
- if (isMuted) {
508
- muteButton.setAttribute(
509
- "title",
510
- "Unmute newly appearing notifications"
511
- );
512
- } else {
513
- muteButton.setAttribute(
514
- "title",
515
- "Mute newly appearing notifications"
516
- );
517
- }
518
- };
519
- alignBottomLeftButton.onclick = () => {
520
- this.setUIAlignment("bottom-left" /* BottomLeft */);
521
- };
522
- alignBottomRightButton.onclick = () => {
523
- this.setUIAlignment("bottom-right" /* BottomRight */);
524
- };
525
- alignTopLeftButton.onclick = () => {
526
- this.setUIAlignment("top-left" /* TopLeft */);
527
- };
528
- alignTopRightButton.onclick = () => {
529
- this.setUIAlignment("top-right" /* TopRight */);
530
- };
531
- }
454
+ container.appendChild(menuElement);
455
+ new DOMBuilder(menuElement).openTag("div", { class: "abledom-menu" }).openTag(
456
+ "span",
457
+ {
458
+ class: "notifications-count",
459
+ title: "Number of notifications"
460
+ },
461
+ (notificationCountElement) => {
462
+ this._notificationCountElement = notificationCountElement;
463
+ }
464
+ ).closeTag().openTag(
465
+ "button",
466
+ {
467
+ class: "button",
468
+ title: "Show all notifications"
469
+ },
470
+ (showAllButton) => {
471
+ this._showAllButton = showAllButton;
472
+ showAllButton.onclick = () => {
473
+ this.showAll();
474
+ };
475
+ }
476
+ ).element(showall_default).closeTag().openTag(
477
+ "button",
478
+ {
479
+ class: "button",
480
+ title: "Hide all notifications"
481
+ },
482
+ (hideAllButton) => {
483
+ this._hideAllButton = hideAllButton;
484
+ hideAllButton.onclick = () => {
485
+ this.hideAll();
486
+ };
487
+ }
488
+ ).element(hideall_default).closeTag().openTag(
489
+ "button",
490
+ {
491
+ class: "button",
492
+ title: "Mute newly appearing notifications"
493
+ },
494
+ (muteButton) => {
495
+ muteButton.onclick = () => {
496
+ const isMuted = this._isMuted = muteButton.classList.toggle(pressedClass);
497
+ if (isMuted) {
498
+ muteButton.setAttribute(
499
+ "title",
500
+ "Unmute newly appearing notifications"
501
+ );
502
+ } else {
503
+ muteButton.setAttribute(
504
+ "title",
505
+ "Mute newly appearing notifications"
506
+ );
507
+ }
508
+ };
509
+ }
510
+ ).element(muteall_default).closeTag().openTag(
511
+ "button",
512
+ {
513
+ class: "button align-button align-button-first pressed",
514
+ title: "Attach notifications to bottom left"
515
+ },
516
+ (alignBottomLeftButton) => {
517
+ this._alignBottomLeftButton = alignBottomLeftButton;
518
+ alignBottomLeftButton.onclick = () => {
519
+ this.setUIAlignment("bottom-left" /* BottomLeft */);
520
+ };
521
+ }
522
+ ).element(alignbottomleft_default).closeTag().openTag(
523
+ "button",
524
+ {
525
+ class: "button align-button",
526
+ title: "Attach notifications to top left"
527
+ },
528
+ (alignTopLeftButton) => {
529
+ this._alignTopLeftButton = alignTopLeftButton;
530
+ alignTopLeftButton.onclick = () => {
531
+ this.setUIAlignment("top-left" /* TopLeft */);
532
+ };
533
+ }
534
+ ).element(aligntopleft_default).closeTag().openTag(
535
+ "button",
536
+ {
537
+ class: "button align-button",
538
+ title: "Attach notifications to top right"
539
+ },
540
+ (alignTopRightButton) => {
541
+ this._alignTopRightButton = alignTopRightButton;
542
+ alignTopRightButton.onclick = () => {
543
+ this.setUIAlignment("top-right" /* TopRight */);
544
+ };
545
+ }
546
+ ).element(aligntopright_default).closeTag().openTag(
547
+ "button",
548
+ {
549
+ class: "button align-button align-button-last",
550
+ title: "Attach notifications to bottom right"
551
+ },
552
+ (alignBottomRightButton) => {
553
+ this._alignBottomRightButton = alignBottomRightButton;
554
+ alignBottomRightButton.onclick = () => {
555
+ this.setUIAlignment("bottom-right" /* BottomRight */);
556
+ };
557
+ }
558
+ ).element(alignbottomright_default).closeTag().closeTag();
532
559
  win.document.body.appendChild(container);
533
560
  }
534
561
  setUIAlignment(alignment) {