@m3ui-vue/m3ui-vue 1.6.2 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/API.md +1224 -28
  2. package/dist/{MColorPickerModal-NtkihoK6.js → MColorPickerModal-H8nuX0Wu.js} +3 -4
  3. package/dist/{MColorPickerModal-NtkihoK6.js.map → MColorPickerModal-H8nuX0Wu.js.map} +1 -1
  4. package/dist/MDialog-B42Mhn8W.js +331 -0
  5. package/dist/MDialog-B42Mhn8W.js.map +1 -0
  6. package/dist/{MListItem-D2cNUyzP.js → MListItem-DiOAxaN7.js} +431 -325
  7. package/dist/MListItem-DiOAxaN7.js.map +1 -0
  8. package/dist/{MLoadingIndicator-DWUj0BAB.js → MLoadingIndicator-CuTZYFFj.js} +2 -2
  9. package/dist/{MLoadingIndicator-DWUj0BAB.js.map → MLoadingIndicator-CuTZYFFj.js.map} +1 -1
  10. package/dist/{MSeekBar-C4cn9RIF.js → MSeekBar-BCDQTx2t.js} +2 -2
  11. package/dist/{MSeekBar-C4cn9RIF.js.map → MSeekBar-BCDQTx2t.js.map} +1 -1
  12. package/dist/MSegmentedButton-BXzRsg1S.js +105 -0
  13. package/dist/MSegmentedButton-BXzRsg1S.js.map +1 -0
  14. package/dist/MSignaturePad-BTqGaPXA.js +313 -0
  15. package/dist/MSignaturePad-BTqGaPXA.js.map +1 -0
  16. package/dist/MSlider-D_O8J9YH.js +739 -0
  17. package/dist/MSlider-D_O8J9YH.js.map +1 -0
  18. package/dist/{MSpinner-DZkXZJpc.js → MSpinner-UCdtSOHP.js} +2 -2
  19. package/dist/{MSpinner-DZkXZJpc.js.map → MSpinner-UCdtSOHP.js.map} +1 -1
  20. package/dist/{MTextField-CNH-byir.js → MTextField-CYk9yFvi.js} +162 -115
  21. package/dist/MTextField-CYk9yFvi.js.map +1 -0
  22. package/dist/_useFieldValidation-B0B44M_t.js +191 -0
  23. package/dist/_useFieldValidation-B0B44M_t.js.map +1 -0
  24. package/dist/api.json +1 -1
  25. package/dist/code-editor.js +184 -103
  26. package/dist/code-editor.js.map +1 -1
  27. package/dist/components/MAddressField.vue.d.ts +18 -3
  28. package/dist/components/MAppBarWithSearch.vue.d.ts +1 -1
  29. package/dist/components/MAudioRecorder.vue.d.ts +2 -2
  30. package/dist/components/MAutocomplete.vue.d.ts +22 -3
  31. package/dist/components/MCheckbox.vue.d.ts +23 -1
  32. package/dist/components/MCodeEditor.vue.d.ts +23 -1
  33. package/dist/components/MColorPicker.vue.d.ts +24 -3
  34. package/dist/components/MConfirmDialog.vue.d.ts +2 -2
  35. package/dist/components/MCountrySelect.vue.d.ts +13 -2
  36. package/dist/components/MCreditCardInput.vue.d.ts +33 -0
  37. package/dist/components/MCronField.vue.d.ts +23 -1
  38. package/dist/components/MDataTable.vue.d.ts +1 -1
  39. package/dist/components/MDatePicker.vue.d.ts +24 -3
  40. package/dist/components/MDateRangePicker.vue.d.ts +24 -3
  41. package/dist/components/MFileUpload.vue.d.ts +23 -2
  42. package/dist/components/MForm.vue.d.ts +61 -0
  43. package/dist/components/MFormBuilder.vue.d.ts +22 -0
  44. package/dist/components/MFormRenderer.vue.d.ts +151 -0
  45. package/dist/components/MJsonEditor.vue.d.ts +23 -1
  46. package/dist/components/MMapRoute.vue.d.ts +176 -0
  47. package/dist/components/MMaskField.vue.d.ts +20 -2
  48. package/dist/components/MMentionField.vue.d.ts +13 -2
  49. package/dist/components/MMultiAutocomplete.vue.d.ts +22 -3
  50. package/dist/components/MMultiSelect.vue.d.ts +22 -3
  51. package/dist/components/MNavigationRail.vue.d.ts +1 -1
  52. package/dist/components/MNotificationCenter.vue.d.ts +2 -2
  53. package/dist/components/MNumberField.vue.d.ts +20 -2
  54. package/dist/components/MPdfSigner.vue.d.ts +499 -0
  55. package/dist/components/MPdfViewer.vue.d.ts +12 -0
  56. package/dist/components/MPhoneInput.vue.d.ts +19 -4
  57. package/dist/components/MPinInput.vue.d.ts +24 -3
  58. package/dist/components/MPosKeypad.vue.d.ts +3 -3
  59. package/dist/components/MRadioGroup.vue.d.ts +23 -1
  60. package/dist/components/MRating.vue.d.ts +23 -1
  61. package/dist/components/MRichTextEditor.vue.d.ts +23 -1
  62. package/dist/components/MSearchBar.vue.d.ts +1 -1
  63. package/dist/components/MSegmentedButton.vue.d.ts +23 -2
  64. package/dist/components/MSelect.vue.d.ts +22 -3
  65. package/dist/components/MSignaturePad.vue.d.ts +19 -0
  66. package/dist/components/MSlider.vue.d.ts +23 -1
  67. package/dist/components/MSpreadsheet.vue.d.ts +137 -0
  68. package/dist/components/MStack.vue.d.ts +1 -1
  69. package/dist/components/MSwitch.vue.d.ts +23 -1
  70. package/dist/components/MTable.vue.d.ts +1 -1
  71. package/dist/components/MTagInput.vue.d.ts +20 -2
  72. package/dist/components/MText.vue.d.ts +1 -1
  73. package/dist/components/MTextField.vue.d.ts +26 -3
  74. package/dist/components/MTimePicker.vue.d.ts +24 -3
  75. package/dist/components/MTimezoneSelect.vue.d.ts +13 -2
  76. package/dist/components/MTour.vue.d.ts +2 -2
  77. package/dist/components/MTrackingTimeline.vue.d.ts +75 -0
  78. package/dist/components/MWindow.vue.d.ts +2 -2
  79. package/dist/composables/_routeGeometry.d.ts +26 -0
  80. package/dist/composables/_useFieldValidation.d.ts +91 -0
  81. package/dist/composables/mapRouting.d.ts +35 -0
  82. package/dist/composables/pdfSign.d.ts +52 -0
  83. package/dist/composables/spreadsheetFormula.d.ts +55 -0
  84. package/dist/composables/useLocale.d.ts +177 -0
  85. package/dist/composables/validation.d.ts +82 -0
  86. package/dist/draw.js +2 -2
  87. package/dist/flow.js +1 -1
  88. package/dist/gantt.js +2 -2
  89. package/dist/index.d.ts +12 -0
  90. package/dist/locales/index.js +693 -7
  91. package/dist/locales/index.js.map +1 -1
  92. package/dist/m3ui-vue.css +1 -1
  93. package/dist/m3ui.js +15507 -12417
  94. package/dist/m3ui.js.map +1 -1
  95. package/dist/map.d.ts +4 -0
  96. package/dist/map.js +1207 -745
  97. package/dist/map.js.map +1 -1
  98. package/dist/media.js +4 -4
  99. package/dist/pdf.d.ts +3 -0
  100. package/dist/pdf.js +1228 -687
  101. package/dist/pdf.js.map +1 -1
  102. package/dist/rich-text-editor.js +188 -146
  103. package/dist/rich-text-editor.js.map +1 -1
  104. package/dist/styles.css +1 -1
  105. package/dist/{useLocale-DaVSTdm0.js → useLocale-DL96OFgr.js} +99 -1
  106. package/dist/useLocale-DL96OFgr.js.map +1 -0
  107. package/package.json +5 -1
  108. package/src/__tests__/MForm.test.ts +325 -0
  109. package/src/__tests__/MFormRenderer.test.ts +157 -0
  110. package/src/__tests__/MMapRoute.test.ts +418 -0
  111. package/src/__tests__/MPdfSigner.test.ts +175 -0
  112. package/src/__tests__/MPhoneInput.test.ts +5 -2
  113. package/src/__tests__/MRichTextEditor.test.ts +2 -1
  114. package/src/__tests__/MSpreadsheet.test.ts +223 -0
  115. package/src/__tests__/MTrackingTimeline.test.ts +66 -0
  116. package/src/__tests__/_fakeMaplibre.ts +4 -1
  117. package/src/__tests__/_osrmRoutes.ts +10 -0
  118. package/src/__tests__/attrsFallthrough.test.ts +11 -0
  119. package/src/__tests__/fieldsValidation.test.ts +229 -0
  120. package/src/__tests__/spreadsheetFormula.test.ts +77 -0
  121. package/src/__tests__/ssr.test.ts +4 -0
  122. package/src/__tests__/validation.test.ts +77 -0
  123. package/src/components/MAddressField.vue +45 -8
  124. package/src/components/MAutocomplete.vue +69 -23
  125. package/src/components/MCheckbox.vue +80 -17
  126. package/src/components/MCodeEditor.vue +59 -2
  127. package/src/components/MColorPicker.vue +65 -16
  128. package/src/components/MCountrySelect.vue +17 -3
  129. package/src/components/MCreditCardInput.vue +76 -7
  130. package/src/components/MCronField.vue +60 -10
  131. package/src/components/MDatePicker.vue +65 -16
  132. package/src/components/MDateRangePicker.vue +66 -16
  133. package/src/components/MFileUpload.vue +71 -8
  134. package/src/components/MForm.vue +208 -0
  135. package/src/components/MFormBuilder.vue +417 -0
  136. package/src/components/MFormRenderer.vue +324 -0
  137. package/src/components/MJsonEditor.vue +57 -3
  138. package/src/components/MMapRoute.vue +523 -0
  139. package/src/components/MMaskField.vue +55 -13
  140. package/src/components/MMentionField.vue +17 -2
  141. package/src/components/MMultiAutocomplete.vue +70 -23
  142. package/src/components/MMultiSelect.vue +70 -23
  143. package/src/components/MNumberField.vue +58 -16
  144. package/src/components/MPdfSigner.vue +433 -0
  145. package/src/components/MPdfViewer.vue +12 -0
  146. package/src/components/MPhoneInput.vue +60 -18
  147. package/src/components/MPinInput.vue +58 -10
  148. package/src/components/MRadioGroup.vue +65 -4
  149. package/src/components/MRating.vue +62 -6
  150. package/src/components/MRichTextEditor.vue +64 -4
  151. package/src/components/MSegmentedButton.vue +59 -2
  152. package/src/components/MSelect.vue +72 -26
  153. package/src/components/MSignaturePad.vue +71 -6
  154. package/src/components/MSlider.vue +61 -10
  155. package/src/components/MSpreadsheet.vue +992 -0
  156. package/src/components/MSwitch.vue +63 -8
  157. package/src/components/MTagInput.vue +67 -25
  158. package/src/components/MTextField.vue +68 -14
  159. package/src/components/MTimePicker.vue +65 -16
  160. package/src/components/MTimezoneSelect.vue +17 -3
  161. package/src/components/MTrackingTimeline.vue +257 -0
  162. package/src/composables/_routeGeometry.ts +140 -0
  163. package/src/composables/_useFieldValidation.ts +287 -0
  164. package/src/composables/mapRouting.ts +55 -0
  165. package/src/composables/pdfSign.ts +141 -0
  166. package/src/composables/spreadsheetFormula.ts +459 -0
  167. package/src/composables/useLocale.ts +277 -0
  168. package/src/composables/validation.ts +178 -0
  169. package/src/index.ts +12 -0
  170. package/src/locales/de.ts +98 -0
  171. package/src/locales/es.ts +105 -7
  172. package/src/locales/fr.ts +98 -0
  173. package/src/locales/ja.ts +98 -0
  174. package/src/locales/ko.ts +98 -0
  175. package/src/locales/pt.ts +98 -0
  176. package/src/locales/zh.ts +98 -0
  177. package/src/map.ts +4 -0
  178. package/src/pdf.ts +3 -0
  179. package/dist/MButton-OQ4wIERQ.js +0 -171
  180. package/dist/MButton-OQ4wIERQ.js.map +0 -1
  181. package/dist/MDialog-DYMnaBlt.js +0 -167
  182. package/dist/MDialog-DYMnaBlt.js.map +0 -1
  183. package/dist/MListItem-D2cNUyzP.js.map +0 -1
  184. package/dist/MProgressBar-BWly1UKN.js +0 -179
  185. package/dist/MProgressBar-BWly1UKN.js.map +0 -1
  186. package/dist/MSegmentedButton-BEB4gXLA.js +0 -64
  187. package/dist/MSegmentedButton-BEB4gXLA.js.map +0 -1
  188. package/dist/MSlider-BIkA6DiE.js +0 -690
  189. package/dist/MSlider-BIkA6DiE.js.map +0 -1
  190. package/dist/MTextField-CNH-byir.js.map +0 -1
  191. package/dist/useLocale-DaVSTdm0.js.map +0 -1
