efront 3.11.2 → 3.11.3

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.
@@ -118,7 +118,7 @@ var scan = function (text) {
118
118
  }
119
119
 
120
120
  if (/^\-(\s|$)/.test(row)) {
121
- if (data || span > spacesize) push();
121
+ if (data || span >= spacesize) push();
122
122
  if (!parents[spacesize]) {
123
123
  var obj = [];
124
124
  push(obj);
@@ -33,10 +33,23 @@
33
33
  };
34
34
  var parseMenuList = function (items) {
35
35
  if (items instanceof Array) {
36
+ if (!items[0] || !items[0].name) {
37
+ var items1 = [];
38
+ for (var cx = 0, dx = items.length; cx < dx; cx++) {
39
+ var item = items[cx];
40
+ if (!item) continue;
41
+ item = parseMenuList(item);
42
+ items1.push.apply(items1, item);
43
+ items1.push({ line: true });
44
+ }
45
+ items1.pop();
46
+ items = items1;
47
+ }
36
48
  return items;
37
49
  }
38
50
  if (items instanceof Object) {
39
51
  var keys = Object.keys(items);
52
+
40
53
  items = keys.map(k => {
41
54
  var c = items[k];
42
55
  var item = {};
@@ -54,7 +67,8 @@
54
67
  if (/,/.test(name)) {
55
68
  var [name, ...roles] = name.split(',');
56
69
  }
57
- item.name = name;
70
+ if (/^\-+$/.test(name)) item.line = true;
71
+ else item.name = name;
58
72
  if (roles) item.roles = roles;
59
73
  if (path) item.path = path;
60
74
  if (data) item.params = parseKV(data);
@@ -68,6 +82,8 @@
68
82
  return [];
69
83
  };
70
84
  result.update = function (items) {
85
+ delete result.loading_promise;
86
+ delete result.then;
71
87
  items = parseMenuList(items);
72
88
  items.map(getChildren);
73
89
  var opened = data.getInstance("menu-opened");
@@ -174,10 +190,19 @@
174
190
  result.load(result.active);
175
191
  return result;
176
192
  };
177
- result.fetch = function (url) {
178
- data.from(url).loading_promise.then(result.update);
193
+ result.from = result.fetch = function (url) {
194
+ result.loading_promise = data.from(url).loading_promise.then(result.update);
195
+ result.then = then;
179
196
  return result;
180
197
  };
198
+ var then = function (ok, oh) {
199
+ if (this.loading_promise) {
200
+ return this.loading_promise.then(ok, oh);
201
+ }
202
+ delete result.then;
203
+ ok(result);
204
+ result.then = then;
205
+ };
181
206
  result.update(items);
182
207
  return result;
183
208
  });
@@ -19,6 +19,7 @@ function Item(value) {
19
19
  this.icon = value.icon;
20
20
  this.color = value.color;
21
21
  this.test = value.test;
22
+ this.line = value.line;
22
23
  }
23
24
  this.count = 0;//子项中的叶子节点数
24
25
  this.total = 0;//子项中的节点数
@@ -18,7 +18,8 @@
18
18
  outline: none;
19
19
  user-select: none;
20
20
  }
21
- >.label{
21
+
22
+ >.label {
22
23
  position: relative;
23
24
  }
24
25
 
@@ -91,7 +92,7 @@
91
92
 
92
93
  >.track {
93
94
  background: #0001;
94
- box-shadow: inset 0 0 6px 6px #6fc3;
95
+ box-shadow: inset 0 0 6px 6px #00000006;
95
96
  }
96
97
  }
97
98
 
@@ -1,13 +1,9 @@
1
1
 
2
2
  var _slider = createElement(div);
3
- var empty = function (index, item) {
4
- if (!item) return;
5
- return document.createElement('empty');
6
- };
7
- var getGenerator = function (container) {
3
+ var getGenerator = function (container, tagName = 'item') {
8
4
  if (!container) return;
9
- if (!container.childNodes.length) return container.$generator || empty;
10
- var template = document.createElement("div");
5
+ if (!container.childNodes.length && container.$generator) return container.$generator;
6
+ var template = document.createElement(tagName);
11
7
  var templates = [].concat.apply([], container.childNodes).filter(a => {
12
8
  if (a.hasAttribute('insert')) {
13
9
  return false;
@@ -25,17 +21,24 @@ var getGenerator = function (container) {
25
21
  appendChild(template, templates);
26
22
  container.insertBefore = _slider.insertBefore;
27
23
  container.appendChild = _slider.appendChild;
28
- var scopes = container.$parentScopes.concat(container.$scope);
29
- return container.$generator = function (index, com) {
24
+ var scopes = container.$parentScopes || [];
25
+ if (container.$scope) scopes = scopes.concat(container.$scope);
26
+ return container.$generator = function (index, com, element) {
30
27
  if (!com) {
31
28
  if (!container.src || index >= container.src.length) return;
32
29
  com = container.src[index];
33
30
  }
34
31
  if (!com) return;
35
- var template1 = template.cloneNode(true);
36
- if (!template1.childNodes.length) return template1;
37
- var item = template1.childNodes[0];
38
- item.with = [].concat.apply([], template1.childNodes).slice(1);
32
+ if (!element) {
33
+ var template1 = template.cloneNode(true);
34
+ if (!template1.childNodes.length) {
35
+ element = template1;
36
+ }
37
+ else {
38
+ element = template1.childNodes[0];
39
+ if (template1.childNodes.length > 1) element.with = [].concat.apply([], template1.childNodes).slice(1);
40
+ }
41
+ }
39
42
  var parsedSrc = container.$src;
40
43
  if (parsedSrc) {
41
44
  var { keyName, itemName, indexName } = parsedSrc;
@@ -44,8 +47,8 @@ var getGenerator = function (container) {
44
47
  [itemName || '$item']: com,
45
48
  [indexName || '$index']: index
46
49
  };
47
- var newItem = render(item, newScope, scopes);
48
- if (item.with.length) newItem.with = render(item.with, newScope, scopes);
50
+ var newItem = render(element, newScope, scopes);
51
+ if (element.with) newItem.with = render(element.with, newScope, scopes);
49
52
  } else {
50
53
  var newScope = container.src[index];
51
54
  if (!isObject(newScope)) newScope = {
@@ -65,8 +68,8 @@ var getGenerator = function (container) {
65
68
  return this.$item;
66
69
  }
67
70
  }
68
- var newItem = render(item, newScope, scopes);
69
- newItem.with = render(newItem.with = item.with, newScope, scopes);
71
+ var newItem = render(element, newScope, scopes);
72
+ if (element.with) newItem.with = render(newItem.with = element.with, newScope, scopes);
70
73
  }
71
74
  return newItem;
72
75
  };
@@ -117,8 +117,9 @@ function main(elem, mode) {
117
117
  case "inline":
118
118
  case "t":
119
119
  case "tree":
120
+ mode = "tree";
120
121
  if (elem) {
121
- var generator = getGenerator(elem);
122
+ var generator = getGenerator(elem, 'menu-item');
122
123
  tree(elem, function (index, item) {
123
124
  var e = generator(index, item);
124
125
  if (!e || e.children.length) return e;
@@ -156,7 +157,7 @@ function main(elem, mode) {
156
157
  active(elem, item, item.value, target);
157
158
  };
158
159
  if ("$src" in elem) {
159
- getGenerator(elem);
160
+ getGenerator(elem, 'menu-item');
160
161
  care(elem, function (src) {
161
162
  menuList(elem, getTreeFromData(src), emit, direction);
162
163
  elem.registerAsRoot();
@@ -92,12 +92,15 @@ body:active & {
92
92
  display: block;
93
93
  overflow: hidden;
94
94
  text-overflow: hidden;
95
- line-height: 40px;
96
95
  position: relative;
97
96
  border-bottom: 1px solid #18333c;
97
+ border-top: none;
98
+ border-left: none;
99
+ border-right: none;
98
100
  padding: 0;
99
101
 
100
102
  menu-item {
103
+ line-height: 24px;
101
104
  display: inline-block;
102
105
 
103
106
  &.has-children:after {
@@ -110,11 +113,9 @@ body:active & {
110
113
  vertical-align: top;
111
114
  }
112
115
 
113
- .button {
114
- line-height: 40px;
115
- }
116
116
  }
117
117
 
118
+ &[mode=tree],
118
119
  &[mode=tree],
119
120
  &[type=tree],
120
121
  &[mode=inline],
@@ -122,46 +123,46 @@ body:active & {
122
123
  height: auto;
123
124
  box-shadow: none;
124
125
  padding: 0;
125
- margin: 0;
126
-
127
- // &[browser=samsung] {
128
- // .tab1 {
129
- // &.open s {
130
- // overflow : visible;
131
- // text-indent: -6.6pt;
132
- // }
133
- // &.closed s{
134
- // overflow : visible;
135
- // text-indent: 3.1pt;
136
- // }
137
- // }
138
- // }
139
-
140
- // &[browser=firefox] {
141
- // .tab1 {
142
- // &.open s {
143
- // text-indent: -8.6px;
144
- // }
145
-
146
- // &.closed s {
147
- // text-indent: -4.1px;
148
- // }
149
- // }
150
- // }
151
-
152
- // &[browser=safari] {
153
- // .tab1 {
154
- // &.open s {
155
- // text-indent: -5.6px;
156
- // }
157
-
158
- // &.closed s {
159
- // text-indent: -1.1px;
160
- // }
161
- // }
162
- // }
163
-
164
- .tab1 {
126
+
127
+ >.button {
128
+ box-shadow: none;
129
+ padding-top: 6px;
130
+ padding-bottom: 6px;
131
+ line-height: 20px;
132
+ font-size: 14px;
133
+
134
+ >b {
135
+ font-weight: normal;
136
+ }
137
+
138
+ &:not(.tab1) {
139
+ display: block;
140
+ background: #2c3b41;
141
+ color: #8aa4af;
142
+
143
+ &.checked,
144
+ &.actived,
145
+ &.selected {
146
+ color: #fff;
147
+ }
148
+ }
149
+
150
+ i {
151
+ margin-right: 10px;
152
+ }
153
+
154
+
155
+ &.hover {
156
+ text-shadow: none;
157
+ color: #fff;
158
+ }
159
+
160
+ }
161
+
162
+ >.tab1 {
163
+ font-size: 16px;
164
+ line-height: 28px;
165
+
165
166
  &.open {
166
167
  color: #fff;
167
168
  background: #1e282c;
@@ -218,45 +219,13 @@ body:active & {
218
219
 
219
220
  border-left: 3px solid transparent;
220
221
  display : block;
221
- height : 44px;
222
- line-height: 44px;
223
222
  font-size : 14px;
224
223
  color : #b8c7ce;
225
224
  }
226
225
 
227
- >.button {
228
- box-shadow: none;
229
-
230
-
231
- >b {
232
- font-weight: normal;
233
- }
234
-
235
- &:not(.tab1) {
236
- display: block;
237
- height: 36px;
238
- line-height: 36px;
239
- font-size: 14px;
240
- background: #2c3b41;
241
- color: #8aa4af;
242
-
243
- &.checked,
244
- &.actived,
245
- &.selected {
246
- color: #fff;
247
- }
248
- }
249
-
250
- i {
251
- margin-right: 10px;
252
- }
253
-
254
-
255
- &.hover {
256
- text-shadow: none;
257
- color: #fff;
258
- }
259
-
226
+ >[line],
227
+ >.line {
228
+ line-height: 0;
229
+ font-size: 0;
260
230
  }
261
-
262
231
  }
@@ -1,3 +1,4 @@
1
+ var preventDefault = function (e) { e.preventDefault() };
1
2
  function main(elem, scope, hasIcon) {
2
3
  var item = elem || document.createElement('menu-item');
3
4
  item.innerHTML = menuItem;
@@ -11,5 +12,6 @@ function main(elem, scope, hasIcon) {
11
12
  var icon = scope.icon;
12
13
  if (hasIcon === undefined) hasIcon = !!icon;
13
14
  render(item.children, { useIcon: hasIcon, hasIcon, name, icon });
15
+ if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
14
16
  return item;
15
17
  }
@@ -1,4 +1,20 @@
1
1
  i{
2
2
  display: inline-block;
3
3
  width: 1em;
4
+ }
5
+ &.line,
6
+ &[line] {
7
+ box-shadow: none;
8
+ >.track{
9
+ display: none;
10
+ }
11
+ line-height: 0;
12
+ font-size: 0;
13
+ &:after {
14
+ content: "";
15
+ display: block;
16
+ border-bottom: 1px solid;
17
+ opacity: .36;
18
+ margin: 0 -20px;
19
+ }
4
20
  }
@@ -11,11 +11,11 @@ var clear = function () {
11
11
  var unfocus = function () {
12
12
  remove(mounted_menus);
13
13
  this.ispop = false;
14
- this.setFocus();
14
+ this.setFocus(null);
15
15
  };
16
- var setFocus = function (focused = this.firstMenu) {
16
+ var setFocus = function (focused) {
17
17
  var page = this;
18
- if (page.ispop || page === document.activeElement) {
18
+ if (focused) {
19
19
  if (page.focused !== focused) {
20
20
  if (page.focused) removeClass(page.focused, 'focus');
21
21
  if (focused) addClass(focused, "focus");
@@ -106,12 +106,18 @@ function keyalt() {
106
106
  else {
107
107
  root_menu.tabIndex = 0;
108
108
  root_menu.focus();
109
+ root_menu.setFocus(this.firstMenu);
109
110
  }
110
- root_menu.setFocus();
111
+ }
112
+ function keytab(event) {
113
+ if (root_menu !== document.activeElement) return;
114
+ var menu = mounted_menus[mounted_menus.length - 1] || root_menu;
115
+ event.preventDefault();
116
+ menu.moveFocus(1);
111
117
  }
112
118
  function keyesc() {
113
119
  if (root_menu === document.activeElement && !mounted_menus.length) {
114
- if (!root_menu.ispop) root_menu.blur(), root_menu.setFocus();
120
+ if (!root_menu.ispop) root_menu.blur();
115
121
  else root_menu.ispop = false;
116
122
  }
117
123
  }
@@ -137,6 +143,7 @@ function keyspace() {
137
143
  }
138
144
  function register() {
139
145
  // on('keydown.alt')(window, e => e.preventDefault());
146
+ on('keydown.tab')(window, keytab);
140
147
  on('keydown.alt.')(window, keyalt);
141
148
  on('keydown.esc')(window, keyesc);
142
149
  on('keydown.left')(window, keyleft);
@@ -162,6 +169,7 @@ function main(page, items, active, direction = 'y') {
162
169
  if (!item.children || !item.children.length) return;
163
170
  var clone = template.cloneNode();
164
171
  clone.$parentScopes = page.$parentScopes;
172
+ clone.$scope = page.$scope;
165
173
  clone.$src = src;
166
174
  clone.innerHTML = template.innerHTML;
167
175
  var menu = main(clone, item.children, active);
@@ -210,16 +218,18 @@ function main(page, items, active, direction = 'y') {
210
218
  }
211
219
  var fire = function () {
212
220
  cancel();
221
+ if (this.menu.line) return;
213
222
  var pop = active(this.menu, this);
214
223
  if (pop === false) return;
215
224
  var root = page.root || page;
216
225
  if (root.ispop === 1) root.ispop = false;
217
226
  if (page.actived && page.actived.target === this) {
227
+ while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page.actived) remove(mounted_menus.pop());
218
228
  if (!mounted_menus.length) {
219
229
  popMenu(this.menu, this);
220
230
  }
221
231
  else {
222
- unfocus.call(page);
232
+ remove(mounted_menus.pop());
223
233
  }
224
234
  }
225
235
  else {
@@ -244,8 +254,8 @@ function main(page, items, active, direction = 'y') {
244
254
  return false;
245
255
  };
246
256
  var $scope = {
247
- "menu-item": function (e, s) {
248
- var a = bindAccesskey(
257
+ "menu-item"(e, s) {
258
+ var a = button(
249
259
  menuItem(e, s, this.hasIcon)
250
260
  );
251
261
  if (!page.firstMenu) {
@@ -261,31 +271,23 @@ function main(page, items, active, direction = 'y') {
261
271
  };
262
272
  if (page.$src) {
263
273
  var src = page.$src;
264
- var parentScopes = page.$parentScopes;
265
274
  var itemName = src.itemName;
266
275
  var className = `{'has-children':${itemName}.children&&${itemName}.children.length,'warn':${itemName}.type==='danger'||${itemName}.type==='warn'||${itemName}.type==='red'}`;
267
276
  var notHidden = `!${itemName}.hidden`;
277
+ var generator = getGenerator(page, 'menu-item');
268
278
 
269
279
  list(page, function (index) {
270
280
  var item = items[index];
271
281
  if (!item) return;
272
- var a = $scope["menu-item"](null, item);
273
- var scope = {};
274
282
  if (item instanceof Item) item = item.value;
275
- if (src.itemName) scope[src.itemName] = item;
276
- else scope.$item = item;
277
- if (src.keyName) scope[src.keyName] = index;
278
- else scope.$key = index;
279
- if (src.indexName) scope[src.indexName] = index;
280
- else scope.$index = index;
281
- if (src.srcName) scope[src.srcName] = items;
283
+ var a = $scope["menu-item"](null, item);
282
284
  if (src.itemName) a.setAttribute("e-if", notHidden);
285
+ a.setAttribute("e-class", className);
286
+ a = generator(index, item, a);
283
287
  a.menu = item;
284
288
  on("mouseleave")(a, cancel);
285
289
  on("mouseenter")(a, open);
286
290
  on("click")(a, fire);
287
- a.setAttribute("e-class", className);
288
- render(a, scope, parentScopes);
289
291
  return a;
290
292
  });
291
293
  on("append")(page, function () {
@@ -303,7 +305,7 @@ function main(page, items, active, direction = 'y') {
303
305
  });
304
306
  }
305
307
  else {
306
- var generator = getGenerator(page);
308
+ var generator = getGenerator(page, 'menu-item');
307
309
 
308
310
  list(page, function (index) {
309
311
  var elem = generator(index);
@@ -5,7 +5,6 @@
5
5
  background-color: #fff;
6
6
  box-shadow: 0 0 20px -6px rgba(0, 0, 0, .1);
7
7
  border: 1px solid #0003;
8
- line-height: 28px;
9
8
  padding: 6px 0;
10
9
 
11
10
  >menu-item {
@@ -17,6 +16,10 @@
17
16
  color: inherit;
18
17
  box-shadow: none;
19
18
  text-align: inherit;
19
+ vertical-align: top;
20
+ line-height: 20px;
21
+ padding-top: 4px;
22
+ padding-bottom: 4px;
20
23
 
21
24
  &.warn {
22
25
  color: #c28;
@@ -27,7 +30,8 @@
27
30
  }
28
31
 
29
32
  &.has-children {
30
- padding: 0 24px 0 16px;
33
+ padding-right: 24px;
34
+ padding-left: 16px;
31
35
 
32
36
  &:after {
33
37
  content: ">";
@@ -529,14 +529,14 @@ var binders = {
529
529
  };
530
530
  var createEmiter = function (on) {
531
531
  return function (key, search) {
532
- if (this.$src) {
533
- var parsedSrc = this.$src;
532
+ var parsedSrc = this.$src;
533
+ var getter0 = createGetter(search, false), getter1;
534
+ if (parsedSrc) {
534
535
  var scopes = this.$parentScopes;
535
536
  search = search.slice();
536
537
  search[0] += `with(this.$parentScopes[${scopes.length}])`;
537
- this.$parentScopes = scopes.concat(this.$scope);
538
+ getter1 = createGetter(search, false);
538
539
  }
539
- var getter = createGetter(search, false);
540
540
  on(key)(this, function (e) {
541
541
  if (parsedSrc) {
542
542
  var target = e.currentTarget || e.target;
@@ -556,12 +556,14 @@ var createEmiter = function (on) {
556
556
  var res;
557
557
  if (scope) {
558
558
  var temp = this.$scope;
559
+ this.$parentScopes.push(temp);
559
560
  this.$scope = scope;
560
- res = getter.call(this, e);
561
+ res = getter1.call(this, e);
562
+ this.$parentScopes.pop();
561
563
  this.$scope = temp;
562
564
  }
563
565
  else {
564
- res = getter.call(this, e);
566
+ res = getter0.call(this, e);
565
567
  }
566
568
  if (res && isFunction(res.then)) res.then(digest, digest);
567
569
  digest();
@@ -581,7 +583,7 @@ function getFromScopes(key, scope, parentScopes) {
581
583
  }
582
584
  if (parentScopes) for (var cx = parentScopes.length - 1; cx >= 0; cx--) {
583
585
  var o = parentScopes[cx];
584
- if (key in o) {
586
+ if (o && key in o) {
585
587
  return o[key];
586
588
  }
587
589
  }
@@ -614,13 +616,13 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
614
616
  return element;
615
617
  }
616
618
  var isFirstRender = !element.renderid;
617
- element.renderid = 1;
618
- var parentNode = element.parentNode;
619
- if (parentNode) {
620
- if (parentNode.renderid > 1 || parentNode.isMounted) element.renderid = 2;
621
- }
622
619
 
623
620
  if (isFirstRender) {
621
+ element.renderid = 1;
622
+ var parentNode = element.parentNode;
623
+ if (parentNode) {
624
+ if (parentNode.renderid > 1 || parentNode.isMounted) element.renderid = 2;
625
+ }
624
626
  element.renders = element.renders ? [].concat(element.renders) : [];
625
627
  var { ons, copys, attrs, props, binds, context: withContext } = element.$struct;
626
628
  delete element.$struct;
@@ -132,16 +132,18 @@ function tree() {
132
132
  }
133
133
  var tabs = new Array(com.tab + 1).join("<t></t>");
134
134
  if (isFunction(generator)) {
135
- var elem = generator(index, com);
135
+ var elem = generator(index, com instanceof Item ? com.value : com);
136
136
  if (!elem) return;
137
- span = document.createElement('div');
137
+ span = document.createElement('span');
138
138
  span.innerHTML = tabs;
139
- span.appendChild(elem);
139
+ elem.insertBefore(span, elem.firstChild);
140
+ span = elem;
140
141
  } else {
141
- span = div();
142
+ span = document.createElement("node");
142
143
  html(span, `${tabs}<c>${com.name}</c>${com.test ? "<i>_test</i>" : ""}<a class=count>${com.count}</a>`);
143
144
  }
144
145
  var _div = button(span);
146
+ _div.setAttribute("node", '');
145
147
  _div.index = index;
146
148
 
147
149
  if (!com.saved) {
@@ -222,7 +224,7 @@ function tree() {
222
224
  _div.refresh();
223
225
  onclick(_div, function () {
224
226
  var isClosed = com.isClosed();
225
- if (!active(banner, com.value, com)) {
227
+ if (!active(banner, com.value, com, _div)) {
226
228
  return;
227
229
  }
228
230
  if (isClosed === com.isClosed() && com.length) {
@@ -3,13 +3,26 @@
3
3
  background: #222d32;
4
4
  color: #fff;
5
5
 
6
- >div {
6
+ >[node] {
7
7
  display: block;
8
8
  text-align: left;
9
9
  height: auto;
10
10
  background-color: inherit;
11
11
  color: inherit;
12
12
  padding-right: 10px;
13
+ padding-top: 4px;
14
+ padding-bottom: 4px;
15
+ box-shadow: none;
16
+
17
+ &.line,
18
+ &[line] {
19
+ box-shadow: none;
20
+ line-height: 0;
21
+
22
+ >.track {
23
+ display: none;
24
+ }
25
+ }
13
26
  }
14
27
  }
15
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.11.2",
3
+ "version": "3.11.3",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {