@m3ui-vue/m3ui-vue 1.0.3 → 1.1.0

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.
Files changed (99) hide show
  1. package/dist/API.md +75 -11
  2. package/dist/MMenuItem-BOkcVtEe.js +809 -0
  3. package/dist/MMenuItem-BOkcVtEe.js.map +1 -0
  4. package/dist/{MSlider-CdNIH7jc.js → MSlider-BXsBv0ox.js} +208 -182
  5. package/dist/MSlider-BXsBv0ox.js.map +1 -0
  6. package/dist/{MTextField-B4X92vH_.js → MTextField-rML9jnXs.js} +2 -2
  7. package/dist/{MTextField-B4X92vH_.js.map → MTextField-rML9jnXs.js.map} +1 -1
  8. package/dist/api.json +1 -1
  9. package/dist/code-editor.js +1 -1
  10. package/dist/components/MBottomSheet.vue.d.ts +20 -1
  11. package/dist/components/MDialog.vue.d.ts +17 -8
  12. package/dist/components/MDragDropList.vue.d.ts +1 -1
  13. package/dist/components/MMap.vue.d.ts +4 -4
  14. package/dist/components/MMapControl.vue.d.ts +20 -3
  15. package/dist/components/MMapMarker.vue.d.ts +5 -2
  16. package/dist/components/MMapPopup.vue.d.ts +5 -3
  17. package/dist/components/MMenuItem.vue.d.ts +2 -2
  18. package/dist/components/MSeekBar.vue.d.ts +122 -0
  19. package/dist/components/MSplitButton.vue.d.ts +2 -2
  20. package/dist/components/_MMapAttribution.vue.d.ts +7 -0
  21. package/dist/composables/_mapPin.d.ts +5 -0
  22. package/dist/composables/_popupPosition.d.ts +12 -0
  23. package/dist/composables/_useCalendarMonth.d.ts +24 -0
  24. package/dist/composables/_useEscapeStack.d.ts +3 -0
  25. package/dist/composables/_useScrollLock.d.ts +8 -0
  26. package/dist/composables/_useSheetMotion.d.ts +16 -1
  27. package/dist/composables/useLocale.d.ts +8 -0
  28. package/dist/index.d.ts +2 -0
  29. package/dist/locales/index.js +56 -0
  30. package/dist/locales/index.js.map +1 -1
  31. package/dist/m3ui-vue.css +1 -1
  32. package/dist/m3ui.js +5269 -4714
  33. package/dist/m3ui.js.map +1 -1
  34. package/dist/map.js +777 -641
  35. package/dist/map.js.map +1 -1
  36. package/dist/rich-text-editor.js +8 -8
  37. package/dist/styles.css +1 -1
  38. package/dist/{useLocale-b5-hzsL3.js → useLocale-CqQrhWFl.js} +9 -1
  39. package/dist/useLocale-CqQrhWFl.js.map +1 -0
  40. package/package.json +1 -1
  41. package/src/__tests__/MDialog.test.ts +30 -0
  42. package/src/__tests__/MMap.test.ts +132 -2
  43. package/src/__tests__/MSeekBar.test.ts +170 -0
  44. package/src/__tests__/MTooltip.test.ts +110 -0
  45. package/src/__tests__/_fakeMaplibre.ts +3 -0
  46. package/src/__tests__/calendarMonth.test.ts +59 -0
  47. package/src/__tests__/pickerModals.test.ts +128 -0
  48. package/src/__tests__/popupPosition.test.ts +224 -0
  49. package/src/__tests__/scrollLock.test.ts +110 -0
  50. package/src/__tests__/sheets.test.ts +158 -0
  51. package/src/components/MAutocomplete.vue +2 -4
  52. package/src/components/MBottomSheet.vue +211 -13
  53. package/src/components/MCommandPalette.vue +4 -6
  54. package/src/components/MContextMenu.vue +19 -5
  55. package/src/components/MDatePicker.vue +29 -70
  56. package/src/components/MDatePickerModal.vue +116 -172
  57. package/src/components/MDateRangePicker.vue +29 -51
  58. package/src/components/MDateRangePickerModal.vue +84 -162
  59. package/src/components/MDialog.vue +87 -63
  60. package/src/components/MLightbox.vue +6 -3
  61. package/src/components/MMap.vue +74 -28
  62. package/src/components/MMapControl.vue +121 -7
  63. package/src/components/MMapIdentify.vue +2 -1
  64. package/src/components/MMapMarker.vue +14 -7
  65. package/src/components/MMapPopup.vue +8 -4
  66. package/src/components/MMenu.vue +31 -12
  67. package/src/components/MMenuItem.vue +21 -4
  68. package/src/components/MMultiAutocomplete.vue +2 -4
  69. package/src/components/MMultiSelect.vue +2 -4
  70. package/src/components/MNavigationDrawer.vue +2 -8
  71. package/src/components/MNavigationRail.vue +2 -3
  72. package/src/components/MSearchBar.vue +2 -5
  73. package/src/components/MSeekBar.vue +593 -0
  74. package/src/components/MSelect.vue +2 -8
  75. package/src/components/MSplitButton.vue +23 -7
  76. package/src/components/MSpotlightSearch.vue +4 -6
  77. package/src/components/MTimePicker.vue +23 -6
  78. package/src/components/MTimePickerModal.vue +213 -226
  79. package/src/components/MTooltip.vue +99 -3
  80. package/src/components/_MMapAttribution.vue +81 -0
  81. package/src/composables/_mapPin.ts +25 -0
  82. package/src/composables/_popupPosition.ts +39 -0
  83. package/src/composables/_useCalendarMonth.ts +74 -0
  84. package/src/composables/_useEscapeStack.ts +33 -0
  85. package/src/composables/_useScrollLock.ts +41 -0
  86. package/src/composables/_useSheetMotion.ts +82 -20
  87. package/src/composables/useLocale.ts +16 -0
  88. package/src/index.ts +2 -0
  89. package/src/locales/de.ts +8 -0
  90. package/src/locales/es.ts +8 -0
  91. package/src/locales/fr.ts +8 -0
  92. package/src/locales/ja.ts +8 -0
  93. package/src/locales/ko.ts +8 -0
  94. package/src/locales/pt.ts +8 -0
  95. package/src/locales/zh.ts +8 -0
  96. package/dist/MMenuItem-DFyXflk9.js +0 -707
  97. package/dist/MMenuItem-DFyXflk9.js.map +0 -1
  98. package/dist/MSlider-CdNIH7jc.js.map +0 -1
  99. package/dist/useLocale-b5-hzsL3.js.map +0 -1
