@fangzhongya/vue-archive 0.0.69 → 0.0.70

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 (65) hide show
  1. package/README.md +0 -2
  2. package/dist/index.css +2 -2
  3. package/dist/node/index.cjs +101593 -1279
  4. package/dist/node/index.d.cts +2 -0
  5. package/dist/node/index.d.ts +2 -0
  6. package/dist/node/index.js +101580 -1270
  7. package/dist/packages/components/use/code.cjs +15 -16
  8. package/dist/packages/components/use/code.d.ts +2 -2
  9. package/dist/packages/components/use/code.js +76 -74
  10. package/dist/packages/components/use/edit.cjs +11 -11
  11. package/dist/packages/components/use/edit.d.ts +1 -1
  12. package/dist/packages/components/use/edit.js +119 -94
  13. package/dist/packages/components/use/prettier.cjs +1 -0
  14. package/dist/packages/components/use/prettier.d.ts +1 -4
  15. package/dist/packages/components/use/prettier.js +40 -0
  16. package/dist/packages/components/use/retrie/array/index.vue.cjs +2 -2
  17. package/dist/packages/components/use/retrie/array/index.vue.js +17 -16
  18. package/dist/packages/components/use/retrie/function/index.vue.cjs +2 -2
  19. package/dist/packages/components/use/retrie/function/index.vue.js +22 -20
  20. package/dist/packages/components/use/retrie/input/codemirror/codemirror.cjs +3 -0
  21. package/dist/packages/components/use/retrie/input/codemirror/codemirror.js +58 -0
  22. package/dist/packages/components/use/retrie/input/codemirror/codemirror.vue.cjs +1 -0
  23. package/dist/packages/components/use/retrie/input/codemirror/codemirror.vue.js +62 -0
  24. package/dist/packages/components/use/retrie/input/codemirror/codemirror.vue3.cjs +1 -0
  25. package/dist/packages/components/use/retrie/input/codemirror/codemirror.vue3.js +5 -0
  26. package/dist/packages/components/use/retrie/input/editor/editor.cjs +3 -0
  27. package/dist/packages/components/use/retrie/input/{codemirror.d.ts → editor/editor.d.ts} +9 -9
  28. package/dist/packages/components/use/retrie/input/editor/editor.js +39 -0
  29. package/dist/packages/components/use/retrie/input/editor/editor.vue.cjs +1 -0
  30. package/dist/packages/components/use/retrie/input/editor/editor.vue.js +53 -0
  31. package/dist/packages/components/use/retrie/input/editor/editor.vue3.cjs +1 -0
  32. package/dist/packages/components/use/retrie/input/editor/editor.vue3.js +5 -0
  33. package/dist/packages/components/use/retrie/input/editor/init.cjs +1 -0
  34. package/dist/packages/components/use/retrie/input/editor/init.d.ts +1 -0
  35. package/dist/packages/components/use/retrie/input/editor/init.js +16 -0
  36. package/dist/packages/components/use/retrie/input/index.vue.cjs +1 -1
  37. package/dist/packages/components/use/retrie/input/index.vue.js +25 -15
  38. package/dist/packages/components/use/retrie/input/text.vue.cjs +1 -1
  39. package/dist/packages/components/use/retrie/input/text.vue.js +21 -13
  40. package/dist/packages/components/use/retrie/number/index.vue.cjs +1 -1
  41. package/dist/packages/components/use/retrie/number/index.vue.js +24 -22
  42. package/dist/packages/components/use/retrie/object/index.vue.cjs +2 -2
  43. package/dist/packages/components/use/retrie/object/index.vue.js +15 -14
  44. package/dist/packages/components/use/retrie/other/index.vue.cjs +1 -1
  45. package/dist/packages/components/use/retrie/other/index.vue.js +17 -16
  46. package/dist/packages/components/use/retrie/slot/index.vue.cjs +1 -1
  47. package/dist/packages/components/use/retrie/slot/index.vue.js +19 -17
  48. package/dist/packages/components/use/retrie/string/index.vue.cjs +1 -1
  49. package/dist/packages/components/use/retrie/string/index.vue.js +20 -18
  50. package/dist/packages/components/use/set-code.vue.cjs +1 -1
  51. package/dist/packages/components/use/set-code.vue.js +7 -7
  52. package/dist/packages/components/use/util.cjs +3 -3
  53. package/dist/packages/components/use/util.d.ts +10 -5
  54. package/dist/packages/components/use/util.js +88 -62
  55. package/dist/packages/config.d.ts +3 -1
  56. package/dist/packages/page/edit/index.vue2.cjs +1 -1
  57. package/dist/packages/page/edit/index.vue2.js +11 -7
  58. package/package.json +7 -6
  59. package/dist/packages/components/use/codemirror.cjs +0 -3
  60. package/dist/packages/components/use/codemirror.js +0 -31
  61. package/dist/packages/components/use/retrie/input/codemirror.vue.cjs +0 -1
  62. package/dist/packages/components/use/retrie/input/codemirror.vue.js +0 -43
  63. package/dist/packages/components/use/retrie/input/codemirror.vue2.cjs +0 -1
  64. package/dist/packages/components/use/retrie/input/codemirror.vue2.js +0 -4
  65. /package/dist/packages/components/use/{codemirror.d.ts → retrie/input/codemirror/codemirror.d.ts} +0 -0
