efront 4.5.14 → 4.5.16

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.
@@ -68,11 +68,29 @@ var getRowsOfTdsByCol = function (table, start, end) {
68
68
  var getTdsByCol = function (table, start, end) {
69
69
  return [].concat.apply([], getRowsOfTdsByCol(table, start, end));
70
70
  };
71
+ var resizeR = function (t) {
72
+ var h = 0;
73
+ var children = [];
74
+ for (var c of t.children) {
75
+ if (getColspan(c) > 1) continue;
76
+ children.push(c);
77
+ }
78
+ for (var c of children) {
79
+ var height = c.offsetHeight;
80
+ if (h < height) h = height;
81
+ }
82
+ for (var c of children) {
83
+ var height = c.offsetHeight;
84
+ if (h > height) {
85
+ css(c, { height: h });
86
+ }
87
+ }
88
+ }
71
89
  var resizeT = function (t, w) {
72
90
  if (!w) {
73
91
  var w = 0;
74
- for (var cx = 0, dx = t.children.length; cx < dx; cx++) {
75
- w += t.children[cx].offsetWidth;
92
+ for (var c of t.children) {
93
+ w += c.offsetWidth;
76
94
  }
77
95
  }
78
96
  css(t, { width: w });
@@ -143,6 +161,7 @@ var resizeColumn = function (target, targetW) {
143
161
  }
144
162
  };
145
163
  var resizeTarget = function (event) {
164
+ if (swapping && onclick.preventClick) swapping.end(), swapping = null;
146
165
  var { resizing } = this;
147
166
  if (!resizing) return;
148
167
  event.moveLocked = true;
@@ -328,9 +347,7 @@ var removeYIng = function (activeCols) {
328
347
  });
329
348
  };
330
349
  var removeXIng = function (activeRows) {
331
- activeRows.forEach(function (td) {
332
- removeClass(td, 'x-ing');
333
- });
350
+ for (var td of activeRows) removeClass(td, 'x-ing');
334
351
  };
335
352
 
336
353
  var getTdsOfSameRow = function (td) {
@@ -390,15 +407,34 @@ function setContextMenu(thead) {
390
407
  var scope = this;
391
408
  contextmenu(thead, menuItems);
392
409
  }
410
+
411
+ var swapping = null;
412
+
393
413
  function table(elem) {
394
414
  var tableElement = isElement(elem) ? elem : document.createElement("table");
395
415
  var activeCols = [];
396
416
  bind('mousemove')(tableElement, adaptTarget);
417
+ var updateSummaryFields = null;
397
418
  moveupon(tableElement, {
398
419
  start(event) {
399
- if (this.resizing) event.preventDefault();
420
+ if (this.resizing) return event.preventDefault();
421
+ if (!updateSummaryFields) return;
422
+ var thead = getThead(this);
423
+ var th = getTargetIn(thead, event.target, false);
424
+ if (!th) return;
425
+ if (th.tagName.toLowerCase() === 'tr') th = getTargetIn(th, event.target, false);
426
+ var field = th.$scope?.f;
427
+ if (!field || field.fixed || !isHandled(field.key)) return;
428
+ swapping = lazySwap(th, function (value) {
429
+ field.summary = value;
430
+ updateSummaryFields();
431
+ });
432
+ swapping.start();
400
433
  },
401
434
  move: resizeTarget,
435
+ end() {
436
+ if (swapping) swapping.end(), swapping = null;
437
+ }
402
438
  });
403
439
  var activeRows = [];
404
440
  onmousemove(tableElement, function (event) {
@@ -420,6 +456,7 @@ function table(elem) {
420
456
  }
421
457
  if (!getTargetIn(thead, event.target)) return;
422
458
  var tds = cellMatchManager(event.target);
459
+
423
460
  if (!tds) return;
424
461
  setClass(tds, 'y-ing', activeCols);
425
462
  removeXIng(activeRows);
@@ -440,13 +477,15 @@ function table(elem) {
440
477
  };
441
478
  var cellMatchManager = function (element) {
442
479
  if (!thead) thead = getThead(table);
443
- if (!getTargetIn(thead, element)) return false;
444
- if (!tdElementReg.test(element.tagName)) return false;
480
+ var td = getTargetIn(thead, element, false);
481
+ if (!td) return false;
482
+ if (td.tagName.toLowerCase() === 'tr') td = getTargetIn(td, element, false);
483
+ if (!tdElementReg.test(td.tagName)) return false;
445
484
  if (!markedRows) {
446
485
  markThead();
447
486
  markedRows = true;
448
487
  }
449
- var { colstart, colend } = element;
488
+ var { colstart, colend } = td;
450
489
  return getTdsByCol(table, colstart, colend);
451
490
  };
452
491
  watch(table, {
@@ -481,6 +520,10 @@ function table(elem) {
481
520
  }
482
521
  }
483
522
  })
523
+ updateSummaryFields = function () {
524
+ $scope.data.summaryFields = fields.filter(f => f.summary);
525
+ $scope.data.update();
526
+ };
484
527
  thead = null;
485
528
  fields.forEach(enrichField);
486
529
  remove(this.children);
@@ -517,6 +560,7 @@ function table(elem) {
517
560
  data,
518
561
  adapter: null,
519
562
  resizeT,
563
+ resizeR,
520
564
  model,
521
565
  sort(f) {
522
566
  this.data.sort(f);
@@ -43,26 +43,26 @@ td {
43
43
  white-space: normal;
44
44
  height: 100%;
45
45
  padding: 2px 10px;
46
+
47
+ >* {
48
+ position: relative;
49
+ }
46
50
  }
47
51
 
48
52
  .y-ing,
49
53
  .x-ing {
50
- &:before {
51
- content: "";
54
+ >mask {
52
55
  position: absolute;
53
56
  left: 0;
54
57
  top: 0;
55
58
  bottom: 0;
56
59
  right: 0;
60
+ pointer-events: none;
57
61
  background-color: rgba(0, 60, 69, .06);
58
62
  }
59
-
60
- >* {
61
- position: relative;
62
- }
63
63
  }
64
64
 
65
- [draggable="false"]:before {
65
+ [draggable="false"]>mask {
66
66
  display: none;
67
67
  }
68
68
 
@@ -70,7 +70,7 @@ thead {
70
70
 
71
71
  .y-ing,
72
72
  .x-ing {
73
- &:before {
73
+ >mask {
74
74
  background-color: rgba(0, 60, 69, .3);
75
75
  }
76
76
  }
@@ -143,8 +143,27 @@ thead {
143
143
  color: #fff;
144
144
  background-color: #395268;
145
145
  clear: both;
146
+
147
+ &:before {
148
+ content: '';
149
+ display: block;
150
+ position: absolute;
151
+ left: 0;
152
+ height: 0;
153
+ bottom: 0;
154
+ right: 0;
155
+ background: #426;
156
+ transition: height .3s ease-in;
157
+ transition-delay: .7s;
158
+ }
159
+
160
+ &[swapped]:before {
161
+ height: 100%;
162
+ }
146
163
  }
147
164
  }
165
+
166
+
148
167
  }
149
168
 
150
169
  >tbody {
@@ -61,11 +61,6 @@
61
61
  }
62
62
 
63
63
  }
64
-
65
- p span,
66
- p a {
67
- vertical-align: middle;
68
- }
69
64
  </style>
70
65
  <p><span>${i18n`翻译结果仅做为参考,未必完美替换,语法参考:`}<a @click="zimoli.go('/组件/basic/i18n.js',{mark:true})">i18n.js</a></span></p>
71
66
  <p -if="!window.showDirectoryPicker" error>${i18n`国际化工具仅在浏览器支持 showDirectoryPicker 时可用`}</p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.5.14",
3
+ "version": "4.5.16",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {