@teselagen/ui 0.8.3 → 0.8.4

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 CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export function clearParentTooltips(element: any): void;
package/index.cjs.js CHANGED
@@ -2922,6 +2922,77 @@ 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);
2925
2996
  let tippys = [];
2926
2997
  let recentlyHidden = false;
2927
2998
  let clearMe;
@@ -2929,7 +3000,13 @@ let clearMe;
2929
3000
  let lastMouseOverElement = null;
2930
3001
  document.addEventListener("mouseover", function(event) {
2931
3002
  var _a, _b;
2932
- const element2 = event.target;
3003
+ let element2 = event.target;
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
+ }
2933
3010
  if (element2 instanceof Element && element2 !== lastMouseOverElement) {
2934
3011
  let clearOldTippys = /* @__PURE__ */ __name(function(maybeInst) {
2935
3012
  tippys = tippys.filter((t2) => {
@@ -2951,7 +3028,18 @@ let clearMe;
2951
3028
  document.querySelectorAll(`.${id}`).forEach((elem) => {
2952
3029
  elem.classList.remove(id);
2953
3030
  });
2954
- el2.classList.add(id);
3031
+ let targetEl = el2;
3032
+ if (targetEl.disabled || targetEl.getAttribute("disabled") !== null) {
3033
+ const parent2 = targetEl.parentElement;
3034
+ if (parent2) {
3035
+ parent2.classList.add(id);
3036
+ targetEl = parent2;
3037
+ } else {
3038
+ el2.classList.add(id);
3039
+ }
3040
+ } else {
3041
+ el2.classList.add(id);
3042
+ }
2955
3043
  const inst = tippy(`.${id}`, __spreadValues(__spreadProps(__spreadValues({
2956
3044
  theme: "teselagen",
2957
3045
  plugins: [followCursor],
package/index.es.js CHANGED
@@ -2904,6 +2904,77 @@ 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);
2907
2978
  let tippys = [];
2908
2979
  let recentlyHidden = false;
2909
2980
  let clearMe;
@@ -2911,7 +2982,13 @@ let clearMe;
2911
2982
  let lastMouseOverElement = null;
2912
2983
  document.addEventListener("mouseover", function(event) {
2913
2984
  var _a, _b;
2914
- const element2 = event.target;
2985
+ let element2 = event.target;
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
+ }
2915
2992
  if (element2 instanceof Element && element2 !== lastMouseOverElement) {
2916
2993
  let clearOldTippys = /* @__PURE__ */ __name(function(maybeInst) {
2917
2994
  tippys = tippys.filter((t2) => {
@@ -2933,7 +3010,18 @@ let clearMe;
2933
3010
  document.querySelectorAll(`.${id}`).forEach((elem) => {
2934
3011
  elem.classList.remove(id);
2935
3012
  });
2936
- el2.classList.add(id);
3013
+ let targetEl = el2;
3014
+ if (targetEl.disabled || targetEl.getAttribute("disabled") !== null) {
3015
+ const parent2 = targetEl.parentElement;
3016
+ if (parent2) {
3017
+ parent2.classList.add(id);
3018
+ targetEl = parent2;
3019
+ } else {
3020
+ el2.classList.add(id);
3021
+ }
3022
+ } else {
3023
+ el2.classList.add(id);
3024
+ }
2937
3025
  const inst = tippy(`.${id}`, __spreadValues(__spreadProps(__spreadValues({
2938
3026
  theme: "teselagen",
2939
3027
  plugins: [followCursor],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "main": "./src/index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,13 +17,125 @@ 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
+
20
120
  let tippys = [];
21
121
  let recentlyHidden = false;
22
122
  let clearMe;
23
123
  (function () {
24
124
  let lastMouseOverElement = null;
25
125
  document.addEventListener("mouseover", function (event) {
26
- const element = event.target;
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
139
 
28
140
  if (element instanceof Element && element !== lastMouseOverElement) {
29
141
  lastMouseOverElement = element;
@@ -52,7 +164,23 @@ let clearMe;
52
164
  elem.classList.remove(id);
53
165
  });
54
166
 
55
- el.classList.add(id);
167
+ // Check if element is disabled, if so use parent instead
168
+ let targetEl = el;
169
+ if (targetEl.disabled || targetEl.getAttribute("disabled") !== null) {
170
+ const parent = targetEl.parentElement;
171
+ if (parent) {
172
+ // Use the parent as the tooltip target
173
+ parent.classList.add(id);
174
+ targetEl = parent; // Change the tooltip target to parent
175
+ } else {
176
+ // No parent, keep using the original element
177
+ el.classList.add(id);
178
+ }
179
+ } else {
180
+ // Element not disabled, use it directly
181
+ el.classList.add(id);
182
+ }
183
+
56
184
  const inst = tippy(`.${id}`, {
57
185
  theme: "teselagen",
58
186
  plugins: [followCursor],
@@ -84,36 +212,19 @@ let clearMe;
84
212
  requires: ["computeStyles"],
85
213
  requiresIfExists: ["offset"],
86
214
  fn({ state }) {
87
- // console.log(`state:`, state);
88
- // state.styles.popper.bottom = 20 + "px";
89
215
  const customBoundary =
90
216
  document.querySelector(dataAvoid) ||
91
217
  document.querySelector(dataAvoidBackup);
92
218
 
93
219
  if (!customBoundary) return;
94
220
  const a = customBoundary.getBoundingClientRect();
95
- // console.log(
96
- // `state.rects.reference.y:`,
97
- // state.rects.reference.y
98
- // );
99
- // console.log(`a.top:`, a.top);
100
-
221
+
101
222
  if (a.top < state.rects.reference.y) {
102
223
  const b = Math.abs(
103
224
  Math.abs(a.top - state.rects.reference.y) - 10
104
225
  );
105
226
  state.styles.popper.bottom = b + "px";
106
227
  }
107
-
108
- // const overflow = detectOverflow(state, {
109
- // boundary: customBoundary,
110
- // altBoundary: true
111
- // });
112
- // console.log(`overflow:`, overflow);
113
- // if (overflow.bottom > 0) {
114
- // const a = Math.abs(overflow.bottom);
115
- // state.styles.popper.bottom = a + "px";
116
- // }
117
228
  }
118
229
  }
119
230
  ]
@@ -199,3 +310,6 @@ function parentIncludesNoChildDataTip(el, count) {
199
310
  if (el.getAttribute("data-no-child-data-tip")) return true;
200
311
  return parentIncludesNoChildDataTip(el.parentElement, count + 1);
201
312
  }
313
+
314
+ // Export the function to clear parent tooltips so it can be used elsewhere
315
+ export { clearParentTooltips };
@@ -1,7 +0,0 @@
1
- export function EditableCell({ cancelEdit, dataTest, finishEdit, isNumeric, initialValue }: {
2
- cancelEdit: any;
3
- dataTest: any;
4
- finishEdit: any;
5
- isNumeric: any;
6
- initialValue: any;
7
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,43 +0,0 @@
1
- import { noop } from 'lodash-es';
2
- declare namespace _default {
3
- export { noop as addFilters };
4
- export let className: string;
5
- export { noop as clearFilters };
6
- export { noop as contextMenu };
7
- export let disabled: boolean;
8
- export let entities: never[];
9
- export let extraClasses: string;
10
- export let filters: never[];
11
- export let isCopyable: boolean;
12
- export { noop as isEntityDisabled };
13
- export let isLoading: boolean;
14
- export let isSimple: boolean;
15
- export let isSingleSelect: boolean;
16
- export let maxHeight: number;
17
- export let noHeader: boolean;
18
- export let noSelect: boolean;
19
- export let noUserSelect: boolean;
20
- export { noop as onDeselect };
21
- export { noop as onMultiRowSelect };
22
- export { noop as onRowClick };
23
- export { noop as onRowSelect };
24
- export { noop as onSingleRowSelect };
25
- export let page: number;
26
- export let pageSize: number;
27
- export let reduxFormExpandedEntityIdMap: {};
28
- export let reduxFormSearchInput: string;
29
- export let reduxFormSelectedEntityIdMap: {};
30
- export { noop as removeSingleFilter };
31
- export let resized: never[];
32
- export { noop as resizePersist };
33
- export { noop as setFilter };
34
- export { noop as setOrder };
35
- export { noop as setPage };
36
- export { noop as setPageSize };
37
- export { noop as setSearchTerm };
38
- export let showCount: boolean;
39
- export let style: {};
40
- export let withCheckboxes: boolean;
41
- export let withSort: boolean;
42
- }
43
- export default _default;
@@ -1 +0,0 @@
1
- export default function computePresets(props?: {}): import('lodash').Dictionary<any>;
@@ -1 +0,0 @@
1
- export function useDeepEqualMemo(value: any): undefined;
@@ -1,49 +0,0 @@
1
- /**
2
- * Note all these options can be passed at Design Time or at Runtime (like reduxForm())
3
- *
4
- * @export
5
- *
6
- * @param {compOrOpts} compOrOpts
7
- * @typedef {object} compOrOpts
8
- * @property {*string} formName - required unique identifier for the table
9
- * @property {Object | Function} schema - The data table schema or a function returning it. The function wll be called with props as the argument.
10
- * @property {boolean} urlConnected - whether the table should connect to/update the URL
11
- * @property {boolean} withSelectedEntities - whether or not to pass the selected entities
12
- * @property {boolean} isCodeModel - whether the model is keyed by code instead of id in the db
13
- * @property {object} defaults - tableParam defaults such as pageSize, filter, etc
14
- * @property {boolean} noOrderError - won't console an error if an order is not found on schema
15
- */
16
- export default function useTableParams(props: any): any;
17
- /**
18
- * Note all these options can be passed at Design Time or at Runtime (like reduxForm())
19
- */
20
- export type compOrOpts = {
21
- /**
22
- * } formName - required unique identifier for the table
23
- */
24
- string: any;
25
- /**
26
- * - The data table schema or a function returning it. The function wll be called with props as the argument.
27
- */
28
- schema: Object | Function;
29
- /**
30
- * - whether the table should connect to/update the URL
31
- */
32
- urlConnected: boolean;
33
- /**
34
- * - whether or not to pass the selected entities
35
- */
36
- withSelectedEntities: boolean;
37
- /**
38
- * - whether the model is keyed by code instead of id in the db
39
- */
40
- isCodeModel: boolean;
41
- /**
42
- * - tableParam defaults such as pageSize, filter, etc
43
- */
44
- defaults: object;
45
- /**
46
- * - won't console an error if an order is not found on schema
47
- */
48
- noOrderError: boolean;
49
- };