@m3ui-vue/m3ui-vue 0.6.2 → 0.6.4
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 +8 -6
- package/dist/components/MWindow.vue.d.ts +29 -16
- package/dist/m3ui.js +139 -122
- package/dist/m3ui.js.map +1 -1
- package/dist/terminal.js +9 -8
- package/dist/terminal.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MSlider.vue +82 -33
- package/src/components/MTerminal.vue +12 -6
- package/src/components/MWindow.vue +10 -6
package/dist/terminal.js
CHANGED
|
@@ -15,7 +15,12 @@ var f = { class: "overflow-hidden rounded-lg border border-outline-variant" }, p
|
|
|
15
15
|
emits: ["input", "line"],
|
|
16
16
|
setup(i, { expose: h, emit: g }) {
|
|
17
17
|
let _ = i, v = g, y = l(null), b = null, x = null, S = null, C = "";
|
|
18
|
-
function w() {
|
|
18
|
+
function w(e) {
|
|
19
|
+
e.forEach((t, n) => {
|
|
20
|
+
n === e.length - 1 ? b.write(t) : b.writeln(t);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function T() {
|
|
19
24
|
let e = getComputedStyle(document.documentElement);
|
|
20
25
|
return {
|
|
21
26
|
background: e.getPropertyValue("--color-surface-container-lowest").trim() || "#0f0d13",
|
|
@@ -31,7 +36,7 @@ var f = { class: "overflow-hidden rounded-lg border border-outline-variant" }, p
|
|
|
31
36
|
try {
|
|
32
37
|
await import("@xterm/xterm/css/xterm.css");
|
|
33
38
|
} catch {}
|
|
34
|
-
let n =
|
|
39
|
+
let n = T();
|
|
35
40
|
b = new e.Terminal({
|
|
36
41
|
fontFamily: "'JetBrains Mono', 'Fira Code', 'Consolas', monospace",
|
|
37
42
|
fontSize: 14,
|
|
@@ -51,8 +56,7 @@ var f = { class: "overflow-hidden rounded-lg border border-outline-variant" }, p
|
|
|
51
56
|
try {
|
|
52
57
|
x.fit();
|
|
53
58
|
} catch {}
|
|
54
|
-
|
|
55
|
-
_.readonly || b.onData((e) => {
|
|
59
|
+
w(_.lines), _.readonly || b.onData((e) => {
|
|
56
60
|
v("input", e), e === "\r" ? (b.write("\r\n"), v("line", C), C = "") : e === "" ? C.length > 0 && (C = C.slice(0, -1), b.write("\b \b")) : (C += e, b.write(e));
|
|
57
61
|
}), S = new ResizeObserver(() => {
|
|
58
62
|
try {
|
|
@@ -60,10 +64,7 @@ var f = { class: "overflow-hidden rounded-lg border border-outline-variant" }, p
|
|
|
60
64
|
} catch {}
|
|
61
65
|
}), S.observe(y.value);
|
|
62
66
|
}), d(() => _.lines, (e) => {
|
|
63
|
-
|
|
64
|
-
b.clear();
|
|
65
|
-
for (let t of e) b.writeln(t);
|
|
66
|
-
}
|
|
67
|
+
b && (b.clear(), w(e));
|
|
67
68
|
}), o(() => {
|
|
68
69
|
S?.disconnect(), b?.dispose();
|
|
69
70
|
}), h({
|
package/dist/terminal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","names":[],"sources":["../src/components/MTerminal.vue","../src/components/MTerminal.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n lines?: string[]\n readonly?: boolean\n title?: string\n minHeight?: string\n }>(),\n {\n lines: () => [],\n readonly: false,\n title: 'Terminal',\n minHeight: '300px',\n },\n)\n\nconst emit = defineEmits<{\n input: [string]\n line: [string]\n}>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet terminal: any = null\nlet fitAddon: any = null\nlet resizeObserver: ResizeObserver | null = null\nlet lineBuffer = ''\n\nfunction getThemeColors() {\n const style = getComputedStyle(document.documentElement)\n return {\n background: style.getPropertyValue('--color-surface-container-lowest').trim() || '#0f0d13',\n foreground: style.getPropertyValue('--color-on-surface').trim() || '#e6e1e5',\n cursor: style.getPropertyValue('--color-primary').trim() || '#d0bcff',\n cursorAccent: style.getPropertyValue('--color-on-primary').trim() || '#381e72',\n selectionBackground: style.getPropertyValue('--color-primary-container').trim() || '#4f378b',\n }\n}\n\nonMounted(async () => {\n if (!containerRef.value) return\n\n const [xtermMod, fitMod] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ])\n\n try { await import('@xterm/xterm/css/xterm.css') } catch { /* consumer will provide styles */ }\n\n const colors = getThemeColors()\n\n terminal = new xtermMod.Terminal({\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Consolas', monospace\",\n fontSize: 14,\n lineHeight: 1.4,\n cursorBlink: !props.readonly,\n disableStdin: props.readonly,\n theme: {\n background: colors.background,\n foreground: colors.foreground,\n cursor: colors.cursor,\n cursorAccent: colors.cursorAccent,\n selectionBackground: colors.selectionBackground,\n },\n scrollback: 1000,\n convertEol: true,\n })\n\n fitAddon = new fitMod.FitAddon()\n terminal.loadAddon(fitAddon)\n terminal.open(containerRef.value)\n\n try { fitAddon.fit() } catch { /* container might not be visible yet */ }\n\n for (const line of props.lines) {\n terminal.writeln(line)\n }\n\n if (!props.readonly) {\n terminal.onData((data: string) => {\n emit('input', data)\n\n if (data === '\\r') {\n terminal!.write('\\r\\n')\n emit('line', lineBuffer)\n lineBuffer = ''\n } else if (data === '\\x7f') {\n if (lineBuffer.length > 0) {\n lineBuffer = lineBuffer.slice(0, -1)\n terminal!.write('\\b \\b')\n }\n } else {\n lineBuffer += data\n terminal!.write(data)\n }\n })\n }\n\n resizeObserver = new ResizeObserver(() => {\n try { fitAddon?.fit() } catch { /* ignore */ }\n })\n resizeObserver.observe(containerRef.value)\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n for (const line of newLines) {\n terminal.writeln(line)\n }\n})\n\nonBeforeUnmount(() => {\n resizeObserver?.disconnect()\n terminal?.dispose()\n})\n\ndefineExpose({\n write: (text: string) => terminal?.write(text),\n writeln: (text: string) => terminal?.writeln(text),\n clear: () => terminal?.clear(),\n focus: () => terminal?.focus(),\n})\n</script>\n\n<template>\n <div class=\"overflow-hidden rounded-lg border border-outline-variant\">\n <!-- Title bar -->\n <div class=\"flex items-center gap-2 border-b border-outline-variant bg-surface-container px-4 py-2\">\n <MIcon name=\"terminal\" :size=\"18\" class=\"text-on-surface-variant\" />\n <span class=\"flex-1 text-label-medium text-on-surface-variant\">{{ title }}</span>\n <div class=\"flex gap-1.5\">\n <div class=\"h-3 w-3 rounded-full bg-error/60\" />\n <div class=\"h-3 w-3 rounded-full bg-tertiary-container\" />\n <div class=\"h-3 w-3 rounded-full bg-success/60\" />\n </div>\n </div>\n\n <!-- Terminal container -->\n <div\n ref=\"containerRef\"\n class=\"bg-surface-container-lowest px-2 py-1\"\n :style=\"{ minHeight }\"\n />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n lines?: string[]\n readonly?: boolean\n title?: string\n minHeight?: string\n }>(),\n {\n lines: () => [],\n readonly: false,\n title: 'Terminal',\n minHeight: '300px',\n },\n)\n\nconst emit = defineEmits<{\n input: [string]\n line: [string]\n}>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet terminal: any = null\nlet fitAddon: any = null\nlet resizeObserver: ResizeObserver | null = null\nlet lineBuffer = ''\n\nfunction getThemeColors() {\n const style = getComputedStyle(document.documentElement)\n return {\n background: style.getPropertyValue('--color-surface-container-lowest').trim() || '#0f0d13',\n foreground: style.getPropertyValue('--color-on-surface').trim() || '#e6e1e5',\n cursor: style.getPropertyValue('--color-primary').trim() || '#d0bcff',\n cursorAccent: style.getPropertyValue('--color-on-primary').trim() || '#381e72',\n selectionBackground: style.getPropertyValue('--color-primary-container').trim() || '#4f378b',\n }\n}\n\nonMounted(async () => {\n if (!containerRef.value) return\n\n const [xtermMod, fitMod] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ])\n\n try { await import('@xterm/xterm/css/xterm.css') } catch { /* consumer will provide styles */ }\n\n const colors = getThemeColors()\n\n terminal = new xtermMod.Terminal({\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Consolas', monospace\",\n fontSize: 14,\n lineHeight: 1.4,\n cursorBlink: !props.readonly,\n disableStdin: props.readonly,\n theme: {\n background: colors.background,\n foreground: colors.foreground,\n cursor: colors.cursor,\n cursorAccent: colors.cursorAccent,\n selectionBackground: colors.selectionBackground,\n },\n scrollback: 1000,\n convertEol: true,\n })\n\n fitAddon = new fitMod.FitAddon()\n terminal.loadAddon(fitAddon)\n terminal.open(containerRef.value)\n\n try { fitAddon.fit() } catch { /* container might not be visible yet */ }\n\n for (const line of props.lines) {\n terminal.writeln(line)\n }\n\n if (!props.readonly) {\n terminal.onData((data: string) => {\n emit('input', data)\n\n if (data === '\\r') {\n terminal!.write('\\r\\n')\n emit('line', lineBuffer)\n lineBuffer = ''\n } else if (data === '\\x7f') {\n if (lineBuffer.length > 0) {\n lineBuffer = lineBuffer.slice(0, -1)\n terminal!.write('\\b \\b')\n }\n } else {\n lineBuffer += data\n terminal!.write(data)\n }\n })\n }\n\n resizeObserver = new ResizeObserver(() => {\n try { fitAddon?.fit() } catch { /* ignore */ }\n })\n resizeObserver.observe(containerRef.value)\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n for (const line of newLines) {\n terminal.writeln(line)\n }\n})\n\nonBeforeUnmount(() => {\n resizeObserver?.disconnect()\n terminal?.dispose()\n})\n\ndefineExpose({\n write: (text: string) => terminal?.write(text),\n writeln: (text: string) => terminal?.writeln(text),\n clear: () => terminal?.clear(),\n focus: () => terminal?.focus(),\n})\n</script>\n\n<template>\n <div class=\"overflow-hidden rounded-lg border border-outline-variant\">\n <!-- Title bar -->\n <div class=\"flex items-center gap-2 border-b border-outline-variant bg-surface-container px-4 py-2\">\n <MIcon name=\"terminal\" :size=\"18\" class=\"text-on-surface-variant\" />\n <span class=\"flex-1 text-label-medium text-on-surface-variant\">{{ title }}</span>\n <div class=\"flex gap-1.5\">\n <div class=\"h-3 w-3 rounded-full bg-error/60\" />\n <div class=\"h-3 w-3 rounded-full bg-tertiary-container\" />\n <div class=\"h-3 w-3 rounded-full bg-success/60\" />\n </div>\n </div>\n\n <!-- Terminal container -->\n <div\n ref=\"containerRef\"\n class=\"bg-surface-container-lowest px-2 py-1\"\n :style=\"{ minHeight }\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAIA,IAAM,IAAQ,GAeR,IAAO,GAKP,IAAe,EAAwB,IAAI,GAC7C,IAAgB,MAChB,IAAgB,MAChB,IAAwC,MACxC,IAAa;EAEjB,SAAS,IAAiB;GACxB,IAAM,IAAQ,iBAAiB,SAAS,eAAe;GACvD,OAAO;IACL,YAAY,EAAM,iBAAiB,kCAAkC,CAAC,CAAC,KAAK,KAAK;IACjF,YAAY,EAAM,iBAAiB,oBAAoB,CAAC,CAAC,KAAK,KAAK;IACnE,QAAQ,EAAM,iBAAiB,iBAAiB,CAAC,CAAC,KAAK,KAAK;IAC5D,cAAc,EAAM,iBAAiB,oBAAoB,CAAC,CAAC,KAAK,KAAK;IACrE,qBAAqB,EAAM,iBAAiB,2BAA2B,CAAC,CAAC,KAAK,KAAK;GACrF;EACF;SAEA,EAAU,YAAY;GACpB,IAAI,CAAC,EAAa,OAAO;GAEzB,IAAM,CAAC,GAAU,KAAU,MAAM,QAAQ,IAAI,CAC3C,OAAO,iBACP,OAAO,mBACT,CAAC;GAED,IAAI;IAAE,MAAM,OAAO;GAA8B,QAAQ,CAAqC;GAE9F,IAAM,IAAS,EAAe;GAqB9B,AAnBA,IAAW,IAAI,EAAS,SAAS;IAC/B,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,aAAa,CAAC,EAAM;IACpB,cAAc,EAAM;IACpB,OAAO;KACL,YAAY,EAAO;KACnB,YAAY,EAAO;KACnB,QAAQ,EAAO;KACf,cAAc,EAAO;KACrB,qBAAqB,EAAO;IAC9B;IACA,YAAY;IACZ,YAAY;G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3C,OAAM,mCAAkC,CAAA;IAC7C,EAA0D,OAAA,EAArD,OAAM,6CAA4C,CAAA;IACvD,EAAkD,OAAA,EAA7C,OAAM,qCAAoC,CAAA;;EAKnD,CAAA,GAAA,EAIE,OAAA;GAHI,SAAA;GAAJ,KAAI;GACJ,OAAM;GACL,OAAK,EAAA,EAAA,WAAI,EAAA,UAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"terminal.js","names":[],"sources":["../src/components/MTerminal.vue","../src/components/MTerminal.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n lines?: string[]\n readonly?: boolean\n title?: string\n minHeight?: string\n }>(),\n {\n lines: () => [],\n readonly: false,\n title: 'Terminal',\n minHeight: '300px',\n },\n)\n\nconst emit = defineEmits<{\n input: [string]\n line: [string]\n}>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet terminal: any = null\nlet fitAddon: any = null\nlet resizeObserver: ResizeObserver | null = null\nlet lineBuffer = ''\n\nfunction writeLines(lines: string[]) {\n lines.forEach((line, i) => {\n if (i === lines.length - 1) {\n terminal!.write(line)\n } else {\n terminal!.writeln(line)\n }\n })\n}\n\nfunction getThemeColors() {\n const style = getComputedStyle(document.documentElement)\n return {\n background: style.getPropertyValue('--color-surface-container-lowest').trim() || '#0f0d13',\n foreground: style.getPropertyValue('--color-on-surface').trim() || '#e6e1e5',\n cursor: style.getPropertyValue('--color-primary').trim() || '#d0bcff',\n cursorAccent: style.getPropertyValue('--color-on-primary').trim() || '#381e72',\n selectionBackground: style.getPropertyValue('--color-primary-container').trim() || '#4f378b',\n }\n}\n\nonMounted(async () => {\n if (!containerRef.value) return\n\n const [xtermMod, fitMod] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ])\n\n try { await import('@xterm/xterm/css/xterm.css') } catch { /* consumer will provide styles */ }\n\n const colors = getThemeColors()\n\n terminal = new xtermMod.Terminal({\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Consolas', monospace\",\n fontSize: 14,\n lineHeight: 1.4,\n cursorBlink: !props.readonly,\n disableStdin: props.readonly,\n theme: {\n background: colors.background,\n foreground: colors.foreground,\n cursor: colors.cursor,\n cursorAccent: colors.cursorAccent,\n selectionBackground: colors.selectionBackground,\n },\n scrollback: 1000,\n convertEol: true,\n })\n\n fitAddon = new fitMod.FitAddon()\n terminal.loadAddon(fitAddon)\n terminal.open(containerRef.value)\n\n try { fitAddon.fit() } catch { /* container might not be visible yet */ }\n\n writeLines(props.lines)\n\n if (!props.readonly) {\n terminal.onData((data: string) => {\n emit('input', data)\n\n if (data === '\\r') {\n terminal!.write('\\r\\n')\n emit('line', lineBuffer)\n lineBuffer = ''\n } else if (data === '\\x7f') {\n if (lineBuffer.length > 0) {\n lineBuffer = lineBuffer.slice(0, -1)\n terminal!.write('\\b \\b')\n }\n } else {\n lineBuffer += data\n terminal!.write(data)\n }\n })\n }\n\n resizeObserver = new ResizeObserver(() => {\n try { fitAddon?.fit() } catch { /* ignore */ }\n })\n resizeObserver.observe(containerRef.value)\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n writeLines(newLines)\n})\n\nonBeforeUnmount(() => {\n resizeObserver?.disconnect()\n terminal?.dispose()\n})\n\ndefineExpose({\n write: (text: string) => terminal?.write(text),\n writeln: (text: string) => terminal?.writeln(text),\n clear: () => terminal?.clear(),\n focus: () => terminal?.focus(),\n})\n</script>\n\n<template>\n <div class=\"overflow-hidden rounded-lg border border-outline-variant\">\n <!-- Title bar -->\n <div class=\"flex items-center gap-2 border-b border-outline-variant bg-surface-container px-4 py-2\">\n <MIcon name=\"terminal\" :size=\"18\" class=\"text-on-surface-variant\" />\n <span class=\"flex-1 text-label-medium text-on-surface-variant\">{{ title }}</span>\n <div class=\"flex gap-1.5\">\n <div class=\"h-3 w-3 rounded-full bg-error/60\" />\n <div class=\"h-3 w-3 rounded-full bg-tertiary-container\" />\n <div class=\"h-3 w-3 rounded-full bg-success/60\" />\n </div>\n </div>\n\n <!-- Terminal container -->\n <div\n ref=\"containerRef\"\n class=\"bg-surface-container-lowest px-2 py-1\"\n :style=\"{ minHeight }\"\n />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n lines?: string[]\n readonly?: boolean\n title?: string\n minHeight?: string\n }>(),\n {\n lines: () => [],\n readonly: false,\n title: 'Terminal',\n minHeight: '300px',\n },\n)\n\nconst emit = defineEmits<{\n input: [string]\n line: [string]\n}>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet terminal: any = null\nlet fitAddon: any = null\nlet resizeObserver: ResizeObserver | null = null\nlet lineBuffer = ''\n\nfunction writeLines(lines: string[]) {\n lines.forEach((line, i) => {\n if (i === lines.length - 1) {\n terminal!.write(line)\n } else {\n terminal!.writeln(line)\n }\n })\n}\n\nfunction getThemeColors() {\n const style = getComputedStyle(document.documentElement)\n return {\n background: style.getPropertyValue('--color-surface-container-lowest').trim() || '#0f0d13',\n foreground: style.getPropertyValue('--color-on-surface').trim() || '#e6e1e5',\n cursor: style.getPropertyValue('--color-primary').trim() || '#d0bcff',\n cursorAccent: style.getPropertyValue('--color-on-primary').trim() || '#381e72',\n selectionBackground: style.getPropertyValue('--color-primary-container').trim() || '#4f378b',\n }\n}\n\nonMounted(async () => {\n if (!containerRef.value) return\n\n const [xtermMod, fitMod] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ])\n\n try { await import('@xterm/xterm/css/xterm.css') } catch { /* consumer will provide styles */ }\n\n const colors = getThemeColors()\n\n terminal = new xtermMod.Terminal({\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Consolas', monospace\",\n fontSize: 14,\n lineHeight: 1.4,\n cursorBlink: !props.readonly,\n disableStdin: props.readonly,\n theme: {\n background: colors.background,\n foreground: colors.foreground,\n cursor: colors.cursor,\n cursorAccent: colors.cursorAccent,\n selectionBackground: colors.selectionBackground,\n },\n scrollback: 1000,\n convertEol: true,\n })\n\n fitAddon = new fitMod.FitAddon()\n terminal.loadAddon(fitAddon)\n terminal.open(containerRef.value)\n\n try { fitAddon.fit() } catch { /* container might not be visible yet */ }\n\n writeLines(props.lines)\n\n if (!props.readonly) {\n terminal.onData((data: string) => {\n emit('input', data)\n\n if (data === '\\r') {\n terminal!.write('\\r\\n')\n emit('line', lineBuffer)\n lineBuffer = ''\n } else if (data === '\\x7f') {\n if (lineBuffer.length > 0) {\n lineBuffer = lineBuffer.slice(0, -1)\n terminal!.write('\\b \\b')\n }\n } else {\n lineBuffer += data\n terminal!.write(data)\n }\n })\n }\n\n resizeObserver = new ResizeObserver(() => {\n try { fitAddon?.fit() } catch { /* ignore */ }\n })\n resizeObserver.observe(containerRef.value)\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n writeLines(newLines)\n})\n\nonBeforeUnmount(() => {\n resizeObserver?.disconnect()\n terminal?.dispose()\n})\n\ndefineExpose({\n write: (text: string) => terminal?.write(text),\n writeln: (text: string) => terminal?.writeln(text),\n clear: () => terminal?.clear(),\n focus: () => terminal?.focus(),\n})\n</script>\n\n<template>\n <div class=\"overflow-hidden rounded-lg border border-outline-variant\">\n <!-- Title bar -->\n <div class=\"flex items-center gap-2 border-b border-outline-variant bg-surface-container px-4 py-2\">\n <MIcon name=\"terminal\" :size=\"18\" class=\"text-on-surface-variant\" />\n <span class=\"flex-1 text-label-medium text-on-surface-variant\">{{ title }}</span>\n <div class=\"flex gap-1.5\">\n <div class=\"h-3 w-3 rounded-full bg-error/60\" />\n <div class=\"h-3 w-3 rounded-full bg-tertiary-container\" />\n <div class=\"h-3 w-3 rounded-full bg-success/60\" />\n </div>\n </div>\n\n <!-- Terminal container -->\n <div\n ref=\"containerRef\"\n class=\"bg-surface-container-lowest px-2 py-1\"\n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A,GAAA,EAIE,OAAA;GAHI,SAAA;GAAJ,KAAI;GACJ,OAAM;GACL,OAAK,EAAA,EAAA,WAAI,EAAA,UAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -234,21 +234,74 @@ function fillInactiveSize(pct: number) {
|
|
|
234
234
|
return `calc(100% - ${clampedPos(pct)} - ${gap.value}px)`
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
// Range & centered variants: same fix as above — any fill edge that sits at a
|
|
238
|
+
// real draggable thumb must anchor to its clamped (thumbInset-aware) position,
|
|
239
|
+
// not the raw pct, or the fill creeps past a thumb pinned near 0%/100% and
|
|
240
|
+
// swallows the gap that's supposed to stay visible there.
|
|
241
|
+
|
|
242
|
+
// Range: both pctLo and pctHi are thumbs.
|
|
243
|
+
function rangeInactiveBeforeSize() {
|
|
244
|
+
return `calc(${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
245
|
+
}
|
|
246
|
+
function rangeActiveStart() {
|
|
247
|
+
return `calc(${clampedPos(pctLo.value)} + ${gap.value}px)`
|
|
248
|
+
}
|
|
249
|
+
function rangeActiveSize() {
|
|
250
|
+
return `calc(${clampedPos(pctHi.value)} - ${clampedPos(pctLo.value)} - ${gap.value * 2}px)`
|
|
251
|
+
}
|
|
252
|
+
function rangeInactiveAfterSize() {
|
|
253
|
+
return `calc(100% - ${clampedPos(pctHi.value)} - ${gap.value}px)`
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Centered: only pctLo is a thumb — centerPct is a fixed anchor, never inset.
|
|
257
|
+
function centeredActiveStart() {
|
|
258
|
+
return pctLo.value >= centerPct.value
|
|
259
|
+
? `${centerPct.value}%`
|
|
260
|
+
: `calc(${clampedPos(pctLo.value)} + ${gap.value}px)`
|
|
261
|
+
}
|
|
262
|
+
function centeredActiveSize() {
|
|
263
|
+
return pctLo.value >= centerPct.value
|
|
264
|
+
? `calc(${clampedPos(pctLo.value)} - ${centerPct.value}% - ${gap.value}px)`
|
|
265
|
+
: `calc(${centerPct.value}% - ${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
266
|
+
}
|
|
267
|
+
function centeredFarInactiveSize() {
|
|
268
|
+
return pctLo.value >= centerPct.value
|
|
269
|
+
? `calc(100% - ${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
270
|
+
: `calc(100% - ${centerPct.value}% - ${gap.value}px)`
|
|
271
|
+
}
|
|
272
|
+
function centeredNearInactiveSize() {
|
|
273
|
+
return pctLo.value <= centerPct.value
|
|
274
|
+
? `calc(${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
275
|
+
: `calc(${centerPct.value}% - ${gap.value}px)`
|
|
276
|
+
}
|
|
277
|
+
|
|
237
278
|
const r = computed(() => s.value.radius)
|
|
238
279
|
const smallR = computed(() => Math.max(2, r.value / 4))
|
|
280
|
+
// Outer track-end corners: the original `r` shape-scale token, just a touch
|
|
281
|
+
// softer/rounder than the plain token value.
|
|
282
|
+
const fullR = computed(() => r.value * 1.3)
|
|
283
|
+
|
|
284
|
+
// A segment bounded by a gap on *both* sides — range's middle (active)
|
|
285
|
+
// segment between the two thumbs, and centered's active segment (its far
|
|
286
|
+
// side sits at the fixed center junction, its near side at the thumb gap;
|
|
287
|
+
// it never touches a real track end since the near/far inactive segments
|
|
288
|
+
// always cover those) — goes square on every corner, never a rounded cap.
|
|
289
|
+
function pillRadiusSquareBoth() {
|
|
290
|
+
return `${smallR.value}px`
|
|
291
|
+
}
|
|
239
292
|
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
//
|
|
293
|
+
// The pill's outer end (away from the thumb/gap) stays a full stadium cap;
|
|
294
|
+
// the end facing a thumb-gap goes square, matching the official M3 slider's
|
|
295
|
+
// track segments.
|
|
243
296
|
function pillRadiusOuterStart() {
|
|
244
297
|
return isVertical.value
|
|
245
|
-
? `${smallR.value}px ${smallR.value}px ${
|
|
246
|
-
: `${
|
|
298
|
+
? `${smallR.value}px ${smallR.value}px ${fullR.value}px ${fullR.value}px`
|
|
299
|
+
: `${fullR.value}px ${smallR.value}px ${smallR.value}px ${fullR.value}px`
|
|
247
300
|
}
|
|
248
301
|
function pillRadiusOuterEnd() {
|
|
249
302
|
return isVertical.value
|
|
250
|
-
? `${
|
|
251
|
-
: `${smallR.value}px ${
|
|
303
|
+
? `${fullR.value}px ${fullR.value}px ${smallR.value}px ${smallR.value}px`
|
|
304
|
+
: `${smallR.value}px ${fullR.value}px ${fullR.value}px ${smallR.value}px`
|
|
252
305
|
}
|
|
253
306
|
const nd = computed(() => dragging.value === false)
|
|
254
307
|
const tr = computed(() => nd.value ? '75ms ease' : '0s')
|
|
@@ -373,8 +426,8 @@ const tooltipPct = computed(() => {
|
|
|
373
426
|
<div
|
|
374
427
|
class="absolute"
|
|
375
428
|
:style="isVertical
|
|
376
|
-
? { left: '50%', top: '0', bottom: '0', width: `${s.track}px`, transform: 'translateX(-50%)', borderRadius: `${
|
|
377
|
-
: { top: '50%', left: '0', right: '0', height: `${s.track}px`, transform: 'translateY(-50%)', borderRadius: `${
|
|
429
|
+
? { left: '50%', top: '0', bottom: '0', width: `${s.track}px`, transform: 'translateX(-50%)', borderRadius: `${fullR}px` }
|
|
430
|
+
: { top: '50%', left: '0', right: '0', height: `${s.track}px`, transform: 'translateY(-50%)', borderRadius: `${fullR}px` }
|
|
378
431
|
"
|
|
379
432
|
>
|
|
380
433
|
<!-- Standard: active from left/bottom -->
|
|
@@ -397,58 +450,54 @@ const tooltipPct = computed(() => {
|
|
|
397
450
|
|
|
398
451
|
<!-- Centered: active from center -->
|
|
399
452
|
<template v-else-if="variant === 'centered'">
|
|
400
|
-
<!-- Active: from center to thumb (
|
|
453
|
+
<!-- Active: from center to thumb (thumb edge uses its clamped position) -->
|
|
401
454
|
<div class="absolute" :style="{
|
|
402
455
|
...(isVertical
|
|
403
|
-
?
|
|
404
|
-
|
|
405
|
-
: { left: 0, right: 0, bottom: `calc(${pctLo}% + ${gap}px)`, height: `calc(${centerPct - pctLo}% - ${gap}px)` }
|
|
406
|
-
: pctLo >= centerPct
|
|
407
|
-
? { top: 0, bottom: 0, left: `${centerPct}%`, width: `calc(${pctLo - centerPct}% - ${gap}px)` }
|
|
408
|
-
: { top: 0, bottom: 0, left: `calc(${pctLo}% + ${gap}px)`, width: `calc(${centerPct - pctLo}% - ${gap}px)` }
|
|
456
|
+
? { left: 0, right: 0, bottom: centeredActiveStart(), height: centeredActiveSize() }
|
|
457
|
+
: { top: 0, bottom: 0, left: centeredActiveStart(), width: centeredActiveSize() }
|
|
409
458
|
),
|
|
410
|
-
borderRadius:
|
|
459
|
+
borderRadius: pillRadiusSquareBoth(), backgroundColor: ct.active, transition: `all ${tr}`,
|
|
411
460
|
}" />
|
|
412
461
|
<!-- Inactive: above/right of thumb -->
|
|
413
462
|
<div class="absolute" :style="{
|
|
414
463
|
...(isVertical
|
|
415
|
-
? { left: 0, right: 0, top: 0, height:
|
|
416
|
-
: { top: 0, bottom: 0, right: 0, width:
|
|
464
|
+
? { left: 0, right: 0, top: 0, height: centeredFarInactiveSize() }
|
|
465
|
+
: { top: 0, bottom: 0, right: 0, width: centeredFarInactiveSize() }
|
|
417
466
|
),
|
|
418
|
-
borderRadius:
|
|
467
|
+
borderRadius: pillRadiusOuterEnd(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
419
468
|
}" />
|
|
420
469
|
<!-- Inactive: below/left of thumb -->
|
|
421
470
|
<div class="absolute" :style="{
|
|
422
471
|
...(isVertical
|
|
423
|
-
? { left: 0, right: 0, bottom: 0, height:
|
|
424
|
-
: { top: 0, bottom: 0, left: 0, width:
|
|
472
|
+
? { left: 0, right: 0, bottom: 0, height: centeredNearInactiveSize() }
|
|
473
|
+
: { top: 0, bottom: 0, left: 0, width: centeredNearInactiveSize() }
|
|
425
474
|
),
|
|
426
|
-
borderRadius:
|
|
475
|
+
borderRadius: pillRadiusOuterStart(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
427
476
|
}" />
|
|
428
477
|
</template>
|
|
429
478
|
|
|
430
|
-
<!-- Range: active between thumbs -->
|
|
479
|
+
<!-- Range: active between thumbs (both edges use their clamped position) -->
|
|
431
480
|
<template v-else-if="variant === 'range'">
|
|
432
481
|
<div class="absolute" :style="{
|
|
433
482
|
...(isVertical
|
|
434
|
-
? { left: 0, right: 0, bottom: 0, height:
|
|
435
|
-
: { top: 0, bottom: 0, left: 0, width:
|
|
483
|
+
? { left: 0, right: 0, bottom: 0, height: rangeInactiveBeforeSize() }
|
|
484
|
+
: { top: 0, bottom: 0, left: 0, width: rangeInactiveBeforeSize() }
|
|
436
485
|
),
|
|
437
|
-
borderRadius:
|
|
486
|
+
borderRadius: pillRadiusOuterStart(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
438
487
|
}" />
|
|
439
488
|
<div class="absolute" :style="{
|
|
440
489
|
...(isVertical
|
|
441
|
-
? { left: 0, right: 0, bottom:
|
|
442
|
-
: { top: 0, bottom: 0, left:
|
|
490
|
+
? { left: 0, right: 0, bottom: rangeActiveStart(), height: rangeActiveSize() }
|
|
491
|
+
: { top: 0, bottom: 0, left: rangeActiveStart(), width: rangeActiveSize() }
|
|
443
492
|
),
|
|
444
|
-
borderRadius:
|
|
493
|
+
borderRadius: pillRadiusSquareBoth(), backgroundColor: ct.active, transition: `all ${tr}`,
|
|
445
494
|
}" />
|
|
446
495
|
<div class="absolute" :style="{
|
|
447
496
|
...(isVertical
|
|
448
|
-
? { left: 0, right: 0, top: 0, height:
|
|
449
|
-
: { top: 0, bottom: 0, right: 0, width:
|
|
497
|
+
? { left: 0, right: 0, top: 0, height: rangeInactiveAfterSize() }
|
|
498
|
+
: { top: 0, bottom: 0, right: 0, width: rangeInactiveAfterSize() }
|
|
450
499
|
),
|
|
451
|
-
borderRadius:
|
|
500
|
+
borderRadius: pillRadiusOuterEnd(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
452
501
|
}" />
|
|
453
502
|
</template>
|
|
454
503
|
|
|
@@ -28,6 +28,16 @@ let fitAddon: any = null
|
|
|
28
28
|
let resizeObserver: ResizeObserver | null = null
|
|
29
29
|
let lineBuffer = ''
|
|
30
30
|
|
|
31
|
+
function writeLines(lines: string[]) {
|
|
32
|
+
lines.forEach((line, i) => {
|
|
33
|
+
if (i === lines.length - 1) {
|
|
34
|
+
terminal!.write(line)
|
|
35
|
+
} else {
|
|
36
|
+
terminal!.writeln(line)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
function getThemeColors() {
|
|
32
42
|
const style = getComputedStyle(document.documentElement)
|
|
33
43
|
return {
|
|
@@ -74,9 +84,7 @@ onMounted(async () => {
|
|
|
74
84
|
|
|
75
85
|
try { fitAddon.fit() } catch { /* container might not be visible yet */ }
|
|
76
86
|
|
|
77
|
-
|
|
78
|
-
terminal.writeln(line)
|
|
79
|
-
}
|
|
87
|
+
writeLines(props.lines)
|
|
80
88
|
|
|
81
89
|
if (!props.readonly) {
|
|
82
90
|
terminal.onData((data: string) => {
|
|
@@ -107,9 +115,7 @@ onMounted(async () => {
|
|
|
107
115
|
watch(() => props.lines, (newLines) => {
|
|
108
116
|
if (!terminal) return
|
|
109
117
|
terminal.clear()
|
|
110
|
-
|
|
111
|
-
terminal.writeln(line)
|
|
112
|
-
}
|
|
118
|
+
writeLines(newLines)
|
|
113
119
|
})
|
|
114
120
|
|
|
115
121
|
onBeforeUnmount(() => {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Module-scoped so it's actually shared across every MWindow instance.
|
|
3
|
+
// Kept below the app-level overlay scale (dialogs/spotlight/command palette use z-50)
|
|
4
|
+
// so windows never render on top of a real modal.
|
|
5
|
+
let sharedZIndex = 10
|
|
6
|
+
</script>
|
|
7
|
+
|
|
1
8
|
<script setup lang="ts">
|
|
2
9
|
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
|
3
10
|
import MIcon from './MIcon.vue'
|
|
@@ -48,10 +55,7 @@ const posY = ref(props.y)
|
|
|
48
55
|
const winWidth = ref(parseInt(props.width) || 400)
|
|
49
56
|
const winHeight = ref(parseInt(props.height) || 300)
|
|
50
57
|
const minimized = ref(false)
|
|
51
|
-
const zIndex = ref(
|
|
52
|
-
|
|
53
|
-
// Global z-index counter shared across instances
|
|
54
|
-
let globalZIndex = 100
|
|
58
|
+
const zIndex = ref(sharedZIndex)
|
|
55
59
|
|
|
56
60
|
const windowRef = ref<HTMLElement | null>(null)
|
|
57
61
|
|
|
@@ -84,8 +88,8 @@ const windowStyle = computed(() => ({
|
|
|
84
88
|
|
|
85
89
|
// ---- Bring to front ----
|
|
86
90
|
function bringToFront() {
|
|
87
|
-
|
|
88
|
-
zIndex.value =
|
|
91
|
+
sharedZIndex++
|
|
92
|
+
zIndex.value = sharedZIndex
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
// ---- Pointer helpers ----
|