@snack-uikit/tag 0.8.3-preview-cb79db34.0 → 0.9.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.9.1 (2024-04-23)
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/dropdown@0.2.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/dropdown/CHANGELOG.md)
10
+ * [@snack-uikit/scroll@0.5.3](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/scroll/CHANGELOG.md)
11
+ * [@snack-uikit/utils@3.3.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
12
+
13
+
14
+
15
+
16
+
17
+ # 0.9.0 (2024-04-22)
18
+
19
+
20
+ ### Features
21
+
22
+ * **FF-4649:** long text tags handling ([4fa20e0](https://github.com/cloud-ru-tech/snack-uikit/commit/4fa20e00aaf57483d34ab7fdbca5f6b333025c7e))
23
+
24
+
25
+
26
+
27
+
6
28
  ## 0.8.2 (2024-03-26)
7
29
 
8
30
  ### Only dependencies have been changed
@@ -18,6 +18,6 @@ import { ICON_SIZE } from './constants';
18
18
  import styles from './styles.module.css';
19
19
  export function Tag(_a) {
20
20
  var { label, size = SIZE.Xs, appearance = APPEARANCE.Neutral, onDelete, className, tabIndex } = _a, rest = __rest(_a, ["label", "size", "appearance", "onDelete", "className", "tabIndex"]);
21
- return (_jsxs("span", Object.assign({}, extractSupportProps(rest), { className: cn(styles.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": Boolean(onDelete), children: [_jsx("span", { className: styles.label, children: label }), onDelete && (_jsx("button", { type: 'button', className: styles.tagButton, onClick: onDelete, "data-test-id": 'tag-remove-button', tabIndex: tabIndex, children: size === SIZE.Xs ? (_jsx(CrossSVG, { size: ICON_SIZE[size], className: styles.icon })) : (_jsx(CrossSVG, { size: ICON_SIZE[size], className: styles.icon })) }))] })));
21
+ return (_jsxs("span", Object.assign({}, extractSupportProps(rest), { className: cn(styles.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": Boolean(onDelete), children: [_jsx("span", { title: label, className: styles.label, children: label }), onDelete && (_jsx("button", { type: 'button', className: styles.tagButton, onClick: onDelete, "data-test-id": 'tag-remove-button', tabIndex: tabIndex, children: size === SIZE.Xs ? (_jsx(CrossSVG, { size: ICON_SIZE[size], className: styles.icon })) : (_jsx(CrossSVG, { size: ICON_SIZE[size], className: styles.icon })) }))] })));
22
22
  }
23
23
  export { APPEARANCE };
@@ -2,6 +2,7 @@
2
2
  display:inline-flex;
3
3
  align-items:center;
4
4
  box-sizing:border-box;
5
+ max-width:100%;
5
6
  }
6
7
  .tag .tagButton{
7
8
  cursor:pointer;
@@ -83,7 +84,10 @@
83
84
  background-color:var(--sys-neutral-decor-default, #dfe2ec);
84
85
  }
85
86
  .tag[data-appearance=neutral] .label{
87
+ overflow:hidden;
86
88
  color:var(--sys-neutral-text-support, #656771);
89
+ text-overflow:ellipsis;
90
+ white-space:nowrap;
87
91
  }
88
92
  .tag[data-appearance=neutral] .tagButton{
89
93
  color:var(--sys-neutral-text-light, #868892);
@@ -101,7 +105,10 @@
101
105
  background-color:var(--sys-primary-decor-default, #ebdefd);
102
106
  }
103
107
  .tag[data-appearance=primary] .label{
108
+ overflow:hidden;
104
109
  color:var(--sys-primary-text-support, #5b4796);
110
+ text-overflow:ellipsis;
111
+ white-space:nowrap;
105
112
  }
106
113
  .tag[data-appearance=primary] .tagButton{
107
114
  color:var(--sys-primary-text-light, #997adc);
@@ -119,7 +126,10 @@
119
126
  background-color:var(--sys-red-decor-default, #fdd6cd);
120
127
  }
121
128
  .tag[data-appearance=red] .label{
129
+ overflow:hidden;
122
130
  color:var(--sys-red-text-support, #ab423e);
131
+ text-overflow:ellipsis;
132
+ white-space:nowrap;
123
133
  }
124
134
  .tag[data-appearance=red] .tagButton{
125
135
  color:var(--sys-red-text-light, #ea6658);
@@ -137,7 +147,10 @@
137
147
  background-color:var(--sys-orange-decor-default, #fed8b8);
138
148
  }
139
149
  .tag[data-appearance=orange] .label{
150
+ overflow:hidden;
140
151
  color:var(--sys-orange-text-support, #c06735);
152
+ text-overflow:ellipsis;
153
+ white-space:nowrap;
141
154
  }
142
155
  .tag[data-appearance=orange] .tagButton{
143
156
  color:var(--sys-orange-text-light, #ea873a);
@@ -155,7 +168,10 @@
155
168
  background-color:var(--sys-yellow-decor-default, #f0dfb1);
156
169
  }
157
170
  .tag[data-appearance=yellow] .label{
171
+ overflow:hidden;
158
172
  color:var(--sys-yellow-text-support, #a57b0e);
173
+ text-overflow:ellipsis;
174
+ white-space:nowrap;
159
175
  }
160
176
  .tag[data-appearance=yellow] .tagButton{
161
177
  color:var(--sys-yellow-text-light, #ddb035);
@@ -173,7 +189,10 @@
173
189
  background-color:var(--sys-green-decor-default, #d2ead0);
174
190
  }
175
191
  .tag[data-appearance=green] .label{
192
+ overflow:hidden;
176
193
  color:var(--sys-green-text-support, #568a56);
194
+ text-overflow:ellipsis;
195
+ white-space:nowrap;
177
196
  }
178
197
  .tag[data-appearance=green] .tagButton{
179
198
  color:var(--sys-green-text-light, #67ba6e);
@@ -191,7 +210,10 @@
191
210
  background-color:var(--sys-blue-decor-default, #d6e2f4);
192
211
  }
193
212
  .tag[data-appearance=blue] .label{
213
+ overflow:hidden;
194
214
  color:var(--sys-blue-text-support, #4975a9);
215
+ text-overflow:ellipsis;
216
+ white-space:nowrap;
195
217
  }
196
218
  .tag[data-appearance=blue] .tagButton{
197
219
  color:var(--sys-blue-text-light, #729edd);
@@ -209,7 +231,10 @@
209
231
  background-color:var(--sys-violet-decor-default, #efd9ef);
210
232
  }
211
233
  .tag[data-appearance=violet] .label{
234
+ overflow:hidden;
212
235
  color:var(--sys-violet-text-support, #8c5d93);
236
+ text-overflow:ellipsis;
237
+ white-space:nowrap;
213
238
  }
214
239
  .tag[data-appearance=violet] .tagButton{
215
240
  color:var(--sys-violet-text-light, #c886c9);
@@ -227,7 +252,10 @@
227
252
  background-color:var(--sys-pink-decor-default, #f5d9e1);
228
253
  }
229
254
  .tag[data-appearance=pink] .label{
255
+ overflow:hidden;
230
256
  color:var(--sys-pink-text-support, #aa597d);
257
+ text-overflow:ellipsis;
258
+ white-space:nowrap;
231
259
  }
232
260
  .tag[data-appearance=pink] .tagButton{
233
261
  color:var(--sys-pink-text-light, #e68baa);
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Tag } from '../../components';
3
3
  import { SIZE } from '../../constants';
4
+ import styles from './styles.module.css';
4
5
  function renderTag(size, handleRemoveItem, setRef) {
5
6
  return function TagRowItem(item, index) {
6
- return (_jsx("div", { ref: setRef === null || setRef === void 0 ? void 0 : setRef(item, index), children: _jsx(Tag, { label: item.label, appearance: item.appearance, size: size, onDelete: handleRemoveItem === null || handleRemoveItem === void 0 ? void 0 : handleRemoveItem(item) }) }, item.label));
7
+ return (_jsx("div", { ref: setRef === null || setRef === void 0 ? void 0 : setRef(item, index), className: styles.tagWrapper, children: _jsx(Tag, { label: item.label, appearance: item.appearance, size: size, onDelete: handleRemoveItem === null || handleRemoveItem === void 0 ? void 0 : handleRemoveItem(item) }) }, item.label));
7
8
  };
8
9
  }
9
10
  export function TagList({ items, size = SIZE.Xs, onItemRemove, setTagRef }) {
@@ -0,0 +1,3 @@
1
+ .tagWrapper{
2
+ max-width:100%;
3
+ }
@@ -54,6 +54,7 @@ function TagRowTruncatedInner(_a) {
54
54
  const moreButtonWidth = ((_a = hiddenMoreButtonRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
55
55
  let currentRowWidth = 0;
56
56
  let currentRowCount = 1;
57
+ let currentRowVisibleTagAmount = 0;
57
58
  tagsMapRef.current.forEach((tagElement, tagRowItem) => {
58
59
  const tagWidth = (tagElement === null || tagElement === void 0 ? void 0 : tagElement.offsetWidth) || 0;
59
60
  const sumRowWidth = currentRowWidth + tagWidth + gapWidth;
@@ -64,19 +65,23 @@ function TagRowTruncatedInner(_a) {
64
65
  if (currentRowCount === rowLimit) {
65
66
  if (sumRowWidth + moreButtonWidth > maxWidth) {
66
67
  currentRowCount++;
68
+ currentRowVisibleTagAmount = 0;
67
69
  newHiddenTags.push(tagRowItem);
68
70
  return;
69
71
  }
70
72
  currentRowWidth = sumRowWidth;
71
73
  newVisibleTags.push(tagRowItem);
74
+ currentRowVisibleTagAmount++;
72
75
  return;
73
76
  }
74
77
  if (sumRowWidth > maxWidth) {
75
- currentRowWidth = tagWidth + gapWidth;
78
+ currentRowWidth = currentRowVisibleTagAmount ? tagWidth + gapWidth : 0;
76
79
  currentRowCount++;
80
+ currentRowVisibleTagAmount = 0;
77
81
  newVisibleTags.push(tagRowItem);
78
82
  return;
79
83
  }
84
+ currentRowVisibleTagAmount++;
80
85
  currentRowWidth = sumRowWidth;
81
86
  newVisibleTags.push(tagRowItem);
82
87
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Tag",
7
- "version": "0.8.3-preview-cb79db34.0",
7
+ "version": "0.9.1",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -32,11 +32,11 @@
32
32
  "license": "Apache-2.0",
33
33
  "scripts": {},
34
34
  "dependencies": {
35
- "@snack-uikit/dropdown": "0.2.2-preview-cb79db34.0",
35
+ "@snack-uikit/dropdown": "0.2.2",
36
36
  "@snack-uikit/icons": "0.20.1",
37
- "@snack-uikit/scroll": "0.5.3-preview-cb79db34.0",
38
- "@snack-uikit/utils": "3.2.1-preview-cb79db34.0",
37
+ "@snack-uikit/scroll": "0.5.3",
38
+ "@snack-uikit/utils": "3.3.0",
39
39
  "classnames": "2.3.2"
40
40
  },
41
- "gitHead": "ec06c40c0ed64aa42d8842734a8c532f5c4603e6"
41
+ "gitHead": "bf1e1f3cfabccc1ee288c18722e33009bd001798"
42
42
  }
@@ -41,7 +41,9 @@ export function Tag({
41
41
  data-appearance={appearance}
42
42
  data-removable={Boolean(onDelete)}
43
43
  >
44
- <span className={styles.label}>{label}</span>
44
+ <span title={label} className={styles.label}>
45
+ {label}
46
+ </span>
45
47
  {onDelete && (
46
48
  <button
47
49
  type='button'
@@ -94,6 +94,7 @@ $appearances: (
94
94
  display: inline-flex;
95
95
  align-items: center;
96
96
  box-sizing: border-box;
97
+ max-width: 100%;
97
98
 
98
99
  .tagButton {
99
100
  cursor: pointer;
@@ -146,7 +147,10 @@ $appearances: (
146
147
  background-color: simple-var($appearance, 'container');
147
148
 
148
149
  .label {
150
+ overflow: hidden;
149
151
  color: simple-var($appearance, 'label');
152
+ text-overflow: ellipsis;
153
+ white-space: nowrap;
150
154
  }
151
155
 
152
156
  .tagButton {
@@ -3,6 +3,7 @@ import { Ref } from 'react';
3
3
  import { Tag } from '../../components';
4
4
  import { SIZE } from '../../constants';
5
5
  import { Size, TagRowItemInner } from '../../types';
6
+ import styles from './styles.module.scss';
6
7
 
7
8
  type SetTagRef = (item: TagRowItemInner, index: number) => Ref<HTMLDivElement>;
8
9
 
@@ -18,7 +19,7 @@ type OnDeleteHandler = () => void;
18
19
  function renderTag(size: Size, handleRemoveItem?: (item: TagRowItemInner) => OnDeleteHandler, setRef?: SetTagRef) {
19
20
  return function TagRowItem(item: TagRowItemInner, index: number) {
20
21
  return (
21
- <div key={item.label} ref={setRef?.(item, index)}>
22
+ <div key={item.label} ref={setRef?.(item, index)} className={styles.tagWrapper}>
22
23
  <Tag label={item.label} appearance={item.appearance} size={size} onDelete={handleRemoveItem?.(item)} />
23
24
  </div>
24
25
  );
@@ -0,0 +1,3 @@
1
+ .tagWrapper {
2
+ max-width: 100%;
3
+ }
@@ -70,6 +70,7 @@ function TagRowTruncatedInner({
70
70
 
71
71
  let currentRowWidth = 0;
72
72
  let currentRowCount = 1;
73
+ let currentRowVisibleTagAmount = 0;
73
74
 
74
75
  tagsMapRef.current.forEach((tagElement, tagRowItem) => {
75
76
  const tagWidth = tagElement?.offsetWidth || 0;
@@ -83,22 +84,26 @@ function TagRowTruncatedInner({
83
84
  if (currentRowCount === rowLimit) {
84
85
  if (sumRowWidth + moreButtonWidth > maxWidth) {
85
86
  currentRowCount++;
87
+ currentRowVisibleTagAmount = 0;
86
88
  newHiddenTags.push(tagRowItem);
87
89
  return;
88
90
  }
89
91
 
90
92
  currentRowWidth = sumRowWidth;
91
93
  newVisibleTags.push(tagRowItem);
94
+ currentRowVisibleTagAmount++;
92
95
  return;
93
96
  }
94
97
 
95
98
  if (sumRowWidth > maxWidth) {
96
- currentRowWidth = tagWidth + gapWidth;
99
+ currentRowWidth = currentRowVisibleTagAmount ? tagWidth + gapWidth : 0;
97
100
  currentRowCount++;
101
+ currentRowVisibleTagAmount = 0;
98
102
  newVisibleTags.push(tagRowItem);
99
103
  return;
100
104
  }
101
105
 
106
+ currentRowVisibleTagAmount++;
102
107
  currentRowWidth = sumRowWidth;
103
108
  newVisibleTags.push(tagRowItem);
104
109
  });