wave-ui 4.0.1 → 4.0.2
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/dist/types/types/components/WAccordion.d.ts +6 -6
- package/dist/types/types/components/WTabs.d.ts +6 -5
- package/dist/wave-ui.cjs.js +2 -2
- package/dist/wave-ui.esm.js +44 -15
- package/dist/wave-ui.umd.js +2 -2
- package/package.json +1 -1
- package/src/wave-ui/components/w-accordion/index.vue +15 -2
- package/src/wave-ui/components/w-tabs/index.vue +61 -18
package/dist/wave-ui.esm.js
CHANGED
|
@@ -1867,7 +1867,8 @@ var tt = /* @__PURE__ */ J({
|
|
|
1867
1867
|
return this.accordionItems.reduce((e, t) => (e[t._cuid] = t, e), {});
|
|
1868
1868
|
},
|
|
1869
1869
|
accordionItemsProvided() {
|
|
1870
|
-
|
|
1870
|
+
let e = this.$slots.default?.() || [];
|
|
1871
|
+
return this.hasAccordionItemVNodes(e);
|
|
1871
1872
|
},
|
|
1872
1873
|
accordionClasses() {
|
|
1873
1874
|
return {
|
|
@@ -1893,6 +1894,9 @@ var tt = /* @__PURE__ */ J({
|
|
|
1893
1894
|
}
|
|
1894
1895
|
},
|
|
1895
1896
|
methods: {
|
|
1897
|
+
hasAccordionItemVNodes(t = []) {
|
|
1898
|
+
return t.some((t) => t ? t.type === $e || t.type?.name === "w-accordion-item" ? !0 : t.type === e && Array.isArray(t.children) ? this.hasAccordionItemVNodes(t.children) : !1 : !1);
|
|
1899
|
+
},
|
|
1896
1900
|
getAccordionItem(e) {
|
|
1897
1901
|
return this.accordionItemsById[e];
|
|
1898
1902
|
},
|
|
@@ -8030,6 +8034,26 @@ var ti = /* @__PURE__ */ J({
|
|
|
8030
8034
|
}
|
|
8031
8035
|
},
|
|
8032
8036
|
methods: {
|
|
8037
|
+
resolveTabUid(e) {
|
|
8038
|
+
if (!this.tabs.length) return null;
|
|
8039
|
+
if (e == null || e === "") return this.tabs[0]._uid;
|
|
8040
|
+
if (typeof e == "string") {
|
|
8041
|
+
if (this.tabsByUid[e]?._uid) return e;
|
|
8042
|
+
let t = Number.parseInt(e, 10);
|
|
8043
|
+
return !Number.isNaN(t) && `${t}` === e.trim() && this.tabs[t]?._uid || null;
|
|
8044
|
+
}
|
|
8045
|
+
return typeof e == "number" && e >= 0 && this.tabs[e]?._uid || null;
|
|
8046
|
+
},
|
|
8047
|
+
syncActiveTabFromModelValue(e = this.modelValue) {
|
|
8048
|
+
let t = this.resolveTabUid(e) || this.tabs[0]?._uid || null, n = t ? this.tabsByUid[t] : null;
|
|
8049
|
+
this.activeTabUid = n?._uid || null, this.activeTabIndex = n?._index || 0;
|
|
8050
|
+
},
|
|
8051
|
+
shouldEmitUidModelValue() {
|
|
8052
|
+
return typeof this.modelValue == "string" ? !/^\d+$/.test(this.modelValue.trim()) : !1;
|
|
8053
|
+
},
|
|
8054
|
+
getModelValueForTab(e) {
|
|
8055
|
+
return this.shouldEmitUidModelValue() ? e[this.itemIdKey] ?? e._uid : e._index;
|
|
8056
|
+
},
|
|
8033
8057
|
addTab(e) {
|
|
8034
8058
|
(e[this.itemIdKey] ?? e._uid ?? !1) || (e._uid = `${this.tabsStableId}-${this.tabs.length}`), this.tabs.push({
|
|
8035
8059
|
_uid: e[this.itemIdKey] ?? e._uid,
|
|
@@ -8040,7 +8064,7 @@ var ti = /* @__PURE__ */ J({
|
|
|
8040
8064
|
},
|
|
8041
8065
|
refreshTabs() {
|
|
8042
8066
|
let e = this.items;
|
|
8043
|
-
typeof e == "number"
|
|
8067
|
+
typeof e == "number" ? e = Array(e).fill().map((e, t) => this.tabs[t] || {}) : e ||= [], this.tabs = e.map((e, t) => ((e[this.itemIdKey] ?? e._uid ?? !1) || (e._uid = `${this.tabsStableId}-${t}`), {
|
|
8044
8068
|
...e,
|
|
8045
8069
|
_uid: e[this.itemIdKey] ?? e._uid,
|
|
8046
8070
|
_index: t,
|
|
@@ -8073,22 +8097,23 @@ var ti = /* @__PURE__ */ J({
|
|
|
8073
8097
|
openTab(e) {
|
|
8074
8098
|
this.prevTabIndex = this.activeTabIndex;
|
|
8075
8099
|
let t = this.tabsByUid[e];
|
|
8076
|
-
|
|
8100
|
+
if (!t) return;
|
|
8101
|
+
this.activeTabIndex = t._index, this.activeTabUid = t._uid;
|
|
8102
|
+
let n = this.getModelValueForTab(t);
|
|
8103
|
+
this.$emit("update:modelValue", n), this.$emit("input", n), this.noSlider || this.$nextTick(this.updateSlider);
|
|
8077
8104
|
},
|
|
8078
8105
|
updateSlider(e = !0) {
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
this.activeTabEl = e?.querySelector(".w-tabs__bar-item--active");
|
|
8082
|
-
}
|
|
8083
|
-
if (!this.fillBar && this.activeTabEl) {
|
|
8106
|
+
let t = this.$refs["tabs-bar"];
|
|
8107
|
+
if ((e || !this.activeTabEl) && (this.activeTabEl = t?.querySelector(".w-tabs__bar-item--active") || t?.querySelector(`.w-tabs__bar-item:nth-child(${this.activeTabIndex + 1})`)), !this.fillBar && this.activeTabEl) {
|
|
8084
8108
|
let { left: e, width: t } = this.activeTabEl.getBoundingClientRect(), n = this.activeTabEl.parentNode, { left: r } = n.getBoundingClientRect(), { borderLeftWidth: i } = getComputedStyle(n);
|
|
8085
8109
|
this.slider.left = `${e - r - parseInt(i) + n.scrollLeft}px`, this.slider.width = `${t}px`;
|
|
8086
|
-
} else this.slider.left = `${this.activeTab._index * 100 / this.tabs.length}%`, this.slider.width = `${100 / this.tabs.length}
|
|
8110
|
+
} else !this.fillBar && e && this.tabs.length ? this.$nextTick(() => this.updateSlider(!1)) : (this.slider.left = `${this.activeTab._index * 100 / this.tabs.length}%`, this.slider.width = `${100 / this.tabs.length}%`);
|
|
8087
8111
|
},
|
|
8088
8112
|
updateActiveTab(e) {
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8113
|
+
let t = this.resolveTabUid(e), n = t ? this.tabsByUid[t] : null;
|
|
8114
|
+
n?._uid && (this.openTab(n._uid), this.$nextTick(() => {
|
|
8115
|
+
let e = this.$refs["tabs-bar"];
|
|
8116
|
+
this.activeTabEl = e?.querySelector(`.w-tabs__bar-item:nth-child(${n._index + 1})`), this.activeTabEl && this.activeTabEl.scrollIntoView({
|
|
8092
8117
|
behavior: "smooth",
|
|
8093
8118
|
block: "nearest",
|
|
8094
8119
|
inline: "nearest"
|
|
@@ -8099,8 +8124,11 @@ var ti = /* @__PURE__ */ J({
|
|
|
8099
8124
|
return this.items[e._index] || {};
|
|
8100
8125
|
}
|
|
8101
8126
|
},
|
|
8127
|
+
created() {
|
|
8128
|
+
this.tabs = [], (typeof this.items == "number" ? Array(this.items).fill().map(Object) : this.items || []).forEach(this.addTab), this.syncActiveTabFromModelValue(this.modelValue);
|
|
8129
|
+
},
|
|
8102
8130
|
beforeMount() {
|
|
8103
|
-
this
|
|
8131
|
+
this.$nextTick(() => {
|
|
8104
8132
|
this.updateSlider(), setTimeout(() => this.init = !1, 0);
|
|
8105
8133
|
}), this.noSlider || window.addEventListener("resize", this.onResize);
|
|
8106
8134
|
},
|
|
@@ -8109,11 +8137,12 @@ var ti = /* @__PURE__ */ J({
|
|
|
8109
8137
|
},
|
|
8110
8138
|
watch: {
|
|
8111
8139
|
modelValue(e) {
|
|
8112
|
-
|
|
8140
|
+
let t = this.resolveTabUid(e);
|
|
8141
|
+
t && t !== this.activeTabUid && this.updateActiveTab(e);
|
|
8113
8142
|
},
|
|
8114
8143
|
items: {
|
|
8115
8144
|
handler() {
|
|
8116
|
-
this.refreshTabs(), this.tabs.length && this.reopenTheActiveTab(), this.noSlider || this.$nextTick(this.updateSlider);
|
|
8145
|
+
this.refreshTabs(), this.syncActiveTabFromModelValue(this.modelValue), !this.activeTabUid && this.tabs.length && this.reopenTheActiveTab(), this.noSlider || this.$nextTick(this.updateSlider);
|
|
8117
8146
|
},
|
|
8118
8147
|
deep: !0
|
|
8119
8148
|
},
|