@teselagen/ui 0.8.4 → 0.8.6-beta.10

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.
@@ -17,125 +17,14 @@ 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 = [];
21
+
121
22
  let recentlyHidden = false;
122
23
  let clearMe;
123
24
  (function () {
124
25
  let lastMouseOverElement = null;
125
26
  document.addEventListener("mouseover", function (event) {
126
- let element = event.target;
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
- }
27
+ const element = event.target;
139
28
 
140
29
  if (element instanceof Element && element !== lastMouseOverElement) {
141
30
  lastMouseOverElement = element;
@@ -218,7 +107,7 @@ let clearMe;
218
107
 
219
108
  if (!customBoundary) return;
220
109
  const a = customBoundary.getBoundingClientRect();
221
-
110
+
222
111
  if (a.top < state.rects.reference.y) {
223
112
  const b = Math.abs(
224
113
  Math.abs(a.top - state.rects.reference.y) - 10
@@ -312,4 +201,4 @@ function parentIncludesNoChildDataTip(el, count) {
312
201
  }
313
202
 
314
203
  // Export the function to clear parent tooltips so it can be used elsewhere
315
- export { clearParentTooltips };
204
+ // export { clearParentTooltips };
package/src/index.js CHANGED
@@ -41,6 +41,7 @@ export { default as popoverOverflowModifiers } from "./utils/popoverOverflowModi
41
41
  export * from "./utils/tgFormValues";
42
42
  export { default as tgFormValues } from "./utils/tgFormValues";
43
43
  export { default as withStore } from "./utils/withStore";
44
+ export { default as determineBlackOrWhiteTextColor } from "./utils/determineBlackOrWhiteTextColor";
44
45
  export {
45
46
  default as withTableParams,
46
47
  useTableParams
@@ -85,3 +86,4 @@ const noop = () => undefined;
85
86
  export { noop };
86
87
  export { default as showDialogOnDocBody } from "./showDialogOnDocBody";
87
88
  export { default as TableFormTrackerContext } from "./DataTable/TableFormTrackerContext";
89
+ export { initializeHasuraWhereAndFilter } from "./DataTable/utils/initializeHasuraWhereAndFilter";
@@ -1,4 +1,11 @@
1
1
  /* Copyright (C) 2018 TeselaGen Biotechnology, Inc. */
2
2
  import Color from "color";
3
3
 
4
- export default c => (Color(c).isLight() ? "#000000" : "#FFFFFF");
4
+ export default function determineBlackOrWhiteTextColor(c) {
5
+ try {
6
+ return Color(c).isLight() ? "#000000" : "#FFFFFF";
7
+ } catch (e) {
8
+ console.error("Error in color parsing:", e);
9
+ return "#000000"; // Fallback to black if color parsing fails
10
+ }
11
+ }
package/ui.css CHANGED
@@ -9676,7 +9676,7 @@ body:not(.drag-active)
9676
9676
  display: flex;
9677
9677
  flex-wrap: wrap;
9678
9678
  align-items: center;
9679
- margin-top: 20px;
9679
+ margin-top: 10px;
9680
9680
  }
9681
9681
 
9682
9682
  .ReactTable {
@@ -1,2 +1 @@
1
- declare function _default(c: any): "#000000" | "#FFFFFF";
2
- export default _default;
1
+ export default function determineBlackOrWhiteTextColor(c: any): "#000000" | "#FFFFFF";