abledom 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +201 -171
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +27 -18
- package/dist/index.d.ts +27 -18
- package/dist/index.js +201 -171
- package/dist/index.js.map +1 -1
- package/dist/ts3.9/index.d.ts +27 -18
- package/package.json +17 -13
package/dist/esm/index.js
CHANGED
|
@@ -13,11 +13,11 @@ var ValidationRule = class {
|
|
|
13
13
|
constructor() {
|
|
14
14
|
__publicField(this, "_window");
|
|
15
15
|
__publicField(this, "_exceptions", []);
|
|
16
|
-
__publicField(this, "
|
|
16
|
+
__publicField(this, "_onIssue");
|
|
17
17
|
}
|
|
18
|
-
static init(instance, window,
|
|
18
|
+
static init(instance, window, onIssue) {
|
|
19
19
|
instance._window = window;
|
|
20
|
-
instance.
|
|
20
|
+
instance._onIssue = onIssue;
|
|
21
21
|
}
|
|
22
22
|
static dispose(instance) {
|
|
23
23
|
instance.dispose();
|
|
@@ -32,7 +32,7 @@ var ValidationRule = class {
|
|
|
32
32
|
}
|
|
33
33
|
dispose() {
|
|
34
34
|
this._window = void 0;
|
|
35
|
-
this.
|
|
35
|
+
this._onIssue = void 0;
|
|
36
36
|
this._exceptions = [];
|
|
37
37
|
}
|
|
38
38
|
addException(checkException) {
|
|
@@ -51,14 +51,14 @@ var ValidationRule = class {
|
|
|
51
51
|
get window() {
|
|
52
52
|
return this._window;
|
|
53
53
|
}
|
|
54
|
-
notify(
|
|
54
|
+
notify(issue) {
|
|
55
55
|
var _a;
|
|
56
|
-
(_a = this.
|
|
56
|
+
(_a = this._onIssue) == null ? void 0 : _a.call(this, this, issue);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
// inline-file:/Users/marata/Documents/Work/abledom/src/ui/ui.css
|
|
61
|
-
var ui_default = "#abledom-report {\n bottom: 20px;\n display: flex;\n flex-direction: column;\n left: 10px;\n max-height: 80%;\n max-width: 60%;\n padding: 4px 8px;\n position: fixed;\n z-index: 100500;\n}\n\n#abledom-report :focus-visible {\n outline: 3px solid red;\n mix-blend-mode: difference;\n}\n\n#abledom-report.abledom-align-left {\n left: 10px;\n right: auto;\n}\n\n#abledom-report.abledom-align-right {\n left: auto;\n right: 10px;\n}\n\n#abledom-report.abledom-align-bottom {\n bottom: 20px;\n top: auto;\n}\n\n#abledom-report.abledom-align-top {\n /* flex-direction: column-reverse; */\n bottom: auto;\n top: 10px;\n}\n\n.abledom-menu-container {\n backdrop-filter: blur(3px);\n border-radius: 8px;\n box-shadow: 0px 0px 4px rgba(127, 127, 127, 0.5);\n display: inline-block;\n margin: 2px auto 2px 0;\n}\n\n#abledom-report.abledom-align-right .abledom-menu-container {\n margin: 2px 0 2px auto;\n}\n\n.abledom-menu {\n background-color: rgba(140, 10, 121, 0.7);\n border-radius: 8px;\n color: white;\n display: inline flex;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 16px;\n line-height: 26px;\n padding: 4px;\n}\n\n.abledom-menu .
|
|
61
|
+
var ui_default = "#abledom-report {\n bottom: 20px;\n display: flex;\n flex-direction: column;\n left: 10px;\n max-height: 80%;\n max-width: 60%;\n padding: 4px 8px;\n position: fixed;\n z-index: 100500;\n}\n\n#abledom-report :focus-visible {\n outline: 3px solid red;\n mix-blend-mode: difference;\n}\n\n#abledom-report.abledom-align-left {\n left: 10px;\n right: auto;\n}\n\n#abledom-report.abledom-align-right {\n left: auto;\n right: 10px;\n}\n\n#abledom-report.abledom-align-bottom {\n bottom: 20px;\n top: auto;\n}\n\n#abledom-report.abledom-align-top {\n /* flex-direction: column-reverse; */\n bottom: auto;\n top: 10px;\n}\n\n.abledom-menu-container {\n backdrop-filter: blur(3px);\n border-radius: 8px;\n box-shadow: 0px 0px 4px rgba(127, 127, 127, 0.5);\n display: inline-block;\n margin: 2px auto 2px 0;\n}\n\n#abledom-report.abledom-align-right .abledom-menu-container {\n margin: 2px 0 2px auto;\n}\n\n.abledom-menu {\n background-color: rgba(140, 10, 121, 0.7);\n border-radius: 8px;\n color: white;\n display: inline flex;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 16px;\n line-height: 26px;\n padding: 4px;\n}\n\n.abledom-menu .issues-count {\n margin: 0 8px;\n display: inline-block;\n}\n\n.abledom-menu .button {\n all: unset;\n color: #000;\n cursor: pointer;\n background: linear-gradient(\n 180deg,\n rgba(255, 255, 255, 1) 0%,\n rgba(200, 200, 200, 1) 100%\n );\n border-radius: 6px;\n border: 1px solid rgba(255, 255, 255, 0.4);\n box-sizing: border-box;\n line-height: 0px;\n margin-right: 4px;\n max-height: 26px;\n padding: 2px;\n text-decoration: none;\n}\n\n.abledom-menu .align-button {\n border-right-color: rgba(0, 0, 0, 0.4);\n border-radius: 0;\n margin: 0;\n}\n\n.abledom-menu .align-button:active,\n#abledom-report .pressed {\n background: linear-gradient(\n 180deg,\n rgba(130, 130, 130, 1) 0%,\n rgba(180, 180, 180, 1) 100%\n );\n}\n\n.abledom-menu .align-button-first {\n border-top-left-radius: 6px;\n border-bottom-left-radius: 6px;\n margin-left: 8px;\n}\n.abledom-menu .align-button-last {\n border-top-right-radius: 6px;\n border-bottom-right-radius: 6px;\n border-right-color: rgba(255, 255, 255, 0.4);\n}\n\n.abledom-issues-container {\n overflow: scroll;\n max-height: calc(100vh - 100px);\n}\n\n#abledom-report.abledom-align-right .abledom-issues-container {\n text-align: right;\n}\n\n.abledom-issue-container {\n backdrop-filter: blur(3px);\n border-radius: 8px;\n box-shadow: 0px 0px 4px rgba(127, 127, 127, 0.5);\n display: inline-flex;\n margin: 2px 0;\n}\n\n.abledom-issue {\n background-color: rgba(164, 2, 2, 0.7);\n border-radius: 8px;\n color: white;\n display: inline flex;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 16px;\n line-height: 26px;\n padding: 4px;\n}\n.abledom-issue_warning {\n background-color: rgba(163, 82, 1, 0.7);\n}\n.abledom-issue_info {\n background-color: rgba(0, 0, 255, 0.7);\n}\n\n.abledom-issue .button {\n all: unset;\n color: #000;\n cursor: pointer;\n background: linear-gradient(\n 180deg,\n rgba(255, 255, 255, 1) 0%,\n rgba(200, 200, 200, 1) 100%\n );\n border-radius: 6px;\n border: 1px solid rgba(255, 255, 255, 0.4);\n box-sizing: border-box;\n line-height: 0px;\n margin-right: 4px;\n max-height: 26px;\n padding: 2px;\n text-decoration: none;\n}\n\n.abledom-issue .button:hover {\n opacity: 0.7;\n}\n\n.abledom-issue .button.close {\n background: none;\n border-color: transparent;\n color: #fff;\n margin: 0;\n}\n\n.abledom-highlight {\n background-color: yellow;\n box-sizing: border-box;\n display: none;\n opacity: 0.6;\n position: fixed;\n z-index: 100499;\n}\n\n.abledom-highlight-border1 {\n border-top: 2px solid red;\n border-bottom: 2px solid red;\n box-sizing: border-box;\n position: absolute;\n top: -2px;\n width: calc(100% + 20px);\n height: calc(100% + 4px);\n margin: 0 -10px;\n}\n\n.abledom-highlight-border2 {\n border-left: 2px solid red;\n border-right: 2px solid red;\n box-sizing: border-box;\n position: absolute;\n width: calc(100% + 4px);\n left: -2px;\n height: calc(100% + 20px);\n margin: -10px 0;\n}\n";
|
|
62
62
|
|
|
63
63
|
// src/ui/domBuilder.ts
|
|
64
64
|
var DOMBuilder = class {
|
|
@@ -285,21 +285,23 @@ var alignbottomleft_default = function buildSVG12(parent) {
|
|
|
285
285
|
|
|
286
286
|
// src/ui/ui.ts
|
|
287
287
|
var pressedClass = "pressed";
|
|
288
|
-
var
|
|
289
|
-
constructor(win, core, rule,
|
|
288
|
+
var IssueUI = class {
|
|
289
|
+
constructor(win, core, rule, issuesUI) {
|
|
290
290
|
__publicField(this, "_core");
|
|
291
|
-
__publicField(this, "
|
|
291
|
+
__publicField(this, "_issuesUI");
|
|
292
292
|
__publicField(this, "_wrapper");
|
|
293
293
|
__publicField(this, "_rule");
|
|
294
294
|
__publicField(this, "_onToggle");
|
|
295
295
|
__publicField(this, "isHidden", false);
|
|
296
296
|
this._core = core;
|
|
297
297
|
this._rule = rule;
|
|
298
|
-
this.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
298
|
+
this._issuesUI = issuesUI;
|
|
299
|
+
if (!issuesUI.headless) {
|
|
300
|
+
this._wrapper = win.document.createElement(
|
|
301
|
+
"div"
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
issuesUI.addIssue(this);
|
|
303
305
|
}
|
|
304
306
|
static setOnToggle(instance, onToggle) {
|
|
305
307
|
instance._onToggle = onToggle;
|
|
@@ -307,27 +309,26 @@ var NotificationUI = class {
|
|
|
307
309
|
static getElement(instance) {
|
|
308
310
|
return instance._wrapper;
|
|
309
311
|
}
|
|
310
|
-
update(
|
|
312
|
+
update(issue) {
|
|
311
313
|
const rule = this._rule;
|
|
312
314
|
const wrapper = this._wrapper;
|
|
313
|
-
const element =
|
|
315
|
+
const element = issue.element;
|
|
316
|
+
if (!wrapper) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
314
319
|
wrapper.__abledomui = true;
|
|
315
320
|
wrapper.textContent = "";
|
|
316
|
-
new DOMBuilder(wrapper).openTag(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
).openTag("div", {
|
|
330
|
-
class: `abledom-notification${rule.type === 2 /* Warning */ ? " abledom-notification_warning" : rule.type === 3 /* Info */ ? " abledom-notification_info" : ""}`
|
|
321
|
+
new DOMBuilder(wrapper).openTag("div", { class: "abledom-issue-container" }, (container) => {
|
|
322
|
+
container.onmouseenter = () => {
|
|
323
|
+
var _a;
|
|
324
|
+
element && ((_a = this._issuesUI) == null ? void 0 : _a.highlight(element));
|
|
325
|
+
};
|
|
326
|
+
container.onmouseleave = () => {
|
|
327
|
+
var _a;
|
|
328
|
+
(_a = this._issuesUI) == null ? void 0 : _a.highlight(null);
|
|
329
|
+
};
|
|
330
|
+
}).openTag("div", {
|
|
331
|
+
class: `abledom-issue${rule.type === 2 /* Warning */ ? " abledom-issue_warning" : rule.type === 3 /* Info */ ? " abledom-issue_info" : ""}`
|
|
331
332
|
}).openTag(
|
|
332
333
|
"button",
|
|
333
334
|
{
|
|
@@ -336,7 +337,7 @@ var NotificationUI = class {
|
|
|
336
337
|
},
|
|
337
338
|
(logButton) => {
|
|
338
339
|
logButton.onclick = () => {
|
|
339
|
-
const { id, message, element: element2, rel, help, ...extra } =
|
|
340
|
+
const { id, message, element: element2, rel, help, ...extra } = issue;
|
|
340
341
|
this._core.log(
|
|
341
342
|
"AbleDOM: ",
|
|
342
343
|
"\nid:",
|
|
@@ -359,12 +360,12 @@ var NotificationUI = class {
|
|
|
359
360
|
title: "Scroll element into view"
|
|
360
361
|
},
|
|
361
362
|
(revealButton) => {
|
|
362
|
-
const element2 =
|
|
363
|
+
const element2 = issue.element;
|
|
363
364
|
if (element2) {
|
|
364
365
|
revealButton.onclick = () => {
|
|
365
366
|
var _a;
|
|
366
|
-
element2.scrollIntoView();
|
|
367
|
-
(_a = this.
|
|
367
|
+
element2.scrollIntoView({ block: "center" });
|
|
368
|
+
(_a = this._issuesUI) == null ? void 0 : _a.highlight(element2);
|
|
368
369
|
};
|
|
369
370
|
} else {
|
|
370
371
|
revealButton.style.display = "none";
|
|
@@ -378,29 +379,29 @@ var NotificationUI = class {
|
|
|
378
379
|
},
|
|
379
380
|
(bugReportButton) => {
|
|
380
381
|
var _a, _b;
|
|
381
|
-
const bugReport = (_a = this.
|
|
382
|
-
if (bugReport == null ? void 0 : bugReport.isVisible(
|
|
383
|
-
const title = (_b = bugReport.getTitle) == null ? void 0 : _b.call(bugReport,
|
|
382
|
+
const bugReport = (_a = this._issuesUI) == null ? void 0 : _a.bugReport;
|
|
383
|
+
if (bugReport == null ? void 0 : bugReport.isVisible(issue)) {
|
|
384
|
+
const title = (_b = bugReport.getTitle) == null ? void 0 : _b.call(bugReport, issue);
|
|
384
385
|
if (title) {
|
|
385
386
|
bugReportButton.title = title;
|
|
386
387
|
}
|
|
387
388
|
bugReportButton.onclick = () => {
|
|
388
|
-
bugReport.onClick(
|
|
389
|
+
bugReport.onClick(issue);
|
|
389
390
|
};
|
|
390
391
|
} else {
|
|
391
392
|
bugReportButton.style.display = "none";
|
|
392
393
|
}
|
|
393
394
|
}
|
|
394
|
-
).element(bug_default).closeTag().text(
|
|
395
|
+
).element(bug_default).closeTag().text(issue.message).openTag(
|
|
395
396
|
"a",
|
|
396
397
|
{
|
|
397
398
|
class: "button close",
|
|
398
|
-
href:
|
|
399
|
+
href: issue.help || "/",
|
|
399
400
|
title: "Open help",
|
|
400
401
|
target: "_blank"
|
|
401
402
|
},
|
|
402
403
|
(help) => {
|
|
403
|
-
if (!
|
|
404
|
+
if (!issue.help) {
|
|
404
405
|
help.style.display = "none";
|
|
405
406
|
}
|
|
406
407
|
}
|
|
@@ -414,13 +415,16 @@ var NotificationUI = class {
|
|
|
414
415
|
closeButton.onclick = () => {
|
|
415
416
|
var _a;
|
|
416
417
|
this.toggle(false);
|
|
417
|
-
(_a = this.
|
|
418
|
+
(_a = this._issuesUI) == null ? void 0 : _a.highlight(null);
|
|
418
419
|
};
|
|
419
420
|
}
|
|
420
421
|
).element(close_default).closeTag().closeTag().closeTag();
|
|
421
422
|
}
|
|
422
423
|
toggle(show, initial = false) {
|
|
423
424
|
var _a;
|
|
425
|
+
if (!this._wrapper) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
424
428
|
this.isHidden = !show;
|
|
425
429
|
if (!initial) {
|
|
426
430
|
(_a = this._onToggle) == null ? void 0 : _a.call(this, this, show);
|
|
@@ -431,18 +435,18 @@ var NotificationUI = class {
|
|
|
431
435
|
this._wrapper.style.display = show ? "block" : "none";
|
|
432
436
|
}
|
|
433
437
|
dispose() {
|
|
434
|
-
var _a;
|
|
435
|
-
this._wrapper.remove();
|
|
436
|
-
(
|
|
437
|
-
delete this.
|
|
438
|
+
var _a, _b;
|
|
439
|
+
(_a = this._wrapper) == null ? void 0 : _a.remove();
|
|
440
|
+
(_b = this._issuesUI) == null ? void 0 : _b.removeIssue(this);
|
|
441
|
+
delete this._issuesUI;
|
|
438
442
|
}
|
|
439
443
|
};
|
|
440
|
-
var
|
|
444
|
+
var IssuesUI = class {
|
|
441
445
|
constructor(win, props) {
|
|
442
446
|
__publicField(this, "_container");
|
|
443
|
-
__publicField(this, "
|
|
447
|
+
__publicField(this, "_issuesContainer");
|
|
444
448
|
__publicField(this, "_menuElement");
|
|
445
|
-
__publicField(this, "
|
|
449
|
+
__publicField(this, "_issueCountElement");
|
|
446
450
|
__publicField(this, "_showAllButton");
|
|
447
451
|
__publicField(this, "_hideAllButton");
|
|
448
452
|
__publicField(this, "_alignBottomLeftButton");
|
|
@@ -450,10 +454,15 @@ var NotificationsUI = class {
|
|
|
450
454
|
__publicField(this, "_alignTopRightButton");
|
|
451
455
|
__publicField(this, "_alignBottomRightButton");
|
|
452
456
|
__publicField(this, "_isMuted", false);
|
|
453
|
-
__publicField(this, "
|
|
457
|
+
__publicField(this, "_issues", /* @__PURE__ */ new Set());
|
|
454
458
|
__publicField(this, "_highlighter");
|
|
455
459
|
__publicField(this, "bugReport");
|
|
460
|
+
__publicField(this, "headless");
|
|
456
461
|
this.bugReport = props.bugReport;
|
|
462
|
+
this.headless = !!props.headless;
|
|
463
|
+
if (this.headless) {
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
457
466
|
const doc = win.document;
|
|
458
467
|
const container = this._container = doc.createElement("div");
|
|
459
468
|
container.__abledomui = true;
|
|
@@ -462,10 +471,10 @@ var NotificationsUI = class {
|
|
|
462
471
|
style.type = "text/css";
|
|
463
472
|
style.appendChild(doc.createTextNode(ui_default));
|
|
464
473
|
container.appendChild(style);
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
container.appendChild(
|
|
474
|
+
const issuesContainer = this._issuesContainer = doc.createElement("div");
|
|
475
|
+
issuesContainer.__abledomui = true;
|
|
476
|
+
issuesContainer.className = "abledom-issues-container";
|
|
477
|
+
container.appendChild(issuesContainer);
|
|
469
478
|
const menuElement = this._menuElement = doc.createElement("div");
|
|
470
479
|
menuElement.__abledomui = true;
|
|
471
480
|
menuElement.className = "abledom-menu-container";
|
|
@@ -473,17 +482,17 @@ var NotificationsUI = class {
|
|
|
473
482
|
new DOMBuilder(menuElement).openTag("div", { class: "abledom-menu" }).openTag(
|
|
474
483
|
"span",
|
|
475
484
|
{
|
|
476
|
-
class: "
|
|
477
|
-
title: "Number of
|
|
485
|
+
class: "issues-count",
|
|
486
|
+
title: "Number of issues"
|
|
478
487
|
},
|
|
479
|
-
(
|
|
480
|
-
this.
|
|
488
|
+
(issueCountElement) => {
|
|
489
|
+
this._issueCountElement = issueCountElement;
|
|
481
490
|
}
|
|
482
491
|
).closeTag().openTag(
|
|
483
492
|
"button",
|
|
484
493
|
{
|
|
485
494
|
class: "button",
|
|
486
|
-
title: "Show all
|
|
495
|
+
title: "Show all issues"
|
|
487
496
|
},
|
|
488
497
|
(showAllButton) => {
|
|
489
498
|
this._showAllButton = showAllButton;
|
|
@@ -495,7 +504,7 @@ var NotificationsUI = class {
|
|
|
495
504
|
"button",
|
|
496
505
|
{
|
|
497
506
|
class: "button",
|
|
498
|
-
title: "Hide all
|
|
507
|
+
title: "Hide all issues"
|
|
499
508
|
},
|
|
500
509
|
(hideAllButton) => {
|
|
501
510
|
this._hideAllButton = hideAllButton;
|
|
@@ -507,21 +516,15 @@ var NotificationsUI = class {
|
|
|
507
516
|
"button",
|
|
508
517
|
{
|
|
509
518
|
class: "button",
|
|
510
|
-
title: "Mute newly appearing
|
|
519
|
+
title: "Mute newly appearing issues"
|
|
511
520
|
},
|
|
512
521
|
(muteButton) => {
|
|
513
522
|
muteButton.onclick = () => {
|
|
514
523
|
const isMuted = this._isMuted = muteButton.classList.toggle(pressedClass);
|
|
515
524
|
if (isMuted) {
|
|
516
|
-
muteButton.setAttribute(
|
|
517
|
-
"title",
|
|
518
|
-
"Unmute newly appearing notifications"
|
|
519
|
-
);
|
|
525
|
+
muteButton.setAttribute("title", "Unmute newly appearing issues");
|
|
520
526
|
} else {
|
|
521
|
-
muteButton.setAttribute(
|
|
522
|
-
"title",
|
|
523
|
-
"Mute newly appearing notifications"
|
|
524
|
-
);
|
|
527
|
+
muteButton.setAttribute("title", "Mute newly appearing issues");
|
|
525
528
|
}
|
|
526
529
|
};
|
|
527
530
|
}
|
|
@@ -529,7 +532,7 @@ var NotificationsUI = class {
|
|
|
529
532
|
"button",
|
|
530
533
|
{
|
|
531
534
|
class: "button align-button align-button-first pressed",
|
|
532
|
-
title: "Attach
|
|
535
|
+
title: "Attach issues to bottom left"
|
|
533
536
|
},
|
|
534
537
|
(alignBottomLeftButton) => {
|
|
535
538
|
this._alignBottomLeftButton = alignBottomLeftButton;
|
|
@@ -541,7 +544,7 @@ var NotificationsUI = class {
|
|
|
541
544
|
"button",
|
|
542
545
|
{
|
|
543
546
|
class: "button align-button",
|
|
544
|
-
title: "Attach
|
|
547
|
+
title: "Attach issues to top left"
|
|
545
548
|
},
|
|
546
549
|
(alignTopLeftButton) => {
|
|
547
550
|
this._alignTopLeftButton = alignTopLeftButton;
|
|
@@ -553,7 +556,7 @@ var NotificationsUI = class {
|
|
|
553
556
|
"button",
|
|
554
557
|
{
|
|
555
558
|
class: "button align-button",
|
|
556
|
-
title: "Attach
|
|
559
|
+
title: "Attach issues to top right"
|
|
557
560
|
},
|
|
558
561
|
(alignTopRightButton) => {
|
|
559
562
|
this._alignTopRightButton = alignTopRightButton;
|
|
@@ -565,7 +568,7 @@ var NotificationsUI = class {
|
|
|
565
568
|
"button",
|
|
566
569
|
{
|
|
567
570
|
class: "button align-button align-button-last",
|
|
568
|
-
title: "Attach
|
|
571
|
+
title: "Attach issues to bottom right"
|
|
569
572
|
},
|
|
570
573
|
(alignBottomRightButton) => {
|
|
571
574
|
this._alignBottomRightButton = alignBottomRightButton;
|
|
@@ -579,7 +582,7 @@ var NotificationsUI = class {
|
|
|
579
582
|
}
|
|
580
583
|
setUIAlignment(alignment) {
|
|
581
584
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
582
|
-
if (!this._container || !this.
|
|
585
|
+
if (!this._container || !this._issuesContainer || !this._menuElement) {
|
|
583
586
|
return;
|
|
584
587
|
}
|
|
585
588
|
(_a = this._alignBottomLeftButton) == null ? void 0 : _a.classList.remove(pressedClass);
|
|
@@ -593,16 +596,16 @@ var NotificationsUI = class {
|
|
|
593
596
|
"abledom-align-bottom"
|
|
594
597
|
);
|
|
595
598
|
let containerClasses = [];
|
|
596
|
-
let
|
|
599
|
+
let issuesFirst = false;
|
|
597
600
|
switch (alignment) {
|
|
598
601
|
case "bottom-left" /* BottomLeft */:
|
|
599
602
|
containerClasses = ["abledom-align-left", "abledom-align-bottom"];
|
|
600
|
-
|
|
603
|
+
issuesFirst = true;
|
|
601
604
|
(_e = this._alignBottomLeftButton) == null ? void 0 : _e.classList.add(pressedClass);
|
|
602
605
|
break;
|
|
603
606
|
case "bottom-right" /* BottomRight */:
|
|
604
607
|
containerClasses = ["abledom-align-right", "abledom-align-bottom"];
|
|
605
|
-
|
|
608
|
+
issuesFirst = true;
|
|
606
609
|
(_f = this._alignBottomRightButton) == null ? void 0 : _f.classList.add(pressedClass);
|
|
607
610
|
break;
|
|
608
611
|
case "top-left" /* TopLeft */:
|
|
@@ -616,18 +619,18 @@ var NotificationsUI = class {
|
|
|
616
619
|
}
|
|
617
620
|
this._container.classList.add(...containerClasses);
|
|
618
621
|
this._container.insertBefore(
|
|
619
|
-
this.
|
|
620
|
-
|
|
622
|
+
this._issuesContainer,
|
|
623
|
+
issuesFirst ? this._menuElement : null
|
|
621
624
|
);
|
|
622
625
|
}
|
|
623
|
-
|
|
626
|
+
_setIssuesCount(count) {
|
|
624
627
|
if (!this._menuElement) {
|
|
625
628
|
return;
|
|
626
629
|
}
|
|
627
|
-
const countElement = this.
|
|
630
|
+
const countElement = this._issueCountElement;
|
|
628
631
|
if (countElement && count > 0) {
|
|
629
632
|
countElement.textContent = "";
|
|
630
|
-
new DOMBuilder(countElement).openTag("strong").text(`${count}`).closeTag().text(`
|
|
633
|
+
new DOMBuilder(countElement).openTag("strong").text(`${count}`).closeTag().text(` issue${count > 1 ? "s" : ""}`);
|
|
631
634
|
this._menuElement.style.display = "block";
|
|
632
635
|
} else {
|
|
633
636
|
this._menuElement.style.display = "none";
|
|
@@ -641,8 +644,8 @@ var NotificationsUI = class {
|
|
|
641
644
|
}
|
|
642
645
|
let allHidden = true;
|
|
643
646
|
let allVisible = true;
|
|
644
|
-
for (let
|
|
645
|
-
if (
|
|
647
|
+
for (let issue of this._issues) {
|
|
648
|
+
if (issue.isHidden) {
|
|
646
649
|
allVisible = false;
|
|
647
650
|
} else {
|
|
648
651
|
allHidden = false;
|
|
@@ -654,44 +657,46 @@ var NotificationsUI = class {
|
|
|
654
657
|
hideAllButton.style.display = allHidden ? "none" : "block";
|
|
655
658
|
showAllButton.style.display = allVisible ? "none" : "block";
|
|
656
659
|
}
|
|
657
|
-
|
|
658
|
-
if (
|
|
659
|
-
|
|
660
|
+
addIssue(issue) {
|
|
661
|
+
if (this._issues.has(issue)) {
|
|
662
|
+
return;
|
|
660
663
|
}
|
|
661
|
-
|
|
664
|
+
this._issues.add(issue);
|
|
665
|
+
if (this.headless) {
|
|
662
666
|
return;
|
|
663
667
|
}
|
|
668
|
+
if (!this._issuesContainer) {
|
|
669
|
+
throw new Error("IssuesUI is not initialized");
|
|
670
|
+
}
|
|
664
671
|
if (this._isMuted) {
|
|
665
|
-
|
|
672
|
+
issue.toggle(false, true);
|
|
666
673
|
}
|
|
667
|
-
|
|
668
|
-
this.
|
|
669
|
-
|
|
670
|
-
);
|
|
671
|
-
NotificationUI.setOnToggle(notification, () => {
|
|
674
|
+
const issueUIWraper = IssueUI.getElement(issue);
|
|
675
|
+
issueUIWraper && this._issuesContainer.appendChild(issueUIWraper);
|
|
676
|
+
IssueUI.setOnToggle(issue, () => {
|
|
672
677
|
this._setShowHideButtonsVisibility();
|
|
673
678
|
});
|
|
674
|
-
this.
|
|
679
|
+
this._setIssuesCount(this._issues.size);
|
|
675
680
|
this._setShowHideButtonsVisibility();
|
|
676
681
|
}
|
|
677
|
-
|
|
678
|
-
if (!this.
|
|
682
|
+
removeIssue(issue) {
|
|
683
|
+
if (!this._issues.has(issue)) {
|
|
679
684
|
return;
|
|
680
685
|
}
|
|
681
|
-
this.
|
|
682
|
-
this.
|
|
686
|
+
this._issues.delete(issue);
|
|
687
|
+
this._setIssuesCount(this._issues.size);
|
|
683
688
|
this._setShowHideButtonsVisibility();
|
|
684
689
|
this.highlight(null);
|
|
685
690
|
}
|
|
686
691
|
hideAll() {
|
|
687
|
-
this.
|
|
688
|
-
|
|
692
|
+
this._issues.forEach((issue) => {
|
|
693
|
+
issue.toggle(false);
|
|
689
694
|
});
|
|
690
695
|
this._setShowHideButtonsVisibility();
|
|
691
696
|
}
|
|
692
697
|
showAll() {
|
|
693
|
-
this.
|
|
694
|
-
|
|
698
|
+
this._issues.forEach((issue) => {
|
|
699
|
+
issue.toggle(true);
|
|
695
700
|
});
|
|
696
701
|
this._setShowHideButtonsVisibility();
|
|
697
702
|
}
|
|
@@ -705,9 +710,9 @@ var NotificationsUI = class {
|
|
|
705
710
|
(_b = this._container) == null ? void 0 : _b.remove();
|
|
706
711
|
delete this._highlighter;
|
|
707
712
|
delete this._container;
|
|
708
|
-
delete this.
|
|
713
|
+
delete this._issuesContainer;
|
|
709
714
|
delete this._menuElement;
|
|
710
|
-
delete this.
|
|
715
|
+
delete this._issueCountElement;
|
|
711
716
|
delete this._showAllButton;
|
|
712
717
|
delete this._hideAllButton;
|
|
713
718
|
delete this._alignBottomLeftButton;
|
|
@@ -992,7 +997,7 @@ var AbleDOM = class {
|
|
|
992
997
|
__publicField(this, "_props");
|
|
993
998
|
__publicField(this, "_observer");
|
|
994
999
|
__publicField(this, "_clearValidationTimeout");
|
|
995
|
-
__publicField(this, "
|
|
1000
|
+
__publicField(this, "_elementsWithIssues", /* @__PURE__ */ new Set());
|
|
996
1001
|
__publicField(this, "_changedElementIds", /* @__PURE__ */ new Set());
|
|
997
1002
|
__publicField(this, "_elementsDependingOnId", /* @__PURE__ */ new Map());
|
|
998
1003
|
__publicField(this, "_dependantIdsByElement", /* @__PURE__ */ new Map());
|
|
@@ -1000,7 +1005,9 @@ var AbleDOM = class {
|
|
|
1000
1005
|
__publicField(this, "_rules", []);
|
|
1001
1006
|
__publicField(this, "_startFunc");
|
|
1002
1007
|
__publicField(this, "_isStarted", false);
|
|
1003
|
-
__publicField(this, "
|
|
1008
|
+
__publicField(this, "_issuesUI");
|
|
1009
|
+
__publicField(this, "_idlePromise");
|
|
1010
|
+
__publicField(this, "_idleResolve");
|
|
1004
1011
|
__publicField(this, "_onFocusIn", (event) => {
|
|
1005
1012
|
var _a;
|
|
1006
1013
|
const target = event.target;
|
|
@@ -1008,9 +1015,9 @@ var AbleDOM = class {
|
|
|
1008
1015
|
return;
|
|
1009
1016
|
}
|
|
1010
1017
|
for (const rule of this._rules) {
|
|
1011
|
-
const
|
|
1012
|
-
if (
|
|
1013
|
-
this.
|
|
1018
|
+
const focusIssue = (_a = rule.focused) == null ? void 0 : _a.call(rule, event);
|
|
1019
|
+
if (focusIssue) {
|
|
1020
|
+
this._addIssue(rule, focusIssue);
|
|
1014
1021
|
}
|
|
1015
1022
|
}
|
|
1016
1023
|
});
|
|
@@ -1021,14 +1028,14 @@ var AbleDOM = class {
|
|
|
1021
1028
|
return;
|
|
1022
1029
|
}
|
|
1023
1030
|
for (const rule of this._rules) {
|
|
1024
|
-
const
|
|
1025
|
-
if (
|
|
1026
|
-
this.
|
|
1031
|
+
const blurIssue = (_a = rule.blurred) == null ? void 0 : _a.call(rule, event);
|
|
1032
|
+
if (blurIssue) {
|
|
1033
|
+
this._addIssue(rule, blurIssue);
|
|
1027
1034
|
}
|
|
1028
1035
|
}
|
|
1029
1036
|
});
|
|
1030
|
-
__publicField(this, "_notifyAsync", (rule,
|
|
1031
|
-
this.
|
|
1037
|
+
__publicField(this, "_notifyAsync", (rule, issue) => {
|
|
1038
|
+
this._addIssue(rule, issue);
|
|
1032
1039
|
});
|
|
1033
1040
|
__publicField(this, "log", (...args) => {
|
|
1034
1041
|
var _a, _b, _c, _d;
|
|
@@ -1065,12 +1072,14 @@ var AbleDOM = class {
|
|
|
1065
1072
|
}
|
|
1066
1073
|
(_a = this._clearValidationTimeout) == null ? void 0 : _a.call(this);
|
|
1067
1074
|
const _validationTimeout = win.setTimeout(() => {
|
|
1075
|
+
var _a2;
|
|
1068
1076
|
delete this._clearValidationTimeout;
|
|
1069
1077
|
this._remove(_elementsToRemove);
|
|
1070
1078
|
this._validate(_elementsToValidate);
|
|
1071
1079
|
_elementsToRemove.clear();
|
|
1072
1080
|
_elementsToValidate.clear();
|
|
1073
1081
|
this._changedElementIds.clear();
|
|
1082
|
+
(_a2 = this._idleResolve) == null ? void 0 : _a2.call(this);
|
|
1074
1083
|
}, 200);
|
|
1075
1084
|
this._clearValidationTimeout = () => {
|
|
1076
1085
|
win.clearTimeout(_validationTimeout);
|
|
@@ -1165,65 +1174,70 @@ var AbleDOM = class {
|
|
|
1165
1174
|
this._idByElement.delete(element);
|
|
1166
1175
|
}
|
|
1167
1176
|
}
|
|
1168
|
-
|
|
1169
|
-
var _a;
|
|
1170
|
-
if (!this.
|
|
1171
|
-
this.
|
|
1172
|
-
bugReport: (_a = this._props) == null ? void 0 : _a.bugReport
|
|
1177
|
+
_addIssue(rule, issue) {
|
|
1178
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1179
|
+
if (!this._issuesUI) {
|
|
1180
|
+
this._issuesUI = new IssuesUI(this._win, {
|
|
1181
|
+
bugReport: (_a = this._props) == null ? void 0 : _a.bugReport,
|
|
1182
|
+
headless: (_b = this._props) == null ? void 0 : _b.headless
|
|
1173
1183
|
});
|
|
1174
1184
|
}
|
|
1175
|
-
const element =
|
|
1176
|
-
if (!
|
|
1177
|
-
this.
|
|
1185
|
+
const element = issue == null ? void 0 : issue.element;
|
|
1186
|
+
if (!issue) {
|
|
1187
|
+
this._removeIssue(element || this._win.document.body, rule);
|
|
1178
1188
|
return;
|
|
1179
1189
|
}
|
|
1180
|
-
let
|
|
1190
|
+
let issueUI;
|
|
1191
|
+
let justUpdate = true;
|
|
1181
1192
|
if (rule.anchored && element) {
|
|
1182
1193
|
let abledomOnElement = element.__abledom;
|
|
1183
1194
|
if (!abledomOnElement) {
|
|
1184
1195
|
abledomOnElement = element.__abledom = {};
|
|
1185
1196
|
}
|
|
1186
|
-
let
|
|
1187
|
-
if (!
|
|
1188
|
-
|
|
1197
|
+
let issues = abledomOnElement.issues;
|
|
1198
|
+
if (!issues) {
|
|
1199
|
+
issues = abledomOnElement.issues = /* @__PURE__ */ new Map();
|
|
1189
1200
|
}
|
|
1190
|
-
|
|
1191
|
-
if (!
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
this._notificationsUI
|
|
1197
|
-
);
|
|
1198
|
-
notifications.set(rule, notificationUI);
|
|
1201
|
+
issueUI = issues.get(rule);
|
|
1202
|
+
if (!issueUI) {
|
|
1203
|
+
issueUI = new IssueUI(this._win, this, rule, this._issuesUI);
|
|
1204
|
+
issues.set(rule, issueUI);
|
|
1205
|
+
justUpdate = false;
|
|
1206
|
+
(_e = (_d = (_c = this._props) == null ? void 0 : _c.callbacks) == null ? void 0 : _d.onIssueAdded) == null ? void 0 : _e.call(_d, element, rule, issue);
|
|
1199
1207
|
}
|
|
1200
|
-
this.
|
|
1208
|
+
this._elementsWithIssues.add(element);
|
|
1201
1209
|
} else {
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1210
|
+
issueUI = new IssueUI(this._win, this, rule, this._issuesUI);
|
|
1211
|
+
justUpdate = false;
|
|
1212
|
+
(_h = (_g = (_f = this._props) == null ? void 0 : _f.callbacks) == null ? void 0 : _g.onIssueAdded) == null ? void 0 : _h.call(_g, null, rule, issue);
|
|
1213
|
+
}
|
|
1214
|
+
issueUI.update(issue);
|
|
1215
|
+
if (justUpdate) {
|
|
1216
|
+
(_k = (_j = (_i = this._props) == null ? void 0 : _i.callbacks) == null ? void 0 : _j.onIssueUpdated) == null ? void 0 : _k.call(
|
|
1217
|
+
_j,
|
|
1218
|
+
rule.anchored && element ? element : null,
|
|
1205
1219
|
rule,
|
|
1206
|
-
|
|
1220
|
+
issue
|
|
1207
1221
|
);
|
|
1208
1222
|
}
|
|
1209
|
-
notificationUI.update(notification);
|
|
1210
1223
|
}
|
|
1211
|
-
|
|
1212
|
-
var _a;
|
|
1224
|
+
_removeIssue(element, rule) {
|
|
1225
|
+
var _a, _b, _c, _d;
|
|
1213
1226
|
if (!rule.anchored) {
|
|
1214
1227
|
return;
|
|
1215
1228
|
}
|
|
1216
|
-
const
|
|
1217
|
-
if (!
|
|
1229
|
+
const issues = (_a = element.__abledom) == null ? void 0 : _a.issues;
|
|
1230
|
+
if (!issues) {
|
|
1218
1231
|
return;
|
|
1219
1232
|
}
|
|
1220
|
-
const
|
|
1221
|
-
if (
|
|
1222
|
-
|
|
1223
|
-
|
|
1233
|
+
const issue = issues.get(rule);
|
|
1234
|
+
if (issue) {
|
|
1235
|
+
issue.dispose();
|
|
1236
|
+
issues.delete(rule);
|
|
1237
|
+
(_d = (_c = (_b = this._props) == null ? void 0 : _b.callbacks) == null ? void 0 : _c.onIssueRemoved) == null ? void 0 : _d.call(_c, element, rule);
|
|
1224
1238
|
}
|
|
1225
|
-
if (
|
|
1226
|
-
this.
|
|
1239
|
+
if (issues.size === 0) {
|
|
1240
|
+
this._elementsWithIssues.delete(element);
|
|
1227
1241
|
delete element.__abledom;
|
|
1228
1242
|
}
|
|
1229
1243
|
}
|
|
@@ -1238,7 +1252,7 @@ var AbleDOM = class {
|
|
|
1238
1252
|
}
|
|
1239
1253
|
elements.forEach((element) => {
|
|
1240
1254
|
var _a, _b, _c, _d, _e;
|
|
1241
|
-
if (isAccessibilityAffectingElement(element) || ((_a = element.__abledom) == null ? void 0 : _a.
|
|
1255
|
+
if (isAccessibilityAffectingElement(element) || ((_a = element.__abledom) == null ? void 0 : _a.issues)) {
|
|
1242
1256
|
const dependsOnIds = /* @__PURE__ */ new Set();
|
|
1243
1257
|
for (const rule of this._rules) {
|
|
1244
1258
|
if (!rule.validate || ((_b = rule.accept) == null ? void 0 : _b.call(rule, element)) === false) {
|
|
@@ -1248,16 +1262,16 @@ var AbleDOM = class {
|
|
|
1248
1262
|
continue;
|
|
1249
1263
|
}
|
|
1250
1264
|
const validationResult = (_c = rule.validate) == null ? void 0 : _c.call(rule, element);
|
|
1251
|
-
if (validationResult == null ? void 0 : validationResult.
|
|
1252
|
-
this.
|
|
1265
|
+
if (validationResult == null ? void 0 : validationResult.issue) {
|
|
1266
|
+
this._addIssue(rule, validationResult.issue);
|
|
1253
1267
|
const ids = validationResult.dependsOnIds;
|
|
1254
1268
|
if (ids) {
|
|
1255
1269
|
for (const id of ids) {
|
|
1256
1270
|
dependsOnIds.add(id);
|
|
1257
1271
|
}
|
|
1258
1272
|
}
|
|
1259
|
-
} else if ((_e = (_d = element.__abledom) == null ? void 0 : _d.
|
|
1260
|
-
this.
|
|
1273
|
+
} else if ((_e = (_d = element.__abledom) == null ? void 0 : _d.issues) == null ? void 0 : _e.has(rule)) {
|
|
1274
|
+
this._removeIssue(element, rule);
|
|
1261
1275
|
}
|
|
1262
1276
|
}
|
|
1263
1277
|
this._processElementDependingOnIds(
|
|
@@ -1309,10 +1323,25 @@ var AbleDOM = class {
|
|
|
1309
1323
|
_remove(elements) {
|
|
1310
1324
|
elements.forEach((element) => {
|
|
1311
1325
|
var _a, _b;
|
|
1312
|
-
const rules = [...((_b = (_a = element.__abledom) == null ? void 0 : _a.
|
|
1313
|
-
rules.forEach((rule) => this.
|
|
1326
|
+
const rules = [...((_b = (_a = element.__abledom) == null ? void 0 : _a.issues) == null ? void 0 : _b.keys()) || []];
|
|
1327
|
+
rules.forEach((rule) => this._removeIssue(element, rule));
|
|
1314
1328
|
});
|
|
1315
1329
|
}
|
|
1330
|
+
idle() {
|
|
1331
|
+
if (!this._clearValidationTimeout) {
|
|
1332
|
+
return Promise.resolve();
|
|
1333
|
+
}
|
|
1334
|
+
if (!this._idlePromise) {
|
|
1335
|
+
this._idlePromise = new Promise((resolve) => {
|
|
1336
|
+
this._idleResolve = () => {
|
|
1337
|
+
delete this._idlePromise;
|
|
1338
|
+
delete this._idleResolve;
|
|
1339
|
+
resolve();
|
|
1340
|
+
};
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
return this._idlePromise;
|
|
1344
|
+
}
|
|
1316
1345
|
addRule(rule) {
|
|
1317
1346
|
this._rules.push(rule);
|
|
1318
1347
|
}
|
|
@@ -1338,20 +1367,21 @@ var AbleDOM = class {
|
|
|
1338
1367
|
(_b = this._startFunc) == null ? void 0 : _b.call(this);
|
|
1339
1368
|
}
|
|
1340
1369
|
dispose() {
|
|
1341
|
-
var _a, _b, _c;
|
|
1370
|
+
var _a, _b, _c, _d;
|
|
1342
1371
|
const doc = this._win.document;
|
|
1343
1372
|
doc.addEventListener("focusin", this._onFocusIn, true);
|
|
1344
1373
|
doc.addEventListener("focusout", this._onFocusOut, true);
|
|
1345
|
-
this._remove(this.
|
|
1346
|
-
this.
|
|
1374
|
+
this._remove(this._elementsWithIssues);
|
|
1375
|
+
this._elementsWithIssues.clear();
|
|
1347
1376
|
this._dependantIdsByElement.clear();
|
|
1348
1377
|
this._elementsDependingOnId.clear();
|
|
1349
1378
|
this._idByElement.clear();
|
|
1350
|
-
(_a = this.
|
|
1351
|
-
delete this.
|
|
1379
|
+
(_a = this._issuesUI) == null ? void 0 : _a.dispose();
|
|
1380
|
+
delete this._issuesUI;
|
|
1352
1381
|
(_b = this._clearValidationTimeout) == null ? void 0 : _b.call(this);
|
|
1382
|
+
(_c = this._idleResolve) == null ? void 0 : _c.call(this);
|
|
1353
1383
|
for (const rule of this._rules) {
|
|
1354
|
-
(
|
|
1384
|
+
(_d = rule.stop) == null ? void 0 : _d.call(rule);
|
|
1355
1385
|
ValidationRule.dispose(rule);
|
|
1356
1386
|
}
|
|
1357
1387
|
this._rules = [];
|
|
@@ -1401,7 +1431,7 @@ var AtomicRule = class extends ValidationRule {
|
|
|
1401
1431
|
).snapshotItem(0);
|
|
1402
1432
|
if (parentAtomic) {
|
|
1403
1433
|
return {
|
|
1404
|
-
|
|
1434
|
+
issue: {
|
|
1405
1435
|
id: "focusable-in-atomic",
|
|
1406
1436
|
message: "Focusable element inside atomic focusable.",
|
|
1407
1437
|
element,
|
|
@@ -1539,7 +1569,7 @@ var FocusableElementLabelRule = class extends ValidationRule {
|
|
|
1539
1569
|
}
|
|
1540
1570
|
}
|
|
1541
1571
|
return {
|
|
1542
|
-
|
|
1572
|
+
issue: isElementVisible(element) ? {
|
|
1543
1573
|
id: "focusable-element-label",
|
|
1544
1574
|
message: "Focusable element must have a non-empty text label.",
|
|
1545
1575
|
element,
|
|
@@ -1579,7 +1609,7 @@ var ExistingIdRule = class extends ValidationRule {
|
|
|
1579
1609
|
}
|
|
1580
1610
|
}
|
|
1581
1611
|
return {
|
|
1582
|
-
|
|
1612
|
+
issue: {
|
|
1583
1613
|
id: "missing-id",
|
|
1584
1614
|
message: `Elements with referenced ids do not extist.`,
|
|
1585
1615
|
element
|
|
@@ -1768,7 +1798,7 @@ var FindElementRule = class extends ValidationRule {
|
|
|
1768
1798
|
for (const name of Object.keys(this._conditions)) {
|
|
1769
1799
|
if (this._conditions[name](element)) {
|
|
1770
1800
|
return {
|
|
1771
|
-
|
|
1801
|
+
issue: {
|
|
1772
1802
|
id: "find-element",
|
|
1773
1803
|
message: `Element found: ${name}.`,
|
|
1774
1804
|
element
|