@danielgindi/selectbox 1.0.50 → 1.0.51

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/dist/lib.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 1.0.50
2
+ * @danielgindi/selectbox 1.0.51
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  'use strict';
@@ -20,6 +20,251 @@ var DomEventsSink__default = /*#__PURE__*/_interopDefaultLegacy(DomEventsSink);
20
20
  var VirtualListHelper__default = /*#__PURE__*/_interopDefaultLegacy(VirtualListHelper);
21
21
  var mitt__default = /*#__PURE__*/_interopDefaultLegacy(mitt);
22
22
 
23
+ function createMetadataMethodsForProperty(metadataMap, kind, property) {
24
+ return {
25
+ getMetadata: function (key) {
26
+ if ("symbol" != typeof key) throw new TypeError("Metadata keys must be symbols, received: " + key);
27
+ var metadataForKey = metadataMap[key];
28
+ if (void 0 !== metadataForKey) if (1 === kind) {
29
+ var pub = metadataForKey.public;
30
+ if (void 0 !== pub) return pub[property];
31
+ } else if (2 === kind) {
32
+ var priv = metadataForKey.private;
33
+ if (void 0 !== priv) return priv.get(property);
34
+ } else if (Object.hasOwnProperty.call(metadataForKey, "constructor")) return metadataForKey.constructor;
35
+ },
36
+ setMetadata: function (key, value) {
37
+ if ("symbol" != typeof key) throw new TypeError("Metadata keys must be symbols, received: " + key);
38
+ var metadataForKey = metadataMap[key];
39
+
40
+ if (void 0 === metadataForKey && (metadataForKey = metadataMap[key] = {}), 1 === kind) {
41
+ var pub = metadataForKey.public;
42
+ void 0 === pub && (pub = metadataForKey.public = {}), pub[property] = value;
43
+ } else if (2 === kind) {
44
+ var priv = metadataForKey.priv;
45
+ void 0 === priv && (priv = metadataForKey.private = new Map()), priv.set(property, value);
46
+ } else metadataForKey.constructor = value;
47
+ }
48
+ };
49
+ }
50
+
51
+ function convertMetadataMapToFinal(obj, metadataMap) {
52
+ var parentMetadataMap = obj[Symbol.metadata || Symbol.for("Symbol.metadata")],
53
+ metadataKeys = Object.getOwnPropertySymbols(metadataMap);
54
+
55
+ if (0 !== metadataKeys.length) {
56
+ for (var i = 0; i < metadataKeys.length; i++) {
57
+ var key = metadataKeys[i],
58
+ metaForKey = metadataMap[key],
59
+ parentMetaForKey = parentMetadataMap ? parentMetadataMap[key] : null,
60
+ pub = metaForKey.public,
61
+ parentPub = parentMetaForKey ? parentMetaForKey.public : null;
62
+ pub && parentPub && Object.setPrototypeOf(pub, parentPub);
63
+ var priv = metaForKey.private;
64
+
65
+ if (priv) {
66
+ var privArr = Array.from(priv.values()),
67
+ parentPriv = parentMetaForKey ? parentMetaForKey.private : null;
68
+ parentPriv && (privArr = privArr.concat(parentPriv)), metaForKey.private = privArr;
69
+ }
70
+
71
+ parentMetaForKey && Object.setPrototypeOf(metaForKey, parentMetaForKey);
72
+ }
73
+
74
+ parentMetadataMap && Object.setPrototypeOf(metadataMap, parentMetadataMap), obj[Symbol.metadata || Symbol.for("Symbol.metadata")] = metadataMap;
75
+ }
76
+ }
77
+
78
+ function createAddInitializerMethod(initializers) {
79
+ return function (initializer) {
80
+ assertValidInitializer(initializer), initializers.push(initializer);
81
+ };
82
+ }
83
+
84
+ function memberDecCtx(base, name, desc, metadataMap, initializers, kind, isStatic, isPrivate) {
85
+ var kindStr;
86
+
87
+ switch (kind) {
88
+ case 1:
89
+ kindStr = "accessor";
90
+ break;
91
+
92
+ case 2:
93
+ kindStr = "method";
94
+ break;
95
+
96
+ case 3:
97
+ kindStr = "getter";
98
+ break;
99
+
100
+ case 4:
101
+ kindStr = "setter";
102
+ break;
103
+
104
+ default:
105
+ kindStr = "field";
106
+ }
107
+
108
+ var metadataKind,
109
+ metadataName,
110
+ ctx = {
111
+ kind: kindStr,
112
+ name: isPrivate ? "#" + name : name,
113
+ isStatic: isStatic,
114
+ isPrivate: isPrivate
115
+ };
116
+
117
+ if (0 !== kind && (ctx.addInitializer = createAddInitializerMethod(initializers)), isPrivate) {
118
+ metadataKind = 2, metadataName = Symbol(name);
119
+ var access = {};
120
+ 0 === kind ? (access.get = desc.get, access.set = desc.set) : 2 === kind ? access.get = function () {
121
+ return desc.value;
122
+ } : (1 !== kind && 3 !== kind || (access.get = function () {
123
+ return desc.get.call(this);
124
+ }), 1 !== kind && 4 !== kind || (access.set = function (v) {
125
+ desc.set.call(this, v);
126
+ })), ctx.access = access;
127
+ } else metadataKind = 1, metadataName = name;
128
+
129
+ return Object.assign(ctx, createMetadataMethodsForProperty(metadataMap, metadataKind, metadataName));
130
+ }
131
+
132
+ function assertValidInitializer(initializer) {
133
+ if ("function" != typeof initializer) throw new Error("initializers must be functions");
134
+ }
135
+
136
+ function assertValidReturnValue(kind, value) {
137
+ var type = typeof value;
138
+
139
+ if (1 === kind) {
140
+ if ("object" !== type || null === value) throw new Error("accessor decorators must return an object with get, set, or initializer properties or void 0");
141
+ } else if ("function" !== type) throw 0 === kind ? new Error("field decorators must return a initializer function or void 0") : new Error("method decorators must return a function or void 0");
142
+ }
143
+
144
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers) {
145
+ var desc,
146
+ initializer,
147
+ value,
148
+ decs = decInfo[0];
149
+ isPrivate ? desc = 0 === kind || 1 === kind ? {
150
+ get: decInfo[3],
151
+ set: decInfo[4]
152
+ } : 3 === kind ? {
153
+ get: decInfo[3]
154
+ } : 4 === kind ? {
155
+ set: decInfo[3]
156
+ } : {
157
+ value: decInfo[3]
158
+ } : 0 !== kind && (desc = Object.getOwnPropertyDescriptor(base, name)), 1 === kind ? value = {
159
+ get: desc.get,
160
+ set: desc.set
161
+ } : 2 === kind ? value = desc.value : 3 === kind ? value = desc.get : 4 === kind && (value = desc.set);
162
+ var newValue,
163
+ get,
164
+ set,
165
+ ctx = memberDecCtx(base, name, desc, metadataMap, initializers, kind, isStatic, isPrivate);
166
+ if ("function" == typeof decs) void 0 !== (newValue = decs(value, ctx)) && (assertValidReturnValue(kind, newValue), 0 === kind ? initializer = newValue : 1 === kind ? (initializer = newValue.initializer, get = newValue.get || value.get, set = newValue.set || value.set, value = {
167
+ get: get,
168
+ set: set
169
+ }) : value = newValue);else for (var i = decs.length - 1; i >= 0; i--) {
170
+ var newInit;
171
+ if (void 0 !== (newValue = (0, decs[i])(value, ctx))) assertValidReturnValue(kind, newValue), 0 === kind ? newInit = newValue : 1 === kind ? (newInit = newValue.initializer, get = newValue.get || value.get, set = newValue.set || value.set, value = {
172
+ get: get,
173
+ set: set
174
+ }) : value = newValue, void 0 !== newInit && (void 0 === initializer ? initializer = newInit : "function" == typeof initializer ? initializer = [initializer, newInit] : initializer.push(newInit));
175
+ }
176
+
177
+ if (0 === kind || 1 === kind) {
178
+ if (void 0 === initializer) initializer = function (instance, init) {
179
+ return init;
180
+ };else if ("function" != typeof initializer) {
181
+ var ownInitializers = initializer;
182
+
183
+ initializer = function (instance, init) {
184
+ for (var value = init, i = 0; i < ownInitializers.length; i++) value = ownInitializers[i].call(instance, value);
185
+
186
+ return value;
187
+ };
188
+ } else {
189
+ var originalInitializer = initializer;
190
+
191
+ initializer = function (instance, init) {
192
+ return originalInitializer.call(instance, init);
193
+ };
194
+ }
195
+ ret.push(initializer);
196
+ }
197
+
198
+ 0 !== kind && (1 === kind ? (desc.get = value.get, desc.set = value.set) : 2 === kind ? desc.value = value : 3 === kind ? desc.get = value : 4 === kind && (desc.set = value), isPrivate ? 1 === kind ? (ret.push(function (instance, args) {
199
+ return value.get.call(instance, args);
200
+ }), ret.push(function (instance, args) {
201
+ return value.set.call(instance, args);
202
+ })) : 2 === kind ? ret.push(value) : ret.push(function (instance, args) {
203
+ return value.call(instance, args);
204
+ }) : Object.defineProperty(base, name, desc));
205
+ }
206
+
207
+ function applyMemberDecs(ret, Class, protoMetadataMap, staticMetadataMap, decInfos) {
208
+ for (var protoInitializers = [], staticInitializers = [], existingProtoNonFields = new Map(), existingStaticNonFields = new Map(), i = 0; i < decInfos.length; i++) {
209
+ var decInfo = decInfos[i];
210
+
211
+ if (Array.isArray(decInfo)) {
212
+ var base,
213
+ metadataMap,
214
+ initializers,
215
+ kind = decInfo[1],
216
+ name = decInfo[2],
217
+ isPrivate = decInfo.length > 3,
218
+ isStatic = kind >= 5;
219
+
220
+ if (isStatic ? (base = Class, metadataMap = staticMetadataMap, kind -= 5, initializers = staticInitializers) : (base = Class.prototype, metadataMap = protoMetadataMap, initializers = protoInitializers), 0 !== kind && !isPrivate) {
221
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields,
222
+ existingKind = existingNonFields.get(name) || 0;
223
+ if (!0 === existingKind || 3 === existingKind && 4 !== kind || 4 === existingKind && 3 !== kind) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
224
+ !existingKind && kind > 2 ? existingNonFields.set(name, kind) : existingNonFields.set(name, !0);
225
+ }
226
+
227
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers);
228
+ }
229
+ }
230
+
231
+ protoInitializers.length > 0 && pushInitializers(ret, protoInitializers), staticInitializers.length > 0 && pushInitializers(ret, staticInitializers);
232
+ }
233
+
234
+ function pushInitializers(ret, initializers) {
235
+ initializers.length > 0 ? (initializers = initializers.slice(), ret.push(function (instance) {
236
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance, instance);
237
+
238
+ return instance;
239
+ })) : ret.push(function (instance) {
240
+ return instance;
241
+ });
242
+ }
243
+
244
+ function applyClassDecs(ret, targetClass, metadataMap, classDecs) {
245
+ for (var initializers = [], newClass = targetClass, name = targetClass.name, ctx = Object.assign({
246
+ kind: "class",
247
+ name: name,
248
+ addInitializer: createAddInitializerMethod(initializers)
249
+ }, createMetadataMethodsForProperty(metadataMap, 0, name)), i = classDecs.length - 1; i >= 0; i--) newClass = classDecs[i](newClass, ctx) || newClass;
250
+
251
+ ret.push(newClass), initializers.length > 0 ? ret.push(function () {
252
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(newClass, newClass);
253
+ }) : ret.push(function () {});
254
+ }
255
+
256
+ function _applyDecs(targetClass, memberDecs, classDecs) {
257
+ var ret = [],
258
+ staticMetadataMap = {};
259
+
260
+ if (memberDecs) {
261
+ var protoMetadataMap = {};
262
+ applyMemberDecs(ret, targetClass, protoMetadataMap, staticMetadataMap, memberDecs), convertMetadataMapToFinal(targetClass.prototype, protoMetadataMap);
263
+ }
264
+
265
+ return classDecs && applyClassDecs(ret, targetClass, staticMetadataMap, classDecs), convertMetadataMapToFinal(targetClass, staticMetadataMap), ret;
266
+ }
267
+
23
268
  function _asyncIterator(iterable) {
24
269
  var method,
25
270
  async,
@@ -1684,6 +1929,10 @@ function _classPrivateMethodSet() {
1684
1929
  throw new TypeError("attempted to reassign private method");
1685
1930
  }
1686
1931
 
1932
+ function _identity(x) {
1933
+ return x;
1934
+ }
1935
+
1687
1936
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1688
1937
 
1689
1938
  function getDefaultExportFromCjs (x) {
@@ -2032,10 +2281,10 @@ var store$2 = sharedStore;
2032
2281
  (shared$6.exports = function (key, value) {
2033
2282
  return store$2[key] || (store$2[key] = value !== undefined ? value : {});
2034
2283
  })('versions', []).push({
2035
- version: '3.20.3',
2284
+ version: '3.21.1',
2036
2285
  mode: IS_PURE$5 ? 'pure' : 'global',
2037
2286
  copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
2038
- license: 'https://github.com/zloirock/core-js/blob/v3.20.3/LICENSE',
2287
+ license: 'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',
2039
2288
  source: 'https://github.com/zloirock/core-js'
2040
2289
  });
2041
2290
 
@@ -4247,8 +4496,8 @@ var fails$e = fails$v;
4247
4496
  var arrayMethodIsStrict$4 = function (METHOD_NAME, argument) {
4248
4497
  var method = [][METHOD_NAME];
4249
4498
  return !!method && fails$e(function () {
4250
- // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
4251
- method.call(null, argument || function () { throw 1; }, 1);
4499
+ // eslint-disable-next-line no-useless-call -- required for testing
4500
+ method.call(null, argument || function () { return 1; }, 1);
4252
4501
  });
4253
4502
  };
4254
4503
 
@@ -9924,27 +10173,11 @@ var SelectBox = /*#__PURE__*/function () {
9924
10173
  * @returns {SelectBox}
9925
10174
  */ }, { key: "clear", value:
9926
10175
  function clear() {
9927
- var p = this._p;
9928
-
9929
- var clearEvt = { cancel: false };
9930
- this._trigger('clear:before', clearEvt);
9931
- if (clearEvt.cancel)
10176
+ if (!this._performClearWithEvent(true))
9932
10177
  return this;
9933
10178
 
9934
- p.selectedItems = [];
9935
- p.selectedValues = [];
9936
- p.selectionChanged = true;
9937
- p.resortBySelectionNeeded = true;
9938
-
9939
- this._trigger('clear');
9940
-
9941
10179
  if (this[DestroyedSymbol]) return this; // destroyed by event handler
9942
10180
 
9943
- this._updateListItems();
9944
-
9945
- this._setInputText('');
9946
- this._scheduleSync('full');
9947
-
9948
10181
  return this;
9949
10182
  }
9950
10183
 
@@ -10608,19 +10841,11 @@ var SelectBox = /*#__PURE__*/function () {
10608
10841
  var _item = event.item;
10609
10842
  var _value = event.value;
10610
10843
 
10611
- var selectEvt = { value: _value, item: _item, cancel: false };
10612
- _this5._trigger('select:before', selectEvt);
10613
-
10614
- if (selectEvt.cancel)
10844
+ if (!_this5._performSelectWithEvent(_item, _value))
10615
10845
  return;
10616
10846
 
10617
10847
  if (_this5[DestroyedSymbol]) return; // destroyed by event handler
10618
10848
 
10619
- _this5._setSelectedItems([_item]);
10620
- _this5._trigger('select', { value: _value, item: _item });
10621
-
10622
- if (_this5[DestroyedSymbol]) return; // destroyed by event handler
10623
-
10624
10849
  _this5.closeList();
10625
10850
 
10626
10851
  if (p.blurOnSingleSelection === 'touch' && hasTouchCapability ||
@@ -10884,6 +11109,40 @@ var SelectBox = /*#__PURE__*/function () {
10884
11109
  }).
10885
11110
  add(p.el, 'touchcancel.dropdown_touchextra', onTouchCancel);
10886
11111
  });
11112
+ } }, { key: "_performSelectWithEvent", value:
11113
+
11114
+ function _performSelectWithEvent(item, value) {
11115
+ var cancellable = { value: value, item: item, cancel: false };
11116
+ this._trigger('select:before', cancellable);
11117
+
11118
+ if (cancellable.cancel)
11119
+ return false;
11120
+
11121
+ if (this[DestroyedSymbol]) return false; // destroyed by event handler
11122
+
11123
+ this._setSelectedItems([item]);
11124
+ this._trigger('select', { value: value, item: item });
11125
+
11126
+ return true;
11127
+ } }, { key: "_performClearWithEvent", value:
11128
+
11129
+ function _performClearWithEvent() {var clearInput = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11130
+ var cancellable = { cancel: false };
11131
+ this._trigger('clear:before', cancellable);
11132
+
11133
+ if (cancellable.cancel)
11134
+ return false;
11135
+
11136
+ if (this[DestroyedSymbol]) return false; // destroyed by event handler
11137
+
11138
+ this._setSelectedItems([]);
11139
+
11140
+ if (clearInput)
11141
+ this._setInputText('');
11142
+
11143
+ this._trigger('clear');
11144
+
11145
+ return true;
10887
11146
  } }, { key: "_movePrev", value:
10888
11147
 
10889
11148
  function _movePrev() {var _p$filteredItems;
@@ -10899,7 +11158,13 @@ var SelectBox = /*#__PURE__*/function () {
10899
11158
  var nextIndex = selectedItems.length > 0 ? items.indexOf(selectedItems[0]) - 1 : items.length - 1;
10900
11159
  if (nextIndex === -1 && !p.clearable)
10901
11160
  nextIndex = items.length - 1;
10902
- this.setSelectedItems(nextIndex === -1 ? [] : [items[nextIndex]]);
11161
+
11162
+ var item = nextIndex === -1 ? null : items[nextIndex];
11163
+ if (item) {
11164
+ this._performSelectWithEvent(item, item[p.valueProp]);
11165
+ } else {
11166
+ this._performClearWithEvent();
11167
+ }
10903
11168
  }
10904
11169
  } }, { key: "_moveNext", value:
10905
11170
 
@@ -10916,7 +11181,13 @@ var SelectBox = /*#__PURE__*/function () {
10916
11181
  var nextIndex = selectedItems.length > 0 ? items.indexOf(selectedItems[0]) + 1 : 0;
10917
11182
  if (nextIndex === items.length)
10918
11183
  nextIndex = p.clearable ? -1 : 0;
10919
- this.setSelectedItems(nextIndex === -1 ? [] : [items[nextIndex]]);
11184
+
11185
+ var item = nextIndex === -1 ? null : items[nextIndex];
11186
+ if (item) {
11187
+ this._performSelectWithEvent(item, item[p.valueProp]);
11188
+ } else {
11189
+ this._performClearWithEvent();
11190
+ }
10920
11191
  }
10921
11192
  }
10922
11193