@m3ui-vue/m3ui-vue 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. package/README.md +12 -2
  2. package/dist/API.md +3661 -0
  3. package/dist/MIcon-CaEooCmZ.js.map +1 -1
  4. package/dist/{MTextField-B0wGv1Mx.js → MTextField-pJU1vFaR.js} +3 -3
  5. package/dist/MTextField-pJU1vFaR.js.map +1 -0
  6. package/dist/api.json +1 -0
  7. package/dist/barcode.js.map +1 -1
  8. package/dist/chart.js.map +1 -1
  9. package/dist/code-editor.js +2 -2
  10. package/dist/code-editor.js.map +1 -1
  11. package/dist/components/MAbsolute.vue.d.ts +12 -0
  12. package/dist/components/MAlert.vue.d.ts +4 -0
  13. package/dist/components/MAppBar.vue.d.ts +12 -0
  14. package/dist/components/MAppLayout.vue.d.ts +2 -0
  15. package/dist/components/MAspectRatio.vue.d.ts +1 -0
  16. package/dist/components/MAutocomplete.vue.d.ts +18 -0
  17. package/dist/components/MAvatar.vue.d.ts +3 -0
  18. package/dist/components/MBadge.vue.d.ts +6 -0
  19. package/dist/components/MBar.vue.d.ts +5 -0
  20. package/dist/components/MBarcode.vue.d.ts +9 -0
  21. package/dist/components/MBottomSheet.vue.d.ts +3 -0
  22. package/dist/components/MBox.vue.d.ts +6 -0
  23. package/dist/components/MBreadcrumbs.vue.d.ts +2 -0
  24. package/dist/components/MButton.vue.d.ts +14 -4
  25. package/dist/components/MButtonGroup.vue.d.ts +7 -0
  26. package/dist/components/MCalendar.vue.d.ts +8 -0
  27. package/dist/components/MCard.vue.d.ts +17 -0
  28. package/dist/components/MCarousel.vue.d.ts +7 -1
  29. package/dist/components/MCenter.vue.d.ts +1 -0
  30. package/dist/components/MChart.vue.d.ts +7 -0
  31. package/dist/components/MChatBubble.vue.d.ts +10 -0
  32. package/dist/components/MCheckbox.vue.d.ts +5 -0
  33. package/dist/components/MChip.vue.d.ts +9 -0
  34. package/dist/components/MCircleProgressBar.vue.d.ts +7 -0
  35. package/dist/components/MCodeEditor.vue.d.ts +9 -0
  36. package/dist/components/MColorPicker.vue.d.ts +8 -0
  37. package/dist/components/MColorPickerModal.vue.d.ts +4 -0
  38. package/dist/components/MCommandPalette.vue.d.ts +8 -0
  39. package/dist/components/MConfirmDialog.vue.d.ts +7 -0
  40. package/dist/components/MContainer.vue.d.ts +4 -0
  41. package/dist/components/MContextMenu.vue.d.ts +3 -6
  42. package/dist/components/MCopyButton.vue.d.ts +10 -0
  43. package/dist/components/MDataTable.vue.d.ts +33 -12
  44. package/dist/components/MDatePicker.vue.d.ts +16 -0
  45. package/dist/components/MDatePickerModal.vue.d.ts +9 -0
  46. package/dist/components/MDateRangePicker.vue.d.ts +18 -0
  47. package/dist/components/MDateRangePickerModal.vue.d.ts +9 -0
  48. package/dist/components/MDialog.vue.d.ts +9 -7
  49. package/dist/components/MDivider.vue.d.ts +6 -0
  50. package/dist/components/MDragDropList.vue.d.ts +6 -0
  51. package/dist/components/MEmoji.vue.d.ts +6 -0
  52. package/dist/components/MEmojiButton.vue.d.ts +5 -0
  53. package/dist/components/MEmptyState.vue.d.ts +4 -0
  54. package/dist/components/MExpansionPanel.vue.d.ts +9 -0
  55. package/dist/components/MExportButton.vue.d.ts +8 -0
  56. package/dist/components/MFab.vue.d.ts +9 -0
  57. package/dist/components/MFabMenu.vue.d.ts +14 -0
  58. package/dist/components/MFileUpload.vue.d.ts +8 -0
  59. package/dist/components/MFixed.vue.d.ts +10 -0
  60. package/dist/components/MFlex.vue.d.ts +6 -0
  61. package/dist/components/MFooter.vue.d.ts +11 -0
  62. package/dist/components/MFullscreen.vue.d.ts +2 -0
  63. package/dist/components/MGrid.vue.d.ts +7 -0
  64. package/dist/components/MHotkeys.vue.d.ts +4 -0
  65. package/dist/components/MIcon.vue.d.ts +2 -0
  66. package/dist/components/MIconButton.vue.d.ts +10 -0
  67. package/dist/components/MInfiniteScroll.vue.d.ts +6 -0
  68. package/dist/components/MJsonEditor.vue.d.ts +8 -0
  69. package/dist/components/MJsonViewer.vue.d.ts +4 -0
  70. package/dist/components/MKanban.vue.d.ts +2 -0
  71. package/dist/components/MKbd.vue.d.ts +2 -0
  72. package/dist/components/MLightbox.vue.d.ts +4 -0
  73. package/dist/components/MList.vue.d.ts +7 -0
  74. package/dist/components/MListItem.vue.d.ts +24 -0
  75. package/dist/components/MListSubheader.vue.d.ts +6 -0
  76. package/dist/components/MLoadingIndicator.vue.d.ts +10 -0
  77. package/dist/components/MLoadingOverlay.vue.d.ts +5 -0
  78. package/dist/components/MMarkdown.vue.d.ts +3 -0
  79. package/dist/components/MMaskField.vue.d.ts +15 -0
  80. package/dist/components/MMasonry.vue.d.ts +5 -0
  81. package/dist/components/MMenu.vue.d.ts +3 -6
  82. package/dist/components/MMenuDivider.vue.d.ts +4 -0
  83. package/dist/components/MMenuItem.vue.d.ts +5 -0
  84. package/dist/components/MMultiAutocomplete.vue.d.ts +20 -0
  85. package/dist/components/MMultiSelect.vue.d.ts +21 -0
  86. package/dist/components/MNavigationBar.vue.d.ts +2 -0
  87. package/dist/components/MNavigationDrawer.vue.d.ts +11 -0
  88. package/dist/components/MNavigationRail.vue.d.ts +9 -6
  89. package/dist/components/MNavigationSuite.vue.d.ts +5 -3
  90. package/dist/components/MNumberField.vue.d.ts +17 -0
  91. package/dist/components/MOverlay.vue.d.ts +3 -0
  92. package/dist/components/MPageProgress.vue.d.ts +3 -0
  93. package/dist/components/MPagination.vue.d.ts +3 -0
  94. package/dist/components/MPasswordMeter.vue.d.ts +1 -0
  95. package/dist/components/MPinInput.vue.d.ts +11 -0
  96. package/dist/components/MProgressBar.vue.d.ts +6 -0
  97. package/dist/components/MPullToRefresh.vue.d.ts +8 -0
  98. package/dist/components/MQRCode.vue.d.ts +6 -0
  99. package/dist/components/MRadio.vue.d.ts +5 -0
  100. package/dist/components/MRadioGroup.vue.d.ts +6 -0
  101. package/dist/components/MRating.vue.d.ts +11 -0
  102. package/dist/components/MRelativeTime.vue.d.ts +1 -0
  103. package/dist/components/MResponsive.vue.d.ts +3 -0
  104. package/dist/components/MResult.vue.d.ts +6 -0
  105. package/dist/components/MRichTextEditor.vue.d.ts +8 -0
  106. package/dist/components/MScheduler.vue.d.ts +10 -0
  107. package/dist/components/MScrollable.vue.d.ts +3 -0
  108. package/dist/components/MSearchBar.vue.d.ts +6 -0
  109. package/dist/components/MSection.vue.d.ts +5 -0
  110. package/dist/components/MSegmentedButton.vue.d.ts +5 -0
  111. package/dist/components/MSelect.vue.d.ts +17 -0
  112. package/dist/components/MShader.vue.d.ts +1 -0
  113. package/dist/components/MShortNavigationBar.vue.d.ts +8 -9
  114. package/dist/components/MSideSheet.vue.d.ts +3 -0
  115. package/dist/components/MSignaturePad.vue.d.ts +7 -0
  116. package/dist/components/MSimpleCarousel.vue.d.ts +10 -0
  117. package/dist/components/MSkeleton.vue.d.ts +8 -0
  118. package/dist/components/MSlider.vue.d.ts +14 -0
  119. package/dist/components/MSnackbar.vue.d.ts +1 -0
  120. package/dist/components/MSpinner.vue.d.ts +6 -0
  121. package/dist/components/MSplitButton.vue.d.ts +7 -0
  122. package/dist/components/MSplitter.vue.d.ts +4 -0
  123. package/dist/components/MSpotlightSearch.vue.d.ts +18 -0
  124. package/dist/components/MStack.vue.d.ts +7 -0
  125. package/dist/components/MStatCard.vue.d.ts +7 -0
  126. package/dist/components/MStepper.vue.d.ts +7 -0
  127. package/dist/components/MSticky.vue.d.ts +2 -0
  128. package/dist/components/MSubtitle.vue.d.ts +4 -0
  129. package/dist/components/MSwitch.vue.d.ts +5 -6
  130. package/dist/components/MTable.vue.d.ts +17 -4
  131. package/dist/components/MTabs.vue.d.ts +6 -0
  132. package/dist/components/MTagInput.vue.d.ts +17 -0
  133. package/dist/components/MTerminal.vue.d.ts +4 -0
  134. package/dist/components/MText.vue.d.ts +10 -0
  135. package/dist/components/MTextField.vue.d.ts +18 -0
  136. package/dist/components/MTimePicker.vue.d.ts +10 -0
  137. package/dist/components/MTimePickerModal.vue.d.ts +5 -0
  138. package/dist/components/MTimeline.vue.d.ts +3 -0
  139. package/dist/components/MTitle.vue.d.ts +4 -0
  140. package/dist/components/MToggleButton.vue.d.ts +4 -0
  141. package/dist/components/MToolbar.vue.d.ts +5 -0
  142. package/dist/components/MTooltip.vue.d.ts +7 -0
  143. package/dist/components/MTopAppBar.vue.d.ts +8 -0
  144. package/dist/components/MTour.vue.d.ts +5 -0
  145. package/dist/components/MTransferList.vue.d.ts +11 -0
  146. package/dist/components/MTree.vue.d.ts +11 -0
  147. package/dist/components/MTreeTable.vue.d.ts +7 -0
  148. package/dist/components/MVirtualTable.vue.d.ts +6 -0
  149. package/dist/components/MWindow.vue.d.ts +32 -0
  150. package/dist/composables/useLocale.d.ts +2 -0
  151. package/dist/m3ui-vue.css +1 -1
  152. package/dist/m3ui.js +5239 -5242
  153. package/dist/m3ui.js.map +1 -1
  154. package/dist/markdown.js +1 -1
  155. package/dist/markdown.js.map +1 -1
  156. package/dist/qrcode.js.map +1 -1
  157. package/dist/rich-text-editor.js +3 -3
  158. package/dist/rich-text-editor.js.map +1 -1
  159. package/dist/styles.css +1 -1
  160. package/dist/terminal.js.map +1 -1
  161. package/dist/{useLocale-CmI675Ab.js → useLocale-Drihe5G2.js} +13 -10
  162. package/dist/useLocale-Drihe5G2.js.map +1 -0
  163. package/package.json +4 -2
  164. package/src/__tests__/MHotkeys.test.ts +57 -0
  165. package/src/__tests__/hostLocale.test.ts +57 -0
  166. package/src/components/MAbsolute.vue +18 -0
  167. package/src/components/MAlert.vue +12 -0
  168. package/src/components/MAppBar.vue +12 -0
  169. package/src/components/MAppLayout.vue +11 -0
  170. package/src/components/MAspectRatio.vue +6 -0
  171. package/src/components/MAutocomplete.vue +24 -0
  172. package/src/components/MAvatar.vue +12 -1
  173. package/src/components/MBadge.vue +11 -0
  174. package/src/components/MBar.vue +19 -0
  175. package/src/components/MBarcode.vue +14 -0
  176. package/src/components/MBottomSheet.vue +12 -0
  177. package/src/components/MBox.vue +12 -0
  178. package/src/components/MBreadcrumbs.vue +7 -0
  179. package/src/components/MButton.vue +22 -4
  180. package/src/components/MButtonGroup.vue +13 -0
  181. package/src/components/MCalendar.vue +14 -0
  182. package/src/components/MCard.vue +26 -0
  183. package/src/components/MCarousel.vue +17 -1
  184. package/src/components/MCenter.vue +6 -0
  185. package/src/components/MChart.vue +12 -0
  186. package/src/components/MChatBubble.vue +17 -0
  187. package/src/components/MCheckbox.vue +11 -0
  188. package/src/components/MChip.vue +17 -0
  189. package/src/components/MCircleProgressBar.vue +13 -0
  190. package/src/components/MCodeEditor.vue +15 -0
  191. package/src/components/MColorPicker.vue +13 -0
  192. package/src/components/MColorPickerModal.vue +12 -0
  193. package/src/components/MCommandPalette.vue +16 -0
  194. package/src/components/MConfirmDialog.vue +15 -0
  195. package/src/components/MContainer.vue +9 -0
  196. package/src/components/MContextMenu.vue +17 -6
  197. package/src/components/MCopyButton.vue +16 -0
  198. package/src/components/MDataTable.vue +58 -12
  199. package/src/components/MDatePicker.vue +21 -0
  200. package/src/components/MDatePickerModal.vue +16 -0
  201. package/src/components/MDateRangePicker.vue +23 -0
  202. package/src/components/MDateRangePickerModal.vue +16 -0
  203. package/src/components/MDialog.vue +27 -7
  204. package/src/components/MDivider.vue +6 -0
  205. package/src/components/MDragDropList.vue +18 -0
  206. package/src/components/MEmoji.vue +6 -0
  207. package/src/components/MEmojiButton.vue +11 -0
  208. package/src/components/MEmojiSelector.vue +7 -0
  209. package/src/components/MEmptyState.vue +9 -0
  210. package/src/components/MExpansionPanel.vue +17 -0
  211. package/src/components/MExportButton.vue +15 -0
  212. package/src/components/MFab.vue +17 -0
  213. package/src/components/MFabMenu.vue +20 -0
  214. package/src/components/MFileUpload.vue +19 -0
  215. package/src/components/MFixed.vue +16 -0
  216. package/src/components/MFlex.vue +11 -0
  217. package/src/components/MFooter.vue +11 -0
  218. package/src/components/MFullscreen.vue +8 -0
  219. package/src/components/MGrid.vue +12 -0
  220. package/src/components/MHotkeys.vue +20 -13
  221. package/src/components/MIcon.vue +10 -1
  222. package/src/components/MIconButton.vue +13 -0
  223. package/src/components/MInfiniteScroll.vue +16 -0
  224. package/src/components/MJsonEditor.vue +13 -0
  225. package/src/components/MJsonViewer.vue +7 -0
  226. package/src/components/MKanban.vue +18 -0
  227. package/src/components/MKbd.vue +6 -0
  228. package/src/components/MLightbox.vue +16 -0
  229. package/src/components/MList.vue +15 -0
  230. package/src/components/MListDetail.vue +11 -0
  231. package/src/components/MListItem.vue +37 -0
  232. package/src/components/MListSubheader.vue +6 -0
  233. package/src/components/MLoadingIndicator.vue +15 -0
  234. package/src/components/MLoadingOverlay.vue +12 -0
  235. package/src/components/MMarkdown.vue +7 -0
  236. package/src/components/MMaskField.vue +21 -0
  237. package/src/components/MMasonry.vue +11 -0
  238. package/src/components/MMenu.vue +16 -6
  239. package/src/components/MMenuDivider.vue +4 -0
  240. package/src/components/MMenuItem.vue +16 -0
  241. package/src/components/MMultiAutocomplete.vue +26 -0
  242. package/src/components/MMultiSelect.vue +27 -0
  243. package/src/components/MNavigationBar.vue +7 -0
  244. package/src/components/MNavigationDrawer.vue +25 -0
  245. package/src/components/MNavigationRail.vue +24 -6
  246. package/src/components/MNavigationSuite.vue +20 -3
  247. package/src/components/MNotificationHost.vue +3 -0
  248. package/src/components/MNumberField.vue +24 -0
  249. package/src/components/MOverlay.vue +10 -0
  250. package/src/components/MPageProgress.vue +7 -0
  251. package/src/components/MPagination.vue +15 -1
  252. package/src/components/MPasswordMeter.vue +7 -0
  253. package/src/components/MPinInput.vue +19 -0
  254. package/src/components/MProgressBar.vue +9 -0
  255. package/src/components/MPullToRefresh.vue +17 -0
  256. package/src/components/MQRCode.vue +12 -0
  257. package/src/components/MRadio.vue +11 -0
  258. package/src/components/MRadioGroup.vue +11 -0
  259. package/src/components/MRating.vue +19 -0
  260. package/src/components/MRelative.vue +8 -0
  261. package/src/components/MRelativeTime.vue +6 -0
  262. package/src/components/MResponsive.vue +9 -0
  263. package/src/components/MResult.vue +14 -0
  264. package/src/components/MRichTextEditor.vue +14 -0
  265. package/src/components/MScheduler.vue +21 -0
  266. package/src/components/MScrollable.vue +8 -0
  267. package/src/components/MSearchBar.vue +17 -0
  268. package/src/components/MSection.vue +13 -0
  269. package/src/components/MSegmentedButton.vue +10 -0
  270. package/src/components/MSelect.vue +22 -0
  271. package/src/components/MShader.vue +13 -0
  272. package/src/components/MShape.vue +6 -0
  273. package/src/components/MShortNavigationBar.vue +23 -9
  274. package/src/components/MSideSheet.vue +13 -0
  275. package/src/components/MSignaturePad.vue +15 -0
  276. package/src/components/MSimpleCarousel.vue +18 -0
  277. package/src/components/MSkeleton.vue +8 -0
  278. package/src/components/MSlider.vue +21 -0
  279. package/src/components/MSnackbar.vue +5 -0
  280. package/src/components/MSpacer.vue +6 -0
  281. package/src/components/MSpinner.vue +10 -0
  282. package/src/components/MSplitButton.vue +14 -0
  283. package/src/components/MSplitter.vue +10 -0
  284. package/src/components/MSpotlightSearch.vue +27 -0
  285. package/src/components/MStack.vue +12 -0
  286. package/src/components/MStatCard.vue +13 -0
  287. package/src/components/MStepper.vue +12 -0
  288. package/src/components/MSticky.vue +7 -0
  289. package/src/components/MSubtitle.vue +9 -0
  290. package/src/components/MSupportingPane.vue +10 -0
  291. package/src/components/MSwitch.vue +14 -6
  292. package/src/components/MTable.vue +33 -4
  293. package/src/components/MTabs.vue +12 -0
  294. package/src/components/MTagInput.vue +23 -0
  295. package/src/components/MTerminal.vue +11 -0
  296. package/src/components/MText.vue +15 -0
  297. package/src/components/MTextField.vue +26 -0
  298. package/src/components/MTimePicker.vue +15 -0
  299. package/src/components/MTimePickerModal.vue +12 -0
  300. package/src/components/MTimeline.vue +7 -0
  301. package/src/components/MTitle.vue +9 -0
  302. package/src/components/MToggleButton.vue +12 -0
  303. package/src/components/MToolbar.vue +12 -0
  304. package/src/components/MTooltip.vue +15 -0
  305. package/src/components/MTopAppBar.vue +18 -0
  306. package/src/components/MTour.vue +13 -0
  307. package/src/components/MTransferList.vue +24 -0
  308. package/src/components/MTree.vue +11 -0
  309. package/src/components/MTreeTable.vue +15 -0
  310. package/src/components/MVirtualTable.vue +12 -0
  311. package/src/components/MWindow.vue +34 -0
  312. package/src/composables/useLocale.ts +16 -3
  313. package/src/plugin.ts +2 -1
  314. package/dist/MTextField-B0wGv1Mx.js.map +0 -1
  315. package/dist/useLocale-CmI675Ab.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 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\n// xterm draws on a canvas, so it can't use the CSS variables directly: read them (from the\n// container, so a palette set on an ancestor applies too) and hand xterm plain colors.\nfunction getThemeColors() {\n const style = getComputedStyle(containerRef.value ?? 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\n// Theme (.dark) and palette (data-palette) changes don't reach the canvas on their own: re-read\n// the colors whenever <html> changes, like useFieldBg does.\nlet themeObserver: MutationObserver | null = null\nlet unmounted = false\nfunction applyTheme() {\n if (terminal) terminal.options.theme = getThemeColors()\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 // Unmounted while xterm was loading: don't create a terminal (and observers) nobody will dispose.\n if (unmounted || !containerRef.value) return\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: getThemeColors(),\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 themeObserver = new MutationObserver(applyTheme)\n themeObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class', 'style', 'data-theme', 'data-palette'],\n })\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n writeLines(newLines)\n})\n\nonBeforeUnmount(() => {\n unmounted = true\n resizeObserver?.disconnect()\n themeObserver?.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\n// xterm draws on a canvas, so it can't use the CSS variables directly: read them (from the\n// container, so a palette set on an ancestor applies too) and hand xterm plain colors.\nfunction getThemeColors() {\n const style = getComputedStyle(containerRef.value ?? 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\n// Theme (.dark) and palette (data-palette) changes don't reach the canvas on their own: re-read\n// the colors whenever <html> changes, like useFieldBg does.\nlet themeObserver: MutationObserver | null = null\nlet unmounted = false\nfunction applyTheme() {\n if (terminal) terminal.options.theme = getThemeColors()\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 // Unmounted while xterm was loading: don't create a terminal (and observers) nobody will dispose.\n if (unmounted || !containerRef.value) return\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: getThemeColors(),\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 themeObserver = new MutationObserver(applyTheme)\n themeObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class', 'style', 'data-theme', 'data-palette'],\n })\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n writeLines(newLines)\n})\n\nonBeforeUnmount(() => {\n unmounted = true\n resizeObserver?.disconnect()\n themeObserver?.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":"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"}
