efront 3.22.9 → 3.24.2

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,25 +1,31 @@
1
1
 
2
- function create(commFactory, className) {
2
+ var _create = function (commFactory, className, _invoke) {
3
3
  if (!className) return commFactory;
4
4
  if (commFactory instanceof Promise) {
5
5
  return commFactory.then(function (result) {
6
- return create(result, className);
6
+ return _invoke(result, className, _invoke);
7
7
  });
8
8
  }
9
9
  if (isFunction(commFactory)) {
10
10
  var result = function () {
11
11
  var commRelease = commFactory.apply(this || result, arguments);
12
12
  if (commRelease) {
13
- commRelease = create(commRelease, className);
13
+ commRelease = _invoke(commRelease, className, _invoke);
14
14
  }
15
15
  return commRelease;
16
16
  };
17
17
  result.prototype = commFactory.prototype;
18
18
  commFactory.className = className;
19
19
  keys(commFactory).map(k => result[k] = commFactory[k]);
20
+ result.call = function (context, ...args) {
21
+ if (!isEmpty(context)) var release = commFactory.apply(context, args);
22
+ else release = commFactory.apply(result, args);
23
+ if (release) release = _invoke(release, className, _invoke);
24
+ return release;
25
+ };
20
26
  if ({}.hasOwnProperty.call(commFactory, 'toString')) {
21
27
  result.toString = function () {
22
- return create(commFactory.toString(), className);
28
+ return _invoke(commFactory.toString(), className, _invoke);
23
29
  };
24
30
  }
25
31
  return result;
@@ -54,5 +60,5 @@ function cless(commFactory, innerCss, className) {
54
60
  }
55
61
  appendChild(head, stylesheet);
56
62
  }
57
- return create(commFactory, className);
63
+ return _create(commFactory, className, _create);
58
64
  }
@@ -381,7 +381,6 @@ extend(color, {
381
381
  },
382
382
  rgb2h,
383
383
  rgb4h,
384
- rgb4s,
385
384
  rgb2v,
386
385
  rgb4v,
387
386
  rgb2s,
@@ -20,7 +20,7 @@ if (cookiesData) {
20
20
  var digest = function () {
21
21
  dispatch('render', window);
22
22
  };
23
-
23
+ if (/Trident/i.test(navigator.userAgent)) digest = lazy(digest, 60);
24
24
  var cross = cross_.bind(function (callback, onerror) {
25
25
  var xhr = new XMLHttpRequest;
26
26
  var abort = xhr.abort;
@@ -323,9 +323,13 @@ var parseData = function (sourceText) {
323
323
  sourceText = sourceText
324
324
  .replace(/<!--[\s\S]*?-->|<\[CDATA\[[\s\S]*?\]\]>/ig, '')
325
325
  .replace(/^[\s\S]*?<html>([\s\S]*)<\/html>[\s\S]*?$/i, '$1')
326
- .replace(/^[\s\S]*?<body>([\s\S]*?)$/i, '$1')
326
+ .replace(/^([\s\S]*?)<body>([\s\S]*?)$/i, '$1<body>$2')
327
327
  .replace(/<\/body>[\s\S]*?$/, '');
328
- doc.body.innerHTML = sourceText;
328
+ var div = document.createElement('div');
329
+ div.innerHTML = sourceText.replace(/^([\s\S]*?)<body>[\s\S]*?$/, "$1")
330
+ .replace(/<head>/i, '').replace(/<\/head>/i, '');
331
+ for (var c of [...div.childNodes]) doc.head.appendChild(c);
332
+ doc.body.innerHTML = sourceText.replace(/^[\s\S]*?<body>/, '');
329
333
  } else {
330
334
  doc.documentElement.innerHTML = sourceText;
331
335
  }
@@ -1,6 +1,6 @@
1
1
  var dispatch = "dispatchEvent" in document ? function dispatchEvent(target, event) {
2
2
  return target.dispatchEvent(event);
3
- } : function fireEvent(target, event) {
3
+ } : function (target, event) {
4
4
  var fire = "on" + event.type;
5
5
  try {
6
6
  return target.fireEvent(fire, event);
@@ -1,17 +1,28 @@
1
1
  var _input = createElement("input");
2
+ /**
3
+ * @this HTMLInputElement
4
+ */
2
5
  var number = function (event) {
3
6
  var ipt = event.target;
4
7
  var { keyCode } = event;
5
8
  var { value, type } = ipt;
9
+ var s = this.selectionStart;
6
10
  if (keyCode === 13 || keyCode === 18 || keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40 || keyCode === 8 || keyCode === 46 || keyCode === 9) {
7
11
  }
8
12
  else if (keyCode >= 48 && keyCode <= 57 || keyCode >= 96 && keyCode <= 105) {
9
13
  if (this.value) {
10
- if (this.fixed && this.value.replace(/^[^\.]+/, '').length > this.fixed ||
14
+ if (s < this.value.length) {
15
+ var index = this.value.indexOf('.');
16
+ if (index >= 0 && s > index) {
17
+ this.value = this.value.slice(0, this.value.length - 1);
18
+ }
19
+ this.setSelectionRange(s, s);
20
+ }
21
+ else if (this.fixed && this.value.replace(/^[^\.]+/, '').length > this.fixed ||
11
22
  this.limit && this.value.length >= this.limit && !/\./.test(this.value)) {
12
23
  event.preventDefault();
13
24
  }
14
- if(/^[+-]?0$/.test(this.value)){
25
+ else if (/^[+-]?0$/.test(this.value)) {
15
26
  event.preventDefault();
16
27
  }
17
28
  }
@@ -19,14 +30,27 @@ var number = function (event) {
19
30
  else if (keyCode === 110 || keyCode === 190) {
20
31
  if (/^int/i.test(type)) {
21
32
  event.preventDefault();
22
- } else if (/\./i.test(value) || !value || /^[\-\+]$/.test(value)) {
33
+ }
34
+ else if (/\./i.test(value)) {
35
+ var index = this.value.indexOf(".");
36
+ if (s < index) {
37
+ this.value = this.value.slice(0, s) + this.value.slice(index + 1);
38
+ this.setSelectionRange(s, s);
39
+ }
40
+ else {
41
+ event.preventDefault();
42
+ }
43
+ }
44
+ else if (!value || /^[\-\+]$/.test(value)) {
23
45
  event.preventDefault();
24
46
  }
25
- } else if (keyCode === 189 || keyCode === 187) {// 负号 正号
47
+ }
48
+ else if (keyCode === 189 || keyCode === 187) {// 负号 正号
26
49
  if (value || this.positive) {
27
50
  event.preventDefault();
28
51
  }
29
- } else {
52
+ }
53
+ else {
30
54
  event.preventDefault();
31
55
  }
32
56
  if (value && !/^[\d]+$/i.test(value)) {
@@ -36,11 +60,19 @@ var number = function (event) {
36
60
  if (value !== v) {
37
61
  ipt.value = v;
38
62
  }
39
- } else if (!/^[\-\+]$/.test(value)) {
63
+ }
64
+ else if (!/^[\-\+]$/.test(value)) {
40
65
  ipt.value = '';
41
66
  }
42
67
  }
43
68
  };
69
+ var toFixed = function () {
70
+ if (this.value && this.fixed) var fixed = BigNumber.fix(this.value, this.fixed);
71
+ if (this.value !== fixed) {
72
+ this.value = fixed;
73
+ dispatch(this, 'change');
74
+ }
75
+ };
44
76
  var positiveReg = /^\+|^positive\-?|\-?positive$|\+$/i;
45
77
  var negativeReg = /^\-|^negative\-?|\-?negative$|\-$/i;
46
78
  var numberLimit = /\:(\d+)?(?:\.(\d+))?$/;
@@ -92,6 +124,7 @@ function input(element) {
92
124
  case "money":
93
125
  if (!element.fixed) element.fixed = 2;
94
126
  on("keydown")(element, number);
127
+ on("blur")(element, toFixed);
95
128
  break;
96
129
  case "natural":
97
130
  if (!+element.positive) element.positive = true;
@@ -23,6 +23,30 @@ function removeAllListeners() {
23
23
  if (isFunction(offhook)) offhook();
24
24
  offhook = null;
25
25
  }
26
+ if (/Firefox/.test(navigator.userAgent)) on('dragstart')(document, function (e) {
27
+ if (e.target.draggable === false) {
28
+ e.preventDefault();
29
+ return false;
30
+ }
31
+ });
32
+ var locktouch = function (target) {
33
+ if (/(input|textarea|select)/i.test(target.tagName) || getTargetIn(a => String(a.contentEditable) === 'true' || a.draggable, target)) {
34
+ return true;
35
+ } else {
36
+ var { childNodes } = target;
37
+ var a = getTargetIn(a => {
38
+ if ((getComputedStyle(a).userSelect || getComputedStyle(a).webkitUserSelect) !== 'auto') return a;
39
+ });
40
+ if (!a) return;
41
+ var computed = getComputedStyle(a);
42
+ if (computed.cursor === 'auto' && (computed.userSelect || computed.webkitUserSelect) !== 'none') for (var cx = 0, dx = childNodes.length; cx < dx; cx++) {
43
+ var child = childNodes[cx];
44
+ if (child.nodeType === 3) {
45
+ return true;
46
+ }
47
+ }
48
+ }
49
+ };
26
50
 
27
51
  function moveupon(target, { start, move, end }, initialEvent) {
28
52
  var touchLocked = false;
@@ -47,20 +71,18 @@ function moveupon(target, { start, move, end }, initialEvent) {
47
71
  if (isFunction(end)) end.call(target, event);
48
72
  };
49
73
  var hookmouse = function () {
50
- if (touchLocked) return;
51
- touchLocked = true;
52
74
  addHookListener(onmousemove, mousemove, target === window);
53
75
  offmouseup = onmouseup(window, cancel);
54
76
  };
55
77
  var hooktouch = function () {
56
- if (touchLocked) return;
57
- touchLocked = true;
58
78
  addHookListener(ontouchmove, touchmove, target === window);
59
79
  offtouchend = ontouchend(target, cancel);
60
80
  offtouchcancel = ontouchcancel(target, cancel);
61
81
  };
82
+
62
83
  if (!start) {
63
84
  if (!initialEvent) throw new Error("请传入touchstartEvent或者mousedownEvent");
85
+ if (locktouch(initialEvent.target)) return;
64
86
  if (initialEvent.type === "touchstart") {
65
87
  extendTouchEvent(initialEvent);
66
88
  initialEvent.preventDefault();
@@ -71,10 +93,16 @@ function moveupon(target, { start, move, end }, initialEvent) {
71
93
  return;
72
94
  }
73
95
  onmousedown(target, function (event) {
96
+ if (touchLocked) return;
97
+ if (locktouch(event.target)) return;
98
+ touchLocked = true;
74
99
  hookmouse(event);
75
100
  if (isFunction(start)) start.call(this, event);
76
101
  });
77
102
  ontouchstart(target, function (event) {
103
+ if (touchLocked) return;
104
+ if (locktouch(event.target)) return;
105
+ touchLocked = true;
78
106
  extendTouchEvent(event);
79
107
  hooktouch(event);
80
108
  if (isFunction(start)) start.call(this, event);
package/coms/zimoli/on.js CHANGED
@@ -1,6 +1,19 @@
1
- "use strict";
1
+ // "use strict";
2
2
  if (document.efronton) return document.efronton;
3
3
  var is_addEventListener_enabled = "addEventListener" in window;
4
+ if ('attachEvent' in document) {
5
+ is_addEventListener_enabled = false;
6
+ }
7
+ if (!is_addEventListener_enabled) var __call = function (target, context, handler, firstmost) {
8
+ // use strict 无效的情况
9
+ if (isEmpty(target)) {
10
+ this(context, context, handler, firstmost);
11
+ }
12
+ else {
13
+ this(target, context, handler, firstmost);
14
+ }
15
+ };
16
+
4
17
  var handlersMap = {};
5
18
  var changes_key = 'changes';
6
19
  var eventtypereg = /(?:\.once|\.prevent|\.stop|\.capture|\.self|\.passive|\.[a-z0-9]+)+\.?$/i;
@@ -70,7 +83,6 @@ var keyCodeMap = {
70
83
  numdot: 110,
71
84
  divide: 111,
72
85
  div: 111,
73
- "/": 111,
74
86
  f1: 112,
75
87
  f2: 113,
76
88
  f3: 114,
@@ -104,7 +116,7 @@ var keyCodeMap = {
104
116
  ">": 110,
105
117
  slash: 191,
106
118
  "/": 191,
107
- ">": 191,
119
+ "?": 191,
108
120
  backquote: 192,
109
121
  "`": 192,
110
122
  "~": 192,
@@ -308,50 +320,55 @@ var on = document.efronton = function (k) {
308
320
  return remove.bind(target, k, hk, listener);
309
321
  };
310
322
 
311
- else var addhandler = function (context, handler, firstmost = false) {
312
- var target = this || context;
313
- if (eventtypes.capture) {
314
- console.warn("当前运行环境不支持事件capture");
315
- firstmost = true;
316
- }
317
- target = checkroot(target, k);
318
- if (target[handler_path] instanceof Array) {
319
- } else {
320
- var h = function (e) {
321
- if (!e) e = window.event || {};
322
- if (!e.target && e.srcElement) {
323
- e.target = e.srcElement;
324
- }
325
- if (e.stopedPropagation) return;
326
- if (!e.stopPropagation) {
327
- e.stopPropagation = function () {
328
- this.stopedPropagation = true;
329
- };
330
- }
331
- if (!e.preventDefault) {
332
- e.preventDefault = function () {
333
- e.returnValue = false;
334
- e.defaultPrevented = true;
335
- };
336
- }
337
- if (e.button) {
338
- if (e.buttons === undefined) e.buttons = e.button;
339
- if (e.which === undefined) e.which = e.button + 1;
340
- }
341
- if (e.keyCode) {
342
- if (e.which === undefined) e.which = e.keyCode;
343
- }
344
- broadcast.call(target, k, handler_path, e);
345
- return e.returnValue;
346
- };
347
- target[handler_path] = target["on" + k] && target["on" + k] !== handler ? [[{}, target["on" + k]]] : [];
348
- target[handler_path].h = h;
349
- target["on" + k] = h;
350
- }
351
- var listener = [eventtypes, handler, context];
352
- append.call(target, k, handler_path, listener, firstmost);
353
- return remove.bind(target, k, handler_path, listener);
354
- };
323
+ else {
324
+ var _addhandler = function (target, context, handler, firstmost = false) {
325
+ if (eventtypes.capture) {
326
+ console.warn("当前运行环境不支持事件capture");
327
+ firstmost = true;
328
+ }
329
+ target = checkroot(target, k);
330
+ if (target[handler_path] instanceof Array) {
331
+ } else {
332
+ var h = function (e) {
333
+ if (!e) e = window.event || {};
334
+ if (!e.target && e.srcElement) {
335
+ e.target = e.srcElement;
336
+ }
337
+ if (e.stopedPropagation) return;
338
+ if (!e.stopPropagation) {
339
+ e.stopPropagation = function () {
340
+ this.stopedPropagation = true;
341
+ };
342
+ }
343
+ if (!e.preventDefault) {
344
+ e.preventDefault = function () {
345
+ e.returnValue = false;
346
+ e.defaultPrevented = true;
347
+ };
348
+ }
349
+ if (e.button) {
350
+ if (e.buttons === undefined) e.buttons = e.button;
351
+ if (e.which === undefined) e.which = e.button + 1;
352
+ }
353
+ if (e.keyCode) {
354
+ if (e.which === undefined) e.which = e.keyCode;
355
+ }
356
+ broadcast.call(target, k, handler_path, e);
357
+ return e.returnValue;
358
+ };
359
+ target[handler_path] = target["on" + k] && target["on" + k] !== handler ? [[{}, target["on" + k]]] : [];
360
+ target[handler_path].h = h;
361
+ target["on" + k] = h;
362
+
363
+ }
364
+ var listener = [eventtypes, handler, context];
365
+ append.call(target, k, handler_path, listener, firstmost);
366
+ return remove.bind(target, k, handler_path, listener);
367
+ }, addhandler = function (context, handler, firstmost) {
368
+ return _addhandler(context, context, handler, firstmost);
369
+ };
370
+ addhandler.call = __call.bind(_addhandler);
371
+ }
355
372
  handlersMap[on_event_path] = addhandler;
356
373
  return addhandler;
357
374
  };
@@ -43,19 +43,10 @@ function _onremove(node, event) {
43
43
  if (!node || node.isMounted === false) return;
44
44
  var children = node.childNodes;
45
45
  if (node.isMounted) {
46
- var onremove = node.onremove;
47
46
  if (!event) {
48
47
  event = createEvent("remove");
49
48
  }
50
49
  dispatch(node, event);
51
- if (isArray(onremove)) {
52
- onremove.map(function (remove_hindler) {
53
- remove_hindler.call(this, event);
54
- }, node);
55
- }
56
- if (isFunction(onremove)) {
57
- onremove.call(node, event);
58
- }
59
50
  node.isMounted = false;
60
51
  }
61
52
  if (children) for (var cx = 0, dx = children.length; cx < dx; cx++) {
@@ -173,7 +173,7 @@ var createRepeat = function (search, id = 0) {
173
173
  var $parentScopes = element.$parentScopes || [];
174
174
  var $struct = element.$struct;
175
175
  if (element.$scope) {
176
- $struct = Object.assign({}, $struct, { context: $struct.context + `with(this.$parentScopes[${$parentScopes.length}])` }), $parentScopes = $parentScopes.concat(element.$scope);
176
+ $struct = extend({}, $struct, { context: $struct.context + `with(this.$parentScopes[${$parentScopes.length}])` }), $parentScopes = $parentScopes.concat(element.$scope);
177
177
  }
178
178
  var clonedElements1 = Object.create(null);
179
179
  var cloned = keys.map(function (key, cx) {
@@ -631,7 +631,7 @@ function getFromScopes(key, scope, parentScopes) {
631
631
 
632
632
  function renderElement(element, scope = element.$scope, parentScopes = element.$parentScopes, once) {
633
633
  if (!isNode(element) && element.length) {
634
- return Array.prototype.slice.call(element, 0, element.length).map(function (element) {
634
+ return Array.prototype.map.call(element, function (element) {
635
635
  return renderElement(element, scope, parentScopes, once);
636
636
  });
637
637
  }
@@ -365,6 +365,7 @@ function table(elem) {
365
365
  }
366
366
  if (!getTargetIn(thead, event.target)) return;
367
367
  var tds = getTargetIn(cellMatchManager, event.target);
368
+ if (!tds) return;
368
369
  setClass(tds, 'y-ing', activeCols);
369
370
  activeCols = tds;
370
371
  });
@@ -379,15 +380,18 @@ function table(elem) {
379
380
  var table = tableElement;
380
381
  var thead;
381
382
  var markedRows = false;
383
+ var markThead = function () {
384
+ var savedRowDeltas = [];
385
+ Array.prototype.forEach.call(thead.children, function (tr) {
386
+ markRowTds(tr, savedRowDeltas);
387
+ });
388
+ };
382
389
  var cellMatchManager = function (element) {
383
390
  if (!thead) thead = getThead(table);
384
391
  if (!getTargetIn(thead, element)) return false;
385
392
  if (!tdElementReg.test(element.tagName)) return false;
386
393
  if (!markedRows) {
387
- var savedRowDeltas = [];
388
- Array.prototype.forEach.call(thead.children, function (tr) {
389
- markRowTds(tr, savedRowDeltas);
390
- });
394
+ markThead();
391
395
  markedRows = true;
392
396
  }
393
397
  var { colstart, colend } = element;
@@ -468,14 +472,17 @@ function table(elem) {
468
472
  var dstElement = children[rel];
469
473
  var dstTds = getRowsOfTdsByCol(table, dstElement.colstart, dstElement.colend);
470
474
  var srcTds = getRowsOfTdsByCol(table, srcElement.colstart, srcElement.colend);
475
+ var clearCss = { left: '', right: '', borderLeft: '', borderRight: '' };
471
476
  if (append === appendChild.before) {
472
477
  srcTds.map(function (src, cx) {
473
478
  var dst = dstTds[cx];
474
479
  var d = dst[0] || dst.next;
475
480
  if (d) src.map(function (s) {
481
+ css(s, clearCss);
476
482
  append(d, s);
477
483
  });
478
484
  else if (d = dst.prev) src.map(function (s) {
485
+ css(s, clearCss);
479
486
  appendChild.after(d, s);
480
487
  d = s;
481
488
  });
@@ -485,15 +492,22 @@ function table(elem) {
485
492
  var dst = dstTds[cx];
486
493
  var d = dst[dst.length - 1] || dst.prev;
487
494
  if (d) src.map(function (s) {
495
+ css(s, clearCss);
488
496
  append(d, s);
489
497
  d = s;
490
498
  });
491
499
  else if (d = dst.next) src.map(function (s) {
500
+ css(s, clearCss);
492
501
  appendChild.before(d, s);
493
502
  });
494
503
  });
495
504
 
496
505
  }
506
+ markThead();
507
+ markedRows = true;
508
+ requestAnimationFrame(function(){
509
+ setFixedColumn.call(table)
510
+ })
497
511
  }
498
512
  );
499
513
  resizingList.set(table);
@@ -1,6 +1,5 @@
1
1
 
2
2
  var prototype = {
3
- draggable: undefined,
4
3
  resizable: false,
5
4
  closeable: true,
6
5
  showTitle: true,
@@ -301,7 +301,7 @@ function prepare(pgpath, ok) {
301
301
  if (isString(menu)) {
302
302
  res = state.go(menu, item);
303
303
  } else if (menu && menu.path) {
304
- menu = Object.assign({}, menu, { path: state.path(menu.path) });
304
+ menu = extend({}, menu, { path: state.path(menu.path) });
305
305
  res = go(menu, undefined, undefined, pgpath);
306
306
  } else {
307
307
  res = action(menu, item, params);
@@ -476,7 +476,7 @@ var pushstate = function (path_name, history_name, oldpagepath) {
476
476
  history[history_name] = [path_name];
477
477
  } else {
478
478
  var _history = history[history_name];
479
- if (_history.indexOf(oldpagepath) < 0) {
479
+ if ([].indexOf.call(_history, oldpagepath, 0) < 0) {
480
480
  _history.splice(root_path === _history[0], _history.length);
481
481
  isDestroy = true;
482
482
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.22.9",
3
+ "version": "3.24.2",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {