mediacube-ui 0.1.148 → 0.1.149

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.149](https://github.com/MediaCubeCo/mcui/compare/v0.1.148...v0.1.149) (2023-10-02)
6
+
5
7
  ### [0.1.148](https://github.com/MediaCubeCo/mcui/compare/v0.1.147...v0.1.148) (2023-10-02)
6
8
 
7
9
  ### [0.1.147](https://github.com/MediaCubeCo/mcui/compare/v0.1.146...v0.1.147) (2023-09-28)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediacube-ui",
3
- "version": "0.1.148",
3
+ "version": "0.1.149",
4
4
  "description": "Design system for Mediacube services",
5
5
  "author": "Mediacube",
6
6
  "private": false,
@@ -285,7 +285,7 @@ export default {
285
285
  ref: 'xTable',
286
286
  'context-menu': this.tableMenu,
287
287
  class: this.classes,
288
- // 'sync-resize': this.cardIsOpen,
288
+ 'sync-resize': this.cardIsOpen,
289
289
  'scroll-y': this.scrollY,
290
290
  'show-footer': this.canShowFooter,
291
291
  'footer-method': this.footerMethod,
@@ -376,7 +376,7 @@ export default {
376
376
  return this.$listeners['cell-click'] && this.contextMenu ? menu : false
377
377
  },
378
378
  columnsForFirstLoad() {
379
- return new Array(20).fill('').map(() => new Array(30).fill(''))
379
+ return new Array(20).fill('').map(() => new Array(20).fill(''))
380
380
  },
381
381
  },
382
382
  watch: {
@@ -384,17 +384,21 @@ export default {
384
384
  newValue && this.updateData()
385
385
  },
386
386
  totalFooter: {
387
- handler(newVal) {
388
- newVal && this.loadData(true)
387
+ handler: async function(newVal) {
388
+ newVal && (await this.loadData(true))
389
389
  },
390
390
  deep: true,
391
391
  },
392
392
  items: {
393
- handler(newVal) {
394
- newVal && this.loadData(true)
393
+ handler: async function(newVal) {
394
+ newVal && (await this.loadData(true))
395
+ newVal && (await this.setFirstColsWidth())
395
396
  },
396
397
  deep: true,
397
398
  },
399
+ cardIsOpen(newVal) {
400
+ this.toggleColumns(newVal)
401
+ },
398
402
  '$attrs.loading'() {
399
403
  this.checkHorizontalScroll()
400
404
  },
@@ -489,15 +493,38 @@ export default {
489
493
  this.observer && loader.length && this.observer.observe(loader[0])
490
494
  },
491
495
  setFirstColsWidth() {
492
- if (!this.api) return 0
493
- const firstCol = this.api.getColumns().find(c => c.fixed === 'left')
494
- this.firstColsWidth = +firstCol?.width || +firstCol?.minWidth || 0
496
+ const columns = this.$refs.xTable.getColumns()
497
+ const leftFixedColumnsWidth = columns.reduce((sum, curr) => {
498
+ if (curr.fixed === 'left') {
499
+ return sum + Number(curr.width || curr.minWidth)
500
+ }
501
+ return sum
502
+ }, 0)
503
+ if (leftFixedColumnsWidth) {
504
+ this.firstColsWidth = leftFixedColumnsWidth + 5 // 5 - ширина скролла
505
+ }
495
506
  },
496
507
  toggleColumns(val) {
497
508
  if (val) {
498
- this.api.getColumns().forEach(col => {
499
- col.fixed !== 'left' && (col.visible = false)
509
+ const columns = this.$refs.xTable.getColumns()
510
+ let fixedColNeigbhorIndex
511
+ const hideColumns = columns.filter((col, i) => {
512
+ const isFixedCol = col.fixed === 'left'
513
+ /**
514
+ * Скрываем все столбцы кроме фиксированного и его соседа, чтобы не было рассинхрона при выходе из карточки
515
+ * т.к. когда остается 1 столбец, то фикс - размаунтится, а потом при выходе из карточки перерендеривается
516
+ * и скроллит в самый верх
517
+ * */
518
+ if (isFixedCol) fixedColNeigbhorIndex = i + 1
519
+ switch (true) {
520
+ case i === fixedColNeigbhorIndex:
521
+ return
522
+ default:
523
+ return !isFixedCol
524
+ }
525
+ return !isFixedCol
500
526
  })
527
+ hideColumns.forEach(col => (col.visible = false))
501
528
  this.$refs.xTable.refreshColumn()
502
529
  } else {
503
530
  this.$refs.xTable.resetColumn()
@@ -816,13 +843,5 @@ export default {
816
843
  background-position: 468px 0;
817
844
  }
818
845
  }
819
- @keyframes placeHolderShimmer {
820
- 0% {
821
- background-position: -468px 0;
822
- }
823
- 100% {
824
- background-position: 468px 0;
825
- }
826
- }
827
846
  }
828
847
  </style>