efront 4.0.53 → 4.0.54

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.
@@ -75,7 +75,7 @@ class Table extends Array {
75
75
  if (isEmpty(name) || !isString(name)) continue;
76
76
  if (name === searchtext) this.hasFullmatch = true;
77
77
  var [p, m] = mark.power(name, searchtext);
78
- power += p;
78
+ if (p > power) power = p;
79
79
  if (p >= searchtext.length) this.coverCount++;
80
80
  if (!isEmpty(f.key)) o[f.key] = m;
81
81
  else o.name = m, o.toString = returnName, o.valueOf = returnName;
@@ -0,0 +1,54 @@
1
+ function readCSV(data) {
2
+ var reg = /""?|,|\r\n|\r|\n|\u2028|\u2029/g;
3
+ var str = [];
4
+ var instr = false;
5
+ var lastIndex = 0;
6
+ var row = [];
7
+ var table = [];
8
+ while (true) {
9
+ var m = reg.exec(data);
10
+ if (!m) break;
11
+ var s = data.slice(lastIndex, m.index);
12
+ lastIndex = reg.lastIndex;
13
+ if (s) str.push(s);
14
+ switch (m[0]) {
15
+ case `""`:
16
+ str.push('"');
17
+ break;
18
+ case `"`:
19
+ instr = !instr;
20
+ break;
21
+ case `,`:
22
+ if (instr) {
23
+ str.push(',');
24
+ }
25
+ else {
26
+ row.push(str.join(''));
27
+ str = [];
28
+ }
29
+ break;
30
+ case "\r\n":
31
+ case "\r":
32
+ case "\n":
33
+ case "\u2028":
34
+ case "\u2029":
35
+ if (instr) {
36
+ str.push("\r\n");
37
+ }
38
+ else {
39
+ row.push(str.join(""));
40
+ table.push(row);
41
+ row = [];
42
+ str = [];
43
+ }
44
+ break;
45
+ }
46
+ }
47
+ if (str.length || row.length) row.push(str.join(''));
48
+ if (row.length) table.push(row);
49
+ row = [];
50
+ str = [];
51
+ var fields = table.shift();
52
+ if (fields) fields = fields.map((a, i) => { return { name: a, key: i } })
53
+ return Table.from(fields, table);
54
+ }
@@ -11,7 +11,7 @@ var exec_ = function (args, ok, oh, int) {
11
11
  fina();
12
12
  }
13
13
  else if (catches.length) {
14
- catch_ = catches.pop();
14
+ catch_ = catches[catches.length - 1];
15
15
  [index, p, throwed] = catch_;
16
16
  index += p & 0xffff;
17
17
  if (p >>> 16) {
@@ -19,6 +19,7 @@ var exec_ = function (args, ok, oh, int) {
19
19
  }
20
20
  else {
21
21
  e = err;
22
+ catches.pop();
22
23
  fina();
23
24
  }
24
25
  }
@@ -1,4 +1,4 @@
1
- var { skipAssignment, snapSentenceHead, snapExpressFoot, EXPRESS, SCOPED, QUOTED, VALUE, STRAP, STAMP, number_reg, createString } = require("./common");
1
+ var { skipAssignment, snapSentenceHead, snapExpressFoot, EXPRESS, SPACE, SCOPED, QUOTED, VALUE, STRAP, STAMP, number_reg, createString } = require("./common");
2
2
  var strings = require("../basic/strings");
3
3
 
4
4
  var createRefId = function (o) {
@@ -206,6 +206,7 @@ function enumref(scoped) {
206
206
  continue;
207
207
  }
208
208
  if (!eq) break;
209
+ if (o.short) continue;
209
210
  o.type = eq.type;
210
211
  o.isdigit = true;
211
212
  o.text = eq.text;
@@ -26,4 +26,5 @@ t("for(;a=1;){ console.log(a)} console.log(a)", "for (; a = 1;) { console.log(1)
26
26
  t("for(;;a=1){ console.log(a)} console.log(a)", "for (;; a = 1) { console.log(a) } console.log(a)");
27
27
  t("for(var a = 1;;){ console.log(a)} console.log(a)", "for (var a = 1;;) { console.log(1) } console.log(1)");
28
28
  t("for(let a = 1;;){ console.log(a)} console.log(a)", "for (let a = 1;;) { console.log(a) } console.log(a)");
29
+ t("var a=-1; console.log(-a)", "var a = -1; console.log(- -1)");
29
30
  // t(fs.readFileSync(path.join(__dirname,"../zimoli/spacechar_test.js")).toString())
@@ -1107,7 +1107,8 @@ var createString = function (parsed) {
1107
1107
  else if (o.prev && o.type === STAMP && !/^([,;])$/.test(o.text)) {
1108
1108
  if (result[result.length - 1] === " " || (lasttype === PROPERTY || !o.isExpress && o.prev && o.prev.type !== LABEL) && o.text === ':') { }
1109
1109
  else if (lasttype === STAMP) {
1110
- result.push(" ");
1110
+ var prev = o.prev;
1111
+ if (!prev.unary || /[\+\-]$/.test(prev.text) && prev.text === o.text) result.push(" ");
1111
1112
  }
1112
1113
  else if (/^(\+\+|\-\-)$/.test(o.prev.text) && o.prev.prev) {
1113
1114
  var prev_prev = o.prev.prev;
@@ -1116,6 +1117,7 @@ var createString = function (parsed) {
1116
1117
  || prev_prev.type & (EXPRESS | VALUE)
1117
1118
  ) result.push(";");
1118
1119
  }
1120
+
1119
1121
  else if (o.text === '*') {
1120
1122
  if (keepspace && lasttype !== SPACE && (lasttype !== STRAP || o.prev && o.prev.text !== 'function')) result.push(" ");
1121
1123
  }
@@ -1127,6 +1129,9 @@ var createString = function (parsed) {
1127
1129
  if (/^0[0-7]+$/.test(o.text)) {
1128
1130
  o.text = '0o' + o.text.slice(1);
1129
1131
  }
1132
+ if (+o.text < 0 && /\-$/.test(result[result.length - 1])) {
1133
+ result.push(" ");
1134
+ }
1130
1135
  }
1131
1136
  result.push(o.text);
1132
1137
  }
@@ -121,6 +121,10 @@ function testQuote() {
121
121
  var m = scanner(`(sizeof(("table")) / sizeof(("table")[0]))`);
122
122
  console.log(m.toString());
123
123
  }
124
+ function testMinus() {
125
+ var m = scanner(`a- - -!!!b`);
126
+ console.log(m.toString());
127
+ }
124
128
  Program.debug = true;
125
129
  // testSpeed();
126
130
  // testVariables();
@@ -136,6 +140,7 @@ Program.debug = true;
136
140
  // testArrow();
137
141
  // testUnicode();
138
142
  // testComment();
139
- testQuote();
143
+ // testQuote();
144
+ testMinus();
140
145
  // var typescript = require("../typescript/index");
141
146
  // typescript.transpile(data.toString(), { noEmitHelpers: true });
@@ -88,7 +88,6 @@
88
88
 
89
89
  &>.track {
90
90
  border-radius: inherit;
91
- transition: box-shadow .1s, background-color .2s;
92
91
  width: 100%;
93
92
  height: 100%;
94
93
  position: absolute;
@@ -1,4 +1,5 @@
1
1
  & {
2
2
  cursor: default;
3
3
  outline: none;
4
+ max-height: 50%;
4
5
  }
@@ -257,7 +257,7 @@ function main(elem) {
257
257
  elem.innerHTML = '<span ng-bind=get()></span>';
258
258
  render(elem, {
259
259
  get() {
260
- if (!field.key) return;
260
+ if (isEmpty(field.key)) return;
261
261
  var value = seek(data, field.key);
262
262
  if (field.options) {
263
263
  if (!field.optionsMap) {
@@ -13,9 +13,9 @@
13
13
  <td fixed row-index -bind="i+1" :style="adapter.firstChild.getAttribute('style')">
14
14
  </td>
15
15
  <td fixed:="f.fixed" -repeat="(f,i) in fields" :style="adapter.children[i+1].getAttribute('style')">
16
- <model -if="f.key&&!isEmpty(d[f.key])" :field=f :data=d readonly></model>
16
+ <model -if="!isEmpty(f.key)&&!isEmpty(d[f.key])" :field=f :data=d readonly></model>
17
17
  <template -else>&nbsp;</template>
18
- <a on-click="o.do(d)" -if="!f.key&&f.options&&(!o.when||o.when(d))"
18
+ <a on-click="o.do(d)" -if="isEmpty(f.key)&&f.options&&(!o.when||o.when(d))"
19
19
  _type="o.type instanceof Function?o.type(d):o.type" -repeat="o in f.options">
20
20
  <span -text="o.name instanceof Function?o.name(d):o.name"></span>
21
21
  </a>
@@ -371,28 +371,23 @@ var getTdsOfSameRow = function (td) {
371
371
  return tds;
372
372
  };
373
373
  function setContextMenu(thead) {
374
- var fields = this.fields.slice();
375
- var scope = this;
376
- var menuItems = fields.map(f => {
377
- return {
378
- name: f.name || "&nbsp;",
379
- checked: !f.hidden,
380
- width: f.width,
381
- do() {
382
- this.checked = !this.checked;
383
- f.hidden = !this.checked;
384
- scope.fields = fields.filter(f => !f.hidden);
385
- var width = thead.scrollWidth / scope.fields.length;
386
- if (!width || width < 200) width = 200;
387
- forEachRow(thead, function (tr) {
388
- for (var td of tr.children) {
389
- if (td.offsetWidth > width) css(td, { width });
390
- }
391
- });
392
- setLazyFixedColumn.call(thead.parentNode, true)
374
+ var fields = this.originFields.slice();
375
+ var _do = function () {
376
+ this.checked = !this.checked;
377
+ var f = fields[this.index];
378
+ f.hidden = !this.checked;
379
+ scope.fields = fields.filter(f => !f.hidden);
380
+ var width = thead.scrollWidth / scope.fields.length;
381
+ if (!width || width < 200) width = 200;
382
+ forEachRow(thead, function (tr) {
383
+ for (var td of tr.children) {
384
+ if (td.offsetWidth > width) css(td, { width });
393
385
  }
394
- }
395
- });
386
+ });
387
+ setLazyFixedColumn.call(thead.parentNode, true)
388
+ };
389
+ var menuItems = fields.map((f, i) => ({ name: f.name || "&nbsp", index: i, width: f.width, key: f.key, checked: !f.hidden, do: _do }));
390
+ var scope = this;
396
391
  contextmenu(thead, menuItems);
397
392
  }
398
393
  function table(elem) {
@@ -468,11 +463,19 @@ function table(elem) {
468
463
  };
469
464
  vbox(table, 'x');
470
465
  };
471
- care(table, async function ([fields, data]) {
466
+ care(table, async function (src) {
467
+ if (src instanceof Table) {
468
+ data = src;
469
+ fields = data.fields;
470
+ }
471
+ else if (src instanceof Array) {
472
+ var [fields, data] = src;
473
+ }
474
+ else throw new Error("table组件源数据错误!");
472
475
  if (_vbox) _vbox(), _vbox = null;
473
476
  watch(table, {
474
477
  find(text) {
475
- if ($scope.data.constructor === Table){
478
+ if ($scope.data.constructor === Table) {
476
479
  $scope.data.searchText = text;
477
480
  $scope.data.update();
478
481
  }
@@ -485,7 +488,8 @@ function table(elem) {
485
488
  markedRows = false;
486
489
  this.style.display = 'block';
487
490
  var $scope = {
488
- fields,
491
+ originFields: fields,
492
+ fields: fields.filter(f => !f.hidden),
489
493
  isEmpty,
490
494
  hasFoot: true,
491
495
  setContextMenu,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.0.53",
3
+ "version": "4.0.54",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {