wave-ui 1.65.2 → 1.66.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.
@@ -113,8 +113,8 @@ const _NotificationManager$1 = class {
113
113
  if (~~notification.timeout !== 0)
114
114
  setTimeout(() => this.dismiss(notification._uid), notification.timeout);
115
115
  }
116
- dismiss(uid) {
117
- this.notifications = this.notifications.filter((item) => item._uid !== uid);
116
+ dismiss(uid2) {
117
+ this.notifications = this.notifications.filter((item) => item._uid !== uid2);
118
118
  }
119
119
  };
120
120
  let NotificationManager$1 = _NotificationManager$1;
@@ -5493,10 +5493,13 @@ var render$g = function() {
5493
5493
  var _vm = this;
5494
5494
  var _h = _vm.$createElement;
5495
5495
  var _c = _vm._self._c || _h;
5496
- return _c("div", { staticClass: "w-tabs__content" }, [_vm._t("default")], 2);
5496
+ return _c("div", { staticClass: "w-tabs__content" }, [_vm._t("default", null, { "item": _vm.item })], 2);
5497
5497
  };
5498
5498
  var staticRenderFns$g = [];
5499
- const __vue2_script$g = {};
5499
+ const __vue2_script$g = {
5500
+ name: "tab-content",
5501
+ props: { item: Object }
5502
+ };
5500
5503
  const __cssModules$g = {};
