@teselagen/ui 0.3.26 → 0.3.28
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/index.cjs.js +512 -298
- package/index.es.js +512 -298
- package/package.json +1 -1
- package/src/DataTable/index.js +15 -4
- package/src/autoTooltip.js +92 -11
- package/src/style.css +12 -0
- package/style.css +12 -0
package/package.json
CHANGED
package/src/DataTable/index.js
CHANGED
|
@@ -1382,13 +1382,24 @@ class DataTable extends React.Component {
|
|
|
1382
1382
|
{...(isCellEditable && {
|
|
1383
1383
|
tabIndex: -1,
|
|
1384
1384
|
onKeyDown: e => {
|
|
1385
|
-
const isArrowKey =
|
|
1386
|
-
|
|
1387
|
-
if (isArrowKey && e.target?.tagName !== "INPUT") {
|
|
1385
|
+
// const isArrowKey =
|
|
1386
|
+
// (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode === 9;
|
|
1387
|
+
// if (isArrowKey && e.target?.tagName !== "INPUT") {
|
|
1388
|
+
const isTabKey = e.keyCode === 9;
|
|
1389
|
+
// const isEnter = e.keyCode === 13;
|
|
1390
|
+
// console.log(`onKeydown datatable inner`);
|
|
1391
|
+
// console.log(`isEnter:`, isEnter)
|
|
1392
|
+
const isArrowKey = e.keyCode >= 37 && e.keyCode <= 40;
|
|
1393
|
+
// console.log(`e.target?.tagName:`,e.target?.tagName)
|
|
1394
|
+
if (
|
|
1395
|
+
(isArrowKey && e.target?.tagName !== "INPUT") ||
|
|
1396
|
+
isTabKey
|
|
1397
|
+
// || (isEnter && e.target?.tagName === "INPUT")
|
|
1398
|
+
) {
|
|
1388
1399
|
const { schema, entities } = computePresets(this.props);
|
|
1389
1400
|
const left = e.keyCode === 37;
|
|
1390
1401
|
const up = e.keyCode === 38;
|
|
1391
|
-
const down = e.keyCode === 40;
|
|
1402
|
+
const down = e.keyCode === 40 || e.keyCode === 13;
|
|
1392
1403
|
let cellIdToUse = this.getPrimarySelectedCellId();
|
|
1393
1404
|
const pathToIndex = getFieldPathToIndex(schema);
|
|
1394
1405
|
const entityMap = getEntityIdToEntity(entities);
|
package/src/autoTooltip.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import tippy from "tippy.js";
|
|
1
|
+
import tippy, { followCursor } from "tippy.js";
|
|
2
2
|
import "tippy.js/dist/tippy.css";
|
|
3
3
|
|
|
4
4
|
let tippys = [];
|
|
5
|
+
let recentlyHidden = false;
|
|
6
|
+
let clearMe;
|
|
5
7
|
(function () {
|
|
6
8
|
let lastMouseOverElement = null;
|
|
7
9
|
document.addEventListener("mouseover", function (event) {
|
|
@@ -24,23 +26,94 @@ let tippys = [];
|
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
let innerRun = false;
|
|
27
|
-
const inner = (
|
|
29
|
+
const inner = (
|
|
30
|
+
content,
|
|
31
|
+
el,
|
|
32
|
+
{ dataTitle, dataAvoid, dataAvoidBackup }
|
|
33
|
+
) => {
|
|
28
34
|
innerRun = true;
|
|
29
35
|
document.querySelectorAll(`.${id}`).forEach(elem => {
|
|
30
36
|
elem.classList.remove(id);
|
|
31
37
|
});
|
|
32
38
|
|
|
33
39
|
el.classList.add(id);
|
|
34
|
-
|
|
35
40
|
const inst = tippy(`.${id}`, {
|
|
41
|
+
plugins: [followCursor],
|
|
36
42
|
content,
|
|
37
|
-
delay:
|
|
38
|
-
|
|
43
|
+
delay:
|
|
44
|
+
dataTitle && !recentlyHidden
|
|
45
|
+
? [1300, 1300]
|
|
46
|
+
: dataTitle
|
|
47
|
+
? [150, 150]
|
|
48
|
+
: [0, 0],
|
|
49
|
+
allowHTML: true,
|
|
50
|
+
...(dataTitle && {
|
|
51
|
+
followCursor: dataTitle ? "initial" : false
|
|
52
|
+
}),
|
|
53
|
+
onHidden() {
|
|
54
|
+
recentlyHidden = true;
|
|
55
|
+
clearMe && clearTimeout(clearMe);
|
|
56
|
+
clearMe = setTimeout(() => {
|
|
57
|
+
if (tippys.length === 0) recentlyHidden = false;
|
|
58
|
+
}, 700);
|
|
59
|
+
},
|
|
60
|
+
...(dataAvoid && {
|
|
61
|
+
popperOptions: {
|
|
62
|
+
modifiers: [
|
|
63
|
+
{
|
|
64
|
+
name: "myModifier",
|
|
65
|
+
enabled: true,
|
|
66
|
+
phase: "beforeWrite",
|
|
67
|
+
requires: ["computeStyles"],
|
|
68
|
+
requiresIfExists: ["offset"],
|
|
69
|
+
fn({ state }) {
|
|
70
|
+
// console.log(`state:`, state);
|
|
71
|
+
// state.styles.popper.bottom = 20 + "px";
|
|
72
|
+
const customBoundary =
|
|
73
|
+
document.querySelector(dataAvoid) ||
|
|
74
|
+
document.querySelector(dataAvoidBackup);
|
|
75
|
+
|
|
76
|
+
if (!customBoundary) return;
|
|
77
|
+
const a = customBoundary.getBoundingClientRect();
|
|
78
|
+
// console.log(
|
|
79
|
+
// `state.rects.reference.y:`,
|
|
80
|
+
// state.rects.reference.y
|
|
81
|
+
// );
|
|
82
|
+
// console.log(`a.top:`, a.top);
|
|
83
|
+
|
|
84
|
+
if (a.top < state.rects.reference.y) {
|
|
85
|
+
const b = Math.abs(
|
|
86
|
+
Math.abs(a.top - state.rects.reference.y) - 10
|
|
87
|
+
);
|
|
88
|
+
state.styles.popper.bottom = b + "px";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// const overflow = detectOverflow(state, {
|
|
92
|
+
// boundary: customBoundary,
|
|
93
|
+
// altBoundary: true
|
|
94
|
+
// });
|
|
95
|
+
// console.log(`overflow:`, overflow);
|
|
96
|
+
// if (overflow.bottom > 0) {
|
|
97
|
+
// const a = Math.abs(overflow.bottom);
|
|
98
|
+
// state.styles.popper.bottom = a + "px";
|
|
99
|
+
// }
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
})
|
|
39
105
|
});
|
|
106
|
+
|
|
107
|
+
if (dataTitle) {
|
|
108
|
+
inst[0]?.popper?.classList.add("isDataTitle");
|
|
109
|
+
}
|
|
40
110
|
clearOldTippys(...inst);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
111
|
+
|
|
112
|
+
if (!dataTitle) {
|
|
113
|
+
inst.forEach(i => {
|
|
114
|
+
i.show();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
44
117
|
|
|
45
118
|
tippys = [...tippys, ...inst];
|
|
46
119
|
if (content === el.getAttribute("title")) {
|
|
@@ -57,14 +130,22 @@ let tippys = [];
|
|
|
57
130
|
const style = window.getComputedStyle(el);
|
|
58
131
|
const whiteSpace = style.getPropertyValue("white-space");
|
|
59
132
|
const textOverflow = style.getPropertyValue("text-overflow");
|
|
60
|
-
|
|
133
|
+
const dataTitle = el.getAttribute("data-title");
|
|
134
|
+
const dataAvoid = el.getAttribute("data-avoid");
|
|
135
|
+
const dataAvoidBackup = el.getAttribute("data-avoid-backup");
|
|
136
|
+
dataTip = el.getAttribute("data-tip") || dataTitle;
|
|
61
137
|
const isEllipsized =
|
|
62
138
|
whiteSpace === "nowrap" && textOverflow === "ellipsis";
|
|
63
139
|
|
|
140
|
+
const opts = {
|
|
141
|
+
dataTitle,
|
|
142
|
+
dataAvoid,
|
|
143
|
+
dataAvoidBackup
|
|
144
|
+
};
|
|
64
145
|
if (dataTip) {
|
|
65
146
|
if (dataTipStop) break;
|
|
66
147
|
|
|
67
|
-
inner(dataTip, el);
|
|
148
|
+
inner(dataTip, el, opts);
|
|
68
149
|
break;
|
|
69
150
|
} else if (
|
|
70
151
|
isEllipsized &&
|
|
@@ -73,7 +154,7 @@ let tippys = [];
|
|
|
73
154
|
el.textContent &&
|
|
74
155
|
el.textContent?.trim?.().length !== 0
|
|
75
156
|
) {
|
|
76
|
-
inner(el.textContent, el);
|
|
157
|
+
inner(el.textContent, el, opts);
|
|
77
158
|
break;
|
|
78
159
|
} else if (isEllipsized && el.offsetWidth >= el.scrollWidth) {
|
|
79
160
|
// break; //tnr: i don't think we need this..
|
package/src/style.css
CHANGED
|
@@ -157,6 +157,18 @@ code {
|
|
|
157
157
|
display: none;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
.isDataTitle .tippy-arrow {
|
|
161
|
+
opacity: 0 !important;
|
|
162
|
+
}
|
|
163
|
+
.isDataTitle .tippy-box {
|
|
164
|
+
background-color: #4f4a50f4 !important;
|
|
165
|
+
border-radius: 0 !important;
|
|
166
|
+
color: #f3f3f3 !important;
|
|
167
|
+
font-size: 11px !important;
|
|
168
|
+
white-space: pre-wrap;
|
|
169
|
+
padding: 0px 0px !important;
|
|
170
|
+
}
|
|
171
|
+
|
|
160
172
|
[data-tippy-root] {
|
|
161
173
|
z-index: 100000 !important;
|
|
162
174
|
}
|
package/style.css
CHANGED
|
@@ -8975,6 +8975,18 @@ code {
|
|
|
8975
8975
|
display: none;
|
|
8976
8976
|
}
|
|
8977
8977
|
|
|
8978
|
+
.isDataTitle .tippy-arrow {
|
|
8979
|
+
opacity: 0 !important;
|
|
8980
|
+
}
|
|
8981
|
+
.isDataTitle .tippy-box {
|
|
8982
|
+
background-color: #4f4a50f4 !important;
|
|
8983
|
+
border-radius: 0 !important;
|
|
8984
|
+
color: #f3f3f3 !important;
|
|
8985
|
+
font-size: 11px !important;
|
|
8986
|
+
white-space: pre-wrap;
|
|
8987
|
+
padding: 0px 0px !important;
|
|
8988
|
+
}
|
|
8989
|
+
|
|
8978
8990
|
[data-tippy-root] {
|
|
8979
8991
|
z-index: 100000 !important;
|
|
8980
8992
|
}
|