lecom-ui 5.2.99 → 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.
@@ -64,7 +64,7 @@ function useTagVisibility(ref, value) {
64
64
  (a, b) => a - b
65
65
  );
66
66
  if (offsetTops.length <= 1) {
67
- return { visibleCount: totalTags, hiddenCount: 0 };
67
+ return totalTags > 6 ? { visibleCount: 5, hiddenCount: totalTags - 5 } : { visibleCount: totalTags, hiddenCount: 0 };
68
68
  }
69
69
  const firstLineTop = offsetTops[0];
70
70
  const secondLineTop = offsetTops[1];
@@ -99,7 +99,6 @@ function useTagVisibility(ref, value) {
99
99
  const calculateWhenVisible = () => {
100
100
  requestAnimationFrame(() => requestAnimationFrame(calculateMaxVisible));
101
101
  };
102
- calculateWhenVisible();
103
102
  const observer = new IntersectionObserver((entries) => {
104
103
  if (entries.some((entry) => entry.isIntersecting)) calculateWhenVisible();
105
104
  });
@@ -107,6 +106,9 @@ function useTagVisibility(ref, value) {
107
106
  if (ref.current) {
108
107
  observer.observe(ref.current);
109
108
  resizeObserver.observe(ref.current);
109
+ if (ref.current.offsetParent !== null) {
110
+ calculateWhenVisible();
111
+ }
110
112
  }
111
113
  return () => {
112
114
  observer.disconnect();
@@ -117,6 +119,9 @@ function useTagVisibility(ref, value) {
117
119
  const timeout = setTimeout(calculateMaxVisible, 150);
118
120
  return () => clearTimeout(timeout);
119
121
  }, [value.length, calculateMaxVisible]);
122
+ React.useLayoutEffect(() => {
123
+ calculateMaxVisible();
124
+ }, [value.length, calculateMaxVisible]);
120
125
  return { maxVisibleCount, hiddenCount };
121
126
  }
122
127
  function TagInput(props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-ui",
3
- "version": "5.2.99",
3
+ "version": "5.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",