efront 3.12.0 → 3.12.4

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.
@@ -29,8 +29,28 @@ var multipleClick = function () {
29
29
  dispatch(node, "change");
30
30
  };
31
31
 
32
- function main(children, multiple, addable) {
33
- var page = div();
32
+
33
+ function main() {
34
+ var children, multiple, addable, generator, page;
35
+ for (let a of arguments) {
36
+ if (a instanceof Array) children = a;
37
+ switch (typeof a) {
38
+ case "function":
39
+ generator = a;
40
+ break;
41
+ case "boolean":
42
+ if (multiple === void 0) multiple = a;
43
+ else addable = a;
44
+ case "object":
45
+ if (isNode(a)) {
46
+ page = a;
47
+ if (!generator) generator = getGenerator(page);
48
+ }
49
+ else if (a.length) children = a;
50
+
51
+ }
52
+ }
53
+ if (!page) page = div();
34
54
  page.value = multiple ? [] : "";
35
55
  var clicker = multiple ? multipleClick : singleClick;
36
56
  var itemMap = Object.create(null);
@@ -67,18 +87,28 @@ function main(children, multiple, addable) {
67
87
  item.setAttribute('disabled', '');
68
88
  } else {
69
89
  onclick(item, clicker);
90
+ on("mouseenter")(item, mouseenter);
70
91
  }
71
92
  return item;
72
93
 
73
94
  }
95
+ var mouseenter = function () {
96
+ if (!mouse) return;
97
+ focus = this.index;
98
+ setFocus();
99
+ };
100
+
101
+
74
102
  var hasIcon = false, iconed = '';
75
103
  var page = list(page, function (i) {
76
104
  if (i < 0 || i >= children.length) return;
77
- return createItem(children[i]);
105
+ return createItem(generator ? generator(i) : children[i]);
78
106
  });
79
- on("append")(page, function () {
107
+ once("append")(page, function () {
108
+ var index = 0;
109
+ for (var cx = 0, dx = children.length; cx < dx; cx++)if (children[cx].selected) index = cx;
80
110
  page.clean();
81
- page.go(0);
111
+ page.go(index);
82
112
  if (adder) {
83
113
  remove(adder);
84
114
  appendChild(page, adder);
@@ -135,6 +165,60 @@ function main(children, multiple, addable) {
135
165
  adder.setAttribute("adder", '');
136
166
  }
137
167
  page.icon = iconed;
168
+ var focus = 0, focused, mouse = false;
169
+ var setFocus = function () {
170
+ var e = page.getIndexedElement(focus);
171
+ if (e === focused) return;
172
+ if (focused) removeClass(focused, 'focus');
173
+ focused = e;
174
+ if (e) addClass(e, 'focus');
175
+ mouse = false;
176
+ };
177
+ var setMouse = function () {
178
+ mouse = true;
179
+ }
180
+ onmousemove(page, setMouse);
181
+ onmousewheel(page, setMouse);
182
+ var moveFocus = function (delta) {
183
+ focus += delta;
184
+ if (focus < 0) focus = 0;
185
+ if (focus >= children.length) focus = children.length - 1;
186
+ page.scrollIfNotCover(focus);
187
+ setFocus();
188
+ };
189
+ bind('keydown.up')(page, function () {
190
+ moveFocus(-1);
191
+ });
192
+ bind('keydown.down')(page, function () {
193
+ moveFocus(1);
194
+ });
195
+ bind('keydown.tab')(page, function (event) {
196
+ if (document.activeElement === page.target) event.preventDefault();
197
+ moveFocus(event.shiftKey ? -1 : 1);
198
+ });
199
+ bind("keydown.home")(page, function (e) {
200
+ moveFocus(-focus);
201
+ });
202
+ bind("keydown.end")(page, function (e) {
203
+ moveFocus(children.length - 1 - focus);
204
+ });
205
+ bind("keydown.pagedown")(page, function (e) {
206
+ page.scrollBy(page.clientHeight);
207
+ focus = page.index() | 0;
208
+ moveFocus(0);
209
+ })
210
+ bind("keydown.pageup")(page, function (e) {
211
+ page.scrollBy(-page.clientHeight);
212
+ focus = page.index() | 0;
213
+ moveFocus(0);
214
+ })
215
+ var enter = function (e) {
216
+ e.preventDefault();
217
+ var e = page.getIndexedElement(focus);
218
+ if (e) e.click();
219
+ };
220
+ bind('keydown.enter')(page, enter);
221
+ bind('keydown.space')(page, enter);
138
222
  on('mousedown')(page, e => e.preventDefault());
139
223
  return page;
140
224
  }
@@ -18,7 +18,7 @@
18
18
  color: #29e;
19
19
  }
20
20
 
21
- &:hover {
21
+ &.focus {
22
22
  background-color: #2ca2f9;
23
23
  color: #fff;
24
24
  }
@@ -2,9 +2,13 @@
2
2
  <option>选项一</option>
3
3
  <option>选项二</option>
4
4
  <option>选项三</option>
5
+ <option selected>简单选项</option>
5
6
  </select>
6
7
  <select>
7
- <option>选项一</option>
8
- <option>选项二</option>
9
- <option>选项三</option>
8
+ <option -repeat="(o,i) in options600" -text="'选项'+o">选项</option>
9
+ <option selected>600个选项</option>
10
10
  </select>
11
+ <select -src="(o,i) in options6000">
12
+ <option -text="'选项'+o">选项</option>
13
+ <option insert selected>60000个选项</option>
14
+ </select>
@@ -1,8 +1,14 @@
1
1
  var page = div();
2
2
  page.innerHTML = selectList_test;
3
- render(page,{
4
- select
5
- })
3
+ render(page, {
4
+ select,
5
+ select2() {
6
+ var sel = document.createElement("select");
7
+ return sel;
8
+ },
9
+ options600: new Array(600).fill(0).map((_, a) => a),
10
+ options6000: new Array(60000).fill(0).map((_, a) => a)
11
+ });
6
12
  function main() {
7
13
  return page;
8
14
  }
@@ -1,7 +1,7 @@
1
- var listY = list(function (data, index) {
1
+ var listY = list(function (index) {
2
2
  var item = div();
3
3
  css(item, `width:100%;height:${Math.random() * 110 + 30}px;border:1px solid;`);
4
- text(item, data);
4
+ text(item, index);
5
5
  return item;
6
6
  }, "Y");
7
7
  onappend(listY, function () {
@@ -201,7 +201,7 @@ function ybox(generator) {
201
201
  }
202
202
  this.YScrollBoxId = +scrollId + 1;
203
203
  }
204
- if (_box.isMounted) initScrollId.call(_box);
204
+ if (isMounted(_box)) initScrollId.call(_box);
205
205
  on("append")(_box, initScrollId);
206
206
  _box.cancelFrame = function () {
207
207
  cancelAnimationFrame(smooth_timer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.12.0",
3
+ "version": "3.12.4",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {