wave-ui 1.65.1 → 1.66.0

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;
@@ -878,7 +878,7 @@ var render$Q = function() {
878
878
  var _c = _vm._self._c || _h;
879
879
  return _c("transition-group", { staticClass: "w-notification-manager", class: { "w-notification-manager--left": _vm.conf.align === "left" }, attrs: { "tag": "div", "name": _vm.transition, "appear": "" } }, [_vm._l(_vm.notifications, function(notif) {
880
880
  return [notif._value ? _c("w-alert", _vm._b({ key: notif._uid, staticClass: "white--bg", on: { "close": function($event) {
881
- return _vm.notifManager.dismiss(notif._uid);
881
+ return _vm.$waveui._notificationManager.dismiss(notif._uid);
882
882
  } }, model: { value: notif._value, callback: function($$v) {
883
883
  _vm.$set(notif, "_value", $$v);
884
884
  }, expression: "notif._value" } }, "w-alert", _vm.notifProps(notif), false), [_c("div", { domProps: { "innerHTML": _vm._s(notif.message) } })]) : _vm._e()];
@@ -888,16 +888,12 @@ var staticRenderFns$Q = [];
888
888
  var wNotificationManager_vue_vue_type_style_index_0_lang = "";
889
889
  const __vue2_script$Q = {
890
890
  name: "w-notification-manager",
891
- data: () => ({
892
- notifManager: null
893
- }),
894
891
  computed: {
895
892
  conf() {
896
893
  return this.$waveui.config.notificationManager;
897
894
  },
898
895
  notifications() {
899
- var _a;
900
- return ((_a = this.notifManager) == null ? void 0 : _a.notifications) || [];
896
+ return this.$waveui._notificationManager.notifications || [];
901
897
  },
902
898
  transition() {
903
899
  return this.conf.transition ? this.conf.transition.replace("default", `slide-${this.conf.align === "left" ? "right" : "left"}`) : "";
@@ -908,13 +904,6 @@ const __vue2_script$Q = {
908
904
  const { _value, _uid: _uid2, message, timeout, ...props } = notif;
909
905
  return props;
910
906
  }
911
- },
912
- created() {
913
- this.notifManager = new NotificationManager$1();
914
- },
915
- beforeUnmount() {
916
- this.notifManager.notifications = [];
917
- delete this.notifManager;
918
907
  }
919
908
  };
920
909
  const __cssModules$Q = {};
@@ -5504,10 +5493,13 @@ var render$g = function() {
5504
5493
  var _vm = this;
5505
5494
  var _h = _vm.$createElement;
5506
5495
  var _c = _vm._self._c || _h;
5507
- 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);
5508
5497
  };
5509
5498
  var staticRenderFns$g = [];
5510
- const __vue2_script$g = {};
5499
+ const __vue2_script$g = {
5500
+ name: "tab-content",
5501
+ props: { item: Object }
5502
+ };
5511
5503
  const __cssModules$g = {};
5512
5504
  var __component__$g = /* @__PURE__ */ normalizeComponent(
5513
5505
  __vue2_script$g,
@@ -5531,25 +5523,33 @@ var render$f = function() {
5531
5523
  var _vm = this;
5532
5524
  var _h = _vm.$createElement;
5533
5525
  var _c = _vm._self._c || _h;
5534
- 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) {
5535
- 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) {
5536
- !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);
5537
5529
  }, "focus": function($event) {
5538
- _vm.$emit("focus", _vm.getOriginalItem(item));
5530
+ _vm.$emit("focus", _vm.getOriginalItem(tab));
5539
5531
  }, "keypress": function($event) {
5540
5532
  if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")) {
5541
5533
  return null;
5542
5534
  }
5543
- !item._disabled && _vm.openTab(item);
5544
- } } }, [_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() {
5545
- return [_c("div", { domProps: { "innerHTML": _vm._s(item[_vm.itemTitleKey]) } })];
5546
- }, { "item": _vm.getOriginalItem(item), "index": i + 1, "active": item._index === _vm.activeTabIndex })], 2);
5547
- }), _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() {
5548
- return [_c("div", { domProps: { "innerHTML": _vm._s(_vm.activeTab[_vm.itemContentKey]) } })];
5549
- }, { "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.tabs.length ? _c("div", { staticClass: "w-tabs__content-wrap" }, [_vm.keepInDom ? _c("transition-group", { attrs: { "name": _vm.transitionName } }, _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("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) : _vm._e()]);
5550
5549
  };
