efront 4.22.0 → 4.22.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.
- package/coms/basic/refilm_decode.js +20 -9
- package/coms/zimoli/container.js +3 -3
- package/coms/zimoli/field.html +2 -2
- package/coms/zimoli/field.js +60 -55
- package/coms/zimoli/field.less +20 -2
- package/coms/zimoli/grid.js +1 -0
- package/coms/zimoli/image.html +2 -2
- package/coms/zimoli/image.js +9 -14
- package/coms/zimoli/menuList.js +3 -1
- package/coms/zimoli/menuList_test.js +1 -0
- package/coms/zimoli/model.js +21 -2
- package/coms/zimoli/render.js +152 -98
- package/coms/zimoli/tree.js +1 -2
- package/coms/zimoli/tree.less +3 -1
- package/coms/zimoli/tree_test.js +8 -6
- package/coms/zimoli/zimoli.js +1 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/zimoli/render.js
CHANGED
|
@@ -147,11 +147,9 @@ var createGetter = function (target, search, isprop = true) {
|
|
|
147
147
|
if (!search) return function () { };
|
|
148
148
|
if (/^\{/.test(search)) search = `(${search})`;
|
|
149
149
|
search = renderExpress(search);
|
|
150
|
-
var
|
|
151
|
-
if (
|
|
152
|
-
else
|
|
153
|
-
else getter = $$eval.bind(target, search, scopes);
|
|
154
|
-
getter.scopes = scopes;
|
|
150
|
+
if (isprop) var getter = $$eval.bind(target, search, getScopeList(target));
|
|
151
|
+
else if (variableOnlyReg.test(search)) getter = $$eval.bind(target, search + "(event)");
|
|
152
|
+
else getter = $$eval.bind(target, search);
|
|
155
153
|
return getter;
|
|
156
154
|
};
|
|
157
155
|
var createComment = function (renders, type, expression) {
|
|
@@ -242,6 +240,18 @@ var parseRepeat = function (expression) {
|
|
|
242
240
|
srcName
|
|
243
241
|
);
|
|
244
242
|
};
|
|
243
|
+
var getClonedElements = function (clones, repsrc) {
|
|
244
|
+
var newmap = [];
|
|
245
|
+
var inc = 0;
|
|
246
|
+
clones.forEach((c, i) => {
|
|
247
|
+
var m = c.$scope.$item;
|
|
248
|
+
switch (m) {
|
|
249
|
+
case repsrc[inc]: delete clones[i]; newmap[inc++] = c; break;
|
|
250
|
+
case repsrc[inc + 1]: delete clones[i]; inc++; newmap[inc++] = c; break;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
return newmap;
|
|
254
|
+
}
|
|
245
255
|
var createRepeat = function (search, id = 0) {
|
|
246
256
|
// 懒渲染
|
|
247
257
|
// throw new Error("repeat is not supported! use list component instead");
|
|
@@ -272,25 +282,42 @@ var createRepeat = function (search, id = 0) {
|
|
|
272
282
|
if (element.$scope) {
|
|
273
283
|
$parentScopes = $parentScopes.slice(), $parentScopes.push(element.$scope);
|
|
274
284
|
}
|
|
275
|
-
var clonedElements1 = Object.create(null);
|
|
285
|
+
var clonedElements1 = isArrayResult ? [] : Object.create(null);
|
|
286
|
+
if (isArrayResult && !trackBy && clonedElements instanceof Array) {
|
|
287
|
+
clonedElements1 = getClonedElements(clonedElements, result);
|
|
288
|
+
}
|
|
276
289
|
var cloned = keys.map(function (key, cx) {
|
|
277
290
|
var k = isArrayResult ? cx : key;
|
|
278
291
|
var $scope = repeater.createScope(result[k], k, cx);
|
|
279
292
|
if (trackBy) {
|
|
280
293
|
k = seek($scope, trackBy);
|
|
281
294
|
if (clonedElements[k]) {
|
|
282
|
-
clonedElements[k].$
|
|
295
|
+
Object.assign(clonedElements[k].$repeat, $scope)
|
|
283
296
|
return clonedElements1[k] = clonedElements[k];
|
|
284
297
|
}
|
|
285
298
|
}
|
|
286
299
|
else {
|
|
287
|
-
|
|
288
|
-
|
|
300
|
+
if (isArrayResult) {
|
|
301
|
+
var c = clonedElements1[k];
|
|
302
|
+
if (c) {
|
|
303
|
+
Object.assign(c.$repeat, $scope);
|
|
304
|
+
return c;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
var c = changes[k];
|
|
309
|
+
if (!c) c = clonedElements[k];
|
|
310
|
+
else c = null;
|
|
311
|
+
if (c) {
|
|
312
|
+
Object.assign(c.$repeat, $scope);
|
|
313
|
+
return clonedElements1[k] = c;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
289
316
|
}
|
|
290
317
|
var clone = element.cloneNode();
|
|
291
318
|
clone.innerHTML = element.innerHTML;
|
|
292
319
|
clone.$renderid = id;
|
|
293
|
-
clone.$scope = $scope;
|
|
320
|
+
clone.$repeat = clone.$scope = $scope;
|
|
294
321
|
clone.$parentScopes = $parentScopes;
|
|
295
322
|
clone.$struct = $struct;
|
|
296
323
|
clonedElements1[k] = clone;
|
|
@@ -323,46 +350,49 @@ var initIf = function (ifs) {
|
|
|
323
350
|
initialComment(s[0]);
|
|
324
351
|
}
|
|
325
352
|
};
|
|
353
|
+
|
|
354
|
+
var ifget = function () {
|
|
355
|
+
var elements = this.$elements;
|
|
356
|
+
var shouldMount = -1;
|
|
357
|
+
for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
|
|
358
|
+
var getter = elements[cx + 1];
|
|
359
|
+
if (!getter || getter(this)) {
|
|
360
|
+
shouldMount = cx;
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return shouldMount;
|
|
365
|
+
}
|
|
366
|
+
var ifset = function (shouldMount) {
|
|
367
|
+
var elements = this.$elements;
|
|
368
|
+
for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
|
|
369
|
+
var c = elements[cx];
|
|
370
|
+
if (cx === shouldMount) {
|
|
371
|
+
var e = c.$template;
|
|
372
|
+
if (c.nextSibling !== e) appendChild.after(c, e);
|
|
373
|
+
if (e.$renderid < 0) {
|
|
374
|
+
e.$renderid = this.$id;
|
|
375
|
+
e = c.$template = render(e);
|
|
376
|
+
e.$comment = c;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
remove(c.$template);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
};
|
|
326
384
|
var createIf = function (search, id = 0) {
|
|
327
385
|
// 懒渲染
|
|
328
386
|
var getter = createGetter(this, search);
|
|
329
387
|
var element = this;
|
|
330
388
|
var elements = [element, getter];
|
|
331
389
|
if_top.push(elements);
|
|
332
|
-
var savedValue;
|
|
333
390
|
elements.parent = this.parentNode;
|
|
334
|
-
elements.comment = search;
|
|
335
391
|
if (this.$struct.repeat) id = -3;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
var getter = elements[cx + 1];
|
|
341
|
-
if (!getter || getter(this)) {
|
|
342
|
-
shouldMount = cx;
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
if (savedValue === shouldMount) return;
|
|
347
|
-
savedValue = shouldMount;
|
|
348
|
-
for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
|
|
349
|
-
var c = elements[cx];
|
|
350
|
-
if (cx === shouldMount) {
|
|
351
|
-
var e = c.$template;
|
|
352
|
-
appendChild.after(c, e);
|
|
353
|
-
if (e.$renderid < 0) {
|
|
354
|
-
e.$renderid = id;
|
|
355
|
-
e = c.$template = render(e, this.$scope, this.$parentScopes);
|
|
356
|
-
e.$comment = c;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
remove(c.$template);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
}];
|
|
365
|
-
return elements[0] = createComment.call(element, elements.$renders, 'if', elements.comment);
|
|
392
|
+
var comment = elements[0] = createComment.call(element, [new Binder2(ifget, ifset)], 'if', search);
|
|
393
|
+
comment.$id = id;
|
|
394
|
+
comment.$elements = elements;
|
|
395
|
+
return comment;
|
|
366
396
|
};
|
|
367
397
|
var parseIfWithRepeat = function (ifExpression, repeatExpression) {
|
|
368
398
|
var repeater = parseRepeat(repeatExpression);
|
|
@@ -475,9 +505,7 @@ var structures = {
|
|
|
475
505
|
}
|
|
476
506
|
initIf(if_top.splice(cx + 1, if_top.length - cx - 1));
|
|
477
507
|
var top = if_top[cx];
|
|
478
|
-
if (search
|
|
479
|
-
var getter = createGetter(this, search);
|
|
480
|
-
}
|
|
508
|
+
if (search) var getter = createGetter(this, search);
|
|
481
509
|
var comment = createComment.call(this, undefined, search ? 'elseif' : 'else', search);
|
|
482
510
|
top.push(comment, getter);
|
|
483
511
|
},
|
|
@@ -574,19 +602,26 @@ class Model {
|
|
|
574
602
|
var getValue = target.getValue;
|
|
575
603
|
var setValue = target.setValue;
|
|
576
604
|
if (getValue && setValue);
|
|
577
|
-
else if (
|
|
578
|
-
if (!getValue) getValue = gtValue;
|
|
605
|
+
else if ('value' in target) {
|
|
579
606
|
if (!setValue) setValue = stValue;
|
|
580
|
-
|
|
607
|
+
if (!getValue) getValue = gtValue;
|
|
608
|
+
}
|
|
609
|
+
else if (/^input$/i.test(target.tagName) && /^checkbox$/i.test(target.type) || /^checkbox$/i.test(target.tagName)) {
|
|
581
610
|
if (!getValue) getValue = gtChecked;
|
|
582
611
|
if (!setValue) setValue = stChecked;
|
|
583
|
-
}
|
|
612
|
+
}
|
|
613
|
+
else if (/^(select|input|textarea)$/i.test(target.tagName) || "value" in target) {
|
|
584
614
|
if (!getValue) getValue = gtValue;
|
|
585
615
|
if (!setValue) setValue = stValue;
|
|
586
|
-
}
|
|
616
|
+
}
|
|
617
|
+
else if (String(target.contentEditable) === "true") {
|
|
587
618
|
if (!getValue) getValue = gtHtml;
|
|
588
619
|
if (!setValue) setValue = stHtml;
|
|
589
620
|
}
|
|
621
|
+
else {
|
|
622
|
+
if (!getValue) getValue = gtValue;
|
|
623
|
+
if (!setValue) setValue = stValue;
|
|
624
|
+
}
|
|
590
625
|
this.gv = getValue;
|
|
591
626
|
this.sv = setValue;
|
|
592
627
|
this.target = target;
|
|
@@ -599,6 +634,9 @@ class Model {
|
|
|
599
634
|
this.ss.call(this.target, value);
|
|
600
635
|
this.value = value;
|
|
601
636
|
this.bd.value = this.gs.call(this.target, value);
|
|
637
|
+
if (isFunction(this.emit?.call)) {
|
|
638
|
+
this.emit.call(this.target);
|
|
639
|
+
}
|
|
602
640
|
userChanged = true;
|
|
603
641
|
}
|
|
604
642
|
hook(elem, emit) {
|
|
@@ -606,9 +644,10 @@ class Model {
|
|
|
606
644
|
elem.$renders.push(binder);
|
|
607
645
|
binder.call(elem);
|
|
608
646
|
this.bd = binder;
|
|
609
|
-
if (emit) {
|
|
647
|
+
if (emit !== false) {
|
|
648
|
+
this.emit = emit;
|
|
649
|
+
this.value = this.gv.call(this.target);
|
|
610
650
|
eventsBinders.forEach(on => on(this.target, this, true));
|
|
611
|
-
this.value = this.gv.call(elem);
|
|
612
651
|
this.target = elem;
|
|
613
652
|
}
|
|
614
653
|
return binder;
|
|
@@ -645,14 +684,14 @@ var directives = {
|
|
|
645
684
|
var style = this.style;
|
|
646
685
|
if (style.display !== display) style.display = display;
|
|
647
686
|
}, function () {
|
|
648
|
-
return this.style
|
|
687
|
+
return this.style?.display === 'none';
|
|
649
688
|
}),
|
|
650
689
|
show: createBinder2(function (value) {
|
|
651
690
|
var display = value ? '' : 'none';
|
|
652
691
|
var style = this.style;
|
|
653
692
|
if (style.display !== display) style.display = display;
|
|
654
693
|
}, function () {
|
|
655
|
-
return this.style
|
|
694
|
+
return this.style?.display !== 'none';
|
|
656
695
|
}),
|
|
657
696
|
style: createMapper(css, css.styleToMap),
|
|
658
697
|
class: createMapper(addClass, addClass.classToMap),
|
|
@@ -664,7 +703,7 @@ var directives = {
|
|
|
664
703
|
var getter = createGetter(this, search);
|
|
665
704
|
var setter = createSetter(this, search);
|
|
666
705
|
var model = new Model(getter, setter, target);
|
|
667
|
-
model.hook(this, change !== false
|
|
706
|
+
model.hook(this, change !== false);
|
|
668
707
|
},
|
|
669
708
|
value(search, target) {
|
|
670
709
|
directives.model.call(this, search, target, false);
|
|
@@ -712,12 +751,56 @@ var binders = {
|
|
|
712
751
|
}
|
|
713
752
|
};
|
|
714
753
|
var reject = function (e) { digest(); throw e };
|
|
754
|
+
class Emitter {
|
|
755
|
+
constructor(emit, scopes) {
|
|
756
|
+
this.emit = emit;
|
|
757
|
+
this.scopes = scopes;
|
|
758
|
+
}
|
|
759
|
+
call(elem, e) {
|
|
760
|
+
digest();
|
|
761
|
+
var scopes = this.scopes;
|
|
762
|
+
var parsedSrc = elem.$src;
|
|
763
|
+
if (parsedSrc instanceof Repeater) {
|
|
764
|
+
if (e.active || e.currentTarget) var target = e.active || (e.currentTarget === elem ? e.target || e.srcElem || e.currentTarget : e.currentTarget);
|
|
765
|
+
else var target = e.target;
|
|
766
|
+
if (target === elem) {
|
|
767
|
+
scope = parsedSrc.createScope();
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
let scopes = target && target.$parentScopes;
|
|
771
|
+
if (scopes) {
|
|
772
|
+
var scope = null;
|
|
773
|
+
for (var cx = scopes.length - 1; cx >= 0; cx--) {
|
|
774
|
+
var s = scopes[cx];
|
|
775
|
+
if (s === elem.$scope) {
|
|
776
|
+
scope = scopes[cx + 1];
|
|
777
|
+
break;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
if (!scope && target.$scope !== elem.$scope) scope = target.$scope;
|
|
783
|
+
}
|
|
784
|
+
var res;
|
|
785
|
+
if (scope) {
|
|
786
|
+
scopes.push(scope);
|
|
787
|
+
res = this.emit(scopes, elem, e);
|
|
788
|
+
scopes.pop();
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
res = this.emit(scopes, elem, e);
|
|
792
|
+
}
|
|
793
|
+
if (res && isFunction(res.then)) res.then(digest, reject);
|
|
794
|
+
return res;
|
|
795
|
+
|
|
796
|
+
}
|
|
797
|
+
}
|
|
715
798
|
var createEmiter = function (on) {
|
|
716
799
|
return function (target, key, search) {
|
|
717
800
|
/**
|
|
718
801
|
* @type {Repeater}
|
|
719
802
|
*/
|
|
720
|
-
var
|
|
803
|
+
var emit = createGetter(this, search, false);
|
|
721
804
|
var onkey;
|
|
722
805
|
if (key === 'mounted' || key === 'mount') {
|
|
723
806
|
onkey = on === once ? oncemount : onmounted;
|
|
@@ -728,42 +811,7 @@ var createEmiter = function (on) {
|
|
|
728
811
|
else {
|
|
729
812
|
onkey = on(key);
|
|
730
813
|
}
|
|
731
|
-
onkey(target,
|
|
732
|
-
digest();
|
|
733
|
-
var parsedSrc = this.$src;
|
|
734
|
-
if (parsedSrc instanceof Repeater) {
|
|
735
|
-
if (e.active || e.currentTarget) var target = e.active || (e.currentTarget === this ? e.target || e.srcElem || e.currentTarget : e.currentTarget);
|
|
736
|
-
else var target = e.target;
|
|
737
|
-
if (target === this) {
|
|
738
|
-
scope = parsedSrc.createScope();
|
|
739
|
-
}
|
|
740
|
-
else {
|
|
741
|
-
var scopes = target && target.$parentScopes;
|
|
742
|
-
if (scopes) {
|
|
743
|
-
var scope = null;
|
|
744
|
-
for (var cx = scopes.length - 1; cx >= 0; cx--) {
|
|
745
|
-
var s = scopes[cx];
|
|
746
|
-
if (s === this.$scope) {
|
|
747
|
-
scope = scopes[cx + 1];
|
|
748
|
-
break;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
if (!scope && target.$scope !== this.$scope) scope = target.$scope;
|
|
754
|
-
}
|
|
755
|
-
var res;
|
|
756
|
-
if (scope) {
|
|
757
|
-
getter.scopes.push(scope);
|
|
758
|
-
res = getter(this, e);
|
|
759
|
-
getter.scopes.pop();
|
|
760
|
-
}
|
|
761
|
-
else {
|
|
762
|
-
res = getter(this, e);
|
|
763
|
-
}
|
|
764
|
-
if (res && isFunction(res.then)) res.then(digest, reject);
|
|
765
|
-
return res;
|
|
766
|
-
});
|
|
814
|
+
onkey(target, new Emitter(emit, getScopeList(target)));
|
|
767
815
|
};
|
|
768
816
|
};
|
|
769
817
|
var emiters = {
|
|
@@ -936,19 +984,25 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
936
984
|
}
|
|
937
985
|
return element;
|
|
938
986
|
}
|
|
939
|
-
var
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
987
|
+
var deepcontexts = [];
|
|
988
|
+
var getDeepContext = function (deep) {
|
|
989
|
+
var length = deep;
|
|
990
|
+
var deepL = deepcontexts.length;
|
|
991
|
+
while (deep-- > deepL) {
|
|
992
|
+
deepcontexts[deep] = `with($parentScopes[${deep}])`;
|
|
943
993
|
}
|
|
944
|
-
return
|
|
994
|
+
return deepcontexts.slice(0, length).join('');
|
|
995
|
+
}
|
|
996
|
+
var createEval = function (deep) {
|
|
997
|
+
return new Function("$parentScopes", "code", "event", `${getDeepContext(deep)}return eval(code)`);
|
|
945
998
|
};
|
|
999
|
+
|
|
946
1000
|
var evalcontexts = [createEval(0)];
|
|
947
1001
|
|
|
948
1002
|
function $$eval(search, scopes, target = this, event) {
|
|
949
1003
|
var length = scopes.length;
|
|
950
|
-
if (!evalcontexts[length]) evalcontexts[length] = createEval(length);
|
|
951
1004
|
var eval2 = evalcontexts[length];
|
|
1005
|
+
if (!eval2) eval2 = evalcontexts[length] = createEval(length);
|
|
952
1006
|
var res = eval2.call(target, scopes, search, event);
|
|
953
1007
|
return res;
|
|
954
1008
|
}
|
package/coms/zimoli/tree.js
CHANGED
|
@@ -42,6 +42,7 @@ function tree() {
|
|
|
42
42
|
generator = arg;
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
+
if (!element) element = document.createElement('tree');
|
|
45
46
|
if (!generator && element && "$src" in element && element.childNodes.length) {
|
|
46
47
|
generator = getGenerator(element, 'node');
|
|
47
48
|
}
|
|
@@ -212,7 +213,6 @@ function tree() {
|
|
|
212
213
|
} else {
|
|
213
214
|
marginTop = top.offsetTop - bottom.offsetTop - bottom.offsetHeight;
|
|
214
215
|
}
|
|
215
|
-
css(banner, { paddingBottom: -marginTop });
|
|
216
216
|
var res = transition(top, {
|
|
217
217
|
transition: `margin-top ${time(marginTop)}s ease-out`,
|
|
218
218
|
marginTop: fromOffset(marginTop)
|
|
@@ -232,7 +232,6 @@ function tree() {
|
|
|
232
232
|
setState(false);
|
|
233
233
|
z0();
|
|
234
234
|
var paddingBottom = -margin_top;
|
|
235
|
-
css(banner, { paddingBottom });
|
|
236
235
|
var res = transition(change_elem, { transition: `margin-top ${time(margin_top)}s ease-out`, marginTop: fromOffset(margin_top) }, false);
|
|
237
236
|
timeout(z1, res + 60);
|
|
238
237
|
}
|
package/coms/zimoli/tree.less
CHANGED
package/coms/zimoli/tree_test.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
|
|
1
2
|
var data1 = random([
|
|
2
3
|
{
|
|
3
4
|
name: "一级目录${inc}"
|
|
4
5
|
}
|
|
5
|
-
],
|
|
6
|
+
], 2);
|
|
6
7
|
var data2 = random([{
|
|
7
8
|
name: "一级目录${inc}",
|
|
8
9
|
children: [
|
|
@@ -16,14 +17,15 @@ var data2 = random([{
|
|
|
16
17
|
},
|
|
17
18
|
]
|
|
18
19
|
}
|
|
19
|
-
],
|
|
20
|
+
], 2)
|
|
20
21
|
|
|
21
22
|
function tree_test() {
|
|
22
23
|
var banner = tree();
|
|
23
24
|
banner.setData(data2);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
css(banner, {
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
padding: 0,
|
|
28
|
+
height: 260
|
|
29
|
+
});
|
|
28
30
|
return banner;
|
|
29
31
|
}
|
package/coms/zimoli/zimoli.js
CHANGED
|
@@ -447,7 +447,7 @@ function zimoli(pagepath, args, history_name, oldpagepath) {
|
|
|
447
447
|
}
|
|
448
448
|
if (isNode(history_name))
|
|
449
449
|
var zid = history_name.zimoliid = (history_name.zimoliid | 0) + 1;
|
|
450
|
-
else var zid = ++zimoliid;
|
|
450
|
+
else var zid = arguments.length ? ++zimoliid : zimoliid;
|
|
451
451
|
|
|
452
452
|
if (page_generators[pagepath]) return go(pagepath, args, history_name, oldpagepath);
|
|
453
453
|
return prepare(pagepath, function () {
|