@m3ui-vue/m3ui-vue 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +3 -0
  2. package/dist/MIcon-CaEooCmZ.js.map +1 -1
  3. package/dist/{MMenuItem-DbbrJhFE.js → MMenuItem-C7jKU-Qh.js} +13 -13
  4. package/dist/{MMenuItem-DbbrJhFE.js.map → MMenuItem-C7jKU-Qh.js.map} +1 -1
  5. package/dist/barcode.js.map +1 -1
  6. package/dist/chart.js +1 -1
  7. package/dist/chart.js.map +1 -1
  8. package/dist/code-editor.js +1 -1
  9. package/dist/code-editor.js.map +1 -1
  10. package/dist/{common-VrOaLkjh.js → common-0dgrgaPL.js} +287 -213
  11. package/dist/common-0dgrgaPL.js.map +1 -0
  12. package/dist/components/MBar.vue.d.ts +58 -0
  13. package/dist/components/MPageProgress.vue.d.ts +15 -0
  14. package/dist/components/MSlider.vue.d.ts +6 -0
  15. package/dist/components/MWindow.vue.d.ts +30 -17
  16. package/dist/composables/usePageProgress.d.ts +19 -0
  17. package/dist/{dist-Dsrzt6J5.js → dist-CrjSW5DN.js} +248 -241
  18. package/dist/{dist-Dsrzt6J5.js.map → dist-CrjSW5DN.js.map} +1 -1
  19. package/dist/index.d.ts +3 -0
  20. package/dist/m3ui-vue.css +1 -1
  21. package/dist/m3ui.js +2935 -2656
  22. package/dist/m3ui.js.map +1 -1
  23. package/dist/markdown.js +1 -1
  24. package/dist/markdown.js.map +1 -1
  25. package/dist/qrcode.js.map +1 -1
  26. package/dist/rich-text-editor.js +1 -1
  27. package/dist/rich-text-editor.js.map +1 -1
  28. package/dist/styles.css +1 -1
  29. package/dist/terminal.js +9 -8
  30. package/dist/terminal.js.map +1 -1
  31. package/package.json +26 -26
  32. package/src/__tests__/usePageProgress.test.ts +52 -0
  33. package/src/components/MBar.vue +158 -0
  34. package/src/components/MPageProgress.vue +62 -0
  35. package/src/components/MSlider.vue +174 -52
  36. package/src/components/MTerminal.vue +12 -6
  37. package/src/components/MWindow.vue +10 -6
  38. package/src/composables/usePageProgress.ts +49 -0
  39. package/src/index.ts +3 -0
  40. package/dist/common-VrOaLkjh.js.map +0 -1
