@m3ui-vue/m3ui-vue 0.8.3 → 0.8.5

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/README.md CHANGED
@@ -397,6 +397,25 @@ Install only the packages you need:
397
397
  | `MQRCode` | `qrcode-generator` |
398
398
  | `MBarcode` | `jsbarcode` |
399
399
 
400
+ ## About this project
401
+
402
+ M3UI Vue started as a set of components I built for my own projects. Over time it grew
403
+ into something I thought others might find useful, so I decided to open-source it and
404
+ keep improving it so anyone can use it for free.
405
+
406
+ That said, this is a personal project maintained in my spare time. I can't offer
407
+ round-the-clock support or guarantee response times, and features are prioritized
408
+ around what I need and what I have time for.
409
+
410
+ **Contributions are very welcome:**
411
+
412
+ - **Found a bug?** [Open an issue](https://github.com/SrWither/m3ui-vue/issues) with steps
413
+ to reproduce it (a minimal example helps a lot).
414
+ - **Want to fix something or add a feature?** Pull requests are appreciated. For larger
415
+ changes, opening an issue first to discuss the idea is a good way to avoid wasted effort.
416
+
417
+ Thanks for using it! ⭐ Starring the repo is also a nice way to show support.
418
+
400
419
  ## License
401
420
 
402
421
  MIT
@@ -6,11 +6,11 @@ import { Fragment as r, Teleport as i, Transition as a, computed as o, createBlo
6
6
  var P = ["aria-label"], F = {
7
7
  key: 0,
8
8
  class: "block h-full w-full animate-spin rounded-full border-2 border-current border-t-transparent"
9
- }, I = [
9
+ }, ee = [
10
10
  "width",
11
11
  "height",
12
12
  "viewBox"
13
- ], ee = ["d", "stroke-dasharray"], L = 3, te = 9, R = /* @__PURE__ */ p({
13
+ ], I = ["d", "stroke-dasharray"], L = 3, te = 9, R = /* @__PURE__ */ p({
14
14
  __name: "MSpinner",
15
15
  props: {
16
16
  size: { default: 20 },
@@ -58,7 +58,7 @@ var P = ["aria-label"], F = {
58
58
  "stroke-dasharray": s.value.dash,
59
59
  class: "animate-[m3-wavy-travel_2s_linear_infinite]",
60
60
  style: _({ "--m3-wave-len": s.value.len })
61
- }, null, 12, ee)], 12, I)) : (x(), l("span", F))], 12, P));
61
+ }, null, 12, I)], 12, ee)) : (x(), l("span", F))], 12, P));
62
62
  }
