@web-utils/component 3.7.1 → 3.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.
@@ -1,449 +1,15 @@
1
- import L from "codemirror";
1
+ import i from "codemirror";
2
2
  import "codemirror/lib/codemirror.css";
3
3
  import "codemirror/theme/idea.css";
4
4
  import "codemirror/mode/javascript/javascript";
5
5
  import "codemirror/addon/edit/matchbrackets";
6
- import "codemirror/addon/lint/javascript-lint";
7
- import "codemirror/addon/lint/json-lint";
8
- import "codemirror/addon/lint/lint";
9
- import "codemirror/addon/lint/lint.css";
10
- import "codemirror/addon/fold/foldcode";
11
- import "codemirror/addon/fold/foldgutter";
12
6
  import "codemirror/addon/fold/foldgutter.css";
7
+ import "codemirror/addon/fold/foldcode";
13
8
  import "codemirror/addon/fold/brace-fold";
14
9
  import "codemirror/addon/fold/comment-fold";
15
- import { n as F } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
16
- var P = function() {
17
- var i = {}, l = function() {
18
- var m = {
19
- trace: function() {
20
- },
21
- yy: {},
22
- symbols_: {
23
- error: 2,
24
- JSONString: 3,
25
- STRING: 4,
26
- JSONNumber: 5,
27
- NUMBER: 6,
28
- JSONNullLiteral: 7,
29
- NULL: 8,
30
- JSONBooleanLiteral: 9,
31
- TRUE: 10,
32
- FALSE: 11,
33
- JSONText: 12,
34
- JSONValue: 13,
35
- EOF: 14,
36
- JSONObject: 15,
37
- JSONArray: 16,
38
- "{": 17,
39
- "}": 18,
40
- JSONMemberList: 19,
41
- JSONMember: 20,
42
- ":": 21,
43
- ",": 22,
44
- "[": 23,
45
- "]": 24,
46
- JSONElementList: 25,
47
- $accept: 0,
48
- $end: 1
49
- },
50
- terminals_: {
51
- 2: "error",
52
- 4: "STRING",
53
- 6: "NUMBER",
54
- 8: "NULL",
55
- 10: "TRUE",
56
- 11: "FALSE",
57
- 14: "EOF",
58
- 17: "{",
59
- 18: "}",
60
- 21: ":",
61
- 22: ",",
62
- 23: "[",
63
- 24: "]"
64
- },
65
- productions_: [
66
- 0,
67
- [3, 1],
68
- [5, 1],
69
- [7, 1],
70
- [9, 1],
71
- [9, 1],
72
- [12, 2],
73
- [13, 1],
74
- [13, 1],
75
- [13, 1],
76
- [13, 1],
77
- [13, 1],
78
- [13, 1],
79
- [15, 2],
80
- [15, 3],
81
- [20, 3],
82
- [19, 1],
83
- [19, 3],
84
- [16, 2],
85
- [16, 3],
86
- [25, 1],
87
- [25, 3]
88
- ],
89
- performAction: function(u, t, n, p, s, e, o) {
90
- var r = e.length - 1;
91
- switch (s) {
92
- case 1:
93
- this.$ = u.replace(/\\(\\|")/g, "$1").replace(/\\n/g, `
94
- `).replace(/\\r/g, "\r").replace(/\\t/g, " ").replace(/\\v/g, "\v").replace(/\\f/g, "\f").replace(/\\b/g, "\b");
95
- break;
96
- case 2:
97
- this.$ = Number(u);
98
- break;
99
- case 3:
100
- this.$ = null;
101
- break;
102
- case 4:
103
- this.$ = !0;
104
- break;
105
- case 5:
106
- this.$ = !1;
107
- break;
108
- case 6:
109
- return this.$ = e[r - 1];
110
- case 13:
111
- this.$ = {};
112
- break;
113
- case 14:
114
- this.$ = e[r - 1];
115
- break;
116
- case 15:
117
- this.$ = [e[r - 2], e[r]];
118
- break;
119
- case 16:
120
- this.$ = {}, this.$[e[r][0]] = e[r][1];
121
- break;
122
- case 17:
123
- this.$ = e[r - 2], e[r - 2][e[r][0]] = e[r][1];
124
- break;
125
- case 18:
126
- this.$ = [];
127
- break;
128
- case 19:
129
- this.$ = e[r - 1];
130
- break;
131
- case 20:
132
- this.$ = [e[r]];
133
- break;
134
- case 21:
135
- this.$ = e[r - 2], e[r - 2].push(e[r]);
136
- }
137
- },
138
- table: [
139
- {
140
- 3: 5,
141
- 4: [1, 12],
142
- 5: 6,
143
- 6: [1, 13],
144
- 7: 3,
145
- 8: [1, 9],
146
- 9: 4,
147
- 10: [1, 10],
148
- 11: [1, 11],
149
- 12: 1,
150
- 13: 2,
151
- 15: 7,
152
- 16: 8,
153
- 17: [1, 14],
154
- 23: [1, 15]
155
- },
156
- { 1: [3] },
157
- { 14: [1, 16] },
158
- { 14: [2, 7], 18: [2, 7], 22: [2, 7], 24: [2, 7] },
159
- { 14: [2, 8], 18: [2, 8], 22: [2, 8], 24: [2, 8] },
160
- { 14: [2, 9], 18: [2, 9], 22: [2, 9], 24: [2, 9] },
161
- { 14: [2, 10], 18: [2, 10], 22: [2, 10], 24: [2, 10] },
162
- { 14: [2, 11], 18: [2, 11], 22: [2, 11], 24: [2, 11] },
163
- { 14: [2, 12], 18: [2, 12], 22: [2, 12], 24: [2, 12] },
164
- { 14: [2, 3], 18: [2, 3], 22: [2, 3], 24: [2, 3] },
165
- { 14: [2, 4], 18: [2, 4], 22: [2, 4], 24: [2, 4] },
166
- { 14: [2, 5], 18: [2, 5], 22: [2, 5], 24: [2, 5] },
167
- { 14: [2, 1], 18: [2, 1], 21: [2, 1], 22: [2, 1], 24: [2, 1] },
168
- { 14: [2, 2], 18: [2, 2], 22: [2, 2], 24: [2, 2] },
169
- { 3: 20, 4: [1, 12], 18: [1, 17], 19: 18, 20: 19 },
170
- {
171
- 3: 5,
172
- 4: [1, 12],
173
- 5: 6,
174
- 6: [1, 13],
175
- 7: 3,
176
- 8: [1, 9],
177
- 9: 4,
178
- 10: [1, 10],
179
- 11: [1, 11],
180
- 13: 23,
181
- 15: 7,
182
- 16: 8,
183
- 17: [1, 14],
184
- 23: [1, 15],
185
- 24: [1, 21],
186
- 25: 22
187
- },
188
- { 1: [2, 6] },
189
- { 14: [2, 13], 18: [2, 13], 22: [2, 13], 24: [2, 13] },
190
- { 18: [1, 24], 22: [1, 25] },
191
- { 18: [2, 16], 22: [2, 16] },
192
- { 21: [1, 26] },
193
- { 14: [2, 18], 18: [2, 18], 22: [2, 18], 24: [2, 18] },
194
- { 22: [1, 28], 24: [1, 27] },
195
- { 22: [2, 20], 24: [2, 20] },
196
- { 14: [2, 14], 18: [2, 14], 22: [2, 14], 24: [2, 14] },
197
- { 3: 20, 4: [1, 12], 20: 29 },
198
- {
199
- 3: 5,
200
- 4: [1, 12],
201
- 5: 6,
202
- 6: [1, 13],
203
- 7: 3,
204
- 8: [1, 9],
205
- 9: 4,
206
- 10: [1, 10],
207
- 11: [1, 11],
208
- 13: 30,
209
- 15: 7,
210
- 16: 8,
211
- 17: [1, 14],
212
- 23: [1, 15]
213
- },
214
- { 14: [2, 19], 18: [2, 19], 22: [2, 19], 24: [2, 19] },
215
- {
216
- 3: 5,
217
- 4: [1, 12],
218
- 5: 6,
219
- 6: [1, 13],
220
- 7: 3,
221
- 8: [1, 9],
222
- 9: 4,
223
- 10: [1, 10],
224
- 11: [1, 11],
225
- 13: 31,
226
- 15: 7,
227
- 16: 8,
228
- 17: [1, 14],
229
- 23: [1, 15]
230
- },
231
- { 18: [2, 17], 22: [2, 17] },
232
- { 18: [2, 15], 22: [2, 15] },
233
- { 22: [2, 21], 24: [2, 21] }
234
- ],
235
- defaultActions: { 16: [2, 6] },
236
- parseError: function(u, t) {
237
- throw new Error(u);
238
- },
239
- parse: function(u) {
240
- function t(f) {
241
- s.length = s.length - 2 * f, e.length = e.length - f, o.length = o.length - f;
242
- }
243
- function n() {
244
- var f;
245
- return f = p.lexer.lex() || 1, typeof f != "number" && (f = p.symbols_[f] || f), f;
246
- }
247
- var p = this, s = [0], e = [null], o = [], r = this.table, v = "", d = 0, N = 0, _ = 0, $ = 2, J = 1;
248
- this.lexer.setInput(u), this.lexer.yy = this.yy, this.yy.lexer = this.lexer, typeof this.lexer.yylloc == "undefined" && (this.lexer.yylloc = {});
249
- var b = this.lexer.yylloc;
250
- o.push(b), typeof this.yy.parseError == "function" && (this.parseError = this.yy.parseError);
251
- for (var h, S, a, c, w, g = {}, k, y, A, E; ; ) {
252
- if (a = s[s.length - 1], this.defaultActions[a] ? c = this.defaultActions[a] : (h == null && (h = n()), c = r[a] && r[a][h]), typeof c == "undefined" || !c.length || !c[0]) {
253
- if (!_) {
254
- E = [];
255
- for (k in r[a]) this.terminals_[k] && k > 2 && E.push("'" + this.terminals_[k] + "'");
256
- var x = "";
257
- this.lexer.showPosition ? x = "Parse error on line " + (d + 1) + `:
258
- ` + this.lexer.showPosition() + `
259
- Expecting ` + E.join(", ") + ", got '" + this.terminals_[h] + "'" : x = "Parse error on line " + (d + 1) + ": Unexpected " + (h == 1 ? "end of input" : "'" + (this.terminals_[h] || h) + "'"), this.parseError(x, {
260
- text: this.lexer.match,
261
- token: this.terminals_[h] || h,
262
- line: this.lexer.yylineno,
263
- loc: b,
264
- expected: E
265
- });
266
- }
267
- if (_ == 3) {
268
- if (h == J) throw new Error(x || "Parsing halted.");
269
- N = this.lexer.yyleng, v = this.lexer.yytext, d = this.lexer.yylineno, b = this.lexer.yylloc, h = n();
270
- }
271
- for (; !($.toString() in r[a]); ) {
272
- if (a == 0) throw new Error(x || "Parsing halted.");
273
- t(1), a = s[s.length - 1];
274
- }
275
- S = h, h = $, a = s[s.length - 1], c = r[a] && r[a][$], _ = 3;
276
- }
277
- if (c[0] instanceof Array && c.length > 1) throw new Error("Parse Error: multiple actions possible at state: " + a + ", token: " + h);
278
- switch (c[0]) {
279
- case 1:
280
- s.push(h), e.push(this.lexer.yytext), o.push(this.lexer.yylloc), s.push(c[1]), h = null, S ? (h = S, S = null) : (N = this.lexer.yyleng, v = this.lexer.yytext, d = this.lexer.yylineno, b = this.lexer.yylloc, _ > 0 && _--);
281
- break;
282
- case 2:
283
- if (y = this.productions_[c[1]][1], g.$ = e[e.length - y], g._$ = {
284
- first_line: o[o.length - (y || 1)].first_line,
285
- last_line: o[o.length - 1].last_line,
286
- first_column: o[o.length - (y || 1)].first_column,
287
- last_column: o[o.length - 1].last_column
288
- }, w = this.performAction.call(g, v, N, d, this.yy, c[1], e, o), typeof w != "undefined") return w;
289
- y && (s = s.slice(0, -1 * y * 2), e = e.slice(0, -1 * y), o = o.slice(0, -1 * y)), s.push(this.productions_[c[1]][0]), e.push(g.$), o.push(g._$), A = r[s[s.length - 2]][s[s.length - 1]], s.push(A);
290
- break;
291
- case 3:
292
- return !0;
293
- }
294
- }
295
- return !0;
296
- }
297
- }, I = function() {
298
- var u = {
299
- EOF: 1,
300
- parseError: function(t, n) {
301
- if (!this.yy.parseError) throw new Error(t);
302
- this.yy.parseError(t, n);
303
- },
304
- setInput: function(t) {
305
- return this._input = t, this._more = this._less = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0 }, this;
306
- },
307
- input: function() {
308
- var t = this._input[0];
309
- this.yytext += t, this.yyleng++, this.match += t, this.matched += t;
310
- var n = t.match(/\n/);
311
- return n && this.yylineno++, this._input = this._input.slice(1), t;
312
- },
313
- unput: function(t) {
314
- return this._input = t + this._input, this;
315
- },
316
- more: function() {
317
- return this._more = !0, this;
318
- },
319
- less: function(t) {
320
- this._input = this.match.slice(t) + this._input;
321
- },
322
- pastInput: function() {
323
- var t = this.matched.substr(0, this.matched.length - this.match.length);
324
- return (t.length > 20 ? "..." : "") + t.substr(-20).replace(/\n/g, "");
325
- },
326
- upcomingInput: function() {
327
- var t = this.match;
328
- return t.length < 20 && (t += this._input.substr(0, 20 - t.length)), (t.substr(0, 20) + (t.length > 20 ? "..." : "")).replace(/\n/g, "");
329
- },
330
- showPosition: function() {
331
- var t = this.pastInput(), n = new Array(t.length + 1).join("-");
332
- return t + this.upcomingInput() + `
333
- ` + n + "^";
334
- },
335
- next: function() {
336
- if (this.done) return this.EOF;
337
- this._input || (this.done = !0);
338
- var t, n, p, s, e;
339
- this._more || (this.yytext = "", this.match = "");
340
- for (var o = this._currentRules(), r = 0; r < o.length && (p = this._input.match(this.rules[o[r]]), !(p && (!n || p[0].length > n[0].length) && (n = p, s = r, !this.options.flex))); r++)
341
- ;
342
- if (n)
343
- return e = n[0].match(/\n.*/g), e && (this.yylineno += e.length), this.yylloc = {
344
- first_line: this.yylloc.last_line,
345
- last_line: this.yylineno + 1,
346
- first_column: this.yylloc.last_column,
347
- last_column: e ? e[e.length - 1].length - 1 : this.yylloc.last_column + n[0].length
348
- }, this.yytext += n[0], this.match += n[0], this.yyleng = this.yytext.length, this._more = !1, this._input = this._input.slice(n[0].length), this.matched += n[0], t = this.performAction.call(this, this.yy, this, o[s], this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), t || void 0;
349
- if (this._input === "") return this.EOF;
350
- this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
351
- ` + this.showPosition(), {
352
- text: "",
353
- token: null,
354
- line: this.yylineno
355
- });
356
- },
357
- lex: function() {
358
- var t = this.next();
359
- return typeof t != "undefined" ? t : this.lex();
360
- },
361
- begin: function(t) {
362
- this.conditionStack.push(t);
363
- },
364
- popState: function() {
365
- return this.conditionStack.pop();
366
- },
367
- _currentRules: function() {
368
- return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
369
- },
370
- topState: function() {
371
- return this.conditionStack[this.conditionStack.length - 2];
372
- },
373
- pushState: function(t) {
374
- this.begin(t);
375
- }
376
- };
377
- return u.options = {}, u.performAction = function(t, n, p, s) {
378
- switch (p) {
379
- case 0:
380
- break;
381
- case 1:
382
- return 6;
383
- case 2:
384
- return n.yytext = n.yytext.substr(1, n.yyleng - 2), 4;
385
- case 3:
386
- return 17;
387
- case 4:
388
- return 18;
389
- case 5:
390
- return 23;
391
- case 6:
392
- return 24;
393
- case 7:
394
- return 22;
395
- case 8:
396
- return 21;
397
- case 9:
398
- return 10;
399
- case 10:
400
- return 11;
401
- case 11:
402
- return 8;
403
- case 12:
404
- return 14;
405
- case 13:
406
- return "INVALID";
407
- }
408
- }, u.rules = [
409
- /^(?:\s+)/,
410
- /^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,
411
- /^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,
412
- /^(?:\{)/,
413
- /^(?:\})/,
414
- /^(?:\[)/,
415
- /^(?:\])/,
416
- /^(?:,)/,
417
- /^(?::)/,
418
- /^(?:true\b)/,
419
- /^(?:false\b)/,
420
- /^(?:null\b)/,
421
- /^(?:$)/,
422
- /^(?:.)/
423
- ], u.conditions = { INITIAL: { rules: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], inclusive: !0 } }, u;
424
- }();
425
- return m.lexer = I, m;
426
- }();
427
- return i.parser = l, i.parse = function() {
428
- return l.parse.apply(l, arguments);
429
- }, i;
430
- }();
431
- window.jsonlint = P;
432
- const O = (i) => {
433
- if (i)
434
- try {
435
- return JSON.stringify(JSON.parse(i), null, 1);
436
- } catch (l) {
437
- }
438
- return i;
439
- }, R = (i) => {
440
- if (i)
441
- try {
442
- return JSON.stringify(JSON.parse(i));
443
- } catch (l) {
444
- }
445
- return i;
446
- }, T = {
10
+ import "codemirror/addon/fold/foldgutter";
11
+ import { n as o } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
12
+ const s = {
447
13
  name: "CodeMirrorEditor",
448
14
  inject: {
449
15
  elForm: {
@@ -457,61 +23,76 @@ const O = (i) => {
457
23
  value: {
458
24
  type: String,
459
25
  default: ""
460
- }
26
+ },
27
+ mode: {
28
+ type: String,
29
+ default: "javascript"
30
+ },
31
+ theme: {
32
+ type: String,
33
+ default: "idea"
34
+ },
35
+ disabled: {
36
+ type: Boolean,
37
+ default: !1
38
+ },
39
+ formator: Function,
40
+ outputTranformer: Function
461
41
  },
462
42
  watch: {
463
- value(i) {
464
- var l;
465
- (l = this.editor) == null || l.setValue(O(i));
43
+ value(t) {
44
+ var e, r;
45
+ this.formator ? (e = this.editor) == null || e.setValue(this == null ? void 0 : this.formator(t)) : (r = this.editor) == null || r.setValue(t);
466
46
  }
467
47
  },
468
48
  mounted() {
469
- this.editor = L.fromTextArea(this.$refs.editor, {
470
- mode: "application/json",
471
- theme: "idea",
49
+ this.editor = i.fromTextArea(this.$refs.editor, {
50
+ mode: this.mode,
51
+ theme: this.theme,
472
52
  tabSize: 2,
473
53
  indentUnit: 2,
474
54
  lint: !0,
475
55
  foldGutter: !0,
476
- // lineNumbers: true,
56
+ lineNumbers: !0,
477
57
  smartIndent: !0,
58
+ readOnly: this.disabled,
478
59
  lineWrapping: !0,
479
60
  matchBrackets: !0
480
61
  // styleActiveLine: true,
481
62
  // gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'CodeMirror-lint-markers']
482
- }), this.editor.setValue(O(this.value)), this.editor.on("blur", this.change), this.editor.on("focus", this.focus), this.editor.setOption("extraKeys", {
483
- "Ctrl-Alt-L"(i) {
484
- i.setValue(O(i.getValue()), null, 1);
63
+ }), this.formator ? this.editor.setValue(this == null ? void 0 : this.formator(this.value)) : this.editor.setValue(this.value), this.editor.on("blur", this.change), this.editor.on("focus", this.focus), this.editor.setOption("extraKeys", {
64
+ "Ctrl-Alt-L"(t) {
65
+ this.formator && t.setValue(this == null ? void 0 : this.formator(t.getValue()), null, 1);
485
66
  }
486
67
  });
487
68
  },
488
69
  beforeDestroy() {
489
- var i, l;
490
- (i = this.editor) == null || i.off("blur", this.change), (l = this.editor) == null || l.toTextArea();
70
+ var t, e;
71
+ (t = this.editor) == null || t.off("blur", this.change), (e = this.editor) == null || e.toTextArea();
491
72
  },
492
73
  methods: {
493
74
  focus() {
494
- var i, l;
495
- (l = (i = this.elFormItem).clearValidate) == null || l.call(i);
75
+ var t, e;
76
+ (e = (t = this.elFormItem).clearValidate) == null || e.call(t);
496
77
  },
497
78
  change() {
498
- var i;
499
- this.$emit("input", R((i = this.editor) == null ? void 0 : i.getValue()));
79
+ var t, e;
80
+ this.outputTranformer ? this.$emit("input", this.outputTranformer((t = this.editor) == null ? void 0 : t.getValue())) : this.$emit("input", (e = this.editor) == null ? void 0 : e.getValue());
500
81
  }
501
82
  }
502
83
  };
503
- var U = function() {
504
- var l = this, m = l._self._c;
505
- return m("div", { staticClass: "code-mirror-editor" }, [m("textarea", { ref: "editor" })]);
506
- }, j = [], V = /* @__PURE__ */ F(
507
- T,
508
- U,
509
- j,
84
+ var a = function() {
85
+ var e = this, r = e._self._c;
86
+ return r("div", { staticClass: "code-mirror-editor" }, [r("textarea", { ref: "editor" })]);
87
+ }, n = [], l = /* @__PURE__ */ o(
88
+ s,
89
+ a,
90
+ n,
510
91
  !1,
511
92
  null,
512
93
  null
513
94
  );
514
- const et = V.exports;
95
+ const b = l.exports;
515
96
  export {
516
- et as default
97
+ b as default
517
98
  };
@@ -27,6 +27,7 @@ var y = (l, e, t) => new Promise((a, i) => {
27
27
  });
28
28
  import { isBlank as C } from "@web-utils/core";
29
29
  import b from "../monaco-editor/index.mjs";
30
+ import "../monaco-editor/style.css";
30
31
  import g from "vuedraggable";
31
32
  import { c as _ } from "../chunks/json-beautifier.Bp3GslGm.mjs";
32
33
  import { d as m, z as h } from "../chunks/util.CoahLDYn.mjs";
@@ -2872,7 +2873,7 @@ var ra = function() {
2872
2873
  null,
2873
2874
  null
2874
2875
  );
2875
- const ya = da.exports;
2876
+ const Ea = da.exports;
2876
2877
  export {
2877
- ya as default
2878
+ Ea as default
2878
2879
  };