efront 3.13.1 → 3.14.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 (45) hide show
  1. package/apps/pivot/api.yml +7 -0
  2. package/apps/pivot/log/boot.html +2 -0
  3. package/apps/pivot/log/boot.js +44 -0
  4. package/apps/pivot/log/boot.less +11 -0
  5. package/apps/pivot/log/count.html +5 -1
  6. package/apps/pivot/log/count.js +11 -4
  7. package/apps/pivot/log/count.less +10 -2
  8. package/apps/pivot/main.js +9 -10
  9. package/apps/pivot/menu.yml +7 -3
  10. package/apps/pivot/proxy/edit.js +1 -0
  11. package/apps/pivot/proxy/list.js +12 -0
  12. package/apps/pivot/user/edit.js +1 -0
  13. package/apps/pivot/user/list.js +4 -0
  14. package/apps/pivot/user/tag/edit.js +1 -0
  15. package/apps/pivot/user/tag/list.js +3 -0
  16. package/coms/basic/cross_.js +8 -1
  17. package/coms/basic/encodePack.js +2 -9
  18. package/coms/basic/parseURL_test.js +2 -0
  19. package/coms/basic/renderExpress.js +1 -1
  20. package/coms/compile/common.js +165 -6
  21. package/coms/compile/scanner.js +7 -4
  22. package/coms/compile/scanner2.js +2 -117
  23. package/coms/compile/washcode.js +313 -0
  24. package/coms/frame/route.js +3 -0
  25. package/coms/pivot/plist.js +1 -1
  26. package/coms/typescript-helpers/__classPrivateFieldIn.js +11 -0
  27. package/coms/zimoli/cross.js +2 -3
  28. package/coms/zimoli/data.js +22 -4
  29. package/coms/zimoli/field.html +15 -10
  30. package/coms/zimoli/model.js +22 -1
  31. package/coms/zimoli/prompt.js +3 -1
  32. package/coms/zimoli/render.js +11 -8
  33. package/coms/zimoli/renderDefaults.js +1 -0
  34. package/coms/zimoli/search.js +5 -4
  35. package/coms/zimoli/select.js +7 -3
  36. package/coms/zimoli/selectList.js +7 -7
  37. package/coms/zimoli/selectListEdit.js +1 -1
  38. package/coms/zimoli/success.js +4 -0
  39. package/coms/zimoli/success.less +13 -0
  40. package/coms/zimoli/view.less +4 -0
  41. package/package.json +1 -1
  42. package/public/efront.js +1 -1
  43. package/apps/pivot/home/short.html +0 -1
  44. package/apps/pivot/home/short.js +0 -5
  45. package/apps/pivot/home/short.less +0 -1
@@ -15,38 +15,11 @@ const {
15
15
  number_reg,
16
16
  skipAssignment,
17
17
  createScoped,
18
+ createString,
18
19
  } = require("./common");
19
20
 
20
21
 
21
22
 
22
- var needBreak = function (prev, next) {
23
- if (!prev || !next) return;
24
- if (prev.type === STAMP && /^[,;]$/.test(prev.text)) return;
25
- if (next.type === STAMP && /^[,;]$/.test(next.text)) return;
26
- if (prev.type === EXPRESS && /\.$/.test(prev.text)) return;
27
- if (next.type === EXPRESS && /^\./.test(next.text)) return;
28
- if (next.type === PROPERTY) return ";";
29
- if (next.type === STAMP && next.text === "*") return ";";
30
- if (
31
- [EXPRESS, VALUE, QUOTED].indexOf(prev.type) >= 0
32
- || prev.type === STAMP && /^(\+\+|\-\-)$/.test(prev.text)
33
- || prev.type === SCOPED && (prev.isExpress || prev.isObject)
34
- ) {
35
- if ([EXPRESS, VALUE, QUOTED, LABEL].indexOf(next.type) >= 0) return ";";
36
- if (next.type === STRAP) {
37
- if (!/^(in|of|extends|instanceof|as)$/.test(next.text)) return ";";
38
- return " ";
39
- }
40
- if (next.type === SCOPED) {
41
- if (!next.isExpress) return ";";
42
- }
43
- return;
44
- }
45
- if (prev.type === STRAP) {
46
- if ([STRAP, EXPRESS, VALUE, QUOTED].indexOf(next.type) >= 0) return " ";
47
- if (next.type === LABEL) return ";";
48
- }
49
- };
50
23
 