63
63
  }), z = [
64
64
  "bg-surface-container-highest",
@@ -134,7 +134,7 @@ function V(e, t) {
134
134
  }
135
135
  //#endregion
136
136
  //#region src/composables/useDebounce.ts
137
- function H(e, t) {
137
+ function re(e, t) {
138
138
  let n = null;
139
139
  function r(...r) {
140
140
  n && clearTimeout(n), n = setTimeout(() => {
@@ -151,7 +151,7 @@ function H(e, t) {
151
151
  }
152
152
  //#endregion
153
153
  //#region src/components/MIconButton.vue?vue&type=script&setup=true&lang.ts
154
- var re = "relative inline-flex shrink-0 items-center justify-center overflow-hidden transition-colors duration-150 cursor-pointer disabled:cursor-not-allowed disabled:text-on-surface/38 before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]", U = /* @__PURE__ */ p({
154
+ var ie = "relative inline-flex shrink-0 items-center justify-center overflow-hidden transition-colors duration-150 cursor-pointer disabled:cursor-not-allowed disabled:text-on-surface/38 before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]", H = /* @__PURE__ */ p({
155
155
  __name: "MIconButton",
156
156
  props: {
157
157
  icon: {},
@@ -222,7 +222,7 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
222
222
  "aria-label": e.label || void 0,
223
223
  disabled: e.disabled,
224
224
  class: g([
225
- re,
225
+ ie,
226
226
  l.value,
227
227
  d.value,
228
228
  c.value
@@ -247,7 +247,7 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
247
247
  "style"
248
248
  ]));
249
249
  }
250
- }), W = "relative inline-flex items-center justify-center font-medium whitespace-nowrap overflow-hidden transition-[box-shadow,background-color,color] duration-150 select-none cursor-pointer disabled:cursor-not-allowed disabled:shadow-none disabled:text-on-surface/38 before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]", G = /* @__PURE__ */ p({
250
+ }), U = "relative inline-flex items-center justify-center font-medium whitespace-nowrap overflow-hidden transition-[box-shadow,background-color,color] duration-150 select-none cursor-pointer disabled:cursor-not-allowed disabled:shadow-none disabled:text-on-surface/38 before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]", W = /* @__PURE__ */ p({
251
251
  __name: "MButton",
252
252
  props: {
253
253
  variant: { default: "filled" },
@@ -355,7 +355,7 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
355
355
  type: e.to ? void 0 : e.type,
356
356
  disabled: e.disabled || e.loading,
357
357
  class: g([
358
- W,
358
+ U,
359
359
  C.value,
360
360
  v.value,
361
361
  S.value,
@@ -393,25 +393,25 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
393
393
  "style"
394
394
  ]));
395
395
  }
396
- }), K = { class: "relative px-6 pt-6 pb-2" }, q = {
396
+ }), G = { class: "relative px-6 pt-6 pb-2" }, K = {
397
397
  key: 0,
398
398
  class: "absolute right-4 top-4"
399
- }, J = {
399
+ }, q = {
400
400
  key: 1,
401
401
  class: "mb-4 flex justify-center text-secondary"
402
- }, ie = {
402
+ }, J = {
403
403
  key: 0,
404
404
  class: "shrink-0 border-t border-outline-variant"
405
- }, Y = {
405
+ }, ae = {
406
406
  key: 1,
407
407
  class: "flex flex-wrap justify-end gap-2 px-6 pt-4 pb-6"
408
- }, X = {
408
+ }, Y = {
409
409
  key: 0,
410
410
  class: "dialog-fs fixed inset-0 z-50 flex flex-col bg-surface"
411
- }, Z = { class: "flex h-14 shrink-0 items-center gap-2 px-2" }, ae = { class: "flex-1 text-title-large font-medium text-on-surface" }, Q = {
411
+ }, X = { class: "flex h-14 shrink-0 items-center gap-2 px-2" }, Z = { class: "flex-1 text-title-large font-medium text-on-surface" }, oe = {
412
412
  key: 1,
413
413
  class: "flex items-center gap-2"
414
- }, oe = { class: "flex-1 overflow-y-auto px-6 py-4 text-body-medium text-on-surface-variant" }, se = /*#__PURE__*/ n(/* @__PURE__ */ p({
414
+ }, Q = { class: "flex-1 overflow-y-auto px-6 py-4 text-body-medium text-on-surface-variant" }, se = /*#__PURE__*/ n(/* @__PURE__ */ p({
415
415
  __name: "MDialog",
416
416
  props: {
417
417
  modelValue: { type: Boolean },
@@ -458,16 +458,16 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
458
458
  key: 1,
459
459
  name: "m3-dialog-fs"
460
460
  }, {
461
- default: M(() => [t.modelValue ? (x(), l("div", X, [u("div", Z, [
462
- t.persistent ? c("", !0) : (x(), s(U, {
461
+ default: M(() => [t.modelValue ? (x(), l("div", Y, [u("div", X, [
462
+ t.persistent ? c("", !0) : (x(), s(H, {
463
463
  key: 0,
464
464
  icon: "close",
465
465
  label: t.closeLabel ?? O(o).close,
466
466
  onClick: m
467
467
  }, null, 8, ["label"])),
468
- u("h2", ae, [T(e.$slots, "title", {}, () => [d(D(t.title), 1)], !0)]),
469
- e.$slots.actions ? (x(), l("div", Q, [T(e.$slots, "actions", {}, void 0, !0)])) : c("", !0)
470
- ]), u("div", oe, [T(e.$slots, "default", {}, void 0, !0)])])) : c("", !0)]),
468
+ u("h2", Z, [T(e.$slots, "title", {}, () => [d(D(t.title), 1)], !0)]),
469
+ e.$slots.actions ? (x(), l("div", oe, [T(e.$slots, "actions", {}, void 0, !0)])) : c("", !0)
470
+ ]), u("div", Q, [T(e.$slots, "default", {}, void 0, !0)])])) : c("", !0)]),
471
471
  _: 3
472
472
  })) : (x(), s(a, {
473
473
  key: 0,
@@ -478,13 +478,13 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
478
478
  class: "fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4",
479
479
  onClick: N(m, ["self"])
480
480
  }, [u("div", { class: g(["dialog-box flex min-w-[280px] w-full flex-col rounded-xl bg-surface-container-high shadow-elevation-3", [t.maxWidth, t.maxHeight]]) }, [
481
- u("div", K, [
482
- t.closable && !t.persistent ? (x(), l("div", q, [f(U, {
481
+ u("div", G, [
482
+ t.closable && !t.persistent ? (x(), l("div", K, [f(H, {
483
483
  icon: "close",
484
484
  label: t.closeLabel ?? O(o).close,
485
485
  onClick: m
486
486
  }, null, 8, ["label"])])) : c("", !0),
487
- e.$slots.icon ? (x(), l("div", J, [T(e.$slots, "icon", {}, void 0, !0)])) : c("", !0),
487
+ e.$slots.icon ? (x(), l("div", q, [T(e.$slots, "icon", {}, void 0, !0)])) : c("", !0),
488
488
  u("h2", { class: g(["text-headline-small text-on-surface", [e.$slots.icon ? "text-center" : "text-left", t.closable && !t.persistent ? e.$slots.icon ? "px-10" : "pr-10" : ""]]) }, [T(e.$slots, "title", {}, () => [d(D(t.title), 1)], !0)], 2)
489
489
  ]),
490
490
  u("div", {
@@ -496,8 +496,8 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
496
496
  ref_key: "contentInnerEl",
497
497
  ref: y
498
498
  }, [T(e.$slots, "default", {}, void 0, !0)], 512)], 34),
499
- S.value && e.$slots.actions ? (x(), l("div", ie)) : c("", !0),
500
- e.$slots.actions ? (x(), l("div", Y, [T(e.$slots, "actions", {}, void 0, !0)])) : c("", !0)
499
+ S.value && e.$slots.actions ? (x(), l("div", J)) : c("", !0),
500
+ e.$slots.actions ? (x(), l("div", ae, [T(e.$slots, "actions", {}, void 0, !0)])) : c("", !0)
501
501
  ], 2)])) : c("", !0)]),
502
502
  _: 3
503
503
  }))]));
@@ -561,7 +561,7 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
561
561
  },
562
562
  emits: ["update:modelValue", "debounced"],
563
563
  setup(e, { emit: n }) {
564
- let r = e, i = n, a = k(), s = A(), p = C(null), { resolvedFieldBg: m } = V(p, () => r.fieldBg), { debounced: h, cancel: v } = H((e) => i("debounced", e), r.debounce), y = o(() => r.clearable && String(r.modelValue).length > 0 && !r.disabled), b = o(() => {
564
+ let r = e, i = n, a = k(), s = A(), p = C(null), { resolvedFieldBg: m } = V(p, () => r.fieldBg), { debounced: h, cancel: v } = re((e) => i("debounced", e), r.debounce), y = o(() => r.clearable && String(r.modelValue).length > 0 && !r.disabled), b = o(() => {
565
565
  let e = !!s.trailing || r.clearable, t = r.leadingIcon ? "pl-12" : "pl-4", n = e ? "pr-12" : "pr-4", i = r.multiline ? "resize-y min-h-[56px]" : "h-14", a = [
566
566
  "peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent",
567
567
  "transition-[border-color,border-width] duration-150",
@@ -688,7 +688,7 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
688
688
  for (let n of e) D(n) ? t.push([]) : t[t.length - 1].push(n);
689
689
  return t.filter((e) => e.length > 0);
690
690
  }), k = o(() => !!O.value && O.value.length > 1), N = C([]), P = o(() => N.value[N.value.length - 1]), F = C("forward");
691
- function I(e, t) {
691
+ function ee(e, t) {
692
692
  let n = F.value === "forward" ? 1 : -1, r = e.animate([{
693
693
  transform: `translateX(${n * 100}%)`,
694
694
  opacity: .4
@@ -701,7 +701,7 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
701
701
  });
702
702
  r.onfinish = t;
703
703
  }
704
- function ee(e, t) {
704
+ function I(e, t) {
705
705
  let n = F.value === "forward" ? -1 : 1, r = e;
706
706
  r.style.position = "absolute", r.style.insetInline = "0", r.style.top = "0";
707
707
  let i = r.animate([{
@@ -729,8 +729,8 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
729
729
  alpha: 1
730
730
  }), L = e, e;
731
731
  }
732
- let R = 0, z = null;
733
- function B(e, t, n) {
732
+ let R = 0, z = null, B = null;
733
+ function ne(e, t, n) {
734
734
  z?.();
735
735
  let r = e, i = te(), a = i.length - 1, o = n ? 1 : -1, s = n ? a : 0, c = 0, l = 0, u = !1;
736
736
  function d(e) {
@@ -741,25 +741,27 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
741
741
  if (u) return;
742
742
  let r = c ? (e - c) / 1e3 / $ : 1;
743
743
  if (c = e, R = Math.max(0, Math.min(a, R + o * r)), d(R), n && R >= s || !n && R <= s) {
744
- z = null, t();
744
+ z = null, B = null, t();
745
745
  return;
746
746
  }
747
747
  l = requestAnimationFrame(f);
748
748
  }
749
749
  z = () => {
750
750
  u = !0, cancelAnimationFrame(l);
751
+ }, B = n ? null : () => {
752
+ z?.(), z = null, B = null, t();
751
753
  }, d(R), l = requestAnimationFrame(f);
752
754
  }
753
- function ne(e, t) {
754
- B(e, t, !0);
755
- }
756
755
  function V(e, t) {
757
- B(e, t, !1);
756
+ ne(e, t, !0);
757
+ }
758
+ function re(e, t) {
759
+ ne(e, t, !1);
758
760
  }
759
- function H(e) {
761
+ function ie(e) {
760
762
  F.value = "forward", N.value.push(e), h(() => X());
761
763
  }
762
- function re() {
764
+ function H() {
763
765
  F.value = "backward", N.value.pop(), h(() => X());
764
766
  }
765
767
  let U = C(!1), W = C(null), G = C(null), K = C({}), q = m("m-menu-panel-registry", /* @__PURE__ */ new Set());
@@ -770,7 +772,7 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
770
772
  });
771
773
  let J = m("m-menu-sibling-group", null);
772
774
  S("m-menu-sibling-group", { current: null });
773
- function ie() {
775
+ function ae() {
774
776
  if (!W.value) return;
775
777
  let e = W.value.getBoundingClientRect(), t = window.innerHeight - e.bottom - 8, n = t < 200 && e.top > t, r = { maxHeight: `${Math.min(n ? e.top - 12 : t, 400)}px` };
776
778
  n ? r.bottom = `${window.innerHeight - e.top + 4}px` : r.top = `${e.bottom + 4}px`, d.align === "right" ? r.right = `${window.innerWidth - e.right}px` : r.left = `${e.left}px`, K.value = r;
@@ -787,54 +789,54 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
787
789
  let n = t.indexOf(document.activeElement);
788
790
  (n === -1 ? e === 1 ? t[0] : t[t.length - 1] : t[(n + e + t.length) % t.length])?.focus();
789
791
  }
790
- function ae() {
791
- U.value ? J?.current === Q && (J.current = null) : (J && J.current && J.current !== Q && J.current(), J && (J.current = Q), ie(), N.value = []), U.value = !U.value, U.value && X();
792
+ function oe() {
793
+ U.value ? J?.current === Q && (J.current = null) : (J && J.current && J.current !== Q && J.current(), J && (J.current = Q), ae(), N.value = []), U.value = !U.value, U.value && X();
792
794
  }
793
795
  function Q() {
794
796
  J?.current === Q && (J.current = null), U.value = !1;
795
797
  }
796
798
  S("m-menu-close", Q), S("m-menu-nav", {
797
799
  mode: d.submenuMode,
798
- push: H
800
+ push: ie
799
801
  }), n({
800
802
  close: Q,
801
803
  open: U
802
804
  });
803
- function oe(e) {
805
+ function se(e) {
804
806
  let t = e.target;
805
807
  if (!W.value?.contains(t)) {
806
808
  for (let e of q) if (e.contains(t)) return;
807
809
  t.closest?.(".m3-submenu") || Q();
808
810
  }
809
811
  }
810
- function se(e) {
812
+ function ce(e) {
811
813
  if (!U.value) return;
812
814
  let t = e.target;
813
815
  for (let e of q) if (e.contains(t)) return;
814
816
  t.closest?.(".m3-submenu") || Q();
815
817
  }
816
- function ce(e) {
818
+ function ue(e) {
817
819
  if (e.key === "Escape") {
818
- N.value.length ? re() : Q();
820
+ N.value.length ? H() : Q();
819
821
  return;
820
822
  }
821
823
  U.value && (e.key === "ArrowDown" ? (e.preventDefault(), Z(1)) : e.key === "ArrowUp" && (e.preventDefault(), Z(-1)));
822
824
  }
823
825
  y(() => {
824
- document.addEventListener("mousedown", oe), document.addEventListener("keydown", ce), window.addEventListener("scroll", se, !0);
826
+ document.addEventListener("mousedown", se), document.addEventListener("keydown", ue), window.addEventListener("scroll", ce, !0);
825
827
  }), b(() => {
826
- document.removeEventListener("mousedown", oe), document.removeEventListener("keydown", ce), window.removeEventListener("scroll", se, !0), z?.();
828
+ document.removeEventListener("mousedown", se), document.removeEventListener("keydown", ue), window.removeEventListener("scroll", ce, !0), B ? B() : z?.();
827
829
  });
828
- let ue = o(() => d.align === "right" ? "top right" : "top left");
830
+ let de = o(() => d.align === "right" ? "top right" : "top left");
829
831
  return (n, o) => (x(), l(r, null, [u("div", {
830
832
  ref_key: "triggerEl",
831
833
  ref: W,
832
834
  class: "inline-block",
833
- onClick: ae
835
+ onClick: oe
834
836
  }, [T(n.$slots, "trigger", { open: U.value })], 512), (x(), s(i, { to: "body" }, [f(a, {
835
837
  css: !1,
836
- onEnter: ne,
837
- onLeave: V
838
+ onEnter: V,
839
+ onLeave: re
838
840
  }, {
839
841
  default: M(() => [U.value ? (x(), l("div", {
840
842
  key: 0,
@@ -843,20 +845,20 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
843
845
  class: g(["fixed z-500 min-w-48", [e.variant === "expressive" ? "rounded-lg" : "rounded-xs", k.value ? "" : "shadow-elevation-2"]]),
844
846
  style: _({
845
847
  ...K.value,
846
- transformOrigin: ue.value
848
+ transformOrigin: de.value
847
849
  })
848
850
  }, [u("div", { class: g(["overflow-hidden", [e.variant === "expressive" ? "rounded-lg" : "rounded-xs", k.value ? "" : "bg-surface-container"]]) }, [u("div", {
849
851
  class: "relative overflow-y-auto overscroll-contain py-1",
850
852
  style: _({ maxHeight: K.value.maxHeight })
851
853
  }, [f(a, {
852
854
  css: !1,
853
- onEnter: I,
854
- onLeave: ee
855
+ onEnter: ee,
856
+ onLeave: I
855
857
  }, {
856
858
  default: M(() => [P.value ? (x(), l("div", { key: N.value.length }, [u("button", {
857
859
  type: "button",
858
860
  class: "flex w-full items-center gap-3 border-b border-outline-variant px-4 py-2.5 text-left text-body-large text-on-surface outline-none transition-colors hover:bg-on-surface/8 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary",
859
- onClick: re
861
+ onClick: H
860
862
  }, [
861
863
  f(t, {
862
864
  name: "chevron_left",
@@ -937,10 +939,10 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
937
939
  function F(e) {
938
940
  e.pointerType === "mouse" && v.value && !r.disabled && (j(), w.value = !0);
939
941
  }
940
- function I(e) {
942
+ function ee(e) {
941
943
  e.pointerType === "mouse" && (e.relatedTarget?.closest(".m3-submenu") || (w.value = !1));
942
944
  }
943
- function ee(e) {
945
+ function I(e) {
944
946
  if (e.pointerType !== "mouse") return;
945
947
  let t = e.relatedTarget;
946
948
  t?.closest(".m3-submenu") || S.value?.contains(t) || (w.value = !1);
@@ -949,7 +951,7 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
949
951
  ref_key: "itemEl",
950
952
  ref: S,
951
953
  onPointerenter: F,
952
- onPointerleave: I
954
+ onPointerleave: ee
953
955
  }, [(x(), s(E(h.value), {
954
956
  to: e.to || void 0,
955
957
  type: e.to ? void 0 : "button",
@@ -1000,13 +1002,13 @@ var re = "relative inline-flex shrink-0 items-center justify-center overflow-hid
1000
1002
  key: 0,
1001
1003
  class: "m3-submenu min-w-44 rounded-xs shadow-elevation-2",
1002
1004
  style: _(k.value),
1003
- onPointerleave: ee
1005
+ onPointerleave: I
1004
1006
  }, [u("div", De, [T(n.$slots, "children")])], 36)) : c("", !0)]),
1005
1007
  _: 3
1006
1008
  })])) : c("", !0)], 544));
1007
1009
  }
1008
1010
  });
1009
1011
  //#endregion
1010
- export { se as a, H as c, le as i, V as l, we as n, G as o, ve as r, U as s, Oe as t, R as u };
1012
+ export { se as a, re as c, le as i, V as l, we as n, W as o, ve as r, H as s, Oe as t, R as u };
1011
1013
 
1012
- //# sourceMappingURL=MMenuItem-DiilFeDO.js.map
1014
+ //# sourceMappingURL=MMenuItem-BXIxwIdM.js.map