efront 4.5.4 → 4.5.7

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 (46) hide show
  1. package/#/345/233/275/351/231/205/345/214/226.yml +84 -9
  2. package/apps/pivot/api.yml +2 -1
  3. package/apps/pivot/cert/main.xht +38 -18
  4. package/apps/pivot/cert/orders.xht +6 -26
  5. package/apps/pivot/cert/update.xht +35 -2
  6. package/coms/basic/#loader.js +4 -3
  7. package/coms/basic/YAML.js +1 -1
  8. package/coms/basic/awaitable.js +6 -2
  9. package/coms/{zimoli → basic}/data.js +10 -8
  10. package/coms/basic/data.md +48 -0
  11. package/coms/basic/data_test.js +12 -0
  12. package/coms/basic/parseYML.js +13 -6
  13. package/coms/basic/parseYML_test.js +5 -1
  14. package/coms/basic/refilm_decode.js +1 -0
  15. package/coms/compile/Javascript.js +8 -43
  16. package/coms/compile/common.js +51 -8
  17. package/coms/compile/patchlist.js +4 -0
  18. package/coms/compile/patchname.js +4 -0
  19. package/coms/compile/scanner2.js +2 -2
  20. package/coms/compile/translate.js +2 -1
  21. package/coms/compile//347/264/240/351/246/250.js +4 -3
  22. package/coms/compile//347/264/240/351/246/250_test.js +1 -0
  23. package/coms/docs/helps.js +1 -1
  24. package/coms/pivot/acme2.js +103 -19
  25. package/coms/pivot/pedit.js +7 -9
  26. package/coms/reptile/alert.js +1 -0
  27. package/coms/reptile/detectWithExtension.js +2 -1
  28. package/coms/reptile/localStorage.js +4 -0
  29. package/coms/reptile/on.js +4 -0
  30. package/coms/reptile/onmounted.js +1 -0
  31. package/coms/reptile/sessionStorage.js +1 -0
  32. package/coms/reptile/window.js +65 -0
  33. package/coms/zimoli/alert.js +32 -31
  34. package/coms/zimoli/button.less +8 -1
  35. package/coms/zimoli/confirm.js +22 -10
  36. package/coms/zimoli/model.js +28 -14
  37. package/coms/zimoli/model.less +45 -2
  38. package/coms/zimoli/selectDate.js +2 -2
  39. package/coms/zimoli/view.less +1 -2
  40. package/docs//345/267/245/345/205/267//345/233/275/351/231/205/345/214/226.xht +50 -9
  41. package/package.json +1 -1
  42. package/public/efront.js +1 -1
  43. package/coms/zimoli/data_test.js +0 -35
  44. /package/coms/{zimoli → basic}/LoadingArray.js +0 -0
  45. /package/coms/{zimoli → basic}/fromBase64.js +0 -0
  46. /package/coms/{zimoli → basic}/toBase64.js +0 -0
@@ -8,13 +8,13 @@ styles.success = styles.pass = styles.green;
8
8
  styles.info = styles.blue;
9
9
  styles.error = styles.danger = styles.red;
10
10
  styles.warn = styles.orange;
11
- styles.default = '#000a';
11
+ styles.default = '#323436';
12
12
  var fontSize = 16;
13
13
  var singleHeight = fontSize * 3.125 | 0;
14
14
  var container = document.createElement('alert-container');
15
15
  css(container, 'top:0;height:0;left:0;right:0;transition:all 0.2s ease-out;position:absolute;')
16
- var _text = function (bgcolor, parameters) {
17
- var box = document.createElement('div');
16
+ var _text = function (elem, bgcolor, parameters) {
17
+ var box = elem || document.createElement('div');
18
18
  css(box, `background-color:${bgcolor};color:${color.pair(bgcolor, 1)};`);
19
19
  box.innerHTML = [].slice.call(parameters, 0).join(", ");
20
20
  box.initialStyle = `margin-top:-${fromPixel(singleHeight)};`;
@@ -22,8 +22,10 @@ var _text = function (bgcolor, parameters) {
22
22
  };
23
23
  function alert() {
24
24
  var clr = String(isString(this) && this || styles.default), text, autoclose = true, onclose;
25
- [].map.call(arguments, function (arg) {
26
- switch (typeof arg) {
25
+ var setArg = function (args) {
26
+ text = '';
27
+ autoclose = true;
28
+ for (var arg of args) switch (typeof arg) {
27
29
  case "string":
28
30
  case "object":
29
31
  arg = String(arg);
@@ -48,23 +50,10 @@ function alert() {
48
50
  case "function":
49
51
  onclose = arg;
50
52
  }
51
- });
52
- var elem;
53
-
54
- if (color.isColor(clr)) {
55
- elem = _text(clr, [text]);
56
- } else {
57
- elem = _text(styles.log, [text]);
58
- }
59
- var _onclose = lazy(function (event) {
60
- if (onclose) {
61
- onclose.call(this, event);
62
- }
63
- if (close_timer) clearTimeout(close_timer);
64
- });
65
- onremove(elem, _onclose);
66
- var close_timer;
53
+ };
54
+ setArg(arguments);
67
55
  var waitclose = function (autoclose, deltaTime) {
56
+ if (close_timer) clearTimeout(close_timer);
68
57
  if (autoclose) {
69
58
  if (autoclose === true) {
70
59
  autoclose = text && text.length * 160 + deltaTime;
@@ -76,18 +65,30 @@ function alert() {
76
65
  }, autoclose);
77
66
  }
78
67
  };
79
- waitclose(autoclose, 400)
80
- elem.setText = function (content, timeout = true) {
81
- var c = elem;
82
- c.innerHTML = content;
83
- text = content;
84
- if (timeout) {
85
- clearTimeout(close_timer);
86
- waitclose(timeout, -100);
68
+ var setContent = function (elem) {
69
+ if (color.isColor(clr)) {
70
+ elem = _text(elem, clr, [text]);
71
+ } else {
72
+ elem = _text(elem, styles.log, [text]);
73
+ }
74
+ if (!container.parentNode) popup(container);
75
+ if (!elem.parentNode) appendChild(container, elem);
76
+ waitclose(autoclose, 400);
77
+ return elem;
78
+ };
79
+ var elem = setContent();
80
+ var _onclose = lazy(function (event) {
81
+ if (onclose) {
82
+ onclose.call(this, event);
87
83
  }
84
+ if (close_timer) clearTimeout(close_timer);
85
+ });
86
+ onremove(elem, _onclose);
87
+ var close_timer;
88
+ elem.setText = function () {
89
+ setArg(arguments);
90
+ setContent(elem);
88
91
  };
89
- if (!container.parentNode) popup(container);
90
- if (!elem.parentNode) appendChild(container, elem);
91
92
  return elem;
92
93
  }
93
94
  for (var k in styles) {
@@ -316,5 +316,12 @@ a&,
316
316
  content: "确认";
317
317
  }
318
318
 
319
- background: #333;
319
+ &:not(a, .anchor) {
320
+ background: #333;
321
+ }
322
+
323
+ a&,
324
+ &.anchor {
325
+ color: #c26;
326
+ }
320
327
  }
@@ -1,11 +1,10 @@
1
1
  var isOptionalReg = /^是否|是[吗吧]$|[??]$|请|^难道|^确认/i;
2
2
  var conflictReg = /^确[\s\u00a0]*?认[\s\u00a0]*?取[\s\u00a0]*?消/i;
3
3
  var defaultOptions = {
4
- 是: ["是的", "不是"],
5
- 确认: ["确认", "取消"],
6
- 是否: ["", ""],
7
- 是吗: ["", "不是"],
8
- 请: ["完成", "取消"],
4
+ 是否: ["", ""],
5
+ 确认: ["取消", "确认"],
6
+ 是吗: ["不是", ""],
7
+ "": [i18n`取消`, i18n`继续`],
9
8
  }
10
9
  function confirm() {
11
10
  var message, title, options, callback, closable = true, selected = -1, target;
@@ -73,8 +72,14 @@ function confirm() {
73
72
  }
74
73
  }
75
74
  if (!options) {
76
- options = ["确认 ", "取消"];
75
+ options = [i18n`取消`, i18n`确认`];
77
76
  }
77
+ options = options.map((label, index) => {
78
+ if (index === 0) label += '#white';
79
+ var btn = button(label);
80
+ btn.result = index;
81
+ return btn;
82
+ }).reverse();
78
83
  }
79
84
  var clickbtn = function (event) {
80
85
  event.preventDefault();
@@ -88,7 +93,8 @@ function confirm() {
88
93
  if (res instanceof Promise) {
89
94
  element.setAttribute("locked", '');
90
95
  this.setAttribute("loading", "");
91
- res.then(() => {
96
+ res.then((res) => {
97
+ element.result = res;
92
98
  remove(element);
93
99
  element.removeAttribute('locked');
94
100
  this.removeAttribute('loading');
@@ -98,27 +104,33 @@ function confirm() {
98
104
  });
99
105
  }
100
106
  else {
107
+ element.result = res;
101
108
  remove(element);
102
109
  }
103
110
  }
104
111
  else {
112
+ element.result = isHandled(this.result) ? this.result : this;
105
113
  remove(element);
106
114
  }
107
115
  };
116
+ on('remove')(element, function () {
117
+ this.onload();
118
+ });
108
119
  var buttons = options.map(function (label, index, options) {
109
120
  if (isNode(label)) {
110
121
  label.index = index;
111
- if (isFunction(callback)) onclick(label, clickbtn);
122
+ onclick(label, clickbtn);
112
123
  return label;
113
124
  }
114
125
  if (options.length === 2) for (var k in defaultOptions) {
115
- if (label === defaultOptions[k][1]) {
126
+ if (label === defaultOptions[k][0]) {
116
127
  label += " #white";
117
128
  break;
118
129
  }
119
130
  }
120
131
  var btn = button(label);
121
132
  btn.index = index;
133
+ btn.result = options[index];
122
134
  onclick(btn, clickbtn);
123
135
  return btn;
124
136
  });
@@ -138,7 +150,7 @@ function confirm() {
138
150
  on("blur")(element, blur, true);
139
151
  }
140
152
  });
141
- return element;
153
+ return awaitable(element, 'result');
142
154
  }
143
155
  var blur = lazy(function () {
144
156
  var element = this;
@@ -99,10 +99,13 @@ var constructors = {
99
99
  password,
100
100
  text: textarea,
101
101
  number(e) {
102
- var ipt = document.createElement('input');
103
- ipt.setAttribute('type', e.field.type);
104
- input(ipt);
105
- return ipt;
102
+ var { data, field } = e;
103
+ var content = `<input type=${field.type} -model=data[field.key] />` + (field.unit ? `<span>${field.unit}</span>` : '');
104
+ e.innerHTML = content;
105
+ if (field.unit && field.unit.length <= 6) {
106
+ e.setAttribute("u" + field.unit.replace(/[\u0080-\ud7ff\uf000-\uffff]/g, '11').length, '')
107
+ }
108
+ render(e, { data, field, input });
106
109
  },
107
110
  generator(elem) {
108
111
  var { data, field } = elem;
@@ -113,15 +116,21 @@ var constructors = {
113
116
  }
114
117
  });
115
118
  },
116
- date() {
117
- var elem = document.createElement("input");
118
- elem.type = "date";
119
- elem.$renders = [function () {
120
- var { data, field } = this.$scope;
121
- if (data && field) elem.value = parseDate(data[field.key]);
122
- }]
123
- input(elem);
124
- return elem;
119
+ date(m) {
120
+ var { data, field } = m;
121
+ m.innerHTML = `<input placeholder=${field.holder || '选择日期'} readonly -model=data[field.key] />`;
122
+ render(m, {
123
+ data, field, input,
124
+ });
125
+ select(m.firstChild, datepicker("年月日", data[field.key]));
126
+ },
127
+ datetime(m) {
128
+ var { data, field } = m;
129
+ m.innerHTML = `<input placeholder=${field.holder || '选择日期和时间'} readonly -model=data[field.key] />`;
130
+ render(m, {
131
+ data, field, input,
132
+ });
133
+ select(m.firstChild, datepicker("年月日时分", data[field.key]));
125
134
  },
126
135
  color() {
127
136
  return colorpicker();
@@ -200,7 +209,12 @@ var constructors = {
200
209
 
201
210
  }
202
211
  };
203
- constructors.price = constructors.money = constructors.number;
212
+ constructors.int
213
+ = constructors.num
214
+ = constructors.integer
215
+ = constructors.price
216
+ = constructors.money
217
+ = constructors.number;
204
218
  constructors.gen = constructors.generator;
205
219
  var readonly_types = {
206
220
  "date"({ field }, data) {
@@ -1,3 +1,46 @@
1
- &{
1
+ & {
2
2
  word-break: break-all;
3
- }
3
+ }
4
+
5
+ &[type=date] {
6
+ >input {
7
+ width: 8em;
8
+ cursor: default;
9
+ }
10
+ }
11
+
12
+ &[type=datetime] {
13
+ >input {
14
+ width: 10em;
15
+ cursor: default;
16
+ }
17
+ }
18
+
19
+ &[type=int] {
20
+ >input {
21
+ text-align: right;
22
+ width: 8em;
23
+
24
+ +span {
25
+ pointer-events: none;
26
+ }
27
+ }
28
+ }
29
+
30
+ @u(@l) {
31
+ @w: @{l}em/2 + .5em;
32
+
33
+ &[u@l] {
34
+ >input {
35
+ margin-right: -@w;
36
+ padding-right: @w+.2em;
37
+ }
38
+ }
39
+ }
40
+
41
+ @u(1);
42
+ @u(2);
43
+ @u(3);
44
+ @u(4);
45
+ @u(5);
46
+ @u(6);
@@ -257,9 +257,9 @@ var render = function (value, models = "年月日", message = "") {
257
257
  if (_index >= models.length) {
258
258
  _index--;
259
259
  preventDefault = false;
260
- container.value = map.call(models, (model, index) => `${value[model]()}${index + 1 < models.length ? value[model].format : ''}`).join("");
261
- dispatch("change", container);
262
260
  }
261
+ container.value = map.call(models, (model, index) => `${value[model]()}${index + 1 < models.length ? value[model].format : ''}`).join("");
262
+ dispatch("change", container);
263
263
  break;
264
264
  case "val":
265
265
  var val = target.innerText.trim().split(/\s+/);
@@ -57,9 +57,7 @@ body>& {
57
57
  background: inherit;
58
58
  position: relative;
59
59
  position: sticky;
60
- line-height: 20px;
61
60
  overflow: hidden;
62
- text-overflow: ellipsis;
63
61
  padding: 12px 16px 10px 16px;
64
62
 
65
63
  &:before {
@@ -133,5 +131,6 @@ body>& {
133
131
  a.button {
134
132
  display: inline-block;
135
133
  padding: 0;
134
+ margin-right: 6px;
136
135
  }
137
136
  }
@@ -9,9 +9,6 @@
9
9
  color: #f24;
10
10
  }
11
11
 
12
- form {
13
- padding: 0 0 6px 0;
14
- }
15
12
 
16
13
  form>* {
17
14
  margin-right: 16px;
@@ -34,6 +31,33 @@
34
31
  background: #069 !important;
35
32
  }
36
33
 
34
+ form:after {
35
+ content: '';
36
+ display: block;
37
+ clear: both;
38
+ }
39
+
40
+ form>div {
41
+ height: 44px;
42
+ line-height: 42px;
43
+ padding: 0;
44
+
45
+ >input {
46
+ width: 100%;
47
+ height: 36px;
48
+ }
49
+
50
+ @media (min-width:800px) {
51
+ float: right;
52
+
53
+ >input {
54
+ height: 32px;
55
+ width: 300px;
56
+ }
57
+ }
58
+
59
+ }
60
+
37
61
  p span,
38
62
  p a {
39
63
  vertical-align: middle;
@@ -48,9 +72,14 @@
48
72
  <button style="float:right" -if="tableData.length" @click="exportCSV">${i18n`导出到文件`}</button>
49
73
  <hr />
50
74
  <form>
51
- <checkbox -src="filters" @change="runFilter"></checkbox>
75
+ <div>
76
+ <input -model="searchText" placeholder="${i18n`搜索`}" />
77
+ </div>
78
+ <div>
79
+ <checkbox -src="filters" @change="runFilter"></checkbox>
80
+ </div>
52
81
  </form>
53
- <table #table-element -src="[fields,tableData]" @active="showDetail(event)">
82
+ <table #table-element _find="searchText" -src="filtedData" @active="showDetail(event)">
54
83
  </table>
55
84
  </div>
56
85
  <script>
@@ -347,7 +376,7 @@
347
376
  };
348
377
  var 已找到的字符串 = [];
349
378
  var fields = [
350
- { name: i18n`字符串`, key: "text", width: 280 },
379
+ { name: i18n`字符串`, type: 'text', key: "text", width: 280 },
351
380
  { name: i18n`已翻译`, key: "liang", width: 80 },
352
381
  { name: i18n`出现文件`, key: "files", width: 200 },
353
382
  { name: i18n`出现次数`, key: "count", width: 80 },
@@ -376,7 +405,9 @@
376
405
  }
377
406
  ].filter(a => !a.disabled)
378
407
  };
408
+ var searchText = '';
379
409
  var tableData = [];
410
+ var filtedData = [fields, tableData];
380
411
  var runFilter = function () {
381
412
  tableData = 已找到的字符串;
382
413
  var { options } = filters;
@@ -385,6 +416,11 @@
385
416
  tableData = tableData.filter(o.test);
386
417
  }
387
418
  }
419
+ filtedData = Table.from(fields, tableData);
420
+ if (searchText) filtedData.search(searchText, function () {
421
+ render.digest();
422
+ });
423
+ console.log(filtedData)
388
424
  };
389
425
  var detailWindow;
390
426
  var detailScope = {
@@ -506,7 +542,7 @@
506
542
  continue;
507
543
  }
508
544
  else {
509
- if (/^[\.]|_test\.js$/i.test(name)) continue;
545
+ if (/^[\.]|^node_modules|_test\.js$/i.test(name)) continue;
510
546
  if (e.kind === "file" && !/\.([mc]?[tj]sx?|xht|vue|html?)$/i.test(name)) continue;
511
547
  }
512
548
  e.path = path + e.name;
@@ -553,8 +589,9 @@
553
589
  var liang = 0, fanyi = {};
554
590
  for (var { lang: k, id } of supports) {
555
591
  if (!d[k]) continue;
556
- if (preMap[d[k]] && preMap[d[k]] !== d) continue loop;
557
- if (/\\r/.test(d[k])) console.log(d[k]);
592
+ if (preMap[d[k]] && preMap[d[k]] !== d) {
593
+ console.log(i18n`发现不同的翻译`, k, preMap[d[k]], d);
594
+ }
558
595
  preMap[d[k]] = d;
559
596
  liang++;
560
597
  fanyi[id] = d[k];
@@ -600,8 +637,12 @@
600
637
  accept: { 'text/plain': ['.yml'] },
601
638
  }],
602
639
  });
640
+ var msg = alert("正在导出", false);
603
641
  var w = await f.createWritable();
642
+ msg.setText("正在导出.", false);
604
643
  await w.write(YAML.stringify(objs));
644
+ msg.setText("正在导出..", false);
605
645
  await w.close();
646
+ msg.setText(i18n`导出完成`, 'success')
606
647
  };
607
648
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.5.4",
3
+ "version": "4.5.7",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {