abledom 0.5.0 → 0.6.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 +127 -32
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +127 -32
- package/dist/index.js.map +1 -1
- package/dist/ts3.9/index.d.ts +15 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -69,12 +69,13 @@ interface AbleDOMProps {
|
|
|
69
69
|
headless?: boolean;
|
|
70
70
|
callbacks?: {
|
|
71
71
|
onIssueAdded?(element: HTMLElement | null, rule: ValidationRule, issue: ValidationIssue): void;
|
|
72
|
-
onIssueUpdated?(element: HTMLElement
|
|
73
|
-
onIssueRemoved?(element: HTMLElement
|
|
72
|
+
onIssueUpdated?(element: HTMLElement, rule: ValidationRule, issue: ValidationIssue): void;
|
|
73
|
+
onIssueRemoved?(element: HTMLElement, rule: ValidationRule): void;
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
declare class AbleDOM {
|
|
77
77
|
private _win;
|
|
78
|
+
private _isDisposed;
|
|
78
79
|
private _props;
|
|
79
80
|
private _observer;
|
|
80
81
|
private _clearValidationTimeout;
|
|
@@ -87,19 +88,30 @@ declare class AbleDOM {
|
|
|
87
88
|
private _startFunc;
|
|
88
89
|
private _isStarted;
|
|
89
90
|
private _issuesUI;
|
|
91
|
+
private _elementHighlighter;
|
|
90
92
|
private _idlePromise;
|
|
91
93
|
private _idleResolve;
|
|
94
|
+
private _currentAnchoredIssues;
|
|
95
|
+
private _currentNotAnchoredIssues;
|
|
92
96
|
constructor(win: Window, props?: AbleDOMProps);
|
|
93
97
|
private _onElementId;
|
|
98
|
+
private _getHighlighter;
|
|
94
99
|
private _addIssue;
|
|
95
100
|
private _removeIssue;
|
|
96
101
|
private _validate;
|
|
97
102
|
private _processElementDependingOnIds;
|
|
103
|
+
private _updateCurrentAnchoredIssues;
|
|
104
|
+
private _onIssueAdded;
|
|
105
|
+
private _onIssueUpdated;
|
|
106
|
+
private _onIssueRemoved;
|
|
98
107
|
private _remove;
|
|
99
108
|
private _onFocusIn;
|
|
100
109
|
private _onFocusOut;
|
|
101
110
|
private _notifyAsync;
|
|
102
|
-
|
|
111
|
+
private _getCurrentIssues;
|
|
112
|
+
idle(): Promise<ValidationIssue[]>;
|
|
113
|
+
clearCurrentIssues(anchored?: boolean, notAnchored?: boolean): void;
|
|
114
|
+
highlightElement(element: HTMLElement | null, scrollIntoView?: boolean, autoHideTime?: number): void;
|
|
103
115
|
log: typeof console.error;
|
|
104
116
|
addRule(rule: ValidationRule): void;
|
|
105
117
|
removeRule(rule: ValidationRule): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -69,12 +69,13 @@ interface AbleDOMProps {
|
|
|
69
69
|
headless?: boolean;
|
|
70
70
|
callbacks?: {
|
|
71
71
|
onIssueAdded?(element: HTMLElement | null, rule: ValidationRule, issue: ValidationIssue): void;
|
|
72
|
-
onIssueUpdated?(element: HTMLElement
|
|
73
|
-
onIssueRemoved?(element: HTMLElement
|
|
72
|
+
onIssueUpdated?(element: HTMLElement, rule: ValidationRule, issue: ValidationIssue): void;
|
|
73
|
+
onIssueRemoved?(element: HTMLElement, rule: ValidationRule): void;
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
declare class AbleDOM {
|
|
77
77
|
private _win;
|
|
78
|
+
private _isDisposed;
|
|
78
79
|
private _props;
|
|
79
80
|
private _observer;
|
|
80
81
|
private _clearValidationTimeout;
|
|
@@ -87,19 +88,30 @@ declare class AbleDOM {
|
|
|
87
88
|
private _startFunc;
|
|
88
89
|
private _isStarted;
|
|
89
90
|
private _issuesUI;
|
|
91
|
+
private _elementHighlighter;
|
|
90
92
|
private _idlePromise;
|
|
91
93
|
private _idleResolve;
|
|
94
|
+
private _currentAnchoredIssues;
|
|
95
|
+
private _currentNotAnchoredIssues;
|
|
92
96
|
constructor(win: Window, props?: AbleDOMProps);
|
|
93
97
|
private _onElementId;
|
|
98
|
+
private _getHighlighter;
|
|
94
99
|
private _addIssue;
|
|
95
100
|
private _removeIssue;
|
|
96
101
|
private _validate;
|
|
97
102
|
private _processElementDependingOnIds;
|
|
103
|
+
private _updateCurrentAnchoredIssues;
|
|
104
|
+
private _onIssueAdded;
|
|
105
|
+
private _onIssueUpdated;
|
|
106
|
+
private _onIssueRemoved;
|
|
98
107
|
private _remove;
|
|
99
108
|
private _onFocusIn;
|
|
100
109
|
private _onFocusOut;
|
|
101
110
|
private _notifyAsync;
|
|
102
|
-
|
|
111
|
+
private _getCurrentIssues;
|
|
112
|
+
idle(): Promise<ValidationIssue[]>;
|
|
113
|
+
clearCurrentIssues(anchored?: boolean, notAnchored?: boolean): void;
|
|
114
|
+
highlightElement(element: HTMLElement | null, scrollIntoView?: boolean, autoHideTime?: number): void;
|
|
103
115
|
log: typeof console.error;
|
|
104
116
|
addRule(rule: ValidationRule): void;
|
|
105
117
|
removeRule(rule: ValidationRule): void;
|
package/dist/index.js
CHANGED
|
@@ -97,7 +97,10 @@ var ValidationRule = class {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
// inline-file:/Users/marata/Documents/Work/abledom/src/ui/ui.css
|
|
100
|
-
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: auto;\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
|
|
100
|
+
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: auto;\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";
|
|
101
|
+
|
|
102
|
+
// inline-file:/Users/marata/Documents/Work/abledom/src/ui/highlighter.css
|
|
103
|
+
var highlighter_default = ".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";
|
|
101
104
|
|
|
102
105
|
// src/ui/domBuilder.ts
|
|
103
106
|
var DOMBuilder = class {
|
|
@@ -403,8 +406,7 @@ var IssueUI = class {
|
|
|
403
406
|
if (element2) {
|
|
404
407
|
revealButton.onclick = () => {
|
|
405
408
|
var _a;
|
|
406
|
-
|
|
407
|
-
(_a = this._issuesUI) == null ? void 0 : _a.highlight(element2);
|
|
409
|
+
(_a = this._issuesUI) == null ? void 0 : _a.highlight(element2, true);
|
|
408
410
|
};
|
|
409
411
|
} else {
|
|
410
412
|
revealButton.style.display = "none";
|
|
@@ -481,7 +483,8 @@ var IssueUI = class {
|
|
|
481
483
|
}
|
|
482
484
|
};
|
|
483
485
|
var IssuesUI = class {
|
|
484
|
-
constructor(win, props) {
|
|
486
|
+
constructor(win, getHighlighter, props) {
|
|
487
|
+
__publicField(this, "_win");
|
|
485
488
|
__publicField(this, "_container");
|
|
486
489
|
__publicField(this, "_issuesContainer");
|
|
487
490
|
__publicField(this, "_menuElement");
|
|
@@ -494,9 +497,11 @@ var IssuesUI = class {
|
|
|
494
497
|
__publicField(this, "_alignBottomRightButton");
|
|
495
498
|
__publicField(this, "_isMuted", false);
|
|
496
499
|
__publicField(this, "_issues", /* @__PURE__ */ new Set());
|
|
497
|
-
__publicField(this, "
|
|
500
|
+
__publicField(this, "_getHighlighter");
|
|
498
501
|
__publicField(this, "bugReport");
|
|
499
502
|
__publicField(this, "headless");
|
|
503
|
+
this._win = win;
|
|
504
|
+
this._getHighlighter = getHighlighter;
|
|
500
505
|
this.bugReport = props.bugReport;
|
|
501
506
|
this.headless = !!props.headless;
|
|
502
507
|
if (this.headless) {
|
|
@@ -617,7 +622,6 @@ var IssuesUI = class {
|
|
|
617
622
|
}
|
|
618
623
|
).element(alignbottomright_default).closeTag().closeTag();
|
|
619
624
|
doc.body.appendChild(container);
|
|
620
|
-
this._highlighter = new ElementHighlighter(win);
|
|
621
625
|
}
|
|
622
626
|
setUIAlignment(alignment) {
|
|
623
627
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -739,15 +743,15 @@ var IssuesUI = class {
|
|
|
739
743
|
});
|
|
740
744
|
this._setShowHideButtonsVisibility();
|
|
741
745
|
}
|
|
742
|
-
highlight(element) {
|
|
743
|
-
var _a;
|
|
744
|
-
(_a = this.
|
|
746
|
+
highlight(element, scrollIntoView, autoHideTime) {
|
|
747
|
+
var _a, _b;
|
|
748
|
+
(_b = (_a = this._getHighlighter) == null ? void 0 : _a.call(this)) == null ? void 0 : _b.highlight(element, scrollIntoView, autoHideTime);
|
|
745
749
|
}
|
|
746
750
|
dispose() {
|
|
747
|
-
var _a
|
|
748
|
-
(_a = this.
|
|
749
|
-
|
|
750
|
-
delete this.
|
|
751
|
+
var _a;
|
|
752
|
+
(_a = this._container) == null ? void 0 : _a.remove();
|
|
753
|
+
delete this._win;
|
|
754
|
+
delete this._getHighlighter;
|
|
751
755
|
delete this._container;
|
|
752
756
|
delete this._issuesContainer;
|
|
753
757
|
delete this._menuElement;
|
|
@@ -767,6 +771,7 @@ var ElementHighlighter = class {
|
|
|
767
771
|
__publicField(this, "_element");
|
|
768
772
|
__publicField(this, "_cancelScrollTimer");
|
|
769
773
|
__publicField(this, "_intersectionObserver");
|
|
774
|
+
__publicField(this, "_cancelAutoHideTimer");
|
|
770
775
|
__publicField(this, "_onScroll", () => {
|
|
771
776
|
var _a;
|
|
772
777
|
(_a = this._cancelScrollTimer) == null ? void 0 : _a.call(this);
|
|
@@ -787,10 +792,19 @@ var ElementHighlighter = class {
|
|
|
787
792
|
const container = this._container = win.document.createElement("div");
|
|
788
793
|
container.__abledomui = true;
|
|
789
794
|
container.className = "abledom-highlight";
|
|
795
|
+
const doc = win.document;
|
|
796
|
+
const style = doc.createElement("style");
|
|
797
|
+
style.type = "text/css";
|
|
798
|
+
style.appendChild(doc.createTextNode(highlighter_default));
|
|
799
|
+
container.appendChild(style);
|
|
790
800
|
new DOMBuilder(container).openTag("div", { class: "abledom-highlight-border1" }).closeTag().openTag("div", { class: "abledom-highlight-border2" }).closeTag();
|
|
791
801
|
win.addEventListener("scroll", this._onScroll, true);
|
|
792
802
|
}
|
|
793
|
-
highlight(element) {
|
|
803
|
+
highlight(element, scrollIntoView, autoHideTime) {
|
|
804
|
+
var _a;
|
|
805
|
+
if (this._cancelAutoHideTimer && element !== this._element) {
|
|
806
|
+
this._cancelAutoHideTimer();
|
|
807
|
+
}
|
|
794
808
|
if (!element) {
|
|
795
809
|
delete this._element;
|
|
796
810
|
this._unobserve();
|
|
@@ -803,6 +817,22 @@ var ElementHighlighter = class {
|
|
|
803
817
|
return;
|
|
804
818
|
}
|
|
805
819
|
this._element = element;
|
|
820
|
+
if (scrollIntoView) {
|
|
821
|
+
element.scrollIntoView({ block: "center" });
|
|
822
|
+
}
|
|
823
|
+
if (autoHideTime) {
|
|
824
|
+
(_a = this._cancelAutoHideTimer) == null ? void 0 : _a.call(this);
|
|
825
|
+
const autoHideTimeout = win.setTimeout(() => {
|
|
826
|
+
if (this._cancelAutoHideTimer) {
|
|
827
|
+
this.highlight(null);
|
|
828
|
+
delete this._cancelAutoHideTimer;
|
|
829
|
+
}
|
|
830
|
+
}, autoHideTime);
|
|
831
|
+
this._cancelAutoHideTimer = () => {
|
|
832
|
+
win.clearTimeout(autoHideTimeout);
|
|
833
|
+
delete this._cancelAutoHideTimer;
|
|
834
|
+
};
|
|
835
|
+
}
|
|
806
836
|
this._intersectionObserver = new IntersectionObserver(([entry]) => {
|
|
807
837
|
if (entry) {
|
|
808
838
|
const rect = entry.boundingClientRect;
|
|
@@ -821,11 +851,12 @@ var ElementHighlighter = class {
|
|
|
821
851
|
this._intersectionObserver.observe(element);
|
|
822
852
|
}
|
|
823
853
|
dispose() {
|
|
824
|
-
var _a, _b, _c;
|
|
854
|
+
var _a, _b, _c, _d;
|
|
825
855
|
this._unobserve();
|
|
826
856
|
(_a = this._cancelScrollTimer) == null ? void 0 : _a.call(this);
|
|
827
|
-
(_b = this.
|
|
828
|
-
(_c = this.
|
|
857
|
+
(_b = this._cancelAutoHideTimer) == null ? void 0 : _b.call(this);
|
|
858
|
+
(_c = this._window) == null ? void 0 : _c.removeEventListener("scroll", this._onScroll, true);
|
|
859
|
+
(_d = this._container) == null ? void 0 : _d.remove();
|
|
829
860
|
delete this._element;
|
|
830
861
|
delete this._container;
|
|
831
862
|
delete this._window;
|
|
@@ -1033,6 +1064,7 @@ function getStackTrace() {
|
|
|
1033
1064
|
var AbleDOM = class {
|
|
1034
1065
|
constructor(win, props = {}) {
|
|
1035
1066
|
__publicField(this, "_win");
|
|
1067
|
+
__publicField(this, "_isDisposed", false);
|
|
1036
1068
|
__publicField(this, "_props");
|
|
1037
1069
|
__publicField(this, "_observer");
|
|
1038
1070
|
__publicField(this, "_clearValidationTimeout");
|
|
@@ -1045,8 +1077,17 @@ var AbleDOM = class {
|
|
|
1045
1077
|
__publicField(this, "_startFunc");
|
|
1046
1078
|
__publicField(this, "_isStarted", false);
|
|
1047
1079
|
__publicField(this, "_issuesUI");
|
|
1080
|
+
__publicField(this, "_elementHighlighter");
|
|
1048
1081
|
__publicField(this, "_idlePromise");
|
|
1049
1082
|
__publicField(this, "_idleResolve");
|
|
1083
|
+
__publicField(this, "_currentAnchoredIssues", /* @__PURE__ */ new Map());
|
|
1084
|
+
__publicField(this, "_currentNotAnchoredIssues", []);
|
|
1085
|
+
__publicField(this, "_getHighlighter", () => {
|
|
1086
|
+
if (!this._elementHighlighter && !this._isDisposed) {
|
|
1087
|
+
this._elementHighlighter = new ElementHighlighter(this._win);
|
|
1088
|
+
}
|
|
1089
|
+
return this._elementHighlighter;
|
|
1090
|
+
});
|
|
1050
1091
|
__publicField(this, "_onFocusIn", (event) => {
|
|
1051
1092
|
var _a;
|
|
1052
1093
|
const target = event.target;
|
|
@@ -1214,9 +1255,9 @@ var AbleDOM = class {
|
|
|
1214
1255
|
}
|
|
1215
1256
|
}
|
|
1216
1257
|
_addIssue(rule, issue) {
|
|
1217
|
-
var _a, _b
|
|
1258
|
+
var _a, _b;
|
|
1218
1259
|
if (!this._issuesUI) {
|
|
1219
|
-
this._issuesUI = new IssuesUI(this._win, {
|
|
1260
|
+
this._issuesUI = new IssuesUI(this._win, this._getHighlighter, {
|
|
1220
1261
|
bugReport: (_a = this._props) == null ? void 0 : _a.bugReport,
|
|
1221
1262
|
headless: (_b = this._props) == null ? void 0 : _b.headless
|
|
1222
1263
|
});
|
|
@@ -1242,26 +1283,21 @@ var AbleDOM = class {
|
|
|
1242
1283
|
issueUI = new IssueUI(this._win, this, rule, this._issuesUI);
|
|
1243
1284
|
issues.set(rule, issueUI);
|
|
1244
1285
|
justUpdate = false;
|
|
1245
|
-
|
|
1286
|
+
this._onIssueAdded(element, rule, issue);
|
|
1246
1287
|
}
|
|
1247
1288
|
this._elementsWithIssues.add(element);
|
|
1248
1289
|
} else {
|
|
1249
1290
|
issueUI = new IssueUI(this._win, this, rule, this._issuesUI);
|
|
1250
1291
|
justUpdate = false;
|
|
1251
|
-
|
|
1292
|
+
this._onIssueAdded(null, rule, issue);
|
|
1252
1293
|
}
|
|
1253
1294
|
issueUI.update(issue);
|
|
1254
|
-
if (justUpdate) {
|
|
1255
|
-
|
|
1256
|
-
_j,
|
|
1257
|
-
rule.anchored && element ? element : null,
|
|
1258
|
-
rule,
|
|
1259
|
-
issue
|
|
1260
|
-
);
|
|
1295
|
+
if (justUpdate && rule.anchored && element) {
|
|
1296
|
+
this._onIssueUpdated(element, rule, issue);
|
|
1261
1297
|
}
|
|
1262
1298
|
}
|
|
1263
1299
|
_removeIssue(element, rule) {
|
|
1264
|
-
var _a
|
|
1300
|
+
var _a;
|
|
1265
1301
|
if (!rule.anchored) {
|
|
1266
1302
|
return;
|
|
1267
1303
|
}
|
|
@@ -1273,7 +1309,7 @@ var AbleDOM = class {
|
|
|
1273
1309
|
if (issue) {
|
|
1274
1310
|
issue.dispose();
|
|
1275
1311
|
issues.delete(rule);
|
|
1276
|
-
|
|
1312
|
+
this._onIssueRemoved(element, rule);
|
|
1277
1313
|
}
|
|
1278
1314
|
if (issues.size === 0) {
|
|
1279
1315
|
this._elementsWithIssues.delete(element);
|
|
@@ -1359,6 +1395,42 @@ var AbleDOM = class {
|
|
|
1359
1395
|
this._dependantIdsByElement.set(element, dependsOnIds);
|
|
1360
1396
|
}
|
|
1361
1397
|
}
|
|
1398
|
+
_updateCurrentAnchoredIssues(element, rule, issue) {
|
|
1399
|
+
let issuesByElement = this._currentAnchoredIssues.get(element);
|
|
1400
|
+
if (!issuesByElement && issue) {
|
|
1401
|
+
issuesByElement = /* @__PURE__ */ new Map();
|
|
1402
|
+
this._currentAnchoredIssues.set(element, issuesByElement);
|
|
1403
|
+
}
|
|
1404
|
+
if (issuesByElement) {
|
|
1405
|
+
if (issue) {
|
|
1406
|
+
issuesByElement.set(rule, issue);
|
|
1407
|
+
} else {
|
|
1408
|
+
issuesByElement.delete(rule);
|
|
1409
|
+
if (issuesByElement.size === 0) {
|
|
1410
|
+
this._currentAnchoredIssues.delete(element);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
_onIssueAdded(element, rule, issue) {
|
|
1416
|
+
var _a, _b, _c;
|
|
1417
|
+
if (element) {
|
|
1418
|
+
this._updateCurrentAnchoredIssues(element, rule, issue);
|
|
1419
|
+
} else {
|
|
1420
|
+
this._currentNotAnchoredIssues.push(issue);
|
|
1421
|
+
}
|
|
1422
|
+
(_c = (_b = (_a = this._props) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onIssueAdded) == null ? void 0 : _c.call(_b, element, rule, issue);
|
|
1423
|
+
}
|
|
1424
|
+
_onIssueUpdated(element, rule, issue) {
|
|
1425
|
+
var _a, _b, _c;
|
|
1426
|
+
this._updateCurrentAnchoredIssues(element, rule, issue);
|
|
1427
|
+
(_c = (_b = (_a = this._props) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onIssueUpdated) == null ? void 0 : _c.call(_b, element, rule, issue);
|
|
1428
|
+
}
|
|
1429
|
+
_onIssueRemoved(element, rule) {
|
|
1430
|
+
var _a, _b, _c;
|
|
1431
|
+
this._updateCurrentAnchoredIssues(element, rule, null);
|
|
1432
|
+
(_c = (_b = (_a = this._props) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onIssueRemoved) == null ? void 0 : _c.call(_b, element, rule);
|
|
1433
|
+
}
|
|
1362
1434
|
_remove(elements) {
|
|
1363
1435
|
elements.forEach((element) => {
|
|
1364
1436
|
var _a, _b;
|
|
@@ -1366,21 +1438,42 @@ var AbleDOM = class {
|
|
|
1366
1438
|
rules.forEach((rule) => this._removeIssue(element, rule));
|
|
1367
1439
|
});
|
|
1368
1440
|
}
|
|
1441
|
+
_getCurrentIssues() {
|
|
1442
|
+
const issues = this._currentNotAnchoredIssues.slice(0);
|
|
1443
|
+
this._currentAnchoredIssues.forEach((issueByRule) => {
|
|
1444
|
+
issueByRule.forEach((issue) => {
|
|
1445
|
+
issues.push(issue);
|
|
1446
|
+
});
|
|
1447
|
+
});
|
|
1448
|
+
return issues;
|
|
1449
|
+
}
|
|
1369
1450
|
idle() {
|
|
1370
1451
|
if (!this._clearValidationTimeout) {
|
|
1371
|
-
return Promise.resolve();
|
|
1452
|
+
return Promise.resolve(this._getCurrentIssues());
|
|
1372
1453
|
}
|
|
1373
1454
|
if (!this._idlePromise) {
|
|
1374
1455
|
this._idlePromise = new Promise((resolve) => {
|
|
1375
1456
|
this._idleResolve = () => {
|
|
1376
1457
|
delete this._idlePromise;
|
|
1377
1458
|
delete this._idleResolve;
|
|
1378
|
-
resolve();
|
|
1459
|
+
resolve(this._getCurrentIssues());
|
|
1379
1460
|
};
|
|
1380
1461
|
});
|
|
1381
1462
|
}
|
|
1382
1463
|
return this._idlePromise;
|
|
1383
1464
|
}
|
|
1465
|
+
clearCurrentIssues(anchored = true, notAnchored = true) {
|
|
1466
|
+
if (anchored) {
|
|
1467
|
+
this._currentAnchoredIssues.clear();
|
|
1468
|
+
}
|
|
1469
|
+
if (notAnchored) {
|
|
1470
|
+
this._currentNotAnchoredIssues = [];
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
highlightElement(element, scrollIntoView, autoHideTime) {
|
|
1474
|
+
var _a;
|
|
1475
|
+
(_a = this._getHighlighter()) == null ? void 0 : _a.highlight(element, scrollIntoView, autoHideTime);
|
|
1476
|
+
}
|
|
1384
1477
|
addRule(rule) {
|
|
1385
1478
|
this._rules.push(rule);
|
|
1386
1479
|
}
|
|
@@ -1407,6 +1500,7 @@ var AbleDOM = class {
|
|
|
1407
1500
|
}
|
|
1408
1501
|
dispose() {
|
|
1409
1502
|
var _a, _b, _c, _d;
|
|
1503
|
+
this._isDisposed = true;
|
|
1410
1504
|
const doc = this._win.document;
|
|
1411
1505
|
doc.addEventListener("focusin", this._onFocusIn, true);
|
|
1412
1506
|
doc.addEventListener("focusout", this._onFocusOut, true);
|
|
@@ -1415,6 +1509,7 @@ var AbleDOM = class {
|
|
|
1415
1509
|
this._dependantIdsByElement.clear();
|
|
1416
1510
|
this._elementsDependingOnId.clear();
|
|
1417
1511
|
this._idByElement.clear();
|
|
1512
|
+
this.clearCurrentIssues();
|
|
1418
1513
|
(_a = this._issuesUI) == null ? void 0 : _a.dispose();
|
|
1419
1514
|
delete this._issuesUI;
|
|
1420
1515
|
(_b = this._clearValidationTimeout) == null ? void 0 : _b.call(this);
|