@m3ui-vue/m3ui-vue 0.1.1 → 0.1.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 (59) hide show
  1. package/README.md +1 -3
  2. package/dist/MIcon-CaEooCmZ.js +20 -0
  3. package/dist/MIcon-CaEooCmZ.js.map +1 -0
  4. package/dist/_plugin-vue_export-helper-B3ysoDQm.js +8 -0
  5. package/dist/chart.d.ts +1 -0
  6. package/dist/chart.js +141 -0
  7. package/dist/chart.js.map +1 -0
  8. package/dist/code-editor.d.ts +2 -0
  9. package/dist/code-editor.js +379 -0
  10. package/dist/code-editor.js.map +1 -0
  11. package/dist/components/MButton.vue.d.ts +1 -1
  12. package/dist/components/MCalendar.vue.d.ts +1 -1
  13. package/dist/components/MCodeEditor.vue.d.ts +3 -1
  14. package/dist/components/MDataTable.vue.d.ts +1 -1
  15. package/dist/components/MFab.vue.d.ts +0 -2
  16. package/dist/components/MIconButton.vue.d.ts +1 -1
  17. package/dist/components/MMultiSelect.vue.d.ts +1 -1
  18. package/dist/components/MProgressBar.vue.d.ts +1 -1
  19. package/dist/components/MRichTextEditor.vue.d.ts +1 -1
  20. package/dist/components/MScheduler.vue.d.ts +1 -1
  21. package/dist/components/MSelect.vue.d.ts +1 -1
  22. package/dist/components/MSkeleton.vue.d.ts +1 -1
  23. package/dist/components/MSpotlightSearch.vue.d.ts +1 -1
  24. package/dist/components/MStack.vue.d.ts +2 -2
  25. package/dist/components/MTerminal.vue.d.ts +2 -2
  26. package/dist/components/MTextField.vue.d.ts +1 -1
  27. package/dist/components/_MContextMenuPanel.vue.d.ts +1 -1
  28. package/dist/dist-Dsrzt6J5.js +1192 -0
  29. package/dist/dist-Dsrzt6J5.js.map +1 -0
  30. package/dist/index.d.ts +0 -6
  31. package/dist/m3ui-vue.css +2 -0
  32. package/dist/m3ui.js +2723 -3384
  33. package/dist/m3ui.js.map +1 -1
  34. package/dist/markdown.d.ts +1 -0
  35. package/dist/markdown.js +41 -0
  36. package/dist/markdown.js.map +1 -0
  37. package/dist/rich-text-editor.d.ts +1 -0
  38. package/dist/rich-text-editor.js +215 -0
  39. package/dist/rich-text-editor.js.map +1 -0
  40. package/dist/styles/theme.css +3 -0
  41. package/dist/styles.css +2 -0
  42. package/dist/terminal.d.ts +1 -0
  43. package/dist/terminal.js +97 -0
  44. package/dist/terminal.js.map +1 -0
  45. package/package.json +28 -2
  46. package/src/chart.ts +1 -0
  47. package/src/code-editor.ts +2 -0
  48. package/src/components/MAlert.vue +1 -1
  49. package/src/components/MCodeEditor.vue +99 -10
  50. package/src/components/MFab.vue +64 -48
  51. package/src/components/MMultiSelect.vue +3 -2
  52. package/src/components/MTooltip.vue +8 -1
  53. package/src/components/_MContextMenuPanel.vue +47 -41
  54. package/src/index.ts +6 -6
  55. package/src/markdown.ts +1 -0
  56. package/src/rich-text-editor.ts +1 -0
  57. package/src/styles/theme.css +3 -0
  58. package/src/terminal.ts +1 -0
  59. package/dist/m3ui.css +0 -2
package/README.md CHANGED
@@ -33,9 +33,7 @@ In your main stylesheet (e.g. `src/style.css`):
33
33
  @import 'tailwindcss';
34
34
  @import '@m3ui-vue/m3ui-vue/theme';
35
35
  @import '@m3ui-vue/m3ui-vue/palettes'; /* optional — includes 20 color palettes */