5501
5504
  var __component__$g = /* @__PURE__ */ normalizeComponent(
5502
5505
  __vue2_script$g,
@@ -5520,25 +5523,33 @@ var render$f = function() {
5520
5523
  var _vm = this;
5521
5524
  var _h = _vm.$createElement;
5522
5525
  var _c = _vm._self._c || _h;
5523
- return _c("div", { staticClass: "w-tabs", class: _vm.tabsClasses }, [_c("div", { ref: "tabs-bar", staticClass: "w-tabs__bar", class: _vm.tabsBarClasses }, [_vm._l(_vm.tabsItems, function(item, i) {
5524
- return _c("div", { key: i, staticClass: "w-tabs__bar-item", class: _vm.barItemClasses(item), attrs: { "tabindex": !item._disabled && 0, "aria-selected": item._index === _vm.activeTabIndex ? "true" : "false", "role": "tab" }, on: { "click": function($event) {
5525
- !item._disabled && _vm.openTab(item);
5526
+ return _c("div", { staticClass: "w-tabs", class: _vm.tabsClasses }, [_c("div", { ref: "tabs-bar", staticClass: "w-tabs__bar", class: _vm.tabsBarClasses }, [_vm._l(_vm.tabs, function(tab, i) {
5527
+ return _c("div", { key: i, staticClass: "w-tabs__bar-item", class: _vm.barItemClasses(tab), attrs: { "tabindex": !tab._disabled && 0, "aria-selected": tab._uid === _vm.activeTabUid ? "true" : "false", "role": "tab" }, on: { "click": function($event) {
5528
+ !tab._disabled && tab._uid !== _vm.activeTabUid && _vm.openTab(tab._uid);
5526
5529
  }, "focus": function($event) {
5527
- _vm.$emit("focus", _vm.getOriginalItem(item));
5530
+ _vm.$emit("focus", _vm.getOriginalItem(tab));
5528
5531
  }, "keypress": function($event) {
5529
5532
  if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")) {
5530
5533
  return null;
5531
5534
  }
5532
- !item._disabled && _vm.openTab(item);
5533
- } } }, [_vm.$scopedSlots["item-title." + (item.id || i + 1)] ? _vm._t("item-title." + (item.id || i + 1), null, { "item": _vm.getOriginalItem(item), "index": i + 1, "active": item._index === _vm.activeTabIndex }) : _vm._t("item-title", function() {
5534
- return [_c("div", { domProps: { "innerHTML": _vm._s(item[_vm.itemTitleKey]) } })];
5535
- }, { "item": _vm.getOriginalItem(item), "index": i + 1, "active": item._index === _vm.activeTabIndex })], 2);
5536
- }), _vm.$scopedSlots["tabs-bar-extra"] ? _c("div", { staticClass: "w-tabs__bar-extra" }, [_vm._t("tabs-bar-extra")], 2) : _vm._e(), !_vm.noSlider && !_vm.card ? _c("div", { staticClass: "w-tabs__slider", class: _vm.sliderColor, style: _vm.sliderStyles }) : _vm._e()], 2), _vm.tabsItems.length ? _c("div", { staticClass: "w-tabs__content-wrap" }, [_c("transition", { attrs: { "name": _vm.transitionName, "mode": _vm.transitionMode } }, [_c("keep-alive", [_c("tab-content", { key: _vm.activeTab._index, class: _vm.contentClass }, [_vm.$scopedSlots["item-content." + (_vm.activeTab.id || _vm.activeTab._index + 1)] ? _vm._t("item-content." + (_vm.activeTab.id || _vm.activeTab._index + 1), null, { "item": _vm.getOriginalItem(_vm.activeTab), "index": _vm.activeTab._index + 1, "active": _vm.activeTab._index === _vm.activeTabIndex }) : _vm._t("item-content", function() {
5537
- return [_c("div", { domProps: { "innerHTML": _vm._s(_vm.activeTab[_vm.itemContentKey]) } })];
5538
- }, { "item": _vm.getOriginalItem(_vm.activeTab), "index": _vm.activeTab._index + 1, "active": _vm.activeTab._index === _vm.activeTabIndex })], 2)], 1)], 1)], 1) : _vm._e()]);
5535
+ !tab._disabled && _vm.openTab(tab._uid);
5536
+ } } }, [_vm.$scopedSlots["item-title." + (tab.id || i + 1)] ? _vm._t("item-title." + (tab.id || i + 1), null, { "item": _vm.getOriginalItem(tab), "index": i + 1, "active": tab._uid === _vm.activeTabUid }) : _vm._t("item-title", function() {
5537
+ return [_c("div", { domProps: { "innerHTML": _vm._s(tab[_vm.itemTitleKey]) } })];
5538
+ }, { "item": _vm.getOriginalItem(tab), "index": i + 1, "active": tab._uid === _vm.activeTabUid })], 2);
5539
+ }), _vm.$scopedSlots["tabs-bar-extra"] ? _c("div", { staticClass: "w-tabs__bar-extra" }, [_vm._t("tabs-bar-extra")], 2) : _vm._e(), !_vm.noSlider && !_vm.card ? _c("div", { staticClass: "w-tabs__slider", class: _vm.sliderColor, style: _vm.sliderStyles }) : _vm._e()], 2), _vm.keepInDom ? _c("transition-group", { staticClass: "w-tabs__content-wrap", attrs: { "name": _vm.transitionName, "tag": "div" } }, _vm._l(_vm.tabs, function(tab, i) {
5540
+ return _c("tab-content", { directives: [{ name: "show", rawName: "v-show", value: tab._uid === _vm.activeTab._uid, expression: "tab._uid === activeTab._uid" }], key: tab._uid, class: _vm.contentClass, attrs: { "item": tab } }, [_vm.$scopedSlots["item-content." + (tab._index + 1)] ? _vm._t("item-content." + (tab._index + 1), null, { "item": _vm.getOriginalItem(tab), "index": tab._index + 1, "active": tab._index === _vm.activeTab._index }) : _vm._t("item-content", function() {
5541
+ return [tab[_vm.itemContentKey] ? _c("div", { domProps: { "innerHTML": _vm._s(tab[_vm.itemContentKey]) } }) : _vm._e()];
5542
+ }, { "item": _vm.getOriginalItem(tab), "index": tab._index + 1, "active": tab._index === _vm.activeTab._index })], 2);
5543
+ }), 1) : _c("div", { staticClass: "w-tabs__content-wrap" }, [_c("transition", { attrs: { "name": _vm.transitionName, "mode": _vm.transitionMode } }, [_c("keep-alive", { attrs: { "exclude": _vm.keepAlive ? "" : "tab-content" } }, [_c("tab-content", { key: _vm.activeTabUid, class: _vm.contentClass, attrs: { "item": _vm.activeTab }, scopedSlots: _vm._u([{ key: "default", fn: function(ref) {
5544
+ var item = ref.item;
5545
+ return [item ? [_vm.$scopedSlots["item-content." + (item._index + 1)] ? _vm._t("item-content." + (item._index + 1), null, { "item": _vm.getOriginalItem(item), "index": item._index + 1, "active": item._uid === _vm.activeTabUid }) : _vm._t("item-content", function() {
5546
+ return [item[_vm.itemContentKey] ? _c("div", { domProps: { "innerHTML": _vm._s(item[_vm.itemContentKey]) } }) : _vm._e()];
5547
+ }, { "item": _vm.getOriginalItem(item), "index": item._index + 1, "active": item._uid === _vm.activeTabUid })] : _vm._e()];
5548
+ } }], null, true) })], 1)], 1)], 1)], 1);
5539
5549
  };