@@ -1,707 +0,0 @@
1
- import { i as e } from "./useLocale-b5-hzsL3.js";
2
- import { a as t, c as n, g as r, h as i, n as a, o } from "./MTextField-B4X92vH_.js";
3
- import { t as s } from "./MIcon-DLOkQduI.js";
4
- import { t as c } from "./_plugin-vue_export-helper-B3ysoDQm.js";
5
- import { Fragment as l, Teleport as u, Transition as d, computed as f, createBlock as p, createCommentVNode as m, createElementBlock as h, createElementVNode as g, createTextVNode as _, createVNode as v, defineComponent as y, inject as b, mergeProps as x, nextTick as S, normalizeClass as C, normalizeStyle as w, onMounted as T, onUnmounted as ee, openBlock as E, provide as D, ref as O, renderList as k, renderSlot as A, resolveDynamicComponent as j, toDisplayString as M, unref as N, useSlots as te, watch as P, withCtx as F, withDirectives as ne, withModifiers as I } from "vue";
6
- //#region src/components/MButton.vue?vue&type=script&setup=true&lang.ts
7
- var L = "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]", R = /* @__PURE__ */ y({
8
- __name: "MButton",
9
- props: {
10
- variant: { default: "filled" },
11
- color: { default: "primary" },
12
- type: { default: "button" },
13
- disabled: {
14
- type: Boolean,
15
- default: !1
16
- },
17
- loading: {
18
- type: Boolean,
19
- default: !1
20
- },
21
- icon: {},
22
- iconPos: { default: "leading" },
23
- size: { default: "sm" },
24
- shape: { default: "rounded" },
25
- to: {},
26
- rippleColor: {}
27
- },
28
- setup(e) {
29
- let t = ["primary", "error"], n = e, a = f(() => n.to ? "RouterLink" : "button"), o = f(() => !!n.color && !t.includes(n.color)), c = f(() => {
30
- if (o.value) return {
31
- "--color-primary": n.color,
32
- "--color-on-primary": "#ffffff",
33
- "--color-primary-container": n.color + "33",
34
- "--color-on-primary-container": n.color
35
- };
36
- }), u = f(() => n.color === "error"), d = f(() => {
37
- switch (n.variant) {
38
- case "filled":
39
- case "tonal":
40
- case "elevated": return "disabled:bg-on-surface/10";
41
- case "outlined": return u.value ? "disabled:border-error/10" : "disabled:border-outline-variant/10";
42
- default: return "";
43
- }
44
- }), g = {
45
- xs: {
46
- h: "h-8",
47
- text: "text-label-large",
48
- icon: 20,
49
- spinner: 16,
50
- gap: "gap-1",
51
- px: "px-3",
52
- pxText: "px-2",
53
- squareRadius: "rounded-md"
54
- },
55
- sm: {
56
- h: "h-10",
57
- text: "text-label-large",
58
- icon: 20,
59
- spinner: 16,
60
- gap: "gap-2",
61
- px: "px-4",
62
- pxText: "px-3",
63
- squareRadius: "rounded-md"
64
- },
65
- md: {
66
- h: "h-14",
67
- text: "text-title-medium",
68
- icon: 24,
69
- spinner: 18,
70
- gap: "gap-2",
71
- px: "px-6",
72
- pxText: "px-3",
73
- squareRadius: "rounded-lg"
74
- },
75
- lg: {
76
- h: "h-24",
77
- text: "text-headline-small",
78
- icon: 32,
79
- spinner: 26,
80
- gap: "gap-3",
81
- px: "px-12",
82
- pxText: "px-4",
83
- squareRadius: "rounded-xl"
84
- },
85
- xl: {
86
- h: "h-[136px]",
87
- text: "text-headline-large",
88
- icon: 40,
89
- spinner: 34,
90
- gap: "gap-4",
91
- px: "px-16",
92
- pxText: "px-4",
93
- squareRadius: "rounded-xl"
94
- }
95
- }, _ = f(() => g[n.size] ?? g.sm), v = f(() => `${_.value.h} ${_.value.text} ${_.value.gap}`), y = f(() => _.value.icon), b = f(() => _.value.spinner), x = f(() => n.variant === "text" ? _.value.pxText : _.value.px), S = f(() => n.shape === "squared" ? _.value.squareRadius : "rounded-full"), T = f(() => {
96
- let e = u.value;
97
- switch (n.variant) {
98
- case "filled": return e ? "bg-error text-on-error enabled:hover:shadow-elevation-1 enabled:active:shadow-none" : "bg-primary text-on-primary enabled:hover:shadow-elevation-1 enabled:active:shadow-none";
99
- case "tonal": return e ? "bg-error-container text-on-error-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none" : "bg-secondary-container text-on-secondary-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none";
100
- case "elevated": return e ? "bg-surface-container-low text-error shadow-elevation-1 enabled:hover:shadow-elevation-2" : "bg-surface-container-low text-primary shadow-elevation-1 enabled:hover:shadow-elevation-2";
101
- case "outlined": return e ? "border border-error text-error" : "border border-outline-variant text-primary";
102
- case "text": return e ? "text-error" : "text-primary";
103
- default: return "";
104
- }
105
- });
106
- return (t, n) => ne((E(), p(j(a.value), {
107
- to: e.to || void 0,
108
- type: e.to ? void 0 : e.type,
109
- disabled: e.disabled || e.loading,
110
- class: C([
111
- L,
112
- S.value,
113
- v.value,
114
- x.value,
115
- T.value,
116
- d.value
117
- ]),
118
- style: w(c.value)
119
- }, {
120
- default: F(() => [
121
- e.iconPos === "leading" ? (E(), h(l, { key: 0 }, [e.loading ? (E(), p(i, {
122
- key: 0,
123
- size: b.value
124
- }, null, 8, ["size"])) : e.icon ? (E(), p(s, {
125
- key: 1,
126
- name: e.icon,
127
- size: y.value
128
- }, null, 8, ["name", "size"])) : m("", !0)], 64)) : m("", !0),
129
- A(t.$slots, "default"),
130
- e.iconPos === "trailing" ? (E(), h(l, { key: 1 }, [e.loading ? (E(), p(i, {
131
- key: 0,
132
- size: b.value
133
- }, null, 8, ["size"])) : e.icon ? (E(), p(s, {
134
- key: 1,
135
- name: e.icon,
136
- size: y.value
137
- }, null, 8, ["name", "size"])) : m("", !0)], 64)) : m("", !0)
138
- ]),
139
- _: 3
140
- }, 8, [
141
- "to",
142
- "type",
143
- "disabled",
144
- "class",
145
- "style"
146
- ])), [[N(r), {
147
- disabled: e.disabled || e.loading,
148
- color: e.rippleColor
149
- }]]);
150
- }
151
- }), z = { class: "relative px-6 pt-6 pb-2" }, B = {
152
- key: 0,
153
- class: "absolute right-4 top-4"
154
- }, V = {
155
- key: 1,
156
- class: "mb-4 flex justify-center text-secondary"
157
- }, H = {
158
- key: 0,
159
- class: "shrink-0 border-t border-outline-variant"
160
- }, U = {
161
- key: 1,
162
- class: "flex flex-wrap justify-end gap-2 px-6 pt-4 pb-6"
163
- }, W = {
164
- key: 0,
165
- class: "dialog-fs fixed inset-0 z-50 flex flex-col bg-surface"
166
- }, G = { class: "flex h-14 shrink-0 items-center gap-2 px-2" }, K = { class: "flex-1 text-title-large font-medium text-on-surface" }, q = {
167
- key: 1,
168
- class: "flex items-center gap-2"
169
- }, J = { class: "flex-1 overflow-y-auto px-6 py-4 text-body-medium text-on-surface-variant" }, Y = /*#__PURE__*/ c(/* @__PURE__ */ y({
170
- __name: "MDialog",
171
- props: {
172
- modelValue: { type: Boolean },
173
- title: {},
174
- maxWidth: { default: "max-w-[560px]" },
175
- maxHeight: { default: "max-h-[90vh]" },
176
- persistent: {
177
- type: Boolean,
178
- default: !1
179
- },
180
- fullscreen: {
181
- type: Boolean,
182
- default: !1
183
- },
184
- closeLabel: {},
185
- closable: {
186
- type: Boolean,
187
- default: !0
188
- }
189
- },
190
- emits: ["update:modelValue"],
191
- setup(t, { emit: n }) {
192
- let r = t, i = e(), o = (e) => /^-?[\d.]+[a-z%]*$|^(calc|min|max|clamp|var)\(/i.test(e.trim()), s = f(() => [r.maxWidth, r.maxHeight].filter((e) => !o(e))), c = f(() => ({
193
- ...o(r.maxWidth) ? { maxWidth: r.maxWidth } : {},
194
- ...o(r.maxHeight) ? { maxHeight: r.maxHeight } : {}
195
- })), l = n;
196
- function y() {
197
- r.persistent || l("update:modelValue", !1);
198
- }
199
- function b(e) {
200
- e.key === "Escape" && y();
201
- }
202
- let x = O(), T = O(), D = O(!1), k;
203
- function j() {
204
- let e = x.value;
205
- if (!e) {
206
- D.value = !1;
207
- return;
208
- }
209
- D.value = e.scrollHeight - e.scrollTop - e.clientHeight > 1;
210
- }
211
- return P(() => r.modelValue, async (e) => {
212
- e ? (document.addEventListener("keydown", b), document.body.style.overflow = "hidden", await S(), j(), k = new ResizeObserver(j), x.value && k.observe(x.value), T.value && k.observe(T.value)) : (document.removeEventListener("keydown", b), document.body.style.overflow = "", k?.disconnect(), k = void 0);
213
- }), ee(() => {
214
- document.removeEventListener("keydown", b), k?.disconnect();
215
- }), (e, n) => (E(), p(u, { to: "body" }, [t.fullscreen ? (E(), p(d, {
216
- key: 1,
217
- name: "m3-dialog-fs",
218
- appear: ""
219
- }, {
220
- default: F(() => [t.modelValue ? (E(), h("div", W, [g("div", G, [
221
- t.persistent ? m("", !0) : (E(), p(a, {
222
- key: 0,
223
- icon: "close",
224
- label: t.closeLabel ?? N(i).close,
225
- onClick: y
226
- }, null, 8, ["label"])),
227
- g("h2", K, [A(e.$slots, "title", {}, () => [_(M(t.title), 1)], !0)]),
228
- e.$slots.actions ? (E(), h("div", q, [A(e.$slots, "actions", {}, void 0, !0)])) : m("", !0)
229
- ]), g("div", J, [A(e.$slots, "default", {}, void 0, !0)])])) : m("", !0)]),
230
- _: 3
231
- })) : (E(), p(d, {
232
- key: 0,
233
- name: "m3-dialog",
234
- appear: ""
235
- }, {
236
- default: F(() => [t.modelValue ? (E(), h("div", {
237
- key: 0,
238
- class: "fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4",
239
- onClick: I(y, ["self"])
240
- }, [g("div", {
241
- class: C(["dialog-box flex min-w-[280px] w-full flex-col rounded-xl bg-surface-container-high shadow-elevation-3", s.value]),
242
- style: w(c.value)
243
- }, [
244
- g("div", z, [
245
- t.closable && !t.persistent ? (E(), h("div", B, [v(a, {
246
- icon: "close",
247
- label: t.closeLabel ?? N(i).close,
248
- onClick: y
249
- }, null, 8, ["label"])])) : m("", !0),
250
- e.$slots.icon ? (E(), h("div", V, [A(e.$slots, "icon", {}, void 0, !0)])) : m("", !0),
251
- g("h2", { class: C(["text-headline-small text-on-surface", [e.$slots.icon ? "text-center" : "text-left", t.closable && !t.persistent ? e.$slots.icon ? "px-10" : "pr-10" : ""]]) }, [A(e.$slots, "title", {}, () => [_(M(t.title), 1)], !0)], 2)
252
- ]),
253
- g("div", {
254
- ref_key: "contentEl",
255
- ref: x,
256
- class: C(["overflow-y-auto px-6 pt-2 text-body-medium text-on-surface-variant", e.$slots.actions ? "pb-2" : "pb-6"]),
257
- onScroll: j
258
- }, [g("div", {
259
- ref_key: "contentInnerEl",
260
- ref: T
261
- }, [A(e.$slots, "default", {}, void 0, !0)], 512)], 34),
262
- D.value && e.$slots.actions ? (E(), h("div", H)) : m("", !0),
263
- e.$slots.actions ? (E(), h("div", U, [A(e.$slots, "actions", {}, void 0, !0)])) : m("", !0)
264
- ], 6)])) : m("", !0)]),
265
- _: 3
266
- }))]));
267
- }
268
- }), [["__scopeId", "data-v-0aac9ebd"]]), X = { class: "my-1 border-outline-variant" }, re = /* @__PURE__ */ y({
269
- __name: "MMenuDivider",
270
- props: { gap: {
271
- type: Boolean,
272
- default: !1
273
- } },
274
- setup(e) {
275
- return (e, t) => (E(), h("hr", X));
276
- }
277
- }), ie = { class: "flex-1 truncate" }, ae = { key: "root" }, oe = {
278
- key: 0,
279
- class: "flex flex-col gap-1 px-1.5"
280
- }, se = { class: "overflow-hidden rounded-lg bg-surface-container" }, ce = 220, Z = 1 / 240, Q = /* @__PURE__ */ y({
281
- inheritAttrs: !1,
282
- __name: "MMenu",
283
- props: {
284
- align: { default: "right" },
285
- submenuMode: { default: "flyout" },
286
- variant: { default: "standard" }
287
- },
288
- setup(e, { expose: t }) {
289
- let n = e, r = te();
290
- function i(e) {
291
- let t = [];
292
- for (let n of e) n.type === l && Array.isArray(n.children) ? t.push(...i(n.children)) : t.push(n);
293
- return t;
294
- }
295
- function a(e) {
296
- if (e.type !== re) return !1;
297
- let t = e.props?.gap;
298
- return t === "" || t === !0 || t === "true";
299
- }
300
- let o = f(() => {
301
- if (n.variant !== "expressive") return null;
302
- let e = i(r.default?.({ close: $ }) ?? []), t = [[]];
303
- for (let n of e) a(n) ? t.push([]) : t[t.length - 1].push(n);
304
- return t.filter((e) => e.length > 0);
305
- }), c = f(() => !!o.value && o.value.length > 1), _ = O([]), y = f(() => _.value[_.value.length - 1]), M = O("forward");
306
- function N(e, t) {
307
- let n = M.value === "forward" ? 1 : -1, r = e.animate([{
308
- transform: `translateX(${n * 100}%)`,
309
- opacity: .4
310
- }, {
311
- transform: "translateX(0%)",
312
- opacity: 1
313
- }], {
314
- duration: ce,
315
- easing: "cubic-bezier(0.05,0.7,0.1,1)"
316
- });
317
- r.onfinish = t;
318
- }
319
- function ne(e, t) {
320
- let n = M.value === "forward" ? -1 : 1, r = e;
321
- r.style.position = "absolute", r.style.insetInline = "0", r.style.top = "0";
322
- let i = r.animate([{
323
- transform: "translateX(0%)",
324
- opacity: 1
325
- }, {
326
- transform: `translateX(${n * 100}%)`,
327
- opacity: .4
328
- }], {
329
- duration: ce,
330
- easing: "cubic-bezier(0.3,0,0.8,0.15)"
331
- });
332
- i.onfinish = t;
333
- }
334
- let I = null;
335
- function L() {
336
- if (I) return I;
337
- let e = [], t = .8, n = 0, r = 0, i = 0;
338
- for (let a = 0; a < 1 && (e.push({
339
- scale: t,
340
- alpha: r
341
- }), n += (-1400 * (t - 1) - 1.8 * Math.sqrt(1400) * n) * Z, t += n * Z, i += (-3800 * (r - 1) - 2 * Math.sqrt(3800) * i) * Z, r += i * Z, !(Math.abs(t - 1) < .003 && Math.abs(r - 1) < .003)); a += Z);
342
- return e.push({
343
- scale: 1,
344
- alpha: 1
345
- }), I = e, e;
346
- }
347
- let R = 0, z = null, B = null;
348
- function V(e, t, n) {
349
- z?.();
350
- let r = e, i = L(), a = i.length - 1, o = Math.round(Math.max(0, Math.min(a, R))), s = n ? a : 0, c = n ? 1 : -1, l = [];
351
- for (let e = o; n ? e <= s : e >= s; e += c) l.push(i[e]);
352
- let u = (e) => ({
353
- transform: `scale(${e.scale})`,
354
- opacity: String(Math.min(1, Math.max(0, e.alpha)))
355
- });
356
- Object.assign(r.style, u(i[s]));
357
- let d = !1;
358
- function f() {
359
- d || (d = !0, R = s, z = null, B = null, t());
360
- }
361
- if (l.length < 2 || typeof r.animate != "function") return f();
362
- let p = r.animate(l.map(u), {
363
- duration: (l.length - 1) * Z * 1e3,
364
- easing: "linear"
365
- });
366
- p.finished.catch(() => {}), p.onfinish = f, z = () => {
367
- let e = Number(p.currentTime ?? 0) / (Z * 1e3);
368
- R = Math.max(0, Math.min(a, o + c * e)), d = !0, p.cancel();
369
- }, B = n ? null : () => {
370
- z?.(), z = null, B = null, t();
371
- };
372
- }
373
- function H(e, t) {
374
- V(e, t, !0);
375
- }
376
- function U(e, t) {
377
- V(e, t, !1);
378
- }
379
- function W(e) {
380
- M.value = "forward", _.value.push(e), S(() => de());
381
- }
382
- function G() {
383
- M.value = "backward", _.value.pop(), S(() => de());
384
- }
385
- let K = O(!1), q = O(null), J = O(null), Y = O({}), X = b("m-menu-panel-registry", /* @__PURE__ */ new Set());
386
- D("m-menu-panel-registry", X), P(J, (e, t) => {
387
- t && X.delete(t), e && X.add(e);
388
- }), ee(() => {
389
- J.value && X.delete(J.value);
390
- });
391
- let Q = b("m-menu-sibling-group", null);
392
- D("m-menu-sibling-group", { current: null });
393
- function le() {
394
- if (!q.value) return;
395
- let e = q.value.getBoundingClientRect(), t = window.innerHeight - e.bottom - 8, r = t < 200 && e.top > t, i = { maxHeight: `${Math.min(r ? e.top - 12 : t, 400)}px` };
396
- r ? i.bottom = `${window.innerHeight - e.top + 4}px` : i.top = `${e.bottom + 4}px`, n.align === "right" ? i.right = `${window.innerWidth - e.right}px` : i.left = `${e.left}px`, Y.value = i;
397
- }
398
- function ue() {
399
- return J.value ? Array.from(J.value.querySelectorAll("button:not(:disabled), a[href]")) : [];
400
- }
401
- function de() {
402
- S(() => ue()[0]?.focus());
403
- }
404
- function fe(e) {
405
- let t = ue();
406
- if (!t.length) return;
407
- let n = t.indexOf(document.activeElement);
408
- (n === -1 ? e === 1 ? t[0] : t[t.length - 1] : t[(n + e + t.length) % t.length])?.focus();
409
- }
410
- function pe() {
411
- K.value ? Q?.current === $ && (Q.current = null) : (Q && Q.current && Q.current !== $ && Q.current(), Q && (Q.current = $), le(), _.value = []), K.value = !K.value, K.value && de();
412
- }
413
- function $() {
414
- Q?.current === $ && (Q.current = null), K.value = !1;
415
- }
416
- D("m-menu-close", $), D("m-menu-nav", {
417
- mode: n.submenuMode,
418
- push: W
419
- }), t({
420
- close: $,
421
- open: K
422
- });
423
- function me(e) {
424
- let t = e.target;
425
- if (!q.value?.contains(t)) {
426
- for (let e of X) if (e.contains(t)) return;
427
- t.closest?.(".m3-submenu") || $();
428
- }
429
- }
430
- function he(e) {
431
- if (!K.value) return;
432
- let t = e.target;
433
- for (let e of X) if (e.contains(t)) return;
434
- t.closest?.(".m3-submenu") || $();
435
- }
436
- function ge(e) {
437
- if (e.key === "Escape") {
438
- _.value.length ? G() : $();
439
- return;
440
- }
441
- K.value && (e.key === "ArrowDown" ? (e.preventDefault(), fe(1)) : e.key === "ArrowUp" && (e.preventDefault(), fe(-1)));
442
- }
443
- T(() => {
444
- document.addEventListener("mousedown", me), document.addEventListener("keydown", ge), window.addEventListener("scroll", he, !0);
445
- }), ee(() => {
446
- document.removeEventListener("mousedown", me), document.removeEventListener("keydown", ge), window.removeEventListener("scroll", he, !0), B ? B() : z?.();
447
- });
448
- let _e = f(() => n.align === "right" ? "top right" : "top left");
449
- return (t, n) => (E(), h(l, null, [g("div", x({
450
- ref_key: "triggerEl",
451
- ref: q
452
- }, t.$attrs, {
453
- class: "inline-block",
454
- onClick: pe
455
- }), [A(t.$slots, "trigger", { open: K.value })], 16), (E(), p(u, { to: "body" }, [v(d, {
456
- css: !1,
457
- onEnter: H,
458
- onLeave: U
459
- }, {
460
- default: F(() => [K.value ? (E(), h("div", {
461
- key: 0,
462
- ref_key: "dropdownEl",
463
- ref: J,
464
- class: C(["fixed z-500 min-w-48", [e.variant === "expressive" ? "rounded-lg" : "rounded-xs", c.value ? "" : "shadow-elevation-2"]]),
465
- style: w({
466
- ...Y.value,
467
- transformOrigin: _e.value
468
- })
469
- }, [g("div", { class: C(["overflow-hidden", [e.variant === "expressive" ? "rounded-lg" : "rounded-xs", c.value ? "" : "bg-surface-container"]]) }, [g("div", {
470
- class: "relative overflow-y-auto overscroll-contain py-1",
471
- style: w({ maxHeight: Y.value.maxHeight })
472
- }, [v(d, {
473
- css: !1,
474
- onEnter: N,
475
- onLeave: ne
476
- }, {
477
- default: F(() => [y.value ? (E(), h("div", { key: _.value.length }, [g("button", {
478
- type: "button",
479
- 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",
480
- onClick: G
481
- }, [
482
- v(s, {
483
- name: "chevron_left",
484
- size: 20,
485
- class: "shrink-0 text-on-surface-variant"
486
- }),
487
- y.value.icon ? (E(), p(s, {
488
- key: 0,
489
- name: y.value.icon,
490
- size: 20,
491
- class: "shrink-0 text-on-surface-variant"
492
- }, null, 8, ["name"])) : m("", !0),
493
- g("span", ie, [(E(), p(j(() => y.value?.header?.())))])
494
- ]), (E(), p(j(() => y.value?.content?.())))])) : (E(), h("div", ae, [c.value ? (E(), h("div", oe, [(E(!0), h(l, null, k(o.value, (e, t) => (E(), h("div", {
495
- key: t,
496
- class: "rounded-lg shadow-elevation-2"
497
- }, [g("div", se, [(E(), p(j(() => e)))])]))), 128))])) : A(t.$slots, "default", { close: $ }, void 0, void 0, 1)]))]),
498
- _: 3
499
- })], 4)], 2)], 6)) : m("", !0)]),
500
- _: 3
501
- })]))], 64));
502
- }
503
- }), le = ["data-m3-menu-choice"], ue = { class: "flex-1" }, de = {
504
- key: 2,
505
- class: "ml-4 shrink-0 text-label-small text-on-surface-variant opacity-60"
506
- }, fe = { class: "overflow-hidden rounded-xs bg-surface-container py-1" }, pe = 32, $ = /* @__PURE__ */ y({
507
- __name: "MMenuItem",
508
- props: {
509
- icon: {},
510
- shortcut: {},
511
- to: {},
512
- disabled: {
513
- type: Boolean,
514
- default: !1
515
- },
516
- danger: {
517
- type: Boolean,
518
- default: !1
519
- },
520
- keepOpen: {
521
- type: Boolean,
522
- default: void 0
523
- },
524
- selected: {
525
- type: Boolean,
526
- default: void 0
527
- },
528
- checked: {
529
- type: Boolean,
530
- default: void 0
531
- },
532
- selectedIcon: {}
533
- },
534
- emits: ["click", "update:checked"],
535
- setup(e, { emit: r }) {
536
- let i = e, a = r, c = f(() => i.checked !== void 0), l = f(() => c.value || i.selected !== void 0), _ = f(() => !!(i.checked ?? i.selected)), y = f(() => l.value && !i.icon), x = f(() => i.selectedIcon ?? (i.icon ? void 0 : "check")), D = O("single");
537
- function k() {
538
- let e = U.value;
539
- if (!e || !l.value) return;
540
- let t = (e) => !!e?.hasAttribute("data-m3-menu-choice"), n = t(e.previousElementSibling), r = t(e.nextElementSibling);
541
- D.value = n && r ? "middle" : n ? "last" : r ? "first" : "single";
542
- }
543
- function ne() {
544
- if (_.value) return [
545
- 12,
546
- 12,
547
- 12,
548
- 12
549
- ];
550
- let e = D.value === "first" ? 12 : 4, t = D.value === "last" ? 12 : 4;
551
- return [
552
- e,
553
- e,
554
- t,
555
- t
556
- ];
557
- }
558
- let { snap: I } = n(() => l.value ? [...ne(), y.value && _.value ? pe : 0] : [], ([e, t, n, r, i]) => {
559
- let a = W.value instanceof HTMLElement ? W.value : W.value?.$el;
560
- a && r !== void 0 && (a.style.borderRadius = `${e}px ${t}px ${n}px ${r}px`), G.value && i !== void 0 && (G.value.style.width = `${i}px`);
561
- }, o);
562
- P(D, () => I());
563
- let L = null;
564
- T(() => {
565
- k();
566
- let e = U.value?.parentElement;
567
- e && (L = new MutationObserver(k), L.observe(e, { childList: !0 }));
568
- }), ee(() => L?.disconnect()), P(l, () => S(k)), n(() => y.value ? [+!!_.value] : [], ([e]) => {
569
- G.value && e !== void 0 && (G.value.style.opacity = String(e));
570
- }, t);
571
- let R = te(), z = f(() => i.to ? "RouterLink" : "button"), B = f(() => !!R.children), V = b("m-menu-close", null), H = b("m-menu-nav", null), U = O(), W = O(), G = O(), K = O(!1), q = O({});
572
- function J() {
573
- if (!U.value) return;
574
- let e = U.value.getBoundingClientRect(), t = e.right + 200 > window.innerWidth;
575
- q.value = {
576
- position: "fixed",
577
- top: `${e.top}px`,
578
- ...t ? { right: `${window.innerWidth - e.left}px` } : { left: `${e.right}px` },
579
- zIndex: "501"
580
- };
581
- }
582
- function Y() {
583
- if (K.value) {
584
- K.value = !1;
585
- return;
586
- }
587
- J(), K.value = !0;
588
- }
589
- function X() {
590
- if (!i.disabled) {
591
- if (B.value) {
592
- H?.mode === "push" ? H.push({
593
- icon: i.icon,
594
- header: R.default,
595
- content: R.children
596
- }) : Y();
597
- return;
598
- }
599
- c.value && a("update:checked", !i.checked), a("click"), (i.keepOpen ?? c.value) || V?.();
600
- }
601
- }
602
- function re(e) {
603
- e.pointerType === "mouse" && B.value && !i.disabled && (J(), K.value = !0);
604
- }
605
- function ie(e) {
606
- e.pointerType === "mouse" && (e.relatedTarget?.closest(".m3-submenu") || (K.value = !1));
607
- }
608
- function ae(e) {
609
- if (e.pointerType !== "mouse") return;
610
- let t = e.relatedTarget;
611
- t?.closest(".m3-submenu") || U.value?.contains(t) || (K.value = !1);
612
- }
613
- return (t, n) => (E(), h("div", {
614
- ref_key: "itemEl",
615
- ref: U,
616
- "data-m3-menu-choice": l.value || void 0,
617
- onPointerenter: re,
618
- onPointerleave: ie
619
- }, [(E(), p(j(z.value), {
620
- ref_key: "controlEl",
621
- ref: W,
622
- to: e.to || void 0,
623
- type: e.to ? void 0 : "button",
624
- role: l.value ? c.value ? "menuitemcheckbox" : "menuitemradio" : void 0,
625
- "aria-checked": l.value ? _.value : void 0,
626
- class: C(["flex items-center gap-3 py-2.5 text-left text-body-large transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary", l.value ? [
627
- "relative mx-1 w-[calc(100%-0.5rem)] px-3 duration-150 before:pointer-events-none before:absolute before:inset-0 before:rounded-[inherit] before:bg-current before:opacity-0 before:transition-opacity",
628
- _.value ? "bg-tertiary-container text-on-tertiary-container" : "text-on-surface",
629
- e.disabled ? "cursor-not-allowed opacity-[0.38]" : "cursor-pointer hover:before:opacity-[0.08] active:before:opacity-[0.12]"
630
- ] : [
631
- "w-full px-4",
632
- e.disabled ? "cursor-not-allowed opacity-[0.38] text-on-surface" : "cursor-pointer",
633
- !e.disabled && e.danger ? "text-error hover:bg-error/8" : "",
634
- !e.disabled && !e.danger ? "text-on-surface hover:bg-on-surface/8" : ""
635
- ]]),
636
- disabled: e.disabled || void 0,
637
- "aria-haspopup": B.value ? "menu" : void 0,
638
- "aria-expanded": B.value ? K.value : void 0,
639
- onClick: X
640
- }, {
641
- default: F(() => [
642
- y.value ? (E(), h("span", {
643
- key: 0,
644
- ref_key: "iconSlotEl",
645
- ref: G,
646
- class: "-mr-3 flex shrink-0 overflow-hidden",
647
- style: {
648
- width: "0",
649
- opacity: "0"
650
- }
651
- }, [v(s, {
652
- name: x.value,
653
- size: 20,
654
- class: "shrink-0"
655
- }, null, 8, ["name"])], 512)) : e.icon ? (E(), p(s, {
656
- key: 1,
657
- name: _.value && x.value ? x.value : e.icon,
658
- filled: _.value && !x.value,
659
- size: 20,
660
- class: C(["shrink-0", l.value ? _.value ? "" : "text-on-surface-variant" : e.danger ? "text-error" : "text-on-surface-variant"])
661
- }, null, 8, [
662
- "name",
663
- "filled",
664
- "class"
665
- ])) : m("", !0),
666
- g("span", ue, [A(t.$slots, "default")]),
667
- e.shortcut && !B.value ? (E(), h("span", de, M(e.shortcut), 1)) : m("", !0),
668
- B.value ? (E(), p(s, {
669
- key: 3,
670
- name: "chevron_right",
671
- size: 18,
672
- class: "shrink-0 text-on-surface-variant"
673
- })) : m("", !0)
674
- ]),
675
- _: 3
676
- }, 8, [
677
- "to",
678
- "type",
679
- "role",
680
- "aria-checked",
681
- "class",
682
- "disabled",
683
- "aria-haspopup",
684
- "aria-expanded"
685
- ])), B.value && N(H)?.mode !== "push" ? (E(), p(u, {
686
- key: 0,
687
- to: "body"
688
- }, [v(d, {
689
- "enter-active-class": "transition-opacity duration-100",
690
- "enter-from-class": "opacity-0",
691
- "leave-active-class": "transition-opacity duration-75",
692
- "leave-to-class": "opacity-0"
693
- }, {
694
- default: F(() => [K.value ? (E(), h("div", {
695
- key: 0,
696
- class: "m3-submenu min-w-44 rounded-xs shadow-elevation-2",
697
- style: w(q.value),
698
- onPointerleave: ae
699
- }, [g("div", fe, [A(t.$slots, "children")])], 36)) : m("", !0)]),
700
- _: 3
701
- })])) : m("", !0)], 40, le));
702
- }
703
- });
704
- //#endregion
705
- export { R as a, Y as i, Q as n, re as r, $ as t };
706
-
707
- //# sourceMappingURL=MMenuItem-DFyXflk9.js.map