wave-ui 4.0.0 → 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/.nojekyll +0 -0
- package/dist/types/types/components/WAccordion.d.ts +6 -6
- package/dist/types/types/components/WMenu.d.ts +2 -1
- package/dist/types/types/components/WTabs.d.ts +6 -5
- package/dist/types/types/components/WTooltip.d.ts +2 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/mixins/detachable.d.ts +7 -0
- package/dist/types/types/mixins/detachable.js +2 -0
- package/dist/wave-ui.cjs.js +3 -3
- package/dist/wave-ui.esm.js +59 -25
- package/dist/wave-ui.umd.js +3 -3
- package/package.json +1 -1
- package/src/wave-ui/components/w-accordion/index.vue +15 -2
- package/src/wave-ui/components/w-menu.vue +1 -1
- package/src/wave-ui/components/w-tabs/index.vue +61 -18
- package/src/wave-ui/components/w-tooltip.vue +1 -1
- package/src/wave-ui/mixins/detachable.js +29 -21
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
|
},
|
|
@@ -5198,6 +5202,7 @@ var kn = {
|
|
|
5198
5202
|
},
|
|
5199
5203
|
inject: { detachableDefaultRoot: { default: null } },
|
|
5200
5204
|
data: () => ({
|
|
5205
|
+
detachableDomReady: !1,
|
|
5201
5206
|
docEventListenersHandlers: [],
|
|
5202
5207
|
openTimeout: null,
|
|
5203
5208
|
viewportPlacementOverride: null,
|
|
@@ -5362,12 +5367,14 @@ var kn = {
|
|
|
5362
5367
|
}
|
|
5363
5368
|
},
|
|
5364
5369
|
mounted() {
|
|
5365
|
-
this.
|
|
5366
|
-
this.activator ? this.bindActivatorEvents() : this
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5370
|
+
this.detachableDomReady = !0, this.$nextTick(() => {
|
|
5371
|
+
this.activator ? this.bindActivatorEvents() : this.$nextTick(() => {
|
|
5372
|
+
this.activator ? this.bindActivatorEvents() : this._attachActivatorListeners(), this.modelValue && !this.disable && this.open({ target: this.activatorEl });
|
|
5373
|
+
}), this.overlay && (this.overlayEl = this.$refs.overlay?.$el), this.modelValue && this.activator && !this.disable ? this.toggle({
|
|
5374
|
+
type: this.shouldShowOnClick ? "click" : "mouseenter",
|
|
5375
|
+
target: this.activatorEl
|
|
5376
|
+
}) : this.modelValue && !this.disable && this.open({ target: this.activatorEl });
|
|
5377
|
+
});
|
|
5371
5378
|
},
|
|
5372
5379
|
unmounted() {
|
|
5373
5380
|
this.close(), this._detachActivatorListeners(), this.unbindActivatorDocEvents();
|
|
@@ -5391,7 +5398,8 @@ function An(t, i, a, l, d, p) {
|
|
|
5391
5398
|
return x(), c(e, null, [
|
|
5392
5399
|
T(t.$slots, "activator"),
|
|
5393
5400
|
t.$slots.activator ? s("", !0) : T(t.$slots, "default", { key: 0 }),
|
|
5394
|
-
(x(), o(n, {
|
|
5401
|
+
t.detachableDomReady ? (x(), o(n, {
|
|
5402
|
+
key: 1,
|
|
5395
5403
|
to: t.teleportTarget,
|
|
5396
5404
|
disabled: !t.teleportTarget
|
|
5397
5405
|
}, [f(r, {
|
|
@@ -5459,7 +5467,7 @@ function An(t, i, a, l, d, p) {
|
|
|
5459
5467
|
"persistent",
|
|
5460
5468
|
"class",
|
|
5461
5469
|
"z-index"
|
|
5462
|
-
])) : s("", !0)], 8, ["to", "disabled"]))
|
|
5470
|
+
])) : s("", !0)], 8, ["to", "disabled"])) : s("", !0)
|
|
5463
5471
|
], 64);
|
|
5464
5472
|
}
|
|
5465
5473
|
var jn = /* @__PURE__ */ J({
|
|
@@ -8026,6 +8034,26 @@ var ti = /* @__PURE__ */ J({
|
|
|
8026
8034
|
}
|
|
8027
8035
|
},
|
|
8028
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
|
+
},
|
|
8029
8057
|
addTab(e) {
|
|
8030
8058
|
(e[this.itemIdKey] ?? e._uid ?? !1) || (e._uid = `${this.tabsStableId}-${this.tabs.length}`), this.tabs.push({
|
|
8031
8059
|
_uid: e[this.itemIdKey] ?? e._uid,
|
|
@@ -8036,7 +8064,7 @@ var ti = /* @__PURE__ */ J({
|
|
|
8036
8064
|
},
|
|
8037
8065
|
refreshTabs() {
|
|
8038
8066
|
let e = this.items;
|
|
8039
|
-
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}`), {
|
|
8040
8068
|
...e,
|
|
8041
8069
|
_uid: e[this.itemIdKey] ?? e._uid,
|
|
8042
8070
|
_index: t,
|
|
@@ -8069,22 +8097,23 @@ var ti = /* @__PURE__ */ J({
|
|
|
8069
8097
|
openTab(e) {
|
|
8070
8098
|
this.prevTabIndex = this.activeTabIndex;
|
|
8071
8099
|
let t = this.tabsByUid[e];
|
|
8072
|
-
|
|
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);
|
|
8073
8104
|
},
|
|
8074
8105
|
updateSlider(e = !0) {
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
this.activeTabEl = e?.querySelector(".w-tabs__bar-item--active");
|
|
8078
|
-
}
|
|
8079
|
-
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) {
|
|
8080
8108
|
let { left: e, width: t } = this.activeTabEl.getBoundingClientRect(), n = this.activeTabEl.parentNode, { left: r } = n.getBoundingClientRect(), { borderLeftWidth: i } = getComputedStyle(n);
|
|
8081
8109
|
this.slider.left = `${e - r - parseInt(i) + n.scrollLeft}px`, this.slider.width = `${t}px`;
|
|
8082
|
-
} 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}%`);
|
|
8083
8111
|
},
|
|
8084
8112
|
updateActiveTab(e) {
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
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({
|
|
8088
8117
|
behavior: "smooth",
|
|
8089
8118
|
block: "nearest",
|
|
8090
8119
|
inline: "nearest"
|
|
@@ -8095,8 +8124,11 @@ var ti = /* @__PURE__ */ J({
|
|
|
8095
8124
|
return this.items[e._index] || {};
|
|
8096
8125
|
}
|
|
8097
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
|
+
},
|
|
8098
8130
|
beforeMount() {
|
|
8099
|
-
this
|
|
8131
|
+
this.$nextTick(() => {
|
|
8100
8132
|
this.updateSlider(), setTimeout(() => this.init = !1, 0);
|
|
8101
8133
|
}), this.noSlider || window.addEventListener("resize", this.onResize);
|
|
8102
8134
|
},
|
|
@@ -8105,11 +8137,12 @@ var ti = /* @__PURE__ */ J({
|
|
|
8105
8137
|
},
|
|
8106
8138
|
watch: {
|
|
8107
8139
|
modelValue(e) {
|
|
8108
|
-
|
|
8140
|
+
let t = this.resolveTabUid(e);
|
|
8141
|
+
t && t !== this.activeTabUid && this.updateActiveTab(e);
|
|
8109
8142
|
},
|
|
8110
8143
|
items: {
|
|
8111
8144
|
handler() {
|
|
8112
|
-
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);
|
|
8113
8146
|
},
|
|
8114
8147
|
deep: !0
|
|
8115
8148
|
},
|
|
@@ -9124,7 +9157,8 @@ function Ki(t, i, a, l, u, p) {
|
|
|
9124
9157
|
return x(), c(e, null, [
|
|
9125
9158
|
T(t.$slots, "activator"),
|
|
9126
9159
|
t.$slots.activator ? s("", !0) : T(t.$slots, "default", { key: 0 }),
|
|
9127
|
-
(x(), o(n, {
|
|
9160
|
+
t.detachableDomReady ? (x(), o(n, {
|
|
9161
|
+
key: 1,
|
|
9128
9162
|
to: t.teleportTarget,
|
|
9129
9163
|
disabled: !t.teleportTarget
|
|
9130
9164
|
}, [f(r, {
|
|
@@ -9139,7 +9173,7 @@ function Ki(t, i, a, l, u, p) {
|
|
|
9139
9173
|
style: b(p.styles)
|
|
9140
9174
|
}, [a.tooltip ? (x(), c(e, { key: 0 }, [d(k(a.tooltip), 1)], 64)) : t.$slots.tooltip ? T(t.$slots, "tooltip", { key: 1 }) : t.$slots.activator ? T(t.$slots, "default", { key: 2 }) : s("", !0)], 6)) : s("", !0)]),
|
|
9141
9175
|
_: 3
|
|
9142
|
-
}, 8, ["name", "onAfterLeave"])], 8, ["to", "disabled"]))
|
|
9176
|
+
}, 8, ["name", "onAfterLeave"])], 8, ["to", "disabled"])) : s("", !0)
|
|
9143
9177
|
], 64);
|
|
9144
9178
|
}
|
|
9145
9179
|
var qi = /* @__PURE__ */ J({
|