lecom-ui 5.3.0 → 5.3.2
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.
|
@@ -57,8 +57,13 @@ function useTagVisibility(ref, value) {
|
|
|
57
57
|
const [hiddenCount, setHiddenCount] = React.useState(0);
|
|
58
58
|
const calculateVisibleTags = React.useCallback(
|
|
59
59
|
(children, totalTags) => {
|
|
60
|
-
if (children.length === 0 || totalTags === 0)
|
|
61
|
-
|
|
60
|
+
if (children.length === 0 || totalTags === 0) {
|
|
61
|
+
const initialCount = getInitialEstimate(totalTags);
|
|
62
|
+
return {
|
|
63
|
+
visibleCount: initialCount,
|
|
64
|
+
hiddenCount: Math.max(totalTags - initialCount, 0)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
62
67
|
if (totalTags <= 3) return { visibleCount: totalTags, hiddenCount: 0 };
|
|
63
68
|
const offsetTops = [...new Set(children.map((c) => c.offsetTop))].sort(
|
|
64
69
|
(a, b) => a - b
|
|
@@ -80,7 +85,7 @@ function useTagVisibility(ref, value) {
|
|
|
80
85
|
hiddenCount: Math.max(totalTags - visibleCount, 0)
|
|
81
86
|
};
|
|
82
87
|
},
|
|
83
|
-
[]
|
|
88
|
+
[getInitialEstimate]
|
|
84
89
|
);
|
|
85
90
|
const calculateMaxVisible = React.useCallback(() => {
|
|
86
91
|
const container = ref.current;
|
|
@@ -137,8 +142,8 @@ function TagInput(props) {
|
|
|
137
142
|
...restProps
|
|
138
143
|
} = props;
|
|
139
144
|
const ref = React.useRef(null);
|
|
140
|
-
|
|
141
|
-
const visibleCount =
|
|
145
|
+
useTagVisibility(ref, value);
|
|
146
|
+
const visibleCount = Math.min(7, value.length);
|
|
142
147
|
const displayTags = value.slice(0, visibleCount);
|
|
143
148
|
const actualHiddenCount = Math.max(value.length - visibleCount, 0);
|
|
144
149
|
const textareaRadius = radius === "full" ? "large" : radius;
|