@@ -1,10 +1,11 @@
1
1
  import * as d from "vue";
2
- import { defineComponent as y, defineAsyncComponent as h, resolveComponent as $, h as n, ref as k, onMounted as g } from "vue";
3
- import C from "./code.vue.js";
4
- import a from "./retrie/input/index.vue.js";
2
+ import { defineComponent as h, defineAsyncComponent as C, resolveComponent as g, h as t, ref as b, onMounted as j } from "vue";
3
+ import x from "./code.vue.js";
4
+ import v from "./retrie/input/index.vue.js";
5
5
  /* empty css */
6
- import x from "./effect.vue.js";
7
- const _ = y({
6
+ import H from "./effect.vue.js";
7
+ import { prettierHtml as $, prettierJs as k, prettierCss as V } from "./util.js";
8
+ const U = h({
8
9
  /**
9
10
  * @props {Stinrg} value 插入数据
10
11
  */
@@ -24,157 +25,181 @@ const _ = y({
24
25
  vueHtml: ""
25
26
  };
26
27
  },
27
- setup(m) {
28
- function v(s) {
29
- const l = document.getElementsByTagName("head")[0], c = "data-vite-dev-id", o = s + ".css", r = l.querySelector(`style[${c}="${o}"]`);
30
- if (r)
31
- return r;
28
+ setup(u) {
29
+ function f(o) {
30
+ const c = document.getElementsByTagName("head")[0], r = "data-vite-dev-id", s = o + ".css", l = c.querySelector(`style[${r}="${s}"]`);
31
+ if (l)
32
+ return l;
32
33
  {
33
34
  let e = document.createElement("style");
34
- return e.appendChild(document.createTextNode("")), e.setAttribute("type", "text/css"), e.setAttribute(c, o), l.appendChild(e), e;
35
+ return e.appendChild(document.createTextNode("")), e.setAttribute("type", "text/css"), e.setAttribute(r, s), c.appendChild(e), e;
35
36
  }
36
37
  }
37
- function u(s, l = "", c) {
38
- const o = [], r = m.value?.name;
38
+ async function a(o, c = "", r) {
39
+ const s = [], l = u.value?.name;
39
40
  let e = "";
40
- return Object.keys(d).forEach((p) => {
41
- l.includes(p + "(") && o.push(p);
42
- }), o.length > 0 && (e = `import { ${o.join(" , ")} } from 'vue';`), `<!--${r}-->
43
- <template>
44
- ${s}
45
- </template>
46
- <script>
47
- ${e}
41
+ Object.keys(d).forEach((y) => {
42
+ c.includes(y + "(") && s.push(y);
43
+ }), s.length > 0 && (e = `import { ${s.join(" , ")} } from 'vue';`);
44
+ let m = `<template>
45
+ ${o}
46
+ </template>`;
47
+ m = await $(m);
48
+ let p = `${e}
48
49
  export default {
49
50
  setup(props, ctx) {
50
- ${l}
51
+ ${c}
51
52
  }
52
- }
53
+ }`;
54
+ return p = await k(p), `<!--${l}-->
55
+ ${m}
56
+ <script>
57
+ ${p}
53
58
  <\/script>
54
59
  <style>
55
- ${c}
60
+ ${r}
56
61
  </style>
57
62
  `;
58
63
  }
59
- function i(s, l, c) {
64
+ function i(o, c, r) {
60
65
  try {
61
- const o = Object.keys(d);
66
+ const s = Object.keys(d);
62
67
  return new Function(
63
68
  "props",
64
69
  "ctx",
65
70
  "vue",
66
71
  ` "use strict";
67
- const { ${o.join(",")} } = vue;
68
- ${s}; `
69
- )(l, c, d);
70
- } catch (o) {
71
- console.error("Code block execution failed:", o);
72
+ const { ${s.join(",")} } = vue;
73
+ ${o}; `
74
+ )(c, r, d);
75
+ } catch (s) {
76
+ console.error("Code block execution failed:", s);
72
77
  }
73
78
  }
74
- const t = k(null);
75
- return g(() => {
76
- t.value = v(m.value?.key);
79
+ const n = b(null);
80
+ return j(() => {
81
+ n.value = f(u.value?.key);
77
82
  }), {
78
- getHmtlVue: u,
83
+ getHmtlVue: a,
79
84
  getCodeBlock: i,
80
- style: t
85
+ style: n
81
86
  };
82
87
  },
83
- render(m, v, u, i, t) {
84
- const s = u.value;
85
- let l = "div";
86
- s.component ? l = h(s.component) : s.name && (l = $(s.name));
87
- const c = {};
88
- c[s.name] = l;
89
- const o = () => {
90
- const e = i.getHmtlVue(t.template, t.script, t.style);
91
- t.vueHtml = e;
92
- }, r = () => {
93
- i.style.innerHTML = t.style, o();
88
+ render(u, f, a, i, n) {
89
+ const o = a.value || {};
90
+ let c = "div";
91
+ o.component ? c = C(o.component) : o.name && (c = g(o.name));
92
+ const r = {};
93
+ r[o.name] = c;
94
+ const s = async () => {
95
+ const e = await i.getHmtlVue(
96
+ n.template,
97
+ n.script,
98
+ n.style
99
+ );
100
+ n.vueHtml = e;
101
+ }, l = () => {
102
+ i.style.innerHTML = n.style, s();
94
103
  };
95
- return n(
104
+ return t(
96
105
  "div",
97
106
  {
98
107
  class: "code-edit"
99
108
  },
100
109
  [
101
- n(
110
+ t(
102
111
  "div",
103
112
  {
104
113
  class: "edit-effect use"
105
114
  },
106
115
  [
107
- n(
108
- x,
116
+ t(
117
+ H,
109
118
  {
110
119
  class: "use-component"
111
120
  },
112
121
  {
113
- default: () => n(
114
- y({
115
- components: c,
116
- setup(e, f) {
122
+ default: () => t(
123
+ h({
124
+ components: r,
125
+ setup(e, m) {
117
126
  return i.getCodeBlock(
118
- t.script,
127
+ n.script,
119
128
  e,
120
- f
129
+ m
121
130
  );
122
131
  },
123
- template: t.template
132
+ template: n.template || "<div></div>"
124
133
  })
125
134
  )
126
135
  }
127
136
  ),
128
- n(C, {
129
- html: t.vueHtml,
130
- name: s.name + "_edit",
131
- onRefresh: o
137
+ t(x, {
138
+ html: n.vueHtml,
139
+ name: o.name + "_edit",
140
+ onRefresh: s
132
141
  })
133
142
  ]
134
143
  ),
135
- n(
144
+ t(
136
145
  "div",
137
146
  {
138
147
  class: "edit-input"
139
148
  },
140
149
  [
141
- n(
150
+ t(
142
151
  "div",
143
152
  {
144
- onClick: r
153
+ class: "but-div",
154
+ onClick: l
145
155
  },
146
156
  "运行"
147
157
  ),
148
- n("div", {}, [
149
- n("div", {}, "template"),
150
- n(a, {
151
- check: (e) => e,
152
- modelValue: t.template,
153
- "onUpdate:modelValue": (e) => {
154
- t.template = e;
155
- }
156
- })
158
+ t("div", {}, [
159
+ t("div", {}, "template"),
160
+ t(
161
+ "div",
162
+ {},
163
+ t(v, {
164
+ format: "html",
165
+ check: (e) => e,
166
+ modelValue: n.template,
167
+ "onUpdate:modelValue": async (e) => {
168
+ n.template = await $(e);
169
+ }
170
+ })
171
+ )
157
172
  ]),
158
- n("div", {}, [
159
- n("div", {}, "script"),
160
- n("div", {}, "setup(props, ctx)"),
161
- n(a, {
162
- check: (e) => e,
163
- modelValue: t.script,
164
- "onUpdate:modelValue": (e) => {
165
- t.script = e;
166
- }
167
- })
173
+ t("div", {}, [
174
+ t("div", {}, "script"),
175
+ t("div", {}, "setup(props, ctx)"),
176
+ t(
177
+ "div",
178
+ {},
179
+ t(v, {
180
+ format: "js",
181
+ check: (e) => e,
182
+ modelValue: n.script,
183
+ "onUpdate:modelValue": async (e) => {
184
+ n.script = await k(e);
185
+ }
186
+ })
187
+ )
168
188
  ]),
169
- n("div", {}, [
170
- n("div", {}, "style"),
171
- n(a, {
172
- check: (e) => e,
173
- modelValue: t.style,
174
- "onUpdate:modelValue": (e) => {
175
- t.style = e;
176
- }
177
- })
189
+ t("div", {}, [
190
+ t("div", {}, "style"),
191
+ t(
192
+ "div",
193
+ {},
194
+ t(v, {
195
+ format: "css",
196
+ check: (e) => e,
197
+ modelValue: n.style,
198
+ "onUpdate:modelValue": async (e) => {
199
+ n.style = await V(e);
200
+ }
201
+ })
202
+ )
178
203
  ])
179
204
  ]
180
205
  )
@@ -183,5 +208,5 @@ ${c}
183
208
  }
184
209
  });
185
210
  export {
186
- _ as default
211
+ U as default
187
212
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("prettier"),r=require("prettier/plugins/html"),e=require("prettier/plugins/postcss"),t=require("prettier/plugins/typescript"),n=require("prettier/plugins/babel"),s=require("prettier/plugins/estree"),c={js:{parser:"babel",plugins:[n,s]},ts:{parser:"typescript",plugins:[t,s]},css:{parser:"css",plugins:[e]},html:{parser:"html",plugins:[r]},json:{parser:"json5",plugins:[]},vue:{parser:"vue",plugins:[e,r,n,t,s]}};async function p(i,o){return await u.format(i,{...c[o]})}exports.getFormat=p;
@@ -1,4 +1 @@
1
- //扩展EvenetTarget类型
2
- declare interface EventTarget {
3
- value: string;
4
- }
1
+ export declare function getFormat(text: string, type: string): Promise<string>;
@@ -0,0 +1,40 @@
1
+ import { format as e } from "prettier";
2
+ import s from "prettier/plugins/html";
3
+ import t from "prettier/plugins/postcss";
4
+ import o from "prettier/plugins/typescript";
5
+ import p from "prettier/plugins/babel";
6
+ import r from "prettier/plugins/estree";
7
+ const n = {
8
+ js: {
9
+ parser: "babel",
10
+ plugins: [p, r]
11
+ },
12
+ ts: {
13
+ parser: "typescript",
14
+ plugins: [o, r]
15
+ },
16
+ css: {
17
+ parser: "css",
18
+ plugins: [t]
19
+ },
20
+ html: {
21
+ parser: "html",
22
+ plugins: [s]
23
+ },
24
+ json: {
25
+ parser: "json5",
26
+ plugins: []
27
+ },
28
+ vue: {
29
+ parser: "vue",
30
+ plugins: [t, s, p, o, r]
31
+ }
32
+ };
33
+ async function v(m, i) {
34
+ return await e(m, {
35
+ ...n[i]
36
+ });
37
+ }
38
+ export {
39
+ v as getFormat
40
+ };
@@ -1,3 +1,3 @@
1
- "use strict";const n=require("vue"),m=require("../input/index.vue.cjs");;/* empty css */const f=require("../../util.cjs"),d={class:"form-array"},p=n.defineComponent({__name:"index",props:{modelValue:{type:null}},emits:["value","error"],setup(i,{emit:s}){const u=i,o=s,l=n.ref("");n.watch(()=>u.modelValue,()=>{let e=u.modelValue;l.value=a(e)||e},{immediate:!0});function c(e){return new Function("",`{return ${e}}`)}function a(e){let r;if(e)try{let t=e;typeof e=="string"?(t=c(e)(),r=f.prettierArrFormat(e)):r=JSON.stringify(e),t instanceof Array?(o("value",t,r),o("error",!1)):(o("error",!0),console.log("error","类型不匹配"))}catch(t){o("error",!0),console.log("error",t)}else r=`[
1
+ "use strict";const n=require("vue"),m=require("../input/index.vue.cjs");;/* empty css */const f=require("../../util.cjs"),d={class:"form-array"},p=n.defineComponent({__name:"index",props:{modelValue:{type:null}},emits:["value","error"],setup(i,{emit:s}){const u=i,o=s,l=n.ref("");n.watch(()=>u.modelValue,async()=>{let e=u.modelValue;l.value=await a(e)||e},{immediate:!0});function c(e){return new Function("",`{return ${e}}`)}async function a(e){let r;if(e)try{let t=e;typeof e=="string"?(t=c(e)(),r=await f.prettierArrFormat(e)):r=JSON.stringify(e),t instanceof Array?(o("value",t,r),o("error",!1)):(o("error",!0),console.log("error","类型不匹配"))}catch(t){o("error",!0),console.log("error",t)}else r=`[
2
2
 
3
- ]`,o("value",void 0,r),o("error",!1);return r}return(e,r)=>(n.openBlock(),n.createElementBlock("div",d,[n.createVNode(m,{modelValue:l.value,"onUpdate:modelValue":r[0]||(r[0]=t=>l.value=t),check:a},null,8,["modelValue"])]))}});module.exports=p;
3
+ ]`,o("value",void 0,r),o("error",!1);return r}return(e,r)=>(n.openBlock(),n.createElementBlock("div",d,[n.createVNode(m,{format:"json",modelValue:l.value,"onUpdate:modelValue":r[0]||(r[0]=t=>l.value=t),check:a},null,8,["modelValue"])]))}});module.exports=p;
@@ -1,8 +1,8 @@
1
- import { defineComponent as c, ref as f, watch as s, createElementBlock as p, openBlock as d, createVNode as v } from "vue";
2
- import _ from "../input/index.vue.js";
1
+ import { defineComponent as c, ref as s, watch as f, createElementBlock as p, openBlock as d, createVNode as v } from "vue";
2
+ import y from "../input/index.vue.js";
3
3
  /* empty css */
4
- import { prettierArrFormat as V } from "../../util.js";
5
- const g = { class: "form-array" }, A = /* @__PURE__ */ c({
4
+ import { prettierArrFormat as _ } from "../../util.js";
5
+ const V = { class: "form-array" }, A = /* @__PURE__ */ c({
6
6
  __name: "index",
7
7
  props: {
8
8
  modelValue: {
@@ -11,12 +11,12 @@ const g = { class: "form-array" }, A = /* @__PURE__ */ c({
11
11
  },
12
12
  emits: ["value", "error"],
13
13
  setup(u, { emit: i }) {
14
- const n = u, t = i, l = f("");
15
- s(
16
- () => n.modelValue,
17
- () => {
18
- let e = n.modelValue;
19
- l.value = a(e) || e;
14
+ const l = u, t = i, n = s("");
15
+ f(
16
+ () => l.modelValue,
17
+ async () => {
18
+ let e = l.modelValue;
19
+ n.value = await a(e) || e;
20
20
  },
21
21
  {
22
22
  immediate: !0
@@ -25,12 +25,12 @@ const g = { class: "form-array" }, A = /* @__PURE__ */ c({
25
25
  function m(e) {
26
26
  return new Function("", `{return ${e}}`);
27
27
  }
28
- function a(e) {
28
+ async function a(e) {
29
29
  let r;
30
30
  if (e)
31
31
  try {
32
32
  let o = e;
33
- typeof e == "string" ? (o = m(e)(), r = V(e)) : r = JSON.stringify(e), o instanceof Array ? (t("value", o, r), t("error", !1)) : (t("error", !0), console.log("error", "类型不匹配"));
33
+ typeof e == "string" ? (o = m(e)(), r = await _(e)) : r = JSON.stringify(e), o instanceof Array ? (t("value", o, r), t("error", !1)) : (t("error", !0), console.log("error", "类型不匹配"));
34
34
  } catch (o) {
35
35
  t("error", !0), console.log("error", o);
36
36
  }
@@ -40,10 +40,11 @@ const g = { class: "form-array" }, A = /* @__PURE__ */ c({
40
40
  ]`, t("value", void 0, r), t("error", !1);
41
41
  return r;
42
42
  }
43
- return (e, r) => (d(), p("div", g, [
44
- v(_, {
45
- modelValue: l.value,
46
- "onUpdate:modelValue": r[0] || (r[0] = (o) => l.value = o),
43
+ return (e, r) => (d(), p("div", V, [
44
+ v(y, {
45
+ format: "json",
46
+ modelValue: n.value,
47
+ "onUpdate:modelValue": r[0] || (r[0] = (o) => n.value = o),
47
48
  check: a
48
49
  }, null, 8, ["modelValue"])
49
50
  ]));
@@ -1,3 +1,3 @@
1
- "use strict";const o=require("vue"),m=require("../input/index.vue.cjs");;/* empty css */const v=require("@fangzhongya/utils/basic/string/toFunction"),d={class:"form-function"},f=o.defineComponent({__name:"index",props:{modelValue:{type:null},list:{type:Array},config:{type:Object,default(){return{label:"label",prop:"prop"}}}},emits:["value","error"],setup(i,{emit:s}){const l=i,a=o.computed(()=>l.list?.map(e=>e[l.config.prop])||[]),n=s,u=o.ref("");o.watch(()=>l.modelValue,()=>{let e=l.modelValue;u.value=c(e)||e},{immediate:!0});function p(){return`(${a.value.join(", ")}) `}function c(e){let r;if(e)try{let t=v.toFunction(e);t&&(t(...a.value),n("value",t,e),n("error",!1))}catch(t){n("error",!0),console.log("error",t)}else r=`()=> {
1
+ "use strict";const o=require("vue"),m=require("../input/index.vue.cjs");;/* empty css */const v=require("../../util.cjs"),d=require("@fangzhongya/utils/basic/string/toFunction"),f={class:"form-function"},_=o.defineComponent({__name:"index",props:{modelValue:{type:null},list:{type:Array},config:{type:Object,default(){return{label:"label",prop:"prop"}}}},emits:["value","error"],setup(i,{emit:s}){const u=i,a=o.computed(()=>u.list?.map(e=>e[u.config.prop])||[]),n=s,l=o.ref("");o.watch(()=>u.modelValue,async()=>{let e=u.modelValue;l.value=await c(e)||e},{immediate:!0});function p(){return`(${a.value.join(", ")}) `}async function c(e){let r;if(e)try{let t=d.toFunction(e);t&&(t(...a.value),e=await v.prettierFunFormat(e),n("value",t,e),n("error",!1))}catch(t){n("error",!0),console.log("error",t)}else r=`()=> {
2
2
 
3
- }`,n("value",void 0,p()+r),n("error",!1);return r}return(e,r)=>(o.openBlock(),o.createElementBlock("div",d,[o.createVNode(m,{modelValue:u.value,"onUpdate:modelValue":r[0]||(r[0]=t=>u.value=t),check:c},null,8,["modelValue"])]))}});module.exports=f;
3
+ }`,n("value",void 0,p()+r),n("error",!1);return r}return(e,r)=>(o.openBlock(),o.createElementBlock("div",f,[o.createVNode(m,{format:"js",modelValue:l.value,"onUpdate:modelValue":r[0]||(r[0]=t=>l.value=t),check:c},null,8,["modelValue"])]))}});module.exports=_;
@@ -1,8 +1,9 @@
1
- import { defineComponent as p, computed as s, ref as f, watch as d, createElementBlock as v, openBlock as _, createVNode as V } from "vue";
2
- import y from "../input/index.vue.js";
1
+ import { defineComponent as p, computed as f, ref as s, watch as d, createElementBlock as v, openBlock as _, createVNode as y } from "vue";
2
+ import V from "../input/index.vue.js";
3
3
  /* empty css */
4
- import { toFunction as g } from "@fangzhongya/utils/basic/string/toFunction";
5
- const b = { class: "form-function" }, B = /* @__PURE__ */ p({
4
+ import { prettierFunFormat as g } from "../../util.js";
5
+ import { toFunction as b } from "@fangzhongya/utils/basic/string/toFunction";
6
+ const h = { class: "form-function" }, B = /* @__PURE__ */ p({
6
7
  __name: "index",
7
8
  props: {
8
9
  modelValue: {
@@ -22,40 +23,41 @@ const b = { class: "form-function" }, B = /* @__PURE__ */ p({
22
23
  }
23
24
  },
24
25
  emits: ["value", "error"],
25
- setup(m, { emit: c }) {
26
- const l = m, a = s(() => l.list?.map((e) => e[l.config.prop]) || []), t = c, n = f("");
26
+ setup(m, { emit: i }) {
27
+ const a = m, n = f(() => a.list?.map((e) => e[a.config.prop]) || []), t = i, l = s("");
27
28
  d(
28
- () => l.modelValue,
29
- () => {
30
- let e = l.modelValue;
31
- n.value = u(e) || e;
29
+ () => a.modelValue,
30
+ async () => {
31
+ let e = a.modelValue;
32
+ l.value = await u(e) || e;
32
33
  },
33
34
  {
34
35
  immediate: !0
35
36
  }
36
37
  );
37
- function i() {
38
- return `(${a.value.join(", ")}) `;
38
+ function c() {
39
+ return `(${n.value.join(", ")}) `;
39
40
  }
40
- function u(e) {
41
+ async function u(e) {
41
42
  let r;
42
43
  if (e)
43
44
  try {
44
- let o = g(e);
45
- o && (o(...a.value), t("value", o, e), t("error", !1));
45
+ let o = b(e);
46
+ o && (o(...n.value), e = await g(e), t("value", o, e), t("error", !1));
46
47
  } catch (o) {
47
48
  t("error", !0), console.log("error", o);
48
49
  }
49
50
  else
50
51
  r = `()=> {
51
52
 
52
- }`, t("value", void 0, i() + r), t("error", !1);
53
+ }`, t("value", void 0, c() + r), t("error", !1);
53
54
  return r;
54
55
  }
55
- return (e, r) => (_(), v("div", b, [
56
- V(y, {
57
- modelValue: n.value,
58
- "onUpdate:modelValue": r[0] || (r[0] = (o) => n.value = o),
56
+ return (e, r) => (_(), v("div", h, [
57
+ y(V, {
58
+ format: "js",
59
+ modelValue: l.value,
60
+ "onUpdate:modelValue": r[0] || (r[0] = (o) => l.value = o),
59
61
  check: u
60
62
  }, null, 8, ["modelValue"])
61
63
  ]));
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@codemirror/view"),u=require("@codemirror/lang-javascript"),a=require("@codemirror/lang-html"),g=require("@codemirror/lang-json"),f=require("@codemirror/lang-css"),l=require("@codemirror/state"),d=require("codemirror"),i=(e,{onUpdate:t,onChange:n,onFocus:o,onBlur:c})=>l.EditorState.create({doc:`
2
+
3
+ `,extensions:[...e,d.basicSetup,s.EditorView.updateListener.of(r=>{t&&t(r),r.docChanged&&n&&n(r.state.doc.toString(),r),r.focusChanged&&(r.view.hasFocus?o&&o(r):c&&c(r))})]});function E(e,t){return new s.EditorView({state:i([u.javascript()],t),parent:e})}function q(e,t){return new s.EditorView({state:i([a.html()],t),parent:e})}function S(e,t){return new s.EditorView({state:i([g.json()],t),parent:e})}function m(e,t){return new s.EditorView({state:i([f.css()],t),parent:e})}exports.createEditorState=i;exports.getCss=m;exports.getHtml=q;exports.getJs=E;exports.getJson=S;
@@ -0,0 +1,58 @@
1
+ import { EditorView as e } from "@codemirror/view";
2
+ import { javascript as m } from "@codemirror/lang-javascript";
3
+ import { html as c } from "@codemirror/lang-html";
4
+ import { json as u } from "@codemirror/lang-json";
5
+ import { css as a } from "@codemirror/lang-css";
6
+ import { EditorState as g } from "@codemirror/state";
7
+ import { basicSetup as S } from "codemirror";
8
+ const i = (r, { onUpdate: t, onChange: n, onFocus: s, onBlur: f }) => g.create({
9
+ doc: `
10
+
11
+ `,
12
+ extensions: [
13
+ ...r,
14
+ S,
15
+ e.updateListener.of((o) => {
16
+ t && t(o), o.docChanged && n && n(o.state.doc.toString(), o), o.focusChanged && (o.view.hasFocus ? s && s(o) : f && f(o));
17
+ })
18
+ ]
19
+ });
20
+ function J(r, t) {
21
+ return new e({
22
+ // 状态
23
+ state: i([m()], t),
24
+ // 绑定元素
25
+ parent: r
26
+ });
27
+ }
28
+ function b(r, t) {
29
+ return new e({
30
+ // 状态
31
+ state: i([c()], t),
32
+ // 绑定元素
33
+ parent: r
34
+ });
35
+ }
36
+ function d(r, t) {
37
+ return new e({
38
+ // 状态
39
+ state: i([u()], t),
40
+ // 绑定元素
41
+ parent: r
42
+ });
43
+ }
44
+ function H(r, t) {
45
+ return new e({
46
+ // 状态
47
+ state: i([a()], t),
48
+ // 绑定元素
49
+ parent: r
50
+ });
51
+ }
52
+ export {
53
+ i as createEditorState,
54
+ H as getCss,
55
+ b as getHtml,
56
+ J as getJs,
57
+ d as getJson
58
+ };
@@ -0,0 +1 @@
1
+ "use strict";const e=require("vue"),p=require("../../../../../directives/adjust/index.cjs"),n=require("./codemirror.cjs"),h={class:"codemirror-div"},_=e.defineComponent({__name:"codemirror",props:{modelValue:{type:null},format:{type:String},check:{type:Function,default(){return""}}},emits:["update:modelValue"],setup(u,{emit:m}){const t=u,f=m,o=e.ref(),r=e.ref();function s(a){const c=a.view,l=c.state.doc,v=l.toString().trim();let i=t.check(v);i&&(c.dispatch({changes:{from:0,to:l.length,insert:i}}),f("update:modelValue",i))}function d(){t.format==="js"||t.format==="ts"?r.value=n.getJs(o.value,{onBlur:s}):t.format==="css"||t.format==="scss"?r.value=n.getCss(o.value,{onBlur:s}):t.format==="html"||t.format==="vue"?r.value=n.getHtml(o.value,{onBlur:s}):t.format==="json"&&(r.value=n.getJson(o.value,{onBlur:s}))}return e.onMounted(()=>{d()}),(a,c)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",h,[e.createElementVNode("div",{class:"codemirror-code",ref_key:"refText",ref:o},null,512)])),[[e.unref(p),{bottom:{}}]])}});module.exports=_;
@@ -0,0 +1,62 @@
1
+ import { defineComponent as p, ref as i, onMounted as v, withDirectives as h, createElementBlock as _, openBlock as g, createElementVNode as k, unref as x } from "vue";
2
+ import y from "../../../../../directives/adjust/index.js";
3
+ import { getJs as V, getCss as j, getHtml as w, getJson as B } from "./codemirror.js";
4
+ const C = { class: "codemirror-div" }, S = /* @__PURE__ */ p({
5
+ __name: "codemirror",
6
+ props: {
7
+ modelValue: {
8
+ type: null
9
+ },
10
+ format: {
11
+ type: String
12
+ },
13
+ check: {
14
+ type: Function,
15
+ default() {
16
+ return "";
17
+ }
18
+ }
19
+ },
20
+ emits: ["update:modelValue"],
21
+ setup(l, { emit: m }) {
22
+ const e = l, f = m, t = i(), o = i();
23
+ function r(c) {
24
+ const s = c.view, a = s.state.doc, d = a.toString().trim();
25
+ let n = e.check(d);
26
+ n && (s.dispatch({
27
+ changes: {
28
+ from: 0,
29
+ to: a.length,
30
+ insert: n
31
+ }
32
+ }), f("update:modelValue", n));
33
+ }
34
+ function u() {
35
+ e.format === "js" || e.format === "ts" ? o.value = V(t.value, {
36
+ onBlur: r
37
+ }) : e.format === "css" || e.format === "scss" ? o.value = j(t.value, {
38
+ onBlur: r
39
+ }) : e.format === "html" || e.format === "vue" ? o.value = w(t.value, {
40
+ onBlur: r
41
+ }) : e.format === "json" && (o.value = B(t.value, {
42
+ onBlur: r
43
+ }));
44
+ }
45
+ return v(() => {
46
+ u();
47
+ }), (c, s) => h((g(), _("div", C, [
48
+ k("div", {
49
+ class: "codemirror-code",
50
+ ref_key: "refText",
51
+ ref: t
52
+ }, null, 512)
53
+ ])), [
54
+ [x(y), {
55
+ bottom: {}
56
+ }]
57
+ ]);
58
+ }
59
+ });
60
+ export {
61
+ S as default
62
+ };
@@ -0,0 +1 @@
1
+ "use strict";const e=require("./codemirror.vue.cjs");;/* empty css */module.exports=e;
@@ -0,0 +1,5 @@
1
+ import o from "./codemirror.vue.js";
2
+ /* empty css */
3
+ export {
4
+ o as default
5
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("monaco-editor/esm/vs/editor/editor.api"),n={theme:"vs",value:`
2
+
3
+ `,lineNumbers:"on",automaticLayout:!0};function r(e){return t.editor.create(e,{...n,language:"typescript"})}function o(e){return t.editor.create(e,{...n,language:"html"})}function u(e){return t.editor.create(e,{...n,language:"json"})}function a(e){return t.editor.create(e,{...n,language:"css"})}exports.getCss=a;exports.getHtml=o;exports.getJs=r;exports.getJson=u;