simp-select 1.0.0 → 1.0.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.
@@ -1,1588 +1 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory();
4
- else if(typeof define === 'function' && define.amd)
5
- define("SimpleSelect", [], factory);
6
- else if(typeof exports === 'object')
7
- exports["SimpleSelect"] = factory();
8
- else
9
- root["SimpleSelect"] = factory();
10
- })(typeof self === 'undefined' ? this : self, function() {
11
- return /******/ (function() { // webpackBootstrap
12
- /******/ "use strict";
13
- /******/ var __webpack_modules__ = ({
14
-
15
- /***/ 737:
16
- /***/ (function(__unused_webpack_module, exports) {
17
-
18
-
19
-
20
- Object.defineProperty(exports, "__esModule", ({
21
- value: true
22
- }));
23
- exports.initClass = exports.nameMark = exports.nameSelect = exports.simpleSelectionOptions = exports.simpleSelectLocale = void 0;
24
- exports.simpleSelectLocale = {
25
- noSearch: 'No matches for',
26
- searchText: 'Search',
27
- title: 'Select',
28
- selected: 'Selected:',
29
- all: 'all',
30
- ok: 'Ok',
31
- cansel: 'Cansel',
32
- selectAll: 'Select all',
33
- resetAll: 'Reset all'
34
- };
35
- exports.simpleSelectionOptions = {
36
- isSearch: true,
37
- isSearchInDropdown: false,
38
- countShowSelected: 2,
39
- isConfirmInMulti: false,
40
- isConfirmInMultiOkClickOutside: false,
41
- nativeOnDevice: ['Android', 'BlackBerry', 'iPhone', 'iPad', 'iPod', 'Opera Mini', 'IEMobile', 'Silk'],
42
- locale: exports.simpleSelectLocale,
43
- sepChars: ',',
44
- isUp: false,
45
- floatWidth: 767,
46
- isCloneClass: true,
47
- selectAll: false,
48
- selectAllAfterClose: true,
49
- resetAll: false,
50
- resetAllAfterClose: true
51
- };
52
- exports.nameSelect = 'SimSel';
53
- var markPrefix = 'simple-select-';
54
- exports.nameMark = "".concat(markPrefix, "init");
55
- exports.initClass = 'SimpleSel';
56
-
57
- /***/ }),
58
-
59
- /***/ 874:
60
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
61
-
62
-
63
-
64
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
65
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
66
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
67
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
68
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
69
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
70
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
71
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
72
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
73
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
74
- function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
75
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
76
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
77
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
78
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
79
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
80
- Object.defineProperty(exports, "__esModule", ({
81
- value: true
82
- }));
83
- exports.SimpleSelectItem = void 0;
84
- var simpleSelection_utils_1 = __webpack_require__(679);
85
- var simpleSelectItemDOM_1 = __webpack_require__(844);
86
- var SimpleSelectItem = /*#__PURE__*/function (_simpleSelectItemDOM_) {
87
- _inherits(SimpleSelectItem, _simpleSelectItemDOM_);
88
- var _super = _createSuper(SimpleSelectItem);
89
- function SimpleSelectItem(select, options, localOptions) {
90
- var _thisSuper, _this;
91
- _classCallCheck(this, SimpleSelectItem);
92
- _this = _super.call(this, select, options, localOptions);
93
- _defineProperty(_assertThisInitialized(_this), "closeOutsideHandler", void 0);
94
- // not native
95
- _defineProperty(_assertThisInitialized(_this), "closeEscHandler", void 0);
96
- // not native
97
- _defineProperty(_assertThisInitialized(_this), "changeListener", void 0);
98
- // not native
99
- _defineProperty(_assertThisInitialized(_this), "searchHandler", void 0);
100
- // not native
101
- _defineProperty(_assertThisInitialized(_this), "clickToggleOpen", void 0);
102
- // not native
103
- _defineProperty(_assertThisInitialized(_this), "triggerSetup", void 0);
104
- // not native
105
- _defineProperty(_assertThisInitialized(_this), "confirmOkHandler", void 0);
106
- // not native
107
- _defineProperty(_assertThisInitialized(_this), "confirmNoHandler", void 0);
108
- // not native
109
- _defineProperty(_assertThisInitialized(_this), "selectAllHandler", void 0);
110
- // not native
111
- _defineProperty(_assertThisInitialized(_this), "resetAllHandler", void 0);
112
- // not native
113
- _defineProperty(_assertThisInitialized(_this), "closeHandler", void 0);
114
- // not native
115
- _defineProperty(_assertThisInitialized(_this), "handleResize", void 0);
116
- // not native
117
- _defineProperty(_assertThisInitialized(_this), "mql", null);
118
- _defineProperty(_assertThisInitialized(_this), "countOpen", 0);
119
- _defineProperty(_assertThisInitialized(_this), "multiDebounceTime", 0);
120
- _defineProperty(_assertThisInitialized(_this), "timeoutDebounceId", null);
121
- if (!select) {
122
- throw Error('Select is required');
123
- }
124
- _this.init();
125
- _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(SimpleSelectItem.prototype)), "initDom", _thisSuper).call(_thisSuper);
126
- _this.initAfterDom();
127
- return _this;
128
- }
129
- _createClass(SimpleSelectItem, [{
130
- key: "init",
131
- value: function init() {
132
- var _this2 = this;
133
- this.changeListener = this.changeListenerInit.bind(this);
134
- this.$select.addEventListener('change', this.changeListener);
135
- this.searchHandler = this.searchHandlerInit.bind(this);
136
- this.closeOutsideHandler = this.closeOutsideHandlerInit.bind(this);
137
- this.closeEscHandler = this.closeEscHandlerInit.bind(this);
138
- this.clickToggleOpen = this.clickToggleOpenInit.bind(this);
139
- this.triggerSetup = this.triggerSetupInit.bind(this);
140
- this.confirmOkHandler = this.confirmOkHandlerInit.bind(this);
141
- this.confirmNoHandler = this.confirmNoHandlerInit.bind(this);
142
- this.selectAllHandler = this.selectAllHandlerInit.bind(this);
143
- this.resetAllHandler = this.resetAllHandlerInit.bind(this);
144
- this.closeHandler = this.closeHandlerInit.bind(this);
145
- this.handleResize = this.handleResizeInit.bind(this);
146
- if (this.options.callbackInitialization) {
147
- this.options.callbackInitialization(this);
148
- }
149
- if (!this.isNative && this.options.floatWidth) {
150
- this.mql = window.matchMedia("(max-width: ".concat(this.options.floatWidth, "px)"));
151
- if (this.mql) {
152
- // @ts-ignore
153
- this.mql.onchange = this.handleResize;
154
- this.handleResizeInit(this.mql);
155
- }
156
- }
157
- this.state.subscribe('isOpen', function (val) {
158
- _this2.toggleOpenHandler();
159
- if (!val && _this2.options.isConfirmInMulti) {
160
- _this2.createList();
161
- }
162
- if (val) {
163
- if (_this2.elemInputSearch) {
164
- _this2.elemInputSearch.value = '';
165
- }
166
- }
167
- // if (!val) {
168
- // if (this.options.isConfirmInMulti) {
169
- // this.triggerInit();
170
- // }
171
- // }
172
- });
173
-
174
- this.state.subscribe('filterStr', function (val) {
175
- _this2.filterList(val);
176
- });
177
- if (!this.isNative) {
178
- this.elemTopBody.addEventListener('click', this.clickToggleOpen);
179
- this.elemTopBody.addEventListener('keyup', this.clickToggleOpen);
180
- }
181
- }
182
- }, {
183
- key: "handleResizeInit",
184
- value: function handleResizeInit(e) {
185
- if (!e) {
186
- return;
187
- }
188
- if (e.matches) {
189
- this.state.setState('isFloat', true);
190
- } else {
191
- this.state.setState('isFloat', false);
192
- }
193
- }
194
- }, {
195
- key: "initAfterDom",
196
- value: function initAfterDom() {
197
- if (this.confirmOk) {
198
- this.confirmOk.addEventListener('click', this.confirmOkHandler);
199
- }
200
- if (this.confirmNo) {
201
- this.confirmNo.addEventListener('click', this.confirmNoHandler);
202
- }
203
- if (this.options.callbackInitialized) {
204
- this.options.callbackInitialized(this);
205
- }
206
- if (this.isMulti && !this.options.isConfirmInMulti) {
207
- if ((0, simpleSelection_utils_1.toCamelCase)('simple-debounce-time') in this.$select.dataset) {
208
- this.multiDebounceTime = Number(this.$select.dataset[(0, simpleSelection_utils_1.toCamelCase)('simple-debounce-time')]);
209
- } else if (this.options.debounceTime || this.options.debounceTime === 0) {
210
- this.multiDebounceTime = this.options.debounceTime;
211
- }
212
- }
213
- if (this.multiDebounceTime) {
214
- this.multiDebounceChange = this.debounce(this.multiDebounceChange.bind(this), this.multiDebounceTime);
215
- }
216
- if (this.elemSelectAll) {
217
- this.elemSelectAll.addEventListener('click', this.selectAllHandler);
218
- }
219
- if (this.elemResetAll) {
220
- this.elemResetAll.addEventListener('click', this.resetAllHandler);
221
- }
222
- if (this.elemDropDownClose) {
223
- this.elemDropDownClose.addEventListener('click', this.closeHandler);
224
- }
225
- }
226
- }, {
227
- key: "debounce",
228
- value: function debounce(func, delay) {
229
- var _this3 = this;
230
- return function () {
231
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
232
- args[_key] = arguments[_key];
233
- }
234
- if (_this3.timeoutDebounceId) {
235
- clearTimeout(_this3.timeoutDebounceId);
236
- }
237
- _this3.timeoutDebounceId = setTimeout(function () {
238
- func.apply(void 0, args);
239
- _this3.timeoutDebounceId = null;
240
- }, delay);
241
- };
242
- }
243
- }, {
244
- key: "confirmOkHandlerInit",
245
- value: function confirmOkHandlerInit(e) {
246
- e.preventDefault();
247
- this.confirmOkBuild();
248
- }
249
- }, {
250
- key: "confirmOkBuild",
251
- value: function confirmOkBuild() {
252
- var options = this.$select.options;
253
- if (!this.elemListBody) {
254
- return;
255
- }
256
- var liItems = this.elemListBody.querySelectorAll('[data-sel-position]');
257
- liItems.forEach(function (item) {
258
- var pos = parseInt(item.dataset[(0, simpleSelection_utils_1.toCamelCase)('sel-position')], 10);
259
- if (!pos && pos !== 0) {
260
- return;
261
- }
262
- var option = options[pos];
263
- if (!option || option.disabled) {
264
- return;
265
- }
266
- option.selected = item.dataset[(0, simpleSelection_utils_1.toCamelCase)('sel-opt-checked')] === 'true';
267
- });
268
- this.state.setState('isOpen', false);
269
- this.triggerInit();
270
- }
271
- }, {
272
- key: "confirmNoHandlerInit",
273
- value: function confirmNoHandlerInit(e) {
274
- e.preventDefault();
275
- this.state.setState('isOpen', false);
276
- }
277
- }, {
278
- key: "closeHandlerInit",
279
- value: function closeHandlerInit(e) {
280
- e.preventDefault();
281
- this.state.setState('isOpen', false);
282
- }
283
- }, {
284
- key: "selectAllHandlerInit",
285
- value: function selectAllHandlerInit(e) {
286
- e.preventDefault();
287
- Array.from(this.$select.options).forEach(function (option) {
288
- if (option.disabled) {
289
- return;
290
- }
291
- option.selected = true;
292
- });
293
- this.createList();
294
- if (this.options.selectAllAfterClose) {
295
- this.state.setState('isOpen', false);
296
- }
297
- this.triggerInit();
298
- }
299
- }, {
300
- key: "resetAllHandlerInit",
301
- value: function resetAllHandlerInit(e) {
302
- e.preventDefault();
303
- Array.from(this.$select.options).forEach(function (option) {
304
- if (option.disabled) {
305
- return;
306
- }
307
- option.selected = false;
308
- });
309
- this.createList();
310
- if (this.options.selectAllAfterClose) {
311
- this.state.setState('isOpen', false);
312
- }
313
- this.triggerInit();
314
- }
315
- // click for LI
316
- }, {
317
- key: "triggerSetupInit",
318
- value: function triggerSetupInit(e) {
319
- if (e.button !== 0) return;
320
- var target = e.target;
321
- var targetLi = target.closest('li');
322
- if (targetLi) {
323
- this.changeClickItem(targetLi);
324
- }
325
- }
326
- }, {
327
- key: "changeClickItem",
328
- value: function changeClickItem(item) {
329
- if (item) {
330
- var pos = Number(item.dataset[(0, simpleSelection_utils_1.toCamelCase)('sel-position')]) || 0;
331
- var option = this.$select.options[pos];
332
- if (option && !option.disabled) {
333
- if (this.isMulti) {
334
- if (this.options.isConfirmInMulti || this.isFloatWidth) {
335
- if (item.dataset[(0, simpleSelection_utils_1.toCamelCase)('sel-opt-checked')] === 'true') {
336
- item.dataset[(0, simpleSelection_utils_1.toCamelCase)('sel-opt-checked')] = 'false';
337
- item.classList.remove('SimpleSel__list_item--checked');
338
- } else {
339
- item.dataset[(0, simpleSelection_utils_1.toCamelCase)('sel-opt-checked')] = 'true';
340
- item.classList.add('SimpleSel__list_item--checked');
341
- }
342
- } else {
343
- option.selected = !option.selected;
344
- this.createList();
345
- this.multiDebounceChange();
346
- }
347
- } else {
348
- option.selected = !option.selected;
349
- this.createList();
350
- this.state.setState('isOpen', false);
351
- this.triggerInit();
352
- }
353
- }
354
- }
355
- }
356
- }, {
357
- key: "multiDebounceChange",
358
- value: function multiDebounceChange() {
359
- // can be overridden for multiselect - debounce
360
- this.triggerInit();
361
- }
362
- }, {
363
- key: "triggerInit",
364
- value: function triggerInit() {
365
- (0, simpleSelection_utils_1.triggerInputEvent)(this.$select);
366
- }
367
- }, {
368
- key: "clickToggleOpenInit",
369
- value: function clickToggleOpenInit(e) {
370
- e.preventDefault();
371
- if (this.isDisabled) {
372
- return;
373
- }
374
- if (e.type === 'click') {
375
- this.state.setState('isOpen', !this.state.getState('isOpen'));
376
- return;
377
- }
378
- if (e instanceof KeyboardEvent) {
379
- if (e.key === 'Enter') {
380
- this.state.setState('isOpen', !this.state.getState('isOpen'));
381
- }
382
- }
383
- }
384
- }, {
385
- key: "closeOutsideHandlerInit",
386
- value: function closeOutsideHandlerInit(e) {
387
- var target = e.target;
388
- if (!target) {
389
- return;
390
- }
391
- if (!this.elemWrap.contains(target)) {
392
- if (this.options.isConfirmInMulti && this.options.isConfirmInMultiOkClickOutside) {
393
- this.confirmOkBuild();
394
- }
395
- this.state.setState('isOpen', false);
396
- }
397
- }
398
- }, {
399
- key: "closeEscHandlerInit",
400
- value: function closeEscHandlerInit(e) {
401
- if (e.code === 'Escape') {
402
- e.preventDefault();
403
- e.stopPropagation();
404
- this.state.setState('isOpen', false);
405
- }
406
- if (e.code === 'Tab') {
407
- e.preventDefault();
408
- e.stopPropagation();
409
- if (!this.elemWrap.contains(e.target)) {
410
- this.state.setState('isOpen', false);
411
- }
412
- }
413
- if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
414
- e.preventDefault();
415
- e.stopPropagation();
416
- this.keyBoardChangeChecked(e.key === 'ArrowDown');
417
- }
418
- if (e.key === 'Enter') {
419
- var target = e.target;
420
- if (target && (0, simpleSelection_utils_1.toCamelCase)('sel-opt-item') in target.dataset) {
421
- e.preventDefault();
422
- e.stopPropagation();
423
- this.changeClickItem(target);
424
- }
425
- }
426
- }
427
- }, {
428
- key: "keyBoardChangeChecked",
429
- value: function keyBoardChangeChecked(isDown) {
430
- // eslint-disable-next-line max-len
431
- var liItems = this.elemListBody.querySelectorAll('[data-sel-position]:not([data-sel-opt-disabled="true"])');
432
- if (!liItems.length) {
433
- return;
434
- }
435
- var indCurrent = 0;
436
- var firstOption;
437
- liItems.forEach(function (el, i) {
438
- if (document.activeElement === el) {
439
- indCurrent = i;
440
- firstOption = el;
441
- }
442
- el.removeAttribute('tabindex');
443
- });
444
- if (!firstOption) {
445
- firstOption = isDown ? liItems[0] : liItems[liItems.length - 1];
446
- } else if (isDown) {
447
- firstOption = liItems[indCurrent + 1] || liItems[0];
448
- } else {
449
- firstOption = liItems[indCurrent - 1] || liItems[liItems.length - 1];
450
- }
451
- firstOption.tabIndex = 0;
452
- firstOption.focus();
453
- }
454
- }, {
455
- key: "searchHandlerInit",
456
- value: function searchHandlerInit(e) {
457
- var target = e.target;
458
- if (!target) {
459
- return;
460
- }
461
- var value = target.value;
462
- this.state.setState('filterStr', value);
463
- }
464
- }, {
465
- key: "toggleOpenHandler",
466
- value: function toggleOpenHandler() {
467
- var isOpen = this.state.getState('isOpen');
468
- if (isOpen) {
469
- this.elemWrap.classList.add('SimpleSel--open');
470
- document.addEventListener('click', this.closeOutsideHandler);
471
- document.addEventListener('keyup', this.closeEscHandler);
472
- if (this.elemInputSearch) {
473
- this.elemInputSearch.focus();
474
- // this.elemInputSearch.tabIndex = 0;
475
- }
476
-
477
- if (this.options.callbackOpen) {
478
- this.options.callbackOpen(this);
479
- }
480
- this.countOpen++;
481
- } else {
482
- this.state.setState('filterList', '');
483
- this.elemWrap.classList.remove('SimpleSel--open');
484
- document.removeEventListener('click', this.closeOutsideHandler);
485
- document.removeEventListener('keyup', this.closeEscHandler);
486
- if (this.timeoutDebounceId) {
487
- clearTimeout(this.timeoutDebounceId);
488
- this.triggerInit();
489
- }
490
- if (this.options.callbackClose && this.countOpen > 0) {
491
- this.options.callbackClose(this);
492
- }
493
- }
494
- // this.bodyElement.classList.toggle('SimpleSel--open', this.state.getState('isOpen'))
495
- }
496
- }, {
497
- key: "changeListenerInit",
498
- value: function changeListenerInit(e) {
499
- if (this.options.callbackChangeSelect) {
500
- this.options.callbackChangeSelect(e, this);
501
- }
502
- this.createList(true);
503
- // alert(e.target.value);
504
- }
505
- }, {
506
- key: "getSelect",
507
- value: function getSelect() {
508
- return this.$select;
509
- }
510
- }, {
511
- key: "handlerChangeChecked",
512
- value: function handlerChangeChecked() {
513
- if (this.elemListBody) {
514
- this.elemListBody.addEventListener('mouseup', this.triggerSetup);
515
- // this.elemListBody.addEventListener('mouseup', (e) => {})
516
- }
517
- }
518
- }, {
519
- key: "createList",
520
- value: function createList() {
521
- var isCompare = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
522
- var newItems = [];
523
- var group = this.$select.querySelectorAll('optgroup');
524
- if (group && group.length) {
525
- group.forEach(function (item, ind) {
526
- newItems.push((0, simpleSelection_utils_1.getCreateListItem)(item, (ind + 1).toString(), true));
527
- });
528
- } else {
529
- newItems.push((0, simpleSelection_utils_1.getCreateListItem)(this.$select, '1', false));
530
- }
531
- if (isCompare) {
532
- var old = this.state.getState('items');
533
- if (!(0, simpleSelection_utils_1.compareObj)(old, newItems)) {
534
- this.state.setState('items', newItems);
535
- }
536
- } else {
537
- this.state.setState('items', newItems);
538
- }
539
- }
540
- }, {
541
- key: "filterList",
542
- value: function filterList(val) {
543
- val = val.toLowerCase();
544
- var items = (0, simpleSelection_utils_1.cloneObj)(this.state.getState('items'));
545
- items.forEach(function (group) {
546
- var isShowGroup = false;
547
- group.items.forEach(function (item) {
548
- if (item.title.toLowerCase().includes(val)) {
549
- isShowGroup = true;
550
- item.isShowFilter = true;
551
- } else {
552
- item.isShowFilter = false;
553
- }
554
- });
555
- group.isShowFilter = isShowGroup;
556
- });
557
- this.state.setState('items', items);
558
- }
559
- }, {
560
- key: "inputSearchHandler",
561
- value: function inputSearchHandler() {
562
- if (!this.elemInputSearch) {
563
- return;
564
- }
565
- this.elemInputSearch.addEventListener('input', this.searchHandler);
566
- }
567
- }, {
568
- key: "detachItem",
569
- value: function detachItem() {
570
- if (this.options.callbackDestroyInit) {
571
- this.options.callbackDestroyInit(this);
572
- }
573
- var parentElement = this.elemWrap.parentNode;
574
- this.$select.removeEventListener('change', this.changeListener);
575
- if (this.elemInputSearch) {
576
- this.elemInputSearch.removeEventListener('input', this.searchHandler);
577
- }
578
- if (this.confirmOk) {
579
- this.confirmOk.removeEventListener('click', this.confirmOkHandler);
580
- }
581
- if (this.confirmNo) {
582
- this.confirmNo.removeEventListener('click', this.confirmNoHandler);
583
- }
584
- parentElement.replaceChild(this.$select, this.elemWrap);
585
- this.$select.classList.remove(this.classSelectInit);
586
- if (this.elemSelectAll) {
587
- this.elemSelectAll.removeEventListener('click', this.selectAllHandler);
588
- }
589
- if (this.elemResetAll) {
590
- this.elemResetAll.removeEventListener('click', this.resetAllHandler);
591
- }
592
- if (this.options.callbackDestroy) {
593
- this.options.callbackDestroy(this);
594
- }
595
- if (this.elemDropDownClose) {
596
- this.elemDropDownClose.removeEventListener('click', this.closeHandler);
597
- }
598
- if (this.mql) {
599
- this.mql.onchange = null;
600
- this.mql = null;
601
- }
602
- }
603
- }]);
604
- return SimpleSelectItem;
605
- }(simpleSelectItemDOM_1.SimpleSelectItemDOM);
606
- exports.SimpleSelectItem = SimpleSelectItem;
607
-
608
- /***/ }),
609
-
610
- /***/ 844:
611
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
612
-
613
-
614
-
615
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
616
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
617
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
618
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
619
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
620
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
621
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
622
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
623
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
624
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
625
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
626
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
627
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
628
- Object.defineProperty(exports, "__esModule", ({
629
- value: true
630
- }));
631
- exports.SimpleSelectItemDOM = void 0;
632
- var simpleSelection_utils_1 = __webpack_require__(679);
633
- var store_1 = __webpack_require__(972);
634
- var simpleSelection_const_1 = __webpack_require__(737);
635
- var SimpleSelectItemDOM = /*#__PURE__*/function () {
636
- function SimpleSelectItemDOM(select, options, localOptions) {
637
- _classCallCheck(this, SimpleSelectItemDOM);
638
- _defineProperty(this, "options", void 0);
639
- _defineProperty(this, "$select", void 0);
640
- _defineProperty(this, "id", void 0);
641
- _defineProperty(this, "titlePlaceholder", void 0);
642
- _defineProperty(this, "isDisabled", false);
643
- _defineProperty(this, "isMulti", void 0);
644
- _defineProperty(this, "state", (0, store_1.store)({
645
- items: [],
646
- isOpen: false,
647
- filterStr: '',
648
- isFloat: false
649
- }));
650
- // classSelectInit= 'SimpleSel__select_init'
651
- _defineProperty(this, "classSelectInit", (0, simpleSelection_utils_1.getClass)('select_init'));
652
- _defineProperty(this, "isNative", void 0);
653
- _defineProperty(this, "elemWrap", document.createElement('div'));
654
- // all
655
- _defineProperty(this, "elemTop", document.createElement('div'));
656
- // all
657
- _defineProperty(this, "elemTopBody", document.createElement('div'));
658
- // all
659
- _defineProperty(this, "elemDropDown", null);
660
- // not native
661
- _defineProperty(this, "elemDropDownClose", null);
662
- // not native
663
- _defineProperty(this, "elemListBody", null);
664
- // not native
665
- _defineProperty(this, "elemInputSearch", null);
666
- // not native
667
- _defineProperty(this, "elemTitle", void 0);
668
- // not native
669
- _defineProperty(this, "confirmOk", null);
670
- // not native
671
- _defineProperty(this, "confirmNo", null);
672
- // not native
673
- _defineProperty(this, "elemControl", null);
674
- // not native
675
- _defineProperty(this, "elemSelectAll", null);
676
- // not native
677
- _defineProperty(this, "elemResetAll", null);
678
- // not native
679
- _defineProperty(this, "cloneClasses", '');
680
- _defineProperty(this, "isShowCheckbox", false);
681
- _defineProperty(this, "bodyLiHTMLBeforeFromSelect", null);
682
- _defineProperty(this, "bodyLiHTMLAfterFromSelect", null);
683
- _defineProperty(this, "isFloatWidth", false);
684
- _defineProperty(this, "bodyOpenClass", "".concat(simpleSelection_const_1.initClass, "--body_open"));
685
- var id = localOptions.id,
686
- isNative = localOptions.isNative;
687
- this.$select = select;
688
- this.isMulti = select.multiple;
689
- this.id = id;
690
- this.isNative = isNative;
691
- this.options = (0, simpleSelection_utils_1.cloneObj)(options);
692
- if (this.options.isCloneClass) {
693
- this.cloneClasses = this.$select.className;
694
- }
695
- if (options.callbackInitialization) {
696
- this.options.callbackInitialization = options.callbackInitialization;
697
- }
698
- if (options.callbackInitialized) {
699
- this.options.callbackInitialized = options.callbackInitialized;
700
- }
701
- if (options.callbackOpen) {
702
- this.options.callbackOpen = options.callbackOpen;
703
- }
704
- if (options.callbackClose) {
705
- this.options.callbackClose = options.callbackClose;
706
- }
707
- if (options.callbackDestroyInit) {
708
- this.options.callbackDestroyInit = options.callbackDestroyInit;
709
- }
710
- if (options.callbackDestroy) {
711
- this.options.callbackDestroy = options.callbackDestroy;
712
- }
713
- if (options.callbackChangeSelect) {
714
- this.options.callbackChangeSelect = options.callbackChangeSelect;
715
- }
716
- if (options.changeBodyLi) {
717
- this.options.changeBodyLi = options.changeBodyLi;
718
- }
719
- var dataConfirm = this.$select.dataset[(0, simpleSelection_utils_1.toCamelCase)('simple-is-confirm')];
720
- if (this.isMulti && dataConfirm) {
721
- this.options.isConfirmInMulti = dataConfirm === '1' || dataConfirm === 'true';
722
- }
723
- this.optionOverride();
724
- this.isDisabled = this.$select.disabled;
725
- // this.initDom()
726
- }
727
- _createClass(SimpleSelectItemDOM, [{
728
- key: "optionOverride",
729
- value: function optionOverride() {
730
- var dataPlaceholder = (0, simpleSelection_utils_1.toCamelCase)('simple-placeholder');
731
- if (this.$select.dataset[dataPlaceholder]) {
732
- this.titlePlaceholder = this.$select.dataset[dataPlaceholder] || '';
733
- } else {
734
- this.titlePlaceholder = this.options.locale.title;
735
- }
736
- var dataResetAll = (0, simpleSelection_utils_1.toCamelCase)('simple-reset-all');
737
- if (dataResetAll in this.$select.dataset) {
738
- var resReset = this.$select.dataset[dataResetAll];
739
- this.options.resetAll = !(resReset === 'false' || resReset === '0');
740
- }
741
- // const dataSelect = toCamelCase('simple-select-all');
742
- // if (dataSelect in this.$select.dataset) {
743
- // const resSelect = this.$select.dataset[dataSelect];
744
- // this.options.selectAll = !(resSelect === 'false' || resSelect === '0');
745
- // }
746
- if (this.$select.hasAttribute('data-simple-select-all')) {
747
- var resSelect = this.$select.getAttribute('data-simple-select-all');
748
- this.options.selectAll = (0, simpleSelection_utils_1.ifTrueDataAttr)(resSelect);
749
- }
750
- var isShowCheckboxLocal = this.$select.dataset[(0, simpleSelection_utils_1.toCamelCase)('simple-show-checkbox')];
751
- if (this.isMulti) {
752
- this.isShowCheckbox = !(isShowCheckboxLocal && !(0, simpleSelection_utils_1.ifTrueDataAttr)(isShowCheckboxLocal));
753
- } else if (isShowCheckboxLocal === 'true') {
754
- this.isShowCheckbox = true;
755
- }
756
- var itemHtmlBefore = this.$select.dataset[(0, simpleSelection_utils_1.toCamelCase)('simple-item-html-before')];
757
- if (itemHtmlBefore) {
758
- this.bodyLiHTMLBeforeFromSelect = itemHtmlBefore;
759
- }
760
- var itemHtmlAfter = this.$select.dataset[(0, simpleSelection_utils_1.toCamelCase)('simple-item-html-after')];
761
- if (itemHtmlAfter) {
762
- this.bodyLiHTMLAfterFromSelect = itemHtmlAfter;
763
- }
764
- if (this.$select.hasAttribute('data-simple-up')) {
765
- this.options.isUp = (0, simpleSelection_utils_1.ifTrueDataAttr)(this.$select.getAttribute('data-simple-up'));
766
- }
767
- }
768
- }, {
769
- key: "initDom",
770
- value: function initDom() {
771
- var _this = this;
772
- this.createList(false);
773
- this.createHTML();
774
- this.state.subscribe('items', function (_val) {
775
- _this.createListHTML();
776
- _this.createTitleHTML();
777
- });
778
- this.state.subscribe('isOpen', function (val) {
779
- _this.createListHTML();
780
- _this.createTitleHTML();
781
- _this.toggleTabIndex(val);
782
- });
783
- this.state.subscribe('isFloat', function (val) {
784
- _this.isFloatWidth = val;
785
- var cls = (0, simpleSelection_utils_1.getClass)('float', true);
786
- _this.elemWrap.classList.toggle(cls, val);
787
- });
788
- }
789
- }, {
790
- key: "toggleTabIndex",
791
- value: function toggleTabIndex(isOpen) {
792
- var tabIndex = isOpen ? 0 : -1;
793
- if (this.state.getState('isFloat')) {
794
- document.body.classList.toggle(this.bodyOpenClass, isOpen);
795
- }
796
- if (this.elemInputSearch) {
797
- this.elemInputSearch.tabIndex = tabIndex;
798
- }
799
- if (this.elemResetAll) {
800
- this.elemResetAll.tabIndex = tabIndex;
801
- }
802
- if (this.elemSelectAll) {
803
- this.elemSelectAll.tabIndex = tabIndex;
804
- }
805
- if (this.confirmOk) {
806
- this.confirmOk.tabIndex = tabIndex;
807
- }
808
- if (this.confirmNo) {
809
- this.confirmNo.tabIndex = tabIndex;
810
- }
811
- }
812
- }, {
813
- key: "updateHTML",
814
- value: function updateHTML() {
815
- this.createList(true);
816
- }
817
- }, {
818
- key: "createHTML",
819
- value: function createHTML() {
820
- this.$select.classList.add(this.classSelectInit);
821
- this.$select.tabIndex = -1;
822
- this.elemTopBody.className = (0, simpleSelection_utils_1.getClass)('top_body');
823
- this.elemTopBody.tabIndex = this.isDisabled ? -1 : 0;
824
- this.createIcon();
825
- this.elemTop.append(this.elemTopBody);
826
- var resClassesWrap = simpleSelection_const_1.initClass;
827
- if (this.options.isCloneClass) {
828
- resClassesWrap += " ".concat(this.cloneClasses);
829
- }
830
- if (this.$select.hasAttribute('data-simple-add-classes')) {
831
- resClassesWrap += " ".concat(this.$select.getAttribute('data-simple-add-classes'));
832
- }
833
- if (this.isDisabled) {
834
- resClassesWrap += " ".concat((0, simpleSelection_utils_1.getClass)('disabled', true));
835
- }
836
- if (this.options.isUp) {
837
- resClassesWrap += " ".concat((0, simpleSelection_utils_1.getClass)('up', true));
838
- }
839
- resClassesWrap += " ".concat(this.isMulti ? (0, simpleSelection_utils_1.getClass)('multi', true) : (0, simpleSelection_utils_1.getClass)('single', true));
840
- this.elemWrap.className = resClassesWrap;
841
- this.elemWrap.dataset.countAll = this.$select.options.length.toString();
842
- this.elemTop.className = (0, simpleSelection_utils_1.getClass)('top');
843
- // creating an initial structure
844
- var parentElement = this.$select.parentNode;
845
- if (parentElement) {
846
- parentElement.replaceChild(this.elemWrap, this.$select);
847
- this.elemWrap.appendChild(this.$select);
848
- }
849
- this.elemWrap.append(this.elemTop);
850
- if (this.isNative) {
851
- this.$select.classList.add((0, simpleSelection_utils_1.getClass)('native', true, this.classSelectInit));
852
- this.elemWrap.classList.add((0, simpleSelection_utils_1.getClass)('native', true));
853
- } else {
854
- this.createDropDown();
855
- this.createControlHTML();
856
- this.createInputHTML();
857
- }
858
- this.createTitleHTML();
859
- }
860
- }, {
861
- key: "createControlHTML",
862
- value: function createControlHTML() {
863
- if (!this.elemDropDown || !this.isMulti) {
864
- return;
865
- }
866
- if (!this.options.selectAll && !this.options.resetAll) {
867
- return;
868
- }
869
- this.elemControl = document.createElement('div');
870
- this.elemControl.classList.add((0, simpleSelection_utils_1.getClass)('controls'));
871
- this.elemDropDown.prepend(this.elemControl);
872
- var classControl = (0, simpleSelection_utils_1.getClass)('control');
873
- if (this.options.selectAll) {
874
- this.elemSelectAll = (0, simpleSelection_utils_1.createButton)();
875
- this.elemSelectAll.className = "".concat(classControl, " ").concat((0, simpleSelection_utils_1.getClass)('select_all', true, classControl));
876
- this.elemSelectAll.innerHTML = "<span class=\"".concat((0, simpleSelection_utils_1.getClass)('select_all__icon'), "\"></span> ").concat(this.options.locale.selectAll);
877
- this.elemControl.append(this.elemSelectAll);
878
- }
879
- if (this.options.resetAll) {
880
- this.elemResetAll = (0, simpleSelection_utils_1.createButton)();
881
- this.elemResetAll.className = "".concat(classControl, " ").concat((0, simpleSelection_utils_1.getClass)('reset_all', true, classControl));
882
- this.elemResetAll.innerHTML = "<span class=\"".concat((0, simpleSelection_utils_1.getClass)('reset_all__icon'), "\"></span> ").concat(this.options.locale.resetAll);
883
- this.elemControl.append(this.elemResetAll);
884
- }
885
- }
886
- }, {
887
- key: "createIcon",
888
- value: function createIcon() {
889
- var icon = document.createElement('span');
890
- icon.className = (0, simpleSelection_utils_1.getClass)('icon');
891
- this.elemTopBody.append(icon);
892
- }
893
- }, {
894
- key: "createDropDown",
895
- value: function createDropDown() {
896
- if (this.isNative) {
897
- return;
898
- }
899
- this.elemDropDown = document.createElement('div');
900
- this.elemDropDown.className = (0, simpleSelection_utils_1.getClass)('body');
901
- this.elemListBody = document.createElement('ul');
902
- this.elemListBody.className = (0, simpleSelection_utils_1.getClass)('list');
903
- this.elemWrap.append(this.elemDropDown);
904
- this.elemDropDown.append(this.elemListBody);
905
- this.elemDropDownClose = (0, simpleSelection_utils_1.createButton)();
906
- this.elemDropDownClose.classList.add((0, simpleSelection_utils_1.getClass)('close'));
907
- this.elemDropDown.append(this.elemDropDownClose);
908
- if (this.isMulti) {
909
- this.createIsConfirmInMultiHTML();
910
- }
911
- this.handlerChangeChecked();
912
- }
913
- }, {
914
- key: "createIsConfirmInMultiHTML",
915
- value: function createIsConfirmInMultiHTML() {
916
- var _this$elemDropDown;
917
- var confirm = document.createElement('div');
918
- var classesItem = (0, simpleSelection_utils_1.getClass)('bottom_control');
919
- this.confirmOk = (0, simpleSelection_utils_1.createButton)();
920
- this.confirmNo = (0, simpleSelection_utils_1.createButton)();
921
- confirm.append(this.confirmOk);
922
- confirm.append(this.confirmNo);
923
- this.confirmOk.innerHTML = this.options.locale.ok;
924
- this.confirmNo.innerHTML = this.options.locale.cansel;
925
- this.confirmOk.className = "".concat(classesItem, " ").concat((0, simpleSelection_utils_1.getClass)('ok', true, classesItem));
926
- this.confirmNo.className = "".concat(classesItem, " ").concat((0, simpleSelection_utils_1.getClass)('no', true, classesItem));
927
- var classes = (0, simpleSelection_utils_1.getClass)('bottom_controls');
928
- if (!this.options.isConfirmInMulti) {
929
- classes += " ".concat((0, simpleSelection_utils_1.getClass)('hide', true, classes));
930
- }
931
- confirm.className = classes;
932
- (_this$elemDropDown = this.elemDropDown) === null || _this$elemDropDown === void 0 || _this$elemDropDown.append(confirm);
933
- }
934
- }, {
935
- key: "createTitleHTML",
936
- value: function createTitleHTML() {
937
- var _this2 = this;
938
- if (!this.elemTitle) {
939
- this.elemTitle = document.createElement('div');
940
- this.elemTitle.className = (0, simpleSelection_utils_1.getClass)('title');
941
- this.elemTopBody.prepend(this.elemTitle);
942
- }
943
- var itemsChecked = this.getChecked();
944
- this.elemTop.title = '';
945
- var isPlaceholder = !itemsChecked.length;
946
- var title = this.titlePlaceholder;
947
- if (itemsChecked.length) {
948
- var attrTitle = '';
949
- itemsChecked.forEach(function (item, index) {
950
- if (index !== 0) {
951
- attrTitle += "".concat(_this2.options.sepChars, "<span class=\"").concat((0, simpleSelection_utils_1.getClass)('sep_space', true), "\">&nbsp;</span>");
952
- }
953
- attrTitle += "".concat(item.title);
954
- });
955
- this.elemTop.title = attrTitle;
956
- var maxShow = this.options.countShowSelected;
957
- var maxShowAttr = Number(this.$select.dataset.simpleCountShowsSelected);
958
- if (maxShowAttr && maxShowAttr > 0) {
959
- maxShow = maxShowAttr;
960
- }
961
- if (itemsChecked.length > maxShow) {
962
- title = "".concat(this.options.locale.selected, " ").concat(itemsChecked.length);
963
- if (this.$select.querySelectorAll('option').length === itemsChecked.length) {
964
- title += " (".concat(this.options.locale.all, ")");
965
- }
966
- } else if (attrTitle) {
967
- title = attrTitle;
968
- }
969
- }
970
- this.elemTitle.innerHTML = title;
971
- this.elemTitle.classList.toggle('SimpleSel__title--placeholder', isPlaceholder);
972
- this.elemTitle.classList.toggle('SimpleSel__title--fill', !isPlaceholder);
973
- this.elemWrap.classList.toggle((0, simpleSelection_utils_1.getClass)('fill', true), !isPlaceholder);
974
- }
975
- }, {
976
- key: "createListHTML",
977
- value: function createListHTML() {
978
- var _this3 = this;
979
- if (!this.elemListBody) {
980
- return;
981
- }
982
- var resBodyList = '';
983
- var countShowItem = 0;
984
- var countCheckedItems = 0;
985
- var countCheckedFullItems = 0;
986
- // this.items.forEach(group => {
987
- this.state.getState('items').forEach(function (group) {
988
- if (!group.isGroup) {
989
- var _this3$createLi = _this3.createLi(group),
990
- result = _this3$createLi.result,
991
- countShow = _this3$createLi.countShow,
992
- countChecked = _this3$createLi.countChecked,
993
- countCheckedFull = _this3$createLi.countCheckedFull;
994
- resBodyList += result;
995
- countShowItem += countShow;
996
- countCheckedItems += countChecked;
997
- countCheckedFullItems += countCheckedFull;
998
- } else {
999
- var _this3$createLi2 = _this3.createLi(group),
1000
- _result = _this3$createLi2.result,
1001
- _countShow = _this3$createLi2.countShow,
1002
- _countChecked = _this3$createLi2.countChecked,
1003
- _countCheckedFull = _this3$createLi2.countCheckedFull;
1004
- resBodyList += "<div class=\"".concat((0, simpleSelection_utils_1.getClass)('group_items'), "\">");
1005
- resBodyList += _result;
1006
- resBodyList += '</div>';
1007
- countCheckedItems += _countChecked;
1008
- countShowItem += _countShow;
1009
- countCheckedFullItems += _countCheckedFull;
1010
- }
1011
- });
1012
- var isSearch = this.state.getState('filterStr');
1013
- if (isSearch && isSearch.length && countShowItem === 0) {
1014
- resBodyList = "<div class=\"".concat((0, simpleSelection_utils_1.getClass)('no_match'), "\">");
1015
- resBodyList = "".concat(this.options.locale.noSearch, " \"").concat(isSearch, "\"");
1016
- resBodyList += '</div>';
1017
- }
1018
- this.elemWrap.dataset.countChecked = countCheckedItems.toString();
1019
- this.elemWrap.dataset.countCheckedFull = countCheckedFullItems.toString();
1020
- if (this.isMulti) {
1021
- this.elemWrap.dataset.checkAllMulti = this.$select.options.length === countCheckedItems ? 'yes' : 'no';
1022
- }
1023
- this.elemListBody.innerHTML = resBodyList;
1024
- }
1025
- }, {
1026
- key: "createInputHTML",
1027
- value: function createInputHTML() {
1028
- var isSearch = this.options.isSearch;
1029
- var isSearchInDropdown = this.options.isSearchInDropdown;
1030
- if ('simpleSelectSearch' in this.$select.dataset) {
1031
- isSearch = this.$select.dataset.simpleSelectSearch !== 'false';
1032
- }
1033
- if ('simpleSelectSearchDropdown' in this.$select.dataset) {
1034
- isSearchInDropdown = this.$select.dataset.simpleSelectSearchDropdown !== 'false';
1035
- }
1036
- if (!isSearch && !isSearchInDropdown) {
1037
- return;
1038
- }
1039
- this.elemInputSearch = document.createElement('input');
1040
- this.elemInputSearch.type = 'text';
1041
- this.elemInputSearch.tabIndex = -1;
1042
- this.elemInputSearch.autocomplete = 'off';
1043
- this.elemInputSearch.ariaAutoComplete = 'none';
1044
- this.elemInputSearch.inputMode = 'off';
1045
- this.elemInputSearch.placeholder = this.options.locale.searchText;
1046
- this.elemInputSearch.name = "".concat(simpleSelection_const_1.initClass, "_name_").concat(this.id);
1047
- var className = (0, simpleSelection_utils_1.getClass)('search');
1048
- if (isSearchInDropdown) {
1049
- if (this.elemDropDown) {
1050
- this.elemInputSearch.className = "".concat(className, " ").concat((0, simpleSelection_utils_1.getClass)('dropdown', true, className));
1051
- this.elemDropDown.prepend(this.elemInputSearch);
1052
- }
1053
- } else {
1054
- this.elemInputSearch.className = "".concat(className, " ").concat((0, simpleSelection_utils_1.getClass)('top', true, className));
1055
- this.elemTop.append(this.elemInputSearch);
1056
- }
1057
- this.inputSearchHandler();
1058
- }
1059
- }, {
1060
- key: "getChecked",
1061
- value: function getChecked() {
1062
- var items = this.state.getState('items');
1063
- var res = [];
1064
- items.forEach(function (group) {
1065
- res = [].concat(_toConsumableArray(res), _toConsumableArray(group.items.filter(function (i) {
1066
- return i.checked;
1067
- })));
1068
- });
1069
- return res;
1070
- }
1071
- }, {
1072
- key: "createLi",
1073
- value: function createLi(data) {
1074
- var _this4 = this;
1075
- var result = '';
1076
- var countShow = 0;
1077
- var countChecked = 0;
1078
- var countCheckedFull = 0;
1079
- if (!data.isShowFilter) {
1080
- return {
1081
- result: result,
1082
- countShow: countShow,
1083
- countChecked: countChecked,
1084
- countCheckedFull: countCheckedFull
1085
- };
1086
- }
1087
- if (data.isGroup) {
1088
- result += "<label class=\"".concat((0, simpleSelection_utils_1.getClass)('group_title'), "\">").concat(data.titleGroup, "</label>");
1089
- result += "<ul class=\"".concat((0, simpleSelection_utils_1.getClass)('group'), "\">");
1090
- }
1091
- data.items.forEach(function (option) {
1092
- if (!option.isShowFilter) {
1093
- return;
1094
- }
1095
- countShow++;
1096
- var classLiInit = (0, simpleSelection_utils_1.getClass)('list_item');
1097
- var classLi = classLiInit;
1098
- if (option.checked) {
1099
- countChecked++;
1100
- classLi += " ".concat((0, simpleSelection_utils_1.getClass)('checked', true, classLiInit));
1101
- if (option.value) {
1102
- countCheckedFull++;
1103
- }
1104
- }
1105
- if (option.disabled) {
1106
- classLi += " ".concat((0, simpleSelection_utils_1.getClass)('disabled', true, classLiInit));
1107
- }
1108
- if (!option.value) {
1109
- classLi += " ".concat((0, simpleSelection_utils_1.getClass)('not_value', true, classLiInit));
1110
- }
1111
- var dataAttr = "data-sel-group-id=\"".concat(data.idGroup, "\"");
1112
- dataAttr += " data-sel-position=\"".concat(option.position, "\"");
1113
- dataAttr += " data-sel-id=\"".concat(option.id, "\"");
1114
- if (option.value) {
1115
- dataAttr += " data-sel-value=\"".concat(option.value, "\"");
1116
- }
1117
- dataAttr += ' data-sel-opt-item';
1118
- dataAttr += " data-sel-opt-checked=\"".concat(option.checked, "\"");
1119
- dataAttr += " data-sel-opt-disabled=\"".concat(option.disabled, "\"");
1120
- result += "<li class=\"".concat(classLi, "\" ").concat(dataAttr, ">");
1121
- var createLiBodyRes = _this4.createLiBody(option, _this4.$select.options[option.position]);
1122
- result += typeof createLiBodyRes === 'string' ? createLiBodyRes : createLiBodyRes.outerHTML;
1123
- result += '</li>';
1124
- });
1125
- if (data.isGroup) {
1126
- result += '</ul>';
1127
- }
1128
- return {
1129
- result: result,
1130
- countShow: countShow,
1131
- countChecked: countChecked,
1132
- countCheckedFull: countCheckedFull
1133
- };
1134
- }
1135
- }, {
1136
- key: "createLiBody",
1137
- value: function createLiBody(option, optionNative) {
1138
- var item = document.createElement('div');
1139
- item.className = (0, simpleSelection_utils_1.getClass)('list_item_body');
1140
- var res = '';
1141
- if (this.isShowCheckbox) {
1142
- res = "<span class=\"".concat((0, simpleSelection_utils_1.getClass)('list_item_icon'), "\"></span>");
1143
- }
1144
- if (this.bodyLiHTMLBeforeFromSelect) {
1145
- res += this.bodyLiHTMLBeforeFromSelect;
1146
- }
1147
- if (optionNative.hasAttribute('data-simple-html-before')) {
1148
- res += optionNative.getAttribute('data-simple-html-before');
1149
- }
1150
- res += "".concat(option.title);
1151
- if (this.bodyLiHTMLAfterFromSelect) {
1152
- res += this.bodyLiHTMLAfterFromSelect;
1153
- }
1154
- if (optionNative.hasAttribute('data-simple-html-after')) {
1155
- res += optionNative.getAttribute('data-simple-html-after');
1156
- }
1157
- item.innerHTML = res;
1158
- if (this.options.changeBodyLi) {
1159
- return this.options.changeBodyLi(item, optionNative);
1160
- }
1161
- return item;
1162
- }
1163
- }, {
1164
- key: "handlerChangeChecked",
1165
- value: function handlerChangeChecked() {
1166
- console.error('This method need redefine');
1167
- }
1168
- // only desktop
1169
- }, {
1170
- key: "createList",
1171
- value: function createList(_isCompare) {
1172
- console.error('This method need redefine');
1173
- }
1174
- // only desktop
1175
- }, {
1176
- key: "inputSearchHandler",
1177
- value: function inputSearchHandler() {
1178
- console.error('This method need redefine');
1179
- }
1180
- }]);
1181
- return SimpleSelectItemDOM;
1182
- }();
1183
- exports.SimpleSelectItemDOM = SimpleSelectItemDOM;
1184
-
1185
- /***/ }),
1186
-
1187
- /***/ 679:
1188
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1189
-
1190
-
1191
-
1192
- Object.defineProperty(exports, "__esModule", ({
1193
- value: true
1194
- }));
1195
- exports.createButton = exports.cloneObj = exports.compareObj = exports.getClass = exports.getCreateListItem = exports.triggerInputEvent = exports.ifTrueDataAttr = exports.createDataAttr = exports.toCamelCase = void 0;
1196
- var simpleSelection_const_1 = __webpack_require__(737);
1197
- var toCamelCase = function toCamelCase(input) {
1198
- return input.replace(/-([a-z])/g, function (_, letter) {
1199
- return letter.toUpperCase();
1200
- });
1201
- };
1202
- exports.toCamelCase = toCamelCase;
1203
- var createDataAttr = function createDataAttr(name) {
1204
- return "data-".concat(name);
1205
- };
1206
- exports.createDataAttr = createDataAttr;
1207
- var ifTrueDataAttr = function ifTrueDataAttr(attr) {
1208
- if (!attr) {
1209
- return false;
1210
- }
1211
- return attr === 'true' || attr === '1';
1212
- };
1213
- exports.ifTrueDataAttr = ifTrueDataAttr;
1214
- function triggerInputEvent(element) {
1215
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'change';
1216
- var event = new Event(type, {
1217
- bubbles: true,
1218
- cancelable: true
1219
- });
1220
- element.dispatchEvent(event);
1221
- }
1222
- exports.triggerInputEvent = triggerInputEvent;
1223
- var getCreateListItem = function getCreateListItem(item, idGroup, isGroup) {
1224
- var options = item.querySelectorAll('option');
1225
- var items = [];
1226
- options.forEach(function (option, ind) {
1227
- items.push({
1228
- id: (ind + 1).toString(),
1229
- position: option.index,
1230
- title: option.innerHTML,
1231
- // value: option.value,
1232
- value: option.getAttribute('value'),
1233
- checked: option.selected,
1234
- disabled: option.disabled,
1235
- isShowFilter: true
1236
- });
1237
- });
1238
- var newItem = {
1239
- isGroup: isGroup,
1240
- idGroup: idGroup,
1241
- items: items,
1242
- isShowFilter: true
1243
- };
1244
- if (item instanceof HTMLOptGroupElement) {
1245
- newItem.titleGroup = item.label || '';
1246
- newItem.isDisabledGroup = item.disabled || false;
1247
- }
1248
- return newItem;
1249
- };
1250
- exports.getCreateListItem = getCreateListItem;
1251
- var getClass = function getClass(cls) {
1252
- var mod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1253
- var classInit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : simpleSelection_const_1.initClass;
1254
- var sep = mod ? '--' : '__';
1255
- return "".concat(classInit).concat(sep).concat(cls);
1256
- };
1257
- exports.getClass = getClass;
1258
- var compareObj = function compareObj(obj1, obj2) {
1259
- return JSON.stringify(obj1) === JSON.stringify(obj2);
1260
- };
1261
- exports.compareObj = compareObj;
1262
- var cloneObj = function cloneObj(obj) {
1263
- return JSON.parse(JSON.stringify(obj));
1264
- };
1265
- exports.cloneObj = cloneObj;
1266
- var createButton = function createButton() {
1267
- var btn = document.createElement('button');
1268
- btn.type = 'button';
1269
- btn.tabIndex = -1;
1270
- return btn;
1271
- };
1272
- exports.createButton = createButton;
1273
-
1274
- /***/ }),
1275
-
1276
- /***/ 972:
1277
- /***/ (function(__unused_webpack_module, exports) {
1278
-
1279
-
1280
-
1281
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1282
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1283
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1284
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1285
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
1286
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1287
- Object.defineProperty(exports, "__esModule", ({
1288
- value: true
1289
- }));
1290
- exports.store = void 0;
1291
- function store(obj) {
1292
- var stateData = {};
1293
- var subscribers = {}; /** подписка на конкретное свойство */
1294
- var subscribersAll = []; /** подписка на все свойства */
1295
- var getState = function getState(k) {
1296
- if (!k) {
1297
- return stateData;
1298
- }
1299
- if (!(k in stateData)) {
1300
- return null;
1301
- }
1302
- return stateData[k];
1303
- };
1304
- var setState = function setState(k, val) {
1305
- var prevState = _objectSpread({}, stateData);
1306
- var prev = stateData[k] || stateData[k] == 0 ? stateData[k] : null;
1307
- stateData[k] = val;
1308
- if (k in subscribers) {
1309
- subscribers[k].forEach(function (cb) {
1310
- return cb(val, prev, stateData);
1311
- });
1312
- }
1313
- subscribersAll.forEach(function (cb) {
1314
- return cb(k, prevState, stateData);
1315
- });
1316
- };
1317
- if (obj) {
1318
- Object.keys(obj).forEach(function (k) {
1319
- // @ts-ignore
1320
- setState(k, obj[k]);
1321
- });
1322
- }
1323
- return {
1324
- getState: getState,
1325
- setState: setState,
1326
- subscribe: function subscribe(k, cb) {
1327
- if (!(k in subscribers)) {
1328
- subscribers[k] = [];
1329
- }
1330
- subscribers[k].push(cb);
1331
- var cur = getState(k);
1332
- cb(cur, null, getState());
1333
- return function () {
1334
- subscribers[k] = subscribers[k].filter(function (i) {
1335
- return i !== cb;
1336
- });
1337
- };
1338
- },
1339
- subscribeAll: function subscribeAll(cb) {
1340
- subscribersAll.push(cb);
1341
- cb(null, null, getState());
1342
- return function () {
1343
- subscribersAll = subscribersAll.filter(function (i) {
1344
- return i !== cb;
1345
- });
1346
- };
1347
- },
1348
- unSubscribe: function unSubscribe(k, cb) {
1349
- if (k in subscribers) {
1350
- subscribers[k] = subscribers[k].filter(function (i) {
1351
- return i !== cb;
1352
- });
1353
- }
1354
- }
1355
- };
1356
- }
1357
- exports.store = store;
1358
-
1359
- /***/ }),
1360
-
1361
- /***/ 181:
1362
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1363
-
1364
- __webpack_require__.r(__webpack_exports__);
1365
- // extracted by mini-css-extract-plugin
1366
-
1367
-
1368
- /***/ })
1369
-
1370
- /******/ });
1371
- /************************************************************************/
1372
- /******/ // The module cache
1373
- /******/ var __webpack_module_cache__ = {};
1374
- /******/
1375
- /******/ // The require function
1376
- /******/ function __webpack_require__(moduleId) {
1377
- /******/ // Check if module is in cache
1378
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
1379
- /******/ if (cachedModule !== undefined) {
1380
- /******/ return cachedModule.exports;
1381
- /******/ }
1382
- /******/ // Create a new module (and put it into the cache)
1383
- /******/ var module = __webpack_module_cache__[moduleId] = {
1384
- /******/ // no module.id needed
1385
- /******/ // no module.loaded needed
1386
- /******/ exports: {}
1387
- /******/ };
1388
- /******/
1389
- /******/ // Execute the module function
1390
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1391
- /******/
1392
- /******/ // Return the exports of the module
1393
- /******/ return module.exports;
1394
- /******/ }
1395
- /******/
1396
- /************************************************************************/
1397
- /******/ /* webpack/runtime/make namespace object */
1398
- /******/ !function() {
1399
- /******/ // define __esModule on exports
1400
- /******/ __webpack_require__.r = function(exports) {
1401
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1402
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1403
- /******/ }
1404
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
1405
- /******/ };
1406
- /******/ }();
1407
- /******/
1408
- /************************************************************************/
1409
- var __webpack_exports__ = {};
1410
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
1411
- !function() {
1412
- var exports = __webpack_exports__;
1413
- var __webpack_unused_export__;
1414
-
1415
-
1416
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1417
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1418
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1419
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1420
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
1421
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1422
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1423
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
1424
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1425
- __webpack_unused_export__ = ({
1426
- value: true
1427
- });
1428
- var simpleSelection_const_1 = __webpack_require__(737);
1429
- var simpleSelection_utils_1 = __webpack_require__(679);
1430
- var simpleSelectItem_1 = __webpack_require__(874);
1431
- __webpack_require__(181);
1432
- var SimpleSelect = /*#__PURE__*/function () {
1433
- function SimpleSelect(selector, options) {
1434
- _classCallCheck(this, SimpleSelect);
1435
- _defineProperty(this, "callCount", Date.now());
1436
- _defineProperty(this, "countInit", 0);
1437
- // $selects: HTMLSelectElement[] = [];
1438
- _defineProperty(this, "$selects", []);
1439
- _defineProperty(this, "options", void 0);
1440
- _defineProperty(this, "nameMarkTransform", (0, simpleSelection_utils_1.toCamelCase)(simpleSelection_const_1.nameMark));
1441
- _defineProperty(this, "dataNameMark", (0, simpleSelection_utils_1.createDataAttr)(simpleSelection_const_1.nameMark));
1442
- _defineProperty(this, "isNative", void 0);
1443
- if (!selector) {
1444
- selector = 'select';
1445
- }
1446
- // this.$selects = Array.from(document.querySelectorAll(selector));
1447
- this.options = _objectSpread(_objectSpread({}, simpleSelection_const_1.simpleSelectionOptions), options);
1448
- if (typeof selector === 'string') {
1449
- this.init(Array.from(document.querySelectorAll(selector)));
1450
- } else if (selector instanceof HTMLSelectElement) {
1451
- this.init([selector]);
1452
- } else if (selector instanceof NodeList) {
1453
- this.init(Array.from(selector));
1454
- } else if (Array.isArray(selector)) {
1455
- this.init(selector);
1456
- } else {
1457
- console.warn('Wrong selector: ', selector);
1458
- }
1459
- }
1460
- _createClass(SimpleSelect, [{
1461
- key: "detectMobile",
1462
- value: function detectMobile() {
1463
- if (this.options.detectNative) {
1464
- this.isNative = this.options.detectNative();
1465
- return;
1466
- }
1467
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1468
- // @ts-ignore
1469
- var ua = navigator.userAgent || navigator.vendor || window.opera;
1470
- var res = false;
1471
- // Checks for iOs, Android, Blackberry, Opera Mini, and Windows mobile devices
1472
- for (var i = 0; i < this.options.nativeOnDevice.length; i++) {
1473
- if (ua.toString().toLowerCase().indexOf(this.options.nativeOnDevice[i].toLowerCase()) > 0) {
1474
- if (this.options.nativeOnDevice[i]) {
1475
- res = true;
1476
- }
1477
- }
1478
- }
1479
- this.isNative = res;
1480
- }
1481
- }, {
1482
- key: "init",
1483
- value: function init(selects) {
1484
- var _this = this;
1485
- this.detectMobile();
1486
- selects.forEach(function ($select) {
1487
- _this.build($select);
1488
- });
1489
- }
1490
- }, {
1491
- key: "createMethods",
1492
- value: function createMethods(select) {
1493
- var self = this;
1494
- return {
1495
- getInstance: function getInstance() {
1496
- return select.getSelect();
1497
- },
1498
- reload: function reload() {
1499
- self.rebuild(select);
1500
- },
1501
- update: function update() {
1502
- select.updateHTML();
1503
- },
1504
- detach: function detach() {
1505
- self.detach(select);
1506
- }
1507
- };
1508
- }
1509
- }, {
1510
- key: "setMethods",
1511
- value: function setMethods(select) {
1512
- // @ts-ignore
1513
- select.$select[simpleSelection_const_1.nameSelect] = this.createMethods(select);
1514
- }
1515
- }, {
1516
- key: "setMethodsClear",
1517
- value: function setMethodsClear(select) {
1518
- // @ts-ignore
1519
- delete select.$select[simpleSelection_const_1.nameSelect];
1520
- }
1521
- }, {
1522
- key: "build",
1523
- value: function build(select) {
1524
- var isProcessed = (this.nameMarkTransform in select.dataset);
1525
- if (isProcessed) {
1526
- console.warn('This element has already been initialized', select);
1527
- return;
1528
- }
1529
- this.countInit += 1;
1530
- var id = "".concat(this.callCount, "-").concat(this.countInit);
1531
- select.setAttribute(this.dataNameMark, id);
1532
- // this.$selects.push(select);
1533
- var newSelect = new simpleSelectItem_1.SimpleSelectItem(select, this.options, {
1534
- id: id,
1535
- isNative: this.isNative
1536
- });
1537
- this.$selects.push(newSelect);
1538
- this.setMethods(newSelect);
1539
- }
1540
- }, {
1541
- key: "detach",
1542
- value: function detach(itemSelect) {
1543
- itemSelect.detachItem();
1544
- itemSelect.$select.removeAttribute(this.dataNameMark);
1545
- this.setMethodsClear(itemSelect);
1546
- this.$selects = this.$selects.filter(function (item) {
1547
- return item !== itemSelect;
1548
- });
1549
- }
1550
- }, {
1551
- key: "rebuild",
1552
- value: function rebuild(selectsItems) {
1553
- var select = selectsItems.$select;
1554
- this.detach(selectsItems);
1555
- this.build(select);
1556
- }
1557
- }, {
1558
- key: "getSelects",
1559
- value: function getSelects() {
1560
- return this.$selects;
1561
- }
1562
- }, {
1563
- key: "getSelectFirst",
1564
- value: function getSelectFirst() {
1565
- // return this.$selects[0];
1566
- return this.createMethods(this.$selects[0]);
1567
- }
1568
- }, {
1569
- key: "getSelectById",
1570
- value: function getSelectById(id) {
1571
- var search = this.$selects.filter(function (item) {
1572
- return item.id === id;
1573
- })[0];
1574
- if (!search) {
1575
- return null;
1576
- }
1577
- return this.createMethods(search);
1578
- }
1579
- }]);
1580
- return SimpleSelect;
1581
- }();
1582
- exports["default"] = SimpleSelect;
1583
- }();
1584
- __webpack_exports__ = __webpack_exports__["default"];
1585
- /******/ return __webpack_exports__;
1586
- /******/ })()
1587
- ;
1588
- });
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("SimpleSelect",[],t):"object"==typeof exports?exports.SimpleSelect=t():e.SimpleSelect=t()}("undefined"==typeof self?this:self,(function(){return function(){"use strict";var e={737:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.initClass=t.nameMark=t.nameSelect=t.simpleSelectionOptions=t.simpleSelectLocale=void 0,t.simpleSelectLocale={noSearch:"No matches for",searchText:"Search",title:"Select",selected:"Selected:",all:"all",ok:"Ok",cansel:"Cansel",selectAll:"Select all",resetAll:"Reset all"},t.simpleSelectionOptions={isSearch:!0,isSearchInDropdown:!1,countShowSelected:2,isConfirmInMulti:!1,isConfirmInMultiOkClickOutside:!1,nativeOnDevice:["Android","BlackBerry","iPhone","iPad","iPod","Opera Mini","IEMobile","Silk"],locale:t.simpleSelectLocale,sepChars:",",isUp:!1,floatWidth:767,isCloneClass:!0,selectAll:!1,selectAllAfterClose:!0,resetAll:!1,resetAllAfterClose:!0},t.nameSelect="SimSel";t.nameMark="".concat("simple-select-","init"),t.initClass="SimpleSel"},874:function(e,t,i){function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function n(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,h(s.key),s)}}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function o(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,n=c(e);if(t){var l=c(this).constructor;i=Reflect.construct(n,arguments,l)}else i=n.apply(this,arguments);return function(e,t){if(t&&("object"===s(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}(this,i)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function r(){return r="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var s=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e}(e,t);if(s){var n=Object.getOwnPropertyDescriptor(s,t);return n.get?n.get.call(arguments.length<3?e:i):n.value}},r.apply(this,arguments)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t,i){return(t=h(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function h(e){var t=function(e,t){if("object"!==s(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===s(t)?t:String(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleSelectItem=void 0;var d=i(679),p=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(p,e);var t,i,s,h=o(p);function p(e,t,i){var s,n;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,p),u(a(n=h.call(this,e,t,i)),"closeOutsideHandler",void 0),u(a(n),"closeEscHandler",void 0),u(a(n),"changeListener",void 0),u(a(n),"searchHandler",void 0),u(a(n),"clickToggleOpen",void 0),u(a(n),"triggerSetup",void 0),u(a(n),"confirmOkHandler",void 0),u(a(n),"confirmNoHandler",void 0),u(a(n),"selectAllHandler",void 0),u(a(n),"resetAllHandler",void 0),u(a(n),"closeHandler",void 0),u(a(n),"handleResize",void 0),u(a(n),"mql",null),u(a(n),"countOpen",0),u(a(n),"multiDebounceTime",0),u(a(n),"timeoutDebounceId",null),!e)throw Error("Select is required");return n.init(),r((s=a(n),c(p.prototype)),"initDom",s).call(s),n.initAfterDom(),n}return t=p,i=[{key:"init",value:function(){var e=this;this.changeListener=this.changeListenerInit.bind(this),this.$select.addEventListener("change",this.changeListener),this.searchHandler=this.searchHandlerInit.bind(this),this.closeOutsideHandler=this.closeOutsideHandlerInit.bind(this),this.closeEscHandler=this.closeEscHandlerInit.bind(this),this.clickToggleOpen=this.clickToggleOpenInit.bind(this),this.triggerSetup=this.triggerSetupInit.bind(this),this.confirmOkHandler=this.confirmOkHandlerInit.bind(this),this.confirmNoHandler=this.confirmNoHandlerInit.bind(this),this.selectAllHandler=this.selectAllHandlerInit.bind(this),this.resetAllHandler=this.resetAllHandlerInit.bind(this),this.closeHandler=this.closeHandlerInit.bind(this),this.handleResize=this.handleResizeInit.bind(this),this.options.callbackInitialization&&this.options.callbackInitialization(this),!this.isNative&&this.options.floatWidth&&(this.mql=window.matchMedia("(max-width: ".concat(this.options.floatWidth,"px)")),this.mql&&(this.mql.onchange=this.handleResize,this.handleResizeInit(this.mql))),this.state.subscribe("isOpen",(function(t){e.toggleOpenHandler(),!t&&e.options.isConfirmInMulti&&e.createList(),t&&e.elemInputSearch&&(e.elemInputSearch.value="")})),this.state.subscribe("filterStr",(function(t){e.filterList(t)})),this.isNative||(this.elemTopBody.addEventListener("click",this.clickToggleOpen),this.elemTopBody.addEventListener("keyup",this.clickToggleOpen))}},{key:"handleResizeInit",value:function(e){e&&(e.matches?this.state.setState("isFloat",!0):this.state.setState("isFloat",!1))}},{key:"initAfterDom",value:function(){this.confirmOk&&this.confirmOk.addEventListener("click",this.confirmOkHandler),this.confirmNo&&this.confirmNo.addEventListener("click",this.confirmNoHandler),this.options.callbackInitialized&&this.options.callbackInitialized(this),this.isMulti&&!this.options.isConfirmInMulti&&((0,d.toCamelCase)("simple-debounce-time")in this.$select.dataset?this.multiDebounceTime=Number(this.$select.dataset[(0,d.toCamelCase)("simple-debounce-time")]):(this.options.debounceTime||0===this.options.debounceTime)&&(this.multiDebounceTime=this.options.debounceTime)),this.multiDebounceTime&&(this.multiDebounceChange=this.debounce(this.multiDebounceChange.bind(this),this.multiDebounceTime)),this.elemSelectAll&&this.elemSelectAll.addEventListener("click",this.selectAllHandler),this.elemResetAll&&this.elemResetAll.addEventListener("click",this.resetAllHandler),this.elemDropDownClose&&this.elemDropDownClose.addEventListener("click",this.closeHandler)}},{key:"debounce",value:function(e,t){var i=this;return function(){for(var s=arguments.length,n=new Array(s),l=0;l<s;l++)n[l]=arguments[l];i.timeoutDebounceId&&clearTimeout(i.timeoutDebounceId),i.timeoutDebounceId=setTimeout((function(){e.apply(void 0,n),i.timeoutDebounceId=null}),t)}}},{key:"confirmOkHandlerInit",value:function(e){e.preventDefault(),this.confirmOkBuild()}},{key:"confirmOkBuild",value:function(){var e=this.$select.options;this.elemListBody&&(this.elemListBody.querySelectorAll("[data-sel-position]").forEach((function(t){var i=parseInt(t.dataset[(0,d.toCamelCase)("sel-position")],10);if(i||0===i){var s=e[i];s&&!s.disabled&&(s.selected="true"===t.dataset[(0,d.toCamelCase)("sel-opt-checked")])}})),this.state.setState("isOpen",!1),this.triggerInit())}},{key:"confirmNoHandlerInit",value:function(e){e.preventDefault(),this.state.setState("isOpen",!1)}},{key:"closeHandlerInit",value:function(e){e.preventDefault(),this.state.setState("isOpen",!1)}},{key:"selectAllHandlerInit",value:function(e){e.preventDefault(),Array.from(this.$select.options).forEach((function(e){e.disabled||(e.selected=!0)})),this.createList(),this.options.selectAllAfterClose&&this.state.setState("isOpen",!1),this.triggerInit()}},{key:"resetAllHandlerInit",value:function(e){e.preventDefault(),Array.from(this.$select.options).forEach((function(e){e.disabled||(e.selected=!1)})),this.createList(),this.options.selectAllAfterClose&&this.state.setState("isOpen",!1),this.triggerInit()}},{key:"triggerSetupInit",value:function(e){if(0===e.button){var t=e.target.closest("li");t&&this.changeClickItem(t)}}},{key:"changeClickItem",value:function(e){if(e){var t=Number(e.dataset[(0,d.toCamelCase)("sel-position")])||0,i=this.$select.options[t];i&&!i.disabled&&(this.isMulti?this.options.isConfirmInMulti||this.isFloatWidth?"true"===e.dataset[(0,d.toCamelCase)("sel-opt-checked")]?(e.dataset[(0,d.toCamelCase)("sel-opt-checked")]="false",e.classList.remove("SimpleSel__list_item--checked")):(e.dataset[(0,d.toCamelCase)("sel-opt-checked")]="true",e.classList.add("SimpleSel__list_item--checked")):(i.selected=!i.selected,this.createList(),this.multiDebounceChange()):(i.selected=!i.selected,this.createList(),this.state.setState("isOpen",!1),this.triggerInit()))}}},{key:"multiDebounceChange",value:function(){this.triggerInit()}},{key:"triggerInit",value:function(){(0,d.triggerInputEvent)(this.$select)}},{key:"clickToggleOpenInit",value:function(e){e.preventDefault(),this.isDisabled||("click"!==e.type?e instanceof KeyboardEvent&&"Enter"===e.key&&this.state.setState("isOpen",!this.state.getState("isOpen")):this.state.setState("isOpen",!this.state.getState("isOpen")))}},{key:"closeOutsideHandlerInit",value:function(e){var t=e.target;t&&(this.elemWrap.contains(t)||(this.options.isConfirmInMulti&&this.options.isConfirmInMultiOkClickOutside&&this.confirmOkBuild(),this.state.setState("isOpen",!1)))}},{key:"closeEscHandlerInit",value:function(e){if("Escape"===e.code&&(e.preventDefault(),e.stopPropagation(),this.state.setState("isOpen",!1)),"Tab"===e.code&&(e.preventDefault(),e.stopPropagation(),this.elemWrap.contains(e.target)||this.state.setState("isOpen",!1)),"ArrowUp"!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),e.stopPropagation(),this.keyBoardChangeChecked("ArrowDown"===e.key)),"Enter"===e.key){var t=e.target;t&&(0,d.toCamelCase)("sel-opt-item")in t.dataset&&(e.preventDefault(),e.stopPropagation(),this.changeClickItem(t))}}},{key:"keyBoardChangeChecked",value:function(e){var t=this.elemListBody.querySelectorAll('[data-sel-position]:not([data-sel-opt-disabled="true"])');if(t.length){var i,s=0;t.forEach((function(e,t){document.activeElement===e&&(s=t,i=e),e.removeAttribute("tabindex")})),(i=i?e?t[s+1]||t[0]:t[s-1]||t[t.length-1]:e?t[0]:t[t.length-1]).tabIndex=0,i.focus()}}},{key:"searchHandlerInit",value:function(e){var t=e.target;if(t){var i=t.value;this.state.setState("filterStr",i)}}},{key:"toggleOpenHandler",value:function(){this.state.getState("isOpen")?(this.elemWrap.classList.add("SimpleSel--open"),document.addEventListener("click",this.closeOutsideHandler),document.addEventListener("keyup",this.closeEscHandler),this.elemInputSearch&&this.elemInputSearch.focus(),this.options.callbackOpen&&this.options.callbackOpen(this),this.countOpen++):(this.state.setState("filterList",""),this.elemWrap.classList.remove("SimpleSel--open"),document.removeEventListener("click",this.closeOutsideHandler),document.removeEventListener("keyup",this.closeEscHandler),this.timeoutDebounceId&&(clearTimeout(this.timeoutDebounceId),this.triggerInit()),this.options.callbackClose&&this.countOpen>0&&this.options.callbackClose(this))}},{key:"changeListenerInit",value:function(e){this.options.callbackChangeSelect&&this.options.callbackChangeSelect(e,this),this.createList(!0)}},{key:"getSelect",value:function(){return this.$select}},{key:"handlerChangeChecked",value:function(){this.elemListBody&&this.elemListBody.addEventListener("mouseup",this.triggerSetup)}},{key:"createList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=[],i=this.$select.querySelectorAll("optgroup");if(i&&i.length?i.forEach((function(e,i){t.push((0,d.getCreateListItem)(e,(i+1).toString(),!0))})):t.push((0,d.getCreateListItem)(this.$select,"1",!1)),e){var s=this.state.getState("items");(0,d.compareObj)(s,t)||this.state.setState("items",t)}else this.state.setState("items",t)}},{key:"filterList",value:function(e){e=e.toLowerCase();var t=(0,d.cloneObj)(this.state.getState("items"));t.forEach((function(t){var i=!1;t.items.forEach((function(t){t.title.toLowerCase().includes(e)?(i=!0,t.isShowFilter=!0):t.isShowFilter=!1})),t.isShowFilter=i})),this.state.setState("items",t)}},{key:"inputSearchHandler",value:function(){this.elemInputSearch&&this.elemInputSearch.addEventListener("input",this.searchHandler)}},{key:"detachItem",value:function(){this.options.callbackDestroyInit&&this.options.callbackDestroyInit(this);var e=this.elemWrap.parentNode;this.$select.removeEventListener("change",this.changeListener),this.elemInputSearch&&this.elemInputSearch.removeEventListener("input",this.searchHandler),this.confirmOk&&this.confirmOk.removeEventListener("click",this.confirmOkHandler),this.confirmNo&&this.confirmNo.removeEventListener("click",this.confirmNoHandler),e.replaceChild(this.$select,this.elemWrap),this.$select.classList.remove(this.classSelectInit),this.elemSelectAll&&this.elemSelectAll.removeEventListener("click",this.selectAllHandler),this.elemResetAll&&this.elemResetAll.removeEventListener("click",this.resetAllHandler),this.options.callbackDestroy&&this.options.callbackDestroy(this),this.elemDropDownClose&&this.elemDropDownClose.removeEventListener("click",this.closeHandler),this.mql&&(this.mql.onchange=null,this.mql=null)}}],i&&n(t.prototype,i),s&&n(t,s),Object.defineProperty(t,"prototype",{writable:!1}),p}(i(844).SimpleSelectItemDOM);t.SimpleSelectItem=p},844:function(e,t,i){function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function n(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return l(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=new Array(t);i<t;i++)s[i]=e[i];return s}function o(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,r(s.key),s)}}function a(e,t,i){return(t=r(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function r(e){var t=function(e,t){if("object"!==s(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===s(t)?t:String(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleSelectItemDOM=void 0;var c=i(679),u=i(972),h=i(737),d=function(){function e(t,i,s){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),a(this,"options",void 0),a(this,"$select",void 0),a(this,"id",void 0),a(this,"titlePlaceholder",void 0),a(this,"isDisabled",!1),a(this,"isMulti",void 0),a(this,"state",(0,u.store)({items:[],isOpen:!1,filterStr:"",isFloat:!1})),a(this,"classSelectInit",(0,c.getClass)("select_init")),a(this,"isNative",void 0),a(this,"elemWrap",document.createElement("div")),a(this,"elemTop",document.createElement("div")),a(this,"elemTopBody",document.createElement("div")),a(this,"elemDropDown",null),a(this,"elemDropDownClose",null),a(this,"elemListBody",null),a(this,"elemInputSearch",null),a(this,"elemTitle",void 0),a(this,"confirmOk",null),a(this,"confirmNo",null),a(this,"elemControl",null),a(this,"elemSelectAll",null),a(this,"elemResetAll",null),a(this,"cloneClasses",""),a(this,"isShowCheckbox",!1),a(this,"bodyLiHTMLBeforeFromSelect",null),a(this,"bodyLiHTMLAfterFromSelect",null),a(this,"isFloatWidth",!1),a(this,"bodyOpenClass","".concat(h.initClass,"--body_open"));var n=s.id,l=s.isNative;this.$select=t,this.isMulti=t.multiple,this.id=n,this.isNative=l,this.options=(0,c.cloneObj)(i),this.options.isCloneClass&&(this.cloneClasses=this.$select.className),i.callbackInitialization&&(this.options.callbackInitialization=i.callbackInitialization),i.callbackInitialized&&(this.options.callbackInitialized=i.callbackInitialized),i.callbackOpen&&(this.options.callbackOpen=i.callbackOpen),i.callbackClose&&(this.options.callbackClose=i.callbackClose),i.callbackDestroyInit&&(this.options.callbackDestroyInit=i.callbackDestroyInit),i.callbackDestroy&&(this.options.callbackDestroy=i.callbackDestroy),i.callbackChangeSelect&&(this.options.callbackChangeSelect=i.callbackChangeSelect),i.changeBodyLi&&(this.options.changeBodyLi=i.changeBodyLi);var o=this.$select.dataset[(0,c.toCamelCase)("simple-is-confirm")];this.isMulti&&o&&(this.options.isConfirmInMulti="1"===o||"true"===o),this.optionOverride(),this.isDisabled=this.$select.disabled}var t,i,s;return t=e,(i=[{key:"optionOverride",value:function(){var e=(0,c.toCamelCase)("simple-placeholder");this.$select.dataset[e]?this.titlePlaceholder=this.$select.dataset[e]||"":this.titlePlaceholder=this.options.locale.title;var t=(0,c.toCamelCase)("simple-reset-all");if(t in this.$select.dataset){var i=this.$select.dataset[t];this.options.resetAll=!("false"===i||"0"===i)}if(this.$select.hasAttribute("data-simple-select-all")){var s=this.$select.getAttribute("data-simple-select-all");this.options.selectAll=(0,c.ifTrueDataAttr)(s)}var n=this.$select.dataset[(0,c.toCamelCase)("simple-show-checkbox")];this.isMulti?this.isShowCheckbox=!(n&&!(0,c.ifTrueDataAttr)(n)):"true"===n&&(this.isShowCheckbox=!0);var l=this.$select.dataset[(0,c.toCamelCase)("simple-item-html-before")];l&&(this.bodyLiHTMLBeforeFromSelect=l);var o=this.$select.dataset[(0,c.toCamelCase)("simple-item-html-after")];o&&(this.bodyLiHTMLAfterFromSelect=o),this.$select.hasAttribute("data-simple-up")&&(this.options.isUp=(0,c.ifTrueDataAttr)(this.$select.getAttribute("data-simple-up")))}},{key:"initDom",value:function(){var e=this;this.createList(!1),this.createHTML(),this.state.subscribe("items",(function(t){e.createListHTML(),e.createTitleHTML()})),this.state.subscribe("isOpen",(function(t){e.createListHTML(),e.createTitleHTML(),e.toggleTabIndex(t)})),this.state.subscribe("isFloat",(function(t){e.isFloatWidth=t;var i=(0,c.getClass)("float",!0);e.elemWrap.classList.toggle(i,t)}))}},{key:"toggleTabIndex",value:function(e){var t=e?0:-1;this.state.getState("isFloat")&&document.body.classList.toggle(this.bodyOpenClass,e),this.elemInputSearch&&(this.elemInputSearch.tabIndex=t),this.elemResetAll&&(this.elemResetAll.tabIndex=t),this.elemSelectAll&&(this.elemSelectAll.tabIndex=t),this.confirmOk&&(this.confirmOk.tabIndex=t),this.confirmNo&&(this.confirmNo.tabIndex=t)}},{key:"updateHTML",value:function(){this.createList(!0)}},{key:"createHTML",value:function(){this.$select.classList.add(this.classSelectInit),this.$select.tabIndex=-1,this.elemTopBody.className=(0,c.getClass)("top_body"),this.elemTopBody.tabIndex=this.isDisabled?-1:0,this.createIcon(),this.elemTop.append(this.elemTopBody);var e=h.initClass;this.options.isCloneClass&&(e+=" ".concat(this.cloneClasses)),this.$select.hasAttribute("data-simple-add-classes")&&(e+=" ".concat(this.$select.getAttribute("data-simple-add-classes"))),this.isDisabled&&(e+=" ".concat((0,c.getClass)("disabled",!0))),this.options.isUp&&(e+=" ".concat((0,c.getClass)("up",!0))),e+=" ".concat(this.isMulti?(0,c.getClass)("multi",!0):(0,c.getClass)("single",!0)),this.elemWrap.className=e,this.elemWrap.dataset.countAll=this.$select.options.length.toString(),this.elemTop.className=(0,c.getClass)("top");var t=this.$select.parentNode;t&&(t.replaceChild(this.elemWrap,this.$select),this.elemWrap.appendChild(this.$select)),this.elemWrap.append(this.elemTop),this.isNative?(this.$select.classList.add((0,c.getClass)("native",!0,this.classSelectInit)),this.elemWrap.classList.add((0,c.getClass)("native",!0))):(this.createDropDown(),this.createControlHTML(),this.createInputHTML()),this.createTitleHTML()}},{key:"createControlHTML",value:function(){if(this.elemDropDown&&this.isMulti&&(this.options.selectAll||this.options.resetAll)){this.elemControl=document.createElement("div"),this.elemControl.classList.add((0,c.getClass)("controls")),this.elemDropDown.prepend(this.elemControl);var e=(0,c.getClass)("control");this.options.selectAll&&(this.elemSelectAll=(0,c.createButton)(),this.elemSelectAll.className="".concat(e," ").concat((0,c.getClass)("select_all",!0,e)),this.elemSelectAll.innerHTML='<span class="'.concat((0,c.getClass)("select_all__icon"),'"></span> ').concat(this.options.locale.selectAll),this.elemControl.append(this.elemSelectAll)),this.options.resetAll&&(this.elemResetAll=(0,c.createButton)(),this.elemResetAll.className="".concat(e," ").concat((0,c.getClass)("reset_all",!0,e)),this.elemResetAll.innerHTML='<span class="'.concat((0,c.getClass)("reset_all__icon"),'"></span> ').concat(this.options.locale.resetAll),this.elemControl.append(this.elemResetAll))}}},{key:"createIcon",value:function(){var e=document.createElement("span");e.className=(0,c.getClass)("icon"),this.elemTopBody.append(e)}},{key:"createDropDown",value:function(){this.isNative||(this.elemDropDown=document.createElement("div"),this.elemDropDown.className=(0,c.getClass)("body"),this.elemListBody=document.createElement("ul"),this.elemListBody.className=(0,c.getClass)("list"),this.elemWrap.append(this.elemDropDown),this.elemDropDown.append(this.elemListBody),this.elemDropDownClose=(0,c.createButton)(),this.elemDropDownClose.classList.add((0,c.getClass)("close")),this.elemDropDown.append(this.elemDropDownClose),this.isMulti&&this.createIsConfirmInMultiHTML(),this.handlerChangeChecked())}},{key:"createIsConfirmInMultiHTML",value:function(){var e,t=document.createElement("div"),i=(0,c.getClass)("bottom_control");this.confirmOk=(0,c.createButton)(),this.confirmNo=(0,c.createButton)(),t.append(this.confirmOk),t.append(this.confirmNo),this.confirmOk.innerHTML=this.options.locale.ok,this.confirmNo.innerHTML=this.options.locale.cansel,this.confirmOk.className="".concat(i," ").concat((0,c.getClass)("ok",!0,i)),this.confirmNo.className="".concat(i," ").concat((0,c.getClass)("no",!0,i));var s=(0,c.getClass)("bottom_controls");this.options.isConfirmInMulti||(s+=" ".concat((0,c.getClass)("hide",!0,s))),t.className=s,null===(e=this.elemDropDown)||void 0===e||e.append(t)}},{key:"createTitleHTML",value:function(){var e=this;this.elemTitle||(this.elemTitle=document.createElement("div"),this.elemTitle.className=(0,c.getClass)("title"),this.elemTopBody.prepend(this.elemTitle));var t=this.getChecked();this.elemTop.title="";var i=!t.length,s=this.titlePlaceholder;if(t.length){var n="";t.forEach((function(t,i){0!==i&&(n+="".concat(e.options.sepChars,'<span class="').concat((0,c.getClass)("sep_space",!0),'">&nbsp;</span>')),n+="".concat(t.title)})),this.elemTop.title=n;var l=this.options.countShowSelected,o=Number(this.$select.dataset.simpleCountShowsSelected);o&&o>0&&(l=o),t.length>l?(s="".concat(this.options.locale.selected," ").concat(t.length),this.$select.querySelectorAll("option").length===t.length&&(s+=" (".concat(this.options.locale.all,")"))):n&&(s=n)}this.elemTitle.innerHTML=s,this.elemTitle.classList.toggle("SimpleSel__title--placeholder",i),this.elemTitle.classList.toggle("SimpleSel__title--fill",!i),this.elemWrap.classList.toggle((0,c.getClass)("fill",!0),!i)}},{key:"createListHTML",value:function(){var e=this;if(this.elemListBody){var t="",i=0,s=0,n=0;this.state.getState("items").forEach((function(l){if(l.isGroup){var o=e.createLi(l),a=o.result,r=o.countShow,u=o.countChecked,h=o.countCheckedFull;t+='<div class="'.concat((0,c.getClass)("group_items"),'">'),t+=a,t+="</div>",s+=u,i+=r,n+=h}else{var d=e.createLi(l),p=d.result,m=d.countShow,f=d.countChecked,v=d.countCheckedFull;t+=p,i+=m,s+=f,n+=v}}));var l=this.state.getState("filterStr");l&&l.length&&0===i&&(t='<div class="'.concat((0,c.getClass)("no_match"),'">'),t="".concat(this.options.locale.noSearch,' "').concat(l,'"'),t+="</div>"),this.elemWrap.dataset.countChecked=s.toString(),this.elemWrap.dataset.countCheckedFull=n.toString(),this.isMulti&&(this.elemWrap.dataset.checkAllMulti=this.$select.options.length===s?"yes":"no"),this.elemListBody.innerHTML=t}}},{key:"createInputHTML",value:function(){var e=this.options.isSearch,t=this.options.isSearchInDropdown;if("simpleSelectSearch"in this.$select.dataset&&(e="false"!==this.$select.dataset.simpleSelectSearch),"simpleSelectSearchDropdown"in this.$select.dataset&&(t="false"!==this.$select.dataset.simpleSelectSearchDropdown),e||t){this.elemInputSearch=document.createElement("input"),this.elemInputSearch.type="text",this.elemInputSearch.tabIndex=-1,this.elemInputSearch.autocomplete="off",this.elemInputSearch.ariaAutoComplete="none",this.elemInputSearch.inputMode="off",this.elemInputSearch.placeholder=this.options.locale.searchText,this.elemInputSearch.name="".concat(h.initClass,"_name_").concat(this.id);var i=(0,c.getClass)("search");t?this.elemDropDown&&(this.elemInputSearch.className="".concat(i," ").concat((0,c.getClass)("dropdown",!0,i)),this.elemDropDown.prepend(this.elemInputSearch)):(this.elemInputSearch.className="".concat(i," ").concat((0,c.getClass)("top",!0,i)),this.elemTop.append(this.elemInputSearch)),this.inputSearchHandler()}}},{key:"getChecked",value:function(){var e=this.state.getState("items"),t=[];return e.forEach((function(e){t=[].concat(n(t),n(e.items.filter((function(e){return e.checked}))))})),t}},{key:"createLi",value:function(e){var t=this,i="",s=0,n=0,l=0;return e.isShowFilter?(e.isGroup&&(i+='<label class="'.concat((0,c.getClass)("group_title"),'">').concat(e.titleGroup,"</label>"),i+='<ul class="'.concat((0,c.getClass)("group"),'">')),e.items.forEach((function(o){if(o.isShowFilter){s++;var a=(0,c.getClass)("list_item"),r=a;o.checked&&(n++,r+=" ".concat((0,c.getClass)("checked",!0,a)),o.value&&l++),o.disabled&&(r+=" ".concat((0,c.getClass)("disabled",!0,a))),o.value||(r+=" ".concat((0,c.getClass)("not_value",!0,a)));var u='data-sel-group-id="'.concat(e.idGroup,'"');u+=' data-sel-position="'.concat(o.position,'"'),u+=' data-sel-id="'.concat(o.id,'"'),o.value&&(u+=' data-sel-value="'.concat(o.value,'"')),u+=" data-sel-opt-item",u+=' data-sel-opt-checked="'.concat(o.checked,'"'),u+=' data-sel-opt-disabled="'.concat(o.disabled,'"'),i+='<li class="'.concat(r,'" ').concat(u,">");var h=t.createLiBody(o,t.$select.options[o.position]);i+="string"==typeof h?h:h.outerHTML,i+="</li>"}})),e.isGroup&&(i+="</ul>"),{result:i,countShow:s,countChecked:n,countCheckedFull:l}):{result:i,countShow:s,countChecked:n,countCheckedFull:l}}},{key:"createLiBody",value:function(e,t){var i=document.createElement("div");i.className=(0,c.getClass)("list_item_body");var s="";return this.isShowCheckbox&&(s='<span class="'.concat((0,c.getClass)("list_item_icon"),'"></span>')),this.bodyLiHTMLBeforeFromSelect&&(s+=this.bodyLiHTMLBeforeFromSelect),t.hasAttribute("data-simple-html-before")&&(s+=t.getAttribute("data-simple-html-before")),s+="".concat(e.title),this.bodyLiHTMLAfterFromSelect&&(s+=this.bodyLiHTMLAfterFromSelect),t.hasAttribute("data-simple-html-after")&&(s+=t.getAttribute("data-simple-html-after")),i.innerHTML=s,this.options.changeBodyLi?this.options.changeBodyLi(i,t):i}},{key:"handlerChangeChecked",value:function(){console.error("This method need redefine")}},{key:"createList",value:function(e){console.error("This method need redefine")}},{key:"inputSearchHandler",value:function(){console.error("This method need redefine")}}])&&o(t.prototype,i),s&&o(t,s),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.SimpleSelectItemDOM=d},679:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.createButton=t.cloneObj=t.compareObj=t.getClass=t.getCreateListItem=t.triggerInputEvent=t.ifTrueDataAttr=t.createDataAttr=t.toCamelCase=void 0;var s=i(737);t.toCamelCase=function(e){return e.replace(/-([a-z])/g,(function(e,t){return t.toUpperCase()}))};t.createDataAttr=function(e){return"data-".concat(e)};t.ifTrueDataAttr=function(e){return!!e&&("true"===e||"1"===e)},t.triggerInputEvent=function(e){var t=new Event(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"change",{bubbles:!0,cancelable:!0});e.dispatchEvent(t)};t.getCreateListItem=function(e,t,i){var s=e.querySelectorAll("option"),n=[];s.forEach((function(e,t){n.push({id:(t+1).toString(),position:e.index,title:e.innerHTML,value:e.getAttribute("value"),checked:e.selected,disabled:e.disabled,isShowFilter:!0})}));var l={isGroup:i,idGroup:t,items:n,isShowFilter:!0};return e instanceof HTMLOptGroupElement&&(l.titleGroup=e.label||"",l.isDisabledGroup=e.disabled||!1),l};t.getClass=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s.initClass,n=t?"--":"__";return"".concat(i).concat(n).concat(e)};t.compareObj=function(e,t){return JSON.stringify(e)===JSON.stringify(t)};t.cloneObj=function(e){return JSON.parse(JSON.stringify(e))};t.createButton=function(){var e=document.createElement("button");return e.type="button",e.tabIndex=-1,e}},972:function(e,t){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function n(e,t,s){return(t=function(e){var t=function(e,t){if("object"!==i(e)||null===e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var n=s.call(e,t||"default");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===i(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}Object.defineProperty(t,"__esModule",{value:!0}),t.store=void 0,t.store=function(e){var t={},i={},l=[],o=function(e){return e?e in t?t[e]:null:t},a=function(e,o){var a=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?s(Object(i),!0).forEach((function(t){n(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},t),r=t[e]||0==t[e]?t[e]:null;t[e]=o,e in i&&i[e].forEach((function(e){return e(o,r,t)})),l.forEach((function(i){return i(e,a,t)}))};return e&&Object.keys(e).forEach((function(t){a(t,e[t])})),{getState:o,setState:a,subscribe:function(e,t){e in i||(i[e]=[]),i[e].push(t);var s=o(e);return t(s,null,o()),function(){i[e]=i[e].filter((function(e){return e!==t}))}},subscribeAll:function(e){return l.push(e),e(null,null,o()),function(){l=l.filter((function(t){return t!==e}))}},unSubscribe:function(e,t){e in i&&(i[e]=i[e].filter((function(e){return e!==t})))}}}},181:function(e,t,i){i.r(t)}},t={};function i(s){var n=t[s];if(void 0!==n)return n.exports;var l=t[s]={exports:{}};return e[s](l,l.exports,i),l.exports}i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return function(){var e=s;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function l(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?n(Object(i),!0).forEach((function(t){a(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function o(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,r(s.key),s)}}function a(e,t,i){return(t=r(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function r(e){var i=function(e,i){if("object"!==t(e)||null===e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var n=s.call(e,i||"default");if("object"!==t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===i?String:Number)(e)}(e,"string");return"symbol"===t(i)?i:String(i)}var c=i(737),u=i(679),h=i(874);i(181);var d=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),a(this,"callCount",Date.now()),a(this,"countInit",0),a(this,"$selects",[]),a(this,"options",void 0),a(this,"nameMarkTransform",(0,u.toCamelCase)(c.nameMark)),a(this,"dataNameMark",(0,u.createDataAttr)(c.nameMark)),a(this,"isNative",void 0),t||(t="select"),this.options=l(l({},c.simpleSelectionOptions),i),"string"==typeof t?this.init(Array.from(document.querySelectorAll(t))):t instanceof HTMLSelectElement?this.init([t]):t instanceof NodeList?this.init(Array.from(t)):Array.isArray(t)?this.init(t):console.warn("Wrong selector: ",t)}var t,i,s;return t=e,(i=[{key:"detectMobile",value:function(){if(this.options.detectNative)this.isNative=this.options.detectNative();else{for(var e=navigator.userAgent||navigator.vendor||window.opera,t=!1,i=0;i<this.options.nativeOnDevice.length;i++)e.toString().toLowerCase().indexOf(this.options.nativeOnDevice[i].toLowerCase())>0&&this.options.nativeOnDevice[i]&&(t=!0);this.isNative=t}}},{key:"init",value:function(e){var t=this;this.detectMobile(),e.forEach((function(e){t.build(e)}))}},{key:"createMethods",value:function(e){var t=this;return{getInstance:function(){return e.getSelect()},reload:function(){t.rebuild(e)},update:function(){e.updateHTML()},detach:function(){t.detach(e)}}}},{key:"setMethods",value:function(e){e.$select[c.nameSelect]=this.createMethods(e)}},{key:"setMethodsClear",value:function(e){delete e.$select[c.nameSelect]}},{key:"build",value:function(e){if(this.nameMarkTransform in e.dataset)console.warn("This element has already been initialized",e);else{this.countInit+=1;var t="".concat(this.callCount,"-").concat(this.countInit);e.setAttribute(this.dataNameMark,t);var i=new h.SimpleSelectItem(e,this.options,{id:t,isNative:this.isNative});this.$selects.push(i),this.setMethods(i)}}},{key:"detach",value:function(e){e.detachItem(),e.$select.removeAttribute(this.dataNameMark),this.setMethodsClear(e),this.$selects=this.$selects.filter((function(t){return t!==e}))}},{key:"rebuild",value:function(e){var t=e.$select;this.detach(e),this.build(t)}},{key:"getSelects",value:function(){return this.$selects}},{key:"getSelectFirst",value:function(){return this.createMethods(this.$selects[0])}},{key:"getSelectById",value:function(e){var t=this.$selects.filter((function(t){return t.id===e}))[0];return t?this.createMethods(t):null}}])&&o(t.prototype,i),s&&o(t,s),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.default=d}(),s=s.default}()}));