1
+ {"version":3,"file":"terminal.js","names":[],"sources":["../src/components/MTerminal.vue","../src/components/MTerminal.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * A terminal emulator built on xterm.js — pre-filled static output, or fully interactive keyboard input.\n *\n * @event line Emitted with the buffered text once the user presses Enter — the usual event to handle a\n * submitted command\n * @event input Emitted for every raw keystroke/data chunk xterm receives (not readonly)\n */\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** Initial lines to display */\n lines?: string[]\n /** Disable input */\n readonly?: boolean\n /** Title bar text */\n title?: string\n /** Minimum height */\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\n// xterm draws on a canvas, so it can't use the CSS variables directly: read them (from the\n// container, so a palette set on an ancestor applies too) and hand xterm plain colors.\nfunction getThemeColors() {\n const style = getComputedStyle(containerRef.value ?? 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\n// Theme (.dark) and palette (data-palette) changes don't reach the canvas on their own: re-read\n// the colors whenever <html> changes, like useFieldBg does.\nlet themeObserver: MutationObserver | null = null\nlet unmounted = false\nfunction applyTheme() {\n if (terminal) terminal.options.theme = getThemeColors()\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 // Unmounted while xterm was loading: don't create a terminal (and observers) nobody will dispose.\n if (unmounted || !containerRef.value) return\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: getThemeColors(),\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 themeObserver = new MutationObserver(applyTheme)\n themeObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class', 'style', 'data-theme', 'data-palette'],\n })\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n writeLines(newLines)\n})\n\nonBeforeUnmount(() => {\n unmounted = true\n resizeObserver?.disconnect()\n themeObserver?.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\">\n/**\n * A terminal emulator built on xterm.js — pre-filled static output, or fully interactive keyboard input.\n *\n * @event line Emitted with the buffered text once the user presses Enter — the usual event to handle a\n * submitted command\n * @event input Emitted for every raw keystroke/data chunk xterm receives (not readonly)\n */\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** Initial lines to display */\n lines?: string[]\n /** Disable input */\n readonly?: boolean\n /** Title bar text */\n title?: string\n /** Minimum height */\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\n// xterm draws on a canvas, so it can't use the CSS variables directly: read them (from the\n// container, so a palette set on an ancestor applies too) and hand xterm plain colors.\nfunction getThemeColors() {\n const style = getComputedStyle(containerRef.value ?? 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\n// Theme (.dark) and palette (data-palette) changes don't reach the canvas on their own: re-read\n// the colors whenever <html> changes, like useFieldBg does.\nlet themeObserver: MutationObserver | null = null\nlet unmounted = false\nfunction applyTheme() {\n if (terminal) terminal.options.theme = getThemeColors()\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 // Unmounted while xterm was loading: don't create a terminal (and observers) nobody will dispose.\n if (unmounted || !containerRef.value) return\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: getThemeColors(),\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 themeObserver = new MutationObserver(applyTheme)\n themeObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class', 'style', 'data-theme', 'data-palette'],\n })\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n writeLines(newLines)\n})\n\nonBeforeUnmount(() => {\n unmounted = true\n resizeObserver?.disconnect()\n themeObserver?.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":"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"}
@@ -1,6 +1,6 @@
1
- import { inject as e, reactive as t, toValue as n, watchEffect as r } from "vue";
1
+ import { inject as e, reactive as t, shallowRef as n, toValue as r, watchEffect as i } from "vue";
2
2
  //#region src/composables/useLocale.ts
3
- var i = {
3
+ var a = {
4
4
  lang: "en",
5
5
  search: "Search...",
6
6
  noResults: "No results",
@@ -127,14 +127,17 @@ var i = {
127
127
  nextPage: "Next page",
128
128
  carousel: "Carousel",
129
129
  carouselItem: "{index} of {count}"
130
- }, a = Symbol("m3-locale");
131
- function o() {
132
- let o = e(a, {}), s = t({ ...i });
133
- return r(() => {
134
- Object.assign(s, i, n(o));
135
- }), s;
130
+ }, o = Symbol("m3-locale"), s = n(null);
131
+ function c(e) {
132
+ s.value = e ? { locale: e } : null;
133
+ }
134
+ function l() {
135
+ let n = e(o, null), c = t({ ...a });
136
+ return i(() => {
137
+ Object.assign(c, a, r(n ?? s.value?.locale ?? {}));
138
+ }), c;
136
139
  }
137
140
  //#endregion
138
- export { i as n, o as r, a as t };
141
+ export { l as i, c as n, a as r, o as t };
139
142
 
140
- //# sourceMappingURL=useLocale-CmI675Ab.js.map
143
+ //# sourceMappingURL=useLocale-Drihe5G2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocale-Drihe5G2.js","names":[],"sources":["../src/composables/useLocale.ts"],"sourcesContent":["import { inject, reactive, shallowRef, watchEffect, toValue, type InjectionKey, type MaybeRef } from 'vue'\n\nexport interface M3Locale {\n /** BCP-47 language tag (e.g. 'en', 'es', 'pt') — read by locale-aware components (MRelativeTime) that use Intl formatting. */\n lang: string\n\n // Common\n search: string\n noResults: string\n close: string\n cancel: string\n confirm: string\n loading: string\n menu: string\n\n // Navigation\n previous: string\n next: string\n today: string\n more: string\n\n // Tables\n selectedCount: string\n recordCount: string\n expand: string\n columns: string\n exportCsv: string\n noGroup: string\n\n // Tour\n finish: string\n\n // File upload\n dropText: string\n selectText: string\n maxSizePrefix: string\n remove: string\n\n // Pickers\n selectDate: string\n selectTime: string\n selectRange: string\n pickStart: string\n pickEnd: string\n previousMonth: string\n nextMonth: string\n\n // Scheduler\n dayView: string\n weekView: string\n allDay: string\n emojiSearch: string\n emojiNoResults: string\n emojiRecent: string\n emojiSkinTone: string\n emojiSkinTones: string\n emojiCategorySmileys: string\n emojiCategoryGestures: string\n emojiCategoryPeople: string\n emojiCategoryAnimals: string\n emojiCategoryNature: string\n emojiCategoryFood: string\n emojiCategoryActivities: string\n emojiCategoryTravel: string\n emojiCategoryObjects: string\n emojiCategorySymbols: string\n emojiCategoryFlags: string\n\n // Transfer list\n available: string\n selected: string\n noItems: string\n moveAllRight: string\n moveRight: string\n moveLeft: string\n moveAllLeft: string\n\n // Command palette / Spotlight\n searchCommand: string\n navigateHint: string\n selectHint: string\n openHint: string\n closeHint: string\n\n // Infinite scroll\n loadingMore: string\n noMoreItems: string\n\n // Rich text editor\n bold: string\n italic: string\n underline: string\n strikethrough: string\n highlight: string\n bulletList: string\n orderedList: string\n blockquote: string\n code: string\n alignLeft: string\n alignCenter: string\n alignRight: string\n undo: string\n redo: string\n link: string\n image: string\n paragraph: string\n heading1: string\n heading2: string\n heading3: string\n insertLink: string\n insertImage: string\n imageUrlLabel: string\n insert: string\n\n // JSON editor\n jsonValid: string\n jsonInvalid: string\n jsonFormat: string\n jsonMinify: string\n\n // JSON viewer\n jsonElements: string\n jsonFields: string\n\n // Result\n resultSuccessTitle: string\n resultSuccessDesc: string\n resultErrorTitle: string\n resultErrorDesc: string\n resultWarningTitle: string\n resultWarningDesc: string\n resultInfoTitle: string\n resultInfoDesc: string\n result404Title: string\n result404Desc: string\n result403Title: string\n result403Desc: string\n result500Title: string\n result500Desc: string\n\n // Chat bubble\n chatTyping: string\n chatRecordingAudio: string\n\n // Drag & drop list ({pos}/{total} are replaced at runtime)\n reorderHandle: string\n reorderGrabbed: string\n reorderMoved: string\n reorderDropped: string\n reorderCancelled: string\n\n // Transfer list (panes)\n selectAll: string\n clearSearch: string\n\n // Kanban ({column}/{pos}/{total} are replaced at runtime)\n kanbanMoved: string\n // MWindow title bar buttons\n windowMinimize: string\n windowMaximize: string\n windowRestore: string\n // MPagination ({from}/{to}/{total} and {page}/{pages} are replaced at runtime)\n paginationRange: string\n paginationPage: string\n previousPage: string\n nextPage: string\n carousel: string\n carouselItem: string\n}\n\nexport const defaultLocale: M3Locale = {\n lang: 'en',\n\n search: 'Search...',\n noResults: 'No results',\n close: 'Close',\n menu: 'Menu',\n cancel: 'Cancel',\n confirm: 'Confirm',\n loading: 'Loading',\n\n previous: 'Previous',\n next: 'Next',\n today: 'Today',\n more: 'more',\n\n selectedCount: 'selected',\n recordCount: 'record',\n expand: 'Expand',\n columns: 'Columns',\n exportCsv: 'Export CSV',\n noGroup: 'No group',\n\n finish: 'Finish',\n\n dropText: 'Drop files here or',\n selectText: 'browse',\n maxSizePrefix: 'Max.',\n remove: 'Remove',\n\n selectDate: 'Select date',\n selectTime: 'Select time',\n selectRange: 'Select range',\n pickStart: 'Select start',\n pickEnd: 'Select end',\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n\n dayView: 'Day',\n weekView: 'Week',\n allDay: 'All day',\n emojiSearch: 'Search emoji',\n emojiNoResults: 'No emoji found',\n emojiRecent: 'Recently used',\n emojiSkinTone: 'Skin tone',\n emojiSkinTones: 'No skin tone|Light|Medium-light|Medium|Medium-dark|Dark',\n emojiCategorySmileys: 'Smileys',\n emojiCategoryGestures: 'Gestures',\n emojiCategoryPeople: 'People',\n emojiCategoryAnimals: 'Animals',\n emojiCategoryNature: 'Nature',\n emojiCategoryFood: 'Food & drink',\n emojiCategoryActivities: 'Activities',\n emojiCategoryTravel: 'Travel & places',\n emojiCategoryObjects: 'Objects',\n emojiCategorySymbols: 'Symbols',\n emojiCategoryFlags: 'Flags',\n\n available: 'Available',\n selected: 'Selected',\n noItems: 'No items',\n moveAllRight: 'Move all right',\n moveRight: 'Move selected right',\n moveLeft: 'Move selected left',\n moveAllLeft: 'Move all left',\n\n searchCommand: 'Search command...',\n navigateHint: 'navigate',\n selectHint: 'select',\n openHint: 'open',\n closeHint: 'close',\n\n loadingMore: 'Loading...',\n noMoreItems: 'No more items',\n\n bold: 'Bold',\n italic: 'Italic',\n underline: 'Underline',\n strikethrough: 'Strikethrough',\n highlight: 'Highlight',\n bulletList: 'Bullet list',\n orderedList: 'Ordered list',\n blockquote: 'Blockquote',\n code: 'Code',\n alignLeft: 'Align left',\n alignCenter: 'Align center',\n alignRight: 'Align right',\n undo: 'Undo',\n redo: 'Redo',\n link: 'Link',\n image: 'Image',\n paragraph: 'Paragraph',\n heading1: 'Heading 1',\n heading2: 'Heading 2',\n heading3: 'Heading 3',\n insertLink: 'Insert link',\n insertImage: 'Insert image',\n imageUrlLabel: 'Image URL',\n insert: 'Insert',\n\n jsonValid: 'Valid',\n jsonInvalid: 'Invalid',\n jsonFormat: 'Format',\n jsonMinify: 'Minify',\n\n jsonElements: 'elements',\n jsonFields: 'fields',\n\n // Result\n resultSuccessTitle: 'Success',\n resultSuccessDesc: 'The action was completed successfully.',\n resultErrorTitle: 'Something went wrong',\n resultErrorDesc: 'An unexpected error occurred. Please try again.',\n resultWarningTitle: 'Warning',\n resultWarningDesc: 'Something needs your attention.',\n resultInfoTitle: 'Information',\n resultInfoDesc: 'Here is something you should know.',\n result404Title: 'Page not found',\n result404Desc: 'The page you are looking for does not exist or has been moved.',\n result403Title: 'Access denied',\n result403Desc: 'You don\\'t have permission to view this resource.',\n result500Title: 'Server error',\n result500Desc: 'The server could not process the request.',\n\n // Chat bubble\n chatTyping: 'Typing…',\n chatRecordingAudio: 'Recording audio…',\n\n // Drag & drop list ({pos}/{total} are replaced at runtime)\n reorderHandle: 'Reorder',\n reorderGrabbed: 'Item grabbed, position {pos} of {total}. Use the arrow keys to move it, Space to drop it, Escape to cancel.',\n reorderMoved: 'Moved to position {pos} of {total}.',\n reorderDropped: 'Item dropped at position {pos} of {total}.',\n reorderCancelled: 'Reorder cancelled.',\n\n // Transfer list (panes)\n selectAll: 'Select all',\n clearSearch: 'Clear search',\n\n // Kanban ({column}/{pos}/{total} are replaced at runtime)\n kanbanMoved: 'Moved to {column}, position {pos} of {total}.',\n windowMinimize: 'Minimize',\n windowMaximize: 'Maximize',\n windowRestore: 'Restore',\n // MPagination ({from}/{to}/{total} and {page}/{pages} are replaced at runtime)\n paginationRange: '{from}–{to} of {total}',\n paginationPage: 'Page {page} of {pages}',\n previousPage: 'Previous page',\n nextPage: 'Next page',\n carousel: 'Carousel',\n carouselItem: '{index} of {count}',\n}\n\nexport const M3_LOCALE_KEY: InjectionKey<MaybeRef<Partial<M3Locale>>> = Symbol('m3-locale')\n\n/**\n * The locale given to `createM3UI()`, for components rendered outside the app that installed it:\n * `useToast()` and `useNotification()` mount their hosts with an app of their own, where the\n * plugin's `provide` doesn't reach. Inside the user's app the provided locale still wins.\n */\n// Wrapped in an object: a shallowRef holding a ref directly gets that ref unwrapped in its type.\nconst appLocale = shallowRef<{ locale: MaybeRef<Partial<M3Locale>> } | null>(null)\n\n/** @internal Called by `createM3UI()`; not exported from the package. */\nexport function __setAppLocale(locale: MaybeRef<Partial<M3Locale>> | null) {\n appLocale.value = locale ? { locale } : null\n}\n\nexport function useLocale(): M3Locale {\n const provided = inject(M3_LOCALE_KEY, null)\n const locale = reactive({ ...defaultLocale }) as M3Locale\n\n watchEffect(() => {\n Object.assign(locale, defaultLocale, toValue(provided ?? appLocale.value?.locale ?? {}))\n })\n\n return locale\n}\n"],"mappings":";;AA0KA,IAAa,IAA0B;CACrC,MAAM;CAEN,QAAQ;CACR,WAAW;CACX,OAAO;CACP,MAAM;CACN,QAAQ;CACR,SAAS;CACT,SAAS;CAET,UAAU;CACV,MAAM;CACN,OAAO;CACP,MAAM;CAEN,eAAe;CACf,aAAa;CACb,QAAQ;CACR,SAAS;CACT,WAAW;CACX,SAAS;CAET,QAAQ;CAER,UAAU;CACV,YAAY;CACZ,eAAe;CACf,QAAQ;CAER,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,WAAW;CACX,SAAS;CACT,eAAe;CACf,WAAW;CAEX,SAAS;CACT,UAAU;CACV,QAAQ;CACR,aAAa;CACb,gBAAgB;CAChB,aAAa;CACb,eAAe;CACf,gBAAgB;CAChB,sBAAsB;CACtB,uBAAuB;CACvB,qBAAqB;CACrB,sBAAsB;CACtB,qBAAqB;CACrB,mBAAmB;CACnB,yBAAyB;CACzB,qBAAqB;CACrB,sBAAsB;CACtB,sBAAsB;CACtB,oBAAoB;CAEpB,WAAW;CACX,UAAU;CACV,SAAS;CACT,cAAc;CACd,WAAW;CACX,UAAU;CACV,aAAa;CAEb,eAAe;CACf,cAAc;CACd,YAAY;CACZ,UAAU;CACV,WAAW;CAEX,aAAa;CACb,aAAa;CAEb,MAAM;CACN,QAAQ;CACR,WAAW;CACX,eAAe;CACf,WAAW;CACX,YAAY;CACZ,aAAa;CACb,YAAY;CACZ,MAAM;CACN,WAAW;CACX,aAAa;CACb,YAAY;CACZ,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,WAAW;CACX,UAAU;CACV,UAAU;CACV,UAAU;CACV,YAAY;CACZ,aAAa;CACb,eAAe;CACf,QAAQ;CAER,WAAW;CACX,aAAa;CACb,YAAY;CACZ,YAAY;CAEZ,cAAc;CACd,YAAY;CAGZ,oBAAoB;CACpB,mBAAmB;CACnB,kBAAkB;CAClB,iBAAiB;CACjB,oBAAoB;CACpB,mBAAmB;CACnB,iBAAiB;CACjB,gBAAgB;CAChB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,eAAe;CAGf,YAAY;CACZ,oBAAoB;CAGpB,eAAe;CACf,gBAAgB;CAChB,cAAc;CACd,gBAAgB;CAChB,kBAAkB;CAGlB,WAAW;CACX,aAAa;CAGb,aAAa;CACb,gBAAgB;CAChB,gBAAgB;CAChB,eAAe;CAEf,iBAAiB;CACjB,gBAAgB;CAChB,cAAc;CACd,UAAU;CACV,UAAU;CACV,cAAc;AAChB,GAEa,IAA2D,OAAO,WAAW,GAQpF,IAAY,EAA2D,IAAI;AAGjF,SAAgB,EAAe,GAA4C;CACzE,EAAU,QAAQ,IAAS,EAAE,UAAO,IAAI;AAC1C;AAEA,SAAgB,IAAsB;CACpC,IAAM,IAAW,EAAO,GAAe,IAAI,GACrC,IAAS,EAAS,EAAE,GAAG,EAAc,CAAC;CAM5C,OAJA,QAAkB;EAChB,OAAO,OAAO,GAAQ,GAAe,EAAQ,KAAY,EAAU,OAAO,UAAU,CAAC,CAAC,CAAC;CACzF,CAAC,GAEM;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m3ui-vue/m3ui-vue",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Material 3 component library for Vue 3 + Tailwind CSS v4",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -68,10 +68,11 @@
68
68
  "src"
69
69
  ],
70
70
  "scripts": {
71
- "build": "pnpm build:js && pnpm build:types && pnpm build:css",
71
+ "build": "pnpm build:js && pnpm build:types && pnpm build:css && pnpm build:api",
72
72
  "build:js": "vite build && cp dist/m3ui-vue.css dist/styles.css",
73
73
  "build:types": "vue-tsc -p tsconfig.build.json",
74
74
  "build:css": "cp -r src/styles dist/",
75
+ "build:api": "node scripts/generate-api.mjs",
75
76
  "test": "vitest run",
76
77
  "test:watch": "vitest",
77
78
  "prepublishOnly": "pnpm build"
@@ -230,6 +231,7 @@
230
231
  "vitest": "^5.0.0",
231
232
  "vue": "^3.5.42",
232
233
  "vue-chartjs": "^5.3.4",
234
+ "vue-component-meta": "3.3.11",
233
235
  "vue-tsc": "^3.3.11"
234
236
  },
235
237
  "publishConfig": {
@@ -0,0 +1,57 @@
1
+ import { describe, it, expect, vi, afterEach } from 'vitest'
2
+ import { mount, type VueWrapper } from '@vue/test-utils'
3
+ import MHotkeys from '../components/MHotkeys.vue'
4
+
5
+ let wrapper: VueWrapper | null = null
6
+ afterEach(() => { wrapper?.unmount(); wrapper = null })
7
+
8
+ function press(key: string, mods: Partial<KeyboardEventInit> = {}) {
9
+ document.dispatchEvent(new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true, ...mods }))
10
+ }
11
+
12
+ describe('MHotkeys', () => {
13
+ it('fires a mod binding with Ctrl (not on a Mac)', () => {
14
+ const handler = vi.fn()
15
+ wrapper = mount(MHotkeys, { props: { bindings: [{ keys: 'mod+z', label: 'Undo', handler }] } })
16
+ press('z', { ctrlKey: true })
17
+ expect(handler).toHaveBeenCalledTimes(1)
18
+ })
19
+
20
+ it('fires mod+shift combos and not plain mod ones for them', () => {
21
+ const undo = vi.fn()
22
+ const redo = vi.fn()
23
+ wrapper = mount(MHotkeys, {
24
+ props: { bindings: [{ keys: 'mod+z', label: 'Undo', handler: undo }, { keys: 'mod+shift+z', label: 'Redo', handler: redo }] },
25
+ })
26
+ press('Z', { ctrlKey: true, shiftKey: true })
27
+ expect(redo).toHaveBeenCalledTimes(1)
28
+ expect(undo).not.toHaveBeenCalled()
29
+ })
30
+
31
+ it('fires an explicit ctrl binding', () => {
32
+ const handler = vi.fn()
33
+ wrapper = mount(MHotkeys, { props: { bindings: [{ keys: 'ctrl+k', label: 'Search', handler }] } })
34
+ press('k', { ctrlKey: true })
35
+ expect(handler).toHaveBeenCalledTimes(1)
36
+ })
37
+
38
+ it('does not fire when an extra modifier is held', () => {
39
+ const handler = vi.fn()
40
+ wrapper = mount(MHotkeys, { props: { bindings: [{ keys: 'mod+z', label: 'Undo', handler }] } })
41
+ press('z', { ctrlKey: true, altKey: true })
42
+ press('z')
43
+ expect(handler).not.toHaveBeenCalled()
44
+ })
45
+
46
+ it('fires single keys, but not while typing', () => {
47
+ const handler = vi.fn()
48
+ wrapper = mount(MHotkeys, { props: { bindings: [{ keys: 'b', label: 'Brush', handler }] } })
49
+ press('b')
50
+ expect(handler).toHaveBeenCalledTimes(1)
51
+ const input = document.createElement('input')
52
+ document.body.appendChild(input)
53
+ input.dispatchEvent(new KeyboardEvent('keydown', { key: 'b', bubbles: true }))
54
+ expect(handler).toHaveBeenCalledTimes(1)
55
+ input.remove()
56
+ })
57
+ })
@@ -0,0 +1,57 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest'
2
+ import { createApp, defineComponent, h, nextTick, ref } from 'vue'
3
+
4
+ // useToast() and useNotification() mount their hosts in an app of their own, which doesn't see the
5
+ // locale createM3UI() provides to the user's app. The modules keep state (the host is mounted once),
6
+ // so each test imports fresh copies.
7
+ beforeEach(() => {
8
+ vi.resetModules()
9
+ document.body.innerHTML = ''
10
+ })
11
+
12
+ async function setup(locale: Parameters<typeof import('../plugin').createM3UI>[0]['locale']) {
13
+ const { createM3UI } = await import('../plugin')
14
+ const app = createApp(defineComponent({ render: () => h('div') }))
15
+ app.use(createM3UI({ locale }))
16
+ app.mount(document.createElement('div'))
17
+ }
18
+
19
+ describe('toast and notification hosts follow the app locale', () => {
20
+ it('toast close button uses the locale from createM3UI', async () => {
21
+ await setup({ close: 'Cerrar' })
22
+ const { useToast } = await import('../composables/useToast')
23
+ useToast().info('Hola')
24
+ await nextTick()
25
+ const close = document.querySelector('#m3-toast-host button[aria-label]')
26
+ expect(close?.getAttribute('aria-label')).toBe('Cerrar')
27
+ })
28
+
29
+ it('notification close button is labelled, in the locale from createM3UI', async () => {
30
+ await setup({ close: 'Fermer' })
31
+ const { useNotification } = await import('../composables/useNotification')
32
+ useNotification().info('Bonjour')
33
+ await nextTick()
34
+ const host = document.body.lastElementChild!
35
+ const close = [...host.querySelectorAll('button')].find((b) => b.querySelector('.material-symbols-outlined')?.textContent?.trim() === 'close')
36
+ expect(close?.getAttribute('aria-label')).toBe('Fermer')
37
+ })
38
+
39
+ it('follows a ref locale when it changes', async () => {
40
+ const locale = ref({ close: 'Cerrar' })
41
+ await setup(locale)
42
+ const { useToast } = await import('../composables/useToast')
43
+ useToast().info('Hola')
44
+ await nextTick()
45
+ locale.value = { close: 'Schließen' }
46
+ await nextTick()
47
+ expect(document.querySelector('#m3-toast-host button[aria-label]')?.getAttribute('aria-label')).toBe('Schließen')
48
+ })
49
+
50
+ it('stays English without a locale', async () => {
51
+ await setup(undefined)
52
+ const { useToast } = await import('../composables/useToast')
53
+ useToast().info('Hi')
54
+ await nextTick()
55
+ expect(document.querySelector('#m3-toast-host button[aria-label]')?.getAttribute('aria-label')).toBe('Close')
56
+ })
57
+ })
@@ -1,4 +1,10 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * Declarative absolute positioning without Tailwind classes. Supports manual offsets, placement shortcuts, and
4
+ * per-axis control. Pair it with `MRelative` as the positioning parent.
5
+ *
6
+ * @slot default Content.
7
+ */
2
8
  import { computed } from 'vue'
3
9
 
4
10
  export type Placement =
@@ -8,15 +14,27 @@ export type Placement =
8
14
 
9
15
  const props = withDefaults(
10
16
  defineProps<{
17
+ /** Preset corner/edge placement */
11
18
  placement?: Placement
19
+ /** Distance from edges when using placement (applies to both axes) */
12
20
  offset?: string | number
21
+ /** Horizontal offset — overrides offset for the X axis */
13
22
  offsetX?: string | number
23
+ /** Vertical offset — overrides offset for the Y axis */
14
24
  offsetY?: string | number
25
+ /**
26
+ * Top offset (number = px). Defaults to 8px when neither placement nor any of top/right/bottom/left is set
27
+ */
15
28
  top?: string | number
29
+ /** Right offset */
16
30
  right?: string | number
31
+ /** Bottom offset */
17
32
  bottom?: string | number
33
+ /** Left offset. Defaults to 8px when neither placement nor any of top/right/bottom/left is set */
18
34
  left?: string | number
35
+ /** Set all sides to 0 */
19
36
  inset?: boolean
37
+ /** Z-index value */
20
38
  zIndex?: number
21
39
  }>(),
22
40
  { inset: false, offset: 0 },
@@ -1,12 +1,24 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * An inline banner for contextual status messages — info, success, warning, or error.
4
+ *
5
+ * @slot default Alert body content
6
+ * @slot actions Optional row of action buttons rendered below the body
7
+ * @event close Emitted when the close button is clicked. The parent owns visibility — pair with v-if/v-else to
8
+ * actually hide the alert.
9
+ */
2
10
  import MIcon from './MIcon.vue'
3
11
  import { useLocale } from '../composables/useLocale'
4
12
 
5
13
  const props = withDefaults(
6
14
  defineProps<{
15
+ /** Alert variant and color */
7
16
  type?: 'info' | 'success' | 'warning' | 'error'
17
+ /** Bold title text */
8
18
  title?: string
19
+ /** Show close button */
9
20
  closeable?: boolean
21
+ /** Aria label for the close button (falls back to the locale string) */
10
22
  closeAriaLabel?: string
11
23
  }>(),
12
24
  {
@@ -1,8 +1,20 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * A simple, generic slot-based app bar with leading, default, and trailing areas — a lighter-weight alternative
4
+ * to MTopAppBar for when you don't need its variant/title-row layouts.
5
+ *
6
+ * @slot leading Leading area (e.g. back button, menu icon)
7
+ * @slot default Main content (title text)
8
+ * @slot trailing Trailing action buttons
9
+ */
2
10
  withDefaults(defineProps<{
11
+ /** Background color */
3
12
  color?: 'surface' | 'primary' | 'secondary' | 'tertiary'
13
+ /** Add shadow elevation */
4
14
  elevated?: boolean
15
+ /** Compact height (48px vs 64px) */
5
16
  dense?: boolean
17
+ /** Add a bottom border (border-outline-variant) */
6
18
  bordered?: boolean
7
19
  }>(), { color: 'surface' })
8
20
 
@@ -1,8 +1,19 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * Full app shell — drawer, header, content, footer, and fab slots.
4
+ *
5
+ * @slot drawer Side navigation (e.g. MNavigationDrawer). Use drawerRight prop to place it on the right.
6
+ * @slot header Top bar (e.g. MTopAppBar)
7
+ * @slot default Main scrollable content
8
+ * @slot footer Bottom bar or status area
9
+ * @slot fab Floating elements (e.g. MFab) rendered outside the scroll area
10
+ */
2
11
  import { computed } from 'vue'
3
12
 
4
13
  const props = defineProps<{
14
+ /** Container height (CSS value). Use "100%" to fit inside a parent instead of the viewport. */
5
15
  height?: string
16
+ /** Place the drawer slot on the right side of the layout */
6
17
  drawerRight?: boolean
7
18
  }>()
8
19
 
@@ -1,8 +1,14 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * Maintains a consistent aspect ratio for media or containers.
4
+ *
5
+ * @slot default Content, sized to fill the box.
6
+ */
2
7
  import { computed } from 'vue'
3
8
 
4
9
  const props = withDefaults(
5
10
  defineProps<{
11
+ /** Aspect ratio (e.g. "16/9", "4/3", 1) — passed straight through to the CSS aspect-ratio property */
6
12
  ratio?: string | number
7
13
  }>(),
8
14
  { ratio: '16/9' },
@@ -1,4 +1,10 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * Like MSelect but with a text input for filtering. Type to search, arrow keys to navigate, Enter to select.
4
+ *
5
+ * @event update:modelValue Emitted on selection — powers v-model
6
+ * @event debounced Emitted debounce ms after the user stops typing the search query (only when debounce > 0)
7
+ */
2
8
  import { computed, ref, useId, onMounted, onUnmounted, watch, nextTick } from 'vue'
3
9
  import MIcon from './MIcon.vue'
4
10
  import MIconButton from './MIconButton.vue'
@@ -13,21 +19,39 @@ defineOptions({ inheritAttrs: false })
13
19
 
14
20
  const props = withDefaults(
15
21
  defineProps<{
22
+ /** Selected value (v-model) */
16
23
  modelValue: unknown
24
+ /** The options to choose from; see `SelectOption`. */
17
25
  options: SelectOption[]
26
+ /** Floating label text */
18
27
  label?: string
28
+ /** Input placeholder */
19
29
  placeholder?: string
30
+ /** Field style */
20
31
  variant?: 'filled' | 'outlined'
32
+ /** Dropdown mode: docked (inline) or modal (dialog) */
21
33
  mode?: 'docked' | 'modal'
34
+ /** Disables the field */
22
35
  disabled?: boolean
36
+ /** Error state */
23
37
  error?: boolean
38
+ /** Error message shown when error is true */
24
39
  errorLabel?: string
40
+ /** Helper text below field */
25
41
  hint?: string
42
+ /** Marks as required — adds a red asterisk after the label */
26
43
  required?: boolean
44
+ /** Material Symbol icon name */
27
45
  leadingIcon?: string
46
+ /** Show a clear button */
28
47
  clearable?: boolean
48
+ /**
49
+ * Overrides the auto-detected background color used to cut the floating label out of the outlined border
50
+ */
29
51
  fieldBg?: string
52
+ /** Text when no options match */
30
53
  noResultsText?: string
54
+ /** Delay (ms) before filtering and firing @debounced. Selection is always instant */
31
55
  debounce?: number
32
56
  }>(),
33
57
  {
@@ -1,7 +1,18 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * A circular initials avatar. There's no image-source prop — it always renders extracted initials or a fallback
4
+ * string, never a photo.
5
+ */
2
6
  import { computed } from 'vue'
3
7
 
4
- const props = withDefaults(defineProps<{ name?: string; fallback?: string; size?: number }>(), { size: 40 })
8
+ const props = withDefaults(defineProps<{
9
+ /** Full name — initials are extracted automatically (first + last). Takes priority over fallback */
10
+ name?: string
11
+ /** Custom text shown when name is not provided (e.g. 'AJ'). Falls back to '?' if neither is set */
12
+ fallback?: string
13
+ /** Avatar size in px — also scales the font size proportionally (40%) */
14
+ size?: number
15
+ }>(), { size: 40 })
5
16
 
6
17
  const initials = computed(() => {
7
18
  if (props.name) {
@@ -1,4 +1,9 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * A small numeric or dot indicator overlaid on another element, such as an icon button or avatar.
4
+ *
5
+ * @slot default The element the badge sits on.
6
+ */
2
7
  import { computed } from 'vue'
3
8
 
4
9
  export type BadgePosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
@@ -6,11 +11,17 @@ export type BadgeOverlap = 'inside' | 'outside' | 'edge'
6
11
 
7
12
  const props = withDefaults(
8
13
  defineProps<{
14
+ /** Numeric badge value */
9
15
  count?: number
16
+ /** Show a small dot instead of a number */
10
17
  dot?: boolean
18
+ /** Badge color */
11
19
  color?: 'primary' | 'error' | 'secondary' | 'tertiary'
20
+ /** Max value before showing "N+" */
12
21
  max?: number
22
+ /** Corner where the badge is placed */
13
23
  position?: BadgePosition
24
+ /** How much the badge overlaps the content */
14
25
  overlap?: BadgeOverlap
15
26
  }>(),
16
27
  {
@@ -1,21 +1,40 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * A draggable Electron title bar for frameless windows (`frame: false`). Sets `-webkit-app-region: drag` on
4
+ * itself and carves out `no-drag` around the icon, controls, and slot content, so those stay clickable. It
5
+ * can't touch the real OS window — minimize/maximize/close just emit events for your app to forward over IPC.
6
+ *
7
+ * @slot icon Replaces the icon — e.g. an `<img>` logo instead of a Material Symbol
8
+ * @slot title Replaces the title text
9
+ * @slot default Extra content between the title and the trailing area (drag-adjacent, e.g. tabs)
10
+ * @slot trailing Action buttons right before minimize/maximize/close
11
+ * @event close Emitted when the close button is clicked
12
+ * @event minimize Emitted when the minimize button is clicked — forward to your Electron IPC call
13
+ * @event maximize Emitted when the maximize/restore button is clicked, or (with doubleClickMaximize) empty drag
14
+ * space is double-clicked
15
+ */
2
16
  import { computed } from 'vue'
3
17
  import MIcon from './MIcon.vue'
4
18
 
5
19
  const props = withDefaults(
6
20
  defineProps<{
21
+ /** Window title text */
7
22
  title?: string
8
23
  /** Material Symbol name, or an image src (URL, data URI, or a path with a file extension) — detected automatically. */
9
24
  icon?: string
25
+ /** Centered floats over the whole bar so it stays centered regardless of side content width */
10
26
  titleAlign?: 'start' | 'center'
11
27
  /** 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
28
  controls?: boolean
13
29
  /** Individually hide one control while keeping the others — e.g. a fixed-size window with no maximize button. */
14
30
  minimizable?: boolean
31
+ /** Show the maximize/restore button on its own */
15
32
  maximizable?: boolean
33
+ /** Show the close button on its own */
16
34
  closable?: boolean
17
35
  /** 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
36
  maximized?: boolean
37
+ /** 'macos' reserves space for the native traffic lights and hides the drawn controls by default */
19
38
  platform?: 'windows' | 'macos'
20
39
  /** Bar height in px. */
21
40
  height?: number
@@ -1,4 +1,9 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * Renders a barcode as inline SVG. Available from the `/barcode` entry point.
4
+ *
5
+ * @slot error Shown instead of the SVG when value is invalid for the given format (e.g. a non-numeric EAN13)
6
+ */
2
7
  import { ref, watchEffect } from 'vue'
3
8
  import JsBarcode from 'jsbarcode'
4
9
 
@@ -6,16 +11,25 @@ defineOptions({ inheritAttrs: false })
6
11
 
7
12
  const props = withDefaults(
8
13
  defineProps<{
14
+ /** Data to encode. Required — there is no default. */
9
15
  value: string
10
16
  /** Barcode symbology. Common values: 'CODE128', 'EAN13', 'EAN8', 'UPC', 'CODE39', 'ITF14', 'MSI', 'pharmacode', 'codabar'. */
11
17
  format?: string
18
+ /** Width of the narrowest bar, in px */
12
19
  width?: number
20
+ /** Bar height in px */
13
21
  height?: number
22
+ /** Show the encoded text below the bars */
14
23
  displayValue?: boolean
24
+ /** Bar color */
15
25
  color?: string
26
+ /** Background color */
16
27
  background?: string
28
+ /** Quiet zone around the barcode, in px */
17
29
  margin?: number
30
+ /** Font size for the displayed value */
18
31
  fontSize?: number
32
+ /** aria-label for the svg. Defaults to value */
19
33
  label?: string
20
34
  }>(),
21
35
  {
@@ -1,10 +1,22 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * A sheet that slides up from the bottom of the screen, capped at a 640px max width and rounded top corners.
4
+ * Supports drag-to-dismiss via the handle bar, or tapping the scrim.
5
+ *
6
+ * @slot default Sheet body content (scrollable)
7
+ * @slot actions Footer action buttons, shown in a bordered strip below the content
8
+ * @event update:modelValue Emitted when the sheet closes (scrim click, drag-to-dismiss, or the close button) —
9
+ * powers v-model
10
+ */
2
11
  import MIcon from './MIcon.vue'
3
12
  import { useSheetMotion } from '../composables/_useSheetMotion'
4
13
 
5
14
  withDefaults(defineProps<{
15
+ /** Open/closed state (v-model) */
6
16
  modelValue: boolean
17
+ /** Sheet header title */
7
18
  title?: string
19
+ /** Use max-h-[92vh] instead of the default max-h-[60vh] */
8
20
  fullHeight?: boolean
9
21
  }>(), { fullHeight: false })
10
22
 
@@ -1,13 +1,25 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * Generic surface box with padding, radius, elevation, and border — a building block for ad-hoc layout that
4
+ * doesn't warrant a dedicated component.
5
+ *
6
+ * @slot default Content.
7
+ */
2
8
  import { computed } from 'vue'
3
9
 
4
10
  const props = withDefaults(
5
11
  defineProps<{
12
+ /** Surface color variant */
6
13
  surface?: 'default' | 'container' | 'container-low' | 'container-high' | 'container-highest' | 'primary-container' | 'secondary-container' | 'tertiary-container' | 'inverse'
14
+ /** Padding size */
7
15
  padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'
16
+ /** Border radius */
8
17
  rounded?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'
18
+ /** Shadow elevation level */
9
19
  elevation?: 0 | 1 | 2 | 3
20
+ /** Show border */
10
21
  border?: boolean
22
+ /** HTML tag to render */
11
23
  tag?: string
12
24
  }>(),
13
25
  { padding: 'none', rounded: 'none', elevation: 0, border: false, tag: 'div' },