slim-select 2.2.2 → 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.
@@ -69,7 +69,7 @@ class Settings {
69
69
  this.id = 'ss-' + generateID();
70
70
  this.style = settings.style || '';
71
71
  this.class = settings.class || [];
72
- this.isEnabled = settings.isEnabled !== undefined ? settings.isEnabled : true;
72
+ this.disabled = settings.disabled !== undefined ? settings.disabled : false;
73
73
  this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
74
74
  this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
75
75
  this.searchPlaceholder = settings.searchPlaceholder || 'Search';
@@ -87,6 +87,8 @@ class Settings {
87
87
  this.minSelected = settings.minSelected || 0;
88
88
  this.maxSelected = settings.maxSelected || 1000;
89
89
  this.timeoutDelay = settings.timeoutDelay || 200;
90
+ this.maxValuesShown = settings.maxValuesShown || 20;
91
+ this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
90
92
  }
91
93
  }
92
94
 
@@ -269,23 +271,21 @@ class Store {
269
271
  const dataSearch = [];
270
272
  this.data.forEach((dataObj) => {
271
273
  if (dataObj instanceof Optgroup) {
272
- if (!includeOptgroup) {
273
- dataObj.options.forEach((option) => {
274
- if (filter && filter(option)) {
275
- dataSearch.push(option);
274
+ let optOptions = [];
275
+ dataObj.options.forEach((option) => {
276
+ if (!filter || filter(option)) {
277
+ if (!includeOptgroup) {
278
+ dataSearch.push(new Option(option));
276
279
  }
277
- });
278
- }
279
- else {
280
- let optOptions = [];
281
- dataObj.options.forEach((option) => {
282
- if (!filter || filter(option)) {
280
+ else {
283
281
  optOptions.push(new Option(option));
284
282
  }
285
- });
286
- if (optOptions.length > 0) {
287
- dataSearch.push(new Optgroup(dataObj));
288
283
  }
284
+ });
285
+ if (optOptions.length > 0) {
286
+ let optgroup = new Optgroup(dataObj);
287
+ optgroup.options = optOptions;
288
+ dataSearch.push(optgroup);
289
289
  }
290
290
  }
291
291
  if (dataObj instanceof Option) {
@@ -305,6 +305,7 @@ class Render {
305
305
  placeholder: 'ss-placeholder',
306
306
  values: 'ss-values',
307
307
  single: 'ss-single',
308
+ max: 'ss-max',
308
309
  value: 'ss-value',
309
310
  valueText: 'ss-value-text',
310
311
  valueDelete: 'ss-value-delete',
@@ -361,23 +362,7 @@ class Render {
361
362
  this.main.main.classList.add(this.settings.openPosition === 'up' ? this.classes.openAbove : this.classes.openBelow);
362
363
  this.moveContent();
363
364
  this.renderOptions(this.store.getData());
364
- if (this.settings.contentPosition === 'relative') {
365
- this.moveContentBelow();
366
- }
367
- else if (this.settings.openPosition.toLowerCase() === 'up') {
368
- this.moveContentAbove();
369
- }
370
- else if (this.settings.openPosition.toLowerCase() === 'down') {
371
- this.moveContentBelow();
372
- }
373
- else {
374
- if (this.putContent(this.content.main, this.settings.isOpen) === 'up') {
375
- this.moveContentAbove();
376
- }
377
- else {
378
- this.moveContentBelow();
379
- }
380
- }
365
+ this.moveContent();
381
366
  const selectedOptions = this.store.getSelectedOptions();
382
367
  if (selectedOptions.length) {
383
368
  const selectedId = selectedOptions[selectedOptions.length - 1].id;
@@ -435,7 +420,7 @@ class Render {
435
420
  }
436
421
  };
437
422
  main.onclick = (e) => {
438
- if (!this.settings.isEnabled) {
423
+ if (this.settings.disabled) {
439
424
  return;
440
425
  }
441
426
  this.settings.isOpen ? this.callbacks.close() : this.callbacks.open();
@@ -450,7 +435,7 @@ class Render {
450
435
  }
451
436
  deselect.onclick = (e) => {
452
437
  e.stopPropagation();
453
- if (!this.settings.isEnabled) {
438
+ if (this.settings.disabled) {
454
439
  return;
455
440
  }
456
441
  let shouldDelete = true;
@@ -566,6 +551,19 @@ class Render {
566
551
  placeholder.remove();
567
552
  }
568
553
  }
554
+ if (selectedOptions.length > this.settings.maxValuesShown) {
555
+ const singleValue = document.createElement('div');
556
+ singleValue.classList.add(this.classes.max);
557
+ singleValue.textContent = this.settings.maxValuesMessage.replace('{number}', selectedOptions.length.toString());
558
+ this.main.values.innerHTML = singleValue.outerHTML;
559
+ return;
560
+ }
561
+ else {
562
+ const maxValuesMessage = this.main.values.querySelector('.' + this.classes.max);
563
+ if (maxValuesMessage) {
564
+ maxValuesMessage.remove();
565
+ }
566
+ }
569
567
  let removeNodes = [];
570
568
  for (let i = 0; i < currentNodes.length; i++) {
571
569
  const node = currentNodes[i];
@@ -620,6 +618,9 @@ class Render {
620
618
  deleteDiv.onclick = (e) => {
621
619
  e.preventDefault();
622
620
  e.stopPropagation();
621
+ if (this.settings.disabled) {
622
+ return;
623
+ }
623
624
  let shouldDelete = true;
624
625
  const before = this.store.getSelectedOptions();
625
626
  const after = before.filter((o) => {
@@ -691,12 +692,23 @@ class Render {
691
692
  }
692
693
  moveContent() {
693
694
  if (this.settings.contentPosition === 'relative') {
695
+ this.moveContentBelow();
694
696
  return;
695
697
  }
696
- const containerRect = this.main.main.getBoundingClientRect();
697
- this.content.main.style.top = containerRect.top + containerRect.height + window.scrollY + 'px';
698
- this.content.main.style.left = containerRect.left + window.scrollX + 'px';
699
- this.content.main.style.width = containerRect.width + 'px';
698
+ if (this.settings.openPosition === 'down') {
699
+ this.moveContentBelow();
700
+ return;
701
+ }
702
+ else if (this.settings.openPosition === 'up') {
703
+ this.moveContentAbove();
704
+ return;
705
+ }
706
+ if (this.putContent() === 'up') {
707
+ this.moveContentAbove();
708
+ }
709
+ else {
710
+ this.moveContentBelow();
711
+ }
700
712
  }
701
713
  searchDiv() {
702
714
  const main = document.createElement('div');
@@ -907,8 +919,7 @@ class Render {
907
919
  this.content.list.innerHTML = '';
908
920
  if (data.length === 0) {
909
921
  const noResults = document.createElement('div');
910
- noResults.classList.add(this.classes.option);
911
- noResults.classList.add(this.classes.disabled);
922
+ noResults.classList.add(this.classes.search);
912
923
  noResults.innerHTML = this.settings.searchText;
913
924
  this.content.list.appendChild(noResults);
914
925
  return;
@@ -984,7 +995,7 @@ class Render {
984
995
  optgroupClosable.appendChild(optgroupClosableSvg);
985
996
  const optgroupClosableArrow = document.createElementNS('http://www.w3.org/2000/svg', 'path');
986
997
  optgroupClosableSvg.appendChild(optgroupClosableArrow);
987
- if (d.options.some((o) => o.selected)) {
998
+ if (d.options.some((o) => o.selected) || this.content.search.input.value.trim() !== '') {
988
999
  optgroupClosable.classList.add(this.classes.open);
989
1000
  optgroupClosableArrow.setAttribute('d', this.classes.arrowOpen);
990
1001
  }
@@ -1043,8 +1054,7 @@ class Render {
1043
1054
  optionEl.style.cssText = option.style;
1044
1055
  }
1045
1056
  if (this.settings.searchHighlight && this.content.search.input.value.trim() !== '') {
1046
- const textOrHtml = option.html !== '' ? option.html : option.text;
1047
- optionEl.innerHTML = this.highlightText(textOrHtml, this.content.search.input.value, this.classes.searchHighlighter);
1057
+ optionEl.innerHTML = this.highlightText(option.html !== '' ? option.html : option.text, this.content.search.input.value, this.classes.searchHighlighter);
1048
1058
  }
1049
1059
  else if (option.html !== '') {
1050
1060
  optionEl.innerHTML = option.html;
@@ -1055,7 +1065,7 @@ class Render {
1055
1065
  if (this.settings.showOptionTooltips && optionEl.textContent) {
1056
1066
  optionEl.setAttribute('title', optionEl.textContent);
1057
1067
  }
1058
- if ((option.selected && !this.settings.allowDeselect) || (option.disabled && !this.settings.allowDeselect)) {
1068
+ if (option.disabled) {
1059
1069
  optionEl.classList.add(this.classes.disabled);
1060
1070
  }
1061
1071
  if (option.selected && this.settings.hideSelected) {
@@ -1076,9 +1086,8 @@ class Render {
1076
1086
  if (option.disabled || (option.selected && !this.settings.allowDeselect)) {
1077
1087
  return;
1078
1088
  }
1079
- if (this.settings.isMultiple &&
1080
- Array.isArray(selectedOptions) &&
1081
- this.settings.maxSelected <= selectedOptions.length) {
1089
+ if ((this.settings.isMultiple && this.settings.maxSelected <= selectedOptions.length && !option.selected) ||
1090
+ (this.settings.isMultiple && this.settings.minSelected >= selectedOptions.length && option.selected)) {
1082
1091
  return;
1083
1092
  }
1084
1093
  let shouldUpdate = false;
@@ -1143,23 +1152,30 @@ class Render {
1143
1152
  return completedString;
1144
1153
  }
1145
1154
  moveContentAbove() {
1146
- let mainHeight = this.main.main.offsetHeight;
1155
+ const mainHeight = this.main.main.offsetHeight;
1147
1156
  const contentHeight = this.content.main.offsetHeight;
1148
- const height = mainHeight + contentHeight - 1;
1149
- this.content.main.style.margin = '-' + height + 'px 0px 0px 0px';
1150
- this.content.main.style.transformOrigin = 'center bottom';
1151
1157
  this.main.main.classList.remove(this.classes.openBelow);
1152
1158
  this.main.main.classList.add(this.classes.openAbove);
1153
1159
  this.content.main.classList.remove(this.classes.openBelow);
1154
1160
  this.content.main.classList.add(this.classes.openAbove);
1161
+ const containerRect = this.main.main.getBoundingClientRect();
1162
+ this.content.main.style.margin = '-' + (mainHeight + contentHeight - 1) + 'px 0px 0px 0px';
1163
+ this.content.main.style.top = containerRect.top + containerRect.height + window.scrollY + 'px';
1164
+ this.content.main.style.left = containerRect.left + window.scrollX + 'px';
1165
+ this.content.main.style.width = containerRect.width + 'px';
1155
1166
  }
1156
1167
  moveContentBelow() {
1157
- this.content.main.style.margin = '-1px 0px 0px 0px';
1158
- this.content.main.style.transformOrigin = 'center top';
1159
1168
  this.main.main.classList.remove(this.classes.openAbove);
1160
1169
  this.main.main.classList.add(this.classes.openBelow);
1161
1170
  this.content.main.classList.remove(this.classes.openAbove);
1162
1171
  this.content.main.classList.add(this.classes.openBelow);
1172
+ const containerRect = this.main.main.getBoundingClientRect();
1173
+ this.content.main.style.margin = '-1px 0px 0px 0px';
1174
+ if (this.settings.contentPosition !== 'relative') {
1175
+ this.content.main.style.top = containerRect.top + containerRect.height + window.scrollY + 'px';
1176
+ this.content.main.style.left = containerRect.left + window.scrollX + 'px';
1177
+ this.content.main.style.width = containerRect.width + 'px';
1178
+ }
1163
1179
  }
1164
1180
  ensureElementInView(container, element) {
1165
1181
  const cTop = container.scrollTop + container.offsetTop;
@@ -1173,16 +1189,18 @@ class Render {
1173
1189
  container.scrollTop += eBottom - cBottom;
1174
1190
  }
1175
1191
  }
1176
- putContent(el, isOpen) {
1177
- const height = el.offsetHeight;
1178
- const rect = el.getBoundingClientRect();
1179
- const elemTop = isOpen ? rect.top : rect.top - height;
1180
- const elemBottom = isOpen ? rect.bottom : rect.bottom + height;
1181
- if (elemTop <= 0) {
1182
- return 'down';
1183
- }
1184
- if (elemBottom >= window.innerHeight) {
1185
- return 'up';
1192
+ putContent() {
1193
+ const mainHeight = this.main.main.offsetHeight;
1194
+ const mainRect = this.main.main.getBoundingClientRect();
1195
+ const contentHeight = this.content.main.offsetHeight;
1196
+ const spaceBelow = window.innerHeight - (mainRect.top + mainHeight);
1197
+ if (spaceBelow <= contentHeight) {
1198
+ if (mainRect.top > contentHeight) {
1199
+ return 'up';
1200
+ }
1201
+ else {
1202
+ return 'down';
1203
+ }
1186
1204
  }
1187
1205
  return 'down';
1188
1206
  }
@@ -1193,16 +1211,17 @@ class Select {
1193
1211
  this.listen = false;
1194
1212
  this.observer = null;
1195
1213
  this.select = select;
1214
+ this.select.addEventListener('change', this.valueChange.bind(this), {
1215
+ passive: true,
1216
+ });
1217
+ this.observer = new MutationObserver(this.observeCall.bind(this));
1218
+ this.changeListen(true);
1196
1219
  }
1197
1220
  enable() {
1198
- this.disconnectObserver();
1199
1221
  this.select.disabled = false;
1200
- this.connectObserver();
1201
1222
  }
1202
1223
  disable() {
1203
- this.disconnectObserver();
1204
1224
  this.select.disabled = true;
1205
- this.connectObserver();
1206
1225
  }
1207
1226
  hideUI() {
1208
1227
  this.select.tabIndex = -1;
@@ -1214,65 +1233,54 @@ class Select {
1214
1233
  this.select.style.display = '';
1215
1234
  this.select.removeAttribute('aria-hidden');
1216
1235
  }
1217
- changeListen(on) {
1218
- this.listen = on;
1219
- if (this.listen) {
1220
- this.connectObserver();
1236
+ changeListen(listen) {
1237
+ this.listen = listen;
1238
+ if (listen) {
1239
+ if (this.observer) {
1240
+ this.observer.observe(this.select, {
1241
+ subtree: true,
1242
+ childList: true,
1243
+ attributes: true,
1244
+ });
1245
+ }
1221
1246
  }
1222
- else {
1223
- this.disconnectObserver();
1247
+ if (!listen) {
1248
+ if (this.observer) {
1249
+ this.observer.disconnect();
1250
+ }
1224
1251
  }
1225
1252
  }
1226
- addSelectChangeListener(func) {
1227
- this.onSelectChange = func;
1228
- this.addObserver();
1229
- this.connectObserver();
1230
- this.changeListen(true);
1231
- }
1232
- removeSelectChangeListener() {
1233
- this.changeListen(false);
1234
- this.onSelectChange = undefined;
1235
- }
1236
- addValueChangeListener(func) {
1237
- this.onValueChange = func;
1238
- this.select.addEventListener('change', this.valueChange.bind(this), {
1239
- passive: true,
1240
- });
1241
- }
1242
- removeValueChangeListener() {
1243
- this.onValueChange = undefined;
1244
- this.select.removeEventListener('change', this.valueChange.bind(this));
1245
- }
1246
1253
  valueChange(ev) {
1247
1254
  if (this.listen && this.onValueChange) {
1248
1255
  this.onValueChange(this.getSelectedValues());
1249
1256
  }
1250
1257
  return true;
1251
1258
  }
1252
- observeWrapper(mutations) {
1253
- if (this.onSelectChange) {
1254
- this.changeListen(false);
1255
- this.onSelectChange(this.getData());
1256
- this.changeListen(true);
1259
+ observeCall(mutations) {
1260
+ if (!this.listen) {
1261
+ return;
1257
1262
  }
1258
- }
1259
- addObserver() {
1260
- if (this.observer) {
1261
- this.disconnectObserver();
1262
- this.observer = null;
1263
+ let disabledChanged = false;
1264
+ let optgroupOptionChanged = false;
1265
+ for (const m of mutations) {
1266
+ if (m.target === this.select) {
1267
+ if (m.attributeName === 'disabled') {
1268
+ disabledChanged = true;
1269
+ }
1270
+ }
1271
+ if (m.target.nodeName === 'OPTGROUP' || m.target.nodeName === 'OPTION') {
1272
+ optgroupOptionChanged = true;
1273
+ }
1263
1274
  }
1264
- this.observer = new MutationObserver(this.observeWrapper.bind(this));
1265
- }
1266
- connectObserver() {
1267
- if (this.observer) {
1268
- this.observer.observe(this.select, {
1269
- childList: true,
1270
- });
1275
+ if (disabledChanged && this.onDisabledChange) {
1276
+ this.changeListen(false);
1277
+ this.onDisabledChange(this.select.disabled);
1278
+ this.changeListen(true);
1271
1279
  }
1272
- }
1273
- disconnectObserver() {
1274
- if (this.observer) {
1275
- this.observer.disconnect();
1280
+ if (optgroupOptionChanged && this.onOptionsChange) {
1281
+ this.changeListen(false);
1282
+ this.onOptionsChange(this.getData());
1283
+ this.changeListen(true);
1276
1284
  }
1277
1285
  }
1278
1286
  getData() {
@@ -1290,7 +1298,7 @@ class Select {
1290
1298
  }
1291
1299
  getDataFromOptgroup(optgroup) {
1292
1300
  let data = {
1293
- id: (optgroup.dataset ? optgroup.dataset.id : false) || '',
1301
+ id: optgroup.id,
1294
1302
  label: optgroup.label,
1295
1303
  selectAll: optgroup.dataset ? optgroup.dataset.selectall === 'true' : false,
1296
1304
  closable: optgroup.dataset ? optgroup.dataset.closable : 'off',
@@ -1306,10 +1314,10 @@ class Select {
1306
1314
  }
1307
1315
  getDataFromOption(option) {
1308
1316
  return {
1309
- id: (option.dataset ? option.dataset.id : false) || '',
1317
+ id: option.id,
1310
1318
  value: option.value,
1311
1319
  text: option.text,
1312
- html: option.innerHTML,
1320
+ html: option.dataset && option.dataset.html ? option.dataset.html : '',
1313
1321
  selected: option.selected,
1314
1322
  display: option.style.display === 'none' ? false : true,
1315
1323
  disabled: option.disabled,
@@ -1345,6 +1353,7 @@ class Select {
1345
1353
  return values;
1346
1354
  }
1347
1355
  setSelected(value) {
1356
+ this.changeListen(false);
1348
1357
  const options = this.select.childNodes;
1349
1358
  for (const o of options) {
1350
1359
  if (o.nodeName === 'OPTGROUP') {
@@ -1362,6 +1371,7 @@ class Select {
1362
1371
  option.selected = value.includes(option.value);
1363
1372
  }
1364
1373
  }
1374
+ this.changeListen(true);
1365
1375
  }
1366
1376
  updateSelect(id, style, classes) {
1367
1377
  this.changeListen(false);
@@ -1414,8 +1424,12 @@ class Select {
1414
1424
  }
1415
1425
  createOption(info) {
1416
1426
  const optionEl = document.createElement('option');
1417
- optionEl.value = info.value !== '' ? info.value : info.text;
1418
- optionEl.innerHTML = info.html || info.text;
1427
+ optionEl.id = info.id;
1428
+ optionEl.value = info.value;
1429
+ optionEl.innerHTML = info.text;
1430
+ if (info.html !== '') {
1431
+ optionEl.setAttribute('data-html', info.html);
1432
+ }
1419
1433
  if (info.selected) {
1420
1434
  optionEl.selected = info.selected;
1421
1435
  }
@@ -1445,15 +1459,18 @@ class Select {
1445
1459
  }
1446
1460
  destroy() {
1447
1461
  this.changeListen(false);
1448
- this.disconnectObserver();
1449
- this.removeSelectChangeListener();
1450
- this.removeValueChangeListener();
1462
+ this.select.removeEventListener('change', this.valueChange.bind(this));
1463
+ if (this.observer) {
1464
+ this.observer.disconnect();
1465
+ this.observer = null;
1466
+ }
1451
1467
  this.showUI();
1452
1468
  }
1453
1469
  }
1454
1470
 
1455
1471
  class SlimSelect {
1456
1472
  constructor(config) {
1473
+ var _a;
1457
1474
  this.events = {
1458
1475
  search: undefined,
1459
1476
  searchFilter: (opt, search) => {
@@ -1477,23 +1494,7 @@ class SlimSelect {
1477
1494
  if (!this.settings.isOpen) {
1478
1495
  return;
1479
1496
  }
1480
- if (this.settings.openPosition === 'down') {
1481
- this.render.moveContentBelow();
1482
- return;
1483
- }
1484
- else if (this.settings.openPosition === 'up') {
1485
- this.render.moveContentAbove();
1486
- return;
1487
- }
1488
- if (this.settings.contentPosition === 'relative') {
1489
- this.render.moveContentBelow();
1490
- }
1491
- else if (this.render.putContent(this.render.content.main, this.settings.isOpen) === 'up') {
1492
- this.render.moveContentAbove();
1493
- }
1494
- else {
1495
- this.render.moveContentBelow();
1496
- }
1497
+ this.render.moveContent();
1497
1498
  });
1498
1499
  this.documentClick = (e) => {
1499
1500
  if (!this.settings.isOpen) {
@@ -1525,18 +1526,27 @@ class SlimSelect {
1525
1526
  this.events[key] = config.events[key];
1526
1527
  }
1527
1528
  }
1529
+ this.settings.disabled = ((_a = config.settings) === null || _a === void 0 ? void 0 : _a.disabled) ? config.settings.disabled : this.selectEl.disabled;
1528
1530
  this.settings.isMultiple = this.selectEl.multiple;
1529
1531
  this.settings.style = this.selectEl.style.cssText;
1530
1532
  this.settings.class = this.selectEl.className.split(' ');
1531
1533
  this.select = new Select(this.selectEl);
1532
1534
  this.select.updateSelect(this.settings.id, this.settings.style, this.settings.class);
1533
1535
  this.select.hideUI();
1534
- this.select.addSelectChangeListener((data) => {
1535
- this.setData(data);
1536
- });
1537
- this.select.addValueChangeListener((values) => {
1536
+ this.select.onValueChange = (values) => {
1538
1537
  this.setSelected(values);
1539
- });
1538
+ };
1539
+ this.select.onDisabledChange = (disabled) => {
1540
+ if (disabled) {
1541
+ this.disable();
1542
+ }
1543
+ else {
1544
+ this.enable();
1545
+ }
1546
+ };
1547
+ this.select.onOptionsChange = (data) => {
1548
+ this.setData(data);
1549
+ };
1540
1550
  this.store = new Store(this.settings.isMultiple ? 'multiple' : 'single', config.data ? config.data : this.select.getData());
1541
1551
  if (config.data) {
1542
1552
  this.select.updateOptions(this.store.getData());
@@ -1562,7 +1572,7 @@ class SlimSelect {
1562
1572
  if (this.settings.openPosition === 'auto') {
1563
1573
  window.addEventListener('scroll', this.windowScroll, false);
1564
1574
  }
1565
- if (!this.settings.isEnabled) {
1575
+ if (this.settings.disabled) {
1566
1576
  this.disable();
1567
1577
  }
1568
1578
  if (this.settings.alwaysOpen) {
@@ -1571,12 +1581,12 @@ class SlimSelect {
1571
1581
  this.selectEl.slim = this;
1572
1582
  }
1573
1583
  enable() {
1574
- this.settings.isEnabled = true;
1584
+ this.settings.disabled = false;
1575
1585
  this.select.enable();
1576
1586
  this.render.enable();
1577
1587
  }
1578
1588
  disable() {
1579
- this.settings.isEnabled = false;
1589
+ this.settings.disabled = true;
1580
1590
  this.select.disable();
1581
1591
  this.render.disable();
1582
1592
  }
@@ -1610,7 +1620,12 @@ class SlimSelect {
1610
1620
  const data = this.store.getData();
1611
1621
  this.select.updateOptions(data);
1612
1622
  this.render.renderValues();
1613
- this.render.renderOptions(data);
1623
+ if (this.render.content.search.input.value !== '') {
1624
+ this.search(this.render.content.search.input.value);
1625
+ }
1626
+ else {
1627
+ this.render.renderOptions(data);
1628
+ }
1614
1629
  if (this.events.afterChange && !isEqual(selected, this.store.getSelected())) {
1615
1630
  this.events.afterChange(this.store.getSelectedOptions());
1616
1631
  }
@@ -1627,7 +1642,7 @@ class SlimSelect {
1627
1642
  }
1628
1643
  }
1629
1644
  open() {
1630
- if (!this.settings.isEnabled || this.settings.isOpen) {
1645
+ if (this.settings.disabled || this.settings.isOpen) {
1631
1646
  return;
1632
1647
  }
1633
1648
  if (this.events.beforeOpen) {
@@ -1643,10 +1658,12 @@ class SlimSelect {
1643
1658
  }
1644
1659
  this.settings.isOpen = true;
1645
1660
  }, this.settings.timeoutDelay);
1646
- if (this.settings.intervalMove) {
1647
- clearInterval(this.settings.intervalMove);
1661
+ if (this.settings.contentPosition === 'absolute') {
1662
+ if (this.settings.intervalMove) {
1663
+ clearInterval(this.settings.intervalMove);
1664
+ }
1665
+ this.settings.intervalMove = setInterval(this.render.moveContent.bind(this.render), 500);
1648
1666
  }
1649
- this.settings.intervalMove = setInterval(this.render.moveContent.bind(this.render), 500);
1650
1667
  }
1651
1668
  close() {
1652
1669
  if (!this.settings.isOpen || this.settings.alwaysOpen) {
@@ -1762,7 +1779,7 @@ var script = vue.defineComponent({
1762
1779
  this.slim = new SlimSelect(config);
1763
1780
  let selected = this.$props.multiple ? this.slim.getSelected() : this.slim.getSelected()[0];
1764
1781
  if (this.value !== selected) {
1765
- this.value = selected;
1782
+ this.slim.setSelected(this.value);
1766
1783
  }
1767
1784
  },
1768
1785
  beforeUnmount() {
@@ -1771,6 +1788,13 @@ var script = vue.defineComponent({
1771
1788
  }
1772
1789
  },
1773
1790
  watch: {
1791
+ modelValue: {
1792
+ handler: function (newVal) {
1793
+ var _a;
1794
+ (_a = this.slim) === null || _a === void 0 ? void 0 : _a.setSelected(this.getCleanValue(newVal));
1795
+ },
1796
+ immediate: true,
1797
+ },
1774
1798
  data: {
1775
1799
  handler: function (newData) {
1776
1800
  if (this.slim) {
@@ -1783,18 +1807,7 @@ var script = vue.defineComponent({
1783
1807
  computed: {
1784
1808
  value: {
1785
1809
  get() {
1786
- const multi = this.$props.multiple;
1787
- const val = this.$props.modelValue;
1788
- if (val === undefined) {
1789
- return multi ? [] : '';
1790
- }
1791
- if (multi && typeof val === 'string') {
1792
- return [val];
1793
- }
1794
- if (!multi && Array.isArray(val)) {
1795
- return val[0];
1796
- }
1797
- return multi ? [] : '';
1810
+ return this.getCleanValue(this.$props.modelValue);
1798
1811
  },
1799
1812
  set(value) {
1800
1813
  this.$emit('update:modelValue', value);
@@ -1805,6 +1818,16 @@ var script = vue.defineComponent({
1805
1818
  getSlimSelect() {
1806
1819
  return this.slim;
1807
1820
  },
1821
+ getCleanValue(val) {
1822
+ const multi = this.$props.multiple;
1823
+ if (typeof val === 'string') {
1824
+ return multi ? [val] : val;
1825
+ }
1826
+ if (Array.isArray(val)) {
1827
+ return multi ? val : val[0];
1828
+ }
1829
+ return multi ? [] : '';
1830
+ },
1808
1831
  },
1809
1832
  });
1810
1833