slim-select 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,7 +68,7 @@ var SlimSelectVue = (function (vue) {
68
68
  this.id = 'ss-' + generateID();
69
69
  this.style = settings.style || '';
70
70
  this.class = settings.class || [];
71
- this.isEnabled = settings.isEnabled !== undefined ? settings.isEnabled : true;
71
+ this.disabled = settings.disabled !== undefined ? settings.disabled : false;
72
72
  this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
73
73
  this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
74
74
  this.searchPlaceholder = settings.searchPlaceholder || 'Search';
@@ -86,6 +86,8 @@ var SlimSelectVue = (function (vue) {
86
86
  this.minSelected = settings.minSelected || 0;
87
87
  this.maxSelected = settings.maxSelected || 1000;
88
88
  this.timeoutDelay = settings.timeoutDelay || 200;
89
+ this.maxValuesShown = settings.maxValuesShown || 20;
90
+ this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
89
91
  }
90
92
  }
91
93
 
@@ -302,6 +304,7 @@ var SlimSelectVue = (function (vue) {
302
304
  placeholder: 'ss-placeholder',
303
305
  values: 'ss-values',
304
306
  single: 'ss-single',
307
+ max: 'ss-max',
305
308
  value: 'ss-value',
306
309
  valueText: 'ss-value-text',
307
310
  valueDelete: 'ss-value-delete',
@@ -358,23 +361,7 @@ var SlimSelectVue = (function (vue) {
358
361
  this.main.main.classList.add(this.settings.openPosition === 'up' ? this.classes.openAbove : this.classes.openBelow);
359
362
  this.moveContent();
360
363
  this.renderOptions(this.store.getData());
361
- if (this.settings.contentPosition === 'relative') {
362
- this.moveContentBelow();
363
- }
364
- else if (this.settings.openPosition.toLowerCase() === 'up') {
365
- this.moveContentAbove();
366
- }
367
- else if (this.settings.openPosition.toLowerCase() === 'down') {
368
- this.moveContentBelow();
369
- }
370
- else {
371
- if (this.putContent(this.content.main, this.settings.isOpen) === 'up') {
372
- this.moveContentAbove();
373
- }
374
- else {
375
- this.moveContentBelow();
376
- }
377
- }
364
+ this.moveContent();
378
365
  const selectedOptions = this.store.getSelectedOptions();
379
366
  if (selectedOptions.length) {
380
367
  const selectedId = selectedOptions[selectedOptions.length - 1].id;
@@ -432,7 +419,7 @@ var SlimSelectVue = (function (vue) {
432
419
  }
433
420
  };
434
421
  main.onclick = (e) => {
435
- if (!this.settings.isEnabled) {
422
+ if (this.settings.disabled) {
436
423
  return;
437
424
  }
438
425
  this.settings.isOpen ? this.callbacks.close() : this.callbacks.open();
@@ -447,7 +434,7 @@ var SlimSelectVue = (function (vue) {
447
434
  }
448
435
  deselect.onclick = (e) => {
449
436
  e.stopPropagation();
450
- if (!this.settings.isEnabled) {
437
+ if (this.settings.disabled) {
451
438
  return;
452
439
  }
453
440
  let shouldDelete = true;
@@ -563,6 +550,19 @@ var SlimSelectVue = (function (vue) {
563
550
  placeholder.remove();
564
551
  }
565
552
  }
553
+ if (selectedOptions.length > this.settings.maxValuesShown) {
554
+ const singleValue = document.createElement('div');
555
+ singleValue.classList.add(this.classes.max);
556
+ singleValue.textContent = this.settings.maxValuesMessage.replace('{number}', selectedOptions.length.toString());
557
+ this.main.values.innerHTML = singleValue.outerHTML;
558
+ return;
559
+ }
560
+ else {
561
+ const maxValuesMessage = this.main.values.querySelector('.' + this.classes.max);
562
+ if (maxValuesMessage) {
563
+ maxValuesMessage.remove();
564
+ }
565
+ }
566
566
  let removeNodes = [];
567
567
  for (let i = 0; i < currentNodes.length; i++) {
568
568
  const node = currentNodes[i];
@@ -617,6 +617,9 @@ var SlimSelectVue = (function (vue) {
617
617
  deleteDiv.onclick = (e) => {
618
618
  e.preventDefault();
619
619
  e.stopPropagation();
620
+ if (this.settings.disabled) {
621
+ return;
622
+ }
620
623
  let shouldDelete = true;
621
624
  const before = this.store.getSelectedOptions();
622
625
  const after = before.filter((o) => {
@@ -688,12 +691,23 @@ var SlimSelectVue = (function (vue) {
688
691
  }
689
692
  moveContent() {
690
693
  if (this.settings.contentPosition === 'relative') {
694
+ this.moveContentBelow();
691
695
  return;
692
696
  }
693
- const containerRect = this.main.main.getBoundingClientRect();
694
- this.content.main.style.top = containerRect.top + containerRect.height + window.scrollY + 'px';
695
- this.content.main.style.left = containerRect.left + window.scrollX + 'px';
696
- this.content.main.style.width = containerRect.width + 'px';
697
+ if (this.settings.openPosition === 'down') {
698
+ this.moveContentBelow();
699
+ return;
700
+ }
701
+ else if (this.settings.openPosition === 'up') {
702
+ this.moveContentAbove();
703
+ return;
704
+ }
705
+ if (this.putContent() === 'up') {
706
+ this.moveContentAbove();
707
+ }
708
+ else {
709
+ this.moveContentBelow();
710
+ }
697
711
  }
698
712
  searchDiv() {
699
713
  const main = document.createElement('div');
@@ -904,8 +918,7 @@ var SlimSelectVue = (function (vue) {
904
918
  this.content.list.innerHTML = '';
905
919
  if (data.length === 0) {
906
920
  const noResults = document.createElement('div');
907
- noResults.classList.add(this.classes.option);
908
- noResults.classList.add(this.classes.disabled);
921
+ noResults.classList.add(this.classes.search);
909
922
  noResults.innerHTML = this.settings.searchText;
910
923
  this.content.list.appendChild(noResults);
911
924
  return;
@@ -981,7 +994,7 @@ var SlimSelectVue = (function (vue) {
981
994
  optgroupClosable.appendChild(optgroupClosableSvg);
982
995
  const optgroupClosableArrow = document.createElementNS('http://www.w3.org/2000/svg', 'path');
983
996
  optgroupClosableSvg.appendChild(optgroupClosableArrow);
984
- if (d.options.some((o) => o.selected)) {
997
+ if (d.options.some((o) => o.selected) || this.content.search.input.value.trim() !== '') {
985
998
  optgroupClosable.classList.add(this.classes.open);
986
999
  optgroupClosableArrow.setAttribute('d', this.classes.arrowOpen);
987
1000
  }
@@ -1040,8 +1053,7 @@ var SlimSelectVue = (function (vue) {
1040
1053
  optionEl.style.cssText = option.style;
1041
1054
  }
1042
1055
  if (this.settings.searchHighlight && this.content.search.input.value.trim() !== '') {
1043
- const textOrHtml = option.html !== '' ? option.html : option.text;
1044
- optionEl.innerHTML = this.highlightText(textOrHtml, this.content.search.input.value, this.classes.searchHighlighter);
1056
+ optionEl.innerHTML = this.highlightText(option.html !== '' ? option.html : option.text, this.content.search.input.value, this.classes.searchHighlighter);
1045
1057
  }
1046
1058
  else if (option.html !== '') {
1047
1059
  optionEl.innerHTML = option.html;
@@ -1052,7 +1064,7 @@ var SlimSelectVue = (function (vue) {
1052
1064
  if (this.settings.showOptionTooltips && optionEl.textContent) {
1053
1065
  optionEl.setAttribute('title', optionEl.textContent);
1054
1066
  }
1055
- if ((option.selected && !this.settings.allowDeselect) || (option.disabled && !this.settings.allowDeselect)) {
1067
+ if (option.disabled) {
1056
1068
  optionEl.classList.add(this.classes.disabled);
1057
1069
  }
1058
1070
  if (option.selected && this.settings.hideSelected) {
@@ -1073,9 +1085,8 @@ var SlimSelectVue = (function (vue) {
1073
1085
  if (option.disabled || (option.selected && !this.settings.allowDeselect)) {
1074
1086
  return;
1075
1087
  }
1076
- if (this.settings.isMultiple &&
1077
- Array.isArray(selectedOptions) &&
1078
- this.settings.maxSelected <= selectedOptions.length) {
1088
+ if ((this.settings.isMultiple && this.settings.maxSelected <= selectedOptions.length && !option.selected) ||
1089
+ (this.settings.isMultiple && this.settings.minSelected >= selectedOptions.length && option.selected)) {
1079
1090
  return;
1080
1091
  }
1081
1092
  let shouldUpdate = false;
@@ -1140,23 +1151,30 @@ var SlimSelectVue = (function (vue) {
1140
1151
  return completedString;
1141
1152
  }
1142
1153
  moveContentAbove() {
1143
- let mainHeight = this.main.main.offsetHeight;
1154
+ const mainHeight = this.main.main.offsetHeight;
1144
1155
  const contentHeight = this.content.main.offsetHeight;
1145
- const height = mainHeight + contentHeight - 1;
1146
- this.content.main.style.margin = '-' + height + 'px 0px 0px 0px';
1147
- this.content.main.style.transformOrigin = 'center bottom';
1148
1156
  this.main.main.classList.remove(this.classes.openBelow);
1149
1157
  this.main.main.classList.add(this.classes.openAbove);
1150
1158
  this.content.main.classList.remove(this.classes.openBelow);
1151
1159
  this.content.main.classList.add(this.classes.openAbove);
1160
+ const containerRect = this.main.main.getBoundingClientRect();
1161
+ this.content.main.style.margin = '-' + (mainHeight + contentHeight - 1) + 'px 0px 0px 0px';
1162
+ this.content.main.style.top = containerRect.top + containerRect.height + window.scrollY + 'px';
1163
+ this.content.main.style.left = containerRect.left + window.scrollX + 'px';
1164
+ this.content.main.style.width = containerRect.width + 'px';
1152
1165
  }
1153
1166
  moveContentBelow() {
1154
- this.content.main.style.margin = '-1px 0px 0px 0px';
1155
- this.content.main.style.transformOrigin = 'center top';
1156
1167
  this.main.main.classList.remove(this.classes.openAbove);
1157
1168
  this.main.main.classList.add(this.classes.openBelow);
1158
1169
  this.content.main.classList.remove(this.classes.openAbove);
1159
1170
  this.content.main.classList.add(this.classes.openBelow);
1171
+ const containerRect = this.main.main.getBoundingClientRect();
1172
+ this.content.main.style.margin = '-1px 0px 0px 0px';
1173
+ if (this.settings.contentPosition !== 'relative') {
1174
+ this.content.main.style.top = containerRect.top + containerRect.height + window.scrollY + 'px';
1175
+ this.content.main.style.left = containerRect.left + window.scrollX + 'px';
1176
+ this.content.main.style.width = containerRect.width + 'px';
1177
+ }
1160
1178
  }
1161
1179
  ensureElementInView(container, element) {
1162
1180
  const cTop = container.scrollTop + container.offsetTop;
@@ -1170,16 +1188,18 @@ var SlimSelectVue = (function (vue) {
1170
1188
  container.scrollTop += eBottom - cBottom;
1171
1189
  }
1172
1190
  }
1173
- putContent(el, isOpen) {
1174
- const height = el.offsetHeight;
1175
- const rect = el.getBoundingClientRect();
1176
- const elemTop = isOpen ? rect.top : rect.top - height;
1177
- const elemBottom = isOpen ? rect.bottom : rect.bottom + height;
1178
- if (elemTop <= 0) {
1179
- return 'down';
1180
- }
1181
- if (elemBottom >= window.innerHeight) {
1182
- return 'up';
1191
+ putContent() {
1192
+ const mainHeight = this.main.main.offsetHeight;
1193
+ const mainRect = this.main.main.getBoundingClientRect();
1194
+ const contentHeight = this.content.main.offsetHeight;
1195
+ const spaceBelow = window.innerHeight - (mainRect.top + mainHeight);
1196
+ if (spaceBelow <= contentHeight) {
1197
+ if (mainRect.top > contentHeight) {
1198
+ return 'up';
1199
+ }
1200
+ else {
1201
+ return 'down';
1202
+ }
1183
1203
  }
1184
1204
  return 'down';
1185
1205
  }
@@ -1190,16 +1210,17 @@ var SlimSelectVue = (function (vue) {
1190
1210
  this.listen = false;
1191
1211
  this.observer = null;
1192
1212
  this.select = select;
1213
+ this.select.addEventListener('change', this.valueChange.bind(this), {
1214
+ passive: true,
1215
+ });
1216
+ this.observer = new MutationObserver(this.observeCall.bind(this));
1217
+ this.changeListen(true);
1193
1218
  }
1194
1219
  enable() {
1195
- this.disconnectObserver();
1196
1220
  this.select.disabled = false;
1197
- this.connectObserver();
1198
1221
  }
1199
1222
  disable() {
1200
- this.disconnectObserver();
1201
1223
  this.select.disabled = true;
1202
- this.connectObserver();
1203
1224
  }
1204
1225
  hideUI() {
1205
1226
  this.select.tabIndex = -1;
@@ -1211,65 +1232,54 @@ var SlimSelectVue = (function (vue) {
1211
1232
  this.select.style.display = '';
1212
1233
  this.select.removeAttribute('aria-hidden');
1213
1234
  }
1214
- changeListen(on) {
1215
- this.listen = on;
1216
- if (this.listen) {
1217
- this.connectObserver();
1235
+ changeListen(listen) {
1236
+ this.listen = listen;
1237
+ if (listen) {
1238
+ if (this.observer) {
1239
+ this.observer.observe(this.select, {
1240
+ subtree: true,
1241
+ childList: true,
1242
+ attributes: true,
1243
+ });
1244
+ }
1218
1245
  }
1219
- else {
1220
- this.disconnectObserver();
1246
+ if (!listen) {
1247
+ if (this.observer) {
1248
+ this.observer.disconnect();
1249
+ }
1221
1250
  }
1222
1251
  }
1223
- addSelectChangeListener(func) {
1224
- this.onSelectChange = func;
1225
- this.addObserver();
1226
- this.connectObserver();
1227
- this.changeListen(true);
1228
- }
1229
- removeSelectChangeListener() {
1230
- this.changeListen(false);
1231
- this.onSelectChange = undefined;
1232
- }
1233
- addValueChangeListener(func) {
1234
- this.onValueChange = func;
1235
- this.select.addEventListener('change', this.valueChange.bind(this), {
1236
- passive: true,
1237
- });
1238
- }
1239
- removeValueChangeListener() {
1240
- this.onValueChange = undefined;
1241
- this.select.removeEventListener('change', this.valueChange.bind(this));
1242
- }
1243
1252
  valueChange(ev) {
1244
1253
  if (this.listen && this.onValueChange) {
1245
1254
  this.onValueChange(this.getSelectedValues());
1246
1255
  }
1247
1256
  return true;
1248
1257
  }
1249
- observeWrapper(mutations) {
1250
- if (this.onSelectChange) {
1251
- this.changeListen(false);
1252
- this.onSelectChange(this.getData());
1253
- this.changeListen(true);
1258
+ observeCall(mutations) {
1259
+ if (!this.listen) {
1260
+ return;
1254
1261
  }
1255
- }
1256
- addObserver() {
1257
- if (this.observer) {
1258
- this.disconnectObserver();
1259
- this.observer = null;
1262
+ let disabledChanged = false;
1263
+ let optgroupOptionChanged = false;
1264
+ for (const m of mutations) {
1265
+ if (m.target === this.select) {
1266
+ if (m.attributeName === 'disabled') {
1267
+ disabledChanged = true;
1268
+ }
1269
+ }
1270
+ if (m.target.nodeName === 'OPTGROUP' || m.target.nodeName === 'OPTION') {
1271
+ optgroupOptionChanged = true;
1272
+ }
1260
1273
  }
1261
- this.observer = new MutationObserver(this.observeWrapper.bind(this));
1262
- }
1263
- connectObserver() {
1264
- if (this.observer) {
1265
- this.observer.observe(this.select, {
1266
- childList: true,
1267
- });
1274
+ if (disabledChanged && this.onDisabledChange) {
1275
+ this.changeListen(false);
1276
+ this.onDisabledChange(this.select.disabled);
1277
+ this.changeListen(true);
1268
1278
  }
1269
- }
1270
- disconnectObserver() {
1271
- if (this.observer) {
1272
- this.observer.disconnect();
1279
+ if (optgroupOptionChanged && this.onOptionsChange) {
1280
+ this.changeListen(false);
1281
+ this.onOptionsChange(this.getData());
1282
+ this.changeListen(true);
1273
1283
  }
1274
1284
  }
1275
1285
  getData() {
@@ -1287,7 +1297,7 @@ var SlimSelectVue = (function (vue) {
1287
1297
  }
1288
1298
  getDataFromOptgroup(optgroup) {
1289
1299
  let data = {
1290
- id: (optgroup.dataset ? optgroup.dataset.id : false) || '',
1300
+ id: optgroup.id,
1291
1301
  label: optgroup.label,
1292
1302
  selectAll: optgroup.dataset ? optgroup.dataset.selectall === 'true' : false,
1293
1303
  closable: optgroup.dataset ? optgroup.dataset.closable : 'off',
@@ -1303,10 +1313,10 @@ var SlimSelectVue = (function (vue) {
1303
1313
  }
1304
1314
  getDataFromOption(option) {
1305
1315
  return {
1306
- id: (option.dataset ? option.dataset.id : false) || '',
1316
+ id: option.id,
1307
1317
  value: option.value,
1308
1318
  text: option.text,
1309
- html: option.innerHTML,
1319
+ html: option.dataset && option.dataset.html ? option.dataset.html : '',
1310
1320
  selected: option.selected,
1311
1321
  display: option.style.display === 'none' ? false : true,
1312
1322
  disabled: option.disabled,
@@ -1342,6 +1352,7 @@ var SlimSelectVue = (function (vue) {
1342
1352
  return values;
1343
1353
  }
1344
1354
  setSelected(value) {
1355
+ this.changeListen(false);
1345
1356
  const options = this.select.childNodes;
1346
1357
  for (const o of options) {
1347
1358
  if (o.nodeName === 'OPTGROUP') {
@@ -1359,6 +1370,7 @@ var SlimSelectVue = (function (vue) {
1359
1370
  option.selected = value.includes(option.value);
1360
1371
  }
1361
1372
  }
1373
+ this.changeListen(true);
1362
1374
  }
1363
1375
  updateSelect(id, style, classes) {
1364
1376
  this.changeListen(false);
@@ -1411,8 +1423,12 @@ var SlimSelectVue = (function (vue) {
1411
1423
  }
1412
1424
  createOption(info) {
1413
1425
  const optionEl = document.createElement('option');
1414
- optionEl.value = info.value !== '' ? info.value : info.text;
1415
- optionEl.innerHTML = info.html || info.text;
1426
+ optionEl.id = info.id;
1427
+ optionEl.value = info.value;
1428
+ optionEl.innerHTML = info.text;
1429
+ if (info.html !== '') {
1430
+ optionEl.setAttribute('data-html', info.html);
1431
+ }
1416
1432
  if (info.selected) {
1417
1433
  optionEl.selected = info.selected;
1418
1434
  }
@@ -1442,15 +1458,18 @@ var SlimSelectVue = (function (vue) {
1442
1458
  }
1443
1459
  destroy() {
1444
1460
  this.changeListen(false);
1445
- this.disconnectObserver();
1446
- this.removeSelectChangeListener();
1447
- this.removeValueChangeListener();
1461
+ this.select.removeEventListener('change', this.valueChange.bind(this));
1462
+ if (this.observer) {
1463
+ this.observer.disconnect();
1464
+ this.observer = null;
1465
+ }
1448
1466
  this.showUI();
1449
1467
  }
1450
1468
  }
1451
1469
 
1452
1470
  class SlimSelect {
1453
1471
  constructor(config) {
1472
+ var _a;
1454
1473
  this.events = {
1455
1474
  search: undefined,
1456
1475
  searchFilter: (opt, search) => {
@@ -1474,23 +1493,7 @@ var SlimSelectVue = (function (vue) {
1474
1493
  if (!this.settings.isOpen) {
1475
1494
  return;
1476
1495
  }
1477
- if (this.settings.openPosition === 'down') {
1478
- this.render.moveContentBelow();
1479
- return;
1480
- }
1481
- else if (this.settings.openPosition === 'up') {
1482
- this.render.moveContentAbove();
1483
- return;
1484
- }
1485
- if (this.settings.contentPosition === 'relative') {
1486
- this.render.moveContentBelow();
1487
- }
1488
- else if (this.render.putContent(this.render.content.main, this.settings.isOpen) === 'up') {
1489
- this.render.moveContentAbove();
1490
- }
1491
- else {
1492
- this.render.moveContentBelow();
1493
- }
1496
+ this.render.moveContent();
1494
1497
  });
1495
1498
  this.documentClick = (e) => {
1496
1499
  if (!this.settings.isOpen) {
@@ -1522,18 +1525,27 @@ var SlimSelectVue = (function (vue) {
1522
1525
  this.events[key] = config.events[key];
1523
1526
  }
1524
1527
  }
1528
+ this.settings.disabled = ((_a = config.settings) === null || _a === void 0 ? void 0 : _a.disabled) ? config.settings.disabled : this.selectEl.disabled;
1525
1529
  this.settings.isMultiple = this.selectEl.multiple;
1526
1530
  this.settings.style = this.selectEl.style.cssText;
1527
1531
  this.settings.class = this.selectEl.className.split(' ');
1528
1532
  this.select = new Select(this.selectEl);
1529
1533
  this.select.updateSelect(this.settings.id, this.settings.style, this.settings.class);
1530
1534
  this.select.hideUI();
1531
- this.select.addSelectChangeListener((data) => {
1532
- this.setData(data);
1533
- });
1534
- this.select.addValueChangeListener((values) => {
1535
+ this.select.onValueChange = (values) => {
1535
1536
  this.setSelected(values);
1536
- });
1537
+ };
1538
+ this.select.onDisabledChange = (disabled) => {
1539
+ if (disabled) {
1540
+ this.disable();
1541
+ }
1542
+ else {
1543
+ this.enable();
1544
+ }
1545
+ };
1546
+ this.select.onOptionsChange = (data) => {
1547
+ this.setData(data);
1548
+ };
1537
1549
  this.store = new Store(this.settings.isMultiple ? 'multiple' : 'single', config.data ? config.data : this.select.getData());
1538
1550
  if (config.data) {
1539
1551
  this.select.updateOptions(this.store.getData());
@@ -1559,7 +1571,7 @@ var SlimSelectVue = (function (vue) {
1559
1571
  if (this.settings.openPosition === 'auto') {
1560
1572
  window.addEventListener('scroll', this.windowScroll, false);
1561
1573
  }
1562
- if (!this.settings.isEnabled) {
1574
+ if (this.settings.disabled) {
1563
1575
  this.disable();
1564
1576
  }
1565
1577
  if (this.settings.alwaysOpen) {
@@ -1568,12 +1580,12 @@ var SlimSelectVue = (function (vue) {
1568
1580
  this.selectEl.slim = this;
1569
1581
  }
1570
1582
  enable() {
1571
- this.settings.isEnabled = true;
1583
+ this.settings.disabled = false;
1572
1584
  this.select.enable();
1573
1585
  this.render.enable();
1574
1586
  }
1575
1587
  disable() {
1576
- this.settings.isEnabled = false;
1588
+ this.settings.disabled = true;
1577
1589
  this.select.disable();
1578
1590
  this.render.disable();
1579
1591
  }
@@ -1607,7 +1619,12 @@ var SlimSelectVue = (function (vue) {
1607
1619
  const data = this.store.getData();
1608
1620
  this.select.updateOptions(data);
1609
1621
  this.render.renderValues();
1610
- this.render.renderOptions(data);
1622
+ if (this.render.content.search.input.value !== '') {
1623
+ this.search(this.render.content.search.input.value);
1624
+ }
1625
+ else {
1626
+ this.render.renderOptions(data);
1627
+ }
1611
1628
  if (this.events.afterChange && !isEqual(selected, this.store.getSelected())) {
1612
1629
  this.events.afterChange(this.store.getSelectedOptions());
1613
1630
  }
@@ -1624,7 +1641,7 @@ var SlimSelectVue = (function (vue) {
1624
1641
  }
1625
1642
  }
1626
1643
  open() {
1627
- if (!this.settings.isEnabled || this.settings.isOpen) {
1644
+ if (this.settings.disabled || this.settings.isOpen) {
1628
1645
  return;
1629
1646
  }
1630
1647
  if (this.events.beforeOpen) {
@@ -1640,10 +1657,12 @@ var SlimSelectVue = (function (vue) {
1640
1657
  }
1641
1658
  this.settings.isOpen = true;
1642
1659
  }, this.settings.timeoutDelay);
1643
- if (this.settings.intervalMove) {
1644
- clearInterval(this.settings.intervalMove);
1660
+ if (this.settings.contentPosition === 'absolute') {
1661
+ if (this.settings.intervalMove) {
1662
+ clearInterval(this.settings.intervalMove);
1663
+ }
1664
+ this.settings.intervalMove = setInterval(this.render.moveContent.bind(this.render), 500);
1645
1665
  }
1646
- this.settings.intervalMove = setInterval(this.render.moveContent.bind(this.render), 500);
1647
1666
  }
1648
1667
  close() {
1649
1668
  if (!this.settings.isOpen || this.settings.alwaysOpen) {
@@ -1759,7 +1778,7 @@ var SlimSelectVue = (function (vue) {
1759
1778
  this.slim = new SlimSelect(config);
1760
1779
  let selected = this.$props.multiple ? this.slim.getSelected() : this.slim.getSelected()[0];
1761
1780
  if (this.value !== selected) {
1762
- this.value = selected;
1781
+ this.slim.setSelected(this.value);
1763
1782
  }
1764
1783
  },
1765
1784
  beforeUnmount() {
@@ -1768,6 +1787,13 @@ var SlimSelectVue = (function (vue) {
1768
1787
  }
1769
1788
  },
1770
1789
  watch: {
1790
+ modelValue: {
1791
+ handler: function (newVal) {
1792
+ var _a;
1793
+ (_a = this.slim) === null || _a === void 0 ? void 0 : _a.setSelected(this.getCleanValue(newVal));
1794
+ },
1795
+ immediate: true,
1796
+ },
1771
1797
  data: {
1772
1798
  handler: function (newData) {
1773
1799
  if (this.slim) {
@@ -1780,18 +1806,7 @@ var SlimSelectVue = (function (vue) {
1780
1806
  computed: {
1781
1807
  value: {
1782
1808
  get() {
1783
- const multi = this.$props.multiple;
1784
- const val = this.$props.modelValue;
1785
- if (val === undefined) {
1786
- return multi ? [] : '';
1787
- }
1788
- if (multi && typeof val === 'string') {
1789
- return [val];
1790
- }
1791
- if (!multi && Array.isArray(val)) {
1792
- return val[0];
1793
- }
1794
- return multi ? [] : '';
1809
+ return this.getCleanValue(this.$props.modelValue);
1795
1810
  },
1796
1811
  set(value) {
1797
1812
  this.$emit('update:modelValue', value);
@@ -1802,6 +1817,16 @@ var SlimSelectVue = (function (vue) {
1802
1817
  getSlimSelect() {
1803
1818
  return this.slim;
1804
1819
  },
1820
+ getCleanValue(val) {
1821
+ const multi = this.$props.multiple;
1822
+ if (typeof val === 'string') {
1823
+ return multi ? [val] : val;
1824
+ }
1825
+ if (Array.isArray(val)) {
1826
+ return multi ? val : val[0];
1827
+ }
1828
+ return multi ? [] : '';
1829
+ },
1805
1830
  },
1806
1831
  });
1807
1832