5551
5550
  var staticRenderFns$f = [];
5552
5551
  var index_vue_vue_type_style_index_0_lang = "";
5552
+ let uid = 0;
5553
5553
  const __vue2_script$f = {
5554
5554
  name: "w-tabs",
5555
5555
  props: {
@@ -5557,6 +5557,7 @@ const __vue2_script$f = {
5557
5557
  color: { type: String },
5558
5558
  bgColor: { type: String },
5559
5559
  items: { type: [Array, Number] },
5560
+ itemIdKey: { type: String, default: "id" },
5560
5561
  itemTitleKey: { type: String, default: "title" },
5561
5562
  itemContentKey: { type: String, default: "content" },
5562
5563
  titleClass: { type: String },
@@ -5569,12 +5570,16 @@ const __vue2_script$f = {
5569
5570
  fillBar: { type: Boolean },
5570
5571
  center: { type: Boolean },
5571
5572
  right: { type: Boolean },
5572
- card: { type: Boolean }
5573
+ card: { type: Boolean },
5574
+ keepAlive: { type: Boolean, default: true },
5575
+ keepInDom: { type: Boolean, default: false }
5573
5576
  },
5574
5577
  components: { TabContent },
5575
5578
  emits: ["input", "update:modelValue", "focus"],
5576
5579
  data: () => ({
5580
+ tabs: [],
5577
5581
  activeTabEl: null,
5582
+ activeTabUid: null,
5578
5583
  activeTabIndex: 0,
5579
5584
  prevTabIndex: -1,
5580
5585
  slider: {
@@ -5595,16 +5600,11 @@ const __vue2_script$f = {
5595
5600
  direction() {
5596
5601
  return this.activeTab._index < this.prevTabIndex ? "right" : "left";
5597
5602
  },
5598
- tabsItems() {
5599
- const items = typeof this.items === "number" ? Array(this.items).fill({}) : this.items;
5600
- return items.map((item, _index) => new Vue.observable({
5601
- ...item,
5602
- _index,
5603
- _disabled: !!item.disabled
5604
- }));
5605
- },
5606
5603
  activeTab() {
5607
- 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, {});
5608
5608
  },
5609
5609
  tabsClasses() {
5610
5610
  return {
@@ -5629,6 +5629,45 @@ const __vue2_script$f = {
5629
5629
  }
5630
5630
  },
5631
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
+ },
5632
5671
  onResize() {
5633
5672
  this.updateSlider(false);
5634
5673
  },
@@ -5642,17 +5681,20 @@ const __vue2_script$f = {
5642
5681
  [this.titleClass]: this.titleClass
5643
5682
  };
5644
5683
  },
5645
- openTab(item) {
5684
+ openTab(uid2) {
5646
5685
  this.prevTabIndex = this.activeTabIndex;
5647
- this.activeTabIndex = item._index;
5648
- this.$emit("update:modelValue", item._index);
5649
- 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);
5650
5691
  if (!this.noSlider)
5651
5692
  this.$nextTick(this.updateSlider);
5652
5693
  },
5653
5694
  updateSlider(domLookup = true) {
5654
5695
  if (domLookup) {
5655
- 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");
5656
5698
  }
5657
5699
  if (!this.fillBar && this.activeTabEl) {
5658
5700
  const { left, width } = this.activeTabEl.getBoundingClientRect();
@@ -5662,8 +5704,8 @@ const __vue2_script$f = {
5662
5704
  this.slider.left = `${left - parentLeft - parseInt(borderLeftWidth) + tabsBar.scrollLeft}px`;
5663
5705
  this.slider.width = `${width}px`;
5664
5706
  } else {
5665
- this.slider.left = `${this.activeTab._index * 100 / this.tabsItems.length}%`;
5666
- 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}%`;
5667
5709
  }
5668
5710
  },
5669
5711
  updateActiveTab(index2) {
@@ -5671,7 +5713,7 @@ const __vue2_script$f = {
5671
5713
  index2 = ~~index2;
5672
5714
  else if (isNaN(index2) || index2 < 0)
5673
5715
  index2 = 0;
5674
- this.activeTabIndex = index2;
5716
+ this.openTab(this.tabs[index2]._uid);
5675
5717
  this.$nextTick(() => {
5676
5718
  const ref = this.$refs["tabs-bar"];
5677
5719
  this.activeTabEl = ref && ref.querySelector(`.w-tabs__bar-item:nth-child(${index2 + 1})`);
@@ -5681,10 +5723,13 @@ const __vue2_script$f = {
5681
5723
  });
5682
5724
  },
5683
5725
  getOriginalItem(item) {
5684
- return this.items[item._index];
5726
+ return this.items[item._index] || {};
5685
5727
  }
5686
5728
  },
5687
5729
  beforeMount() {
5730
+ this.tabs = [];
5731
+ const items = typeof this.items === "number" ? Array(this.items).fill().map(Object) : this.items;
5732
+ items.forEach(this.addTab);
5688
5733
  this.updateActiveTab(this.value);
5689
5734
  this.$nextTick(() => {
5690
5735
  this.updateSlider();
@@ -5698,13 +5743,18 @@ const __vue2_script$f = {
5698
5743
  },
5699
5744
  watch: {
5700
5745
  value(index2) {
5701
- this.updateActiveTab(index2);
5746
+ if (index2 !== this.activeTabIndex)
5747
+ this.updateActiveTab(index2);
5702
5748
  },
5703
- items() {
5704
- while (this.activeTabIndex > 0 && !this.tabsItems[this.activeTabIndex])
5705
- this.activeTabIndex--;
5706
- if (!this.noSlider)
5707
- this.$nextTick(this.updateSlider);
5749
+ items: {
5750
+ handler() {
5751
+ this.refreshTabs();
5752
+ if (this.tabs.length)
5753
+ this.reopenTheActiveTab();
5754
+ if (!this.noSlider)
5755
+ this.$nextTick(this.updateSlider);
5756
+ },
5757
+ deep: true
5708
5758
  },
5709
5759
  fillBar() {
5710
5760
  if (!this.noSlider)
@@ -5909,10 +5959,10 @@ const __vue2_script$e = {
5909
5959
  return this.headers.find((header) => header.sticky);
5910
5960
  },
5911
5961
  selectedRowsByUid() {
5912
- return this.selectedRowsInternal.reduce((obj, uid) => (obj[uid] = true) && obj, {});
5962
+ return this.selectedRowsInternal.reduce((obj, uid2) => (obj[uid2] = true) && obj, {});
5913
5963
  },
5914
5964
  expandedRowsByUid() {
5915
- return this.expandedRowsInternal.reduce((obj, uid) => (obj[uid] = true) && obj, {});
5965
+ return this.expandedRowsInternal.reduce((obj, uid2) => (obj[uid2] = true) && obj, {});
5916
5966
  }
5917
5967
  },
5918
5968
  methods: {
@@ -5954,14 +6004,14 @@ const __vue2_script$e = {
5954
6004
  else
5955
6005
  this.expandedRowsInternal.push(item._uid);
5956
6006
  } else
5957
- this.expandedRowsInternal = this.expandedRowsInternal.filter((uid) => uid !== item._uid);
6007
+ this.expandedRowsInternal = this.expandedRowsInternal.filter((uid2) => uid2 !== item._uid);
5958
6008
  this.$emit(
5959
6009
  "row-expand",
5960
6010
  {
5961
6011
  item,
5962
6012
  index: index2,
5963
6013
  expanded: isExpanding,
5964
- expandedRows: this.expandedRowsInternal.map((uid) => this.filteredItems[uid])
6014
+ expandedRows: this.expandedRowsInternal.map((uid2) => this.filteredItems[uid2])
5965
6015
  }
5966
6016
  );
5967
6017
  this.$emit("update:expanded-rows", this.expandedRowsInternal);
@@ -5975,7 +6025,7 @@ const __vue2_script$e = {
5975
6025
  this.selectedRowsInternal.push(item._uid);
5976
6026
  updated = true;
5977
6027
  } else if (!this.forceSelection || this.selectedRowsInternal.length > 1) {
5978
- this.selectedRowsInternal = this.selectedRowsInternal.filter((uid) => uid !== item._uid);
6028
+ this.selectedRowsInternal = this.selectedRowsInternal.filter((uid2) => uid2 !== item._uid);
5979
6029
  updated = true;
5980
6030
  }
5981
6031
  if (updated) {
@@ -5985,7 +6035,7 @@ const __vue2_script$e = {
5985
6035
  item,
5986
6036
  index: index2,
5987
6037
  selected: isSelecting,
5988
- selectedRows: this.selectedRowsInternal.map((uid) => this.filteredItems[uid])
6038
+ selectedRows: this.selectedRowsInternal.map((uid2) => this.filteredItems[uid2])
5989
6039
  }
5990
6040
  );
5991
6041
  this.$emit("update:selected-rows", this.selectedRowsInternal);