itube-specs 0.0.933 → 0.0.935

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.
@@ -16,9 +16,10 @@
16
16
  class="ui-chips-micro__list"
17
17
  >
18
18
  <UiChips
19
- v-for="item in tags"
19
+ v-for="(item, index) in tags"
20
20
  :key="item.title"
21
21
  :item="item"
22
+ :class="{'--beyond-line': isOverflow && index >= visibleCount}"
22
23
  class="ui-chips-micro__item"
23
24
  micro
24
25
  is-link
@@ -108,6 +109,9 @@ const moreLabel = computed(() => props.label ?? t('show_all'));
108
109
 
109
110
  const GAP = 8;
110
111
 
112
+ /** Ширина кнопки «+N», держать в согласии с $more-width в стилях */
113
+ const MORE_WIDTH = 44;
114
+
111
115
  const isOverflow = ref(false);
112
116
  const moreLeft = ref(0);
113
117
  const visibleCount = ref(0);
@@ -133,16 +137,22 @@ function measure() {
133
137
  const chips = Array.from(el.children) as HTMLElement[];
134
138
  const firstLineTop = chips[ 0 ]?.offsetTop ?? 0;
135
139
 
136
- let lastInLine = chips[ 0 ];
137
140
  let count = 0;
138
141
  for (const chip of chips) {
139
142
  if (chip.offsetTop !== firstLineTop) break;
140
- lastInLine = chip;
141
143
  count += 1;
142
144
  }
143
145
 
146
+ // Зазор после последней плашки бывает уже кнопки — тогда кнопка наползла бы на плашку, а короткую
147
+ // накрыла бы целиком, и та пропала бы совсем: в счётчик не попала, в панель тоже. Отдаём её в панель.
148
+ const rowEnd = (index: number) => chips[ index ].offsetLeft + chips[ index ].offsetWidth + GAP;
149
+
150
+ while (count > 1 && rowEnd(count - 1) + MORE_WIDTH > el.clientWidth) {
151
+ count -= 1;
152
+ }
153
+
144
154
  visibleCount.value = count;
145
- moreLeft.value = lastInLine ? lastInLine.offsetLeft + lastInLine.offsetWidth + GAP : 0;
155
+ moreLeft.value = count > 0 ? rowEnd(count - 1) : 0;
146
156
  }
147
157
 
148
158
  useChipsOverflow(listRef, measure);
@@ -155,7 +165,7 @@ onClickOutside(rootRef, () => {
155
165
  <style lang="scss">
156
166
  $fade-width: 40px;
157
167
 
158
- // Резерв под кнопку «+N» в конце строки: 20px паддингов плюс место на «+» и две цифры
168
+ // Ширина кнопки «+N» под ограничитель позиции: 20px паддингов плюс место на «+» и две цифры
159
169
  $more-width: 44px;
160
170
 
161
171
  @property --ui-chips-micro-fade-start {
@@ -208,12 +218,12 @@ $more-width: 44px;
208
218
  scrollbar-width: none;
209
219
 
210
220
  /* Десктоп: не скролл, а перенос, обрезанный по первой строке. Обрезка через overflow: hidden —
211
- контейнер не прокручиваемый, колесо мыши не перехватывает. Место справа под «+» даёт паддинг. */
221
+ контейнер не прокручиваемый, колесо мыши не перехватывает. Места под «+N» не резервируем:
222
+ паддинг сужал бы строку и сам гнал бы на перенос плашку, которая иначе влезала. */
212
223
  @include from-br(sm) {
213
224
  flex-wrap: wrap;
214
225
  align-content: flex-start;
215
226
  max-height: var(--chips-height-micro);
216
- padding-right: $more-width;
217
227
  overflow: hidden;
218
228
  }
219
229
 
@@ -226,12 +236,21 @@ $more-width: 44px;
226
236
  flex-shrink: 0;
227
237
  }
228
238
 
239
+ /* Плашка, отданная в панель, но физически стоящая в первой строке. Гасим через visibility, а не
240
+ display: она обязана сохранить своё место — иначе следующие подтянутся и замер уедет по кругу. */
241
+ .ui-chips-micro__item.--beyond-line {
242
+ visibility: hidden;
243
+ }
244
+
229
245
  .ui-chips-micro__more {
230
246
  @include font-xs;
231
247
 
232
248
  position: absolute;
233
249
  inset-block: 0;
234
- left: var(--ui-chips-micro-more-left, 0);
250
+
251
+ /* Кнопка встаёт в зазор после последней влезшей плашки. Зазор бывает уже кнопки — тогда
252
+ упираем её в правый край, край последней плашки уходит под неё. */
253
+ left: min(var(--ui-chips-micro-more-left, 0px), 100% - #{$more-width});
235
254
  z-index: $z-index-dropdown;
236
255
  display: grid;
237
256
  place-content: center;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.933",
4
+ "version": "0.0.935",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {