@m3ui-vue/m3ui-vue 1.0.0 → 1.0.1

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 CHANGED
@@ -1,4 +1,4 @@
1
- # @m3ui-vue/m3ui-vue 1.0.0 — API reference
1
+ # @m3ui-vue/m3ui-vue 1.0.1 — API reference
2
2
 
3
3
  Material Design 3 components for Vue 3 + Tailwind CSS v4. Generated from the source by
4
4
  `scripts/generate-api.mjs`; full docs with live demos at https://m3ui.dev.
@@ -1746,7 +1746,7 @@ export interface NavBarItem {
1746
1746
 
1747
1747
  ### MNavigationDrawer
1748
1748
 
1749
- A slide-out or inline drawer of grouped, badge-able, optionally-nested navigation items — modal (Teleported, scrim-backed) or inline (participates in layout, supports a collapsed icon-only mode).
1749
+ A slide-out or inline drawer of grouped, badge-able, optionally-nested navigation items — modal (Teleported, scrim-backed, swiped closed toward its edge) or inline (participates in layout, supports a collapsed icon-only mode).
1750
1750
 
1751
1751
  Props:
1752
1752
  - `modelValue: boolean` (v-model) — Open/closed state (v-model)
@@ -1757,6 +1757,7 @@ Props:
1757
1757
  - `collapsed?: boolean` — Compact mode (72px) showing only icons — inline variant only
1758
1758
  - `width?: string` — Custom drawer width (e.g. "320px", "25rem"). Defaults to 22.5rem (360px)
1759
1759
  - `side?: "top" | "right" | "bottom" | "left" = "left"` — Which side the drawer opens from. Top/bottom are only available for the modal variant — the inline variant always renders on left or right.
1760
+ - `swipeEnabled?: boolean = true` — Lets the modal drawer be swiped closed toward its edge; with false it only closes through v-model or the scrim
1760
1761
 
1761
1762
  Events:
1762
1763
  - `update:modelValue(boolean)` — Open/closed state for v-model
@@ -32,14 +32,14 @@ var I = /* @__PURE__ */ new WeakMap(), L = {
32
32
  let t = I.get(e);
33
33
  t && e.removeEventListener("pointerdown", t.onPointerDown), I.delete(e);
34
34
  }
35
- }, R = ["aria-label"], z = {
35
+ }, R = ["aria-label"], ne = {
36
36
  key: 0,
37
37
  class: "block h-full w-full animate-spin rounded-full border-2 border-current border-t-transparent"
38
- }, B = [
38
+ }, z = [
39
39
  "width",
40
40
  "height",
41
41
  "viewBox"
42
- ], V = ["d", "stroke-dasharray"], H = 3, U = 9, W = /* @__PURE__ */ p({
42
+ ], B = ["d", "stroke-dasharray"], V = 3, H = 9, U = /* @__PURE__ */ p({
43
43
  __name: "MSpinner",
44
44
  props: {
45
45
  size: { default: 20 },
@@ -50,10 +50,10 @@ var I = /* @__PURE__ */ new WeakMap(), L = {
50
50
  label: {}
51
51
  },
52
52
  setup(t) {
53
- let n = t, r = e(), i = o(() => (n.size / 2 - 1 - H / 2) / 1.25), a = o(() => n.size / 2), s = o(() => {
53
+ let n = t, r = e(), i = o(() => (n.size / 2 - 1 - V / 2) / 1.25), a = o(() => n.size / 2), s = o(() => {
54
54
  let e = a.value, t = i.value, n = t * .08, r = [], o = 0, s = 0, c = 0;
55
55
  for (let i = 0; i <= 216; i++) {
56
- let a = 2 * Math.PI * i / 216 - Math.PI / 2, l = t + n * Math.sin(U * a), u = e + l * Math.cos(a), d = e + l * Math.sin(a);
56
+ let a = 2 * Math.PI * i / 216 - Math.PI / 2, l = t + n * Math.sin(H * a), u = e + l * Math.cos(a), d = e + l * Math.sin(a);
57
57
  i > 0 && (o += Math.sqrt((u - s) ** 2 + (d - c) ** 2)), r.push(`${i === 0 ? "M" : "L"}${u.toFixed(2)},${d.toFixed(2)}`), s = u, c = d;
58
58
  }
59
59
  let l = o * .58, u = o - l, d = `${l.toFixed(1)} ${u.toFixed(1)}`;
@@ -82,14 +82,14 @@ var I = /* @__PURE__ */ new WeakMap(), L = {
82
82
  }, [u("path", {
83
83
  d: s.value.path,
84
84
  stroke: "currentColor",
85
- "stroke-width": H,
85
+ "stroke-width": V,
86
86
  "stroke-linecap": "round",
87
87
  "stroke-dasharray": s.value.dash,
88
88
  class: "animate-[m3-wavy-travel_2s_linear_infinite]",
89
89
  style: v({ "--m3-wave-len": s.value.len })
90
- }, null, 12, V)], 12, B)) : (S(), l("span", z))], 12, R));
90
+ }, null, 12, B)], 12, z)) : (S(), l("span", ne))], 12, R));
91
91
  }
92
- }), ne = [
92
+ }), re = [
93
93
  "bg-surface-container-highest",
94
94
  "bg-surface-container-high",
95
95
  "bg-surface-container-low",
@@ -116,8 +116,8 @@ var I = /* @__PURE__ */ new WeakMap(), L = {
116
116
  "bg-tertiary",
117
117
  "bg-error"
118
118
  ];
119
- function re(e) {
120
- for (let t of ne) if (e.classList.contains(t)) return `var(--color-${t.slice(3)})`;
119
+ function W(e) {
120
+ for (let t of re) if (e.classList.contains(t)) return `var(--color-${t.slice(3)})`;
121
121
  return null;
122
122
  }
123
123
  function G(e) {
@@ -137,7 +137,7 @@ function K(e, t) {
137
137
  function i() {
138
138
  let t = e.value?.parentElement ?? null;
139
139
  for (; t;) {
140
- let e = re(t);
140
+ let e = W(t);
141
141
  if (e) {
142
142
  r(e);
143
143
  return;
@@ -630,7 +630,7 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
630
630
  style: v(d.value)
631
631
  }, {
632
632
  default: M(() => [
633
- e.iconPos === "leading" ? (S(), l(r, { key: 0 }, [e.loading ? (S(), s(W, {
633
+ e.iconPos === "leading" ? (S(), l(r, { key: 0 }, [e.loading ? (S(), s(U, {
634
634
  key: 0,
635
635
  size: b.value
636
636
  }, null, 8, ["size"])) : e.icon ? (S(), s(t, {
@@ -639,7 +639,7 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
639
639
  size: y.value
640
640
  }, null, 8, ["name", "size"])) : c("", !0)], 64)) : c("", !0),
641
641
  E(n.$slots, "default"),
642
- e.iconPos === "trailing" ? (S(), l(r, { key: 1 }, [e.loading ? (S(), s(W, {
642
+ e.iconPos === "trailing" ? (S(), l(r, { key: 1 }, [e.loading ? (S(), s(U, {
643
643
  key: 0,
644
644
  size: b.value
645
645
  }, null, 8, ["size"])) : e.icon ? (S(), s(t, {
@@ -856,39 +856,42 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
856
856
  alpha: 1
857
857
  }), L = e, e;
858
858
  }
859
- let z = 0, B = null, V = null;
860
- function H(e, t, n) {
861
- B?.();
862
- let r = e, i = R(), a = i.length - 1, o = n ? 1 : -1, s = n ? a : 0, c = 0, l = 0, u = !1;
863
- function d(e) {
864
- let t = i[Math.round(Math.max(0, Math.min(a, e)))];
865
- r.style.transform = `scale(${t.scale})`, r.style.opacity = String(Math.min(1, Math.max(0, t.alpha)));
866
- }
867
- function f(e) {
868
- if (u) return;
869
- let r = c ? (e - c) / 1e3 / $ : 1;
870
- if (c = e, z = Math.max(0, Math.min(a, z + o * r)), d(z), n && z >= s || !n && z <= s) {
871
- B = null, V = null, t();
872
- return;
873
- }
874
- l = requestAnimationFrame(f);
859
+ let ne = 0, z = null, B = null;
860
+ function V(e, t, n) {
861
+ z?.();
862
+ let r = e, i = R(), a = i.length - 1, o = Math.round(Math.max(0, Math.min(a, ne))), s = n ? a : 0, c = n ? 1 : -1, l = [];
863
+ for (let e = o; n ? e <= s : e >= s; e += c) l.push(i[e]);
864
+ let u = (e) => ({
865
+ transform: `scale(${e.scale})`,
866
+ opacity: String(Math.min(1, Math.max(0, e.alpha)))
867
+ });
868
+ Object.assign(r.style, u(i[s]));
869
+ let d = !1;
870
+ function f() {
871
+ d || (d = !0, ne = s, z = null, B = null, t());
875
872
  }
876
- B = () => {
877
- u = !0, cancelAnimationFrame(l);
878
- }, V = n ? null : () => {
879
- B?.(), B = null, V = null, t();
880
- }, d(z), l = requestAnimationFrame(f);
873
+ if (l.length < 2 || typeof r.animate != "function") return f();
874
+ let p = r.animate(l.map(u), {
875
+ duration: (l.length - 1) * $ * 1e3,
876
+ easing: "linear"
877
+ });
878
+ p.finished.catch(() => {}), p.onfinish = f, z = () => {
879
+ let e = Number(p.currentTime ?? 0) / ($ * 1e3);
880
+ ne = Math.max(0, Math.min(a, o + c * e)), d = !0, p.cancel();
881
+ }, B = n ? null : () => {
882
+ z?.(), z = null, B = null, t();
883
+ };
881
884
  }
882
- function U(e, t) {
883
- H(e, t, !0);
885
+ function H(e, t) {
886
+ V(e, t, !0);
884
887
  }
885
- function W(e, t) {
886
- H(e, t, !1);
888
+ function U(e, t) {
889
+ V(e, t, !1);
887
890
  }
888
- function ne(e) {
891
+ function re(e) {
889
892
  F.value = "forward", N.value.push(e), g(() => oe());
890
893
  }
891
- function re() {
894
+ function W() {
892
895
  F.value = "backward", N.value.pop(), g(() => oe());
893
896
  }
894
897
  let G = w(!1), K = w(null), q = w(null), J = w({}), Y = m("m-menu-panel-registry", /* @__PURE__ */ new Set());
@@ -924,7 +927,7 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
924
927
  }
925
928
  C("m-menu-close", Z), C("m-menu-nav", {
926
929
  mode: d.submenuMode,
927
- push: ne
930
+ push: re
928
931
  }), n({
929
932
  close: Z,
930
933
  open: G
@@ -944,7 +947,7 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
944
947
  }
945
948
  function ue(e) {
946
949
  if (e.key === "Escape") {
947
- N.value.length ? re() : Z();
950
+ N.value.length ? W() : Z();
948
951
  return;
949
952
  }
950
953
  G.value && (e.key === "ArrowDown" ? (e.preventDefault(), se(1)) : e.key === "ArrowUp" && (e.preventDefault(), se(-1)));
@@ -952,7 +955,7 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
952
955
  b(() => {
953
956
  document.addEventListener("mousedown", Q), document.addEventListener("keydown", ue), window.addEventListener("scroll", le, !0);
954
957
  }), x(() => {
955
- document.removeEventListener("mousedown", Q), document.removeEventListener("keydown", ue), window.removeEventListener("scroll", le, !0), V ? V() : B?.();
958
+ document.removeEventListener("mousedown", Q), document.removeEventListener("keydown", ue), window.removeEventListener("scroll", le, !0), B ? B() : z?.();
956
959
  });
957
960
  let de = o(() => d.align === "right" ? "top right" : "top left");
958
961
  return (n, o) => (S(), l(r, null, [u("div", h({
@@ -963,8 +966,8 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
963
966
  onClick: ce
964
967
  }), [E(n.$slots, "trigger", { open: G.value })], 16), (S(), s(i, { to: "body" }, [f(a, {
965
968
  css: !1,
966
- onEnter: U,
967
- onLeave: W
969
+ onEnter: H,
970
+ onLeave: U
968
971
  }, {
969
972
  default: M(() => [G.value ? (S(), l("div", {
970
973
  key: 0,
@@ -986,7 +989,7 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
986
989
  default: M(() => [P.value ? (S(), l("div", { key: N.value.length }, [u("button", {
987
990
  type: "button",
988
991
  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",
989
- onClick: re
992
+ onClick: W
990
993
  }, [
991
994
  f(t, {
992
995
  name: "chevron_left",
@@ -1044,7 +1047,7 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
1044
1047
  setup(e, { emit: n }) {
1045
1048
  let r = e, d = n, p = o(() => r.checked !== void 0), h = o(() => p.value || r.selected !== void 0), y = o(() => !!(r.checked ?? r.selected)), C = o(() => h.value && !r.icon), T = o(() => r.selectedIcon ?? (r.icon ? void 0 : "check")), A = w("single");
1046
1049
  function N() {
1047
- let e = V.value;
1050
+ let e = B.value;
1048
1051
  if (!e || !h.value) return;
1049
1052
  let t = (e) => !!e?.hasAttribute("data-m3-menu-choice"), n = t(e.previousElementSibling), r = t(e.nextElementSibling);
1050
1053
  A.value = n && r ? "middle" : n ? "last" : r ? "first" : "single";
@@ -1065,23 +1068,23 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
1065
1068
  ];
1066
1069
  }
1067
1070
  let { snap: F } = Q(() => h.value ? [...P(), C.value && y.value ? Le : 0] : [], ([e, t, n, r, i]) => {
1068
- let a = H.value instanceof HTMLElement ? H.value : H.value?.$el;
1069
- a && r !== void 0 && (a.style.borderRadius = `${e}px ${t}px ${n}px ${r}px`), U.value && i !== void 0 && (U.value.style.width = `${i}px`);
1071
+ let a = V.value instanceof HTMLElement ? V.value : V.value?.$el;
1072
+ a && r !== void 0 && (a.style.borderRadius = `${e}px ${t}px ${n}px ${r}px`), H.value && i !== void 0 && (H.value.style.width = `${i}px`);
1070
1073
  }, ae);
1071
1074
  ee(A, () => F());
1072
1075
  let te = null;
1073
1076
  b(() => {
1074
1077
  N();
1075
- let e = V.value?.parentElement;
1078
+ let e = B.value?.parentElement;
1076
1079
  e && (te = new MutationObserver(N), te.observe(e, { childList: !0 }));
1077
1080
  }), x(() => te?.disconnect()), ee(h, () => g(N)), Q(() => C.value ? [+!!y.value] : [], ([e]) => {
1078
- U.value && e !== void 0 && (U.value.style.opacity = String(e));
1081
+ H.value && e !== void 0 && (H.value.style.opacity = String(e));
1079
1082
  }, oe);
1080
- let I = j(), L = o(() => r.to ? "RouterLink" : "button"), R = o(() => !!I.children), z = m("m-menu-close", null), B = m("m-menu-nav", null), V = w(), H = w(), U = w(), W = w(!1), ne = w({});
1081
- function re() {
1082
- if (!V.value) return;
1083
- let e = V.value.getBoundingClientRect(), t = e.right + 200 > window.innerWidth;
1084
- ne.value = {
1083
+ let I = j(), L = o(() => r.to ? "RouterLink" : "button"), R = o(() => !!I.children), ne = m("m-menu-close", null), z = m("m-menu-nav", null), B = w(), V = w(), H = w(), U = w(!1), re = w({});
1084
+ function W() {
1085
+ if (!B.value) return;
1086
+ let e = B.value.getBoundingClientRect(), t = e.right + 200 > window.innerWidth;
1087
+ re.value = {
1085
1088
  position: "fixed",
1086
1089
  top: `${e.top}px`,
1087
1090
  ...t ? { right: `${window.innerWidth - e.left}px` } : { left: `${e.right}px` },
@@ -1089,45 +1092,45 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
1089
1092
  };
1090
1093
  }
1091
1094
  function G() {
1092
- if (W.value) {
1093
- W.value = !1;
1095
+ if (U.value) {
1096
+ U.value = !1;
1094
1097
  return;
1095
1098
  }
1096
- re(), W.value = !0;
1099
+ W(), U.value = !0;
1097
1100
  }
1098
1101
  function K() {
1099
1102
  if (!r.disabled) {
1100
1103
  if (R.value) {
1101
- B?.mode === "push" ? B.push({
1104
+ z?.mode === "push" ? z.push({
1102
1105
  icon: r.icon,
1103
1106
  header: I.default,
1104
1107
  content: I.children
1105
1108
  }) : G();
1106
1109
  return;
1107
1110
  }
1108
- p.value && d("update:checked", !r.checked), d("click"), (r.keepOpen ?? p.value) || z?.();
1111
+ p.value && d("update:checked", !r.checked), d("click"), (r.keepOpen ?? p.value) || ne?.();
1109
1112
  }
1110
1113
  }
1111
1114
  function q(e) {
1112
- e.pointerType === "mouse" && R.value && !r.disabled && (re(), W.value = !0);
1115
+ e.pointerType === "mouse" && R.value && !r.disabled && (W(), U.value = !0);
1113
1116
  }
1114
1117
  function J(e) {
1115
- e.pointerType === "mouse" && (e.relatedTarget?.closest(".m3-submenu") || (W.value = !1));
1118
+ e.pointerType === "mouse" && (e.relatedTarget?.closest(".m3-submenu") || (U.value = !1));
1116
1119
  }
1117
1120
  function Y(e) {
1118
1121
  if (e.pointerType !== "mouse") return;
1119
1122
  let t = e.relatedTarget;
1120
- t?.closest(".m3-submenu") || V.value?.contains(t) || (W.value = !1);
1123
+ t?.closest(".m3-submenu") || B.value?.contains(t) || (U.value = !1);
1121
1124
  }
1122
1125
  return (n, r) => (S(), l("div", {
1123
1126
  ref_key: "itemEl",
1124
- ref: V,
1127
+ ref: B,
1125
1128
  "data-m3-menu-choice": h.value || void 0,
1126
1129
  onPointerenter: q,
1127
1130
  onPointerleave: J
1128
1131
  }, [(S(), s(D(L.value), {
1129
1132
  ref_key: "controlEl",
1130
- ref: H,
1133
+ ref: V,
1131
1134
  to: e.to || void 0,
1132
1135
  type: e.to ? void 0 : "button",
1133
1136
  role: h.value ? p.value ? "menuitemcheckbox" : "menuitemradio" : void 0,
@@ -1144,14 +1147,14 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
1144
1147
  ]]),
1145
1148
  disabled: e.disabled || void 0,
1146
1149
  "aria-haspopup": R.value ? "menu" : void 0,
1147
- "aria-expanded": R.value ? W.value : void 0,
1150
+ "aria-expanded": R.value ? U.value : void 0,
1148
1151
  onClick: K
1149
1152
  }, {
1150
1153
  default: M(() => [
1151
1154
  C.value ? (S(), l("span", {
1152
1155
  key: 0,
1153
1156
  ref_key: "iconSlotEl",
1154
- ref: U,
1157
+ ref: H,
1155
1158
  class: "-mr-3 flex shrink-0 overflow-hidden",
1156
1159
  style: {
1157
1160
  width: "0",
@@ -1191,7 +1194,7 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
1191
1194
  "disabled",
1192
1195
  "aria-haspopup",
1193
1196
  "aria-expanded"
1194
- ])), R.value && k(B)?.mode !== "push" ? (S(), s(i, {
1197
+ ])), R.value && k(z)?.mode !== "push" ? (S(), s(i, {
1195
1198
  key: 0,
1196
1199
  to: "body"
1197
1200
  }, [f(a, {
@@ -1200,10 +1203,10 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
1200
1203
  "leave-active-class": "transition-opacity duration-75",
1201
1204
  "leave-to-class": "opacity-0"
1202
1205
  }, {
1203
- default: M(() => [W.value ? (S(), l("div", {
1206
+ default: M(() => [U.value ? (S(), l("div", {
1204
1207
  key: 0,
1205
1208
  class: "m3-submenu min-w-44 rounded-xs shadow-elevation-2",
1206
- style: v(ne.value),
1209
+ style: v(re.value),
1207
1210
  onPointerleave: Y
1208
1211
  }, [u("div", Ie, [E(n.$slots, "children")])], 36)) : c("", !0)]),
1209
1212
  _: 3
@@ -1360,6 +1363,6 @@ var le = ie(.4, 0, .2, 1), ue = "relative inline-flex shrink-0 items-center just
1360
1363
  }
1361
1364
  });
1362
1365
  //#endregion
1363
- export { J as _, we as a, W as b, se as c, ae as d, le as f, Y as g, X as h, Ee as i, ce as l, ie as m, Re as n, pe as o, Q as p, Me as r, de as s, qe as t, oe as u, q as v, L as x, K as y };
1366
+ export { J as _, we as a, U as b, se as c, ae as d, le as f, Y as g, X as h, Ee as i, ce as l, ie as m, Re as n, pe as o, Q as p, Me as r, de as s, qe as t, oe as u, q as v, L as x, K as y };
1364
1367
 
1365
- //# sourceMappingURL=MTextField-TZ7lfr09.js.map
1368
+ //# sourceMappingURL=MTextField-BPbFeI9M.js.map