mediacube-ui 0.1.317 → 0.1.318

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.318](https://github.com/MediaCubeCo/mcui/compare/v0.1.317...v0.1.318) (2024-10-09)
6
+
5
7
  ### [0.1.317](https://github.com/MediaCubeCo/mcui/compare/v0.1.316...v0.1.317) (2024-10-04)
6
8
 
7
9
  ### [0.1.316](https://github.com/MediaCubeCo/mcui/compare/v0.1.315...v0.1.316) (2024-09-24)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediacube-ui",
3
- "version": "0.1.317",
3
+ "version": "0.1.318",
4
4
  "description": "Design system for Mediacube services",
5
5
  "author": "Mediacube",
6
6
  "private": false,
@@ -431,12 +431,15 @@ export default {
431
431
  'mc-field-select--error': this.errorText,
432
432
  'mc-field-select--disabled': this.disabled,
433
433
  [`mc-field-select--bg-${this.backgroundColor}`]: this.backgroundColor,
434
- 'mc-field-select--is-empty-options-list': this.isEmptyOptionsList || this.loading,
434
+ 'mc-field-select--is-empty-options-list': this.isEmptyOptions,
435
435
  'mc-field-select--with-preview': this.optionWithPreview,
436
436
  'mc-field-select--max-height': this.maxHeight,
437
437
  'mc-field-select--rtl': this.rtl,
438
438
  }
439
439
  },
440
+ isEmptyOptions() {
441
+ return this.isEmptyOptionsList || this.loading || this.computedOptions?.length === this._value?.length
442
+ },
440
443
  computedTitle() {
441
444
  return `${this.title}${this.required ? ' *' : ''}`
442
445
  },
@@ -659,18 +662,31 @@ export default {
659
662
  this.custom_limit = Infinity
660
663
  let child_width = 0
661
664
  const parent = this.$refs[this.key]?.$refs?.tags?.firstChild
665
+ if (!this.value?.length) return
666
+ const limit_text_width = this.getLimitTextWidth() // Получаем ширину текста лимита
667
+ const total_width = +parent?.clientWidth - +limit_text_width
662
668
  for (let i = 0; i < this.value?.length; i++) {
663
669
  const children = parent?.children?.[i]
664
- const elemStyle = window.getComputedStyle(children)
665
- child_width += +children?.clientWidth + +parseInt(elemStyle.marginRight)
670
+ const elem_style = window.getComputedStyle(children)
671
+ child_width += children?.clientWidth + (parseInt(elem_style?.marginRight) || 0)
666
672
  // считаем занимаемую дочерними элементами ширину, если превышает родительскую, то выходим из цикла и ставим лимит
667
- if (child_width > +parent?.clientWidth) {
673
+ if (+child_width > +total_width) {
668
674
  this.custom_limit = i
669
675
  break
670
676
  }
671
677
  }
672
678
  })
673
679
  },
680
+ getLimitTextWidth() {
681
+ const temp_limit_element = document.createElement('div')
682
+ temp_limit_element.style.visibility = 'hidden'
683
+ temp_limit_element.style.position = 'absolute'
684
+ temp_limit_element.innerText = `+${this.value?.length}` // Устанавливаем текст лимита
685
+ document.body.appendChild(temp_limit_element)
686
+ const limit_text_width = temp_limit_element.clientWidth
687
+ document.body.removeChild(temp_limit_element)
688
+ return limit_text_width
689
+ },
674
690
  toggleOptions() {
675
691
  this.is_show_all_options = !this.is_show_all_options
676
692
  },
@@ -817,6 +833,7 @@ export default {
817
833
  }
818
834
 
819
835
  &__tags-wrap {
836
+ width: 100%;
820
837
  position: relative;
821
838
  padding-top: 4px;
822
839
  padding-bottom: 3px;