@cloud-ru/ds-tag 1.2.2-preview-c0e895ed.0 → 1.2.2-preview-e8fe6b56.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.
- package/dist/cjs/components/TagBase/TagBase.js +1 -1
- package/dist/cjs/helperComponents/TagList/TagList.js +1 -1
- package/dist/cjs/helperComponents/TagRowSimple/styles.module.css +3 -3
- package/dist/cjs/helperComponents/TagRowTruncated/TagRowTruncated.js +27 -38
- package/dist/cjs/helperComponents/TagRowTruncated/styles.module.css +9 -9
- package/dist/cjs/style.css +12 -12
- package/dist/esm/components/TagBase/TagBase.js +2 -2
- package/dist/esm/helperComponents/TagList/TagList.js +1 -1
- package/dist/esm/helperComponents/TagRowSimple/styles.module.css +3 -3
- package/dist/esm/helperComponents/TagRowTruncated/TagRowTruncated.js +27 -38
- package/dist/esm/helperComponents/TagRowTruncated/styles.module.css +9 -9
- package/dist/esm/style.css +12 -12
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/components/TagBase/TagBase.tsx +2 -2
- package/src/helperComponents/TagList/TagList.tsx +1 -1
- package/src/helperComponents/TagRowTruncated/TagRowTruncated.tsx +28 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/ds-tag",
|
|
3
|
-
"version": "1.2.2-preview-
|
|
3
|
+
"version": "1.2.2-preview-e8fe6b56.0",
|
|
4
4
|
"description": "Пакет компактных меток — компонент Tag (опционально удаляемый или ссылочный) и контейнер TagRow для групп меток с обрезанием по строкам.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"classnames": "^2.5.1",
|
|
37
|
-
"@cloud-ru/ds-materials": "2.0.3-preview-
|
|
38
|
-
"@cloud-ru/ds-
|
|
39
|
-
"@cloud-ru/ds-
|
|
40
|
-
"@cloud-ru/ds-
|
|
41
|
-
"@cloud-ru/ds-
|
|
42
|
-
"@cloud-ru/ds-truncate-string": "1.0.20-preview-
|
|
43
|
-
"@cloud-ru/ds-
|
|
37
|
+
"@cloud-ru/ds-materials": "2.0.3-preview-e8fe6b56.0",
|
|
38
|
+
"@cloud-ru/ds-dropdown": "1.2.2-preview-e8fe6b56.0",
|
|
39
|
+
"@cloud-ru/ds-icons": "1.7.3-preview-e8fe6b56.0",
|
|
40
|
+
"@cloud-ru/ds-scroll": "1.0.7-preview-e8fe6b56.0",
|
|
41
|
+
"@cloud-ru/ds-tooltip": "1.0.19-preview-e8fe6b56.0",
|
|
42
|
+
"@cloud-ru/ds-truncate-string": "1.0.20-preview-e8fe6b56.0",
|
|
43
|
+
"@cloud-ru/ds-utils": "1.3.1-preview-e8fe6b56.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CrossSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
2
2
|
import { TruncateString } from '@cloud-ru/ds-truncate-string';
|
|
3
|
-
import { withInnerRefSupport } from '@cloud-ru/ds-utils';
|
|
3
|
+
import { extractSupportProps, withInnerRefSupport } from '@cloud-ru/ds-utils';
|
|
4
4
|
import cn from 'classnames';
|
|
5
5
|
|
|
6
6
|
import { APPEARANCE, SIZE, TEST_IDS } from '../../constants';
|
|
@@ -26,7 +26,7 @@ export function TagBase({
|
|
|
26
26
|
return (
|
|
27
27
|
<span
|
|
28
28
|
ref={innerRef}
|
|
29
|
-
{...rest}
|
|
29
|
+
{...extractSupportProps(rest)}
|
|
30
30
|
className={cn(styles.tag, className)}
|
|
31
31
|
data-size={size}
|
|
32
32
|
data-appearance={appearance}
|
|
@@ -20,7 +20,7 @@ function renderTag(size: Size, handleRemoveItem?: (item: TagRowItemInner) => OnD
|
|
|
20
20
|
return function TagRowItem(item: TagRowItemInner) {
|
|
21
21
|
return (
|
|
22
22
|
<div key={item.id ?? item.label} ref={setRef?.(item)} className={styles.tagWrapper}>
|
|
23
|
-
<Tag size={size} {
|
|
23
|
+
<Tag size={size} onDelete={handleRemoveItem?.(item)} {...item} />
|
|
24
24
|
</div>
|
|
25
25
|
);
|
|
26
26
|
};
|
|
@@ -78,55 +78,44 @@ function TagRowTruncatedInner({
|
|
|
78
78
|
|
|
79
79
|
const moreButtonWidth = hiddenMoreButtonRef.current?.offsetWidth || 0;
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}));
|
|
85
|
-
|
|
86
|
-
let rowWidth = 0;
|
|
87
|
-
let rowCount = 1;
|
|
88
|
-
let rowItems = 0;
|
|
89
|
-
|
|
90
|
-
const allTagsFit = measuredTags.every(({ width }) => {
|
|
91
|
-
const nextWidth = rowWidth + (rowItems ? gapWidth : 0) + width;
|
|
92
|
-
if (rowItems && nextWidth > maxWidth) {
|
|
93
|
-
rowCount++;
|
|
94
|
-
rowWidth = width;
|
|
95
|
-
rowItems = 1;
|
|
96
|
-
} else {
|
|
97
|
-
rowWidth = nextWidth;
|
|
98
|
-
rowItems++;
|
|
99
|
-
}
|
|
100
|
-
return rowCount <= rowLimit && width <= maxWidth;
|
|
101
|
-
});
|
|
81
|
+
let currentRowWidth = 0;
|
|
82
|
+
let currentRowCount = 1;
|
|
83
|
+
let currentRowVisibleTagAmount = 0;
|
|
102
84
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
85
|
+
tagsMapRef.current.forEach((tagElement, tagRowItem) => {
|
|
86
|
+
const tagWidth = tagElement?.offsetWidth || 0;
|
|
87
|
+
const sumRowWidth = currentRowWidth + tagWidth + gapWidth;
|
|
106
88
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
newVisibleTags.push(item);
|
|
89
|
+
if (currentRowCount > rowLimit) {
|
|
90
|
+
newHiddenTags.push(tagRowItem);
|
|
110
91
|
return;
|
|
111
92
|
}
|
|
112
93
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
94
|
+
if (currentRowCount === rowLimit) {
|
|
95
|
+
if (sumRowWidth + moreButtonWidth > maxWidth) {
|
|
96
|
+
currentRowCount++;
|
|
97
|
+
currentRowVisibleTagAmount = 0;
|
|
98
|
+
newHiddenTags.push(tagRowItem);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
currentRowWidth = sumRowWidth;
|
|
103
|
+
newVisibleTags.push(tagRowItem);
|
|
104
|
+
currentRowVisibleTagAmount++;
|
|
105
|
+
return;
|
|
119
106
|
}
|
|
120
107
|
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
108
|
+
if (sumRowWidth > maxWidth) {
|
|
109
|
+
currentRowWidth = currentRowVisibleTagAmount ? tagWidth + gapWidth : 0;
|
|
110
|
+
currentRowCount++;
|
|
111
|
+
currentRowVisibleTagAmount = 0;
|
|
112
|
+
newVisibleTags.push(tagRowItem);
|
|
124
113
|
return;
|
|
125
114
|
}
|
|
126
115
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
newVisibleTags.push(
|
|
116
|
+
currentRowVisibleTagAmount++;
|
|
117
|
+
currentRowWidth = sumRowWidth;
|
|
118
|
+
newVisibleTags.push(tagRowItem);
|
|
130
119
|
});
|
|
131
120
|
|
|
132
121
|
setVisibleTags(newVisibleTags);
|