efront 2.46.3 → 2.47.0

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,5 +1,7 @@
1
1
  "use strict";
2
2
  module.exports = encode62;
3
+ var encodeUTF8 = require("../basic/encodeUTF8");
4
+ var decodeUTF8 = require("../basic/decodeUTF8");
3
5
  var src = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
4
6
  var map = {};
5
7
  src.split("").forEach((s, i) => map[s] = i);
@@ -7,7 +9,7 @@ src.split("").forEach((s, i) => map[s] = i);
7
9
  function encode62(string) {
8
10
  string = String(string)
9
11
  string = string.length + string + "2017-08-19";
10
- var buff = Buffer.from(src);
12
+ var buff = src.split('');
11
13
  for (var cx = 0, dx = buff.length + src.length, sl = string.length, cl = buff.length; cx < dx; cx++) {
12
14
  var s1 = string.charCodeAt(cx % sl) % cl;
13
15
  var s2 = cx % cl;
@@ -15,7 +17,7 @@ function encode62(string) {
15
17
  buff[s1] = buff[s2];
16
18
  buff[s2] = btemp;
17
19
  }
18
- return buff.toString();
20
+ return buff.join('');
19
21
  };
20
22
 
21
23
 
@@ -31,13 +33,29 @@ Object.assign(encode62, {
31
33
  var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
32
34
  var time_start = parseInt((new Date() - parseInt(time_rest, 36)) / time_delta) * time_delta;
33
35
  var time_stamp = time_start + parseInt(time_rest, 36);
34
- return this.decode62(string.slice(0, string.length - time_delta.toString(36).length), time_stamp.toString(36));
36
+ string = this.decode62(string.slice(0, string.length - time_delta.toString(36).length), time_stamp.toString(36)).replace(/\.\.?/g, a => a === '.' ? "%" : ".");
37
+ return decodeURIComponent(string);
35
38
  },
36
39
  timeencode(string) {
37
40
  var { time_delta } = this;
38
- var time_stamp = +new Date();
41
+ var time_free = time_delta / 6 | 0;
42
+ var time_stamp = +new Date() - time_free;
39
43
  var time_rest = time_stamp % time_delta;
40
- return this.encode62(string, time_stamp.toString(36)) + time_rest.toString(36).padStart(time_delta.toString(36).length, '0');
44
+ var time_rest_str = time_rest.toString(36);
45
+ var time_delta_str = time_delta.toString(36);
46
+ string = encodeURIComponent(string).replace(/\./g, '..').replace(/%/g, '.');
47
+ return this.encode62(string, time_stamp.toString(36)) + repeat("0", time_delta_str.length - time_rest_str.length) + time_rest_str;
48
+ },
49
+ timeupdate(string) {
50
+ var { time_delta } = this;
51
+ var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
52
+ var time_start = parseInt((new Date() - parseInt(time_rest, 36)) / time_delta) * time_delta;
53
+ var time_stamp = time_start + parseInt(time_rest, 36);
54
+ if (time_stamp + (time_delta >> 1) > +new Date()) {
55
+ return string;
56
+ } else {
57
+ return this.timeencode(this.timedecode(string));
58
+ }
41
59
  },
42
60
  encode62(data, sign) {
43
61
  if (!sign) return data;
@@ -53,14 +71,19 @@ Object.assign(encode62, {
53
71
  });
54
72
  return result;
55
73
  },
56
- encode(data, sign) {
74
+ encodestr(data, sign) {
57
75
  if (!sign) return data;
58
- var result = Buffer.from(data);
76
+ var result = encodeUTF8(data);
59
77
  sign = Buffer.from(sign);
78
+ var delta = 0, c = 0;
60
79
  for (var cx = 0, dx = data.length; cx < dx; cx++) {
61
- result[cx] = result[cx] ^ sign[cx % sign.length];
80
+ if (result[cx] < 128) result[cx] = result[cx] ^ sign[cx % sign.length];
81
+ else if (result[cx] < 192) {
82
+ var c = c << 8 | sign[(delta += 6) / 8 % sign.length | 0];
83
+ result[cx] = result[cx] ^ (c >> 8 - delta % 8 & 0x3f);
84
+ }
62
85
  }
63
- return result;
86
+ return decodeUTF8(result);
64
87
  },
65
88
  decode(data, sign) {
66
89
  if (!sign) return data;
@@ -75,7 +98,7 @@ Object.assign(encode62, {
75
98
  return encode62(string);
76
99
  },
77
100
  genb() {
78
- return encode62(Date.now() + "" + Math.random());
101
+ return encode62(Date.now() * Math.random() + "" + Math.random().toString(36) + Math.random().toString(36).toUpperCase());
79
102
  },
80
103
  huan(x, y) {
81
104
  return x.split("").map(s => y[map[s]]).join("");
@@ -90,24 +113,10 @@ Object.assign(encode62, {
90
113
  y.split("").forEach((a, j) => y_map[a] = j);
91
114
  return z.split("").map(c => src[y_map[c]]).join("");
92
115
  },
93
- ab2c(a, b) {
94
- return this.huan(a, b);
95
- },
96
- ba2d(a, b) {
97
- return this.huan(b, a);
98
- },
99
- ca2b(c, a) {
100
- return this.yuan(c, a);
101
- },
102
- cb2a(c, b) {
103
- return this.suan(c, b);
104
- },
105
- da2b(d, a) {
106
- return this.suan(d, a);
107
- },
108
- db2a(d, b) {
109
- return this.yuan(d, b);
110
- }
111
116
  });
112
-
117
+ encode62.ab2c = encode62.ba2d = encode62.huan;
118
+ encode62.db2a = encode62.ca2b = encode62.yuan;
119
+ encode62.da2b = encode62.cb2a = encode62.suan;
120
+ encode62.decodestr = encode62.encodestr;
121
+ encode62.encode = encode62.decode;
113
122
  encode62.decode62 = encode62.encode62;
@@ -32,7 +32,8 @@ describe("encode62_test", function () {
32
32
  c = encode62.ab2c(a, b);
33
33
  });
34
34
  it("ba2d", function () {
35
- d = encode62.ba2d(a, b);
35
+ // 注意,参数顺序已变更
36
+ d = encode62.ba2d(b, a);
36
37
  });
37
38
  it("ca2b", function () {
38
39
  expect(encode62.ca2b(c, a)).to.be.eq(b);
@@ -333,25 +333,23 @@ function fixApi(api, href) {
333
333
  }
334
334
  api.base = href;
335
335
  api.path = api.url;
336
- if (/^\.([\?\#][\s\S]*)?$/.test(api.url)) {
337
- api.url = href + api.url.replace(/^\./, "");
338
- } else {
339
- api.url = href + api.url;
336
+ if (/^\.([\?\#][\s\S]*)?$/.test(api.path)) {
337
+ api.path = api.path.replace(/^\./, "");
340
338
  }
341
339
  if (extraSearch || extraHash) {
342
340
  if (/[\?#]/.test(api.url)) {
343
341
  var [, search, hash] = paramReg.exec(api.url);
344
342
  }
345
- var url = api.url.replace(paramReg, '');
343
+ var path = api.path.replace(paramReg, '');
346
344
  if (extraSearch) {
347
345
  search = search ? extraSearch + '&' + search : extraSearch;
348
346
  }
349
347
  if (extraHash) {
350
348
  hash = hash ? extraHash + '&' + hash : extraHash;
351
349
  }
352
- if (search) url += '?' + search;
353
- if (hash) url += "#" + hash;
354
- api.url = url;
350
+ if (search) path += '?' + search;
351
+ if (hash) path += "#" + hash;
352
+ api.path = path;
355
353
  }
356
354
  }
357
355
  }
@@ -404,6 +402,12 @@ function createApiMap(data) {
404
402
  }
405
403
  var _configfileurl;
406
404
  var configPormise;
405
+ function LoadingArray_then(ok, oh) {
406
+ if (this.loading_promise) this.loading_promise.then(ok, oh);
407
+ else if (this.is_errored) oh(this.error_message);
408
+ else ok();
409
+ }
410
+
407
411
  var privates = {
408
412
  loadAfterConfig(serviceId, params) {
409
413
  var promise = this.getApi(serviceId).then((api) => {
@@ -434,7 +438,8 @@ var privates = {
434
438
  },
435
439
  fromApi(api, params) {
436
440
  let url = api.url;
437
-
441
+ var base = api.base;
442
+ if (base) url = base + api.path;
438
443
  if (this.validApi(api, params)) {
439
444
  params = this.repare(api, params);
440
445
  return this.loadIgnoreConfig(api.method, url, params, api);
@@ -623,6 +628,7 @@ var data = {
623
628
  if (isObject(response)) {
624
629
  response.is_loaded = true;
625
630
  response.is_loading = false;
631
+ if (response.then === LoadingArray_then) delete response.then;
626
632
  }
627
633
  this.loading_count--;
628
634
  },
@@ -631,6 +637,7 @@ var data = {
631
637
  if (isObject(response)) {
632
638
  response.is_loaded = false;
633
639
  response.is_loading = true;
640
+ response.then = LoadingArray_then;
634
641
  }
635
642
  this.loading_count++;
636
643
  },
@@ -657,6 +664,9 @@ var data = {
657
664
  data = this.parseConfig(data);
658
665
  configPormise = Promise.resolve(data);
659
666
  },
667
+ getConfig() {
668
+ return privates.getConfigPromise();
669
+ },
660
670
  parseConfig(o) {
661
671
  if (o instanceof Promise) {
662
672
  return o.then(createApiMap);
@@ -9,15 +9,22 @@ var dispatch = "dispatchEvent" in document ? function dispatchEvent(target, even
9
9
  }
10
10
  };
11
11
  function main() {
12
- var target, event;
12
+ var target, event, value;
13
13
  for (var cx = 0, dx = arguments.length; cx < dx; cx++) {
14
14
  var arg = arguments[cx];
15
- if (isString(arg)) {
16
- event = createEvent(arg);
17
- } else if (isNode(arg) || arg === window || arg === document) {
15
+ if (isNode(arg) || arg === window || arg === document) {
18
16
  target = arg;
19
- } else {
20
- event = arg;
17
+ }
18
+ else if (!event) {
19
+ if (isString(arg)) {
20
+ event = createEvent(arg);
21
+ }
22
+ else {
23
+ event = arg;
24
+ }
25
+ }
26
+ else {
27
+ event.value = arg;
21
28
  }
22
29
  }
23
30
  if (dispatch(target || window, event)) {
@@ -23,8 +23,8 @@ var encode62 = {
23
23
  var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
24
24
  var time_start = parseInt((new Date() - parseInt(time_rest, 36)) / time_delta) * time_delta;
25
25
  var time_stamp = time_start + parseInt(time_rest, 36);
26
-
27
- return this.encode(string.slice(0, string.length - time_delta.toString(36).length), time_stamp.toString(36));
26
+ string = this.encode(string.slice(0, string.length - time_delta.toString(36).length), time_stamp.toString(36)).replace(/\.\.?/g, a => a === '.' ? "%" : ".");
27
+ return decodeURIComponent(string);
28
28
  },
29
29
  timeencode(string) {
30
30
  var { time_delta } = this;
@@ -33,6 +33,7 @@ var encode62 = {
33
33
  var time_rest = time_stamp % time_delta;
34
34
  var time_rest_str = time_rest.toString(36);
35
35
  var time_delta_str = time_delta.toString(36);
36
+ string = encodeURIComponent(string).replace(/\./g, '..').replace(/%/g, '.');
36
37
  return this.encode(string, time_stamp.toString(36)) + repeat("0", time_delta_str.length - time_rest_str.length) + time_rest_str;
37
38
  },
38
39
  timeupdate(string) {
@@ -66,12 +66,6 @@ function input(element) {
66
66
  on("keydown")(element, number);
67
67
  break;
68
68
  }
69
- if (format) {
70
- var picker = selectDate(format, input.value);
71
- on("change")(element, picker.update);
72
- select(element, picker);
73
- element.readonly = "readonly";
74
- }
75
69
  }
76
70
  return element;
77
71
  }
@@ -30,13 +30,13 @@
30
30
  display: none;
31
31
  }
32
32
 
33
- &::-webkit-calendar-picker-indicator {
34
- display: none;
35
- }
33
+ // &::-webkit-calendar-picker-indicator {
34
+ // display: none;
35
+ // }
36
36
 
37
- &::-webkit-calendar-picker-indicator:hover {
38
- display: none;
39
- }
37
+ // &::-webkit-calendar-picker-indicator:hover {
38
+ // display: none;
39
+ // }
40
40
 
41
41
  &::-webkit-clear-button {
42
42
  display: none;
@@ -37,6 +37,17 @@ var renderModel = function (field, data) {
37
37
  var constructors = {
38
38
  input,
39
39
  raw: input,
40
+ swap(e) {
41
+ var { field } = e;
42
+ e = swap(e);
43
+ if (field.options) {
44
+ e.getValue = function () {
45
+ return field.options[+this.checked].value;
46
+ };
47
+ }
48
+ return e;
49
+ },
50
+ switch: swap,
40
51
  row: textarea,
41
52
  password,
42
53
  text: textarea,
@@ -72,9 +83,26 @@ var constructors = {
72
83
  cast(elem, field);
73
84
  return elem;
74
85
  },
75
- select() {
76
- var elem = select();
77
- elem.innerHTML = `<option ng-repeat="(o,i) in field.options" ng-bind="o.name||o" _value="o.key!==undefined?o.key:o"></option>`;
86
+ select(_, t) {
87
+ if (!t) {
88
+ var elem = select();
89
+ elem.innerHTML = `<option ng-repeat="(o,i) in field.options" ng-bind="o.name||o" _value="o.key!==undefined?o.key:o"></option>`;
90
+ }
91
+ else if (t === 'a') {
92
+ var { field, data } = _;
93
+ var pad = selectList(field.options, field.multi, true);
94
+ var e = document.createElement('select');
95
+ var opt = null;
96
+ for (var o of field.options) {
97
+ if (o.key === data[field.key]) {
98
+ opt = o;
99
+ break;
100
+ }
101
+ }
102
+ e.innerHTML = `<option selected value="${opt ? opt.key : ''}">${opt ? opt.name : '请选择'}</option>`;
103
+ e.value = opt ? opt.key : '';
104
+ elem = select(e, pad);
105
+ }
78
106
  return elem;
79
107
  },
80
108
  "repeat"(_, field_type) {
@@ -117,8 +145,18 @@ var readonly_types = {
117
145
  "size"({ field }, data) {
118
146
  var f = data[field.key];
119
147
  return size(f);
120
- }
148
+ },
149
+ swap(e, data) {
150
+ var { field } = e;
151
+ var v = data[field.key];
152
+ if (field.options) {
153
+ var o = field.options[v];
154
+ if (o) return o.name;
155
+ }
156
+ return v;
157
+ },
121
158
  };
159
+ readonly_types.select = readonly_types.swap;
122
160
  function main(elem) {
123
161
  var build = function () {
124
162
  var { data, readonly, field } = elem;
@@ -205,7 +243,6 @@ function main(elem) {
205
243
  }
206
244
  };
207
245
  on("changes")(elem, function ({ changes }) {
208
-
209
246
  if (changes.data || changes.field || changes.readonly) {
210
247
  build();
211
248
  }
@@ -4,8 +4,10 @@
4
4
  onkeydown(document, function (e) {
5
5
  if (e.which === 27 && rootElements.length) {
6
6
  var r = rootElements.pop();
7
- r.blur();
8
- remove(r);
7
+ if (r) {
8
+ r.blur();
9
+ remove(r);
10
+ }
9
11
  }
10
12
  });
11
13
  var animationStyle = "opacity:0;transform:scale(1.2);transition:.1s opacity ease-out,.2s transform ease-out;";
@@ -162,24 +164,27 @@ var popup_with_mask = function (element, mask = createMask(element)) {
162
164
  return element;
163
165
  };
164
166
  var isypop = function (target) {
167
+ if (!target) return false;
165
168
  var { offsetParent, nextSibling, previousSibling } = target;
166
169
  if (
167
- nextSibling
170
+ nextSibling && nextSibling.tagName === target.tagName
168
171
  && (
169
172
  nextSibling.offsetLeft - target.offsetLeft >= target.offsetWidth / 2
170
173
  || target.offsetLeft - nextSibling.offsetLeft >= nextSibling.offsetWidth / 2
171
174
  )
172
- || previousSibling
175
+ || previousSibling && previousSibling.tagName === target.tagName
173
176
  && (
174
177
  previousSibling.offsetLeft - target.offsetLeft >= target.offsetWidth / 2
175
178
  || target.offsetLeft - previousSibling.offsetLeft >= previousSibling.offsetWidth / 2
176
179
  )
177
180
  ) return true;
178
- if (offsetParent && target.offsetTop / target.offsetHeight < .2 && offsetParent.offsetWidth / target.offsetWidth > 1.5) return true;
181
+ var padding = parseFloat(getComputedStyle(offsetParent).paddingTop) + parseFloat(getComputedStyle(offsetParent).paddingBottom);
182
+ if (offsetParent && target.offsetTop / target.offsetHeight < .2 && (offsetParent.clientWidth - padding) / target.offsetWidth > 1.5) return true;
179
183
 
180
184
  };
181
185
  var isxpop = arriswise(isypop, arguments);
182
186
  var popup_as_extra = function (element, target, style) {
187
+ element.target = target;
183
188
  if (style) {
184
189
  if (/^[vy]/i.test(style)) {
185
190
  popup_as_yextra(element, target, style);
@@ -195,9 +200,9 @@ var popup_as_extra = function (element, target, style) {
195
200
  popup_as_yextra(element, target, style);
196
201
  } else if (isxpop(target)) {
197
202
  popup_as_xextra(element, target, style);
198
- } else if (isypop(target.parentNode)) {
203
+ } else if (isypop(target.offsetParent)) {
199
204
  popup_as_yextra(element, target, style);
200
- } else if (isxpop(target.parentNode)) {
205
+ } else if (isxpop(target.offsetParent)) {
201
206
  popup_as_xextra(element, target, style);
202
207
  } else {
203
208
  if (/inline|cell/i.test(getComputedStyle(target).display)) {
@@ -266,10 +271,10 @@ var _as_yextra = function (global, innerWidth, innerHeight, element, target, poi
266
271
  }
267
272
 
268
273
  css(element, `min-width:auto;`);
269
- var aimedWidth = element.offsetWidth;
274
+ var aimedWidth = getScreenPosition(element).width;
270
275
  //如果宽度不足其附着元素的宽度
271
- if (aimedWidth < target.offsetWidth) {
272
- aimedWidth = target.offsetWidth;
276
+ if (aimedWidth < position.width) {
277
+ aimedWidth = position.width;
273
278
  }
274
279
 
275
280
  //如果宽度超出可视区,调整宽度
@@ -0,0 +1,40 @@
1
+ function prompt(msg = "请输入", check) {
2
+ var ipt = input();
3
+ var oked, ohed;
4
+ var oks = [], ohs = [];
5
+ var fire = function () {
6
+ if (!oked && !ohed) return;
7
+ if (oked) oks.forEach(o => o(ipt.value));
8
+ if (ohed) ohs.forEach(o => o(ipt.value));
9
+ oks.splice(0, oks.length);
10
+ ohs.splice(0, ohs.length);
11
+ };
12
+ var c = confirm(msg, ipt, ["确认", "取消"], function (_) {
13
+ if (oked || ohed) return;
14
+ if (_ === "确认") {
15
+ if (check && check(ipt.value) === false) return false;
16
+ oked = true;
17
+ } else {
18
+ ohed = true;
19
+ }
20
+ fire();
21
+ });
22
+ on('append')(ipt, function () {
23
+ setTimeout(function () {
24
+ ipt.focus();
25
+ });
26
+ })
27
+ on("mousedown")(c, e => e.target !== ipt && e.preventDefault() | ipt.focus());
28
+ on("keydown.enter")(c, function () {
29
+ if (check && check(ipt.value) === false) return;
30
+ oked = true;
31
+ remove(c);
32
+ fire();
33
+ });
34
+ c.then = function (ok, oh) {
35
+ oks.push(ok);
36
+ ohs.push(oh);
37
+ fire();
38
+ };
39
+ return c;
40
+ }
@@ -90,7 +90,7 @@ var initialComment = function (renders, type, expression) {
90
90
  var parseRepeat = function (expression) {
91
91
  var reg =
92
92
  // /////////////////////////////////////////// i // r ///////////////////////// o ///// a ///////////////////// t /////
93
- /^(?:let\b|var\b|const\b)?\s*(?:[\(\{\[]\s*)?(.+?)((?:\s*,\s*.+?)*)?(?:\s*[\)\}\]]\s*|\s+)(in|of)\s+(.+?)(\s+?:track\s*by\s+(.+?))?$/i;
93
+ /^(?:let\b|var\b|const\b)?\s*(?:[\(\{\[]\s*)?(.+?)((?:\s*,\s*.+?)*)?(?:\s*[\)\}\]]\s*|\s+)(in|of)\s+(.+?)(?:\s+track\s*by\s+(.+?))?$/i;
94
94
  var res = reg.exec(expression);
95
95
  if (!res) return res;
96
96
  var [_, i, k, r, s, t] = res;
@@ -125,7 +125,7 @@ var createRepeat = function (search, id = 0) {
125
125
  var [context, expression] = search;
126
126
  var res = parseRepeat(expression);
127
127
  if (!res) throw new Error(`不能识别循环表达式: ${expression} `);
128
- var { keyName, itemName, indexName, srcName } = res;
128
+ var { keyName, itemName, indexName, srcName, trackBy } = res;
129
129
  // 懒渲染
130
130
  var getter = createGetter([context, srcName]).bind(this);
131
131
  var element = this, clonedElements = [], savedValue, savedOrigin;
@@ -151,17 +151,26 @@ var createRepeat = function (search, id = 0) {
151
151
  var clonedElements1 = Object.create(null);
152
152
  var cloned = keys.map(function (key, cx) {
153
153
  var k = isArrayResult ? cx : key;
154
- var c = changes[k];
155
- if (clonedElements[k]) if (!c || !isObject(c.previous) && !isObject(c.current)) return clonedElements1[k] = clonedElements[k];
156
- var clone = element.cloneNode();
157
- clone.innerHTML = element.innerHTML;
158
- clone.renderid = id;
159
- clone.$parentScopes = $parentScopes;
160
154
  var $scope = {
161
155
  [keyName || '$key']: k,
162
156
  [itemName || '$item']: result[k],
163
157
  [indexName || '$index']: cx
164
158
  };
159
+ if (trackBy) {
160
+ k = seek($scope, trackBy);
161
+ if (clonedElements[k]) {
162
+ clonedElements[k].$scope = $scope;
163
+ return clonedElements1[k] = clonedElements[k];
164
+ }
165
+ }
166
+ else {
167
+ var c = changes[k];
168
+ if (clonedElements[k]) if (!c || !isObject(c.previous) && !isObject(c.current)) return clonedElements1[k] = clonedElements[k];
169
+ }
170
+ var clone = element.cloneNode();
171
+ clone.innerHTML = element.innerHTML;
172
+ clone.renderid = id;
173
+ clone.$parentScopes = $parentScopes;
165
174
  clone.$scope = $scope;
166
175
  clone.$parentScopes = $parentScopes;
167
176
  clone.$struct = $struct;
@@ -556,7 +565,8 @@ function getFromScopes(key, scope, parentScopes) {
556
565
  if (key in scope) {
557
566
  return scope[key];
558
567
  }
559
- if (parentScopes) for (var o of parentScopes) {
568
+ if (parentScopes) for (var cx = parentScopes.length - 1; cx >= 0; cx--) {
569
+ var o = parentScopes[cx];
560
570
  if (key in o) {
561
571
  return o[key];
562
572
  }
@@ -25,6 +25,7 @@ rootElements.pop = function (elem) {
25
25
  if (cx < 0) {
26
26
  cx = rootElements.length - 1;
27
27
  }
28
+ if (isFunction(rootElements[cx].onback) && rootElements[cx].onback() === false) return;
28
29
  return rootElements.splice(cx, 1)[0];
29
30
  };
30
31
  rootElements.mount = function (elem) {
@@ -0,0 +1,15 @@
1
+ function search(seartext, options) {
2
+ if (options instanceof Array) {
3
+ var hasFullmatch = false;
4
+ var a = options.map(o => {
5
+ if (o.name === seartext) hasFullmatch = true;
6
+ var [power, m] = mark.power(o.name, seartext);
7
+ return { power, name: m, value: o.value };
8
+ }).filter(a => a.power > 0);
9
+ a.sort(function (a, b) {
10
+ return b.power - a.power;
11
+ });
12
+ a.hasFullmatch = hasFullmatch;
13
+ return a;
14
+ }
15
+ }
@@ -2,21 +2,22 @@ var saved_list;
2
2
  var _remove = function () {
3
3
  var removing_list = saved_list;
4
4
  if (removing_list) {
5
- var target = this;
6
- setTimeout(function () {
5
+ setTimeout(function run() {
7
6
  if (removing_list !== saved_list) return remove(removing_list);
8
7
  var { activeElement } = document;
9
- if (!getTargetIn(removing_list, activeElement)) {
8
+ a: if (!getTargetIn(removing_list, activeElement)) {
9
+ var extras = [].concat(removing_list.with);
10
+ for (var e of extras) {
11
+ if (getTargetIn(e, activeElement)) break a;
12
+ }
10
13
  remove(removing_list);
11
14
  if (removing_list === saved_list) saved_list = null;
12
- } else {
13
- once('blur')(activeElement, function () {
14
- setTimeout(function () {
15
- if (document.activeElement === target) return;
16
- _remove();
17
- });
18
- });
15
+ return;
19
16
  }
17
+ once('blur')(activeElement, function () {
18
+ if (!isMounted(this)) return removing_list.target.focus();
19
+ run();
20
+ });
20
21
  });
21
22
  }
22
23
  };
@@ -48,10 +49,23 @@ function select(target, list, removeOnSelect, direction) {
48
49
  onblur(target, removeByBlur);
49
50
  if (/select/i.test(target.tagName)) {
50
51
  onmousedown(target, preventDefault);
52
+ care(target, 'add-option', function (a) {
53
+ var o = document.createElement('option');
54
+ o.value = a.value || a;
55
+ o.innerHTML = a.name || a;
56
+ this.appendChild(o);
57
+ });
58
+ care(target, 'set-options', function (options) {
59
+ this.innerHTML = options.map(o => `<option value="${o.value}">${o.name}</option>`).join("");
60
+ });
61
+ on('focus')(target, preventDefault);
51
62
  }
52
63
  var onlistchange = function () {
53
64
  if (target.multiple) {
54
65
  } else {
66
+ if (!savedOptions) {
67
+ target.innerHTML = `<option selected value="${this.value}">${this.name || this.value}</option>`
68
+ }
55
69
  target.value = this.value;
56
70
  dispatch(target, "change");
57
71
  }
@@ -114,9 +128,9 @@ function select(target, list, removeOnSelect, direction) {
114
128
  var allOptions = [].concat.apply([], target.querySelectorAll("option"));
115
129
  if (deepEqual.shallow(allOptions, savedOptions)) return;
116
130
  savedOptions = allOptions;
117
- list = selectList(allOptions, target.multiple);
131
+ list = selectList(allOptions, target.multiple, target.editable);
118
132
  if (!target.multiple) {
119
- onclick(list, _remove);
133
+ onclick(list, onlistclick);
120
134
  }
121
135
  bindEvent();
122
136
  };