@@ -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,iBAAi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EAAU,MAAM,CAAI;GAExB,CAAC,GAGH,IAAiB,IAAI,qBAAqB;IACxC,IAAI;KAAE,GAAU,IAAI;IAAE,QAAQ,CAAe;GAC/C,CAAC,GACD,EAAe,QAAQ,EAAa,KAAK;EAC3C,CAAC,GAED,QAAY,EAAM,QAAQ,MAAa;GAChC,OACL;MAAS,MAAM;IACf,KAAK,IAAM,KAAQ,GACjB,EAAS,QAAQ,CAAI;GAFR;EAIjB,CAAC,GAED,QAAsB;GAEpB,AADA,GAAgB,WAAW,GAC3B,GAAU,QAAQ;EACpB,CAAC,GAED,EAAa;GACX,QAAQ,MAAiB,GAAU,MAAM,CAAI;GAC7C,UAAU,MAAiB,GAAU,QAAQ,CAAI;GACjD,aAAa,GAAU,MAAM;GAC7B,aAAa,GAAU,MAAM;EAC/B,CAAC,mBAIC,EAkBM,OAlBN,GAkBM,CAhBJ,EAQM,OARN,GAQM;GAPJ,EAAoE,GAAA;IAA7D,MAAK;IAAY,MAAM;IAAI,OAAM;;GACxC,EAAiF,QAAjF,GAAiF,EAAf,EAAA,KAAK,GAAA,CAAA;YACvE,EAIM,OAAA,EAJD,OAAM,eAAc,GAAA;IACvB,EAAgD,OAAA,EAA3C,OAAM,mCAAkC,CAAA;IAC7C,EAA0D,OAAA,EAArD,OAAM,6CAA4C,CAAA;IACvD,EAAkD,OAAA,EAA7C,OAAM,qCAAoC,CAAA;;MAKnD,EAIE,OAAA;YAHI;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 :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,EAAW,GAAiB;GACnC,EAAM,SAAS,GAAM,MAAM;IACzB,AAAI,MAAM,EAAM,SAAS,IACvB,EAAU,MAAM,CAAI,IAEpB,EAAU,QAAQ,CAAI;GAE1B,CAAC;EACH;EAEA,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;I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AAK;EAC3C,CAAC,GAED,QAAY,EAAM,QAAQ,MAAa;GAChC,MACL,EAAS,MAAM,GACf,EAAW,CAAQ;EACrB,CAAC,GAED,QAAsB;GAEpB,AADA,GAAgB,WAAW,GAC3B,GAAU,QAAQ;EACpB,CAAC,GAED,EAAa;GACX,QAAQ,MAAiB,GAAU,MAAM,CAAI;GAC7C,UAAU,MAAiB,GAAU,QAAQ,CAAI;GACjD,aAAa,GAAU,MAAM;GAC7B,aAAa,GAAU,MAAM;EAC/B,CAAC,cAIC,EAAA,GAAA,EAkBM,OAlBN,GAkBM,CAhBJ,EAQM,OARN,GAQM;GAPJ,EAAoE,GAAA;IAA7D,MAAK;IAAY,MAAM;IAAI,OAAM;;GACxC,EAAiF,QAAjF,GAAiF,EAAf,EAAA,KAAK,GAAA,CAAA;GACvE,AAAA,EAAA,OAAA,EAIM,OAAA,EAJD,OAAM,eAAc,GAAA;IACvB,EAAgD,OAAA,EAA3C,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m3ui-vue/m3ui-vue",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Material 3 component library for Vue 3 + Tailwind CSS v4",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -176,48 +176,48 @@
176
176
  }
177
177
  },
178
178
  "devDependencies": {
179
- "@codemirror/commands": "^6.10.3",
179
+ "@codemirror/commands": "^6.11.0",
180
180
  "@codemirror/lang-css": "^6.3.1",
181
- "@codemirror/lang-html": "^6.4.11",
181
+ "@codemirror/lang-html": "^6.4.12",
182
182
  "@codemirror/lang-javascript": "^6.2.5",
183
183
  "@codemirror/lang-json": "^6.0.2",
184
184
  "@codemirror/lang-python": "^6.2.1",
185
185
  "@codemirror/lang-vue": "^0.1.3",
186
- "@codemirror/language": "^6.12.3",
187
- "@codemirror/state": "^6.6.0",
186
+ "@codemirror/language": "^6.12.4",
187
+ "@codemirror/state": "^6.7.4",
188
188
  "@codemirror/theme-one-dark": "^6.1.3",
189
- "@codemirror/view": "^6.43.1",
189
+ "@codemirror/view": "^6.43.11",
190
190
  "@lezer/highlight": "^1.2.3",
191
- "@tiptap/extension-color": "^3.26.1",
192
- "@tiptap/extension-highlight": "^3.26.1",
193
- "@tiptap/extension-image": "^3.26.1",
194
- "@tiptap/extension-link": "^3.26.1",
195
- "@tiptap/extension-placeholder": "^3.26.1",
196
- "@tiptap/extension-text-align": "^3.26.1",
197
- "@tiptap/extension-text-style": "^3.26.1",
198
- "@tiptap/extension-underline": "^3.26.1",
199
- "@tiptap/starter-kit": "^3.26.1",
200
- "@tiptap/vue-3": "^3.26.1",
191
+ "@tiptap/extension-color": "^3.31.3",
192
+ "@tiptap/extension-highlight": "^3.31.3",
193
+ "@tiptap/extension-image": "^3.31.3",
194
+ "@tiptap/extension-link": "^3.31.3",
195
+ "@tiptap/extension-placeholder": "^3.31.3",
196
+ "@tiptap/extension-text-align": "^3.31.3",
197
+ "@tiptap/extension-text-style": "^3.31.3",
198
+ "@tiptap/extension-underline": "^3.31.3",
199
+ "@tiptap/starter-kit": "^3.31.3",
200
+ "@tiptap/vue-3": "^3.31.3",
201
201
  "@types/jsbarcode": "^3.11.4",
202
- "@types/markdown-it": "^14.1.2",
203
- "@vitejs/plugin-vue": "^6.0.7",
204
- "@vue/test-utils": "^2.4.11",
202
+ "@types/markdown-it": "^14.2.0",
203
+ "@vitejs/plugin-vue": "^6.0.8",
204
+ "@vue/test-utils": "^2.5.0",
205
205
  "@vue/tsconfig": "^0.9.1",
206
- "@webgpu/types": "^0.1.71",
206
+ "@webgpu/types": "^0.1.72",
207
207
  "@xterm/addon-fit": "^0.11.0",
208
208
  "@xterm/xterm": "^6.0.0",
209
209
  "chart.js": "^4.5.1",
210
210
  "codemirror": "^6.0.2",
211
- "happy-dom": "^20.10.6",
212
- "highlight.js": "^11.11.1",
211
+ "happy-dom": "^20.14.5",
212
+ "highlight.js": "^11.12.0",
213
213
  "jsbarcode": "^3.12.3",
214
- "markdown-it": "^14.2.0",
214
+ "markdown-it": "^15.0.2",
215
215
  "qrcode-generator": "^2.0.4",
216
216
  "typescript": "~6.0.3",
217
- "vite": "^8.0.16",
218
- "vitest": "^4.1.9",
217
+ "vite": "^8.3.0",
218
+ "vitest": "^5.0.0",
219
219
  "vue": "^3.5.42",
220
- "vue-chartjs": "^5.3.3",
220
+ "vue-chartjs": "^5.3.4",
221
221
  "vue-tsc": "^3.3.11"
222
222
  },
223
223
  "publishConfig": {
@@ -0,0 +1,52 @@
1
+ import { describe, it, expect, beforeEach, vi } from 'vitest'
2
+ import { usePageProgress } from '../composables/usePageProgress'
3
+
4
+ describe('usePageProgress', () => {
5
+ beforeEach(() => {
6
+ const { done } = usePageProgress()
7
+ done()
8
+ vi.useRealTimers()
9
+ })
10
+
11
+ it('start() activates the bar with an initial value', () => {
12
+ const { progress, isActive, start } = usePageProgress()
13
+ start()
14
+ expect(isActive.value).toBe(true)
15
+ expect(progress.value).toBeGreaterThan(0)
16
+ expect(progress.value).toBeLessThan(100)
17
+ })
18
+
19
+ it('start() trickles progress toward 90% over time without reaching it', () => {
20
+ vi.useFakeTimers()
21
+ const { progress, start } = usePageProgress()
22
+ start()
23
+ vi.advanceTimersByTime(2000)
24
+ expect(progress.value).toBeGreaterThan(50)
25
+ expect(progress.value).toBeLessThan(90)
26
+ vi.useRealTimers()
27
+ })
28
+
29
+ it('set() jumps straight to the given percentage, clamped to [0, 100]', () => {
30
+ const { progress, isActive, set } = usePageProgress()
31
+ set(150)
32
+ expect(progress.value).toBe(100)
33
+ expect(isActive.value).toBe(true)
34
+
35
+ set(-10)
36
+ expect(progress.value).toBe(0)
37
+ })
38
+
39
+ it('done() completes the bar then fades it out and resets', () => {
40
+ vi.useFakeTimers()
41
+ const { progress, isActive, start, done } = usePageProgress()
42
+ start()
43
+ done()
44
+ expect(progress.value).toBe(100)
45
+ expect(isActive.value).toBe(true)
46
+
47
+ vi.advanceTimersByTime(200)
48
+ expect(isActive.value).toBe(false)
49
+ expect(progress.value).toBe(0)
50
+ vi.useRealTimers()
51
+ })
52
+ })
@@ -0,0 +1,158 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import MIcon from './MIcon.vue'
4
+
5
+ const props = withDefaults(
6
+ defineProps<{
7
+ title?: string
8
+ /** Material Symbol name, or an image src (URL, data URI, or a path with a file extension) — detected automatically. */
9
+ icon?: string
10
+ titleAlign?: 'start' | 'center'
11
+ /** Show the minimize/maximize/close buttons as a group. Defaults to `true`, except on `platform="macos"` where the OS draws native traffic lights instead. */
12
+ controls?: boolean
13
+ /** Individually hide one control while keeping the others — e.g. a fixed-size window with no maximize button. */
14
+ minimizable?: boolean
15
+ maximizable?: boolean
16
+ closable?: boolean
17
+ /** Reflects the real window state — the bar has no way to know it itself, the host app must read it from its Electron main process and pass it down. */
18
+ maximized?: boolean
19
+ platform?: 'windows' | 'macos'
20
+ /** Bar height in px. */
21
+ height?: number
22
+ /** Double-clicking empty drag space toggles maximize, matching native title bar behavior. */
23
+ doubleClickMaximize?: boolean
24
+ }>(),
25
+ {
26
+ titleAlign: 'start',
27
+ // Explicit `undefined` defaults, not omitted — an omitted optional boolean
28
+ // prop gets auto-cast to `false` by Vue (not left `undefined`), which would
29
+ // permanently break the `props.x ?? smartDefault` fallbacks below.
30
+ controls: undefined,
31
+ minimizable: undefined,
32
+ maximizable: undefined,
33
+ closable: undefined,
34
+ maximized: false,
35
+ platform: 'windows',
36
+ height: 36,
37
+ doubleClickMaximize: true,
38
+ },
39
+ )
40
+
41
+ const emit = defineEmits<{ minimize: []; maximize: []; close: [] }>()
42
+
43
+ // A plain Material Symbol name never has a scheme/path/extension, so this is
44
+ // enough to tell an image src apart from an icon name without needing a
45
+ // separate prop.
46
+ const iconIsImage = computed(() => {
47
+ if (!props.icon) return false
48
+ return /^(data:|https?:\/\/|\.{0,2}\/)/.test(props.icon) || /\.(png|jpe?g|svg|gif|webp|ico|avif)$/i.test(props.icon)
49
+ })
50
+
51
+ const showControls = computed(() => props.controls ?? props.platform !== 'macos')
52
+ const showMinimize = computed(() => showControls.value && (props.minimizable ?? true))
53
+ const showMaximize = computed(() => showControls.value && (props.maximizable ?? true))
54
+ const showClose = computed(() => showControls.value && (props.closable ?? true))
55
+ const hasAnyControl = computed(() => showMinimize.value || showMaximize.value || showClose.value)
56
+
57
+ function onDblclick() {
58
+ if (props.doubleClickMaximize) emit('maximize')
59
+ }
60
+ </script>
61
+
62
+ <template>
63
+ <div
64
+ class="relative flex w-full shrink-0 select-none items-center bg-surface-container text-on-surface"
65
+ style="-webkit-app-region: drag"
66
+ :style="{ height: `${height}px` }"
67
+ @dblclick="onDblclick"
68
+ >
69
+ <!-- Reserves space for native macOS traffic lights, drawn by the OS outside the web content -->
70
+ <div v-if="platform === 'macos'" class="h-full shrink-0" style="width: 78px" />
71
+
72
+ <div
73
+ v-if="icon || $slots.icon"
74
+ class="flex h-full shrink-0 items-center pl-3"
75
+ style="-webkit-app-region: no-drag"
76
+ >
77
+ <slot name="icon">
78
+ <img v-if="iconIsImage" :src="icon" alt="" class="h-4 w-4 object-contain" />
79
+ <MIcon v-else :name="icon!" :size="16" />
80
+ </slot>
81
+ </div>
82
+
83
+ <!-- Start-aligned title sits inline; centered title floats over the whole bar so it's
84
+ centered regardless of how wide the icon/controls on either side are. -->
85
+ <div
86
+ v-if="titleAlign === 'start'"
87
+ class="flex h-full flex-1 items-center truncate px-2 text-label-medium text-on-surface-variant"
88
+ >
89
+ <slot name="title">{{ title }}</slot>
90
+ </div>
91
+ <div v-else class="h-full flex-1" />
92
+ <div
93
+ v-if="titleAlign === 'center'"
94
+ class="pointer-events-none absolute inset-x-0 flex h-full items-center justify-center truncate px-20 text-label-medium text-on-surface-variant"
95
+ >
96
+ <slot name="title">{{ title }}</slot>
97
+ </div>
98
+
99
+ <div v-if="$slots.default" class="flex h-full items-center" style="-webkit-app-region: no-drag">
100
+ <slot />
101
+ </div>
102
+
103
+ <div v-if="$slots.trailing" class="flex h-full shrink-0 items-center" style="-webkit-app-region: no-drag">
104
+ <slot name="trailing" />
105
+ </div>
106
+
107
+ <div v-if="hasAnyControl" class="flex h-full shrink-0" style="-webkit-app-region: no-drag">
108
+ <button
109
+ v-if="showMinimize"
110
+ type="button"
111
+ class="m3-bar-btn"
112
+ aria-label="Minimize"
113
+ @click="emit('minimize')"
114
+ >
115
+ <MIcon name="horizontal_rule" :size="16" />
116
+ </button>
117
+ <button
118
+ v-if="showMaximize"
119
+ type="button"
120
+ class="m3-bar-btn"
121
+ :aria-label="maximized ? 'Restore' : 'Maximize'"
122
+ @click="emit('maximize')"
123
+ >
124
+ <MIcon :name="maximized ? 'filter_none' : 'crop_square'" :size="14" />
125
+ </button>
126
+ <button
127
+ v-if="showClose"
128
+ type="button"
129
+ class="m3-bar-btn m3-bar-btn-close"
130
+ aria-label="Close"
131
+ @click="emit('close')"
132
+ >
133
+ <MIcon name="close" :size="16" />
134
+ </button>
135
+ </div>
136
+ </div>
137
+ </template>
138
+
139
+ <style>
140
+ .m3-bar-btn {
141
+ display: inline-flex;
142
+ height: 100%;
143
+ width: 46px;
144
+ align-items: center;
145
+ justify-content: center;
146
+ color: var(--color-on-surface-variant);
147
+ transition: background-color 100ms ease, color 100ms ease;
148
+ cursor: pointer;
149
+ }
150
+ .m3-bar-btn:hover {
151
+ background-color: var(--color-surface-container-highest);
152
+ color: var(--color-on-surface);
153
+ }
154
+ .m3-bar-btn-close:hover {
155
+ background-color: var(--color-error);
156
+ color: var(--color-on-error);
157
+ }
158
+ </style>
@@ -0,0 +1,62 @@
1
+ <script setup lang="ts">
2
+ import { getCurrentInstance, onMounted, onUnmounted } from "vue";
3
+ import { usePageProgress } from "../composables/usePageProgress";
4
+
5
+ const props = withDefaults(
6
+ defineProps<{
7
+ color?: "primary" | "secondary" | "tertiary" | "error";
8
+ thickness?: number;
9
+ /** Auto-wire to vue-router's navigation guards when a router is detected. Set to `false` to drive it entirely by hand via `usePageProgress()`. */
10
+ auto?: boolean;
11
+ position?: "top" | "bottom";
12
+ }>(),
13
+ { color: "primary", thickness: 3, auto: true, position: "top" },
14
+ );
15
+
16
+ const { progress, isActive, start, done } = usePageProgress();
17
+
18
+ const colorMap: Record<"primary" | "secondary" | "tertiary" | "error", string> = {
19
+ primary: "bg-primary",
20
+ secondary: "bg-secondary",
21
+ tertiary: "bg-tertiary",
22
+ error: "bg-error",
23
+ };
24
+
25
+ const unregister: Array<() => void> = [];
26
+
27
+ onMounted(() => {
28
+ if (!props.auto) return;
29
+
30
+ // Duck-typed vue-router detection — avoids a hard dependency on the package.
31
+ const router = getCurrentInstance()?.appContext.config.globalProperties.$router;
32
+ if (!router) return;
33
+
34
+ unregister.push(router.beforeEach(() => { start(); }));
35
+ unregister.push(router.afterEach(() => { done(); }));
36
+ unregister.push(router.onError(() => { done(); }));
37
+ });
38
+
39
+ onUnmounted(() => {
40
+ unregister.forEach((fn) => fn());
41
+ unregister.length = 0;
42
+ });
43
+ </script>
44
+
45
+ <template>
46
+ <div
47
+ class="pointer-events-none fixed inset-x-0 z-[9999] overflow-hidden transition-opacity duration-300"
48
+ :class="[position === 'top' ? 'top-0' : 'bottom-0', isActive ? 'opacity-100' : 'opacity-0']"
49
+ :style="{ height: `${thickness}px` }"
50
+ role="progressbar"
51
+ aria-hidden="true"
52
+ :aria-valuenow="isActive ? Math.round(progress) : undefined"
53
+ aria-valuemin="0"
54
+ aria-valuemax="100"
55
+ >
56
+ <div
57
+ class="h-full rounded-r-full transition-[width] duration-200 ease-out"
58
+ :class="colorMap[color]"
59
+ :style="{ width: `${progress}%` }"
60
+ />
61
+ </div>
62
+ </template>