51
24
 
52
25
  var compress = function (scoped, maped) {
@@ -266,95 +239,7 @@ class Program extends Array {
266
239
  }
267
240
 
268
241
  toString() {
269
- var lasttype;
270
- var result = [];
271
- var run = (o, i, a) => {
272
- if (!~[SPACE, COMMENT, STAMP, PIECE].indexOf(o.type) && lasttype !== SPACE && !this.pressed) {
273
- var prev = o.prev;
274
- if (~[QUOTED, SCOPED, STRAP].indexOf(lasttype)
275
- || prev && prev.type === STAMP && !/(\+\+|\-\-|~|!)$/.test(prev.text) && prev.prev && prev.prev.type !== STAMP) {
276
- if (o.type !== SCOPED && (o.type !== EXPRESS || !/^\./.test(o.text))) {
277
- result.push(" ");
278
- lasttype = SPACE
279
- }
280
- }
281
- }
282
- switch (o.type) {
283
- case COMMENT:
284
- // 每一次要远行,我都不得不对自己的物品去粗取精。取舍之间,什么重要,什么不是那么重要,都有了一道明显的分界线。
285
- if (!this.pressed) {
286
- result.push(o.text);
287
- if (this.pressed && /^\/\//.test(o.text)) {
288
- result.push("\r\n");
289
- }
290
- }
291
- break;
292
- case SPACE:
293
- if (!this.pressed) {
294
- result.push(o.text);
295
- break;
296
- }
297
- var b = needBreak(o.prev, o.next);
298
- if (b) result.push(b);
299
- break;
300
- case QUOTED:
301
- if (!o.length) {
302
- result.push(o.text);
303
- break;
304
- }
305
- case SCOPED:
306
- if (!this.pressed && (lasttype === STRAP || lasttype === STAMP || lasttype === SCOPED && o.entry === "{") && o.type !== QUOTED) result.push(" ");
307
- result.push(o.entry);
308
- if (o.length > 0) {
309
- if (o.entry === "{" && result[0].type !== SPACE) {
310
- if (!this.pressed) {
311
- result.push(" ");
312
- }
313
- }
314
- lasttype = undefined;
315
- o.forEach(run);
316
- if (/^[,;]$/.test(result[result.length - 1]) && this.pressed) {
317
- if (!o.prev || o.prev.text !== 'for') result.pop();
318
- }
319
- if (o.leave === "}" && (!o.next || o.next.type !== PIECE) && o[o.length - 1].type !== SPACE) {
320
- if (!this.pressed) result.push(" ");
321
- }
322
- }
323
- result.push(o.leave);
324
- break;
325
- default:
326
- if (o instanceof Object) {
327
- if ([STRAP, EXPRESS, PROPERTY, VALUE].indexOf(lasttype) >= 0 && [STRAP, EXPRESS, PROPERTY, VALUE].indexOf(o.type) >= 0) {
328
- result.push(" ");
329
- }
330
- else if (o.prev && o.type === STAMP && !/^([,;])$/.test(o.text)) {
331
- if (result[result.length - 1] === " " || lasttype === PROPERTY && o.text === ':') { }
332
- else if (lasttype === STAMP) {
333
- result.push(" ");
334
- }
335
- else if (/^(\+\+|\-\-)$/.test(o.prev.text) && o.prev.prev) {
336
- var prev_prev = o.prev.prev;
337
- if (
338
- prev_prev.type === STRAP && !prev_prev.isExpress
339
- || prev_prev.type === EXPRESS
340
- || prev_prev.type === VALUE
341
- ) result.push(";");
342
- }
343
- else if (!/^(\+\+|\-\-)$/.test(o.text)) {
344
- if (!this.pressed && lasttype !== SPACE) result.push(" ");
345
- }
346
- }
347
- result.push(o.text);
348
- }
349
- else {
350
- result.push(o);
351
- }
352
- }
353
- lasttype = o.type;
354
- if (o.isprop) lasttype = PROPERTY;
355
- };
356
- this.forEach(run);
357
- return result.join("");
242
+ return createString(this);
358
243
  }
359
244
  get envs() {
360
245
  return this.scoped.envs;
@@ -0,0 +1,313 @@
1
+ const {
2
+ /*-1 */COMMENT,
3
+ /* 0 */SPACE,
4
+ /* 1 */STRAP,
5
+ /* 2 */STAMP,
6
+ /* 3 */VALUE,
7
+ /* 4 */QUOTED,
8
+ /* 5 */PIECE,
9
+ /* 6 */EXPRESS,
10
+ /* 7 */SCOPED,
11
+ /* 8 */LABEL,
12
+ /* 9 */PROPERTY,
13
+ skipAssignment,
14
+ getDeclared,
15
+ createScoped,
16
+ createString,
17
+ } = require("./common");
18
+ var strings = require("../basic/strings");
19
+
20
+ /**
21
+ * 按语句分割代码
22
+ */
23
+ var createExpressList = function (parsed) {
24
+ var list = [];
25
+ for (var cx = 0, dx = parsed.length; cx < dx; cx++) {
26
+ var o = parsed[cx];
27
+ switch (o.type) {
28
+ case LABEL:
29
+ var exp = [o];
30
+ exp.first = exp[0];
31
+ list.push(exp);
32
+ break;
33
+ case STRAP:
34
+ case SCOPED:
35
+ case EXPRESS:
36
+ case VALUE:
37
+ case QUOTED:
38
+ var o0 = skipAssignment(o);
39
+ var exp = [];
40
+ do {
41
+ exp.push(o);
42
+ o = parsed[++cx];
43
+ } while (o0 !== o);
44
+ cx--;
45
+ patchExpress(exp);
46
+ list.push(exp);
47
+ break;
48
+ case COMMENT:
49
+ case SPACE:
50
+ case STAMP:
51
+ list.push([o]);
52
+ break;
53
+ default:
54
+ console.log(o.type, 'type');
55
+ }
56
+ }
57
+ return list;
58
+ };
59
+ var getFunctionEnd = function (first) {
60
+ if (!first) return false;
61
+ var o = first.next;
62
+ if (!o) return false;
63
+ if (first.type === STRAP && first.text === 'function') {
64
+ if (o.type === EXPRESS) o = o.next;
65
+ if (!o) return false;
66
+ if (o.next && !o.next.next) return o.next;
67
+ }
68
+ return false;
69
+ }
70
+ var patchExpress = function (exp) {
71
+ if (!exp.first) {
72
+ exp.first = exp[0];
73
+ }
74
+ if (!exp.lastUncomment) {
75
+ exp.lastUncomment = exp[exp.length - 1];
76
+ }
77
+ if (exp.first) {
78
+ delete exp.first.prev;
79
+ }
80
+ if (exp.lastUncomment) {
81
+ delete exp.lastUncomment.next;
82
+ }
83
+ var first = exp.first;
84
+ if (first && first.type === QUOTED && /^(['"`])use strict\1/i.test(first.text)) {
85
+ exp.saved = true;
86
+ }
87
+ if (first && first.type === SCOPED && first.entry === '(') {
88
+ var ff = first.first;
89
+ var fn = first.next;
90
+ if (fn && fn.type === SCOPED && fn.entry === '(') {
91
+ var fe = getFunctionEnd(ff);
92
+ if (fe) {
93
+ first.push(fn);
94
+ var fnn = fn.next;
95
+ if (fnn) {
96
+ first.next = fnn;
97
+ fnn.prev = first;
98
+ }
99
+ fn.prev = fe;
100
+ fe.next = fn;
101
+ delete fn.next;
102
+ exp.splice(1, 1);
103
+ }
104
+ }
105
+ }
106
+ };
107
+
108
+ function createExpressKey(exp) {
109
+ var keys = [];
110
+ for (var e of exp) {
111
+ if (e.type === EXPRESS) {
112
+ var t = e.text;
113
+ while (t.length > 0) {
114
+ if (/^\./.test(t)) {
115
+ if (!keys.length) keys.push('');
116
+ t = t.slice(1);
117
+ }
118
+ var m = /[^\.\[]+/.exec(t);
119
+ if (m) {
120
+ m = m[0];
121
+ keys.push(m);
122
+ t = t.slice(m.length);
123
+ continue;
124
+ }
125
+ var m = /^\[(['"`])([\s\S]*?)\1\]/.exec(t)
126
+ if (m) {
127
+ m = m[0];
128
+ t = t.slice(m.length);
129
+ m = m.slice(1, m.length - 1);
130
+ m = strings.decode(m);
131
+ keys.push(m);
132
+ continue;
133
+ }
134
+ break;
135
+ }
136
+ }
137
+ }
138
+ return keys.join('.');
139
+ }
140
+ function needLeft(o) {
141
+ if (o.type === EXPRESS && /^[\.\[]/.test(o.text)) return true;
142
+ if (o.type === SCOPED && o.entry === '[') return true;
143
+ return false;
144
+ }
145
+ function needRight(o) {
146
+ if (o.type === EXPRESS && /[\.\]]$/.test(o.text)) return true;
147
+ if (o.type === SCOPED && o.entry === '[') return true;
148
+ return false;
149
+ }
150
+ function renameId(id, amap) {
151
+ var m = /^[^\.]+/.exec(id);
152
+ if (m) {
153
+ var id0 = m[0];
154
+ var w = amap[id0];
155
+ if (w) return w + id.slice(id0.length);
156
+ }
157
+ };
158
+ function checkRefered(scope) {
159
+ var { used } = scope;
160
+ var map = Object.create(null);
161
+ for (var k in used) {
162
+ var u = used[k];
163
+ for (var o of u) {
164
+ var right = [];
165
+ var e = o;
166
+ while (e) {
167
+ if (right.length) {
168
+ if (!needRight(right[right.length - 1]) && !needLeft(e)) break;
169
+ }
170
+ right.push(e);
171
+ e = e.next;
172
+ }
173
+ if (right.length) {
174
+ var key = createExpressKey(right);
175
+ var iswrite = false;
176
+ iswrite = !!o.kind || !!e && e.type === STAMP && /=$/.test(e.text);
177
+ if (key) map[key] = map[key] | 1 + iswrite;
178
+ }
179
+ }
180
+ }
181
+ var readed, writed;
182
+ for (var k in map) {
183
+ if (map[k] >> 1) {
184
+ if (!writed) writed = Object.create(null);
185
+ writed[k] = true;
186
+ }
187
+ if (map[k] & 1) {
188
+ if (!readed) readed = Object.create(null);
189
+ readed[k] = true;
190
+ }
191
+ }
192
+ for (var s of scope) {
193
+ if (s.isfunc && s.pass) {
194
+ var [writed0, readed0] = checkRefered(s);
195
+ var { pass, args } = s;
196
+ var amap = {};
197
+ for (var cx = 0, dx = pass.length; cx < dx; cx++) {
198
+ amap[args[cx]] = pass[cx];
199
+ }
200
+ for (var w in writed0) {
201
+ var id = renameId(w, amap);
202
+ if (id) writed[id] = true;
203
+ }
204
+ for (var r in readed0) {
205
+ var id = renameId(r, amap);
206
+ if (id) readed[id] = true;
207
+ }
208
+ }
209
+ }
210
+
211
+ return [writed, readed];
212
+ }
213
+
214
+ var getroot = function (pick) {
215
+ if (pick) {
216
+ var match = /^[^\.]+/.exec(pick);
217
+ if (match) match = match[0];
218
+ return match;
219
+ }
220
+ }
221
+
222
+ function washcode(code, pick) {
223
+ var avoid = getroot(pick);
224
+ var needs = Object.assign(Object.create(null), pick ? { [pick]: true } : code.envs);
225
+ var explist = createExpressList(code);
226
+ var maped = Object.create(null);
227
+ for (var exp of explist) {
228
+ exp.scoped = createScoped(exp, true);
229
+ if (avoid && avoid in exp.scoped.used) {
230
+ if (code.vars[avoid] && !code.envs[avoid] && !maped[avoid]) {
231
+ exp.saved = true;
232
+ maped[avoid] = true;
233
+ }
234
+ }
235
+ var [writed, readed] = checkRefered(exp.scoped);
236
+ exp.writed = writed;
237
+ exp.readed = readed;
238
+ }
239
+ var count = 0;
240
+ while (count < explist.length) {
241
+ var saved_count = count;
242
+ for (var exp of explist) {
243
+ if (exp.saved) continue;
244
+ if (!exp.first) {
245
+ exp.saved = true;
246
+ count++;
247
+ break;
248
+ }
249
+ var { writed, readed } = exp;
250
+ for (var w in writed) {
251
+ if (w === avoid) continue;
252
+ if (needs[w] || getroot(w) in code.envs) {
253
+ exp.saved = true;
254
+ for (var r in readed) {
255
+
256
+ var rs = r.split('.');
257
+ while (rs.length) {
258
+ needs[rs.join('.')] = true;
259
+ rs.pop();
260
+ }
261
+ }
262
+ count++;
263
+ break;
264
+ }
265
+ }
266
+ }
267
+ if (saved_count === count) break;
268
+ }
269
+ for (var cx = 0, dx = explist.length; cx < dx; cx++) {
270
+ var exp = explist[cx];
271
+ var prev = explist[cx - 1], next = explist[cx + 1];
272
+ if (!exp.first) {
273
+ if (!exp.saved) continue;
274
+ if (exp.length !== 1 || !prev && !next) continue;
275
+ if (exp[0].type === STAMP) {
276
+ if (prev && !prev.saved || next && !next.saved) {
277
+ exp.saved = false;
278
+ }
279
+ continue;
280
+ }
281
+ if (next && !next.saved) {
282
+ exp.saved = false;
283
+ }
284
+ continue;
285
+ }
286
+ if (!exp.saved) {
287
+ if (exp[0].type === STRAP && /^(let|var|const)$/.test(exp[0].text)) {
288
+ var save = false, inc = 2;
289
+ while (next && next[0].type === STAMP && /^,$/.test(next[0].text)) {
290
+ next.saved = false;
291
+ next = explist[cx + inc++];
292
+ if (!next) break;
293
+ if (next.saved) {
294
+ save = true;
295
+ break;
296
+ }
297
+ next = explist[cx + inc++];
298
+ }
299
+ exp.saved = save;
300
+ if (exp.saved) {
301
+ if (!prev.saved) prev.saved = true;
302
+ exp.splice(1, exp.length - 1, ' ');
303
+ patchExpress(exp);
304
+ }
305
+ }
306
+ }
307
+ }
308
+ explist = explist.filter(e => e.saved);
309
+ var text = explist.map(createString).join("");
310
+ return text;
311
+ }
312
+
313
+ module.exports = washcode;
@@ -75,6 +75,7 @@
75
75
  if (/,/.test(name)) {
76
76
 
77
77
  }
78
+ item.closed = true;
78
79
  return item;
79
80
  });
80
81
  return items;
@@ -114,6 +115,7 @@
114
115
  actived = mmap[opened.active] || actived;
115
116
  if (actived) {
116
117
  if (actived_value === historys.length) {
118
+ setActive(actived, true);
117
119
  result.active = actived;
118
120
  };
119
121
  }
@@ -123,6 +125,7 @@
123
125
  var setActive = function (p, active) {
124
126
  while (p) {
125
127
  p.active = active;
128
+ if (active) p.closed = false;
126
129
  p = p.parent;
127
130
  }
128
131
  };
@@ -2,7 +2,7 @@
2
2
  function main(title, type, fields, edit_ref, options) {
3
3
  return frame$list(title, {
4
4
  load() {
5
- return data.from("list", { type }, a => JSAM.parse(encode62.timedecode(a)));
5
+ return data.from("list", { type }, a => JSAM.parse(encode62.timedecode(a || '')));
6
6
  },
7
7
  remove(o) {
8
8
  return data.from("edit", { type, key: encode62.timeencode(o.key), value: encode62.timeencode("") }).loading_promise;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * typescript:classPrivateFieldIn
3
+ * 这个文件由工具生成,请不要手动修改
4
+ *
5
+ * Efront Authors
6
+ * 2022-02-04T17:45:54.577Z
7
+ */
8
+ var __classPrivateFieldIn = (this && this.__classPrivateFieldIn) || function(state, receiver) {
9
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
10
+ return typeof state === "function" ? receiver === state : state.has(receiver);
11
+ };
@@ -17,9 +17,9 @@ if (cookiesData) {
17
17
  }
18
18
  }
19
19
 
20
- var digest = function () {
20
+ var digest = lazy(function () {
21
21
  dispatch('render', window);
22
- };
22
+ }, 0);
23
23
 
24
24
  var cross = cross_.bind(function (callback, onerror) {
25
25
  var xhr = new XMLHttpRequest;
@@ -32,7 +32,6 @@ var cross = cross_.bind(function (callback, onerror) {
32
32
 
33
33
  xhr.onreadystatechange = function () {
34
34
  if (xhr.readyState === 4) {
35
- dispatch(window, 'render');
36
35
  switch (xhr.status) {
37
36
  case 0:
38
37
  if (!navigator.onLine) {
@@ -75,8 +75,24 @@ const formulaters = {
75
75
  var seekFromSource = function (obj, base) {
76
76
  var source = dataSourceMap;
77
77
  if (base && base in dataSourceMap) source = source[base];
78
- obj = seek(source, obj);
79
- if (isObject(obj)) for (var k in obj) if (obj[k] === dataSourceMap) delete obj[k];
78
+ if (isObject(obj)) {
79
+ var dist = {};
80
+ for (var k in obj) {
81
+ var v = obj[k];
82
+ if (/^\:/.test(k)) {
83
+ k = seek(source, k.slice(1));
84
+ }
85
+ if (v === '') {
86
+ if (source !== dataSourceMap) v = source;
87
+ else v = seek(source, k);
88
+ }
89
+ else if (/^\:/.test(v)) {
90
+ v = seek(source, v.slice(1));
91
+ }
92
+ dist[k] = v;
93
+ }
94
+ obj = dist;
95
+ }
80
96
  return obj;
81
97
  };
82
98
  function getErrorMessage(error = this) {
@@ -553,8 +569,10 @@ var privates = {
553
569
  headers = seekFromSource(headers, api.base);
554
570
  }
555
571
  cross(realmethod, uri, headers).send(params).done(e => {
572
+ updateLoadingCount();
556
573
  ok(e.response || e.responseText);
557
574
  }).error(xhr => {
575
+ updateLoadingCount();
558
576
  try {
559
577
  var e = getErrorMessage(parseData(xhr.response || xhr.responseText || xhr.statusText || xhr.status));
560
578
  oh({ status: xhr.status, api, params: params1, error: e, toString: getErrorMessage })
@@ -627,7 +645,6 @@ function responseCrash(e, data) {
627
645
  data.error = e;
628
646
  }
629
647
  error_report(e, e.status < 500 ? 'warn' : 'error');
630
- updateLoadingCount();
631
648
  }
632
649
  var getData = function () { return this.data };
633
650
  var updateLoadingCount = function () {
@@ -643,7 +660,6 @@ var data = {
643
660
  response.is_loading = false;
644
661
  if (response.then === LoadingArray_then) delete response.then;
645
662
  }
646
- updateLoadingCount();
647
663
  },
648
664
  responseCrash,
649
665
  responseLoading(response) {
@@ -865,10 +881,12 @@ var data = {
865
881
  headers = seekFromSource(headers, api.base);
866
882
  }
867
883
  instance.loading = cross(method, uri, headers).send(params).done(xhr => {
884
+ updateLoadingCount();
868
885
  if (instance.loading !== xhr) return oh(aborted);
869
886
  instance.loading = null;
870
887
  ok(xhr.responseText || xhr.response);
871
888
  }).error(xhr => {
889
+ updateLoadingCount();
872
890
  if (instance.loading !== xhr) return oh(aborted);
873
891
  instance.loading = null;
874
892
  try {
@@ -1,11 +1,16 @@
1
- <div class="head">
2
- <span ng-bind=field.name></span>
3
- <span class="required" ng-if="field.required">*</span>
4
- </div>
5
- <div class="body">
1
+ <template v-if='field?.key'>
2
+ <div class="head">
3
+ <span ng-bind=field.name></span>
4
+ <span class="required" ng-if="field.required">*</span>
5
+ </div>
6
+ <div class="body">
7
+ <model _data=data _field=field></model>
8
+ <span class="error" ng-bind="error"></span>
9
+ </div>
10
+ <div class="foot" ng-if="field.msg">
11
+ <span ng-bind=field.msg></span>
12
+ </div>
13
+ </template>
14
+ <template v-else>
6
15
  <model _data=data _field=field></model>
7
- <span class="error" ng-bind="error"></span>
8
- </div>
9
- <div class="foot" ng-if="field.msg">
10
- <span ng-bind=field.msg></span>
11
- </div>
16
+ </template>
@@ -48,6 +48,12 @@ var constructors = {
48
48
  }
49
49
  return e;
50
50
  },
51
+ success(e) {
52
+ success(e);
53
+ e.innerHTML = `<span ng-html="field.comment"></span>`;
54
+ render(e.children, e.$scope, e.$parentScopes);
55
+ return e;
56
+ },
51
57
  switch: swap,
52
58
  row: textarea,
53
59
  password,
@@ -149,16 +155,31 @@ var readonly_types = {
149
155
  var f = data[field.key];
150
156
  return size(f);
151
157
  },
158
+ html(a, data) {
159
+ var t = document.createElement("span");
160
+ t.innerHTML = seek(data, a.field.key);
161
+ return t;
162
+ },
152
163
  swap(e, data) {
153
164
  var { field } = e;
154
165
  var v = data[field.key];
155
166
  if (field.options) {
156
- var o = field.options[v];
167
+ if (!field.optionsMap) field.optionsMap = createOptionsMap(field.options);
168
+ var o = field.optionsMap[v];
157
169
  if (o) return o.name;
158
170
  }
171
+ if (isEmpty(v)) v = '';
159
172
  return v;
160
173
  },
161
174
  };
175
+ readonly_types.anchor = readonly_types.url;
176
+ var createOptionsMap = function (options) {
177
+ var map = Object.create(null);
178
+ for (var o of options) {
179
+ map[o.key] = o;
180
+ }
181
+ return map;
182
+ }
162
183
  readonly_types.select = readonly_types.swap;
163
184
  function main(elem) {
164
185
  var build = function () {
@@ -25,8 +25,10 @@ function prompt(msg = "请输入", check) {
25
25
  });
26
26
  })
27
27
  on("mousedown")(c, e => e.target !== ipt && e.preventDefault() | ipt.focus());
28
- on("keydown.enter")(c, function () {
28
+ on("keydown.enter")(c, function (event) {
29
+ if (event.defaultPrevented) return;
29
30
  if (check && check(ipt.value) === false) return;
31
+ event.preventDefault();
30
32
  oked = true;
31
33
  remove(c);
32
34
  fire();