lecom-ui 5.2.96 → 5.2.97

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.
@@ -55,26 +55,11 @@ function useTagVisibility(ref, value) {
55
55
  () => getInitialEstimate(value.length)
56
56
  );
57
57
  const [hiddenCount, setHiddenCount] = React.useState(0);
58
- React.useEffect(() => {
59
- if (maxVisibleCount === null) {
60
- setMaxVisibleCount(getInitialEstimate(value.length));
61
- }
62
- }, [value.length, getInitialEstimate, maxVisibleCount]);
63
58
  const calculateVisibleTags = React.useCallback(
64
59
  (children, totalTags) => {
65
- if (children.length === 0 || totalTags === 0) {
60
+ if (children.length === 0 || totalTags === 0)
66
61
  return { visibleCount: 0, hiddenCount: 0 };
67
- }
68
- if (totalTags <= 3) {
69
- return { visibleCount: totalTags, hiddenCount: 0 };
70
- }
71
- if (children.length === 0) {
72
- const estimated = totalTags <= 4 ? totalTags : 4;
73
- return {
74
- visibleCount: estimated,
75
- hiddenCount: Math.max(totalTags - estimated, 0)
76
- };
77
- }
62
+ if (totalTags <= 3) return { visibleCount: totalTags, hiddenCount: 0 };
78
63
  const offsetTops = [...new Set(children.map((c) => c.offsetTop))].sort(
79
64
  (a, b) => a - b
80
65
  );
@@ -94,13 +79,9 @@ function useTagVisibility(ref, value) {
94
79
  }
95
80
  const maxSecondLineVisible = Math.min(secondLineCount, 2);
96
81
  const visibleCount = firstLineCount + maxSecondLineVisible;
97
- if (visibleCount >= totalTags) {
98
- return { visibleCount: totalTags, hiddenCount: 0 };
99
- }
100
- const hiddenCount2 = totalTags - visibleCount;
101
82
  return {
102
83
  visibleCount,
103
- hiddenCount: hiddenCount2
84
+ hiddenCount: Math.max(totalTags - visibleCount, 0)
104
85
  };
105
86
  },
106
87
  []
@@ -119,7 +100,11 @@ function useTagVisibility(ref, value) {
119
100
  setHiddenCount(newHiddenCount);
120
101
  }, [ref, calculateVisibleTags, value.length]);
121
102
  React.useLayoutEffect(() => {
122
- calculateMaxVisible();
103
+ requestAnimationFrame(() => {
104
+ requestAnimationFrame(() => {
105
+ calculateMaxVisible();
106
+ });
107
+ });
123
108
  const resizeObserver = new ResizeObserver(() => {
124
109
  calculateMaxVisible();
125
110
  });
@@ -131,22 +116,11 @@ function useTagVisibility(ref, value) {
131
116
  };
132
117
  }, [value, calculateMaxVisible, ref]);
133
118
  React.useEffect(() => {
134
- if (ref.current) {
135
- requestAnimationFrame(() => {
136
- requestAnimationFrame(() => {
137
- calculateMaxVisible();
138
- });
139
- });
140
- }
141
- }, [value.length, calculateMaxVisible, ref]);
142
- React.useEffect(() => {
143
- if (ref.current && value.length > 5) {
144
- const timeoutId = setTimeout(() => {
145
- calculateMaxVisible();
146
- }, 50);
147
- return () => clearTimeout(timeoutId);
148
- }
149
- }, [value.length, calculateMaxVisible, ref]);
119
+ const timeout = setTimeout(() => {
120
+ calculateMaxVisible();
121
+ }, 150);
122
+ return () => clearTimeout(timeout);
123
+ }, [value.length, calculateMaxVisible]);
150
124
  return { maxVisibleCount, hiddenCount };
151
125
  }
152
126
  function TagInput(props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-ui",
3
- "version": "5.2.96",
3
+ "version": "5.2.97",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",