@@ -1,12 +1,14 @@
1
- import { t as e } from "./MIcon-DpajuUTJ.js";
2
- import { t } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
3
- import { i as n } from "./useLocale-DaVSTdm0.js";
4
- import { computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, normalizeClass as u, normalizeStyle as d, onBeforeUnmount as f, onMounted as p, openBlock as m, ref as h, renderSlot as g, toDisplayString as _, watch as v, withCtx as y } from "vue";
1
+ import { n as e, r as t, t as n } from "./_useFieldValidation-B0B44M_t.js";
2
+ import { t as r } from "./MIcon-DpajuUTJ.js";
3
+ import { t as i } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
4
+ import { i as a } from "./useLocale-DL96OFgr.js";
5
+ import { Fragment as o, computed as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, inject as m, mergeProps as h, normalizeClass as g, normalizeStyle as _, onBeforeUnmount as v, onMounted as y, openBlock as b, provide as x, ref as S, renderSlot as C, toDisplayString as w, unref as T, watch as E, withCtx as D } from "vue";
5
6
  // src/components/MCodeEditor.vue?vue&type=script&setup=true&lang.ts
6
- var b = { class: "flex flex-col overflow-hidden rounded-lg border border-outline-variant" }, x = { class: "flex items-center justify-between border-b border-outline-variant bg-surface-container px-4 py-2" }, S = { class: "text-label-medium text-on-surface-variant" }, C = { class: "flex items-center gap-2" }, w = ["title"], T = {
7
+ var O = ["aria-invalid", "aria-describedby"], k = { class: "flex items-center justify-between border-b border-outline-variant bg-surface-container px-4 py-2" }, A = { class: "text-label-medium text-on-surface-variant" }, j = { class: "flex items-center gap-2" }, M = ["title"], N = {
7
8
  key: 0,
8
9
  class: "text-primary"
9
- }, E = /*#__PURE__*/ t(/* @__PURE__ */ l({
10
+ }, P = ["id"], F = /*#__PURE__*/ i(/* @__PURE__ */ p({
11
+ inheritAttrs: !1,
10
12
  __name: "MCodeEditor",
11
13
  props: {
12
14
  modelValue: {},
@@ -23,20 +25,44 @@ var b = { class: "flex flex-col overflow-hidden rounded-lg border border-outline
23
25
  minHeight: { default: "200px" },
24
26
  maxHeight: { default: "600px" },
25
27
  placeholder: {},
28
+ error: { type: [Boolean, String] },
29
+ errorLabel: {},
30
+ required: { type: Boolean },
31
+ rules: {},
32
+ validateOn: {},
33
+ validateDebounce: {},
34
+ name: {},
26
35
  wrap: {
27
36
  type: Boolean,
28
37
  default: !0
29
38
  }
30
39
  },
31
- emits: ["update:modelValue"],
32
- setup(t, { emit: n }) {
33
- let s = t, l = n, y = h(null), E = null, D = null, O = h(!1);
34
- async function k() {
35
- await navigator.clipboard.writeText(s.modelValue), O.value = !0, setTimeout(() => {
36
- O.value = !1;
40
+ emits: ["update:modelValue", "blur"],
41
+ setup(n, { expose: i, emit: a }) {
42
+ let d = n, p = a, m = S(null), x = null, D = S(null), F = e({
43
+ value: () => d.modelValue,
44
+ rules: () => d.rules,
45
+ required: () => d.required,
46
+ error: () => d.error,
47
+ errorLabel: () => d.errorLabel,
48
+ name: () => d.name,
49
+ validateOn: () => d.validateOn,
50
+ validateDebounce: () => d.validateDebounce,
51
+ disabled: () => d.readonly,
52
+ focus: () => {
53
+ x?.focus();
54
+ },
55
+ el: () => D.value,
56
+ setValue: (e) => p("update:modelValue", e)
57
+ }), { hasError: I, message: L, messageId: R } = F, z = t(() => D.value, () => {
58
+ F.onBlur(), p("blur");
59
+ }), B = null, V = S(!1);
60
+ async function H() {
61
+ await navigator.clipboard.writeText(d.modelValue), V.value = !0, setTimeout(() => {
62
+ V.value = !1;
37
63
  }, 1500);
38
64
  }
39
- let A = r(() => ({
65
+ let U = s(() => ({
40
66
  javascript: "JavaScript",
41
67
  typescript: "TypeScript",
42
68
  json: "JSON",
@@ -49,9 +75,9 @@ var b = { class: "flex flex-col overflow-hidden rounded-lg border border-outline
49
75
  rust: "Rust",
50
76
  asm: "Assembly",
51
77
  plain: "Texto"
52
- })[s.language]);
53
- async function j() {
54
- if (D) return D;
78
+ })[d.language]);
79
+ async function W() {
80
+ if (B) return B;
55
81
  let [e, t, n, r, i, a, o, s, c, l, u, d, f, p, m] = await Promise.all([
56
82
  import("@codemirror/view"),
57
83
  import("@codemirror/state"),
@@ -69,7 +95,7 @@ var b = { class: "flex flex-col overflow-hidden rounded-lg border border-outline
69
95
  import("@codemirror/lang-rust"),
70
96
  import("@codemirror/legacy-modes/mode/gas")
71
97
  ]);
72
- return D = {
98
+ return B = {
73
99
  viewMod: e,
74
100
  stateMod: t,
75
101
  commandsMod: n,
@@ -85,9 +111,9 @@ var b = { class: "flex flex-col overflow-hidden rounded-lg border border-outline
85
111
  cppMod: f,
86
112
  rustMod: p,
87
113
  asmMod: m
88
- }, D;
114
+ }, B;
89
115
  }
90
- function M(e, t) {
116
+ function G(e, t) {
91
117
  return e.HighlightStyle.define([
92
118
  {
93
119
  tag: t.keyword,
@@ -222,8 +248,8 @@ var b = { class: "flex flex-col overflow-hidden rounded-lg border border-outline
222
248
  }
223
249
  ]);
224
250
  }
225
- function N(e) {
226
- switch (s.language) {
251
+ function K(e) {
252
+ switch (d.language) {
227
253
  case "javascript": return e.jsMod.javascript();
228
254
  case "typescript": return e.jsMod.javascript({ typescript: !0 });
229
255
  case "json": return e.jsonMod.json();
@@ -238,8 +264,8 @@ var b = { class: "flex flex-col overflow-hidden rounded-lg border border-outline
238
264
  default: return [];
239
265
  }
240
266
  }
241
- function P(e) {
242
- let { viewMod: t, stateMod: n, commandsMod: r, languageMod: i, highlightMod: a, oneDarkMod: o } = e, c = M(i, a.tags), u = [
267
+ function q(e) {
268
+ let { viewMod: t, stateMod: n, commandsMod: r, languageMod: i, highlightMod: a, oneDarkMod: o } = e, s = G(i, a.tags), c = [
243
269
  t.keymap.of([
244
270
  ...r.defaultKeymap,
245
271
  ...r.historyKeymap,
@@ -252,63 +278,79 @@ var b = { class: "flex flex-col overflow-hidden rounded-lg border border-outline
252
278
  t.drawSelection(),
253
279
  t.highlightActiveLine(),
254
280
  t.highlightActiveLineGutter(),
255
- i.syntaxHighlighting(c),
281
+ i.syntaxHighlighting(s),
256
282
  i.syntaxHighlighting(i.defaultHighlightStyle, { fallback: !0 }),
257
- N(e),
283
+ K(e),
258
284
  t.EditorView.updateListener.of((e) => {
259
- e.docChanged && l("update:modelValue", e.state.doc.toString());
285
+ e.docChanged && p("update:modelValue", e.state.doc.toString());
260
286
  }),
261
- n.EditorState.readOnly.of(s.readonly)
287
+ n.EditorState.readOnly.of(d.readonly)
262
288
  ];
263
- return s.wrap && u.push(t.EditorView.lineWrapping), s.lineNumbers && u.push(t.lineNumbers()), s.theme === "dark" && u.push(o.oneDark), s.placeholder && u.push(t.placeholder(s.placeholder)), u;
289
+ return d.wrap && c.push(t.EditorView.lineWrapping), d.lineNumbers && c.push(t.lineNumbers()), d.theme === "dark" && c.push(o.oneDark), d.placeholder && c.push(t.placeholder(d.placeholder)), c;
264
290
  }
265
- async function F() {
266
- if (!y.value) return;
267
- let e = await j(), { viewMod: t, stateMod: n } = e;
268
- E?.destroy(), E = new t.EditorView({
291
+ async function J() {
292
+ if (!m.value) return;
293
+ let e = await W(), { viewMod: t, stateMod: n } = e;
294
+ x?.destroy(), x = new t.EditorView({
269
295
  state: n.EditorState.create({
270
- doc: s.modelValue,
271
- extensions: P(e)
296
+ doc: d.modelValue,
297
+ extensions: q(e)
272
298
  }),
273
- parent: y.value
299
+ parent: m.value
274
300
  });
275
301
  }
276
- return p(F), v(() => s.modelValue, (e) => {
277
- E && E.state.doc.toString() !== e && E.dispatch({ changes: {
302
+ return y(J), E(() => d.modelValue, (e) => {
303
+ x && x.state.doc.toString() !== e && x.dispatch({ changes: {
278
304
  from: 0,
279
- to: E.state.doc.length,
305
+ to: x.state.doc.length,
280
306
  insert: e
281
307
  } });
282
- }), v([
283
- () => s.language,
284
- () => s.theme,
285
- () => s.readonly,
286
- () => s.lineNumbers,
287
- () => s.wrap,
288
- () => s.placeholder
289
- ], F), f(() => E?.destroy()), (n, r) => (m(), a("div", b, [o("div", x, [o("span", S, _(A.value), 1), o("div", C, [g(n.$slots, "actions", {}, void 0, !0), o("button", {
308
+ }), E([
309
+ () => d.language,
310
+ () => d.theme,
311
+ () => d.readonly,
312
+ () => d.lineNumbers,
313
+ () => d.wrap,
314
+ () => d.placeholder
315
+ ], J), v(() => x?.destroy()), i({
316
+ validate: F.validate,
317
+ resetValidation: F.resetValidation
318
+ }), (e, t) => (b(), l(o, null, [u("div", h({
319
+ ref_key: "rootEl",
320
+ ref: D
321
+ }, e.$attrs, {
322
+ class: ["flex flex-col overflow-hidden rounded-lg border", T(I) ? "border-error" : "border-outline-variant"],
323
+ "aria-invalid": T(I) || void 0,
324
+ "aria-describedby": T(L) ? T(R) : void 0,
325
+ onFocusout: t[0] ||= (...e) => T(z) && T(z)(...e)
326
+ }), [u("div", k, [u("span", A, w(U.value), 1), u("div", j, [C(e.$slots, "actions", {}, void 0, !0), u("button", {
290
327
  type: "button",
291
328
  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",
292
- title: O.value ? "Copied!" : "Copy code",
293
- onClick: k
294
- }, [c(e, {
295
- name: O.value ? "check" : "content_copy",
329
+ title: V.value ? "Copied!" : "Copy code",
330
+ onClick: H
331
+ }, [f(r, {
332
+ name: V.value ? "check" : "content_copy",
296
333
  size: 16,
297
- class: u(O.value ? "text-primary" : "")
298
- }, null, 8, ["name", "class"]), O.value ? (m(), a("span", T, "Copied")) : i("", !0)], 8, w)])]), o("div", {
334
+ class: g(V.value ? "text-primary" : "")
335
+ }, null, 8, ["name", "class"]), V.value ? (b(), l("span", N, "Copied")) : c("", !0)], 8, M)])]), u("div", {
299
336
  ref_key: "containerRef",
300
- ref: y,
337
+ ref: m,
301
338
  class: "code-editor-container overflow-auto bg-surface text-on-surface",
302
- style: d({
303
- minHeight: t.minHeight,
304
- maxHeight: t.maxHeight
339
+ style: _({
340
+ minHeight: n.minHeight,
341
+ maxHeight: n.maxHeight
305
342
  })
306
- }, null, 4)]));
343
+ }, null, 4)], 16, O), T(L) ? (b(), l("p", {
344
+ key: 0,
345
+ id: T(R),
346
+ role: "alert",
347
+ class: "mt-1 px-4 text-body-small text-error"
348
+ }, w(T(L)), 9, P)) : c("", !0)], 64));
307
349
  }
308
- }), [["__scopeId", "data-v-f0196990"]]), D = { class: "flex flex-col gap-0" }, O = { class: "flex items-center gap-2" }, k = ["title"], A = ["title"], j = {
350
+ }), [["__scopeId", "data-v-99aeb6f7"]]), I = { class: "flex items-center gap-2" }, L = ["title"], R = ["title"], z = {
309
351
  key: 0,
310
352
  class: "px-3 py-1.5 text-body-small text-error"
311
- }, M = /* @__PURE__ */ l({
353
+ }, B = ["id"], V = /* @__PURE__ */ p({
312
354
  __name: "MJsonEditor",
313
355
  props: {
314
356
  modelValue: {},
@@ -316,92 +358,131 @@ var b = { class: "flex flex-col overflow-hidden rounded-lg border border-outline
316
358
  type: Boolean,
317
359
  default: !1
318
360
  },
361
+ error: { type: [Boolean, String] },
362
+ errorLabel: {},
363
+ required: { type: Boolean },
364
+ rules: {},
365
+ validateOn: {},
366
+ validateDebounce: {},
367
+ name: {},
319
368
  minHeight: { default: "200px" },
320
369
  maxHeight: { default: "600px" },
321
370
  labels: {}
322
371
  },
323
- emits: ["update:modelValue"],
324
- setup(t, { emit: l }) {
325
- let d = n(), f = t, p = r(() => ({
326
- valid: d.jsonValid,
327
- invalid: d.jsonInvalid,
328
- format: d.jsonFormat,
329
- minify: d.jsonMinify,
330
- ...f.labels
331
- })), g = l, b = h(JSON.stringify(f.modelValue, null, 2)), x = h(null), S = r(() => !x.value);
332
- v(() => f.modelValue, (e) => {
372
+ emits: ["update:modelValue", "blur"],
373
+ setup(i, { expose: o, emit: p }) {
374
+ let h = a(), _ = !!m(n, null), v = i, y = s(() => ({
375
+ valid: h.jsonValid,
376
+ invalid: h.jsonInvalid,
377
+ format: h.jsonFormat,
378
+ minify: h.jsonMinify,
379
+ ...v.labels
380
+ })), C = p, O = S(JSON.stringify(v.modelValue, null, 2)), k = S(null), A = s(() => !k.value), j = () => !k.value || y.value.invalid, M = S(null), N = e({
381
+ value: () => v.modelValue,
382
+ rules: () => [...v.rules ? Array.isArray(v.rules) ? v.rules : [v.rules] : [], j],
383
+ required: () => v.required && (_ || !!v.rules),
384
+ error: () => v.error,
385
+ errorLabel: () => v.errorLabel,
386
+ name: () => v.name,
387
+ validateOn: () => v.validateOn,
388
+ validateDebounce: () => v.validateDebounce,
389
+ disabled: () => v.readonly,
390
+ focus: () => {
391
+ M.value?.querySelector(".cm-content")?.focus();
392
+ },
393
+ el: () => M.value,
394
+ setValue: (e) => C("update:modelValue", e)
395
+ }), { hasError: P, message: V, messageId: H } = N, U = t(() => M.value, () => {
396
+ N.onBlur(), C("blur");
397
+ });
398
+ x(n, null), E(() => v.modelValue, (e) => {
333
399
  let t;
334
400
  try {
335
- t = JSON.parse(b.value);
401
+ t = JSON.parse(O.value);
336
402
  } catch {
337
403
  t = void 0;
338
404
  }
339
- JSON.stringify(t) !== JSON.stringify(e) && (b.value = JSON.stringify(e, null, 2), x.value = null);
405
+ JSON.stringify(t) !== JSON.stringify(e) && (O.value = JSON.stringify(e, null, 2), k.value = null);
340
406
  });
341
- function C(e) {
342
- b.value = e;
407
+ function W(e) {
408
+ O.value = e;
343
409
  try {
344
410
  let t = JSON.parse(e);
345
- x.value = null, g("update:modelValue", t);
411
+ k.value = null, C("update:modelValue", t);
346
412
  } catch (e) {
347
- x.value = e.message;
413
+ k.value = e.message;
348
414
  }
349
415
  }
350
- function w() {
416
+ function G() {
351
417
  try {
352
- let e = JSON.parse(b.value);
353
- b.value = JSON.stringify(e, null, 2), x.value = null, g("update:modelValue", e);
418
+ let e = JSON.parse(O.value);
419
+ O.value = JSON.stringify(e, null, 2), k.value = null, C("update:modelValue", e);
354
420
  } catch {}
355
421
  }
356
- function T() {
422
+ function K() {
357
423
  try {
358
- let e = JSON.parse(b.value);
359
- b.value = JSON.stringify(e), x.value = null, g("update:modelValue", e);
424
+ let e = JSON.parse(O.value);
425
+ O.value = JSON.stringify(e), k.value = null, C("update:modelValue", e);
360
426
  } catch {}
361
427
  }
362
- return (n, r) => (m(), a("div", D, [c(E, {
363
- "model-value": b.value,
428
+ return o({
429
+ validate: N.validate,
430
+ resetValidation: N.resetValidation
431
+ }), (e, t) => (b(), l("div", {
432
+ ref_key: "rootEl",
433
+ ref: M,
434
+ class: "flex flex-col gap-0",
435
+ onFocusout: t[0] ||= (...e) => T(U) && T(U)(...e)
436
+ }, [f(F, {
437
+ "model-value": O.value,
364
438
  language: "json",
365
- readonly: t.readonly,
366
- "min-height": t.minHeight,
367
- "max-height": t.maxHeight,
368
- "onUpdate:modelValue": C
439
+ error: T(P) && !k.value,
440
+ readonly: i.readonly,
441
+ "min-height": i.minHeight,
442
+ "max-height": i.maxHeight,
443
+ "onUpdate:modelValue": W
369
444
  }, {
370
- actions: y(() => [o("div", O, [
371
- o("span", { class: u(["flex items-center gap-1 rounded-full px-2.5 py-0.5 text-label-small", S.value ? "bg-success-container text-on-success-container" : "bg-error-container text-on-error-container"]) }, [c(e, {
372
- name: S.value ? "check_circle" : "error",
445
+ actions: D(() => [u("div", I, [
446
+ u("span", { class: g(["flex items-center gap-1 rounded-full px-2.5 py-0.5 text-label-small", A.value ? "bg-success-container text-on-success-container" : "bg-error-container text-on-error-container"]) }, [f(r, {
447
+ name: A.value ? "check_circle" : "error",
373
448
  size: 14
374
- }, null, 8, ["name"]), s(" " + _(S.value ? p.value.valid : p.value.invalid), 1)], 2),
375
- t.readonly ? i("", !0) : (m(), a("button", {
449
+ }, null, 8, ["name"]), d(" " + w(A.value ? y.value.valid : y.value.invalid), 1)], 2),
450
+ i.readonly ? c("", !0) : (b(), l("button", {
376
451
  key: 0,
377
452
  type: "button",
378
- title: p.value.format,
453
+ title: y.value.format,
379
454
  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",
380
- onClick: w
381
- }, [c(e, {
455
+ onClick: G
456
+ }, [f(r, {
382
457
  name: "format_indent_increase",
383
458
  size: 16
384
- }), s(" " + _(p.value.format), 1)], 8, k)),
385
- t.readonly ? i("", !0) : (m(), a("button", {
459
+ }), d(" " + w(y.value.format), 1)], 8, L)),
460
+ i.readonly ? c("", !0) : (b(), l("button", {
386
461
  key: 1,
387
462
  type: "button",
388
- title: p.value.minify,
463
+ title: y.value.minify,
389
464
  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",
390
- onClick: T
391
- }, [c(e, {
465
+ onClick: K
466
+ }, [f(r, {
392
467
  name: "compress",
393
468
  size: 16
394
- }), s(" " + _(p.value.minify), 1)], 8, A))
469
+ }), d(" " + w(y.value.minify), 1)], 8, R))
395
470
  ])]),
396
471
  _: 1
397
472
  }, 8, [
398
473
  "model-value",
474
+ "error",
399
475
  "readonly",
400
476
  "min-height",
401
477
  "max-height"
402
- ]), x.value ? (m(), a("p", j, _(x.value), 1)) : i("", !0)]));
478
+ ]), k.value ? (b(), l("p", z, w(k.value), 1)) : T(V) ? (b(), l("p", {
479
+ key: 1,
480
+ id: T(H),
481
+ role: "alert",
482
+ class: "px-3 py-1.5 text-body-small text-error"
483
+ }, w(T(V)), 9, B)) : c("", !0)], 544));
403
484
  }
404
485
  });
405
- export { E as MCodeEditor, M as MJsonEditor };
486
+ export { F as MCodeEditor, V as MJsonEditor };
406
487
 
407
488
  //# sourceMappingURL=code-editor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-editor.js","names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_renderSlot","_createVNode","MIcon","_normalizeClass","_normalizeStyle","_openBlock","_createElementBlock","_createVNode","MCodeEditor","_withCtx","_createElementVNode","_normalizeClass","MIcon","_createTextVNode","_toDisplayString","MIcon_default","useLocale","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4$1","_hoisted_5$1","_hoisted_6","MCodeEditor_default","defineComponent","__emit","props","__props","emit","containerRef","ref","view","cmModules","copied","copyCode","langLabel","computed","loadModules","viewMod","stateMod","commandsMod","languageMod","highlightMod","oneDarkMod","jsMod","jsonMod","htmlMod","cssMod","pyMod","vueMod","cppMod","rustMod","asmMod","buildM3HighlightStyle","tags","getLangExtension","mods","buildExtensions","m3Style","exts","update","createEditor","onMounted","watch","val","onBeforeUnmount","openBlock","createElementBlock","createElementVNode","toDisplayString","renderSlot","_ctx","createVNode","normalizeClass","createCommentVNode","normalizeStyle","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","MJsonEditor_default","locale","l","rawText","parseError","isValid","current","onTextUpdate","text","parsed","formatJson","minifyJson","withCtx","createTextVNode"],"sources":["../src/components/MCodeEditor.vue","../src/components/MJsonEditor.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * A syntax-highlighted code editor built on CodeMirror 6, with a header bar, line numbers, and a copy button.\n *\n * @slot actions Extra controls rendered in the header bar, before the built-in copy button\n * @event update:modelValue Emitted on every document change — powers v-model\n */\nimport { ref, watch, onMounted, onBeforeUnmount, computed } from 'vue'\nimport MIcon from './MIcon.vue'\n\ntype Language = 'javascript' | 'typescript' | 'json' | 'html' | 'css' | 'python' | 'vue' | 'c' | 'cpp' | 'rust' | 'asm' | 'plain'\n\nconst props = withDefaults(\n defineProps<{\n /** Editor content (v-model) */\n modelValue: string\n /** Syntax language */\n language?: Language\n /** Read-only mode */\n readonly?: boolean\n /** Show line numbers */\n lineNumbers?: boolean\n /** Color theme */\n theme?: 'light' | 'dark'\n /** Minimum editor height */\n minHeight?: string\n /** Maximum editor height */\n maxHeight?: string\n /** Placeholder text shown via CodeMirror when the editor is empty */\n placeholder?: string\n /** Word wrap */\n wrap?: boolean\n }>(),\n {\n language: 'javascript',\n readonly: false,\n lineNumbers: true,\n theme: 'light',\n minHeight: '200px',\n maxHeight: '600px',\n wrap: true,\n },\n)\n\nconst emit = defineEmits<{ 'update:modelValue': [string] }>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet view: any = null\nlet cmModules: any = null\nconst copied = ref(false)\n\nasync function copyCode() {\n await navigator.clipboard.writeText(props.modelValue)\n copied.value = true\n setTimeout(() => { copied.value = false }, 1500)\n}\n\nconst langLabel = computed(() => {\n const labels: Record<Language, string> = {\n javascript: 'JavaScript',\n typescript: 'TypeScript',\n json: 'JSON',\n html: 'HTML',\n css: 'CSS',\n python: 'Python',\n vue: 'Vue',\n c: 'C',\n cpp: 'C++',\n rust: 'Rust',\n asm: 'Assembly',\n plain: 'Texto',\n }\n return labels[props.language]\n})\n\nasync function loadModules() {\n if (cmModules) return cmModules\n\n const [viewMod, stateMod, commandsMod, languageMod, highlightMod, oneDarkMod, jsMod, jsonMod, htmlMod, cssMod, pyMod, vueMod, cppMod, rustMod, asmMod] = await Promise.all([\n import('@codemirror/view'),\n import('@codemirror/state'),\n import('@codemirror/commands'),\n import('@codemirror/language'),\n import('@lezer/highlight'),\n import('@codemirror/theme-one-dark'),\n import('@codemirror/lang-javascript'),\n import('@codemirror/lang-json'),\n import('@codemirror/lang-html'),\n import('@codemirror/lang-css'),\n import('@codemirror/lang-python'),\n import('@codemirror/lang-vue'),\n import('@codemirror/lang-cpp'),\n import('@codemirror/lang-rust'),\n import('@codemirror/legacy-modes/mode/gas'),\n ])\n\n cmModules = { viewMod, stateMod, commandsMod, languageMod, highlightMod, oneDarkMod, jsMod, jsonMod, htmlMod, cssMod, pyMod, vueMod, cppMod, rustMod, asmMod }\n return cmModules\n}\n\nfunction buildM3HighlightStyle(languageMod: any, tags: any) {\n return languageMod.HighlightStyle.define([\n { tag: tags.keyword, color: 'var(--color-primary)' },\n { tag: tags.controlKeyword, color: 'var(--color-primary)', fontWeight: '500' },\n { tag: tags.operatorKeyword, color: 'var(--color-primary)' },\n { tag: tags.definitionKeyword, color: 'var(--color-primary)' },\n { tag: tags.moduleKeyword, color: 'var(--color-primary)' },\n\n { tag: tags.string, color: 'var(--color-tertiary)' },\n { tag: tags.regexp, color: 'var(--color-tertiary)' },\n\n { tag: tags.number, color: 'var(--color-error)' },\n { tag: tags.bool, color: 'var(--color-error)' },\n\n { tag: tags.function(tags.variableName), color: 'var(--color-secondary)' },\n { tag: tags.function(tags.definition(tags.variableName)), color: 'var(--color-secondary)', fontWeight: '500' },\n\n { tag: tags.typeName, color: 'var(--color-primary)', fontStyle: 'italic' },\n { tag: tags.className, color: 'var(--color-primary)', fontStyle: 'italic' },\n { tag: tags.namespace, color: 'var(--color-on-surface-variant)' },\n\n { tag: tags.propertyName, color: 'var(--color-on-surface)' },\n { tag: tags.definition(tags.propertyName), color: 'var(--color-on-surface)' },\n\n { tag: tags.variableName, color: 'var(--color-on-surface)' },\n { tag: tags.definition(tags.variableName), color: 'var(--color-on-surface)' },\n\n { tag: tags.comment, color: 'var(--color-outline)', fontStyle: 'italic' },\n { tag: tags.lineComment, color: 'var(--color-outline)', fontStyle: 'italic' },\n { tag: tags.blockComment, color: 'var(--color-outline)', fontStyle: 'italic' },\n\n { tag: tags.meta, color: 'var(--color-on-surface-variant)' },\n { tag: tags.tagName, color: 'var(--color-primary)' },\n { tag: tags.attributeName, color: 'var(--color-tertiary)' },\n { tag: tags.attributeValue, color: 'var(--color-secondary)' },\n\n { tag: tags.atom, color: 'var(--color-error)' },\n { tag: tags.null, color: 'var(--color-error)' },\n\n { tag: tags.punctuation, color: 'var(--color-on-surface-variant)' },\n { tag: tags.bracket, color: 'var(--color-on-surface-variant)' },\n { tag: tags.operator, color: 'var(--color-on-surface-variant)' },\n { tag: tags.separator, color: 'var(--color-on-surface-variant)' },\n ])\n}\n\nfunction getLangExtension(mods: any) {\n switch (props.language) {\n case 'javascript': return mods.jsMod.javascript()\n case 'typescript': return mods.jsMod.javascript({ typescript: true })\n case 'json': return mods.jsonMod.json()\n case 'html': return mods.htmlMod.html()\n case 'css': return mods.cssMod.css()\n case 'python': return mods.pyMod.python()\n case 'vue': return mods.vueMod.vue()\n case 'c': case 'cpp': return mods.cppMod.cpp()\n case 'rust': return mods.rustMod.rust()\n case 'asm': return mods.languageMod.StreamLanguage.define(mods.asmMod.gas)\n default: return []\n }\n}\n\nfunction buildExtensions(mods: any) {\n const { viewMod, stateMod, commandsMod, languageMod, highlightMod, oneDarkMod } = mods\n\n const m3Style = buildM3HighlightStyle(languageMod, highlightMod.tags)\n\n const exts = [\n viewMod.keymap.of([...commandsMod.defaultKeymap, ...commandsMod.historyKeymap, commandsMod.indentWithTab]),\n commandsMod.history(),\n languageMod.bracketMatching(),\n languageMod.indentOnInput(),\n languageMod.foldGutter(),\n viewMod.drawSelection(),\n viewMod.highlightActiveLine(),\n viewMod.highlightActiveLineGutter(),\n languageMod.syntaxHighlighting(m3Style),\n languageMod.syntaxHighlighting(languageMod.defaultHighlightStyle, { fallback: true }),\n getLangExtension(mods),\n viewMod.EditorView.updateListener.of((update: any) => {\n if (update.docChanged) emit('update:modelValue', update.state.doc.toString())\n }),\n stateMod.EditorState.readOnly.of(props.readonly),\n ]\n\n if (props.wrap) exts.push(viewMod.EditorView.lineWrapping)\n if (props.lineNumbers) exts.push(viewMod.lineNumbers())\n if (props.theme === 'dark') exts.push(oneDarkMod.oneDark)\n if (props.placeholder) exts.push(viewMod.placeholder(props.placeholder))\n\n return exts\n}\n\nasync function createEditor() {\n if (!containerRef.value) return\n const mods = await loadModules()\n const { viewMod, stateMod } = mods\n\n view?.destroy()\n\n view = new viewMod.EditorView({\n state: stateMod.EditorState.create({\n doc: props.modelValue,\n extensions: buildExtensions(mods),\n }),\n parent: containerRef.value,\n })\n}\n\nonMounted(createEditor)\n\nwatch(() => props.modelValue, (val) => {\n if (view && view.state.doc.toString() !== val) {\n view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: val } })\n }\n})\n\nwatch([() => props.language, () => props.theme, () => props.readonly, () => props.lineNumbers, () => props.wrap, () => props.placeholder], createEditor)\n\nonBeforeUnmount(() => view?.destroy())\n</script>\n\n<template>\n <div class=\"flex flex-col overflow-hidden rounded-lg border border-outline-variant\">\n <!-- Header bar -->\n <div class=\"flex items-center justify-between border-b border-outline-variant bg-surface-container px-4 py-2\">\n <span class=\"text-label-medium text-on-surface-variant\">{{ langLabel }}</span>\n <div class=\"flex items-center gap-2\">\n <slot name=\"actions\" />\n <button\n type=\"button\"\n 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\"\n :title=\"copied ? 'Copied!' : 'Copy code'\"\n @click=\"copyCode\"\n >\n <MIcon :name=\"copied ? 'check' : 'content_copy'\" :size=\"16\" :class=\"copied ? 'text-primary' : ''\" />\n <span v-if=\"copied\" class=\"text-primary\">Copied</span>\n </button>\n </div>\n </div>\n\n <!-- Editor -->\n <div\n ref=\"containerRef\"\n class=\"code-editor-container overflow-auto bg-surface text-on-surface\"\n :style=\"{ minHeight, maxHeight }\"\n />\n </div>\n</template>\n\n<style scoped>\n.code-editor-container {\n /* .cm-editor/.cm-scroller/.cm-gutters all use height:100%, which only ever\n resolves against a genuinely definite ancestor height — a min-height (what\n this container has, so it can grow with content up to maxHeight) doesn't\n count as definite for that percentage chain, so .cm-gutters silently fell\n back to sizing off its own content instead of the real editor height.\n Making this a flex column and letting .cm-editor grow via flex instead of\n a % height gives the whole chain a real definite size to resolve against. */\n display: flex;\n flex-direction: column;\n /* Also grow to fill the outer wrapper (see the root element's own flex-col\n above) rather than just sitting at minHeight, whenever a consumer stretches\n the whole component taller than that — e.g. `class=\"h-full\"` in a grid\n cell next to taller content. Still hard-capped by maxHeight either way. */\n flex: 1 1 auto;\n min-height: 0;\n}\n\n.code-editor-container :deep(.cm-editor) {\n flex: 1;\n min-height: 0;\n font-size: 0.8125rem;\n}\n\n.code-editor-container :deep(.cm-editor.cm-focused) {\n outline: none;\n}\n\n.code-editor-container :deep(.cm-scroller) {\n /* .cm-scroller normally sizes itself off a height:100% against .cm-editor,\n but that's a percentage-height-in-nested-flex-column case that browsers\n don't reliably resolve — grow it directly instead so it has a real,\n laid-out height for .cm-gutters to stretch against below. */\n flex: 1 !important;\n min-height: 0;\n /* .cm-scroller lays out .cm-gutters/.cm-content in a row (gutter | content),\n so .cm-gutters' height comes from cross-axis stretch, not flex-grow —\n CodeMirror's own base theme sets align-items: flex-start !important here,\n which is exactly what stops the gutter from stretching to full height in\n the first place. */\n align-items: stretch !important;\n /* Set here, not on .cm-editor: CodeMirror's base theme declares\n font-family: monospace and line-height: 1.4 on .cm-scroller itself,\n which beats inheritance */\n font-family: var(--font-mono, 'Roboto Mono', monospace);\n line-height: 1.6;\n}\n\n.code-editor-container :deep(.cm-content) {\n padding: 12px 0;\n}\n\n.code-editor-container :deep(.cm-line) {\n padding: 0 16px;\n}\n\n.code-editor-container :deep(.cm-gutters) {\n background: var(--color-surface-container);\n border-right: 1px solid var(--color-outline-variant);\n color: var(--color-outline);\n font-size: 0.75rem;\n padding: 0 4px;\n /* .cm-gutters ships with an explicit height:100% rather than auto, so the\n align-items:stretch above (on .cm-scroller) never actually kicks in —\n stretch only applies to items whose cross-size computes to auto. Forcing\n height back to auto here is what makes that stretch take effect. */\n height: auto !important;\n align-self: stretch !important;\n}\n\n.code-editor-container :deep(.cm-activeLineGutter) {\n background: var(--color-surface-container-high);\n color: var(--color-on-surface-variant);\n}\n\n.code-editor-container :deep(.cm-activeLine) {\n /* CodeMirror renders the selection highlight on a layer with z-index: -1\n (@codemirror/view's selectionLayer has `above: false` by design, so it always\n sits behind the line content). An opaque active-line background would paint\n straight over it and hide the selection on the current line — this needs to\n stay a translucent tint so a selection underneath still shows through. */\n background: color-mix(in srgb, var(--color-on-surface) 5%, transparent);\n}\n\n.code-editor-container :deep(.cm-selectionBackground) {\n background: var(--color-primary-container) !important;\n}\n\n.code-editor-container :deep(.cm-cursor) {\n border-left-color: var(--color-primary);\n border-left-width: 2px;\n}\n\n.code-editor-container :deep(.cm-matchingBracket) {\n background: var(--color-tertiary-container);\n color: var(--color-on-tertiary-container);\n border-radius: 2px;\n}\n\n.code-editor-container :deep(.cm-foldGutter span) {\n color: var(--color-on-surface-variant);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * A JSON-aware editor built on top of MCodeEditor — validates as you type and adds format/minify shortcuts.\n *\n * @event update:modelValue Emitted with the parsed value whenever the text is valid JSON — powers v-model\n */\nimport { ref, computed, watch } from 'vue'\nimport MCodeEditor from './MCodeEditor.vue'\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\n\nexport interface JsonEditorLabels {\n valid?: string\n invalid?: string\n format?: string\n minify?: string\n}\n\nconst locale = useLocale()\n\nconst props = withDefaults(\n defineProps<{\n /** JSON data (v-model, any valid JSON) */\n modelValue: unknown\n /** Read-only mode */\n readonly?: boolean\n /** Min height */\n minHeight?: string\n /** Max height */\n maxHeight?: string\n /**\n * Overrides for the valid/invalid badge and format/minify button text (see `JsonEditorLabels`) — defaults come\n * from useLocale()\n */\n labels?: JsonEditorLabels\n }>(),\n {\n readonly: false,\n minHeight: '200px',\n maxHeight: '600px',\n },\n)\n\nconst l = computed<Required<JsonEditorLabels>>(() => ({\n valid: locale.jsonValid,\n invalid: locale.jsonInvalid,\n format: locale.jsonFormat,\n minify: locale.jsonMinify,\n ...props.labels,\n}))\n\nconst emit = defineEmits<{ 'update:modelValue': [unknown] }>()\n\nconst rawText = ref(JSON.stringify(props.modelValue, null, 2))\nconst parseError = ref<string | null>(null)\n\nconst isValid = computed(() => !parseError.value)\n\nwatch(() => props.modelValue, (val) => {\n let current: unknown\n try {\n current = JSON.parse(rawText.value)\n } catch {\n current = undefined\n }\n // Only resync from outside when the actual data changed, not just its formatting —\n // otherwise the round-trip from formatJson/minifyJson emitting would immediately\n // overwrite the newly (re)formatted text with a pretty-printed copy.\n if (JSON.stringify(current) === JSON.stringify(val)) return\n rawText.value = JSON.stringify(val, null, 2)\n parseError.value = null\n})\n\nfunction onTextUpdate(text: string) {\n rawText.value = text\n try {\n const parsed = JSON.parse(text)\n parseError.value = null\n emit('update:modelValue', parsed)\n } catch (e) {\n parseError.value = (e as Error).message\n }\n}\n\nfunction formatJson() {\n try {\n const parsed = JSON.parse(rawText.value)\n rawText.value = JSON.stringify(parsed, null, 2)\n parseError.value = null\n emit('update:modelValue', parsed)\n } catch {\n // keep error state\n }\n}\n\nfunction minifyJson() {\n try {\n const parsed = JSON.parse(rawText.value)\n rawText.value = JSON.stringify(parsed)\n parseError.value = null\n emit('update:modelValue', parsed)\n } catch {\n // keep error state\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-0\">\n <MCodeEditor\n :model-value=\"rawText\"\n language=\"json\"\n :readonly=\"readonly\"\n :min-height=\"minHeight\"\n :max-height=\"maxHeight\"\n @update:model-value=\"onTextUpdate\"\n >\n <template #actions>\n <div class=\"flex items-center gap-2\">\n <!-- Validation badge -->\n <span\n class=\"flex items-center gap-1 rounded-full px-2.5 py-0.5 text-label-small\"\n :class=\"isValid ? 'bg-success-container text-on-success-container' : 'bg-error-container text-on-error-container'\"\n >\n <MIcon :name=\"isValid ? 'check_circle' : 'error'\" :size=\"14\" />\n {{ isValid ? l.valid : l.invalid }}\n </span>\n\n <button\n v-if=\"!readonly\"\n type=\"button\"\n :title=\"l.format\"\n 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\"\n @click=\"formatJson\"\n >\n <MIcon name=\"format_indent_increase\" :size=\"16\" />\n {{ l.format }}\n </button>\n <button\n v-if=\"!readonly\"\n type=\"button\"\n :title=\"l.minify\"\n 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\"\n @click=\"minifyJson\"\n >\n <MIcon name=\"compress\" :size=\"16\" />\n {{ l.minify }}\n </button>\n </div>\n </template>\n </MCodeEditor>\n\n <p v-if=\"parseError\" class=\"px-3 py-1.5 text-body-small text-error\">\n {{ parseError }}\n </p>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,IAAMkC,IAAQC,GAgCRC,IAAOH,GAEPI,IAAeC,EAAwB,IAAI,GAC7CC,IAAY,MACZC,IAAiB,MACfC,IAASH,EAAI,EAAK;EAExB,eAAeI,IAAW;GAGxB,AAFA,MAAM,UAAU,UAAU,UAAUR,EAAM,UAAU,GACpD,EAAO,QAAQ,IACf,iBAAiB;IAAE,EAAO,QAAQ;GAAM,GAAG,IAAI;EACjD;EAEA,IAAMS,IAAYC,SAeT;GAbL,YAAY;GACZ,YAAY;GACZ,MAAM;GACN,MAAM;GACN,KAAK;GACL,QAAQ;GACR,KAAK;GACL,GAAG;GACH,KAAK;GACL,MAAM;GACN,KAAK;GACL,OAAO;EAEF,EAAA,CAAOV,EAAM,SACrB;EAED,eAAeW,IAAc;GAC3B,IAAIL,GAAW,OAAOA;GAEtB,IAAM,CAACM,GAASC,GAAUC,GAAaC,GAAaC,GAAcC,GAAYC,GAAOC,GAASC,GAASC,GAAQC,GAAOC,GAAQC,GAAQC,GAASC,KAAU,MAAM,QAAQ,IAAI;IACzK,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,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GAEV,SAAO/E,QA+BV,CA9BNC,EA8BM,OA9BNmE,GA8BM;IA5BJnE,EAMO,QAAA,EALL,OAAKC,EAAA,CAAC,uEACE2E,EAAA,QAAO,mDAAA,4CAAA,CAAA,E,IAEf/E,EAA+DK,GAAA;KAAvD,MAAM0E,EAAA,QAAO,iBAAA;KAA8B,MAAM;I,uBAAMzE,EAAA,MAC/DC,EAAGwE,EAAA,QAAUH,EAAA,MAAE,QAAQA,EAAA,MAAE,OAAO,GAAA,CAAA,C;IAIzBxD,EAAA,W,aADTtB,EAAA,GAAAC,EASS,UAAA;;KAPP,MAAK;KACJ,OAAO6E,EAAA,MAAE;KACV,OAAM;KACL,SAAOQ;I,IAERpF,EAAkDK,GAAA;KAA3C,MAAK;KAA0B,MAAM;I,IAAMC,EAAA,MAClDC,EAAGqE,EAAA,MAAE,MAAM,GAAA,CAAA,C;IAGJxD,EAAA,W,aADTtB,EAAA,GAAAC,EASS,UAAA;;KAPP,MAAK;KACJ,OAAO6E,EAAA,MAAE;KACV,OAAM;KACL,SAAOS;I,IAERrF,EAAoCK,GAAA;KAA7B,MAAK;KAAY,MAAM;I,IAAMC,EAAA,MACpCC,EAAGqE,EAAA,MAAE,MAAM,GAAA,CAAA,C;;;;;;;;E,IAMVE,EAAA,SAAThF,EAAA,GAAAC,EAEI,KAFJ0E,GAEIlE,EADCuE,EAAA,KAAU,GAAA,CAAA,K"}
1
+ {"version":3,"file":"code-editor.js","names":["$attrs","_hoisted_2","_hoisted_3","_hoisted_4","_openBlock","_createElementBlock","_createElementVNode","_mergeProps","_unref","_toDisplayString","_renderSlot","_createVNode","MIcon","_normalizeClass","_normalizeStyle","_openBlock","_createElementBlock","_unref","_createVNode","MCodeEditor","_withCtx","_createElementVNode","_normalizeClass","MIcon","_createTextVNode","_toDisplayString","useFieldValidation","useFocusLeave","FORM_KEY","MIcon_default","_plugin_vue_export_helper_default","useLocale","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4$1","_hoisted_5$1","_hoisted_6","_hoisted_7","MCodeEditor_default","defineComponent","__expose","__emit","props","__props","emit","containerRef","ref","view","rootEl","validation","v","errorMessage","onFocusOut","cmModules","copied","copyCode","langLabel","computed","loadModules","viewMod","stateMod","commandsMod","languageMod","highlightMod","oneDarkMod","jsMod","jsonMod","htmlMod","cssMod","pyMod","vueMod","cppMod","rustMod","asmMod","buildM3HighlightStyle","tags","getLangExtension","mods","buildExtensions","m3Style","exts","update","createEditor","onMounted","watch","val","onBeforeUnmount","openBlock","createElementBlock","Fragment","createElementVNode","mergeProps","_ctx","unref","hasError","messageId","_cache","args","toDisplayString","renderSlot","createVNode","normalizeClass","createCommentVNode","normalizeStyle","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","MJsonEditor_default","locale","inForm","inject","l","rawText","parseError","isValid","jsonRule","provide","current","onTextUpdate","text","parsed","formatJson","minifyJson","withCtx","createTextVNode"],"sources":["../src/components/MCodeEditor.vue","../src/components/MJsonEditor.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * A syntax-highlighted code editor built on CodeMirror 6, with a header bar, line numbers, and a copy button.\n *\n * @slot actions Extra controls rendered in the header bar, before the built-in copy button\n * @event update:modelValue Emitted on every document change — powers v-model\n * @event blur Emitted when focus leaves the editor\n */\nimport { ref, watch, onMounted, onBeforeUnmount, computed } from 'vue'\nimport { useFieldValidation, useFocusLeave } from '../composables/_useFieldValidation'\nimport type { ValidateOn, ValidationRule } from '../composables/validation'\nimport MIcon from './MIcon.vue'\n\ntype Language = 'javascript' | 'typescript' | 'json' | 'html' | 'css' | 'python' | 'vue' | 'c' | 'cpp' | 'rust' | 'asm' | 'plain'\n\nconst props = withDefaults(\n defineProps<{\n /** Editor content (v-model) */\n modelValue: string\n /** Syntax language */\n language?: Language\n /** Read-only mode */\n readonly?: boolean\n /** Show line numbers */\n lineNumbers?: boolean\n /** Color theme */\n theme?: 'light' | 'dark'\n /** Minimum editor height */\n minHeight?: string\n /** Maximum editor height */\n maxHeight?: string\n /** Placeholder text shown via CodeMirror when the editor is empty */\n placeholder?: string\n /** Error state. A string is also the message */\n error?: boolean | string\n /** Error message shown when `error` is true */\n errorLabel?: string\n /** Inside an `MForm` or with `rules`, the code can't be blank */\n required?: boolean\n /** Validation rules (functions or a Standard Schema); see `MForm` */\n rules?: ValidationRule | ValidationRule[]\n /** When the rules are checked and shown: on leaving it (default), on change, or only on submit */\n validateOn?: ValidateOn\n /** Wait this long (ms) after the value stops changing before re-checking (one request for an async rule, not one per key). Defaults to its `MForm`'s */\n validateDebounce?: number\n /** The key of this field in its `MForm` */\n name?: string\n /** Word wrap */\n wrap?: boolean\n }>(),\n {\n language: 'javascript',\n readonly: false,\n lineNumbers: true,\n theme: 'light',\n minHeight: '200px',\n maxHeight: '600px',\n wrap: true,\n },\n)\n\n// Editor + its message: attributes go on the editor\ndefineOptions({ inheritAttrs: false })\n\nconst emit = defineEmits<{ 'update:modelValue': [string]; blur: [] }>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet view: any = null\nconst rootEl = ref<HTMLElement | null>(null)\n\nconst validation = useFieldValidation({\n value: () => props.modelValue,\n rules: () => props.rules,\n required: () => props.required,\n error: () => props.error,\n errorLabel: () => props.errorLabel,\n name: () => props.name,\n validateOn: () => props.validateOn,\n validateDebounce: () => props.validateDebounce,\n disabled: () => props.readonly,\n focus: () => { view?.focus() },\n el: () => rootEl.value,\n setValue: (v) => emit('update:modelValue', v as string),\n})\nconst { hasError, message: errorMessage, messageId } = validation\nconst onFocusOut = useFocusLeave(() => rootEl.value, () => {\n validation.onBlur()\n emit('blur')\n})\nlet cmModules: any = null\nconst copied = ref(false)\n\nasync function copyCode() {\n await navigator.clipboard.writeText(props.modelValue)\n copied.value = true\n setTimeout(() => { copied.value = false }, 1500)\n}\n\nconst langLabel = computed(() => {\n const labels: Record<Language, string> = {\n javascript: 'JavaScript',\n typescript: 'TypeScript',\n json: 'JSON',\n html: 'HTML',\n css: 'CSS',\n python: 'Python',\n vue: 'Vue',\n c: 'C',\n cpp: 'C++',\n rust: 'Rust',\n asm: 'Assembly',\n plain: 'Texto',\n }\n return labels[props.language]\n})\n\nasync function loadModules() {\n if (cmModules) return cmModules\n\n const [viewMod, stateMod, commandsMod, languageMod, highlightMod, oneDarkMod, jsMod, jsonMod, htmlMod, cssMod, pyMod, vueMod, cppMod, rustMod, asmMod] = await Promise.all([\n import('@codemirror/view'),\n import('@codemirror/state'),\n import('@codemirror/commands'),\n import('@codemirror/language'),\n import('@lezer/highlight'),\n import('@codemirror/theme-one-dark'),\n import('@codemirror/lang-javascript'),\n import('@codemirror/lang-json'),\n import('@codemirror/lang-html'),\n import('@codemirror/lang-css'),\n import('@codemirror/lang-python'),\n import('@codemirror/lang-vue'),\n import('@codemirror/lang-cpp'),\n import('@codemirror/lang-rust'),\n import('@codemirror/legacy-modes/mode/gas'),\n ])\n\n cmModules = { viewMod, stateMod, commandsMod, languageMod, highlightMod, oneDarkMod, jsMod, jsonMod, htmlMod, cssMod, pyMod, vueMod, cppMod, rustMod, asmMod }\n return cmModules\n}\n\nfunction buildM3HighlightStyle(languageMod: any, tags: any) {\n return languageMod.HighlightStyle.define([\n { tag: tags.keyword, color: 'var(--color-primary)' },\n { tag: tags.controlKeyword, color: 'var(--color-primary)', fontWeight: '500' },\n { tag: tags.operatorKeyword, color: 'var(--color-primary)' },\n { tag: tags.definitionKeyword, color: 'var(--color-primary)' },\n { tag: tags.moduleKeyword, color: 'var(--color-primary)' },\n\n { tag: tags.string, color: 'var(--color-tertiary)' },\n { tag: tags.regexp, color: 'var(--color-tertiary)' },\n\n { tag: tags.number, color: 'var(--color-error)' },\n { tag: tags.bool, color: 'var(--color-error)' },\n\n { tag: tags.function(tags.variableName), color: 'var(--color-secondary)' },\n { tag: tags.function(tags.definition(tags.variableName)), color: 'var(--color-secondary)', fontWeight: '500' },\n\n { tag: tags.typeName, color: 'var(--color-primary)', fontStyle: 'italic' },\n { tag: tags.className, color: 'var(--color-primary)', fontStyle: 'italic' },\n { tag: tags.namespace, color: 'var(--color-on-surface-variant)' },\n\n { tag: tags.propertyName, color: 'var(--color-on-surface)' },\n { tag: tags.definition(tags.propertyName), color: 'var(--color-on-surface)' },\n\n { tag: tags.variableName, color: 'var(--color-on-surface)' },\n { tag: tags.definition(tags.variableName), color: 'var(--color-on-surface)' },\n\n { tag: tags.comment, color: 'var(--color-outline)', fontStyle: 'italic' },\n { tag: tags.lineComment, color: 'var(--color-outline)', fontStyle: 'italic' },\n { tag: tags.blockComment, color: 'var(--color-outline)', fontStyle: 'italic' },\n\n { tag: tags.meta, color: 'var(--color-on-surface-variant)' },\n { tag: tags.tagName, color: 'var(--color-primary)' },\n { tag: tags.attributeName, color: 'var(--color-tertiary)' },\n { tag: tags.attributeValue, color: 'var(--color-secondary)' },\n\n { tag: tags.atom, color: 'var(--color-error)' },\n { tag: tags.null, color: 'var(--color-error)' },\n\n { tag: tags.punctuation, color: 'var(--color-on-surface-variant)' },\n { tag: tags.bracket, color: 'var(--color-on-surface-variant)' },\n { tag: tags.operator, color: 'var(--color-on-surface-variant)' },\n { tag: tags.separator, color: 'var(--color-on-surface-variant)' },\n ])\n}\n\nfunction getLangExtension(mods: any) {\n switch (props.language) {\n case 'javascript': return mods.jsMod.javascript()\n case 'typescript': return mods.jsMod.javascript({ typescript: true })\n case 'json': return mods.jsonMod.json()\n case 'html': return mods.htmlMod.html()\n case 'css': return mods.cssMod.css()\n case 'python': return mods.pyMod.python()\n case 'vue': return mods.vueMod.vue()\n case 'c': case 'cpp': return mods.cppMod.cpp()\n case 'rust': return mods.rustMod.rust()\n case 'asm': return mods.languageMod.StreamLanguage.define(mods.asmMod.gas)\n default: return []\n }\n}\n\nfunction buildExtensions(mods: any) {\n const { viewMod, stateMod, commandsMod, languageMod, highlightMod, oneDarkMod } = mods\n\n const m3Style = buildM3HighlightStyle(languageMod, highlightMod.tags)\n\n const exts = [\n viewMod.keymap.of([...commandsMod.defaultKeymap, ...commandsMod.historyKeymap, commandsMod.indentWithTab]),\n commandsMod.history(),\n languageMod.bracketMatching(),\n languageMod.indentOnInput(),\n languageMod.foldGutter(),\n viewMod.drawSelection(),\n viewMod.highlightActiveLine(),\n viewMod.highlightActiveLineGutter(),\n languageMod.syntaxHighlighting(m3Style),\n languageMod.syntaxHighlighting(languageMod.defaultHighlightStyle, { fallback: true }),\n getLangExtension(mods),\n viewMod.EditorView.updateListener.of((update: any) => {\n if (update.docChanged) emit('update:modelValue', update.state.doc.toString())\n }),\n stateMod.EditorState.readOnly.of(props.readonly),\n ]\n\n if (props.wrap) exts.push(viewMod.EditorView.lineWrapping)\n if (props.lineNumbers) exts.push(viewMod.lineNumbers())\n if (props.theme === 'dark') exts.push(oneDarkMod.oneDark)\n if (props.placeholder) exts.push(viewMod.placeholder(props.placeholder))\n\n return exts\n}\n\nasync function createEditor() {\n if (!containerRef.value) return\n const mods = await loadModules()\n const { viewMod, stateMod } = mods\n\n view?.destroy()\n\n view = new viewMod.EditorView({\n state: stateMod.EditorState.create({\n doc: props.modelValue,\n extensions: buildExtensions(mods),\n }),\n parent: containerRef.value,\n })\n}\n\nonMounted(createEditor)\n\nwatch(() => props.modelValue, (val) => {\n if (view && view.state.doc.toString() !== val) {\n view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: val } })\n }\n})\n\nwatch([() => props.language, () => props.theme, () => props.readonly, () => props.lineNumbers, () => props.wrap, () => props.placeholder], createEditor)\n\nonBeforeUnmount(() => view?.destroy())\n\ndefineExpose({\n /** Checks its rules and shows the result; resolves to whether they pass */\n validate: validation.validate,\n /** Hides its validation error (until the next check) */\n resetValidation: validation.resetValidation,\n})\n</script>\n\n<template>\n <div\n ref=\"rootEl\"\n v-bind=\"$attrs\"\n class=\"flex flex-col overflow-hidden rounded-lg border\"\n :class=\"hasError ? 'border-error' : 'border-outline-variant'\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"errorMessage ? messageId : undefined\"\n @focusout=\"onFocusOut\"\n >\n <!-- Header bar -->\n <div class=\"flex items-center justify-between border-b border-outline-variant bg-surface-container px-4 py-2\">\n <span class=\"text-label-medium text-on-surface-variant\">{{ langLabel }}</span>\n <div class=\"flex items-center gap-2\">\n <slot name=\"actions\" />\n <button\n type=\"button\"\n 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\"\n :title=\"copied ? 'Copied!' : 'Copy code'\"\n @click=\"copyCode\"\n >\n <MIcon :name=\"copied ? 'check' : 'content_copy'\" :size=\"16\" :class=\"copied ? 'text-primary' : ''\" />\n <span v-if=\"copied\" class=\"text-primary\">Copied</span>\n </button>\n </div>\n </div>\n\n <!-- Editor -->\n <div\n ref=\"containerRef\"\n class=\"code-editor-container overflow-auto bg-surface text-on-surface\"\n :style=\"{ minHeight, maxHeight }\"\n />\n </div>\n <p v-if=\"errorMessage\" :id=\"messageId\" role=\"alert\" class=\"mt-1 px-4 text-body-small text-error\">{{ errorMessage }}</p>\n</template>\n\n<style scoped>\n.code-editor-container {\n /* .cm-editor/.cm-scroller/.cm-gutters all use height:100%, which only ever\n resolves against a genuinely definite ancestor height — a min-height (what\n this container has, so it can grow with content up to maxHeight) doesn't\n count as definite for that percentage chain, so .cm-gutters silently fell\n back to sizing off its own content instead of the real editor height.\n Making this a flex column and letting .cm-editor grow via flex instead of\n a % height gives the whole chain a real definite size to resolve against. */\n display: flex;\n flex-direction: column;\n /* Also grow to fill the outer wrapper (see the root element's own flex-col\n above) rather than just sitting at minHeight, whenever a consumer stretches\n the whole component taller than that — e.g. `class=\"h-full\"` in a grid\n cell next to taller content. Still hard-capped by maxHeight either way. */\n flex: 1 1 auto;\n min-height: 0;\n}\n\n.code-editor-container :deep(.cm-editor) {\n flex: 1;\n min-height: 0;\n font-size: 0.8125rem;\n}\n\n.code-editor-container :deep(.cm-editor.cm-focused) {\n outline: none;\n}\n\n.code-editor-container :deep(.cm-scroller) {\n /* .cm-scroller normally sizes itself off a height:100% against .cm-editor,\n but that's a percentage-height-in-nested-flex-column case that browsers\n don't reliably resolve — grow it directly instead so it has a real,\n laid-out height for .cm-gutters to stretch against below. */\n flex: 1 !important;\n min-height: 0;\n /* .cm-scroller lays out .cm-gutters/.cm-content in a row (gutter | content),\n so .cm-gutters' height comes from cross-axis stretch, not flex-grow —\n CodeMirror's own base theme sets align-items: flex-start !important here,\n which is exactly what stops the gutter from stretching to full height in\n the first place. */\n align-items: stretch !important;\n /* Set here, not on .cm-editor: CodeMirror's base theme declares\n font-family: monospace and line-height: 1.4 on .cm-scroller itself,\n which beats inheritance */\n font-family: var(--font-mono, 'Roboto Mono', monospace);\n line-height: 1.6;\n}\n\n.code-editor-container :deep(.cm-content) {\n padding: 12px 0;\n}\n\n.code-editor-container :deep(.cm-line) {\n padding: 0 16px;\n}\n\n.code-editor-container :deep(.cm-gutters) {\n background: var(--color-surface-container);\n border-right: 1px solid var(--color-outline-variant);\n color: var(--color-outline);\n font-size: 0.75rem;\n padding: 0 4px;\n /* .cm-gutters ships with an explicit height:100% rather than auto, so the\n align-items:stretch above (on .cm-scroller) never actually kicks in —\n stretch only applies to items whose cross-size computes to auto. Forcing\n height back to auto here is what makes that stretch take effect. */\n height: auto !important;\n align-self: stretch !important;\n}\n\n.code-editor-container :deep(.cm-activeLineGutter) {\n background: var(--color-surface-container-high);\n color: var(--color-on-surface-variant);\n}\n\n.code-editor-container :deep(.cm-activeLine) {\n /* CodeMirror renders the selection highlight on a layer with z-index: -1\n (@codemirror/view's selectionLayer has `above: false` by design, so it always\n sits behind the line content). An opaque active-line background would paint\n straight over it and hide the selection on the current line — this needs to\n stay a translucent tint so a selection underneath still shows through. */\n background: color-mix(in srgb, var(--color-on-surface) 5%, transparent);\n}\n\n.code-editor-container :deep(.cm-selectionBackground) {\n background: var(--color-primary-container) !important;\n}\n\n.code-editor-container :deep(.cm-cursor) {\n border-left-color: var(--color-primary);\n border-left-width: 2px;\n}\n\n.code-editor-container :deep(.cm-matchingBracket) {\n background: var(--color-tertiary-container);\n color: var(--color-on-tertiary-container);\n border-radius: 2px;\n}\n\n.code-editor-container :deep(.cm-foldGutter span) {\n color: var(--color-on-surface-variant);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * A JSON-aware editor built on top of MCodeEditor — validates as you type and adds format/minify shortcuts.\n *\n * @event update:modelValue Emitted with the parsed value whenever the text is valid JSON — powers v-model\n * @event blur Emitted when focus leaves the editor\n */\nimport { ref, computed, inject, provide, watch } from 'vue'\nimport { FORM_KEY, useFieldValidation, useFocusLeave, type FormContext } from '../composables/_useFieldValidation'\nimport type { ValidateOn, ValidationRule } from '../composables/validation'\nimport MCodeEditor from './MCodeEditor.vue'\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\n\nexport interface JsonEditorLabels {\n valid?: string\n invalid?: string\n format?: string\n minify?: string\n}\n\nconst locale = useLocale()\n// jsonRule is always there: `required` alone (no MForm, no rules) keeps today's behavior\nconst inForm = !!inject(FORM_KEY, null)\n\nconst props = withDefaults(\n defineProps<{\n /** JSON data (v-model, any valid JSON) */\n modelValue: unknown\n /** Read-only mode */\n readonly?: boolean\n /** Error state. A string is also the message */\n error?: boolean | string\n /** Error message shown when `error` is true */\n errorLabel?: string\n /** Inside an `MForm` or with `rules`, it can't be empty (null) */\n required?: boolean\n /** Validation rules (functions or a Standard Schema); see `MForm` */\n rules?: ValidationRule | ValidationRule[]\n /** When the rules are checked and shown: on leaving it (default), on change, or only on submit */\n validateOn?: ValidateOn\n /** Wait this long (ms) after the value stops changing before re-checking (one request for an async rule, not one per key). Defaults to its `MForm`'s */\n validateDebounce?: number\n /** The key of this field in its `MForm` */\n name?: string\n /** Min height */\n minHeight?: string\n /** Max height */\n maxHeight?: string\n /**\n * Overrides for the valid/invalid badge and format/minify button text (see `JsonEditorLabels`) — defaults come\n * from useLocale()\n */\n labels?: JsonEditorLabels\n }>(),\n {\n readonly: false,\n minHeight: '200px',\n maxHeight: '600px',\n },\n)\n\nconst l = computed<Required<JsonEditorLabels>>(() => ({\n valid: locale.jsonValid,\n invalid: locale.jsonInvalid,\n format: locale.jsonFormat,\n minify: locale.jsonMinify,\n ...props.labels,\n}))\n\nconst emit = defineEmits<{ 'update:modelValue': [unknown]; blur: [] }>()\n\nconst rawText = ref(JSON.stringify(props.modelValue, null, 2))\nconst parseError = ref<string | null>(null)\n\nconst isValid = computed(() => !parseError.value)\n\n// Text that doesn't parse is one more rule: it blocks an MForm submit\nconst jsonRule: ValidationRule = () => !parseError.value || l.value.invalid\nconst rootEl = ref<HTMLElement | null>(null)\nconst validation = useFieldValidation({\n value: () => props.modelValue,\n rules: () => [...(props.rules ? (Array.isArray(props.rules) ? props.rules : [props.rules]) : []), jsonRule],\n required: () => props.required && (inForm || !!props.rules),\n error: () => props.error,\n errorLabel: () => props.errorLabel,\n name: () => props.name,\n validateOn: () => props.validateOn,\n validateDebounce: () => props.validateDebounce,\n disabled: () => props.readonly,\n focus: () => { rootEl.value?.querySelector<HTMLElement>('.cm-content')?.focus() },\n el: () => rootEl.value,\n setValue: (v) => emit('update:modelValue', v),\n})\nconst { hasError, message: errorMessage, messageId } = validation\nconst onFocusOut = useFocusLeave(() => rootEl.value, () => {\n validation.onBlur()\n emit('blur')\n})\n// The inner MCodeEditor edits text, not this value: keep it out of the form\nprovide(FORM_KEY, null as unknown as FormContext)\n\nwatch(() => props.modelValue, (val) => {\n let current: unknown\n try {\n current = JSON.parse(rawText.value)\n } catch {\n current = undefined\n }\n // Only resync from outside when the actual data changed, not just its formatting —\n // otherwise the round-trip from formatJson/minifyJson emitting would immediately\n // overwrite the newly (re)formatted text with a pretty-printed copy.\n if (JSON.stringify(current) === JSON.stringify(val)) return\n rawText.value = JSON.stringify(val, null, 2)\n parseError.value = null\n})\n\nfunction onTextUpdate(text: string) {\n rawText.value = text\n try {\n const parsed = JSON.parse(text)\n parseError.value = null\n emit('update:modelValue', parsed)\n } catch (e) {\n parseError.value = (e as Error).message\n }\n}\n\nfunction formatJson() {\n try {\n const parsed = JSON.parse(rawText.value)\n rawText.value = JSON.stringify(parsed, null, 2)\n parseError.value = null\n emit('update:modelValue', parsed)\n } catch {\n // keep error state\n }\n}\n\nfunction minifyJson() {\n try {\n const parsed = JSON.parse(rawText.value)\n rawText.value = JSON.stringify(parsed)\n parseError.value = null\n emit('update:modelValue', parsed)\n } catch {\n // keep error state\n }\n}\n\ndefineExpose({\n /** Checks its rules and shows the result; resolves to whether they pass */\n validate: validation.validate,\n /** Hides its validation error (until the next check) */\n resetValidation: validation.resetValidation,\n})\n</script>\n\n<template>\n <div ref=\"rootEl\" class=\"flex flex-col gap-0\" @focusout=\"onFocusOut\">\n <MCodeEditor\n :model-value=\"rawText\"\n language=\"json\"\n :error=\"hasError && !parseError\"\n :readonly=\"readonly\"\n :min-height=\"minHeight\"\n :max-height=\"maxHeight\"\n @update:model-value=\"onTextUpdate\"\n >\n <template #actions>\n <div class=\"flex items-center gap-2\">\n <!-- Validation badge -->\n <span\n class=\"flex items-center gap-1 rounded-full px-2.5 py-0.5 text-label-small\"\n :class=\"isValid ? 'bg-success-container text-on-success-container' : 'bg-error-container text-on-error-container'\"\n >\n <MIcon :name=\"isValid ? 'check_circle' : 'error'\" :size=\"14\" />\n {{ isValid ? l.valid : l.invalid }}\n </span>\n\n <button\n v-if=\"!readonly\"\n type=\"button\"\n :title=\"l.format\"\n 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\"\n @click=\"formatJson\"\n >\n <MIcon name=\"format_indent_increase\" :size=\"16\" />\n {{ l.format }}\n </button>\n <button\n v-if=\"!readonly\"\n type=\"button\"\n :title=\"l.minify\"\n 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\"\n @click=\"minifyJson\"\n >\n <MIcon name=\"compress\" :size=\"16\" />\n {{ l.minify }}\n </button>\n </div>\n </template>\n </MCodeEditor>\n\n <p v-if=\"parseError\" class=\"px-3 py-1.5 text-body-small text-error\">\n {{ parseError }}\n </p>\n <!-- The parse error above already says what's wrong with the text -->\n <p v-else-if=\"errorMessage\" :id=\"messageId\" role=\"alert\" class=\"px-3 py-1.5 text-body-small text-error\">{{ errorMessage }}</p>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAeA,IAAM2C,IAAQC,GAiDRC,IAAOH,GAEPI,IAAeC,EAAwB,IAAI,GAC7CC,IAAY,MACVC,IAASF,EAAwB,IAAI,GAErCG,IAAaxB,EAAmB;GACpC,aAAaiB,EAAM;GACnB,aAAaA,EAAM;GACnB,gBAAgBA,EAAM;GACtB,aAAaA,EAAM;GACnB,kBAAkBA,EAAM;GACxB,YAAYA,EAAM;GAClB,kBAAkBA,EAAM;GACxB,wBAAwBA,EAAM;GAC9B,gBAAgBA,EAAM;GACtB,aAAa;IAAE,GAAM,MAAM;GAAE;GAC7B,UAAUM,EAAO;GACjB,WAAW,MAAMJ,EAAK,qBAAqBM,CAAW;EACxD,CAAC,GACK,EAAE,aAAU,SAASC,GAAc,iBAAcF,GACjDG,IAAa1B,QAAoBsB,EAAO,aAAa;GAEzD,AADAC,EAAW,OAAO,GAClBL,EAAK,MAAM;EACb,CAAC,GACGS,IAAiB,MACfC,IAASR,EAAI,EAAK;EAExB,eAAeS,IAAW;GAGxB,AAFA,MAAM,UAAU,UAAU,UAAUb,EAAM,UAAU,GACpD,EAAO,QAAQ,IACf,iBAAiB;IAAE,EAAO,QAAQ;GAAM,GAAG,IAAI;EACjD;EAEA,IAAMc,IAAYC,SAeT;GAbL,YAAY;GACZ,YAAY;GACZ,MAAM;GACN,MAAM;GACN,KAAK;GACL,QAAQ;GACR,KAAK;GACL,GAAG;GACH,KAAK;GACL,MAAM;GACN,KAAK;GACL,OAAO;EAEF,EAAA,CAAOf,EAAM,SACrB;EAED,eAAegB,IAAc;GAC3B,IAAIL,GAAW,OAAOA;GAEtB,IAAM,CAACM,GAASC,GAAUC,GAA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EAAA,MAAE;KACV,OAAM;KACL,SAAOW;I,IAER3G,EAAoCK,GAAA;KAA7B,MAAK;KAAY,MAAM;I,IAAMC,EAAA,MACpCC,EAAGyF,EAAA,MAAE,MAAM,GAAA,CAAA,C;;;;;;;;;E,IAMVE,EAAA,SAATrG,EAAA,GAAAC,EAEI,KAFJ4F,GAEInF,EADC2F,EAAA,KAAU,GAAA,CAAA,KAGDnG,EAAAmC,CAAA,KAAdrC,EAAA,GAAAC,EAA8H,KAAA;;GAAjG,IAAIC,EAAA+E,CAAA;GAAW,MAAK;GAAQ,OAAM;EAA4C,GAAAvE,EAAAR,EAAAmC,CAAA,CAAY,GAAA,GAAAyD,CAAA,K"}
@@ -1,3 +1,4 @@
1
+ import type { ValidateOn, ValidationRule } from '../composables/validation';
1
2
  import { type MapSearchProvider, type MapSearchResult } from '../composables/mapSearch';
2
3
  type __VLS_Props = {
3
4
  /** The picked place (v-model), or null */
@@ -18,11 +19,19 @@ type __VLS_Props = {
18
19
  minLength?: number;
19
20
  /** Helper text below the field */
20
21
  hint?: string;
21
- /** Error state */
22
- error?: boolean;
22
+ /** Error state. A string is also the message */
23
+ error?: boolean | string;
23
24
  /** Error message shown when `error` is true */
24
25
  errorLabel?: string;
25
- /** Marks it as required */
26
+ /** Validation rules (functions or a Standard Schema), run on the picked place (null until one is picked); see `MForm` */
27
+ rules?: ValidationRule | ValidationRule[];
28
+ /** When the rules are checked and shown: on leaving the field (default), while typing, or only on submit */
29
+ validateOn?: ValidateOn;
30
+ /** Wait this long (ms) after the value stops changing before re-checking (one request for an async rule, not one per key). Defaults to its `MForm`'s */
31
+ validateDebounce?: number;
32
+ /** The key of this field in its `MForm` */
33
+ name?: string;
34
+ /** Marks it as required; inside an `MForm` or with `rules`, a place must be picked (typed text alone isn't enough) */
26
35
  required?: boolean;
27
36
  /** Disables the field */
28
37
  disabled?: boolean;
@@ -36,11 +45,17 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
36
45
  clear: typeof clear;
37
46
  /** Focuses the field */
38
47
  focus: () => void | undefined;
48
+ /** Checks its rules and shows the result; resolves to whether they pass */
49
+ validate: () => Promise<boolean>;
50
+ /** Hides its validation error (until the next check) */
51
+ resetValidation: () => void;
39
52
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
40
53
  select: (place: MapSearchResult) => any;
54
+ blur: () => any;
41
55
  "update:modelValue": (place: MapSearchResult | null) => any;
42
56
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
43
57
  onSelect?: ((place: MapSearchResult) => any) | undefined;
58
+ onBlur?: (() => any) | undefined;
44
59
  "onUpdate:modelValue"?: ((place: MapSearchResult | null) => any) | undefined;
45
60
  }>, {
46
61
  modelValue: MapSearchResult | null;
@@ -54,8 +54,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
54
54
  onNavigation?: (() => any) | undefined;
55
55
  }>, {
56
56
  transparent: boolean;
57
- modelValue: string;
58
57
  loading: boolean;
58
+ modelValue: string;
59
59
  expanded: boolean;
60
60
  leadingIcon: string;
61
61
  clearable: boolean;