slim-select 2.7.1 → 2.8.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.
- package/dist/index.d.ts +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/slimselect.cjs.js +54 -47
- package/dist/slimselect.es.js +54 -47
- package/dist/slimselect.global.js +54 -47
- package/dist/slimselect.js +54 -47
- package/dist/slimselect.min.js +1 -1
- package/dist/slimselect.umd.js +54 -47
- package/dist/slimselect.umd.min.js +1 -1
- package/package.json +30 -30
- package/src/slim-select/index.ts +11 -8
- package/src/slim-select/render.ts +11 -4
- package/src/slim-select/settings.ts +2 -0
- package/src/vue/dist/slim-select/helpers.d.ts +5 -5
- package/src/vue/dist/slim-select/index.d.ts +46 -46
- package/src/vue/dist/slim-select/render.d.ts +120 -120
- package/src/vue/dist/slim-select/select.d.ts +28 -28
- package/src/vue/dist/slim-select/settings.d.ts +34 -33
- package/src/vue/dist/slim-select/store.d.ts +80 -80
- package/src/vue/dist/slimselectvue.es.js +1947 -1940
- package/src/vue/dist/slimselectvue.global.js +1947 -1940
- package/src/vue/dist/slimselectvue.ssr.js +1947 -1940
- package/src/vue/dist/vue/hello.d.ts +2 -2
- package/src/vue/dist/vue/slimselect.vue.d.ts +326 -324
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Settings, { SettingsPartial } from './settings';
|
|
2
1
|
import Render from './render';
|
|
3
2
|
import Select from './select';
|
|
3
|
+
import Settings, { SettingsPartial } from './settings';
|
|
4
4
|
import Store, { DataArray, DataArrayPartial, Option, OptionOptional } from './store';
|
|
5
5
|
export interface Config {
|
|
6
6
|
select: string | Element;
|
package/dist/settings.d.ts
CHANGED
package/dist/slimselect.cjs.js
CHANGED
|
@@ -52,45 +52,6 @@ function kebabCase(str) {
|
|
|
52
52
|
return str[0] === str[0].toUpperCase() ? result.substring(1) : result;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
class Settings {
|
|
56
|
-
constructor(settings) {
|
|
57
|
-
this.id = '';
|
|
58
|
-
this.style = '';
|
|
59
|
-
this.class = [];
|
|
60
|
-
this.isMultiple = false;
|
|
61
|
-
this.isOpen = false;
|
|
62
|
-
this.isFullOpen = false;
|
|
63
|
-
this.intervalMove = null;
|
|
64
|
-
if (!settings) {
|
|
65
|
-
settings = {};
|
|
66
|
-
}
|
|
67
|
-
this.id = 'ss-' + generateID();
|
|
68
|
-
this.style = settings.style || '';
|
|
69
|
-
this.class = settings.class || [];
|
|
70
|
-
this.disabled = settings.disabled !== undefined ? settings.disabled : false;
|
|
71
|
-
this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
|
|
72
|
-
this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
|
|
73
|
-
this.ariaLabel = settings.ariaLabel || 'Combobox';
|
|
74
|
-
this.searchPlaceholder = settings.searchPlaceholder || 'Search';
|
|
75
|
-
this.searchText = settings.searchText || 'No Results';
|
|
76
|
-
this.searchingText = settings.searchingText || 'Searching...';
|
|
77
|
-
this.searchHighlight = settings.searchHighlight !== undefined ? settings.searchHighlight : false;
|
|
78
|
-
this.closeOnSelect = settings.closeOnSelect !== undefined ? settings.closeOnSelect : true;
|
|
79
|
-
this.contentLocation = settings.contentLocation || document.body;
|
|
80
|
-
this.contentPosition = settings.contentPosition || 'absolute';
|
|
81
|
-
this.openPosition = settings.openPosition || 'auto';
|
|
82
|
-
this.placeholderText = settings.placeholderText !== undefined ? settings.placeholderText : 'Select Value';
|
|
83
|
-
this.allowDeselect = settings.allowDeselect !== undefined ? settings.allowDeselect : false;
|
|
84
|
-
this.hideSelected = settings.hideSelected !== undefined ? settings.hideSelected : false;
|
|
85
|
-
this.showOptionTooltips = settings.showOptionTooltips !== undefined ? settings.showOptionTooltips : false;
|
|
86
|
-
this.minSelected = settings.minSelected || 0;
|
|
87
|
-
this.maxSelected = settings.maxSelected || 1000;
|
|
88
|
-
this.timeoutDelay = settings.timeoutDelay || 200;
|
|
89
|
-
this.maxValuesShown = settings.maxValuesShown || 20;
|
|
90
|
-
this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
55
|
class Optgroup {
|
|
95
56
|
constructor(optgroup) {
|
|
96
57
|
this.id = !optgroup.id || optgroup.id === '' ? generateID() : optgroup.id;
|
|
@@ -649,14 +610,19 @@ class Render {
|
|
|
649
610
|
}
|
|
650
611
|
}
|
|
651
612
|
if (shouldAdd) {
|
|
652
|
-
if (
|
|
613
|
+
if (this.settings.keepOrder) {
|
|
653
614
|
this.main.values.appendChild(this.multipleValue(selectedOptions[d]));
|
|
654
615
|
}
|
|
655
|
-
else if (d === 0) {
|
|
656
|
-
this.main.values.insertBefore(this.multipleValue(selectedOptions[d]), currentNodes[d]);
|
|
657
|
-
}
|
|
658
616
|
else {
|
|
659
|
-
currentNodes
|
|
617
|
+
if (currentNodes.length === 0) {
|
|
618
|
+
this.main.values.appendChild(this.multipleValue(selectedOptions[d]));
|
|
619
|
+
}
|
|
620
|
+
else if (d === 0) {
|
|
621
|
+
this.main.values.insertBefore(this.multipleValue(selectedOptions[d]), currentNodes[d]);
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
currentNodes[d - 1].insertAdjacentElement('afterend', this.multipleValue(selectedOptions[d]));
|
|
625
|
+
}
|
|
660
626
|
}
|
|
661
627
|
}
|
|
662
628
|
}
|
|
@@ -1562,6 +1528,46 @@ class Select {
|
|
|
1562
1528
|
}
|
|
1563
1529
|
}
|
|
1564
1530
|
|
|
1531
|
+
class Settings {
|
|
1532
|
+
constructor(settings) {
|
|
1533
|
+
this.id = '';
|
|
1534
|
+
this.style = '';
|
|
1535
|
+
this.class = [];
|
|
1536
|
+
this.isMultiple = false;
|
|
1537
|
+
this.isOpen = false;
|
|
1538
|
+
this.isFullOpen = false;
|
|
1539
|
+
this.intervalMove = null;
|
|
1540
|
+
if (!settings) {
|
|
1541
|
+
settings = {};
|
|
1542
|
+
}
|
|
1543
|
+
this.id = 'ss-' + generateID();
|
|
1544
|
+
this.style = settings.style || '';
|
|
1545
|
+
this.class = settings.class || [];
|
|
1546
|
+
this.disabled = settings.disabled !== undefined ? settings.disabled : false;
|
|
1547
|
+
this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
|
|
1548
|
+
this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
|
|
1549
|
+
this.ariaLabel = settings.ariaLabel || 'Combobox';
|
|
1550
|
+
this.searchPlaceholder = settings.searchPlaceholder || 'Search';
|
|
1551
|
+
this.searchText = settings.searchText || 'No Results';
|
|
1552
|
+
this.searchingText = settings.searchingText || 'Searching...';
|
|
1553
|
+
this.searchHighlight = settings.searchHighlight !== undefined ? settings.searchHighlight : false;
|
|
1554
|
+
this.closeOnSelect = settings.closeOnSelect !== undefined ? settings.closeOnSelect : true;
|
|
1555
|
+
this.contentLocation = settings.contentLocation || document.body;
|
|
1556
|
+
this.contentPosition = settings.contentPosition || 'absolute';
|
|
1557
|
+
this.openPosition = settings.openPosition || 'auto';
|
|
1558
|
+
this.placeholderText = settings.placeholderText !== undefined ? settings.placeholderText : 'Select Value';
|
|
1559
|
+
this.allowDeselect = settings.allowDeselect !== undefined ? settings.allowDeselect : false;
|
|
1560
|
+
this.hideSelected = settings.hideSelected !== undefined ? settings.hideSelected : false;
|
|
1561
|
+
this.keepOrder = settings.keepOrder !== undefined ? settings.keepOrder : false;
|
|
1562
|
+
this.showOptionTooltips = settings.showOptionTooltips !== undefined ? settings.showOptionTooltips : false;
|
|
1563
|
+
this.minSelected = settings.minSelected || 0;
|
|
1564
|
+
this.maxSelected = settings.maxSelected || 1000;
|
|
1565
|
+
this.timeoutDelay = settings.timeoutDelay || 200;
|
|
1566
|
+
this.maxValuesShown = settings.maxValuesShown || 20;
|
|
1567
|
+
this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1565
1571
|
class SlimSelect {
|
|
1566
1572
|
constructor(config) {
|
|
1567
1573
|
var _a;
|
|
@@ -1661,7 +1667,7 @@ class SlimSelect {
|
|
|
1661
1667
|
if (config.data) {
|
|
1662
1668
|
this.select.updateOptions(this.store.getData());
|
|
1663
1669
|
}
|
|
1664
|
-
const
|
|
1670
|
+
const renderCallbacks = {
|
|
1665
1671
|
open: this.open.bind(this),
|
|
1666
1672
|
close: this.close.bind(this),
|
|
1667
1673
|
addable: this.events.addable ? this.events.addable : undefined,
|
|
@@ -1671,7 +1677,7 @@ class SlimSelect {
|
|
|
1671
1677
|
beforeChange: this.events.beforeChange,
|
|
1672
1678
|
afterChange: this.events.afterChange,
|
|
1673
1679
|
};
|
|
1674
|
-
this.render = new Render(this.settings, this.store,
|
|
1680
|
+
this.render = new Render(this.settings, this.store, renderCallbacks);
|
|
1675
1681
|
this.render.renderValues();
|
|
1676
1682
|
this.render.renderOptions(this.store.getData());
|
|
1677
1683
|
const selectAriaLabel = this.selectEl.getAttribute('aria-label');
|
|
@@ -1685,7 +1691,6 @@ class SlimSelect {
|
|
|
1685
1691
|
if (this.selectEl.parentNode) {
|
|
1686
1692
|
this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling);
|
|
1687
1693
|
}
|
|
1688
|
-
document.addEventListener('click', this.documentClick);
|
|
1689
1694
|
window.addEventListener('resize', this.windowResize, false);
|
|
1690
1695
|
if (this.settings.openPosition === 'auto') {
|
|
1691
1696
|
window.addEventListener('scroll', this.windowScroll, false);
|
|
@@ -1781,6 +1786,7 @@ class SlimSelect {
|
|
|
1781
1786
|
if (this.settings.isOpen) {
|
|
1782
1787
|
this.settings.isFullOpen = true;
|
|
1783
1788
|
}
|
|
1789
|
+
document.addEventListener('click', this.documentClick);
|
|
1784
1790
|
}, this.settings.timeoutDelay);
|
|
1785
1791
|
if (this.settings.contentPosition === 'absolute') {
|
|
1786
1792
|
if (this.settings.intervalMove) {
|
|
@@ -1807,6 +1813,7 @@ class SlimSelect {
|
|
|
1807
1813
|
if (this.events.afterClose) {
|
|
1808
1814
|
this.events.afterClose();
|
|
1809
1815
|
}
|
|
1816
|
+
document.removeEventListener('click', this.documentClick);
|
|
1810
1817
|
}, this.settings.timeoutDelay);
|
|
1811
1818
|
if (this.settings.intervalMove) {
|
|
1812
1819
|
clearInterval(this.settings.intervalMove);
|
package/dist/slimselect.es.js
CHANGED
|
@@ -50,45 +50,6 @@ function kebabCase(str) {
|
|
|
50
50
|
return str[0] === str[0].toUpperCase() ? result.substring(1) : result;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
class Settings {
|
|
54
|
-
constructor(settings) {
|
|
55
|
-
this.id = '';
|
|
56
|
-
this.style = '';
|
|
57
|
-
this.class = [];
|
|
58
|
-
this.isMultiple = false;
|
|
59
|
-
this.isOpen = false;
|
|
60
|
-
this.isFullOpen = false;
|
|
61
|
-
this.intervalMove = null;
|
|
62
|
-
if (!settings) {
|
|
63
|
-
settings = {};
|
|
64
|
-
}
|
|
65
|
-
this.id = 'ss-' + generateID();
|
|
66
|
-
this.style = settings.style || '';
|
|
67
|
-
this.class = settings.class || [];
|
|
68
|
-
this.disabled = settings.disabled !== undefined ? settings.disabled : false;
|
|
69
|
-
this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
|
|
70
|
-
this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
|
|
71
|
-
this.ariaLabel = settings.ariaLabel || 'Combobox';
|
|
72
|
-
this.searchPlaceholder = settings.searchPlaceholder || 'Search';
|
|
73
|
-
this.searchText = settings.searchText || 'No Results';
|
|
74
|
-
this.searchingText = settings.searchingText || 'Searching...';
|
|
75
|
-
this.searchHighlight = settings.searchHighlight !== undefined ? settings.searchHighlight : false;
|
|
76
|
-
this.closeOnSelect = settings.closeOnSelect !== undefined ? settings.closeOnSelect : true;
|
|
77
|
-
this.contentLocation = settings.contentLocation || document.body;
|
|
78
|
-
this.contentPosition = settings.contentPosition || 'absolute';
|
|
79
|
-
this.openPosition = settings.openPosition || 'auto';
|
|
80
|
-
this.placeholderText = settings.placeholderText !== undefined ? settings.placeholderText : 'Select Value';
|
|
81
|
-
this.allowDeselect = settings.allowDeselect !== undefined ? settings.allowDeselect : false;
|
|
82
|
-
this.hideSelected = settings.hideSelected !== undefined ? settings.hideSelected : false;
|
|
83
|
-
this.showOptionTooltips = settings.showOptionTooltips !== undefined ? settings.showOptionTooltips : false;
|
|
84
|
-
this.minSelected = settings.minSelected || 0;
|
|
85
|
-
this.maxSelected = settings.maxSelected || 1000;
|
|
86
|
-
this.timeoutDelay = settings.timeoutDelay || 200;
|
|
87
|
-
this.maxValuesShown = settings.maxValuesShown || 20;
|
|
88
|
-
this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
53
|
class Optgroup {
|
|
93
54
|
constructor(optgroup) {
|
|
94
55
|
this.id = !optgroup.id || optgroup.id === '' ? generateID() : optgroup.id;
|
|
@@ -647,14 +608,19 @@ class Render {
|
|
|
647
608
|
}
|
|
648
609
|
}
|
|
649
610
|
if (shouldAdd) {
|
|
650
|
-
if (
|
|
611
|
+
if (this.settings.keepOrder) {
|
|
651
612
|
this.main.values.appendChild(this.multipleValue(selectedOptions[d]));
|
|
652
613
|
}
|
|
653
|
-
else if (d === 0) {
|
|
654
|
-
this.main.values.insertBefore(this.multipleValue(selectedOptions[d]), currentNodes[d]);
|
|
655
|
-
}
|
|
656
614
|
else {
|
|
657
|
-
currentNodes
|
|
615
|
+
if (currentNodes.length === 0) {
|
|
616
|
+
this.main.values.appendChild(this.multipleValue(selectedOptions[d]));
|
|
617
|
+
}
|
|
618
|
+
else if (d === 0) {
|
|
619
|
+
this.main.values.insertBefore(this.multipleValue(selectedOptions[d]), currentNodes[d]);
|
|
620
|
+
}
|
|
621
|
+
else {
|
|
622
|
+
currentNodes[d - 1].insertAdjacentElement('afterend', this.multipleValue(selectedOptions[d]));
|
|
623
|
+
}
|
|
658
624
|
}
|
|
659
625
|
}
|
|
660
626
|
}
|
|
@@ -1560,6 +1526,46 @@ class Select {
|
|
|
1560
1526
|
}
|
|
1561
1527
|
}
|
|
1562
1528
|
|
|
1529
|
+
class Settings {
|
|
1530
|
+
constructor(settings) {
|
|
1531
|
+
this.id = '';
|
|
1532
|
+
this.style = '';
|
|
1533
|
+
this.class = [];
|
|
1534
|
+
this.isMultiple = false;
|
|
1535
|
+
this.isOpen = false;
|
|
1536
|
+
this.isFullOpen = false;
|
|
1537
|
+
this.intervalMove = null;
|
|
1538
|
+
if (!settings) {
|
|
1539
|
+
settings = {};
|
|
1540
|
+
}
|
|
1541
|
+
this.id = 'ss-' + generateID();
|
|
1542
|
+
this.style = settings.style || '';
|
|
1543
|
+
this.class = settings.class || [];
|
|
1544
|
+
this.disabled = settings.disabled !== undefined ? settings.disabled : false;
|
|
1545
|
+
this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
|
|
1546
|
+
this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
|
|
1547
|
+
this.ariaLabel = settings.ariaLabel || 'Combobox';
|
|
1548
|
+
this.searchPlaceholder = settings.searchPlaceholder || 'Search';
|
|
1549
|
+
this.searchText = settings.searchText || 'No Results';
|
|
1550
|
+
this.searchingText = settings.searchingText || 'Searching...';
|
|
1551
|
+
this.searchHighlight = settings.searchHighlight !== undefined ? settings.searchHighlight : false;
|
|
1552
|
+
this.closeOnSelect = settings.closeOnSelect !== undefined ? settings.closeOnSelect : true;
|
|
1553
|
+
this.contentLocation = settings.contentLocation || document.body;
|
|
1554
|
+
this.contentPosition = settings.contentPosition || 'absolute';
|
|
1555
|
+
this.openPosition = settings.openPosition || 'auto';
|
|
1556
|
+
this.placeholderText = settings.placeholderText !== undefined ? settings.placeholderText : 'Select Value';
|
|
1557
|
+
this.allowDeselect = settings.allowDeselect !== undefined ? settings.allowDeselect : false;
|
|
1558
|
+
this.hideSelected = settings.hideSelected !== undefined ? settings.hideSelected : false;
|
|
1559
|
+
this.keepOrder = settings.keepOrder !== undefined ? settings.keepOrder : false;
|
|
1560
|
+
this.showOptionTooltips = settings.showOptionTooltips !== undefined ? settings.showOptionTooltips : false;
|
|
1561
|
+
this.minSelected = settings.minSelected || 0;
|
|
1562
|
+
this.maxSelected = settings.maxSelected || 1000;
|
|
1563
|
+
this.timeoutDelay = settings.timeoutDelay || 200;
|
|
1564
|
+
this.maxValuesShown = settings.maxValuesShown || 20;
|
|
1565
|
+
this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1563
1569
|
class SlimSelect {
|
|
1564
1570
|
constructor(config) {
|
|
1565
1571
|
var _a;
|
|
@@ -1659,7 +1665,7 @@ class SlimSelect {
|
|
|
1659
1665
|
if (config.data) {
|
|
1660
1666
|
this.select.updateOptions(this.store.getData());
|
|
1661
1667
|
}
|
|
1662
|
-
const
|
|
1668
|
+
const renderCallbacks = {
|
|
1663
1669
|
open: this.open.bind(this),
|
|
1664
1670
|
close: this.close.bind(this),
|
|
1665
1671
|
addable: this.events.addable ? this.events.addable : undefined,
|
|
@@ -1669,7 +1675,7 @@ class SlimSelect {
|
|
|
1669
1675
|
beforeChange: this.events.beforeChange,
|
|
1670
1676
|
afterChange: this.events.afterChange,
|
|
1671
1677
|
};
|
|
1672
|
-
this.render = new Render(this.settings, this.store,
|
|
1678
|
+
this.render = new Render(this.settings, this.store, renderCallbacks);
|
|
1673
1679
|
this.render.renderValues();
|
|
1674
1680
|
this.render.renderOptions(this.store.getData());
|
|
1675
1681
|
const selectAriaLabel = this.selectEl.getAttribute('aria-label');
|
|
@@ -1683,7 +1689,6 @@ class SlimSelect {
|
|
|
1683
1689
|
if (this.selectEl.parentNode) {
|
|
1684
1690
|
this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling);
|
|
1685
1691
|
}
|
|
1686
|
-
document.addEventListener('click', this.documentClick);
|
|
1687
1692
|
window.addEventListener('resize', this.windowResize, false);
|
|
1688
1693
|
if (this.settings.openPosition === 'auto') {
|
|
1689
1694
|
window.addEventListener('scroll', this.windowScroll, false);
|
|
@@ -1779,6 +1784,7 @@ class SlimSelect {
|
|
|
1779
1784
|
if (this.settings.isOpen) {
|
|
1780
1785
|
this.settings.isFullOpen = true;
|
|
1781
1786
|
}
|
|
1787
|
+
document.addEventListener('click', this.documentClick);
|
|
1782
1788
|
}, this.settings.timeoutDelay);
|
|
1783
1789
|
if (this.settings.contentPosition === 'absolute') {
|
|
1784
1790
|
if (this.settings.intervalMove) {
|
|
@@ -1805,6 +1811,7 @@ class SlimSelect {
|
|
|
1805
1811
|
if (this.events.afterClose) {
|
|
1806
1812
|
this.events.afterClose();
|
|
1807
1813
|
}
|
|
1814
|
+
document.removeEventListener('click', this.documentClick);
|
|
1808
1815
|
}, this.settings.timeoutDelay);
|
|
1809
1816
|
if (this.settings.intervalMove) {
|
|
1810
1817
|
clearInterval(this.settings.intervalMove);
|
|
@@ -53,45 +53,6 @@ var SlimSelect = (function () {
|
|
|
53
53
|
return str[0] === str[0].toUpperCase() ? result.substring(1) : result;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
class Settings {
|
|
57
|
-
constructor(settings) {
|
|
58
|
-
this.id = '';
|
|
59
|
-
this.style = '';
|
|
60
|
-
this.class = [];
|
|
61
|
-
this.isMultiple = false;
|
|
62
|
-
this.isOpen = false;
|
|
63
|
-
this.isFullOpen = false;
|
|
64
|
-
this.intervalMove = null;
|
|
65
|
-
if (!settings) {
|
|
66
|
-
settings = {};
|
|
67
|
-
}
|
|
68
|
-
this.id = 'ss-' + generateID();
|
|
69
|
-
this.style = settings.style || '';
|
|
70
|
-
this.class = settings.class || [];
|
|
71
|
-
this.disabled = settings.disabled !== undefined ? settings.disabled : false;
|
|
72
|
-
this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
|
|
73
|
-
this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
|
|
74
|
-
this.ariaLabel = settings.ariaLabel || 'Combobox';
|
|
75
|
-
this.searchPlaceholder = settings.searchPlaceholder || 'Search';
|
|
76
|
-
this.searchText = settings.searchText || 'No Results';
|
|
77
|
-
this.searchingText = settings.searchingText || 'Searching...';
|
|
78
|
-
this.searchHighlight = settings.searchHighlight !== undefined ? settings.searchHighlight : false;
|
|
79
|
-
this.closeOnSelect = settings.closeOnSelect !== undefined ? settings.closeOnSelect : true;
|
|
80
|
-
this.contentLocation = settings.contentLocation || document.body;
|
|
81
|
-
this.contentPosition = settings.contentPosition || 'absolute';
|
|
82
|
-
this.openPosition = settings.openPosition || 'auto';
|
|
83
|
-
this.placeholderText = settings.placeholderText !== undefined ? settings.placeholderText : 'Select Value';
|
|
84
|
-
this.allowDeselect = settings.allowDeselect !== undefined ? settings.allowDeselect : false;
|
|
85
|
-
this.hideSelected = settings.hideSelected !== undefined ? settings.hideSelected : false;
|
|
86
|
-
this.showOptionTooltips = settings.showOptionTooltips !== undefined ? settings.showOptionTooltips : false;
|
|
87
|
-
this.minSelected = settings.minSelected || 0;
|
|
88
|
-
this.maxSelected = settings.maxSelected || 1000;
|
|
89
|
-
this.timeoutDelay = settings.timeoutDelay || 200;
|
|
90
|
-
this.maxValuesShown = settings.maxValuesShown || 20;
|
|
91
|
-
this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
56
|
class Optgroup {
|
|
96
57
|
constructor(optgroup) {
|
|
97
58
|
this.id = !optgroup.id || optgroup.id === '' ? generateID() : optgroup.id;
|
|
@@ -650,14 +611,19 @@ var SlimSelect = (function () {
|
|
|
650
611
|
}
|
|
651
612
|
}
|
|
652
613
|
if (shouldAdd) {
|
|
653
|
-
if (
|
|
614
|
+
if (this.settings.keepOrder) {
|
|
654
615
|
this.main.values.appendChild(this.multipleValue(selectedOptions[d]));
|
|
655
616
|
}
|
|
656
|
-
else if (d === 0) {
|
|
657
|
-
this.main.values.insertBefore(this.multipleValue(selectedOptions[d]), currentNodes[d]);
|
|
658
|
-
}
|
|
659
617
|
else {
|
|
660
|
-
currentNodes
|
|
618
|
+
if (currentNodes.length === 0) {
|
|
619
|
+
this.main.values.appendChild(this.multipleValue(selectedOptions[d]));
|
|
620
|
+
}
|
|
621
|
+
else if (d === 0) {
|
|
622
|
+
this.main.values.insertBefore(this.multipleValue(selectedOptions[d]), currentNodes[d]);
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
currentNodes[d - 1].insertAdjacentElement('afterend', this.multipleValue(selectedOptions[d]));
|
|
626
|
+
}
|
|
661
627
|
}
|
|
662
628
|
}
|
|
663
629
|
}
|
|
@@ -1563,6 +1529,46 @@ var SlimSelect = (function () {
|
|
|
1563
1529
|
}
|
|
1564
1530
|
}
|
|
1565
1531
|
|
|
1532
|
+
class Settings {
|
|
1533
|
+
constructor(settings) {
|
|
1534
|
+
this.id = '';
|
|
1535
|
+
this.style = '';
|
|
1536
|
+
this.class = [];
|
|
1537
|
+
this.isMultiple = false;
|
|
1538
|
+
this.isOpen = false;
|
|
1539
|
+
this.isFullOpen = false;
|
|
1540
|
+
this.intervalMove = null;
|
|
1541
|
+
if (!settings) {
|
|
1542
|
+
settings = {};
|
|
1543
|
+
}
|
|
1544
|
+
this.id = 'ss-' + generateID();
|
|
1545
|
+
this.style = settings.style || '';
|
|
1546
|
+
this.class = settings.class || [];
|
|
1547
|
+
this.disabled = settings.disabled !== undefined ? settings.disabled : false;
|
|
1548
|
+
this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
|
|
1549
|
+
this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
|
|
1550
|
+
this.ariaLabel = settings.ariaLabel || 'Combobox';
|
|
1551
|
+
this.searchPlaceholder = settings.searchPlaceholder || 'Search';
|
|
1552
|
+
this.searchText = settings.searchText || 'No Results';
|
|
1553
|
+
this.searchingText = settings.searchingText || 'Searching...';
|
|
1554
|
+
this.searchHighlight = settings.searchHighlight !== undefined ? settings.searchHighlight : false;
|
|
1555
|
+
this.closeOnSelect = settings.closeOnSelect !== undefined ? settings.closeOnSelect : true;
|
|
1556
|
+
this.contentLocation = settings.contentLocation || document.body;
|
|
1557
|
+
this.contentPosition = settings.contentPosition || 'absolute';
|
|
1558
|
+
this.openPosition = settings.openPosition || 'auto';
|
|
1559
|
+
this.placeholderText = settings.placeholderText !== undefined ? settings.placeholderText : 'Select Value';
|
|
1560
|
+
this.allowDeselect = settings.allowDeselect !== undefined ? settings.allowDeselect : false;
|
|
1561
|
+
this.hideSelected = settings.hideSelected !== undefined ? settings.hideSelected : false;
|
|
1562
|
+
this.keepOrder = settings.keepOrder !== undefined ? settings.keepOrder : false;
|
|
1563
|
+
this.showOptionTooltips = settings.showOptionTooltips !== undefined ? settings.showOptionTooltips : false;
|
|
1564
|
+
this.minSelected = settings.minSelected || 0;
|
|
1565
|
+
this.maxSelected = settings.maxSelected || 1000;
|
|
1566
|
+
this.timeoutDelay = settings.timeoutDelay || 200;
|
|
1567
|
+
this.maxValuesShown = settings.maxValuesShown || 20;
|
|
1568
|
+
this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1566
1572
|
class SlimSelect {
|
|
1567
1573
|
constructor(config) {
|
|
1568
1574
|
var _a;
|
|
@@ -1662,7 +1668,7 @@ var SlimSelect = (function () {
|
|
|
1662
1668
|
if (config.data) {
|
|
1663
1669
|
this.select.updateOptions(this.store.getData());
|
|
1664
1670
|
}
|
|
1665
|
-
const
|
|
1671
|
+
const renderCallbacks = {
|
|
1666
1672
|
open: this.open.bind(this),
|
|
1667
1673
|
close: this.close.bind(this),
|
|
1668
1674
|
addable: this.events.addable ? this.events.addable : undefined,
|
|
@@ -1672,7 +1678,7 @@ var SlimSelect = (function () {
|
|
|
1672
1678
|
beforeChange: this.events.beforeChange,
|
|
1673
1679
|
afterChange: this.events.afterChange,
|
|
1674
1680
|
};
|
|
1675
|
-
this.render = new Render(this.settings, this.store,
|
|
1681
|
+
this.render = new Render(this.settings, this.store, renderCallbacks);
|
|
1676
1682
|
this.render.renderValues();
|
|
1677
1683
|
this.render.renderOptions(this.store.getData());
|
|
1678
1684
|
const selectAriaLabel = this.selectEl.getAttribute('aria-label');
|
|
@@ -1686,7 +1692,6 @@ var SlimSelect = (function () {
|
|
|
1686
1692
|
if (this.selectEl.parentNode) {
|
|
1687
1693
|
this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling);
|
|
1688
1694
|
}
|
|
1689
|
-
document.addEventListener('click', this.documentClick);
|
|
1690
1695
|
window.addEventListener('resize', this.windowResize, false);
|
|
1691
1696
|
if (this.settings.openPosition === 'auto') {
|
|
1692
1697
|
window.addEventListener('scroll', this.windowScroll, false);
|
|
@@ -1782,6 +1787,7 @@ var SlimSelect = (function () {
|
|
|
1782
1787
|
if (this.settings.isOpen) {
|
|
1783
1788
|
this.settings.isFullOpen = true;
|
|
1784
1789
|
}
|
|
1790
|
+
document.addEventListener('click', this.documentClick);
|
|
1785
1791
|
}, this.settings.timeoutDelay);
|
|
1786
1792
|
if (this.settings.contentPosition === 'absolute') {
|
|
1787
1793
|
if (this.settings.intervalMove) {
|
|
@@ -1808,6 +1814,7 @@ var SlimSelect = (function () {
|
|
|
1808
1814
|
if (this.events.afterClose) {
|
|
1809
1815
|
this.events.afterClose();
|
|
1810
1816
|
}
|
|
1817
|
+
document.removeEventListener('click', this.documentClick);
|
|
1811
1818
|
}, this.settings.timeoutDelay);
|
|
1812
1819
|
if (this.settings.intervalMove) {
|
|
1813
1820
|
clearInterval(this.settings.intervalMove);
|
package/dist/slimselect.js
CHANGED
|
@@ -56,45 +56,6 @@
|
|
|
56
56
|
return str[0] === str[0].toUpperCase() ? result.substring(1) : result;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
class Settings {
|
|
60
|
-
constructor(settings) {
|
|
61
|
-
this.id = '';
|
|
62
|
-
this.style = '';
|
|
63
|
-
this.class = [];
|
|
64
|
-
this.isMultiple = false;
|
|
65
|
-
this.isOpen = false;
|
|
66
|
-
this.isFullOpen = false;
|
|
67
|
-
this.intervalMove = null;
|
|
68
|
-
if (!settings) {
|
|
69
|
-
settings = {};
|
|
70
|
-
}
|
|
71
|
-
this.id = 'ss-' + generateID();
|
|
72
|
-
this.style = settings.style || '';
|
|
73
|
-
this.class = settings.class || [];
|
|
74
|
-
this.disabled = settings.disabled !== undefined ? settings.disabled : false;
|
|
75
|
-
this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
|
|
76
|
-
this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
|
|
77
|
-
this.ariaLabel = settings.ariaLabel || 'Combobox';
|
|
78
|
-
this.searchPlaceholder = settings.searchPlaceholder || 'Search';
|
|
79
|
-
this.searchText = settings.searchText || 'No Results';
|
|
80
|
-
this.searchingText = settings.searchingText || 'Searching...';
|
|
81
|
-
this.searchHighlight = settings.searchHighlight !== undefined ? settings.searchHighlight : false;
|
|
82
|
-
this.closeOnSelect = settings.closeOnSelect !== undefined ? settings.closeOnSelect : true;
|
|
83
|
-
this.contentLocation = settings.contentLocation || document.body;
|
|
84
|
-
this.contentPosition = settings.contentPosition || 'absolute';
|
|
85
|
-
this.openPosition = settings.openPosition || 'auto';
|
|
86
|
-
this.placeholderText = settings.placeholderText !== undefined ? settings.placeholderText : 'Select Value';
|
|
87
|
-
this.allowDeselect = settings.allowDeselect !== undefined ? settings.allowDeselect : false;
|
|
88
|
-
this.hideSelected = settings.hideSelected !== undefined ? settings.hideSelected : false;
|
|
89
|
-
this.showOptionTooltips = settings.showOptionTooltips !== undefined ? settings.showOptionTooltips : false;
|
|
90
|
-
this.minSelected = settings.minSelected || 0;
|
|
91
|
-
this.maxSelected = settings.maxSelected || 1000;
|
|
92
|
-
this.timeoutDelay = settings.timeoutDelay || 200;
|
|
93
|
-
this.maxValuesShown = settings.maxValuesShown || 20;
|
|
94
|
-
this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
59
|
class Optgroup {
|
|
99
60
|
constructor(optgroup) {
|
|
100
61
|
this.id = !optgroup.id || optgroup.id === '' ? generateID() : optgroup.id;
|
|
@@ -653,14 +614,19 @@
|
|
|
653
614
|
}
|
|
654
615
|
}
|
|
655
616
|
if (shouldAdd) {
|
|
656
|
-
if (
|
|
617
|
+
if (this.settings.keepOrder) {
|
|
657
618
|
this.main.values.appendChild(this.multipleValue(selectedOptions[d]));
|
|
658
619
|
}
|
|
659
|
-
else if (d === 0) {
|
|
660
|
-
this.main.values.insertBefore(this.multipleValue(selectedOptions[d]), currentNodes[d]);
|
|
661
|
-
}
|
|
662
620
|
else {
|
|
663
|
-
currentNodes
|
|
621
|
+
if (currentNodes.length === 0) {
|
|
622
|
+
this.main.values.appendChild(this.multipleValue(selectedOptions[d]));
|
|
623
|
+
}
|
|
624
|
+
else if (d === 0) {
|
|
625
|
+
this.main.values.insertBefore(this.multipleValue(selectedOptions[d]), currentNodes[d]);
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
currentNodes[d - 1].insertAdjacentElement('afterend', this.multipleValue(selectedOptions[d]));
|
|
629
|
+
}
|
|
664
630
|
}
|
|
665
631
|
}
|
|
666
632
|
}
|
|
@@ -1566,6 +1532,46 @@
|
|
|
1566
1532
|
}
|
|
1567
1533
|
}
|
|
1568
1534
|
|
|
1535
|
+
class Settings {
|
|
1536
|
+
constructor(settings) {
|
|
1537
|
+
this.id = '';
|
|
1538
|
+
this.style = '';
|
|
1539
|
+
this.class = [];
|
|
1540
|
+
this.isMultiple = false;
|
|
1541
|
+
this.isOpen = false;
|
|
1542
|
+
this.isFullOpen = false;
|
|
1543
|
+
this.intervalMove = null;
|
|
1544
|
+
if (!settings) {
|
|
1545
|
+
settings = {};
|
|
1546
|
+
}
|
|
1547
|
+
this.id = 'ss-' + generateID();
|
|
1548
|
+
this.style = settings.style || '';
|
|
1549
|
+
this.class = settings.class || [];
|
|
1550
|
+
this.disabled = settings.disabled !== undefined ? settings.disabled : false;
|
|
1551
|
+
this.alwaysOpen = settings.alwaysOpen !== undefined ? settings.alwaysOpen : false;
|
|
1552
|
+
this.showSearch = settings.showSearch !== undefined ? settings.showSearch : true;
|
|
1553
|
+
this.ariaLabel = settings.ariaLabel || 'Combobox';
|
|
1554
|
+
this.searchPlaceholder = settings.searchPlaceholder || 'Search';
|
|
1555
|
+
this.searchText = settings.searchText || 'No Results';
|
|
1556
|
+
this.searchingText = settings.searchingText || 'Searching...';
|
|
1557
|
+
this.searchHighlight = settings.searchHighlight !== undefined ? settings.searchHighlight : false;
|
|
1558
|
+
this.closeOnSelect = settings.closeOnSelect !== undefined ? settings.closeOnSelect : true;
|
|
1559
|
+
this.contentLocation = settings.contentLocation || document.body;
|
|
1560
|
+
this.contentPosition = settings.contentPosition || 'absolute';
|
|
1561
|
+
this.openPosition = settings.openPosition || 'auto';
|
|
1562
|
+
this.placeholderText = settings.placeholderText !== undefined ? settings.placeholderText : 'Select Value';
|
|
1563
|
+
this.allowDeselect = settings.allowDeselect !== undefined ? settings.allowDeselect : false;
|
|
1564
|
+
this.hideSelected = settings.hideSelected !== undefined ? settings.hideSelected : false;
|
|
1565
|
+
this.keepOrder = settings.keepOrder !== undefined ? settings.keepOrder : false;
|
|
1566
|
+
this.showOptionTooltips = settings.showOptionTooltips !== undefined ? settings.showOptionTooltips : false;
|
|
1567
|
+
this.minSelected = settings.minSelected || 0;
|
|
1568
|
+
this.maxSelected = settings.maxSelected || 1000;
|
|
1569
|
+
this.timeoutDelay = settings.timeoutDelay || 200;
|
|
1570
|
+
this.maxValuesShown = settings.maxValuesShown || 20;
|
|
1571
|
+
this.maxValuesMessage = settings.maxValuesMessage || '{number} selected';
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1569
1575
|
class SlimSelect {
|
|
1570
1576
|
constructor(config) {
|
|
1571
1577
|
var _a;
|
|
@@ -1665,7 +1671,7 @@
|
|
|
1665
1671
|
if (config.data) {
|
|
1666
1672
|
this.select.updateOptions(this.store.getData());
|
|
1667
1673
|
}
|
|
1668
|
-
const
|
|
1674
|
+
const renderCallbacks = {
|
|
1669
1675
|
open: this.open.bind(this),
|
|
1670
1676
|
close: this.close.bind(this),
|
|
1671
1677
|
addable: this.events.addable ? this.events.addable : undefined,
|
|
@@ -1675,7 +1681,7 @@
|
|
|
1675
1681
|
beforeChange: this.events.beforeChange,
|
|
1676
1682
|
afterChange: this.events.afterChange,
|
|
1677
1683
|
};
|
|
1678
|
-
this.render = new Render(this.settings, this.store,
|
|
1684
|
+
this.render = new Render(this.settings, this.store, renderCallbacks);
|
|
1679
1685
|
this.render.renderValues();
|
|
1680
1686
|
this.render.renderOptions(this.store.getData());
|
|
1681
1687
|
const selectAriaLabel = this.selectEl.getAttribute('aria-label');
|
|
@@ -1689,7 +1695,6 @@
|
|
|
1689
1695
|
if (this.selectEl.parentNode) {
|
|
1690
1696
|
this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling);
|
|
1691
1697
|
}
|
|
1692
|
-
document.addEventListener('click', this.documentClick);
|
|
1693
1698
|
window.addEventListener('resize', this.windowResize, false);
|
|
1694
1699
|
if (this.settings.openPosition === 'auto') {
|
|
1695
1700
|
window.addEventListener('scroll', this.windowScroll, false);
|
|
@@ -1785,6 +1790,7 @@
|
|
|
1785
1790
|
if (this.settings.isOpen) {
|
|
1786
1791
|
this.settings.isFullOpen = true;
|
|
1787
1792
|
}
|
|
1793
|
+
document.addEventListener('click', this.documentClick);
|
|
1788
1794
|
}, this.settings.timeoutDelay);
|
|
1789
1795
|
if (this.settings.contentPosition === 'absolute') {
|
|
1790
1796
|
if (this.settings.intervalMove) {
|
|
@@ -1811,6 +1817,7 @@
|
|
|
1811
1817
|
if (this.events.afterClose) {
|
|
1812
1818
|
this.events.afterClose();
|
|
1813
1819
|
}
|
|
1820
|
+
document.removeEventListener('click', this.documentClick);
|
|
1814
1821
|
}, this.settings.timeoutDelay);
|
|
1815
1822
|
if (this.settings.intervalMove) {
|
|
1816
1823
|
clearInterval(this.settings.intervalMove);
|