lecom-ui 5.2.97 → 5.2.99
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.
|
@@ -40,7 +40,7 @@ function HiddenCountTag({
|
|
|
40
40
|
{
|
|
41
41
|
className: "w-4 h-4 cursor-pointer",
|
|
42
42
|
onClick: handleRemove,
|
|
43
|
-
"aria-label":
|
|
43
|
+
"aria-label": "Remover tag oculta",
|
|
44
44
|
tabIndex: 0
|
|
45
45
|
}
|
|
46
46
|
));
|
|
@@ -64,21 +64,17 @@ function useTagVisibility(ref, value) {
|
|
|
64
64
|
(a, b) => a - b
|
|
65
65
|
);
|
|
66
66
|
if (offsetTops.length <= 1) {
|
|
67
|
-
return
|
|
67
|
+
return { visibleCount: totalTags, hiddenCount: 0 };
|
|
68
68
|
}
|
|
69
69
|
const firstLineTop = offsetTops[0];
|
|
70
70
|
const secondLineTop = offsetTops[1];
|
|
71
71
|
let firstLineCount = 0;
|
|
72
72
|
let secondLineCount = 0;
|
|
73
73
|
for (const child of children) {
|
|
74
|
-
if (child.offsetTop === firstLineTop)
|
|
75
|
-
|
|
76
|
-
} else if (child.offsetTop === secondLineTop) {
|
|
77
|
-
secondLineCount++;
|
|
78
|
-
}
|
|
74
|
+
if (child.offsetTop === firstLineTop) firstLineCount++;
|
|
75
|
+
else if (child.offsetTop === secondLineTop) secondLineCount++;
|
|
79
76
|
}
|
|
80
|
-
const
|
|
81
|
-
const visibleCount = firstLineCount + maxSecondLineVisible;
|
|
77
|
+
const visibleCount = firstLineCount + secondLineCount;
|
|
82
78
|
return {
|
|
83
79
|
visibleCount,
|
|
84
80
|
hiddenCount: Math.max(totalTags - visibleCount, 0)
|
|
@@ -100,25 +96,25 @@ function useTagVisibility(ref, value) {
|
|
|
100
96
|
setHiddenCount(newHiddenCount);
|
|
101
97
|
}, [ref, calculateVisibleTags, value.length]);
|
|
102
98
|
React.useLayoutEffect(() => {
|
|
103
|
-
|
|
104
|
-
requestAnimationFrame(() =>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
calculateMaxVisible();
|
|
99
|
+
const calculateWhenVisible = () => {
|
|
100
|
+
requestAnimationFrame(() => requestAnimationFrame(calculateMaxVisible));
|
|
101
|
+
};
|
|
102
|
+
calculateWhenVisible();
|
|
103
|
+
const observer = new IntersectionObserver((entries) => {
|
|
104
|
+
if (entries.some((entry) => entry.isIntersecting)) calculateWhenVisible();
|
|
110
105
|
});
|
|
106
|
+
const resizeObserver = new ResizeObserver(calculateMaxVisible);
|
|
111
107
|
if (ref.current) {
|
|
108
|
+
observer.observe(ref.current);
|
|
112
109
|
resizeObserver.observe(ref.current);
|
|
113
110
|
}
|
|
114
111
|
return () => {
|
|
112
|
+
observer.disconnect();
|
|
115
113
|
resizeObserver.disconnect();
|
|
116
114
|
};
|
|
117
115
|
}, [value, calculateMaxVisible, ref]);
|
|
118
116
|
React.useEffect(() => {
|
|
119
|
-
const timeout = setTimeout(
|
|
120
|
-
calculateMaxVisible();
|
|
121
|
-
}, 150);
|
|
117
|
+
const timeout = setTimeout(calculateMaxVisible, 150);
|
|
122
118
|
return () => clearTimeout(timeout);
|
|
123
119
|
}, [value.length, calculateMaxVisible]);
|
|
124
120
|
return { maxVisibleCount, hiddenCount };
|
|
@@ -155,18 +151,13 @@ function TagInput(props) {
|
|
|
155
151
|
}),
|
|
156
152
|
[disabled, actualHiddenCount]
|
|
157
153
|
);
|
|
158
|
-
const showPlaceholder = value.length === 0;
|
|
159
|
-
const showHiddenCount = actualHiddenCount > 0;
|
|
160
154
|
const handleRemove = React.useCallback(
|
|
161
|
-
(valueToRemove) =>
|
|
162
|
-
onRemove(valueToRemove);
|
|
163
|
-
},
|
|
155
|
+
(valueToRemove) => onRemove(valueToRemove),
|
|
164
156
|
[onRemove]
|
|
165
157
|
);
|
|
166
158
|
const handleRemoveHidden = React.useCallback(() => {
|
|
167
159
|
if (value.length > visibleCount) {
|
|
168
|
-
const
|
|
169
|
-
const tagToRemove = value[lastVisibleIndex];
|
|
160
|
+
const tagToRemove = value[visibleCount];
|
|
170
161
|
if (tagToRemove) {
|
|
171
162
|
onRemove(tagToRemove.value);
|
|
172
163
|
}
|
|
@@ -182,7 +173,7 @@ function TagInput(props) {
|
|
|
182
173
|
style: containerStyles,
|
|
183
174
|
...restProps
|
|
184
175
|
},
|
|
185
|
-
|
|
176
|
+
value.length === 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "body-small-400", className: "text-grey-400" }, placeholder),
|
|
186
177
|
displayTags.map((item) => /* @__PURE__ */ React.createElement(
|
|
187
178
|
TagItem,
|
|
188
179
|
{
|
|
@@ -192,7 +183,7 @@ function TagInput(props) {
|
|
|
192
183
|
readOnly
|
|
193
184
|
}
|
|
194
185
|
)),
|
|
195
|
-
|
|
186
|
+
actualHiddenCount > 0 && /* @__PURE__ */ React.createElement(
|
|
196
187
|
HiddenCountTag,
|
|
197
188
|
{
|
|
198
189
|
count: actualHiddenCount,
|