lecom-ui 5.2.98 → 5.3.0
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
|
));
|
|
@@ -71,14 +71,10 @@ function useTagVisibility(ref, value) {
|
|
|
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)
|
|
@@ -101,23 +97,18 @@ function useTagVisibility(ref, value) {
|
|
|
101
97
|
}, [ref, calculateVisibleTags, value.length]);
|
|
102
98
|
React.useLayoutEffect(() => {
|
|
103
99
|
const calculateWhenVisible = () => {
|
|
104
|
-
requestAnimationFrame(() =>
|
|
105
|
-
requestAnimationFrame(() => {
|
|
106
|
-
calculateMaxVisible();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
100
|
+
requestAnimationFrame(() => requestAnimationFrame(calculateMaxVisible));
|
|
109
101
|
};
|
|
110
102
|
const observer = new IntersectionObserver((entries) => {
|
|
111
|
-
if (entries.some((entry) => entry.isIntersecting))
|
|
112
|
-
calculateWhenVisible();
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
116
|
-
calculateMaxVisible();
|
|
103
|
+
if (entries.some((entry) => entry.isIntersecting)) calculateWhenVisible();
|
|
117
104
|
});
|
|
105
|
+
const resizeObserver = new ResizeObserver(calculateMaxVisible);
|
|
118
106
|
if (ref.current) {
|
|
119
107
|
observer.observe(ref.current);
|
|
120
108
|
resizeObserver.observe(ref.current);
|
|
109
|
+
if (ref.current.offsetParent !== null) {
|
|
110
|
+
calculateWhenVisible();
|
|
111
|
+
}
|
|
121
112
|
}
|
|
122
113
|
return () => {
|
|
123
114
|
observer.disconnect();
|
|
@@ -125,11 +116,12 @@ function useTagVisibility(ref, value) {
|
|
|
125
116
|
};
|
|
126
117
|
}, [value, calculateMaxVisible, ref]);
|
|
127
118
|
React.useEffect(() => {
|
|
128
|
-
const timeout = setTimeout(
|
|
129
|
-
calculateMaxVisible();
|
|
130
|
-
}, 150);
|
|
119
|
+
const timeout = setTimeout(calculateMaxVisible, 150);
|
|
131
120
|
return () => clearTimeout(timeout);
|
|
132
121
|
}, [value.length, calculateMaxVisible]);
|
|
122
|
+
React.useLayoutEffect(() => {
|
|
123
|
+
calculateMaxVisible();
|
|
124
|
+
}, [value.length, calculateMaxVisible]);
|
|
133
125
|
return { maxVisibleCount, hiddenCount };
|
|
134
126
|
}
|
|
135
127
|
function TagInput(props) {
|
|
@@ -164,18 +156,13 @@ function TagInput(props) {
|
|
|
164
156
|
}),
|
|
165
157
|
[disabled, actualHiddenCount]
|
|
166
158
|
);
|
|
167
|
-
const showPlaceholder = value.length === 0;
|
|
168
|
-
const showHiddenCount = actualHiddenCount > 0;
|
|
169
159
|
const handleRemove = React.useCallback(
|
|
170
|
-
(valueToRemove) =>
|
|
171
|
-
onRemove(valueToRemove);
|
|
172
|
-
},
|
|
160
|
+
(valueToRemove) => onRemove(valueToRemove),
|
|
173
161
|
[onRemove]
|
|
174
162
|
);
|
|
175
163
|
const handleRemoveHidden = React.useCallback(() => {
|
|
176
164
|
if (value.length > visibleCount) {
|
|
177
|
-
const
|
|
178
|
-
const tagToRemove = value[lastVisibleIndex];
|
|
165
|
+
const tagToRemove = value[visibleCount];
|
|
179
166
|
if (tagToRemove) {
|
|
180
167
|
onRemove(tagToRemove.value);
|
|
181
168
|
}
|
|
@@ -191,7 +178,7 @@ function TagInput(props) {
|
|
|
191
178
|
style: containerStyles,
|
|
192
179
|
...restProps
|
|
193
180
|
},
|
|
194
|
-
|
|
181
|
+
value.length === 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "body-small-400", className: "text-grey-400" }, placeholder),
|
|
195
182
|
displayTags.map((item) => /* @__PURE__ */ React.createElement(
|
|
196
183
|
TagItem,
|
|
197
184
|
{
|
|
@@ -201,7 +188,7 @@ function TagInput(props) {
|
|
|
201
188
|
readOnly
|
|
202
189
|
}
|
|
203
190
|
)),
|
|
204
|
-
|
|
191
|
+
actualHiddenCount > 0 && /* @__PURE__ */ React.createElement(
|
|
205
192
|
HiddenCountTag,
|
|
206
193
|
{
|
|
207
194
|
count: actualHiddenCount,
|