@m3ui-vue/m3ui-vue 1.4.2 → 1.4.3
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/API.md +1 -1
- package/dist/api.json +1 -1
- package/dist/m3ui.js +48 -30
- package/dist/m3ui.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/MTabs.test.ts +100 -2
- package/src/components/MTabs.vue +33 -6
package/dist/m3ui.js
CHANGED
|
@@ -28221,49 +28221,65 @@ var Nj = /*#__PURE__*/ ie(Aj, [["render", Mj]]), Pj = ["disabled"], Fj = [
|
|
|
28221
28221
|
},
|
|
28222
28222
|
emits: ["update:modelValue"],
|
|
28223
28223
|
setup(e, { emit: t }) {
|
|
28224
|
-
let n = e, r = I(() => (n.iconPosition ?? (n.variant === "primary" ? "top" : "leading")) === "leading"), i = t, a = q([]), o = q(
|
|
28225
|
-
function
|
|
28224
|
+
let n = e, r = I(() => (n.iconPosition ?? (n.variant === "primary" ? "top" : "leading")) === "leading"), i = t, a = q([]), o = q(null), s = q(0), c = q(0);
|
|
28225
|
+
function l(e) {
|
|
28226
28226
|
let t = a.value[e];
|
|
28227
28227
|
return t ? {
|
|
28228
28228
|
left: t.offsetLeft,
|
|
28229
28229
|
width: t.offsetWidth
|
|
28230
28230
|
} : null;
|
|
28231
28231
|
}
|
|
28232
|
-
let
|
|
28233
|
-
function
|
|
28234
|
-
let i = t + (-700 * (e - n) -
|
|
28232
|
+
let u = 2 * vN * Math.sqrt(yN), d = 0, f = 0, p = 0, m = 0, h = 0, g = 0, _ = 0, v = 0;
|
|
28233
|
+
function y(e, t, n, r) {
|
|
28234
|
+
let i = t + (-700 * (e - n) - u * t) * r;
|
|
28235
28235
|
return [e + i * r, i];
|
|
28236
28236
|
}
|
|
28237
|
-
function
|
|
28238
|
-
let t = Math.min((e -
|
|
28239
|
-
if (
|
|
28240
|
-
|
|
28237
|
+
function b(e) {
|
|
28238
|
+
let t = Math.min((e - v) / 1e3, 1 / 30);
|
|
28239
|
+
if (v = e, [d, f] = y(d, f, p, t), [m, h] = y(m, h, g, t), s.value = d, c.value = m, Math.abs(d - p) < .5 && Math.abs(f) < .5 && Math.abs(m - g) < .5 && Math.abs(h) < .5) {
|
|
28240
|
+
d = p, m = g, s.value = d, c.value = m, _ = 0;
|
|
28241
28241
|
return;
|
|
28242
28242
|
}
|
|
28243
|
-
|
|
28243
|
+
_ = requestAnimationFrame(b);
|
|
28244
28244
|
}
|
|
28245
|
-
function
|
|
28246
|
-
|
|
28245
|
+
function x() {
|
|
28246
|
+
_ ||= (v = performance.now(), requestAnimationFrame(b));
|
|
28247
28247
|
}
|
|
28248
|
-
function
|
|
28248
|
+
function S(e, t) {
|
|
28249
|
+
let r = o.value;
|
|
28250
|
+
if (!n.scrollable || !r) return;
|
|
28251
|
+
let i = r.scrollWidth - r.clientWidth;
|
|
28252
|
+
if (i <= 0) return;
|
|
28253
|
+
let a = Math.round(Math.min(Math.max(e.left + e.width / 2 - r.clientWidth / 2, 0), i));
|
|
28254
|
+
if (Math.abs(a - r.scrollLeft) < 1) return;
|
|
28255
|
+
let s = typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, c = t && !s ? "smooth" : "auto";
|
|
28256
|
+
typeof r.scrollTo == "function" ? r.scrollTo({
|
|
28257
|
+
left: a,
|
|
28258
|
+
behavior: c
|
|
28259
|
+
}) : r.scrollLeft = a;
|
|
28260
|
+
}
|
|
28261
|
+
let C = Symbol("none");
|
|
28262
|
+
function w(e = !0, t = "none") {
|
|
28249
28263
|
We(() => {
|
|
28250
|
-
let
|
|
28251
|
-
if (
|
|
28252
|
-
if (n.variant === "primary") {
|
|
28253
|
-
let e = Math.min(
|
|
28254
|
-
|
|
28255
|
-
} else
|
|
28256
|
-
e ?
|
|
28264
|
+
let r = l(n.tabs.findIndex((e) => e.value === n.modelValue));
|
|
28265
|
+
if (r) {
|
|
28266
|
+
if (t !== "none" && (C = n.modelValue, S(r, t === "smooth")), n.variant === "primary") {
|
|
28267
|
+
let e = Math.min(r.width * .2, 16);
|
|
28268
|
+
p = r.left + e, g = r.width - e * 2;
|
|
28269
|
+
} else p = r.left, g = r.width;
|
|
28270
|
+
e ? x() : (d = p, f = 0, m = g, h = 0, s.value = d, c.value = m);
|
|
28257
28271
|
}
|
|
28258
28272
|
});
|
|
28259
28273
|
}
|
|
28260
|
-
Ye(() =>
|
|
28261
|
-
|
|
28262
|
-
}), Q(() => n.modelValue, () =>
|
|
28263
|
-
function
|
|
28274
|
+
Ye(() => w(!1, "instant")), Xe(() => {
|
|
28275
|
+
_ && cancelAnimationFrame(_);
|
|
28276
|
+
}), Q(() => n.modelValue, () => w(!0, "smooth")), Q(() => n.tabs, () => w(!0, C === n.modelValue ? "none" : "instant"), { deep: !0 }), Q(r, () => w(!0));
|
|
28277
|
+
function T(e) {
|
|
28264
28278
|
e.disabled || i("update:modelValue", e.value);
|
|
28265
28279
|
}
|
|
28266
28280
|
return (t, n) => e.variant === "primary" ? (K(), z("div", mN, [B("div", {
|
|
28281
|
+
ref_key: "rowEl",
|
|
28282
|
+
ref: o,
|
|
28267
28283
|
class: W(["relative flex", e.scrollable ? "overflow-x-auto" : "overflow-x-hidden"]),
|
|
28268
28284
|
style: { "scrollbar-width": "none" }
|
|
28269
28285
|
}, [(K(!0), z(F, null, J(e.tabs, (t) => (K(), z("button", {
|
|
@@ -28279,7 +28295,7 @@ var Nj = /*#__PURE__*/ ie(Aj, [["render", Mj]]), Pj = ["disabled"], Fj = [
|
|
|
28279
28295
|
t.value === e.modelValue ? "text-primary" : t.disabled ? "cursor-not-allowed text-on-surface/38" : "cursor-pointer text-on-surface-variant hover:text-on-surface"
|
|
28280
28296
|
]]),
|
|
28281
28297
|
disabled: t.disabled,
|
|
28282
|
-
onClick: (e) =>
|
|
28298
|
+
onClick: (e) => T(t)
|
|
28283
28299
|
}, [t.icon ? (K(), L(P, {
|
|
28284
28300
|
key: 0,
|
|
28285
28301
|
name: t.icon,
|
|
@@ -28287,10 +28303,12 @@ var Nj = /*#__PURE__*/ ie(Aj, [["render", Mj]]), Pj = ["disabled"], Fj = [
|
|
|
28287
28303
|
}, null, 8, ["name"])) : R("", !0), B("span", null, X(t.label), 1)], 10, hN))), 128)), B("div", {
|
|
28288
28304
|
class: "absolute bottom-0 h-[3px] rounded-t-full bg-primary",
|
|
28289
28305
|
style: G({
|
|
28290
|
-
left: `${
|
|
28291
|
-
width: `${
|
|
28306
|
+
left: `${s.value}px`,
|
|
28307
|
+
width: `${c.value}px`
|
|
28292
28308
|
})
|
|
28293
28309
|
}, null, 4)], 2)])) : (K(), z("div", gN, [B("div", {
|
|
28310
|
+
ref_key: "rowEl",
|
|
28311
|
+
ref: o,
|
|
28294
28312
|
class: W(["relative flex", e.scrollable ? "overflow-x-auto" : "overflow-x-hidden"]),
|
|
28295
28313
|
style: { "scrollbar-width": "none" }
|
|
28296
28314
|
}, [(K(!0), z(F, null, J(e.tabs, (t) => (K(), z("button", {
|
|
@@ -28306,7 +28324,7 @@ var Nj = /*#__PURE__*/ ie(Aj, [["render", Mj]]), Pj = ["disabled"], Fj = [
|
|
|
28306
28324
|
t.value === e.modelValue ? "text-on-surface" : t.disabled ? "cursor-not-allowed text-on-surface/38" : "cursor-pointer text-on-surface-variant hover:text-on-surface"
|
|
28307
28325
|
]]),
|
|
28308
28326
|
disabled: t.disabled,
|
|
28309
|
-
onClick: (e) =>
|
|
28327
|
+
onClick: (e) => T(t)
|
|
28310
28328
|
}, [t.icon ? (K(), L(P, {
|
|
28311
28329
|
key: 0,
|
|
28312
28330
|
name: t.icon,
|
|
@@ -28314,8 +28332,8 @@ var Nj = /*#__PURE__*/ ie(Aj, [["render", Mj]]), Pj = ["disabled"], Fj = [
|
|
|
28314
28332
|
}, null, 8, ["name"])) : R("", !0), B("span", null, X(t.label), 1)], 10, _N))), 128)), B("div", {
|
|
28315
28333
|
class: "absolute bottom-0 h-[3px] bg-primary",
|
|
28316
28334
|
style: G({
|
|
28317
|
-
left: `${
|
|
28318
|
-
width: `${
|
|
28335
|
+
left: `${s.value}px`,
|
|
28336
|
+
width: `${c.value}px`
|
|
28319
28337
|
})
|
|
28320
28338
|
}, null, 4)], 2)]));
|
|
28321
28339
|
}
|