5540
5550
  var staticRenderFns$f = [];
5541
5551
  var index_vue_vue_type_style_index_0_lang = "";
5552
+ let uid = 0;
5542
5553
  const __vue2_script$f = {
5543
5554
  name: "w-tabs",
5544
5555
  props: {
@@ -5546,6 +5557,7 @@ const __vue2_script$f = {
5546
5557
  color: { type: String },
5547
5558
  bgColor: { type: String },
5548
5559
  items: { type: [Array, Number] },
5560
+ itemIdKey: { type: String, default: "id" },
5549
5561
  itemTitleKey: { type: String, default: "title" },
5550
5562
  itemContentKey: { type: String, default: "content" },
5551
5563
  titleClass: { type: String },
@@ -5558,12 +5570,16 @@ const __vue2_script$f = {
5558
5570
  fillBar: { type: Boolean },
5559
5571
  center: { type: Boolean },
5560
5572
  right: { type: Boolean },
5561
- card: { type: Boolean }
5573
+ card: { type: Boolean },
5574
+ keepAlive: { type: Boolean, default: true },
5575
+ keepInDom: { type: Boolean, default: false }
5562
5576
  },
5563
5577
  components: { TabContent },
5564
5578
  emits: ["input", "update:modelValue", "focus"],
5565
5579
  data: () => ({
5580
+ tabs: [],
5566
5581
  activeTabEl: null,
5582
+ activeTabUid: null,
5567
5583
  activeTabIndex: 0,
5568
5584
  prevTabIndex: -1,
5569
5585
  slider: {
@@ -5584,16 +5600,11 @@ const __vue2_script$f = {
5584
5600
  direction() {
5585
5601
  return this.activeTab._index < this.prevTabIndex ? "right" : "left";
5586
5602
  },
5587
- tabsItems() {
5588
- const items = typeof this.items === "number" ? Array(this.items).fill({}) : this.items;
5589
- return items.map((item, _index) => new Vue.observable({
5590
- ...item,
5591
- _index,
5592
- _disabled: !!item.disabled
5593
- }));
5594
- },
5595
5603
  activeTab() {
5596
- return this.tabsItems[this.activeTabIndex] || this.tabsItems[0] || {};
5604
+ return this.tabsByUid[this.activeTabUid] || this.tabs[0] || {};
5605
+ },
5606
+ tabsByUid() {
5607
+ return this.tabs.reduce((obj, tab) => (obj[tab._uid] = tab) && obj, {});
5597
5608
  },
5598
5609
  tabsClasses() {
5599
5610
  return {
@@ -5618,6 +5629,45 @@ const __vue2_script$f = {
5618
5629
  }
5619
5630
  },
5620
5631
  methods: {
5632
+ addTab(item) {
5633
+ var _a, _b, _c;
5634
+ if (!((_b = (_a = item[this.itemIdKey]) != null ? _a : item._uid) != null ? _b : false))
5635
+ item._uid = +`${this._uid}${++uid}`;
5636
+ this.tabs.push({
5637
+ _uid: (_c = item[this.itemIdKey]) != null ? _c : item._uid,
5638
+ _index: this.tabs.length,
5639
+ ...item,
5640
+ _disabled: !!item.disabled
5641
+ });
5642
+ },
5643
+ refreshTabs() {
5644
+ let items = this.items;
5645
+ if (typeof items === "number")
5646
+ items = Array(items).fill().map((_, i) => this.tabs[i] || {});
5647
+ this.tabs = items.map((item, _index) => {
5648
+ var _a, _b, _c;
5649
+ if (!((_b = (_a = item[this.itemIdKey]) != null ? _a : item._uid) != null ? _b : false))
5650
+ item._uid = +`${this._uid}${++uid}`;
5651
+ return {
5652
+ ...item,
5653
+ _uid: (_c = item[this.itemIdKey]) != null ? _c : item._uid,
5654
+ _index,
5655
+ _disabled: !!item.disabled
5656
+ };
5657
+ });
5658
+ },
5659
+ reopenTheActiveTab() {
5660
+ var _a, _b, _c;
5661
+ if (this.tabs.length === 1)
5662
+ return this.openTab(this.tabs[0]._uid);
5663
+ let uid2 = (_a = this.tabsByUid[this.activeTabUid]) == null ? void 0 : _a._uid;
5664
+ if (!uid2)
5665
+ uid2 = (_b = this.tabs[this.activeTabIndex]) == null ? void 0 : _b._uid;
5666
+ if (!uid2)
5667
+ uid2 = (_c = this.tabs[Math.max(this.activeTabIndex - 1, this.tabs.length - 1)]) == null ? void 0 : _c._uid;
5668
+ if (uid2)
5669
+ this.openTab(uid2);
5670
+ },
5621
5671
  onResize() {
5622
5672
  this.updateSlider(false);
5623
5673
  },
@@ -5631,17 +5681,20 @@ const __vue2_script$f = {
5631
5681
  [this.titleClass]: this.titleClass
5632
5682
  };
5633
5683
  },
5634
- openTab(item) {
5684
+ openTab(uid2) {
5635
5685
  this.prevTabIndex = this.activeTabIndex;
5636
- this.activeTabIndex = item._index;
5637
- this.$emit("update:modelValue", item._index);
5638
- this.$emit("input", item._index);
5686
+ const tab = this.tabsByUid[uid2];
5687
+ this.activeTabIndex = tab._index;
5688
+ this.activeTabUid = tab._uid;
5689
+ this.$emit("update:modelValue", tab._index);
5690
+ this.$emit("input", tab._index);
5639
5691
  if (!this.noSlider)
5640
5692
  this.$nextTick(this.updateSlider);
5641
5693
  },
5642
5694
  updateSlider(domLookup = true) {
5643
5695
  if (domLookup) {
5644
- this.activeTabEl = this.$refs["tabs-bar"].querySelector(".w-tabs__bar-item--active");
5696
+ const ref = this.$refs["tabs-bar"];
5697
+ this.activeTabEl = ref && ref.querySelector(".w-tabs__bar-item--active");
5645
5698
  }
5646
5699
  if (!this.fillBar && this.activeTabEl) {
5647
5700
  const { left, width } = this.activeTabEl.getBoundingClientRect();
@@ -5651,30 +5704,38 @@ const __vue2_script$f = {
5651
5704
  this.slider.left = `${left - parentLeft - parseInt(borderLeftWidth) + tabsBar.scrollLeft}px`;
5652
5705
  this.slider.width = `${width}px`;
5653
5706
  } else {
5654
- this.slider.left = `${this.activeTab._index * 100 / this.tabsItems.length}%`;
5655
- this.slider.width = `${100 / this.tabsItems.length}%`;
5707
+ this.slider.left = `${this.activeTab._index * 100 / this.tabs.length}%`;
5708
+ this.slider.width = `${100 / this.tabs.length}%`;
5656
5709
  }
5657
5710
  },
5658
5711
  updateActiveTab(index2) {
5712
+ var _a, _b;
5659
5713
  if (typeof index2 === "string")
5660
5714
  index2 = ~~index2;
5661
5715
  else if (isNaN(index2) || index2 < 0)
5662
5716
  index2 = 0;
5663
- this.activeTabIndex = index2;
5664
- this.$nextTick(() => {
5665
- const ref = this.$refs["tabs-bar"];
5666
- this.activeTabEl = ref && ref.querySelector(`.w-tabs__bar-item:nth-child(${index2 + 1})`);
5667
- if (this.activeTabEl) {
5668
- this.activeTabEl.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
5669
- }
5670
- });
5717
+ if ((_a = this.tabs[index2]) == null ? void 0 : _a._uid) {
5718
+ this.openTab((_b = this.tabs[index2]) == null ? void 0 : _b._uid);
5719
+ this.$nextTick(() => {
5720
+ const ref = this.$refs["tabs-bar"];
5721
+ this.activeTabEl = ref && ref.querySelector(`.w-tabs__bar-item:nth-child(${index2 + 1})`);
5722
+ if (this.activeTabEl) {
5723
+ this.activeTabEl.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
5724
+ }
5725
+ });
5726
+ }
5671
5727
  },
5672
5728
  getOriginalItem(item) {
5673
- return this.items[item._index];
5729
+ return this.items[item._index] || {};
5674
5730
  }
5675
5731
  },
5676
5732
  beforeMount() {
5677
- this.updateActiveTab(this.value);
5733
+ var _a;
5734
+ this.tabs = [];
5735
+ const items = typeof this.items === "number" ? Array(this.items).fill().map(Object) : this.items;
5736
+ items.forEach(this.addTab);
5737
+ if ((_a = this.value) != null ? _a : false)
5738
+ this.updateActiveTab(this.value);
5678
5739
  this.$nextTick(() => {
5679
5740
  this.updateSlider();
5680
5741
  setTimeout(() => this.init = false, 0);
@@ -5687,13 +5748,18 @@ const __vue2_script$f = {
5687
5748
  },
5688
5749
  watch: {
5689
5750
  value(index2) {
5690
- this.updateActiveTab(index2);
5751
+ if (index2 !== this.activeTabIndex)
5752
+ this.updateActiveTab(index2);
5691
5753
  },
5692
- items() {
5693
- while (this.activeTabIndex > 0 && !this.tabsItems[this.activeTabIndex])
5694
- this.activeTabIndex--;
5695
- if (!this.noSlider)
5696
- this.$nextTick(this.updateSlider);
5754
+ items: {
5755
+ handler() {
5756
+ this.refreshTabs();
5757
+ if (this.tabs.length)
5758
+ this.reopenTheActiveTab();
5759
+ if (!this.noSlider)
5760
+ this.$nextTick(this.updateSlider);
5761
+ },
5762
+ deep: true
5697
5763
  },
5698
5764
  fillBar() {
5699
5765
  if (!this.noSlider)
@@ -5898,10 +5964,10 @@ const __vue2_script$e = {
5898
5964
  return this.headers.find((header) => header.sticky);
5899
5965
  },
5900
5966
  selectedRowsByUid() {
5901
- return this.selectedRowsInternal.reduce((obj, uid) => (obj[uid] = true) && obj, {});
5967
+ return this.selectedRowsInternal.reduce((obj, uid2) => (obj[uid2] = true) && obj, {});
5902
5968
  },
5903
5969
  expandedRowsByUid() {
5904
- return this.expandedRowsInternal.reduce((obj, uid) => (obj[uid] = true) && obj, {});
5970
+ return this.expandedRowsInternal.reduce((obj, uid2) => (obj[uid2] = true) && obj, {});
5905
5971
  }
5906
5972
  },
5907
5973
  methods: {
@@ -5943,14 +6009,14 @@ const __vue2_script$e = {
5943
6009
  else
5944
6010
  this.expandedRowsInternal.push(item._uid);
5945
6011
  } else
5946
- this.expandedRowsInternal = this.expandedRowsInternal.filter((uid) => uid !== item._uid);
6012
+ this.expandedRowsInternal = this.expandedRowsInternal.filter((uid2) => uid2 !== item._uid);
5947
6013
  this.$emit(
5948
6014
  "row-expand",
5949
6015
  {
5950
6016
  item,
5951
6017
  index: index2,
5952
6018
  expanded: isExpanding,
5953
- expandedRows: this.expandedRowsInternal.map((uid) => this.filteredItems[uid])
6019
+ expandedRows: this.expandedRowsInternal.map((uid2) => this.filteredItems[uid2])
5954
6020
  }
5955
6021
  );
5956
6022
  this.$emit("update:expanded-rows", this.expandedRowsInternal);
@@ -5964,7 +6030,7 @@ const __vue2_script$e = {
5964
6030
  this.selectedRowsInternal.push(item._uid);
5965
6031
  updated = true;
5966
6032
  } else if (!this.forceSelection || this.selectedRowsInternal.length > 1) {
5967
- this.selectedRowsInternal = this.selectedRowsInternal.filter((uid) => uid !== item._uid);
6033
+ this.selectedRowsInternal = this.selectedRowsInternal.filter((uid2) => uid2 !== item._uid);
5968
6034
  updated = true;
5969
6035
  }
5970
6036
  if (updated) {
@@ -5974,7 +6040,7 @@ const __vue2_script$e = {
5974
6040
  item,
5975
6041
  index: index2,
5976
6042
  selected: isSelecting,
5977
- selectedRows: this.selectedRowsInternal.map((uid) => this.filteredItems[uid])
6043
+ selectedRows: this.selectedRowsInternal.map((uid2) => this.filteredItems[uid2])
5978
6044
  }
5979
6045
  );
5980
6046
  this.$emit("update:selected-rows", this.selectedRowsInternal);