vgapp 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/modules/vgselect/js/vgselect.js +41 -23
- package/build/vgapp.css +4942 -10
- package/build/vgapp.js +4275 -3
- package/build/vgapp.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import BaseModule from "../../base-module";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
execute,
|
|
4
|
+
isDisabled,
|
|
5
|
+
isEmptyObj,
|
|
6
|
+
mergeDeepObject,
|
|
7
|
+
noop,
|
|
8
|
+
normalizeData,
|
|
9
|
+
transliterate
|
|
10
|
+
} from "../../../utils/js/functions";
|
|
3
11
|
import {Manipulator} from "../../../utils/js/dom/manipulator";
|
|
4
12
|
import EventHandler from "../../../utils/js/dom/event";
|
|
5
13
|
import Selectors from "../../../utils/js/dom/selectors";
|
|
@@ -57,6 +65,7 @@ class VGSelect extends BaseModule {
|
|
|
57
65
|
}, params));
|
|
58
66
|
|
|
59
67
|
this._drop = Selectors.find('.' + CLASS_NAME_DROPDOWN, this._element);
|
|
68
|
+
this.refresh();
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
static get NAME() {
|
|
@@ -135,11 +144,17 @@ class VGSelect extends BaseModule {
|
|
|
135
144
|
}
|
|
136
145
|
}
|
|
137
146
|
|
|
138
|
-
static build(selector) {
|
|
147
|
+
static build(selector, reBuild) {
|
|
139
148
|
let option_selected,
|
|
140
149
|
placeholder = selector.dataset.placeholder || '',
|
|
141
150
|
isSearch = selector.dataset.search || false;
|
|
142
151
|
|
|
152
|
+
if (selector.dataset?.inited === 'true' && !reBuild) {
|
|
153
|
+
return;
|
|
154
|
+
} else if (reBuild) {
|
|
155
|
+
VGSelect.destroy(selector);
|
|
156
|
+
}
|
|
157
|
+
|
|
143
158
|
selector.parentElement.style.position = 'relative';
|
|
144
159
|
|
|
145
160
|
if (placeholder && selector.selectedIndex === 0) {
|
|
@@ -210,6 +225,8 @@ class VGSelect extends BaseModule {
|
|
|
210
225
|
if (list) list.remove();
|
|
211
226
|
|
|
212
227
|
VGSelect.buildListOptions(selector, this._drop);
|
|
228
|
+
|
|
229
|
+
execute(callback, [this, selector]);
|
|
213
230
|
}
|
|
214
231
|
|
|
215
232
|
toggle(relatedTarget) {
|
|
@@ -296,30 +313,13 @@ class VGSelect extends BaseModule {
|
|
|
296
313
|
return this._element.classList.contains(CLASS_NAME_SHOW);
|
|
297
314
|
}
|
|
298
315
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (element) {
|
|
303
|
-
if (element.classList.contains(CLASS_NAME_CONTAINER)) {
|
|
304
|
-
element.remove();
|
|
305
|
-
|
|
306
|
-
select.selectedIndex = 0;
|
|
307
|
-
[...select.querySelectorAll('option')].forEach(function (el, index) {
|
|
308
|
-
if (el.hasAttribute('selected')) {
|
|
309
|
-
select.selectedIndex = index;
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
refresh(select) {
|
|
317
|
-
const _this = this;
|
|
316
|
+
refresh() {
|
|
317
|
+
const select = this._element.previousSibling;
|
|
318
318
|
|
|
319
319
|
let observer = new MutationObserver(() => {
|
|
320
320
|
clearTimeout(observerTimout);
|
|
321
321
|
observerTimout = setTimeout(() => {
|
|
322
|
-
|
|
322
|
+
VGSelect.build(select, true);
|
|
323
323
|
}, 100);
|
|
324
324
|
});
|
|
325
325
|
|
|
@@ -339,6 +339,23 @@ class VGSelect extends BaseModule {
|
|
|
339
339
|
super.dispose();
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
+
static destroy(select) {
|
|
343
|
+
let element = select.nextElementSibling;
|
|
344
|
+
|
|
345
|
+
if (element) {
|
|
346
|
+
if (element.classList.contains(CLASS_NAME_CONTAINER)) {
|
|
347
|
+
element.remove();
|
|
348
|
+
|
|
349
|
+
select.selectedIndex = 0;
|
|
350
|
+
[...select.querySelectorAll('option')].forEach(function (el, index) {
|
|
351
|
+
if (el.hasAttribute('selected')) {
|
|
352
|
+
select.selectedIndex = index;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
342
359
|
static hideOpenToggles(event) {
|
|
343
360
|
const openToggles = Selectors.findAll('.vg-select:not(.disabled):not(:disabled).show');
|
|
344
361
|
|
|
@@ -421,7 +438,8 @@ EventHandler.on(document, EVENT_KEY_CLICK_DATA_API, SELECTOR_OPTION_TOGGLE, func
|
|
|
421
438
|
|
|
422
439
|
let select = container.previousSibling;
|
|
423
440
|
select.value = el.dataset.value;
|
|
424
|
-
EventHandler.trigger(select, EVENT_KEY_CHANGE, {value: el.dataset.value});
|
|
441
|
+
EventHandler.trigger(select, EVENT_KEY_CHANGE, {value: normalizeData(el.dataset.value)});
|
|
442
|
+
EventHandler.trigger(select, 'change', {value: normalizeData(el.dataset.value)});
|
|
425
443
|
}
|
|
426
444
|
});
|
|
427
445
|
|