@teselagen/ui 0.8.4 → 0.8.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/autoTooltip.d.ts +1 -1
- package/index.cjs.js +1 -78
- package/index.es.js +1 -78
- package/package.json +1 -1
- package/src/autoTooltip.js +3 -115
package/autoTooltip.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
package/index.cjs.js
CHANGED
|
@@ -2922,77 +2922,6 @@ document.addEventListener("mouseup", () => {
|
|
|
2922
2922
|
canSetDragging = false;
|
|
2923
2923
|
isDragging = false;
|
|
2924
2924
|
});
|
|
2925
|
-
const processedDisabledElements = /* @__PURE__ */ new WeakMap();
|
|
2926
|
-
function moveTooltipToParent(element2) {
|
|
2927
|
-
var _a, _b;
|
|
2928
|
-
if (processedDisabledElements.has(element2)) {
|
|
2929
|
-
return;
|
|
2930
|
-
}
|
|
2931
|
-
const isDisabled = element2.disabled === true || element2.getAttribute("disabled") !== null;
|
|
2932
|
-
const hasTipData = element2.getAttribute("data-tip") || element2.getAttribute("data-title") || element2.offsetWidth < element2.scrollWidth && ((_a = element2.textContent) == null ? void 0 : _a.trim().length) > 0;
|
|
2933
|
-
if (!isDisabled || !hasTipData) {
|
|
2934
|
-
return;
|
|
2935
|
-
}
|
|
2936
|
-
const parent2 = element2.parentElement;
|
|
2937
|
-
if (!parent2) {
|
|
2938
|
-
return;
|
|
2939
|
-
}
|
|
2940
|
-
const tooltipAttrs = ["data-tip", "data-title", "data-avoid", "data-avoid-backup"];
|
|
2941
|
-
let attrsMoved = false;
|
|
2942
|
-
const movedAttrs = [];
|
|
2943
|
-
tooltipAttrs.forEach((attr) => {
|
|
2944
|
-
const value = element2.getAttribute(attr);
|
|
2945
|
-
if (value) {
|
|
2946
|
-
if (!parent2.hasAttribute(attr)) {
|
|
2947
|
-
parent2.setAttribute(attr, value);
|
|
2948
|
-
movedAttrs.push(attr);
|
|
2949
|
-
attrsMoved = true;
|
|
2950
|
-
}
|
|
2951
|
-
}
|
|
2952
|
-
});
|
|
2953
|
-
if (element2.offsetWidth < element2.scrollWidth && ((_b = element2.textContent) == null ? void 0 : _b.trim().length) > 0) {
|
|
2954
|
-
if (!parent2.hasAttribute("data-tip")) {
|
|
2955
|
-
parent2.setAttribute("data-tip", element2.textContent);
|
|
2956
|
-
movedAttrs.push("data-tip");
|
|
2957
|
-
attrsMoved = true;
|
|
2958
|
-
}
|
|
2959
|
-
}
|
|
2960
|
-
if (attrsMoved) {
|
|
2961
|
-
processedDisabledElements.set(element2, {
|
|
2962
|
-
parent: parent2,
|
|
2963
|
-
movedAttrs
|
|
2964
|
-
});
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
__name(moveTooltipToParent, "moveTooltipToParent");
|
|
2968
|
-
function clearParentTooltips(element2) {
|
|
2969
|
-
if (!processedDisabledElements.has(element2)) {
|
|
2970
|
-
return;
|
|
2971
|
-
}
|
|
2972
|
-
const { parent: parent2, movedAttrs } = processedDisabledElements.get(element2);
|
|
2973
|
-
if (parent2 && movedAttrs) {
|
|
2974
|
-
movedAttrs.forEach((attr) => {
|
|
2975
|
-
parent2.removeAttribute(attr);
|
|
2976
|
-
});
|
|
2977
|
-
processedDisabledElements.delete(element2);
|
|
2978
|
-
}
|
|
2979
|
-
}
|
|
2980
|
-
__name(clearParentTooltips, "clearParentTooltips");
|
|
2981
|
-
function scanForDisabledElements() {
|
|
2982
|
-
processedDisabledElements.forEach((value, element2) => {
|
|
2983
|
-
const isStillDisabled = element2.disabled === true || element2.getAttribute("disabled") !== null;
|
|
2984
|
-
const isConnected = element2.isConnected;
|
|
2985
|
-
if (!isStillDisabled || !isConnected) {
|
|
2986
|
-
clearParentTooltips(element2);
|
|
2987
|
-
}
|
|
2988
|
-
});
|
|
2989
|
-
document.querySelectorAll("[disabled][data-tip], [disabled][data-title], button[disabled], input[disabled]").forEach((el) => {
|
|
2990
|
-
moveTooltipToParent(el);
|
|
2991
|
-
});
|
|
2992
|
-
}
|
|
2993
|
-
__name(scanForDisabledElements, "scanForDisabledElements");
|
|
2994
|
-
window.addEventListener("DOMContentLoaded", scanForDisabledElements);
|
|
2995
|
-
setInterval(scanForDisabledElements, 2e3);
|
|
2996
2925
|
let tippys = [];
|
|
2997
2926
|
let recentlyHidden = false;
|
|
2998
2927
|
let clearMe;
|
|
@@ -3000,13 +2929,7 @@ let clearMe;
|
|
|
3000
2929
|
let lastMouseOverElement = null;
|
|
3001
2930
|
document.addEventListener("mouseover", function(event) {
|
|
3002
2931
|
var _a, _b;
|
|
3003
|
-
|
|
3004
|
-
if (element2 instanceof Element && (element2.disabled === true || element2.getAttribute("disabled") !== null)) {
|
|
3005
|
-
const parent2 = element2.parentElement;
|
|
3006
|
-
if (parent2 && processedDisabledElements.has(element2)) {
|
|
3007
|
-
element2 = parent2;
|
|
3008
|
-
}
|
|
3009
|
-
}
|
|
2932
|
+
const element2 = event.target;
|
|
3010
2933
|
if (element2 instanceof Element && element2 !== lastMouseOverElement) {
|
|
3011
2934
|
let clearOldTippys = /* @__PURE__ */ __name(function(maybeInst) {
|
|
3012
2935
|
tippys = tippys.filter((t2) => {
|
package/index.es.js
CHANGED
|
@@ -2904,77 +2904,6 @@ document.addEventListener("mouseup", () => {
|
|
|
2904
2904
|
canSetDragging = false;
|
|
2905
2905
|
isDragging = false;
|
|
2906
2906
|
});
|
|
2907
|
-
const processedDisabledElements = /* @__PURE__ */ new WeakMap();
|
|
2908
|
-
function moveTooltipToParent(element2) {
|
|
2909
|
-
var _a, _b;
|
|
2910
|
-
if (processedDisabledElements.has(element2)) {
|
|
2911
|
-
return;
|
|
2912
|
-
}
|
|
2913
|
-
const isDisabled = element2.disabled === true || element2.getAttribute("disabled") !== null;
|
|
2914
|
-
const hasTipData = element2.getAttribute("data-tip") || element2.getAttribute("data-title") || element2.offsetWidth < element2.scrollWidth && ((_a = element2.textContent) == null ? void 0 : _a.trim().length) > 0;
|
|
2915
|
-
if (!isDisabled || !hasTipData) {
|
|
2916
|
-
return;
|
|
2917
|
-
}
|
|
2918
|
-
const parent2 = element2.parentElement;
|
|
2919
|
-
if (!parent2) {
|
|
2920
|
-
return;
|
|
2921
|
-
}
|
|
2922
|
-
const tooltipAttrs = ["data-tip", "data-title", "data-avoid", "data-avoid-backup"];
|
|
2923
|
-
let attrsMoved = false;
|
|
2924
|
-
const movedAttrs = [];
|
|
2925
|
-
tooltipAttrs.forEach((attr) => {
|
|
2926
|
-
const value = element2.getAttribute(attr);
|
|
2927
|
-
if (value) {
|
|
2928
|
-
if (!parent2.hasAttribute(attr)) {
|
|
2929
|
-
parent2.setAttribute(attr, value);
|
|
2930
|
-
movedAttrs.push(attr);
|
|
2931
|
-
attrsMoved = true;
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
|
-
});
|
|
2935
|
-
if (element2.offsetWidth < element2.scrollWidth && ((_b = element2.textContent) == null ? void 0 : _b.trim().length) > 0) {
|
|
2936
|
-
if (!parent2.hasAttribute("data-tip")) {
|
|
2937
|
-
parent2.setAttribute("data-tip", element2.textContent);
|
|
2938
|
-
movedAttrs.push("data-tip");
|
|
2939
|
-
attrsMoved = true;
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
if (attrsMoved) {
|
|
2943
|
-
processedDisabledElements.set(element2, {
|
|
2944
|
-
parent: parent2,
|
|
2945
|
-
movedAttrs
|
|
2946
|
-
});
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
__name(moveTooltipToParent, "moveTooltipToParent");
|
|
2950
|
-
function clearParentTooltips(element2) {
|
|
2951
|
-
if (!processedDisabledElements.has(element2)) {
|
|
2952
|
-
return;
|
|
2953
|
-
}
|
|
2954
|
-
const { parent: parent2, movedAttrs } = processedDisabledElements.get(element2);
|
|
2955
|
-
if (parent2 && movedAttrs) {
|
|
2956
|
-
movedAttrs.forEach((attr) => {
|
|
2957
|
-
parent2.removeAttribute(attr);
|
|
2958
|
-
});
|
|
2959
|
-
processedDisabledElements.delete(element2);
|
|
2960
|
-
}
|
|
2961
|
-
}
|
|
2962
|
-
__name(clearParentTooltips, "clearParentTooltips");
|
|
2963
|
-
function scanForDisabledElements() {
|
|
2964
|
-
processedDisabledElements.forEach((value, element2) => {
|
|
2965
|
-
const isStillDisabled = element2.disabled === true || element2.getAttribute("disabled") !== null;
|
|
2966
|
-
const isConnected = element2.isConnected;
|
|
2967
|
-
if (!isStillDisabled || !isConnected) {
|
|
2968
|
-
clearParentTooltips(element2);
|
|
2969
|
-
}
|
|
2970
|
-
});
|
|
2971
|
-
document.querySelectorAll("[disabled][data-tip], [disabled][data-title], button[disabled], input[disabled]").forEach((el) => {
|
|
2972
|
-
moveTooltipToParent(el);
|
|
2973
|
-
});
|
|
2974
|
-
}
|
|
2975
|
-
__name(scanForDisabledElements, "scanForDisabledElements");
|
|
2976
|
-
window.addEventListener("DOMContentLoaded", scanForDisabledElements);
|
|
2977
|
-
setInterval(scanForDisabledElements, 2e3);
|
|
2978
2907
|
let tippys = [];
|
|
2979
2908
|
let recentlyHidden = false;
|
|
2980
2909
|
let clearMe;
|
|
@@ -2982,13 +2911,7 @@ let clearMe;
|
|
|
2982
2911
|
let lastMouseOverElement = null;
|
|
2983
2912
|
document.addEventListener("mouseover", function(event) {
|
|
2984
2913
|
var _a, _b;
|
|
2985
|
-
|
|
2986
|
-
if (element2 instanceof Element && (element2.disabled === true || element2.getAttribute("disabled") !== null)) {
|
|
2987
|
-
const parent2 = element2.parentElement;
|
|
2988
|
-
if (parent2 && processedDisabledElements.has(element2)) {
|
|
2989
|
-
element2 = parent2;
|
|
2990
|
-
}
|
|
2991
|
-
}
|
|
2914
|
+
const element2 = event.target;
|
|
2992
2915
|
if (element2 instanceof Element && element2 !== lastMouseOverElement) {
|
|
2993
2916
|
let clearOldTippys = /* @__PURE__ */ __name(function(maybeInst) {
|
|
2994
2917
|
tippys = tippys.filter((t2) => {
|
package/package.json
CHANGED
package/src/autoTooltip.js
CHANGED
|
@@ -17,125 +17,13 @@ document.addEventListener("mouseup", () => {
|
|
|
17
17
|
isDragging = false;
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
// Track elements that had their tooltip attributes moved to parent
|
|
21
|
-
const processedDisabledElements = new WeakMap();
|
|
22
|
-
|
|
23
|
-
// Move tooltip attributes from disabled elements to their parent
|
|
24
|
-
function moveTooltipToParent(element) {
|
|
25
|
-
// Check if element already processed
|
|
26
|
-
if (processedDisabledElements.has(element)) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Check if the element is disabled and has tooltip attributes
|
|
31
|
-
const isDisabled = element.disabled === true || element.getAttribute("disabled") !== null;
|
|
32
|
-
const hasTipData = element.getAttribute("data-tip") ||
|
|
33
|
-
element.getAttribute("data-title") ||
|
|
34
|
-
(element.offsetWidth < element.scrollWidth && element.textContent?.trim().length > 0);
|
|
35
|
-
|
|
36
|
-
if (!isDisabled || !hasTipData) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const parent = element.parentElement;
|
|
41
|
-
if (!parent) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Copy tooltip-relevant attributes to the parent
|
|
46
|
-
const tooltipAttrs = ["data-tip", "data-title", "data-avoid", "data-avoid-backup"];
|
|
47
|
-
let attrsMoved = false;
|
|
48
|
-
const movedAttrs = []; // Track which attributes were moved
|
|
49
|
-
|
|
50
|
-
tooltipAttrs.forEach(attr => {
|
|
51
|
-
const value = element.getAttribute(attr);
|
|
52
|
-
if (value) {
|
|
53
|
-
// Add a data attribute to the parent only if it doesn't already have one
|
|
54
|
-
if (!parent.hasAttribute(attr)) {
|
|
55
|
-
parent.setAttribute(attr, value);
|
|
56
|
-
movedAttrs.push(attr); // Record this attribute was moved
|
|
57
|
-
attrsMoved = true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// If element is ellipsized, add its text content as a data-tip to parent
|
|
63
|
-
if (element.offsetWidth < element.scrollWidth && element.textContent?.trim().length > 0) {
|
|
64
|
-
if (!parent.hasAttribute("data-tip")) {
|
|
65
|
-
parent.setAttribute("data-tip", element.textContent);
|
|
66
|
-
movedAttrs.push("data-tip"); // Record this attribute was moved
|
|
67
|
-
attrsMoved = true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Store information about moved attributes
|
|
72
|
-
if (attrsMoved) {
|
|
73
|
-
processedDisabledElements.set(element, {
|
|
74
|
-
parent,
|
|
75
|
-
movedAttrs
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Function to clear tooltips from parent elements
|
|
81
|
-
function clearParentTooltips(element) {
|
|
82
|
-
if (!processedDisabledElements.has(element)) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const { parent, movedAttrs } = processedDisabledElements.get(element);
|
|
87
|
-
if (parent && movedAttrs) {
|
|
88
|
-
// Remove all attributes that were added to the parent
|
|
89
|
-
movedAttrs.forEach(attr => {
|
|
90
|
-
parent.removeAttribute(attr);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Remove the element from our tracking map
|
|
94
|
-
processedDisabledElements.delete(element);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Function to scan for and process disabled elements
|
|
99
|
-
function scanForDisabledElements() {
|
|
100
|
-
// First, check if any previously disabled elements are now enabled and clear their parent tooltips
|
|
101
|
-
processedDisabledElements.forEach((value, element) => {
|
|
102
|
-
const isStillDisabled = element.disabled === true || element.getAttribute("disabled") !== null;
|
|
103
|
-
const isConnected = element.isConnected;
|
|
104
|
-
|
|
105
|
-
if (!isStillDisabled || !isConnected) {
|
|
106
|
-
clearParentTooltips(element);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Then process currently disabled elements
|
|
111
|
-
document.querySelectorAll("[disabled][data-tip], [disabled][data-title], button[disabled], input[disabled]").forEach(el => {
|
|
112
|
-
moveTooltipToParent(el);
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Initialize on load and periodically check for new disabled elements
|
|
117
|
-
window.addEventListener('DOMContentLoaded', scanForDisabledElements);
|
|
118
|
-
setInterval(scanForDisabledElements, 2000);
|
|
119
|
-
|
|
120
20
|
let tippys = [];
|
|
121
21
|
let recentlyHidden = false;
|
|
122
22
|
let clearMe;
|
|
123
23
|
(function () {
|
|
124
24
|
let lastMouseOverElement = null;
|
|
125
25
|
document.addEventListener("mouseover", function (event) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// Special handling for disabled elements - we need to process their parent
|
|
129
|
-
if (element instanceof Element &&
|
|
130
|
-
(element.disabled === true || element.getAttribute("disabled") !== null)) {
|
|
131
|
-
// If this is a disabled element, we want to also process its parent
|
|
132
|
-
// since that's where we moved the tooltip attributes
|
|
133
|
-
const parent = element.parentElement;
|
|
134
|
-
if (parent && processedDisabledElements.has(element)) {
|
|
135
|
-
// Only process the parent if we've previously moved attributes to it
|
|
136
|
-
element = parent;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
26
|
+
const element = event.target;
|
|
139
27
|
|
|
140
28
|
if (element instanceof Element && element !== lastMouseOverElement) {
|
|
141
29
|
lastMouseOverElement = element;
|
|
@@ -218,7 +106,7 @@ let clearMe;
|
|
|
218
106
|
|
|
219
107
|
if (!customBoundary) return;
|
|
220
108
|
const a = customBoundary.getBoundingClientRect();
|
|
221
|
-
|
|
109
|
+
|
|
222
110
|
if (a.top < state.rects.reference.y) {
|
|
223
111
|
const b = Math.abs(
|
|
224
112
|
Math.abs(a.top - state.rects.reference.y) - 10
|
|
@@ -312,4 +200,4 @@ function parentIncludesNoChildDataTip(el, count) {
|
|
|
312
200
|
}
|
|
313
201
|
|
|
314
202
|
// Export the function to clear parent tooltips so it can be used elsewhere
|
|
315
|
-
export { clearParentTooltips };
|
|
203
|
+
// export { clearParentTooltips };
|