36
-
37
- /* Required: tells Tailwind to scan the library for class names */
38
- @source '../node_modules/@m3ui-vue/m3ui-vue';
36
+ @import '@m3ui-vue/m3ui-vue/styles'; /* component scoped styles (transitions, animations) */
39
37
  ```
40
38
 
41
39
  ### 4. Register the Plugin (optional)
@@ -0,0 +1,20 @@
1
+ import { createElementBlock as e, defineComponent as t, normalizeStyle as n, openBlock as r, toDisplayString as i } from "vue";
2
+ //#endregion
3
+ //#region src/components/MIcon.vue
4
+ var a = /* @__PURE__ */ t({
5
+ __name: "MIcon",
6
+ props: {
7
+ name: {},
8
+ size: { default: 24 }
9
+ },
10
+ setup(t) {
11
+ return (a, o) => (r(), e("span", {
12
+ class: "material-symbols-outlined leading-none",
13
+ style: n({ fontSize: `${t.size}px` })
14
+ }, i(t.name), 5));
15
+ }
16
+ });
17
+ //#endregion
18
+ export { a as t };
19
+
20
+ //# sourceMappingURL=MIcon-CaEooCmZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MIcon-CaEooCmZ.js","names":[],"sources":["../src/components/MIcon.vue","../src/components/MIcon.vue"],"sourcesContent":["<script setup lang=\"ts\">\nwithDefaults(defineProps<{ name: string; size?: number }>(), { size: 24 })\n</script>\n\n<template>\n <span class=\"material-symbols-outlined leading-none\" :style=\"{ fontSize: `${size}px` }\">{{\n name\n }}</span>\n</template>\n","<script setup lang=\"ts\">\nwithDefaults(defineProps<{ name: string; size?: number }>(), { size: 24 })\n</script>\n\n<template>\n <span class=\"material-symbols-outlined leading-none\" :style=\"{ fontSize: `${size}px` }\">{{\n name\n }}</span>\n</template>\n"],"mappings":";;;;;;;;;;yBAKE,EAES,QAAA;GAFH,OAAM;GAA0C,OAAK,EAAA,EAAA,UAAA,GAAiB,EAAA,KAAI,IAAA,CAAA;OAC9E,EAAA,IAAI,GAAA,CAAA"}
@@ -0,0 +1,8 @@
1
+ //#region \0plugin-vue:export-helper
2
+ var e = (e, t) => {
3
+ let n = e.__vccOpts || e;
4
+ for (let [e, r] of t) n[e] = r;
5
+ return n;
6
+ };
7
+ //#endregion
8
+ export { e as t };
@@ -0,0 +1 @@
1
+ export { default as MChart } from './components/MChart.vue';
package/dist/chart.js ADDED
@@ -0,0 +1,141 @@
1
+ import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, defineComponent as i, normalizeStyle as a, onBeforeUnmount as o, onMounted as s, openBlock as c, ref as l, resolveDynamicComponent as u, shallowRef as d, watch as f } from "vue";
2
+ //#endregion
3
+ //#region src/components/MChart.vue
4
+ var p = /* @__PURE__ */ i({
5
+ __name: "MChart",
6
+ props: {
7
+ type: {},
8
+ data: {},
9
+ options: {},
10
+ height: { default: "300px" }
11
+ },
12
+ setup(i) {
13
+ let p = i, m = l(!1), h = d(null), g = d({});
14
+ function _() {
15
+ let e = getComputedStyle(document.documentElement), t = (t) => e.getPropertyValue(t).trim();
16
+ return {
17
+ primary: t("--color-primary"),
18
+ onSurface: t("--color-on-surface"),
19
+ onSurfaceVariant: t("--color-on-surface-variant"),
20
+ outlineVariant: t("--color-outline-variant"),
21
+ surface: t("--color-surface"),
22
+ surfaceContainer: t("--color-surface-container")
23
+ };
24
+ }
25
+ let v = l(_()), y = null;
26
+ s(async () => {
27
+ v.value = _(), y = new MutationObserver(() => {
28
+ v.value = _();
29
+ }), y.observe(document.documentElement, {
30
+ attributes: !0,
31
+ attributeFilter: ["class"]
32
+ });
33
+ let [e, t] = await Promise.all([import("chart.js"), import("vue-chartjs")]);
34
+ e.Chart.register(e.CategoryScale, e.LinearScale, e.PointElement, e.LineElement, e.BarElement, e.ArcElement, e.RadialLinearScale, e.Filler, e.Tooltip, e.Legend, e.Title), g.value = {
35
+ line: t.Line,
36
+ bar: t.Bar,
37
+ pie: t.Pie,
38
+ doughnut: t.Doughnut,
39
+ radar: t.Radar
40
+ }, m.value = !0;
41
+ }), o(() => {
42
+ y?.disconnect();
43
+ }), f(() => p.type, () => {
44
+ m.value && (h.value = g.value[p.type] ?? null);
45
+ }, { immediate: !0 }), f(m, () => {
46
+ h.value = g.value[p.type] ?? null;
47
+ });
48
+ let b = e(() => {
49
+ let e = v.value, t = {
50
+ responsive: !0,
51
+ maintainAspectRatio: !1,
52
+ plugins: {
53
+ legend: { labels: {
54
+ color: e.onSurface,
55
+ font: {
56
+ family: "'Roboto', system-ui, sans-serif",
57
+ size: 12
58
+ },
59
+ usePointStyle: !0,
60
+ pointStyle: "circle",
61
+ padding: 16
62
+ } },
63
+ tooltip: {
64
+ backgroundColor: e.surfaceContainer,
65
+ titleColor: e.onSurface,
66
+ bodyColor: e.onSurfaceVariant,
67
+ borderColor: e.outlineVariant,
68
+ borderWidth: 1,
69
+ cornerRadius: 12,
70
+ padding: 12,
71
+ titleFont: {
72
+ family: "'Roboto', system-ui, sans-serif",
73
+ size: 13,
74
+ weight: "600"
75
+ },
76
+ bodyFont: {
77
+ family: "'Roboto', system-ui, sans-serif",
78
+ size: 12
79
+ },
80
+ displayColors: !0,
81
+ boxPadding: 4
82
+ }
83
+ }
84
+ };
85
+ return p.type !== "pie" && p.type !== "doughnut" && (t.scales = {
86
+ x: {
87
+ grid: {
88
+ color: e.outlineVariant + "40",
89
+ drawTicks: !1
90
+ },
91
+ ticks: {
92
+ color: e.onSurfaceVariant,
93
+ font: { size: 11 },
94
+ padding: 8
95
+ },
96
+ border: { color: e.outlineVariant }
97
+ },
98
+ y: {
99
+ grid: {
100
+ color: e.outlineVariant + "40",
101
+ drawTicks: !1
102
+ },
103
+ ticks: {
104
+ color: e.onSurfaceVariant,
105
+ font: { size: 11 },
106
+ padding: 8
107
+ },
108
+ border: { color: e.outlineVariant }
109
+ }
110
+ }), p.type === "radar" && (t.scales = { r: {
111
+ grid: { color: e.outlineVariant + "40" },
112
+ angleLines: { color: e.outlineVariant + "40" },
113
+ pointLabels: {
114
+ color: e.onSurfaceVariant,
115
+ font: { size: 11 }
116
+ },
117
+ ticks: {
118
+ color: e.onSurfaceVariant,
119
+ backdropColor: "transparent"
120
+ }
121
+ } }), x(t, p.options ?? {});
122
+ });
123
+ function x(e, t) {
124
+ let n = { ...e };
125
+ for (let r of Object.keys(t)) t[r] && typeof t[r] == "object" && !Array.isArray(t[r]) ? n[r] = x(e[r] ?? {}, t[r]) : n[r] = t[r];
126
+ return n;
127
+ }
128
+ return (e, o) => (c(), r("div", {
129
+ class: "rounded-lg border border-outline-variant bg-surface p-4",
130
+ style: a({ height: i.height })
131
+ }, [m.value && h.value ? (c(), t(u(h.value), {
132
+ key: 0,
133
+ data: i.data,
134
+ options: b.value
135
+ }, null, 8, ["data", "options"])) : n("", !0)], 4));
136
+ }
137
+ });
138
+ //#endregion
139
+ export { p as MChart };
140
+
141
+ //# sourceMappingURL=chart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart.js","names":[],"sources":["../src/components/MChart.vue","../src/components/MChart.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, watch, onMounted, onBeforeUnmount, shallowRef, type Component } from 'vue'\n\ntype ChartType = 'line' | 'bar' | 'pie' | 'doughnut' | 'radar'\n\nconst props = withDefaults(\n defineProps<{\n type: ChartType\n data: Record<string, any>\n options?: Record<string, any>\n height?: string\n }>(),\n { height: '300px' },\n)\n\nconst ready = ref(false)\nconst chartComponent = shallowRef<Component | null>(null)\nconst componentMap = shallowRef<Record<string, Component>>({})\n\nfunction getM3Colors() {\n const style = getComputedStyle(document.documentElement)\n const get = (v: string) => style.getPropertyValue(v).trim()\n return {\n primary: get('--color-primary'),\n onSurface: get('--color-on-surface'),\n onSurfaceVariant: get('--color-on-surface-variant'),\n outlineVariant: get('--color-outline-variant'),\n surface: get('--color-surface'),\n surfaceContainer: get('--color-surface-container'),\n }\n}\n\nconst m3Colors = ref(getM3Colors())\n\nlet themeObserver: MutationObserver | null = null\n\nonMounted(async () => {\n m3Colors.value = getM3Colors()\n\n themeObserver = new MutationObserver(() => { m3Colors.value = getM3Colors() })\n themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] })\n\n const [chartjs, vueChartjs] = await Promise.all([\n import('chart.js'),\n import('vue-chartjs'),\n ])\n\n chartjs.Chart.register(\n chartjs.CategoryScale,\n chartjs.LinearScale,\n chartjs.PointElement,\n chartjs.LineElement,\n chartjs.BarElement,\n chartjs.ArcElement,\n chartjs.RadialLinearScale,\n chartjs.Filler,\n chartjs.Tooltip,\n chartjs.Legend,\n chartjs.Title,\n )\n\n componentMap.value = {\n line: vueChartjs.Line,\n bar: vueChartjs.Bar,\n pie: vueChartjs.Pie,\n doughnut: vueChartjs.Doughnut,\n radar: vueChartjs.Radar,\n }\n\n ready.value = true\n})\n\nonBeforeUnmount(() => { themeObserver?.disconnect() })\n\nwatch(() => props.type, () => {\n if (ready.value) chartComponent.value = componentMap.value[props.type] ?? null\n}, { immediate: true })\n\nwatch(ready, () => {\n chartComponent.value = componentMap.value[props.type] ?? null\n})\n\nconst mergedOptions = computed<Record<string, any>>(() => {\n const c = m3Colors.value\n const base: Record<string, any> = {\n responsive: true,\n maintainAspectRatio: false,\n plugins: {\n legend: {\n labels: {\n color: c.onSurface,\n font: { family: \"'Roboto', system-ui, sans-serif\", size: 12 },\n usePointStyle: true,\n pointStyle: 'circle',\n padding: 16,\n },\n },\n tooltip: {\n backgroundColor: c.surfaceContainer,\n titleColor: c.onSurface,\n bodyColor: c.onSurfaceVariant,\n borderColor: c.outlineVariant,\n borderWidth: 1,\n cornerRadius: 12,\n padding: 12,\n titleFont: { family: \"'Roboto', system-ui, sans-serif\", size: 13, weight: '600' as const },\n bodyFont: { family: \"'Roboto', system-ui, sans-serif\", size: 12 },\n displayColors: true,\n boxPadding: 4,\n },\n },\n }\n\n if (props.type !== 'pie' && props.type !== 'doughnut') {\n base.scales = {\n x: {\n grid: { color: c.outlineVariant + '40', drawTicks: false },\n ticks: { color: c.onSurfaceVariant, font: { size: 11 }, padding: 8 },\n border: { color: c.outlineVariant },\n },\n y: {\n grid: { color: c.outlineVariant + '40', drawTicks: false },\n ticks: { color: c.onSurfaceVariant, font: { size: 11 }, padding: 8 },\n border: { color: c.outlineVariant },\n },\n }\n }\n\n if (props.type === 'radar') {\n base.scales = {\n r: {\n grid: { color: c.outlineVariant + '40' },\n angleLines: { color: c.outlineVariant + '40' },\n pointLabels: { color: c.onSurfaceVariant, font: { size: 11 } },\n ticks: { color: c.onSurfaceVariant, backdropColor: 'transparent' },\n },\n }\n }\n\n return deepMerge(base, props.options ?? {})\n})\n\nfunction deepMerge(target: any, source: any): any {\n const output = { ...target }\n for (const key of Object.keys(source)) {\n if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {\n output[key] = deepMerge(target[key] ?? {}, source[key])\n } else {\n output[key] = source[key]\n }\n }\n return output\n}\n</script>\n\n<template>\n <div class=\"rounded-lg border border-outline-variant bg-surface p-4\" :style=\"{ height }\">\n <component\n v-if=\"ready && chartComponent\"\n :is=\"chartComponent\"\n :data=\"data\"\n :options=\"mergedOptions\"\n />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, ref, watch, onMounted, onBeforeUnmount, shallowRef, type Component } from 'vue'\n\ntype ChartType = 'line' | 'bar' | 'pie' | 'doughnut' | 'radar'\n\nconst props = withDefaults(\n defineProps<{\n type: ChartType\n data: Record<string, any>\n options?: Record<string, any>\n height?: string\n }>(),\n { height: '300px' },\n)\n\nconst ready = ref(false)\nconst chartComponent = shallowRef<Component | null>(null)\nconst componentMap = shallowRef<Record<string, Component>>({})\n\nfunction getM3Colors() {\n const style = getComputedStyle(document.documentElement)\n const get = (v: string) => style.getPropertyValue(v).trim()\n return {\n primary: get('--color-primary'),\n onSurface: get('--color-on-surface'),\n onSurfaceVariant: get('--color-on-surface-variant'),\n outlineVariant: get('--color-outline-variant'),\n surface: get('--color-surface'),\n surfaceContainer: get('--color-surface-container'),\n }\n}\n\nconst m3Colors = ref(getM3Colors())\n\nlet themeObserver: MutationObserver | null = null\n\nonMounted(async () => {\n m3Colors.value = getM3Colors()\n\n themeObserver = new MutationObserver(() => { m3Colors.value = getM3Colors() })\n themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] })\n\n const [chartjs, vueChartjs] = await Promise.all([\n import('chart.js'),\n import('vue-chartjs'),\n ])\n\n chartjs.Chart.register(\n chartjs.CategoryScale,\n chartjs.LinearScale,\n chartjs.PointElement,\n chartjs.LineElement,\n chartjs.BarElement,\n chartjs.ArcElement,\n chartjs.RadialLinearScale,\n chartjs.Filler,\n chartjs.Tooltip,\n chartjs.Legend,\n chartjs.Title,\n )\n\n componentMap.value = {\n line: vueChartjs.Line,\n bar: vueChartjs.Bar,\n pie: vueChartjs.Pie,\n doughnut: vueChartjs.Doughnut,\n radar: vueChartjs.Radar,\n }\n\n ready.value = true\n})\n\nonBeforeUnmount(() => { themeObserver?.disconnect() })\n\nwatch(() => props.type, () => {\n if (ready.value) chartComponent.value = componentMap.value[props.type] ?? null\n}, { immediate: true })\n\nwatch(ready, () => {\n chartComponent.value = componentMap.value[props.type] ?? null\n})\n\nconst mergedOptions = computed<Record<string, any>>(() => {\n const c = m3Colors.value\n const base: Record<string, any> = {\n responsive: true,\n maintainAspectRatio: false,\n plugins: {\n legend: {\n labels: {\n color: c.onSurface,\n font: { family: \"'Roboto', system-ui, sans-serif\", size: 12 },\n usePointStyle: true,\n pointStyle: 'circle',\n padding: 16,\n },\n },\n tooltip: {\n backgroundColor: c.surfaceContainer,\n titleColor: c.onSurface,\n bodyColor: c.onSurfaceVariant,\n borderColor: c.outlineVariant,\n borderWidth: 1,\n cornerRadius: 12,\n padding: 12,\n titleFont: { family: \"'Roboto', system-ui, sans-serif\", size: 13, weight: '600' as const },\n bodyFont: { family: \"'Roboto', system-ui, sans-serif\", size: 12 },\n displayColors: true,\n boxPadding: 4,\n },\n },\n }\n\n if (props.type !== 'pie' && props.type !== 'doughnut') {\n base.scales = {\n x: {\n grid: { color: c.outlineVariant + '40', drawTicks: false },\n ticks: { color: c.onSurfaceVariant, font: { size: 11 }, padding: 8 },\n border: { color: c.outlineVariant },\n },\n y: {\n grid: { color: c.outlineVariant + '40', drawTicks: false },\n ticks: { color: c.onSurfaceVariant, font: { size: 11 }, padding: 8 },\n border: { color: c.outlineVariant },\n },\n }\n }\n\n if (props.type === 'radar') {\n base.scales = {\n r: {\n grid: { color: c.outlineVariant + '40' },\n angleLines: { color: c.outlineVariant + '40' },\n pointLabels: { color: c.onSurfaceVariant, font: { size: 11 } },\n ticks: { color: c.onSurfaceVariant, backdropColor: 'transparent' },\n },\n }\n }\n\n return deepMerge(base, props.options ?? {})\n})\n\nfunction deepMerge(target: any, source: any): any {\n const output = { ...target }\n for (const key of Object.keys(source)) {\n if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {\n output[key] = deepMerge(target[key] ?? {}, source[key])\n } else {\n output[key] = source[key]\n }\n }\n return output\n}\n</script>\n\n<template>\n <div class=\"rounded-lg border border-outline-variant bg-surface p-4\" :style=\"{ height }\">\n <component\n v-if=\"ready && chartComponent\"\n :is=\"chartComponent\"\n :data=\"data\"\n :options=\"mergedOptions\"\n />\n </div>\n</template>\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export { default as MCodeEditor } from './components/MCodeEditor.vue';
2
+ export { default as MJsonEditor } from './components/MJsonEditor.vue';
@@ -0,0 +1,379 @@
1
+ import { t as e } from "./MIcon-CaEooCmZ.js";
2
+ import { t } from "./_plugin-vue_export-helper-B3ysoDQm.js";
3
+ import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, normalizeClass as l, normalizeStyle as u, onBeforeUnmount as d, onMounted as f, openBlock as p, ref as m, renderSlot as h, toDisplayString as g, watch as _, withCtx as v } from "vue";
4
+ //#region src/components/MCodeEditor.vue?vue&type=script&setup=true&lang.ts
5
+ var y = { class: "overflow-hidden rounded-lg border border-outline-variant" }, b = { class: "flex items-center justify-between border-b border-outline-variant bg-surface-container px-4 py-2" }, x = { class: "text-label-medium text-on-surface-variant" }, S = { class: "flex items-center gap-2" }, C = ["title"], w = {
6
+ key: 0,
7
+ class: "text-primary"
8
+ }, T = /*#__PURE__*/ t(/* @__PURE__ */ c({
9
+ __name: "MCodeEditor",
10
+ props: {
11
+ modelValue: {},
12
+ language: { default: "javascript" },
13
+ readonly: {
14
+ type: Boolean,
15
+ default: !1
16
+ },
17
+ lineNumbers: {
18
+ type: Boolean,
19
+ default: !0
20
+ },
21
+ theme: { default: "light" },
22
+ minHeight: { default: "200px" },
23
+ maxHeight: { default: "600px" },
24
+ placeholder: {},
25
+ wrap: {
26
+ type: Boolean,
27
+ default: !0
28
+ }
29
+ },
30
+ emits: ["update:modelValue"],
31
+ setup(t, { emit: o }) {
32
+ let c = t, v = o, T = m(null), E = null, D = null, O = m(!1);
33
+ async function k() {
34
+ await navigator.clipboard.writeText(c.modelValue), O.value = !0, setTimeout(() => {
35
+ O.value = !1;
36
+ }, 1500);
37
+ }
38
+ let A = n(() => ({
39
+ javascript: "JavaScript",
40
+ typescript: "TypeScript",
41
+ json: "JSON",
42
+ html: "HTML",
43
+ css: "CSS",
44
+ python: "Python",
45
+ vue: "Vue",
46
+ plain: "Texto"
47
+ })[c.language]);
48
+ async function j() {
49
+ if (D) return D;
50
+ let [e, t, n, r, i, a, o, s, c, l, u, d] = await Promise.all([
51
+ import("@codemirror/view"),
52
+ import("@codemirror/state"),
53
+ import("@codemirror/commands"),
54
+ import("@codemirror/language"),
55
+ import("./dist-Dsrzt6J5.js"),
56
+ import("@codemirror/theme-one-dark"),
57
+ import("@codemirror/lang-javascript"),
58
+ import("@codemirror/lang-json"),
59
+ import("@codemirror/lang-html"),
60
+ import("@codemirror/lang-css"),
61
+ import("@codemirror/lang-python"),
62
+ import("@codemirror/lang-vue")
63
+ ]);
64
+ return D = {
65
+ viewMod: e,
66
+ stateMod: t,
67
+ commandsMod: n,
68
+ languageMod: r,
69
+ highlightMod: i,
70
+ oneDarkMod: a,
71
+ jsMod: o,
72
+ jsonMod: s,
73
+ htmlMod: c,
74
+ cssMod: l,
75
+ pyMod: u,
76
+ vueMod: d
77
+ }, D;
78
+ }
79
+ function M(e, t) {
80
+ return e.HighlightStyle.define([
81
+ {
82
+ tag: t.keyword,
83
+ color: "var(--color-primary)"
84
+ },
85
+ {
86
+ tag: t.controlKeyword,
87
+ color: "var(--color-primary)",
88
+ fontWeight: "500"
89
+ },
90
+ {
91
+ tag: t.operatorKeyword,
92
+ color: "var(--color-primary)"
93
+ },
94
+ {
95
+ tag: t.definitionKeyword,
96
+ color: "var(--color-primary)"
97
+ },
98
+ {
99
+ tag: t.moduleKeyword,
100
+ color: "var(--color-primary)"
101
+ },
102
+ {
103
+ tag: t.string,
104
+ color: "var(--color-tertiary)"
105
+ },
106
+ {
107
+ tag: t.regexp,
108
+ color: "var(--color-tertiary)"
109
+ },
110
+ {
111
+ tag: t.number,
112
+ color: "var(--color-error)"
113
+ },
114
+ {
115
+ tag: t.bool,
116
+ color: "var(--color-error)"
117
+ },
118
+ {
119
+ tag: t.function(t.variableName),
120
+ color: "var(--color-secondary)"
121
+ },
122
+ {
123
+ tag: t.function(t.definition(t.variableName)),
124
+ color: "var(--color-secondary)",
125
+ fontWeight: "500"
126
+ },
127
+ {
128
+ tag: t.typeName,
129
+ color: "var(--color-primary)",
130
+ fontStyle: "italic"
131
+ },
132
+ {
133
+ tag: t.className,
134
+ color: "var(--color-primary)",
135
+ fontStyle: "italic"
136
+ },
137
+ {
138
+ tag: t.namespace,
139
+ color: "var(--color-on-surface-variant)"
140
+ },
141
+ {
142
+ tag: t.propertyName,
143
+ color: "var(--color-on-surface)"
144
+ },
145
+ {
146
+ tag: t.definition(t.propertyName),
147
+ color: "var(--color-on-surface)"
148
+ },
149
+ {
150
+ tag: t.variableName,
151
+ color: "var(--color-on-surface)"
152
+ },
153
+ {
154
+ tag: t.definition(t.variableName),
155
+ color: "var(--color-on-surface)"
156
+ },
157
+ {
158
+ tag: t.comment,
159
+ color: "var(--color-outline)",
160
+ fontStyle: "italic"
161
+ },
162
+ {
163
+ tag: t.lineComment,
164
+ color: "var(--color-outline)",
165
+ fontStyle: "italic"
166
+ },
167
+ {
168
+ tag: t.blockComment,
169
+ color: "var(--color-outline)",
170
+ fontStyle: "italic"
171
+ },
172
+ {
173
+ tag: t.meta,
174
+ color: "var(--color-on-surface-variant)"
175
+ },
176
+ {
177
+ tag: t.tagName,
178
+ color: "var(--color-primary)"
179
+ },
180
+ {
181
+ tag: t.attributeName,
182
+ color: "var(--color-tertiary)"
183
+ },
184
+ {
185
+ tag: t.attributeValue,
186
+ color: "var(--color-secondary)"
187
+ },
188
+ {
189
+ tag: t.atom,
190
+ color: "var(--color-error)"
191
+ },
192
+ {
193
+ tag: t.null,
194
+ color: "var(--color-error)"
195
+ },
196
+ {
197
+ tag: t.punctuation,
198
+ color: "var(--color-on-surface-variant)"
199
+ },
200
+ {
201
+ tag: t.bracket,
202
+ color: "var(--color-on-surface-variant)"
203
+ },
204
+ {
205
+ tag: t.operator,
206
+ color: "var(--color-on-surface-variant)"
207
+ },
208
+ {
209
+ tag: t.separator,
210
+ color: "var(--color-on-surface-variant)"
211
+ }
212
+ ]);
213
+ }
214
+ function N(e) {
215
+ switch (c.language) {
216
+ case "javascript": return e.jsMod.javascript();
217
+ case "typescript": return e.jsMod.javascript({ typescript: !0 });
218
+ case "json": return e.jsonMod.json();
219
+ case "html": return e.htmlMod.html();
220
+ case "css": return e.cssMod.css();
221
+ case "python": return e.pyMod.python();
222
+ case "vue": return e.vueMod.vue();
223
+ default: return [];
224
+ }
225
+ }
226
+ function P(e) {
227
+ let { viewMod: t, stateMod: n, commandsMod: r, languageMod: i, highlightMod: a, oneDarkMod: o } = e, s = M(i, a.tags), l = [
228
+ t.keymap.of([
229
+ ...r.defaultKeymap,
230
+ ...r.historyKeymap,
231
+ r.indentWithTab
232
+ ]),
233
+ r.history(),
234
+ i.bracketMatching(),
235
+ i.indentOnInput(),
236
+ i.foldGutter(),
237
+ t.highlightActiveLine(),
238
+ t.highlightActiveLineGutter(),
239
+ i.syntaxHighlighting(s),
240
+ i.syntaxHighlighting(i.defaultHighlightStyle, { fallback: !0 }),
241
+ N(e),
242
+ t.EditorView.updateListener.of((e) => {
243
+ e.docChanged && v("update:modelValue", e.state.doc.toString());
244
+ }),
245
+ n.EditorState.readOnly.of(c.readonly)
246
+ ];
247
+ return c.wrap && l.push(t.EditorView.lineWrapping), c.lineNumbers && l.push(t.lineNumbers()), c.theme === "dark" && l.push(o.oneDark), l;
248
+ }
249
+ async function F() {
250
+ if (!T.value) return;
251
+ let e = await j(), { viewMod: t, stateMod: n } = e;
252
+ E?.destroy(), E = new t.EditorView({
253
+ state: n.EditorState.create({
254
+ doc: c.modelValue,
255
+ extensions: P(e)
256
+ }),
257
+ parent: T.value
258
+ });
259
+ }
260
+ return f(F), _(() => c.modelValue, (e) => {
261
+ E && E.state.doc.toString() !== e && E.dispatch({ changes: {
262
+ from: 0,
263
+ to: E.state.doc.length,
264
+ insert: e
265
+ } });
266
+ }), _([
267
+ () => c.language,
268
+ () => c.theme,
269
+ () => c.readonly,
270
+ () => c.lineNumbers,
271
+ () => c.wrap
272
+ ], F), d(() => E?.destroy()), (n, o) => (p(), i("div", y, [a("div", b, [a("span", x, g(A.value), 1), a("div", S, [h(n.$slots, "actions", {}, void 0, !0), a("button", {
273
+ type: "button",
274
+ class: "flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 text-label-medium text-on-surface-variant transition-colors hover:bg-on-surface/8",
275
+ title: O.value ? "Copied!" : "Copy code",
276
+ onClick: k
277
+ }, [s(e, {
278
+ name: O.value ? "check" : "content_copy",
279
+ size: 16,
280
+ class: l(O.value ? "text-primary" : "")
281
+ }, null, 8, ["name", "class"]), O.value ? (p(), i("span", w, "Copied")) : r("", !0)], 8, C)])]), a("div", {
282
+ ref_key: "containerRef",
283
+ ref: T,
284
+ class: "code-editor-container overflow-auto bg-surface text-on-surface",
285
+ style: u({
286
+ minHeight: t.minHeight,
287
+ maxHeight: t.maxHeight
288
+ })
289
+ }, null, 4)]));
290
+ }
291
+ }), [["__scopeId", "data-v-b0a66a4b"]]), E = { class: "flex flex-col gap-0" }, D = { class: "flex items-center gap-2" }, O = {
292
+ key: 0,
293
+ class: "px-3 py-1.5 text-body-small text-error"
294
+ }, k = /* @__PURE__ */ c({
295
+ __name: "MJsonEditor",
296
+ props: {
297
+ modelValue: {},
298
+ readonly: {
299
+ type: Boolean,
300
+ default: !1
301
+ },
302
+ minHeight: { default: "200px" },
303
+ maxHeight: { default: "600px" }
304
+ },
305
+ emits: ["update:modelValue"],
306
+ setup(t, { emit: c }) {
307
+ let u = t, d = c, f = m(JSON.stringify(u.modelValue, null, 2)), h = m(null), y = n(() => !h.value);
308
+ _(() => u.modelValue, (e) => {
309
+ let t = JSON.stringify(e, null, 2);
310
+ t !== f.value && (f.value = t, h.value = null);
311
+ });
312
+ function b(e) {
313
+ f.value = e;
314
+ try {
315
+ let t = JSON.parse(e);
316
+ h.value = null, d("update:modelValue", t);
317
+ } catch (e) {
318
+ h.value = e.message;
319
+ }
320
+ }
321
+ function x() {
322
+ try {
323
+ let e = JSON.parse(f.value);
324
+ f.value = JSON.stringify(e, null, 2), h.value = null, d("update:modelValue", e);
325
+ } catch {}
326
+ }
327
+ function S() {
328
+ try {
329
+ let e = JSON.parse(f.value);
330
+ f.value = JSON.stringify(e), h.value = null, d("update:modelValue", e);
331
+ } catch {}
332
+ }
333
+ return (n, c) => (p(), i("div", E, [s(T, {
334
+ "model-value": f.value,
335
+ language: "json",
336
+ readonly: t.readonly,
337
+ "min-height": t.minHeight,
338
+ "max-height": t.maxHeight,
339
+ "onUpdate:modelValue": b
340
+ }, {
341
+ actions: v(() => [a("div", D, [
342
+ a("span", { class: l(["flex items-center gap-1 rounded-full px-2.5 py-0.5 text-label-small", y.value ? "bg-success-container text-on-success-container" : "bg-error-container text-on-error-container"]) }, [s(e, {
343
+ name: y.value ? "check_circle" : "error",
344
+ size: 14
345
+ }, null, 8, ["name"]), o(" " + g(y.value ? "Válido" : "Inválido"), 1)], 2),
346
+ t.readonly ? r("", !0) : (p(), i("button", {
347
+ key: 0,
348
+ type: "button",
349
+ title: "Formatear",
350
+ class: "flex h-7 cursor-pointer items-center gap-1 rounded px-2 text-label-medium text-on-surface-variant transition-colors hover:bg-on-surface/8",
351
+ onClick: x
352
+ }, [s(e, {
353
+ name: "format_indent_increase",
354
+ size: 16
355
+ }), c[0] ||= o(" Formatear ", -1)])),
356
+ t.readonly ? r("", !0) : (p(), i("button", {
357
+ key: 1,
358
+ type: "button",
359
+ title: "Minificar",
360
+ class: "flex h-7 cursor-pointer items-center gap-1 rounded px-2 text-label-medium text-on-surface-variant transition-colors hover:bg-on-surface/8",
361
+ onClick: S
362
+ }, [s(e, {
363
+ name: "compress",
364
+ size: 16
365
+ }), c[1] ||= o(" Minificar ", -1)]))
366
+ ])]),
367
+ _: 1
368
+ }, 8, [
369
+ "model-value",
370
+ "readonly",
371
+ "min-height",
372
+ "max-height"
373
+ ]), h.value ? (p(), i("p", O, g(h.value), 1)) : r("", !0)]));
374
+ }
375
+ });
376
+ //#endregion
377
+ export { T as MCodeEditor, k as MJsonEditor };
378
+
379
+ //# sourceMappingURL=code-editor.js.map