efront 4.22.1 → 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.
@@ -315,28 +315,36 @@ function parse(piece) {
315
315
  holder,
316
316
  do: action,
317
317
  editable,
318
+ colon,
318
319
  avoid,
319
320
  needs, valid, repeat, endwith,
320
321
  required, inlist, hidden, readonly,
321
322
  delete_onempty, delete_onsubmit,
323
+ option_to,
324
+ options_from,
322
325
  } = name;
323
326
  }
324
327
  else if (typeof type === 'string') {
325
328
  var test = (reg, a) => {
326
329
  if (reg.test(a)) {
327
- return true;
330
+ a = a.replace(reg, '');
331
+ return [true, a];
328
332
  }
333
+ return [, a];
329
334
  };
330
335
  var is = function (a) {
331
- var reg = /^[\*\+\-\!\-&\?\~]|^\$(?!\d)|[\*\+\-\!\-\$&\?\~]$/;
336
+ var reg = /^\$(?!\d)|[\*\+\-\!\-\$&\?\~\:;]|^[\*\+\-\!\-&\?\~]$/;
332
337
  if (!reg.test(a)) return a;
333
- required = test(/^\*|\*$/, a);
334
- if (test(/^[\+]|[\+]$/, a)) inlist = true;
335
- if (test(/^[\!]|[\!]$/, a)) inlist = false;
336
- hidden = test(/^\-|\-$/, a);
337
- readonly = test(/^&|\$(?!\d)|[\$&]$/, a);
338
- delete_onempty = test(/^\?|\?$/, a);
339
- delete_onsubmit = test(/^\~|\~$/, a);
338
+ [colon, a] = test(/\;$/, a);
339
+ if (colon) colon = false;
340
+ else[colon, a] = test(/;$/, a);
341
+ [required, a] = test(/^\*|\*$/, a);
342
+ [inlist, a] = test(/^[\+]|[\+]$/, a);
343
+ [inlist, a] = test(/^[\!]|[\!]$/, a);
344
+ [hidden, a] = test(/^\-|\-$/, a);
345
+ [readonly, a] = test(/^&|\$(?!\d)|[\$&]$/, a);
346
+ [delete_onempty, a] = test(/^\?|\?$/, a);
347
+ [delete_onsubmit, a] = test(/^\~|\~$/, a);
340
348
  return a.replace(reg, '');
341
349
  };
342
350
  var type1 = is(type);
@@ -456,6 +464,9 @@ function parse(piece) {
456
464
  var field = {
457
465
  name, type, key, value, comment, options,
458
466
  editable,
467
+ colon,
468
+ option_to,
469
+ options_from,
459
470
  size, unit, ratio, holder,
460
471
  needs, valid, repeat, endwith,
461
472
  required, inlist, hidden, readonly,
@@ -1,6 +1,6 @@
1
- <template a-if="!checkNeeds(field.needs,data)"></template>
1
+ <template a-if="!check(data,field.needs)"></template>
2
2
  <template v-else-if='field?.name'>
3
- <div class="head">
3
+ <div class="head" nocolon:="field.colon===false">
4
4
  <span ng-bind=field.name></span>
5
5
  <span class="required" ng-if="field.required">*</span>
6
6
  </div>
@@ -3,7 +3,7 @@ var reshape = function () {
3
3
  var isInlineBlock = body && /^inline/i.test(getComputedStyle(body).display);
4
4
  if (head && body) {
5
5
  var left = head.offsetWidth + 1;
6
- if (isInlineBlock && left < body.offsetWidth >> 2) {
6
+ if (isInlineBlock && left < (this.break || body.offsetWidth >> 2)) {
7
7
  css(head, {
8
8
  marginRight: fromOffset(-left),
9
9
  marginBottom: ''
@@ -28,7 +28,7 @@ var reshape = function () {
28
28
  if (!body) body = head;
29
29
  if (foot && body) {
30
30
  var right = foot.offsetWidth + 1;
31
- if (isInlineBlock && right < body.offsetWidth >> 2) {
31
+ if (isInlineBlock && right < (this.break || body.offsetWidth >> 2)) {
32
32
  css(foot, {
33
33
  marginTop: '',
34
34
  marginLeft: fromOffset(-right)
@@ -51,65 +51,70 @@ var reshape = function () {
51
51
  }
52
52
  }
53
53
  };
54
-
54
+ var checkValue = function () {
55
+ if (!(this.src instanceof Array)) return;
56
+ var { field, data } = this.$scope;
57
+ if (!field || !data) return;
58
+ var v = data[field.key];
59
+ if (!this.checked) if (v === this.oldValue || isEmpty(this.oldValue) && isEmpty(v)) return;
60
+ this.checked = false;
61
+ this.setAttribute("dirty", '');
62
+ var scope = this.$scope;
63
+ var error = valid(field, data);
64
+ if (error) {
65
+ this.setAttribute("error", error);
66
+ switch (error) {
67
+ case "empty":
68
+ scope.error = true;
69
+ break;
70
+ default:
71
+ if (isNode(error)) {
72
+ scope.error = error;
73
+ }
74
+ else {
75
+ scope.error = document.createElement('error');
76
+ scope.error.innerHTML = error;
77
+ }
78
+ }
79
+ }
80
+ else {
81
+ this.removeAttribute('error');
82
+ scope.error = null;
83
+ }
84
+ this.oldValue = data[field.key];
85
+ };
86
+ function ondigest() {
87
+ checkValue.call(this);
88
+ reshape.call(this);
89
+ }
90
+ function ondata(p) {
91
+ var [field, data] = p;
92
+ this.oldValue = data[field.key];
93
+ this.setAttribute("field", field.key);
94
+ this.innerHTML = template;
95
+ render(this, {
96
+ model,
97
+ data,
98
+ error: null,
99
+ field,
100
+ container,
101
+ check,
102
+ readonly: !!this.readonly
103
+ });
104
+ this.reshape();
105
+ }
55
106
  function main(elem) {
56
107
  if (!isElement(elem)) elem = document.createElement('field');
57
108
  elem.reshape = reshape;
58
- resizingList.set(elem, () => elem.reshape());
109
+ if (elem.break === false) elem.break = Infinity;
110
+ resizingList.set(elem, reshape);
59
111
  elem.setAttribute("field", '');
60
- var scope = {};
61
- elem.$renders = [function () {
62
- if (!(this.src instanceof Array)) return;
63
- var [f, data] = this.src;
64
- if (!f || !data) return;
65
- var v = data[f.key];
66
- if (!this.checked) if (v === this.oldValue || isEmpty(this.oldValue) && isEmpty(v)) return;
67
- this.checked = false;
68
- this.setAttribute("dirty", '');
69
- var error = valid(f, data);
70
- if (error) {
71
- this.setAttribute("error", error);
72
- switch (error) {
73
- case "empty":
74
- scope.error = true;
75
- break;
76
- default:
77
- if (isNode(error)) {
78
- scope.error = error;
79
- }
80
- else {
81
- scope.error = document.createElement('error');
82
- scope.error.innerHTML = error;
83
- }
84
- }
85
- }
86
- else {
87
- this.removeAttribute('error');
88
- scope.error = null;
89
- }
90
- this.oldValue = data[f.key];
91
- }]
112
+ elem.$digest = ondigest;
92
113
  elem.removeAttribute("tabindex");
93
114
 
94
- if (!elem.childNodes.length) care(elem, function (p) {
95
- var [f, data] = p;
96
- elem.innerHTML = field;
97
- render(elem, scope = {
98
- model,
99
- data,
100
- error: null,
101
- field: f,
102
- container,
103
- checkNeeds(needs, data) {
104
- var res = check(data, needs);
105
- return res;
106
- },
107
- readonly: !!this.readonly
108
- });
109
- elem.oldValue = data[f.key];
110
- elem.setAttribute("field", f.key);
111
- elem.reshape();
112
- }, false);
115
+ if (!elem.childNodes.length) {
116
+ care(elem, ondata, false);
117
+ }
113
118
  else {
114
119
  var [head, body, foot] = getTypedChildren(elem, ["head", 'body', 'foot']);
115
120
  if (head) addClass(head, "head");
@@ -37,6 +37,22 @@ model {
37
37
  }
38
38
  }
39
39
 
40
+ [nocolon] & {
41
+ >.head {
42
+ &:after {
43
+ display: none;
44
+ }
45
+ }
46
+ }
47
+
48
+ [nocolon] &>.head,
49
+ &[nocolon]>.head,
50
+ >.head[nocolon] {
51
+ &:after {
52
+ display: none;
53
+ }
54
+ }
55
+
40
56
  >.body {
41
57
  .image {
42
58
  margin: 10px 0;
@@ -57,12 +73,14 @@ model {
57
73
  }
58
74
 
59
75
  >.foot {
76
+ text-align: right;
77
+ right: 0;
78
+
60
79
  span {
61
- vertical-align: middle;
80
+ vertical-align: top;
62
81
  }
63
82
  }
64
83
 
65
-
66
84
  .input {
67
85
  width: 100%;
68
86
  }
@@ -547,6 +547,7 @@ var grid_prototype = {
547
547
  current_b = temp_b;
548
548
  } else {
549
549
  var _div = point.target;
550
+ if (!_div && grid.patchCell) _div = point.target = document.createElement('cell');
550
551
  if (_div && _div.parentNode !== grid) appendChild(grid, _div);
551
552
  var current_value;
552
553
  if (current_d === "x") {
@@ -1,9 +1,9 @@
1
- <btn class="plus" ng-if="!hasInstance" ng-click=this.parentNode.choose()>
1
+ <btn class="plus" ng-if="!this.parentNode.hasInstance?" ng-click=this.parentNode.choose()>
2
2
  <div class="icon">
3
3
 
4
4
  </div>
5
5
  <div>添加图片</div>
6
6
  </btn>
7
- <btn class="label" ng-if="hasInstance" ng-click=this.parentNode.choose()>
7
+ <btn class="label" ng-if="this.parentNode.hasInstance?" ng-click=this.parentNode.choose()>
8
8
  更换图片
9
9
  </btn>
@@ -1,8 +1,4 @@
1
1
  var { URL } = window;
2
- var defaultScope = {
3
- hasInstance: false,
4
- btn: button
5
- };
6
2
  function setValue(src) {
7
3
  if (this.value === src) return;
8
4
  this.value = src;
@@ -37,27 +33,26 @@ var choose = function () {
37
33
 
38
34
  var build = function () {
39
35
  var elem = this;
40
- var { $scope = {} } = elem;
41
36
  elem.choose = choose;
42
- extendIfNeeded($scope, defaultScope);
43
37
  elem.setValue = setValue;
44
38
  elem.getValue = getValue;
45
- render(elem, $scope);
39
+ render(elem, { btn: button });
46
40
  };
47
41
 
42
+ var ondata = function (src) {
43
+ css(this, {
44
+ backgroundImage: `url('${src}')`
45
+ });
46
+ this.hasInstance = !!src;
47
+ }
48
48
  function main(elem = div()) {
49
49
  var { uploadto } = elem;
50
+ elem.choose = choose;
50
51
  elem.innerHTML = image;
51
52
  if (!uploadto) {
52
53
  uploadto = elem.getAttribute("uploadto");
53
54
  }
54
- care(elem, function (src) {
55
- css(elem, {
56
- backgroundImage: `url('${src}')`
57
- });
58
- this.hasInstance = this.$scope.hasInstance = !!src;
59
- render.refresh();
60
- }, false);
55
+ care(elem, ondata, false);
61
56
  build.call(elem);
62
57
  return elem;
63
58
  }
@@ -197,7 +197,7 @@ function main() {
197
197
  var target = root.actived.target;
198
198
  if (isObject(menu.value)) delete menu.value.children;
199
199
  var targetmenu = getMenu(target);
200
- targetmenu.extends(menu.value);
200
+ extend(targetmenu.value, menu.value);
201
201
  menu = targetmenu;
202
202
  }
203
203
  else {
@@ -293,6 +293,7 @@ function main() {
293
293
  if (istoolbar) {
294
294
  if (item.constructor === Item && item.length && !item.extended) {
295
295
  item.extends(item[0]);
296
+ item.value = Object.assign({}, item.value);
296
297
  }
297
298
  }
298
299
  return generator(index, item);
@@ -236,7 +236,8 @@ var setContent = function (value) {
236
236
  appendChild(this, value);
237
237
  }
238
238
  else if (isHandled(value)) {
239
- this.innerHTML = value;
239
+ if (this.field.type === 'html') this.innerHTML = value;
240
+ else this.innerText = value;
240
241
  }
241
242
  };
242
243
  var Binder = render.Binder, Model = render.Model;
@@ -279,6 +280,19 @@ function getScopeValue() {
279
280
  function setScopeValue(v) {
280
281
  this.data[this.field.key] = v;
281
282
  }
283
+ var copyOptionData = function () {
284
+ var { data, field } = this;
285
+ if (!data || !field) return;
286
+ var { option_to, options } = field;
287
+ if (!options) return;
288
+ var value = data[field.key];
289
+ var option = isObject(value) ? value : value in options ? options[value] : value;
290
+ extend(data, seek(option, option_to));
291
+ };
292
+ var getOptionsFrom = function () {
293
+ var { data, field } = this;
294
+ return data[field.options_from];
295
+ };
282
296
  function setBinder(elem, binder) {
283
297
  if (binder === elem.$binder) return;
284
298
  removeFromList(elem.$renders, elem.$binder);
@@ -293,7 +307,7 @@ function setBinder(elem, binder) {
293
307
  if (isHandled(ipt) && ipt !== elem) {
294
308
  if (isNode(ipt)) {
295
309
  var model = new Model(getScopeValue, setScopeValue, ipt);
296
- model.hook(elem, ipt);
310
+ model.hook(elem, elem.field.option_to ? copyOptionData : true);
297
311
  appendChild(elem, ipt);
298
312
  }
299
313
  else {
@@ -352,6 +366,11 @@ var run = function ({ changes }) {
352
366
  var [field_type, field_ref] = field_type.split("?");
353
367
  field.ref = field_ref;
354
368
  }
369
+ if (field.options_from) {
370
+ Object.defineProperty(field, 'options', {
371
+ get: getOptionsFrom.bind(elem)
372
+ });
373
+ }
355
374
  var type = elem.getAttribute('type');
356
375
  if (type !== field_type) {
357
376
  elem.setAttribute("type", field_type);