efront 3.22.3 → 3.22.6

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,5 +1,5 @@
1
1
  function main(element) {
2
- var page = element || div();
2
+ var page = element || document.createElement('pagination');
3
3
  page.innerHTML = pagination;
4
4
  render(page, {
5
5
  xlist: list,
@@ -7,26 +7,10 @@ function main(element) {
7
7
  fromPixel,
8
8
  pages: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
9
9
  next() {
10
- var index = this.pglist.index();
11
- index += 10;
12
- if (this.pages.length < index + 10) {
13
- index = this.pages.length - 10;
14
- }
15
- if (index < 0) {
16
- index = 0;
17
- }
18
- this.pglist.go(index);
10
+ this.pglist.scrollBy(this.pglist.clientWidth);
19
11
  },
20
12
  prev() {
21
- var index = this.pglist.index();
22
- index -= 10;
23
- if (this.pages.length < index + 10) {
24
- index = this.pages.length - 10;
25
- }
26
- if (index < 0) {
27
- index = 0;
28
- }
29
- this.pglist.go(index);
13
+ this.pglist.scrollBy(-this.pglist.clientWidth);
30
14
  },
31
15
  start() {
32
16
  this.pglist.go(0);
@@ -39,10 +23,11 @@ function main(element) {
39
23
  this.pglist.go(index);
40
24
  }
41
25
  });
42
-
43
- page.querySelector("xlist").go(0);
44
- once("append")(page, function () {
45
- console.log(page);
46
- })
26
+ var pglist = page.querySelector('xlist');
27
+ onmounted(page, function () {
28
+ console.log(pglist)
29
+ pglist.XScrollBoxId = 1;
30
+ pglist.go(0);
31
+ });
47
32
  return page;
48
33
  }
@@ -1,26 +1,41 @@
1
+ *{
2
+ box-sizing: border-box;
3
+ }
1
4
  & {
2
5
  white-space: nowrap;
6
+ display: block;
7
+ min-width: 240px;
8
+ width: 100%;
9
+ position: relative;
10
+ }
11
+
12
+ >xlist {
3
13
  display: inline-block;
14
+ text-overflow: clip;
15
+ text-align: center;
16
+ position: relative;
17
+ overflow: hidden;
18
+ vertical-align: top;
19
+ border-left: 72px solid transparent;
20
+ border-right: 72px solid transparent;
21
+ margin: 0 -72px 0 -72px;
4
22
 
5
- >xlist {
6
- width: auto;
7
- display: inline-block;
8
- text-overflow: clip;
9
- min-width: 40px;
10
- text-align: center;
11
- max-width: 400px;
12
- position: relative;
13
- overflow: hidden;
14
- vertical-align: top;
23
+ .button {
24
+ border-radius: 0;
15
25
  }
26
+ }
16
27
 
17
- btn {
18
- width: 40px;
19
- height: 40px;
20
- line-height: 40px;
21
- vertical-align: top;
22
- display: inline-block;
23
- background-color: inherit;
24
- color: inherit;
25
- }
28
+ btn.button {
29
+ box-shadow: none;
30
+ padding: 0 10px;
31
+ min-width: 36px;
32
+ height: 28px;
33
+ line-height: 28px;
34
+ color: #999;
35
+ margin: 0;
36
+ vertical-align: top;
37
+ display: inline-block;
38
+ background-color: inherit;
39
+ color: inherit;
40
+ z-index: 1;
26
41
  }
@@ -20,7 +20,7 @@ function random_test() {
20
20
  var id = 0;
21
21
  var run = function () {
22
22
  if (id >= args.length) return;
23
- alert(toString(random.apply(null, args[id])));
23
+ console.log(toString(random.apply(null, args[id])));
24
24
  id++;
25
25
  setTimeout(run, 200);
26
26
  }
@@ -7,22 +7,24 @@
7
7
  <textarea _value="refilm_encode(steps[index])">
8
8
 
9
9
  </textarea>
10
- <table class="form">
11
- <thead>
12
- <tr>
13
- <td ng-repeat="(f,i) in refilms">
14
- <span ng-bind="f.name"></span>
15
- </td>
16
- </tr>
17
- </thead>
18
- <tbody>
19
- <tr ng-repeat="s in steps[index]">
20
- <td ng-repeat="r in refilms">
21
- <span bg-bind="String(s[r.key]||'')"></span>
22
- </td>
23
- </tr>
24
- </tbody>
25
- </table>
10
+ <div class="form">
11
+ <table>
12
+ <thead>
13
+ <tr>
14
+ <td ng-repeat="(f,i) in refilms">
15
+ <span ng-bind="f.name"></span>
16
+ </td>
17
+ </tr>
18
+ </thead>
19
+ <tbody>
20
+ <tr ng-repeat="s in steps[index]">
21
+ <td ng-repeat="r in refilms">
22
+ <span bg-bind="String(s[r.key]||'')"></span>
23
+ </td>
24
+ </tr>
25
+ </tbody>
26
+ </table>
27
+ </div>
26
28
  <form class="form">
27
29
  <field ng-src="[f,data]" ng-repeat="(f,i) in steps[index]"></field>
28
30
  </form>
@@ -28,17 +28,24 @@
28
28
  }
29
29
 
30
30
  >textarea,
31
- >table {
31
+ >.form {
32
32
  width: 400px;
33
33
  }
34
34
 
35
35
  >textarea,
36
36
  >form,
37
- >table {
37
+ >.form {
38
38
  overflow: auto;
39
39
  height: calc(~"100% - 220px");
40
40
  vertical-align: top;
41
41
  display: inline-block;
42
+ table{
43
+ width: auto;
44
+ }
45
+ td{
46
+ white-space: nowrap;
47
+ overflow: hidden;
48
+ }
42
49
  font-size: 16px;
43
50
  font-family: 仿宋;
44
51
  }
@@ -160,8 +160,10 @@ resize.on = function (elem, dragHandle) {
160
160
  if (!~resizingElements.indexOf(elem)) {
161
161
  resizingElements.push(elem);
162
162
  }
163
- bind('render')(elem, resizeh);
163
+ resizeh.call(elem);
164
164
  });
165
+ bind('render')(elem, resizeh);
166
+ bind('resize')(elem, resizeh);
165
167
  on('remove')(elem, function () {
166
168
  var index = resizingElements.indexOf(this);
167
169
  if (~index) resizingElements.splice(index, 1);
@@ -210,7 +210,7 @@ function slider(autoplay, circle = true) {
210
210
  var deltax = event.clientX - saved_x;
211
211
  var deltay = event.clientY - saved_y;
212
212
  if (!direction) {
213
- if (abs(deltax) < MOVELOCK_DELTA && abs(deltay) < MOVELOCK_DELTA) return;
213
+ if (!onclick.preventClick) return;
214
214
  if (abs(deltay) - abs(deltax) > 0) { //垂直方向
215
215
  direction = -1;
216
216
  } else { //水平方向
@@ -21,4 +21,12 @@
21
21
  </a>
22
22
  </td>
23
23
  </tr>
24
- </tbody>
24
+ </tbody>
25
+ <tfoot>
26
+ <tr -if="!data||!data.length" style="padding-bottom: 20px;">
27
+ <td style="text-align: center;">
28
+ <template -if="data.is_loading">加载中</template>
29
+ <template -else>无数据</template>
30
+ </td>
31
+ </tr>
32
+ </tfoot>
@@ -12,7 +12,6 @@ var moveMargin = function (element, movePixels) {
12
12
  marginRight: movePixels ? -movePixels + "px" : ""
13
13
  });
14
14
  };
15
-
16
15
  var markRowTds = function (tr, deltas, colstart, colend) {
17
16
  var inc = 0;
18
17
  var collections = [];
@@ -20,8 +19,8 @@ var markRowTds = function (tr, deltas, colstart, colend) {
20
19
  while (deltas[inc] > 0) {
21
20
  deltas[inc++]--;
22
21
  }
23
- var colspan = +td.getAttribute("colspan") || 1;
24
- var rowspan = +td.getAttribute("rowspan") || 1;
22
+ var colspan = getColspan(td);
23
+ var rowspan = getRowspan(td);
25
24
  rowspan = rowspan > 1 ? rowspan - 1 : 0;
26
25
  colspan = colspan > 1 ? colspan - 1 : 0;
27
26
  for (var cx = inc, dx = colspan + inc; cx <= dx; cx++) {
@@ -40,8 +39,8 @@ var markRowTds = function (tr, deltas, colstart, colend) {
40
39
  });
41
40
  return collections;
42
41
  };
43
- var forEachTableRow = function (table, call) {
44
- for (var tr of table.children) {
42
+ var forEachRow = function (tbody, call) {
43
+ for (var tr of tbody.children) {
45
44
  if (isTableRow(tr)) {
46
45
  call(tr);
47
46
  }
@@ -51,12 +50,18 @@ var forEachTableRow = function (table, call) {
51
50
  }
52
51
  }
53
52
  var getRowsOfTdsByCol = function (table, start, end) {
54
- var savedRowDeltas = [];
55
53
  var savedCollections = [];
56
- forEachTableRow(table, function (tr) {
54
+ var thead = getThead(table);
55
+ var tbody = getTbody(table);
56
+ var savedRowDeltas;
57
+ if (thead) savedRowDeltas = [], forEachRow(thead, function (tr) {
57
58
  var collections = markRowTds(tr, savedRowDeltas, start, end);
58
59
  savedCollections.push(collections);
59
- })
60
+ });
61
+ if (tbody) savedRowDeltas = [], forEachRow(tbody, function (tr) {
62
+ var collections = markRowTds(tr, savedRowDeltas, start, end);
63
+ savedCollections.push(collections);
64
+ });
60
65
  return savedCollections;
61
66
  }
62
67
  var getTdsByCol = function (table, start, end) {
@@ -81,17 +86,29 @@ var getTbody = function (table) {
81
86
  if (/^tbody$/i.test(c.tagName) || c.hasAttribute("tbody")) return c;
82
87
  }
83
88
  };
89
+ var getTfoot = function (table) {
90
+ for (var c of table.children) {
91
+ if (/^tfoot$/i.test(c.tagName) || c.hasAttribute("tfoot")) return c;
92
+ }
93
+ };
84
94
  var isTableRow = function (e) {
85
95
  return trElementReg.test(e.tagName);
86
96
  };
97
+ var getRowspan = function (e) {
98
+ return +e.getAttribute('rowspan') || 1;
99
+ };
100
+ var getColspan = function (e) {
101
+ return +e.getAttribute('colspan') || 1;
102
+ }
87
103
  var resizeColumn = function (target, targetW) {
88
104
  var deltaW = targetW - target.offsetWidth;
89
- forEachTableRow(this, function (tr) {
105
+ forEachRow(this, function (tr) {
90
106
  resizeT(tr, tr.offsetWidth + deltaW);
91
107
  });
92
108
  for (var c of this.children) {
93
109
  if (!isTableRow(c)) {
94
110
  var tr = c.querySelector('tr');
111
+ if (!tr) continue;
95
112
  c.style.width = tr.style.width;
96
113
  }
97
114
  }
@@ -104,6 +121,7 @@ var resizeColumn = function (target, targetW) {
104
121
  for (var c of cs) {
105
122
  w += c.offsetWidth;
106
123
  }
124
+ if (!cs.length) continue;
107
125
  w = targetW - w;
108
126
  while (w !== 0) {
109
127
  var c = cs.pop();
@@ -134,8 +152,8 @@ var getFirstSingleColCell = function (table, col) {
134
152
  var tds = getTdsByCol(table, col, col);
135
153
  while (tds.length) {
136
154
  var td = tds.shift();
137
- var colspan = td.getAttribute("colspan") || 1;
138
- if (1 === +colspan) return td;
155
+ var colspan = getColspan(td);
156
+ if (1 === colspan) return td;
139
157
  }
140
158
  }
141
159
  var adaptTarget = function (event) {
@@ -212,7 +230,7 @@ function enrichField(f) {
212
230
  }
213
231
  }
214
232
  var tbodyHeight = function (tbody) {
215
- return { 'max-height': ((innerHeight - getScreenPosition(tbody).top - 16) / 32 | 0) * 32 }
233
+ return { 'max-height': ((innerHeight - getScreenPosition(tbody).top - 8) / 36 | 0) * 36 }
216
234
  };
217
235
 
218
236
  var setFixed = function (children, scrolled, left, borderRight) {
@@ -271,67 +289,103 @@ var setFixedColumn = function () {
271
289
  }
272
290
  setFixed.call(this, children, this.scrollLeft, 'left', 'borderRight');
273
291
  setFixed.call(this, children.reverse(), this.scrollWidth - this.clientWidth - this.scrollLeft, 'right', 'borderLeft');
292
+ var tfoot = getTfoot(this);
293
+ if (tfoot) {
294
+ css(tfoot, { left: this.scrollLeft });
295
+ }
296
+ };
297
+ var setClass = function (tds, cls, old) {
298
+ tds.forEach(td => td[cls] = true);
299
+ old.forEach(td => { if (!td[cls]) removeClass(td, cls) });
300
+ tds.forEach(td => { addClass(td, cls); delete td[cls] });
301
+ };
302
+ var getTdsOfSameRow = function (td) {
303
+ var tds = [td];
304
+ var tmp = td;
305
+ var rowspan = getRowspan(td);
306
+ var { colstart, colend } = td;
307
+ while (tmp) {
308
+ tmp = tmp.previousElementSibling;
309
+ if (!tmp) break;
310
+ if (colstart - tmp.colend > 1) break;
311
+ if (getRowspan(tmp) > rowspan) break;
312
+ tds.push(tmp);
313
+ colstart = tmp.colstart;
314
+ };
315
+ tmp = td;
316
+ while (tmp) {
317
+ tmp = tmp.nextElementSibling;
318
+ if (!tmp) break;
319
+ if (tmp.colstart - colend > 1) break;
320
+ if (getRowspan(tmp) > rowspan) break;
321
+ tds.push(tmp);
322
+ colend = tmp.colend;
323
+ }
324
+ var tr = td.parentNode;
325
+ while (rowspan > 1) {
326
+ tr = tr.nextElementSibling;
327
+ if (!tr) break;
328
+ for (var c of tr.children) {
329
+ if (c.colstart >= colstart && c.colend <= colend) {
330
+ if (getRowspan(c) <= rowspan) {
331
+ tds.push(c);
332
+ }
333
+ }
334
+ }
335
+ rowspan--;
336
+ }
337
+ return tds;
274
338
  };
275
-
276
339
  function table(elem) {
277
340
  var tableElement = isElement(elem) ? elem : document.createElement("table");
278
341
  var activeCols = [];
279
- var adaptCursor = adaptTarget.bind(tableElement);
280
- var off;
281
- tableElement.init = function () {
282
- off = on("mousemove")(window, adaptCursor);
283
- };
284
- tableElement.dispose = tableElement.destroy = function () {
285
- off();
286
- };
287
- on("append")(tableElement, tableElement.init);
288
- on("remove")(tableElement, tableElement.destroy);
289
- if (isMounted(tableElement)) tableElement.init();
290
-
342
+ bind('mousemove')(tableElement, adaptTarget);
291
343
  moveupon(tableElement, {
292
344
  start(event) {
293
345
  if (this.resizing) event.preventDefault();
294
346
  },
295
347
  move: resizeTarget,
296
348
  });
349
+ var activeRows = [];
297
350
  onmousemove(tableElement, function (event) {
351
+ if (table.resizing) return;
352
+ var tbody = getTbody(table);
353
+ a: if (tbody) {
354
+ var tr = getTargetIn(tbody, event.target, false);
355
+ if (!tr) break a;
356
+ var td = getTargetIn(tr, event.target, false);
357
+ if (!td) break a;
358
+ var tds = getTdsOfSameRow(td);
359
+ setClass(tds, 'x-ing', activeRows);
360
+ activeRows = tds;
361
+ return;
362
+ }
298
363
  if (!thead) {
299
364
  thead = getThead(table);
300
365
  }
301
366
  if (!getTargetIn(thead, event.target)) return;
302
- if (table.resizing) return;
303
367
  var tds = getTargetIn(cellMatchManager, event.target);
304
- if (!isArray(tds)) tds = [];
305
- tds.map(function (td) {
306
- td.ying = true;
307
- });
308
- activeCols.map(function (td) {
309
- if (!td.ying) removeClass(td, "y-ing");
310
- });
311
- activeCols = tds.map(function (td) {
312
- addClass(td, "y-ing");
313
- delete td.ying;
314
- return td;
315
- });
368
+ setClass(tds, 'y-ing', activeCols);
369
+ activeCols = tds;
316
370
  });
317
371
  onmouseleave(tableElement, function () {
318
- activeCols.map(function (td) {
372
+ activeCols.forEach(function (td) {
319
373
  removeClass(td, "y-ing");
320
374
  });
375
+ activeRows.forEach(function (td) {
376
+ removeClass(td, 'x-ing');
377
+ });
321
378
  });
322
379
  var table = tableElement;
323
380
  var thead;
324
381
  var markedRows = false;
325
382
  var cellMatchManager = function (element) {
326
- if (!thead) {
327
- [thead] = table.getElementsByTagName("thead");
328
- if (!thead) thead = table.querySelector('[thead]');
329
- }
383
+ if (!thead) thead = getThead(table);
330
384
  if (!getTargetIn(thead, element)) return false;
331
385
  if (!tdElementReg.test(element.tagName)) return false;
332
386
  if (!markedRows) {
333
387
  var savedRowDeltas = [];
334
- [].map.call(thead.children, function (tr) {
388
+ Array.prototype.forEach.call(thead.children, function (tr) {
335
389
  markRowTds(tr, savedRowDeltas);
336
390
  });
337
391
  markedRows = true;
@@ -340,9 +394,6 @@ function table(elem) {
340
394
  return getTdsByCol(table, colstart, colend);
341
395
  };
342
396
 
343
- table.dragbox = function () {
344
- return thead;
345
- };
346
397
  table.useIncrease = false;
347
398
  var _vbox = function () {
348
399
  table.$Left = function (x) {
@@ -398,6 +449,7 @@ function table(elem) {
398
449
  },
399
450
  a: button,
400
451
  setFixedColumn,
452
+ pagination
401
453
  }, this.$parentScopes.concat(this.$scope));
402
454
  })
403
455
  autodragchildren(
@@ -7,12 +7,11 @@
7
7
 
8
8
  >th,
9
9
  >td {
10
- box-shadow: 1px 0 0 0 #00000033, -1px 0 0 0 #00000033;
10
+ &:not(.y-ing) {
11
+ box-shadow: 1px 0 0 0 #00000033, -1px 0 0 0 #00000033;
12
+ }
11
13
  }
12
14
 
13
- &:insert {
14
- background: #999;
15
- }
16
15
  }
17
16
  }
18
17
 
@@ -43,11 +42,11 @@ th,
43
42
  td {
44
43
  white-space: normal;
45
44
  height: 100%;
46
- border: 1px solid transparent;
47
- padding: 1px 10px;
45
+ padding: 2px 10px;
48
46
  }
49
47
 
50
- .y-ing {
48
+ .y-ing,
49
+ .x-ing {
51
50
  &:before {
52
51
  content: "";
53
52
  position: absolute;
@@ -55,7 +54,7 @@ td {
55
54
  top: 0;
56
55
  bottom: 0;
57
56
  right: 0;
58
- background-color: rgba(0, 30, 69, .06);
57
+ background-color: rgba(0, 60, 69, .06);
59
58
  }
60
59
 
61
60
  >* {
@@ -90,6 +89,29 @@ td {
90
89
 
91
90
  [fixed] {
92
91
  z-index: 2;
92
+ border-left: 1px solid transparent;
93
+ border-right: 1px solid transparent;
94
+ }
95
+
96
+ >tfoot {
97
+ width: 100%;
98
+ display: block;
99
+ position: relative;
100
+ color: #bbb;
101
+
102
+ >tr {
103
+ width: 100%;
104
+ display: block;
105
+
106
+ >td {
107
+ display: block;
108
+ width: 100%;
109
+ }
110
+ }
111
+
112
+ pagination {
113
+ width: 100%;
114
+ }
93
115
  }
94
116
 
95
117
  >thead {
@@ -134,21 +156,14 @@ td {
134
156
 
135
157
  >td,
136
158
  th {
137
- background-color: #f2f4f6;
159
+ background-color: #f8fbfd;
138
160
  }
139
161
  }
140
162
 
141
163
 
142
- &:hover {
143
-
144
- >td,
145
- >th {
146
- background: #e9edf2;
147
- }
148
- }
149
164
  }
150
165
 
151
- >tr[insert] {
166
+ >tr[thead] {
152
167
  position: sticky;
153
168
  top: 0;
154
169
  z-index: 1;
@@ -0,0 +1,32 @@
1
+ <thead>
2
+ <tr>
3
+ <td colspan=2><span>1</span></td>
4
+ <td rowspan=2><span>th1</span></td>
5
+ <td>th3</td>
6
+ <td>th4</td>
7
+ </tr>
8
+ <tr>
9
+ <td>th3</td>
10
+ <td>th4</td>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <tr>
15
+ <td rowspan=2>td1</td>
16
+ <td>td2</td>
17
+ <td>td3</td>
18
+ <td>td4</td>
19
+ </tr>
20
+ <tr>
21
+ <td>td2</td>
22
+ <td>td3</td>
23
+ <td>td4</td>
24
+ </tr>
25
+ <tr>
26
+ <td rowspan=2>td1</td>
27
+ <td>td2</td>
28
+ </tr>
29
+ <tr>
30
+ <td>&nbsp;</td>
31
+ </tr>
32
+ </tbody>
@@ -1,12 +1,5 @@
1
1
  function table_test() {
2
- var data = new Array(100).fill(0).map(function () {
3
- return {
4
- name: random(random$name),
5
- tel: random(random$phone)
6
- };
7
- });
8
2
  var datatable = table();
9
- datatable.innerHTML = `<thead><tr><td colspan=2><span>1</span></td><td rowspan=2><span>th1</span></td><td>th3</td><td>th4</td></tr><tr><td>th3</td><td>th4</td></tr></thead><tbody><tr><td rowspan=2>td1</td><td>td2</td><td>td3</td><td>td4</td></tr><tr><td rowspan=2>td1</td><td>td2</td></tr></tbody>`;
10
- console.log(datatable);
3
+ datatable.innerHTML = template;
11
4
  return datatable;
12
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.22.3",
3
+ "version": "3.22.6",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {