@finqu/cool 1.1.9 → 1.2.3

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.
Files changed (82) hide show
  1. package/dist/css/cool-grid.css +2 -2
  2. package/dist/css/cool-grid.css.map +3 -3
  3. package/dist/css/cool-grid.min.css +1 -1
  4. package/dist/css/cool-grid.min.css.map +1 -1
  5. package/dist/css/cool-reboot.css +6 -2
  6. package/dist/css/cool-reboot.css.map +11 -9
  7. package/dist/css/cool-reboot.min.css +2 -2
  8. package/dist/css/cool-reboot.min.css.map +1 -1
  9. package/dist/css/cool.css +2848 -771
  10. package/dist/css/cool.css.map +33 -29
  11. package/dist/css/cool.min.css +2 -2
  12. package/dist/css/cool.min.css.map +1 -1
  13. package/dist/js/cool.bundle.js +659 -185
  14. package/dist/js/cool.bundle.js.map +1 -1
  15. package/dist/js/cool.bundle.min.js +2 -2
  16. package/dist/js/cool.bundle.min.js.map +1 -1
  17. package/dist/js/cool.esm.js +659 -185
  18. package/dist/js/cool.esm.js.map +1 -1
  19. package/dist/js/cool.esm.min.js +2 -2
  20. package/dist/js/cool.esm.min.js.map +1 -1
  21. package/dist/js/cool.js +659 -185
  22. package/dist/js/cool.js.map +1 -1
  23. package/dist/js/cool.min.js +2 -2
  24. package/dist/js/cool.min.js.map +1 -1
  25. package/html/dropdown-test.html +200 -0
  26. package/html/index.html +1418 -101
  27. package/js/dist/collapse.js +1043 -629
  28. package/js/dist/collapse.js.map +1 -1
  29. package/js/dist/common.js +876 -506
  30. package/js/dist/common.js.map +1 -1
  31. package/js/dist/dropdown.js +3451 -1867
  32. package/js/dist/dropdown.js.map +1 -1
  33. package/js/dist/popover.js +273 -58
  34. package/js/dist/popover.js.map +1 -1
  35. package/js/dist/sectiontabs.js +273 -58
  36. package/js/dist/sectiontabs.js.map +1 -1
  37. package/js/dist/select.js +10031 -3660
  38. package/js/dist/select.js.map +1 -1
  39. package/js/dist/tooltip.js +1703 -1434
  40. package/js/dist/tooltip.js.map +1 -1
  41. package/js/src/abstract-ui-component.js +16 -5
  42. package/js/src/collapse.js +24 -10
  43. package/js/src/common.js +26 -0
  44. package/js/src/dialog.js +12 -18
  45. package/js/src/dropdown.js +79 -7
  46. package/js/src/popover.js +2 -2
  47. package/js/src/section-tabs.js +2 -2
  48. package/js/src/select.js +582 -181
  49. package/js/src/toast.js +2 -2
  50. package/js/src/tooltip.js +7 -2
  51. package/js/src/util/index.js +10 -0
  52. package/package.json +21 -21
  53. package/scss/_alert.scss +79 -82
  54. package/scss/_badge.scss +16 -22
  55. package/scss/_button-group.scss +4 -0
  56. package/scss/_buttons.scss +3 -3
  57. package/scss/_custom-forms.scss +14 -12
  58. package/scss/_dialog.scss +17 -5
  59. package/scss/_dropdown.scss +1 -4
  60. package/scss/_frame.scss +24 -3
  61. package/scss/_functions.scss +10 -0
  62. package/scss/_images.scss +52 -2
  63. package/scss/_input-group.scss +12 -6
  64. package/scss/_mixins.scss +1 -0
  65. package/scss/_navbar.scss +40 -0
  66. package/scss/_notification.scss +13 -0
  67. package/scss/_reboot.scss +4 -0
  68. package/scss/_section.scss +28 -2
  69. package/scss/_select.scss +10 -1
  70. package/scss/_tables.scss +2 -1
  71. package/scss/_type.scss +37 -6
  72. package/scss/_variables.scss +6 -5
  73. package/scss/cool-grid.scss +1 -1
  74. package/scss/cool-reboot.scss +1 -1
  75. package/scss/cool.scss +3 -2
  76. package/scss/mixins/_alert-variant.scss +13 -28
  77. package/scss/mixins/_badge-variant.scss +27 -5
  78. package/scss/mixins/_notification-variant.scss +7 -0
  79. package/scss/mixins/_text-truncate.scss +77 -4
  80. package/scss/utilities/_collapse.scss +2 -2
  81. package/scss/utilities/_cursor.scss +14 -2
  82. package/scss/utilities/_text.scss +4 -2
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Cool UI v1.1.8 (https://finqu.fi)
2
+ * Cool UI v1.2.2 (https://finqu.fi)
3
3
  * Copyright 2011-2019 Finqu Oy
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  */
@@ -1336,6 +1336,10 @@
1336
1336
  linkDisabled = true;
1337
1337
  }
1338
1338
 
1339
+ if (target.hasClass('table-link-exclude')) {
1340
+ linkDisabled = true;
1341
+ }
1342
+
1339
1343
  if (target.is('td, .td, img') && !linkDisabled) {
1340
1344
  if (e.ctrlKey || e.metaKey) {
1341
1345
  window.open(href, '_blank');
@@ -1372,11 +1376,30 @@
1372
1376
  btnDisabled = true;
1373
1377
  }
1374
1378
 
1379
+ if (target.hasClass('table-btn-exclude')) {
1380
+ btnDisabled = true;
1381
+ }
1382
+
1375
1383
  if (target.is('td, .td, img') && !btnDisabled) {
1376
1384
  $(btn).click();
1377
1385
  } else {
1378
1386
  return;
1379
1387
  }
1388
+ }); // button toggle
1389
+
1390
+ $(document).on('click', '.btn-group-toggle .btn > input', function (e) {
1391
+ e.stopPropagation();
1392
+ });
1393
+ $(document).on('click', '.btn-group-toggle .btn', function () {
1394
+ $(this).find('input').trigger('click');
1395
+ $(this).parent().find('input').trigger('change');
1396
+ });
1397
+ $(document).on('change', '.btn-group-toggle .btn > input', function () {
1398
+ if ($(this).is(':checked')) {
1399
+ $(this).parent().addClass('active');
1400
+ } else {
1401
+ $(this).parent().removeClass('active');
1402
+ }
1380
1403
  }); // Force select element unfocus after change
1381
1404
 
1382
1405
  $('select').on('change', function () {
@@ -1513,6 +1536,14 @@
1513
1536
  return result;
1514
1537
  };
1515
1538
 
1539
+ $.event.special.destroyed = {
1540
+ remove: function remove(obj) {
1541
+ if (obj.handler) {
1542
+ obj.handler();
1543
+ }
1544
+ }
1545
+ };
1546
+
1516
1547
  var AbstractUIComponent =
1517
1548
  /*#__PURE__*/
1518
1549
  function () {
@@ -1525,7 +1556,7 @@
1525
1556
  var onInit = this.opts.onInit;
1526
1557
 
1527
1558
  if (typeof onInit === 'function') {
1528
- onInit.call(this.el);
1559
+ onInit.call(this);
1529
1560
  }
1530
1561
  } // Update callback
1531
1562
  ;
@@ -1534,7 +1565,7 @@
1534
1565
  var onUpdate = this.opts.onUpdate;
1535
1566
 
1536
1567
  if (typeof onUpdate === 'function') {
1537
- onUpdate.call(this.el);
1568
+ onUpdate.call(this);
1538
1569
  }
1539
1570
  } // Destroy callback
1540
1571
  ;
@@ -1543,7 +1574,7 @@
1543
1574
  var onDestroy = this.opts.onDestroy;
1544
1575
 
1545
1576
  if (typeof onDestroy === 'function') {
1546
- onDestroy.call(this.el);
1577
+ onDestroy.call(this);
1547
1578
  }
1548
1579
  } // Show callback
1549
1580
  ;
@@ -1552,7 +1583,7 @@
1552
1583
  var onShow = this.opts.onShow;
1553
1584
 
1554
1585
  if (typeof onShow === 'function') {
1555
- onShow.call(this.el);
1586
+ onShow.call(this);
1556
1587
  }
1557
1588
  } // Close callback
1558
1589
  ;
@@ -1561,7 +1592,16 @@
1561
1592
  var onClose = this.opts.onClose;
1562
1593
 
1563
1594
  if (typeof onClose === 'function') {
1564
- onClose.call(this.el);
1595
+ onClose.call(this);
1596
+ }
1597
+ } // Reset callback
1598
+ ;
1599
+
1600
+ _proto.onReset = function onReset() {
1601
+ var onReset = this.opts.onReset;
1602
+
1603
+ if (typeof onReset === 'function') {
1604
+ onReset.call(this);
1565
1605
  }
1566
1606
  } // Debug log
1567
1607
  ;
@@ -2120,7 +2160,7 @@
2120
2160
  _proto.init = function init() {
2121
2161
  var _this2 = this;
2122
2162
 
2123
- $.when(this.buildCache()).then(function () {
2163
+ this.buildCache().then(function () {
2124
2164
  _this2.buildScroll();
2125
2165
 
2126
2166
  _this2.bindEvents();
@@ -2145,112 +2185,174 @@
2145
2185
  this.buildCache();
2146
2186
  this.bindEvents();
2147
2187
  this.onUpdate();
2148
- } // Cache DOM nodes for performance
2188
+ } // Reset plugin data
2149
2189
  ;
2150
2190
 
2151
- _proto.buildCache = function buildCache() {
2152
- var _this3 = this;
2153
-
2154
- this.$el = $(this.el);
2155
- this.$selectHeader = this.$el.find('.select-header');
2156
- this.$selectIconContainer = this.$selectHeader.find('.select-icon');
2157
- this.name = this.$el.data('name') ? this.$el.data('name') : this.opts.name;
2158
- this.scrollContentHeight = this.$el.data('scrollContentHeight') ? this.$el.data('scrollContentHeight') : this.opts.scrollContentHeight;
2159
- this.items = this.$el.data('items') ? this.$el.data('items') : this.opts.items;
2191
+ _proto.reset = function reset() {
2160
2192
  this.data = {};
2161
2193
  this.data[this.name] = [];
2162
- this.searchData = [];
2163
- this.searchApi = this.$el.data('searchApi') ? this.$el.data('searchApi') : this.opts.searchApi;
2164
- this.type = this.$el.data('type') ? this.$el.data('type') : this.opts.type;
2165
- this.contentOpen = false;
2194
+ this.items = [];
2195
+ this.$select.find('.select-item').remove();
2196
+ this.$selectItems = [];
2197
+ this.$selectIconContainer.html(this.selectIconDefault);
2166
2198
 
2167
- if (this.$el.data('setData') && this.$el.data('setData') != '') {
2168
- this.data = this.$el.data('setData');
2199
+ if (this.data[this.name].length == 0 && this.dynamicTitle && this.dynamicTitleDefault && this.dynamicTitleDefault !== 0 && this.$selectTitle.text().trim() == 0 && (this.$selectItems.length > 0 || this.searchApi)) {
2200
+ this.$selectTitle.html(this.dynamicTitleDefault);
2169
2201
  }
2170
2202
 
2171
- if (this.$el.find('.select-search')) {
2172
- this.showSearch = true;
2173
- } else {
2174
- this.showSearch = this.$el.data('showSearch') ? this.$el.data('showSearch') : this.opts.showSearch;
2203
+ if (this.$selectItems.length == 0 && !this.searchApi && this.dynamicTitle && this.dynamicTitleEmptyDefault && this.dynamicTitleEmptyDefault !== 0) {
2204
+ this.$selectHeader.css('cursor', 'default');
2205
+ this.$selectIconContainer.addClass('d-none');
2206
+ this.$selectTitle.html(this.dynamicTitleEmptyDefault);
2175
2207
  }
2176
2208
 
2177
- if (this.$el.find('.select-footer')) {
2178
- this.showFooter = true;
2179
- } else {
2180
- this.showFooter = this.$el.data('showFooter') ? this.$el.data('showFooter') : this.opts.showFooter;
2209
+ if (this.showSearch) {
2210
+ this.searchData = [];
2211
+ this.$searchInput.val('');
2212
+ this.searchString = '';
2213
+ this.search.call(this);
2181
2214
  }
2215
+ } // Cache DOM nodes for performance
2216
+ ;
2182
2217
 
2183
- if (this.items.length) {
2184
- var items = this._renderItemList(this.items);
2218
+ _proto.buildCache = function buildCache() {
2219
+ var _this3 = this;
2185
2220
 
2186
- this.$select = $("\n <div class=\"select-content\">\n\n " + this._renderSearch() + "\n\n <div class=\"select-scrollable-content\">" + items + "</div>\n\n " + this._renderFooter() + "\n\n </div>\n ");
2187
- this.$el.append(this.$select);
2188
- this.$scrollableContent = this.$select.find('.select-scrollable-content') ? this.$select.find('.select-scrollable-content') : false;
2189
- this.$selectItems = this.$select.find('.select-item');
2190
- this.$selectLabels = this.$select.find('[data-label]');
2221
+ return new Promise(function (primaryResolve, primaryReject) {
2222
+ var self = _this3;
2223
+ _this3.$el = $(_this3.el);
2224
+ _this3.$container = _this3.$el.parent();
2225
+ _this3.$selectHeader = _this3.$el.find('.select-header');
2226
+ _this3.$selectTitle = _this3.$el.find('.select-title');
2227
+ _this3.$selectIconContainer = _this3.$selectHeader.find('.select-icon');
2228
+ _this3.selectIconDefault = _this3.$selectHeader.find('.select-icon') ? _this3.$selectHeader.find('.select-icon').html() : '<i class="' + (_this3.opts.faPro ? 'fal' : 'fas') + 'fa-angle-down icon"></i>';
2229
+ _this3.name = _this3.$el.data('name') ? _this3.$el.data('name') : _this3.opts.name;
2230
+ _this3.scrollContentHeight = _this3.$el.data('scrollContentHeight') ? _this3.$el.data('scrollContentHeight') : _this3.opts.scrollContentHeight;
2231
+ _this3.items = _this3.$el.data('items') ? _this3.$el.data('items') : _this3.opts.items;
2232
+ _this3.data = {};
2233
+ _this3.data[_this3.name] = [];
2234
+ _this3.searchData = [];
2235
+ _this3.searchApi = _this3.$el.data('searchApi') ? _this3.$el.data('searchApi') : _this3.opts.searchApi;
2236
+ _this3.type = _this3.$el.data('type') ? _this3.$el.data('type') : _this3.opts.type;
2237
+ _this3.contentOpen = false;
2238
+ _this3.searchPlaceholder = _this3.$el.data('search-placeholder') ? _this3.$el.data('search-placeholder') : _this3.opts.searchPlaceholder;
2239
+ _this3.btnCloseText = _this3.$el.data('btn-close-text') ? _this3.$el.data('btn-close-text') : _this3.opts.btnCloseText;
2240
+ _this3.labelTemplate = _this3.opts.labelTemplate;
2241
+ _this3.confirmCheck = _this3.opts.confirmCheck;
2242
+ _this3.confirmUncheck = _this3.opts.confirmUncheck;
2243
+ _this3.preventUncheck = _this3.opts.preventUncheck;
2244
+ _this3.dynamicTitle = _this3.$el.data('dynamicTitle') ? _this3.$el.data('dynamicTitle') : _this3.opts.dynamicTitle;
2245
+ _this3.dynamicTitleDefault = _this3.$el.data('dynamicTitleDefault') ? _this3.$el.data('dynamicTitleDefault') : _this3.opts.dynamicTitleDefault;
2246
+ _this3.dynamicTitleEmptyDefault = _this3.$el.data('dynamicTitleEmptyDefault') ? _this3.$el.data('dynamicTitleEmptyDefault') : _this3.opts.dynamicTitleEmptyDefault;
2247
+ _this3.allowNoneOnRadioSelect = _this3.$el.data('allowNoneOnRadioSelect') ? _this3.$el.data('allowNoneOnRadioSelect') : _this3.opts.allowNoneOnRadioSelect;
2248
+ _this3.showValidStateIcon = _this3.$el.data('showValidStateIcon') ? _this3.$el.data('showValidStateIcon') : _this3.opts.showValidStateIcon;
2249
+ _this3.itemsToExclude = _this3.$el.data('itemsToExclude') ? _this3.$el.data('itemsToExclude').replace(/\s/g, '').split(',') : _this3.opts.itemsToExclude;
2250
+ _this3.preventClose = false;
2251
+
2252
+ if (_this3.itemsToExclude.length > 0) {
2253
+ _this3.itemsToExclude = _this3.itemsToExclude.map(Number);
2254
+ }
2191
2255
 
2192
- if (this.showSearch) {
2193
- this.$searchContainer = this.$select.find('.select-search');
2194
- this.$searchInput = this.$select.find('[name="select-search"]');
2195
- this.$searchIconContainer = this.$select.find('.select-search-icon');
2196
- this.$clearSearchButton = this.$select.find('[data-clear-search]');
2256
+ if (_this3.opts.setData) {
2257
+ _this3.data = _this3.opts.setData;
2197
2258
  }
2198
2259
 
2199
- if (this.showFooter) {
2200
- this.$footerContainer = this.$select.find('.select-footer');
2201
- this.$closeButton = this.$select.find('[data-select-close]');
2260
+ if (_this3.$el.data('setData') && _this3.$el.data('setData') != '') {
2261
+ _this3.data = _this3.$el.data('setData');
2202
2262
  }
2203
2263
 
2204
- $.each(this.$selectLabels, function (i, el) {
2205
- this.searchData.push({
2206
- id: i,
2207
- val: $(el).text().trim()
2264
+ if (typeof _this3.data[_this3.name].filter !== 'undefined' && self.itemsToExclude) {
2265
+ _this3.data[_this3.name] = _this3.data[_this3.name].filter(function (item) {
2266
+ return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2208
2267
  });
2209
- });
2210
- this.log(this.$el);
2211
- this.log(this.$select);
2212
- this.log(this.$scrollableContent);
2213
- this.log('Name: ' + this.name);
2214
- this.log('Show search: ' + this.showSearch);
2215
- this.log('Show footer: ' + this.showFooter);
2216
- this.log('Scroll content height: ' + this.scrollContentHeight + 'px');
2217
- this.log(this.items);
2218
- this.log(this.searchData);
2219
- } else {
2220
- this.$select = this.$el.find('.select-content');
2221
- this.$scrollableContent = this.$select.find('.select-scrollable-content');
2222
- this.$selectItems = this.$select.find('.select-item');
2223
- this.$selectLabels = this.$select.find('[data-label]');
2268
+ }
2224
2269
 
2225
- if (this.showSearch) {
2226
- this.$searchContainer = this.$select.find('.select-search');
2227
- this.$searchInput = this.$select.find('[name="select-search"]');
2228
- this.$searchIconContainer = this.$select.find('.select-search-icon');
2229
- this.$clearSearchButton = this.$select.find('[data-clear-search]');
2270
+ if (typeof _this3.items.filter !== 'undefined' && self.itemsToExclude) {
2271
+ _this3.items = _this3.items.filter(function (item) {
2272
+ return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2273
+ });
2230
2274
  }
2231
2275
 
2232
- if (this.showFooter) {
2233
- this.$footerContainer = this.$select.find('.select-footer');
2234
- this.$closeButton = this.$select.find('[data-select-close]');
2276
+ if (_this3.$el.find('.select-search').length) {
2277
+ _this3.showSearch = true;
2278
+ } else {
2279
+ _this3.showSearch = _this3.$el.data('showSearch') ? _this3.$el.data('showSearch') : _this3.opts.showSearch;
2235
2280
  }
2236
2281
 
2237
- $.each(this.$selectLabels, function (i, el) {
2238
- _this3.searchData.push({
2239
- id: i,
2240
- val: $(el).text().trim()
2241
- });
2282
+ if (_this3.$el.find('.select-footer').length) {
2283
+ _this3.showFooter = true;
2284
+ } else {
2285
+ _this3.showFooter = _this3.$el.data('showFooter') ? _this3.$el.data('showFooter') : _this3.opts.showFooter;
2286
+ }
2287
+
2288
+ _this3.$select = _this3.$el.find('.select-content');
2289
+ new Promise(function (secondaryResolve, secondaryReject) {
2290
+ if (!_this3.$select.length) {
2291
+ var items = _this3._renderItemList(_this3.items);
2292
+
2293
+ _this3.$select = $("\n <div class=\"select-content\">\n\n " + _this3._renderSearch() + "\n\n <div class=\"select-scrollable-content\">" + items + "</div>\n\n " + _this3._renderFooter() + "\n\n </div>\n ");
2294
+
2295
+ _this3.$el.append(_this3.$select);
2296
+
2297
+ secondaryResolve();
2298
+ } else {
2299
+ secondaryResolve();
2300
+ }
2301
+ }).then(function () {
2302
+ _this3.$scrollableContent = _this3.$select.find('.select-scrollable-content') ? _this3.$select.find('.select-scrollable-content') : false;
2303
+ _this3.$selectItems = _this3.$select.find('.select-item');
2304
+
2305
+ if (_this3.data[_this3.name].length == 0 && _this3.dynamicTitle && _this3.dynamicTitleDefault && _this3.dynamicTitleDefault !== 0 && _this3.$selectTitle.text().trim() == 0 && (_this3.$selectItems.length > 0 || _this3.searchApi)) {
2306
+ _this3.$selectTitle.html(_this3.dynamicTitleDefault);
2307
+ }
2308
+
2309
+ if (_this3.$selectItems.length == 0 && !_this3.searchApi && _this3.dynamicTitle && _this3.dynamicTitleEmptyDefault && _this3.dynamicTitleEmptyDefault !== 0) {
2310
+ _this3.$selectHeader.css('cursor', 'default');
2311
+
2312
+ _this3.$selectIconContainer.addClass('d-none');
2313
+
2314
+ _this3.$selectTitle.html(_this3.dynamicTitleEmptyDefault);
2315
+ }
2316
+
2317
+ if (_this3.showSearch) {
2318
+ _this3.$searchContainer = _this3.$select.find('.select-search');
2319
+ _this3.$searchInput = _this3.$select.find('[name="select-search"]');
2320
+ _this3.$searchIconContainer = _this3.$select.find('.select-search-icon');
2321
+ _this3.$clearSearchButton = _this3.$select.find('[data-clear-search]'); // Prevent tabfocus from breaking select functionality
2322
+
2323
+ _this3.$searchInput[0].tabIndex = -1;
2324
+ }
2325
+
2326
+ if (_this3.showFooter) {
2327
+ _this3.$footerContainer = _this3.$select.find('.select-footer');
2328
+ _this3.$closeButton = _this3.$select.find('[data-select-close]'); // Prevent tabfocus from breaking select functionality
2329
+
2330
+ _this3.$closeButton[0].tabIndex = -1;
2331
+ }
2332
+
2333
+ _this3.buildSearchData();
2334
+
2335
+ _this3.log(_this3.$el);
2336
+
2337
+ _this3.log(_this3.$select);
2338
+
2339
+ _this3.log(_this3.$scrollableContent);
2340
+
2341
+ _this3.log('Name: ' + _this3.name);
2342
+
2343
+ _this3.log('Show search: ' + _this3.showSearch);
2344
+
2345
+ _this3.log('Show footer: ' + _this3.showFooter);
2346
+
2347
+ _this3.log('Scroll content height: ' + _this3.scrollContentHeight + 'px');
2348
+
2349
+ _this3.log(_this3.items);
2350
+
2351
+ _this3.log(_this3.searchData);
2352
+
2353
+ primaryResolve();
2242
2354
  });
2243
- this.log(this.$el);
2244
- this.log(this.$select);
2245
- this.log(this.$scrollableContent);
2246
- this.log('Name: ' + this.name);
2247
- this.log('Show search: ' + this.showSearch);
2248
- this.log('Show footer: ' + this.showFooter);
2249
- this.log('Scroll content height: ' + this.scrollContentHeight + 'px');
2250
- this.log(this.items);
2251
- this.log(this.searchData);
2252
- return true;
2253
- }
2355
+ });
2254
2356
  } // Build scroll
2255
2357
  ;
2256
2358
 
@@ -2283,7 +2385,9 @@
2283
2385
  scrollYMarginOffset: -1,
2284
2386
  suppressScrollY: true,
2285
2387
  suppressScrollX: true
2286
- });
2388
+ }); // Prevent tabfocus from breaking select functionality
2389
+
2390
+ this.$scrollableContent.find('[tabindex="0"]').attr('tabindex', -1);
2287
2391
 
2288
2392
  if (this.$scrollableContent[0].offsetHeight < this.$scrollableContent[0].scrollHeight) {
2289
2393
  this.$scrollableContent.addClass('ps-show-rail-y');
@@ -2291,32 +2395,94 @@
2291
2395
  }
2292
2396
  }
2293
2397
  }
2398
+ } // Build search data
2399
+ ;
2400
+
2401
+ _proto.buildSearchData = function buildSearchData() {
2402
+ var _this4 = this;
2403
+
2404
+ return new Promise(function (resolve, reject) {
2405
+ _this4.searchData = [];
2406
+
2407
+ var selectLabels = _this4.$select.find('[data-label]');
2408
+
2409
+ $.each(selectLabels, function (i, el) {
2410
+ _this4.searchData.push({
2411
+ id: i,
2412
+ val: $(el).text().trim()
2413
+ });
2414
+ });
2415
+ resolve();
2416
+ });
2294
2417
  } // Bind events that trigger methods
2295
2418
  ;
2296
2419
 
2297
2420
  _proto.bindEvents = function bindEvents() {
2298
- var _this4 = this;
2421
+ var _this5 = this;
2299
2422
 
2300
2423
  var self = this;
2301
2424
  this.$selectHeader.on('click' + '.' + NAME$1, function () {
2302
- if (_this4.contentOpen) {
2303
- _this4.close();
2304
- } else {
2305
- _this4.show();
2425
+ if (_this5.contentOpen) {
2426
+ _this5.close();
2427
+ } else if (_this5.$selectItems.length > 0 || _this5.searchApi) {
2428
+ _this5.show();
2306
2429
  }
2307
2430
  });
2308
2431
  this.$el.on('change' + '.' + NAME$1, 'input[type="checkbox"]', function () {
2432
+ var el = this;
2309
2433
  var val = $(this).val();
2434
+ var closeTimeout = 600; // ms
2310
2435
 
2311
- if (this.checked) {
2436
+ self.preventClose = true;
2437
+
2438
+ if (typeof self.confirmCheck === 'function' && el.checked) {
2439
+ el.checked = false;
2440
+ self.confirmCheck(function (cb) {
2441
+ if (cb == 'confirmed') {
2442
+ self.data[self.name].indexOf(val) === -1 ? self.data[self.name].push(val) : false;
2443
+ el.checked = true;
2444
+ self.onSelect(el);
2445
+ }
2446
+
2447
+ setTimeout(function () {
2448
+ self.preventClose = false;
2449
+ }, closeTimeout);
2450
+ }, el);
2451
+ } else if (el.checked) {
2312
2452
  self.data[self.name].indexOf(val) === -1 ? self.data[self.name].push(val) : false;
2313
- } else {
2453
+ self.onSelect(el);
2454
+ setTimeout(function () {
2455
+ self.preventClose = false;
2456
+ }, closeTimeout);
2457
+ } else if (typeof self.confirmUncheck === 'function' && !el.checked) {
2458
+ el.checked = true;
2459
+ self.confirmUncheck(function (cb) {
2460
+ if (cb == 'confirmed') {
2461
+ self.data[self.name] = self.data[self.name].filter(function (n) {
2462
+ return n != val;
2463
+ });
2464
+ el.checked = false;
2465
+ self.onSelect(el);
2466
+ }
2467
+
2468
+ setTimeout(function () {
2469
+ self.preventClose = false;
2470
+ }, closeTimeout);
2471
+ }, el);
2472
+ } else if (!el.checked && !self.preventUncheck) {
2314
2473
  self.data[self.name] = self.data[self.name].filter(function (n) {
2315
2474
  return n != val;
2316
2475
  });
2476
+ self.onSelect(el);
2477
+ setTimeout(function () {
2478
+ self.preventClose = false;
2479
+ }, closeTimeout);
2480
+ } else if (!el.checked && self.preventUncheck) {
2481
+ el.checked = true;
2482
+ setTimeout(function () {
2483
+ self.preventClose = false;
2484
+ }, closeTimeout);
2317
2485
  }
2318
-
2319
- self.onSelect(this);
2320
2486
  });
2321
2487
  this.$el.on('change' + '.' + NAME$1, 'input[type="radio"]', function () {
2322
2488
  var val = $(this).val();
@@ -2330,12 +2496,20 @@
2330
2496
  }
2331
2497
  });
2332
2498
  this.$el.on('click' + '.' + NAME$1, 'input[type="radio"]', function () {
2333
- if ($(this).hasClass('checked')) {
2334
- self.data[plugin.name] = [];
2499
+ if ($(this).hasClass('checked') && self.allowNoneOnRadioSelect) {
2500
+ self.data[self.name] = [];
2335
2501
  $(this).prop('checked', false);
2336
2502
  $(this).removeClass('checked');
2503
+
2504
+ if (self.dynamicTitle) {
2505
+ self.$selectTitle.html(self.dynamicTitleDefault);
2506
+ }
2337
2507
  } else {
2338
2508
  $(this).addClass('checked');
2509
+
2510
+ if (self.dynamicTitle) {
2511
+ self.$selectTitle.html($(this).parent().find('[data-label]').text());
2512
+ }
2339
2513
  }
2340
2514
 
2341
2515
  self.onSelect(this);
@@ -2363,7 +2537,7 @@
2363
2537
  this.$searchInput.on('focusout' + '.' + NAME$1, function () {
2364
2538
  self.$searchContainer.removeClass('focused');
2365
2539
  });
2366
- this.$clearSearchButton.on('click' + '.' + NAME$1, function () {
2540
+ this.$searchContainer.on('click' + '.' + NAME$1, '[data-clear-search]', function () {
2367
2541
  if (self.searchString.length) {
2368
2542
  self.$searchInput.val('');
2369
2543
  self.searchString = '';
@@ -2376,12 +2550,12 @@
2376
2550
 
2377
2551
  if (this.showFooter) {
2378
2552
  this.$closeButton.on('click' + '.' + NAME$1, function () {
2379
- _this4.close();
2553
+ _this5.close();
2380
2554
  });
2381
2555
  }
2382
2556
 
2383
2557
  $(document).on('touchstart click', function (e) {
2384
- if (!self.$el.is(e.target) && self.$el.has(e.target).length === 0 && self.contentOpen) {
2558
+ if (!self.$el.is(e.target) && !self.$el.has(e.target).length && self.contentOpen && !self.preventClose) {
2385
2559
  self.close.call(self);
2386
2560
  }
2387
2561
  });
@@ -2404,9 +2578,13 @@
2404
2578
 
2405
2579
  _proto.setData = function setData() {
2406
2580
  var self = this;
2407
- var type = null;
2408
2581
  var faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2409
- this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-check text-green icon\"></i>");
2582
+
2583
+ if (this.showValidStateIcon) {
2584
+ this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-check text-green icon\"></i>");
2585
+ } else {
2586
+ this.$selectIconContainer.html(this.selectIconDefault);
2587
+ }
2410
2588
 
2411
2589
  if (this.searchApi.length) {
2412
2590
  var searchUrl = this.searchApi;
@@ -2425,23 +2603,11 @@
2425
2603
  url: searchUrl
2426
2604
  }).done(function (data) {
2427
2605
  var items = data.map(function (item) {
2428
- var label = '';
2429
-
2430
- if (item.name) {
2431
- label = item.name;
2432
- } else if (item.label) {
2433
- label = item.label;
2434
- } else if (item.value) {
2435
- label = item.value;
2436
- }
2437
-
2438
- return {
2439
- id: item.id.toString(),
2440
- label: label
2441
- };
2606
+ item.id = item.id.toString();
2607
+ return item;
2442
2608
  });
2443
2609
  items = items.filter(function (item) {
2444
- return self.data[self.name].indexOf(item.id) > -1;
2610
+ return self.data[self.name].indexOf(item.id) > -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
2445
2611
  });
2446
2612
  var result = $(self._renderItemList(items));
2447
2613
  $.when(self.$scrollableContent.append(result)).then(function () {
@@ -2456,12 +2622,12 @@
2456
2622
  }
2457
2623
 
2458
2624
  if (self.$select.find(':input[type="checkbox"]').length) {
2459
- type = 'checkbox';
2625
+ self.type = 'checkbox';
2460
2626
  } else if (self.$select.find(':input[type="radio"]').length) {
2461
- type = 'radio';
2627
+ self.type = 'radio';
2462
2628
  }
2463
2629
 
2464
- if (type == 'checkbox') {
2630
+ if (self.type == 'checkbox') {
2465
2631
  self.data[self.name].forEach(function (value) {
2466
2632
  var $input = self.$select.find(':input').filter(function () {
2467
2633
  return this.value == value;
@@ -2469,24 +2635,29 @@
2469
2635
  $input.prop('checked', true);
2470
2636
  self.onSelect($input[0]);
2471
2637
  });
2472
- } else if (type == 'radio') {
2638
+ } else if (self.type == 'radio') {
2473
2639
  var $input = self.$select.find(':input').filter(function () {
2474
2640
  return this.value == self.data[self.name];
2475
2641
  });
2476
2642
  $input.prop('checked', true);
2477
2643
  $input.addClass('checked');
2644
+
2645
+ if (self.dynamicTitle) {
2646
+ self.$selectTitle.html($input.parent().find('[data-label]').text());
2647
+ }
2648
+
2478
2649
  self.onSelect($input[0]);
2479
2650
  }
2480
2651
  });
2481
2652
  });
2482
2653
  } else {
2483
2654
  if (this.$select.find(':input[type="checkbox"]').length) {
2484
- type = 'checkbox';
2655
+ this.type = 'checkbox';
2485
2656
  } else if (this.$select.find(':input[type="radio"]').length) {
2486
- type = 'radio';
2657
+ this.type = 'radio';
2487
2658
  }
2488
2659
 
2489
- if (type == 'checkbox') {
2660
+ if (this.type == 'checkbox') {
2490
2661
  this.data[this.name].forEach(function (value) {
2491
2662
  var $input = self.$select.find(':input').filter(function () {
2492
2663
  return this.value == value;
@@ -2494,12 +2665,17 @@
2494
2665
  $input.prop('checked', true);
2495
2666
  self.onSelect($input[0]);
2496
2667
  });
2497
- } else if (type == 'radio') {
2668
+ } else if (this.type == 'radio') {
2498
2669
  var $input = this.$select.find(':input').filter(function () {
2499
2670
  return this.value == self.data[self.name];
2500
2671
  });
2501
2672
  $input.prop('checked', true);
2502
2673
  $input.addClass('checked');
2674
+
2675
+ if (this.dynamicTitle) {
2676
+ this.$selectTitle.html($input.parent().find('[data-label]').text());
2677
+ }
2678
+
2503
2679
  this.onSelect($input[0]);
2504
2680
  }
2505
2681
  }
@@ -2518,17 +2694,11 @@
2518
2694
  url: this.searchApi + this.searchString
2519
2695
  }).done(function (data) {
2520
2696
  var items = data.map(function (item) {
2521
- return {
2522
- id: item.id.toString(),
2523
- label: item.name || item.label || item.value || null
2524
- };
2697
+ item.id = item.id.toString();
2698
+ return item;
2525
2699
  });
2526
2700
  items = items.filter(function (item) {
2527
- return !(self.data[self.name].indexOf(item.id) > -1);
2528
- }); // Remove id with value 0 from results
2529
-
2530
- items = items.filter(function (item) {
2531
- return item.id > 0;
2701
+ return self.data[self.name].indexOf(item.id) === -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
2532
2702
  });
2533
2703
  var result = $(self._renderItemList(items));
2534
2704
  $.when(self.$scrollableContent.append(result)).then(function () {
@@ -2582,6 +2752,8 @@
2582
2752
  ;
2583
2753
 
2584
2754
  _proto.show = function show() {
2755
+ var _this6 = this;
2756
+
2585
2757
  if (this.$el.hasClass('show')) {
2586
2758
  return;
2587
2759
  }
@@ -2615,29 +2787,39 @@
2615
2787
  }
2616
2788
 
2617
2789
  this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-angle-up icon\"></i>");
2790
+ setTimeout(function () {
2791
+ _this6.$el[0].scrollIntoView({
2792
+ behavior: 'smooth',
2793
+ block: 'nearest',
2794
+ inline: 'nearest'
2795
+ });
2796
+ }, 300);
2618
2797
  this.contentOpen = true;
2619
2798
  this.onShow();
2620
2799
  } // Close
2621
2800
  ;
2622
2801
 
2623
2802
  _proto.close = function close() {
2624
- var self = this;
2625
- var faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2626
- this.$el.css('max-height', '');
2627
- this.$el.removeClass('show');
2628
- setTimeout(function () {
2629
- self.$el.removeAttr('style');
2630
- }, 300);
2803
+ if (!this.preventClose) {
2804
+ var self = this;
2805
+ var faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2806
+ this.$el.css('max-height', '');
2807
+ this.$el.removeClass('show');
2808
+ setTimeout(function () {
2809
+ self.$el.removeAttr('style');
2810
+ }, 300);
2631
2811
 
2632
- if (this.data[this.name].length > 0) {
2633
- this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-check text-green icon\"></i>");
2634
- } else {
2635
- this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-angle-down icon\"></i>");
2636
- }
2812
+ if (this.data[this.name].length > 0 && this.showValidStateIcon) {
2813
+ this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-check text-green icon\"></i>");
2814
+ } else {
2815
+ this.$selectIconContainer.html(this.selectIconDefault);
2816
+ }
2637
2817
 
2638
- this.contentOpen = false;
2639
- this.onClose();
2640
- };
2818
+ this.contentOpen = false;
2819
+ this.onClose();
2820
+ }
2821
+ } // On select
2822
+ ;
2641
2823
 
2642
2824
  _proto.onSelect = function onSelect(el) {
2643
2825
  var onSelect = this.opts.onSelect;
@@ -2645,13 +2827,210 @@
2645
2827
  if (typeof onSelect === 'function') {
2646
2828
  onSelect.call(el);
2647
2829
  }
2830
+ } // Add more items after plugin is already initialized
2831
+ ;
2832
+
2833
+ _proto.appendItems = function appendItems(items, selectItems) {
2834
+ var _this7 = this;
2835
+
2836
+ return new Promise(function (resolve, reject) {
2837
+ var self = _this7;
2838
+
2839
+ if (!$.isArray(items)) {
2840
+ var itemsArr = [];
2841
+ itemsArr.push(items);
2842
+ items = itemsArr;
2843
+ }
2844
+
2845
+ items = items.filter(function (item) {
2846
+ return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2847
+ });
2848
+ items.forEach(function (item) {
2849
+ _this7.items.push(item);
2850
+ });
2851
+
2852
+ var domItems = _this7._renderItemList(items);
2853
+
2854
+ _this7.$scrollableContent.prepend(domItems);
2855
+
2856
+ _this7.$selectItems = _this7.$select.find('.select-item');
2857
+
2858
+ _this7.buildSearchData().then(function () {
2859
+ if (_this7.$selectItems.length > 0) {
2860
+ if (_this7.$select.find(':input[type="checkbox"]').length) {
2861
+ _this7.type = 'checkbox';
2862
+ } else if (_this7.$select.find(':input[type="radio"]').length) {
2863
+ _this7.type = 'radio';
2864
+ }
2865
+
2866
+ if (_this7.type == 'checkbox') {
2867
+ items.forEach(function (item) {
2868
+ var $input = _this7.$select.find(':input').filter(function () {
2869
+ return this.value == item.id;
2870
+ });
2871
+
2872
+ var val = parseInt($input.val(), 10);
2873
+ $input.prop('checked', true);
2874
+ _this7.data[_this7.name].indexOf(val) === -1 ? _this7.data[_this7.name].push(val) : false;
2875
+
2876
+ _this7.onSelect($input[0]);
2877
+ });
2878
+ } else if (_this7.type == 'radio') {
2879
+ var item = items[0];
2880
+
2881
+ var $input = _this7.$select.find(':input').filter(function () {
2882
+ return this.value == item.id;
2883
+ });
2884
+
2885
+ var val = parseInt($input.val(), 10);
2886
+ $input.prop('checked', true);
2887
+ $input.addClass('checked');
2888
+ _this7.data[_this7.name].indexOf(val) === -1 ? _this7.data[_this7.name] = [val] : false;
2889
+
2890
+ if (_this7.dynamicTitle) {
2891
+ _this7.$selectTitle.html($input.parent().find('[data-label]').text());
2892
+ }
2893
+
2894
+ _this7.$select.find('input[type="radio"]').not($input).prop('checked', false);
2895
+
2896
+ _this7.$select.find('input[type="radio"]').not($input).removeClass('checked');
2897
+
2898
+ _this7.onSelect($input[0]);
2899
+ }
2900
+ }
2901
+
2902
+ if (_this7.data[_this7.name].length == 0 && _this7.dynamicTitle && _this7.dynamicTitleDefault && _this7.dynamicTitleDefault !== 0 && _this7.$selectTitle.text().trim() == 0 && (_this7.$selectItems.length > 0 || _this7.searchApi)) {
2903
+ _this7.$selectTitle.html(_this7.dynamicTitleDefault);
2904
+ }
2905
+
2906
+ if (_this7.$selectHeader.attr('style')) {
2907
+ _this7.$selectHeader.removeAttr('style');
2908
+ }
2909
+
2910
+ if (_this7.$selectIconContainer.hasClass('d-none')) {
2911
+ _this7.$selectIconContainer.removeClass('d-none');
2912
+ }
2913
+
2914
+ resolve();
2915
+ });
2916
+ });
2917
+ } // Deselect items
2918
+ ;
2919
+
2920
+ _proto.deselectItems = function deselectItems(array) {
2921
+ var _this8 = this;
2922
+
2923
+ return new Promise(function (resolve, reject) {
2924
+ array.forEach(function (id) {
2925
+ var $input = _this8.$select.find(':input').filter(function () {
2926
+ return this.value == id;
2927
+ });
2928
+
2929
+ if ($input[0].checked) {
2930
+ $input.trigger('click');
2931
+ }
2932
+ });
2933
+
2934
+ if (_this8.data[_this8.name].length == 0) {
2935
+ _this8.$selectIconContainer.html(_this8.selectIconDefault);
2936
+ }
2937
+ });
2938
+ } // Get item
2939
+ ;
2940
+
2941
+ _proto.getItem = function getItem(key, val) {
2942
+ var result = $.grep(this.items, function (item) {
2943
+ return item[key] == val;
2944
+ })[0];
2945
+ return result ? result : null;
2946
+ } // Get selected items
2947
+ ;
2948
+
2949
+ _proto.getSelectedItems = function getSelectedItems(segment) {
2950
+ var ids = [];
2951
+ var result = [];
2952
+ var data = this.data[this.name];
2953
+
2954
+ if (!$.isArray(data)) {
2955
+ ids.push(data);
2956
+ } else {
2957
+ ids = data;
2958
+ }
2959
+
2960
+ ids = ids.map(Number);
2961
+
2962
+ if (this.items.length > 0) {
2963
+ result = $.grep(this.items, function (item) {
2964
+ return ids.indexOf(parseInt(item.id, 10)) > -1;
2965
+ });
2966
+
2967
+ if (segment) {
2968
+ result = result.map(function (obj) {
2969
+ return obj[segment];
2970
+ }).filter(function (obj) {
2971
+ return obj != null;
2972
+ });
2973
+ }
2974
+ } else {
2975
+ result = ids;
2976
+ }
2977
+
2978
+ return result;
2979
+ } // Get selected item
2980
+ ;
2981
+
2982
+ _proto.getSelectedItem = function getSelectedItem(segment) {
2983
+ var ids = [];
2984
+ var result = [];
2985
+ var data = this.data[this.name];
2986
+
2987
+ if (!$.isArray(data)) {
2988
+ ids.push(data);
2989
+ } else {
2990
+ ids = data;
2991
+ }
2992
+
2993
+ ids = ids.map(Number);
2994
+
2995
+ if (this.items.length > 0) {
2996
+ result = $.grep(this.items, function (item) {
2997
+ return ids.indexOf(parseInt(item.id, 10)) > -1;
2998
+ });
2999
+
3000
+ if (segment) {
3001
+ result = result.map(function (obj) {
3002
+ return obj[segment];
3003
+ }).filter(function (obj) {
3004
+ return obj != null;
3005
+ });
3006
+ }
3007
+ } else {
3008
+ result = ids;
3009
+ }
3010
+
3011
+ return result[0] == null ? null : result[0];
2648
3012
  };
2649
3013
 
2650
3014
  _proto._renderItemList = function _renderItemList(items) {
2651
3015
  var result = '';
2652
3016
 
2653
3017
  for (var i = 0; i < items.length; ++i) {
2654
- result += "\n\n <div class=\"select-item\">\n\n <div class=\"select-item-" + this.type + "\">\n\n <div class=\"styled-" + this.type + "\">\n\n <input type=\"" + this.type + "\" id=\"select-" + this.name + "-" + items[i].id + "\" value=\"" + items[i].id + "\">\n\n <label for=\"select-" + this.name + "-" + items[i].id + "\">\n\n <span class=\"radio-inner\">\n <svg viewBox=\"0 0 18 18\">\n <polyline points=\"1.5 6 4.5 9 10.5 1\"></polyline>\n </svg>\n </span>\n\n <span class=\"" + this.type + "-label\" data-label>\n " + items[i].label + "\n </span>\n\n </label>\n\n </div>\n\n </div>\n\n </div>\n\n ";
3018
+ var item = items[i];
3019
+ var label = '';
3020
+
3021
+ if (typeof this.labelTemplate === 'function') {
3022
+ label = this.labelTemplate(item);
3023
+ } else {
3024
+ if (item.name) {
3025
+ label = item.name;
3026
+ } else if (item.label) {
3027
+ label = item.label;
3028
+ } else if (item.value) {
3029
+ label = item.value;
3030
+ }
3031
+ }
3032
+
3033
+ result += "\n\n <div class=\"select-item\">\n\n <div class=\"select-item-" + this.type + "\">\n\n <div class=\"styled-" + this.type + "\">\n\n <input type=\"" + this.type + "\" id=\"select-" + this.name + "-" + items[i].id + "\" value=\"" + items[i].id + "\" tabindex=\"-1\">\n\n <label for=\"select-" + this.name + "-" + items[i].id + "\">\n\n <span class=\"radio-inner\">\n <svg viewBox=\"0 0 18 18\">\n <polyline points=\"1.5 6 4.5 9 10.5 1\"></polyline>\n </svg>\n </span>\n\n <span class=\"" + this.type + "-label\"" + (typeof this.labelTemplate !== 'function' ? ' data-label' : '') + ">\n " + label + "\n </span>\n\n </label>\n\n </div>\n\n </div>\n\n </div>\n\n ";
2655
3034
  }
2656
3035
 
2657
3036
  return result;
@@ -2660,18 +3039,18 @@
2660
3039
  _proto._renderSearch = function _renderSearch() {
2661
3040
  if (!this.showSearch) {
2662
3041
  return '';
3042
+ } else {
3043
+ var faNameSpace = this.opts.faPro ? 'fal' : 'fas';
3044
+ return "\n\n <div class=\"select-search\">\n\n <div class=\"select-search-input\">\n\n <input type=\"text\" name=\"select-search\" value=\"\" placeholder=\"" + this.searchPlaceholder + "\" tabindex=\"-1\">\n\n </div>\n\n <div class=\"select-search-icon\">\n\n <i class=\"" + faNameSpace + " fa-search icon\"></i>\n\n </div>\n\n </div>\n\n ";
2663
3045
  }
2664
-
2665
- var faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2666
- return "\n\n <div class=\"select-search\">\n\n <div class=\"select-search-input\">\n\n <input type=\"text\" name=\"select-search\" value=\"\" placeholder=\"" + this.opts.searchPlaceholder + "\">\n\n </div>\n\n <div class=\"select-search-icon\">\n\n <i class=\"" + faNameSpace + " fa-search icon\"></i>\n\n </div>\n\n </div>\n\n ";
2667
3046
  };
2668
3047
 
2669
3048
  _proto._renderFooter = function _renderFooter() {
2670
3049
  if (!this.showFooter) {
2671
3050
  return '';
3051
+ } else {
3052
+ return "\n\n <div class=\"select-footer\">\n\n <button class=\"btn btn-block btn-secondary\" type=\"button\" tabindex=\"-1\" data-select-close >\n " + this.btnCloseText + "\n </button>\n\n </div>\n\n ";
2672
3053
  }
2673
-
2674
- return "\n\n <div class=\"select-footer\">\n\n <button class=\"btn btn-primary\" type=\"button\" data-select-close>\n " + this.opts.btnCloseText + "\n </button>\n\n </div>\n\n ";
2675
3054
  };
2676
3055
 
2677
3056
  Select._jQueryInterface = function _jQueryInterface(config) {
@@ -2712,6 +3091,10 @@
2712
3091
  $.fn[NAME$1].defaults = {
2713
3092
  name: '',
2714
3093
  type: 'checkbox',
3094
+ labelTemplate: null,
3095
+ confirmCheck: null,
3096
+ confirmUncheck: null,
3097
+ setData: null,
2715
3098
  scrollContentHeight: 100,
2716
3099
  faPro: false,
2717
3100
  items: [],
@@ -2723,12 +3106,20 @@
2723
3106
  onDestroy: null,
2724
3107
  onShow: null,
2725
3108
  onClose: null,
3109
+ onReset: null,
2726
3110
  onSearch: null,
2727
3111
  onSelect: null,
2728
3112
  buildScroll: null,
2729
3113
  searchPlaceholder: null,
2730
3114
  btnCloseText: null,
2731
- debug: false
3115
+ debug: false,
3116
+ dynamicTitle: false,
3117
+ dynamicTitleDefault: '',
3118
+ dynamicTitleEmptyDefault: '',
3119
+ allowNoneOnRadioSelect: true,
3120
+ preventUncheck: false,
3121
+ showValidStateIcon: true,
3122
+ itemsToExclude: []
2732
3123
  };
2733
3124
  }
2734
3125
 
@@ -2804,6 +3195,7 @@
2804
3195
  this.minWidth = this.$el.data('minWidth') ? this.$el.data('minWidth') : this.opts.minWidth;
2805
3196
  this.scroll = this.$el.data('scroll') ? this.$el.data('scroll') : this.opts.scroll;
2806
3197
  this.scrollContentHeight = this.$el.data('scrollContentHeight') ? this.$el.data('scrollContentHeight') : this.opts.scrollContentHeight;
3198
+ this.positionObserver = this.$el.attr('data-position-observer') ? JSON.parse(this.$el.attr('data-position-observer')) : this.opts.positionObserver;
2807
3199
  this.closeOnItemClick = this.$el.data('closeOnItemClick') ? this.$el.data('closeOnItemClick') : this.opts.closeOnItemClick;
2808
3200
  this.content = this.$el.data('content') ? this.$el.data('content') : this.opts.content;
2809
3201
  this.contentOpen = false;
@@ -2970,8 +3362,10 @@
2970
3362
  var dropdownTriggerHeight = this.$el.outerHeight(true);
2971
3363
  var dropdownTriggerPosX = this.$el.position().left;
2972
3364
  var dropdownTriggerPosY = this.$el.position().top;
2973
- var dropdownPosX;
2974
- var dropdownPosY;
3365
+ var dropdownPosX = 0;
3366
+ var dropdownPosY = 0;
3367
+ var offsetX = 0;
3368
+ var offsetY = 0;
2975
3369
 
2976
3370
  if (placement === 'top') {
2977
3371
  if (this.align === 'end') {
@@ -2999,12 +3393,78 @@
2999
3393
 
3000
3394
  if (this.offset) {
3001
3395
  var offsets = this.offset.split(',');
3002
- var offsetX = offsets[0];
3003
- var offsetY = offsets[1];
3396
+ offsetX = offsets[0];
3397
+ offsetY = offsets[1];
3004
3398
  dropdownPosX += parseInt(offsetX, 10);
3005
3399
  dropdownPosY += parseInt(offsetY, 10);
3006
3400
  }
3007
3401
 
3402
+ if (this.positionObserver) {
3403
+ // this is not set during init so we have to fetch it
3404
+ // and let's assume that this containing parent fits and is inside
3405
+ // viewport
3406
+ var $containingParent = null;
3407
+
3408
+ do {
3409
+ $containingParent = $containingParent ? $containingParent.parent() : this.$container.parent();
3410
+
3411
+ if (!$containingParent) {
3412
+ $containingParent = $('body');
3413
+ break;
3414
+ }
3415
+ } while ($containingParent.css('overflow-x') !== 'hidden' && $containingParent.css('overflow') !== 'hidden' && ($containingParent.prop('tagName') ? $containingParent.prop('tagName').toLowerCase() !== 'body' : false));
3416
+
3417
+ var containingBoundingRect = $containingParent.get(0).getBoundingClientRect();
3418
+ var containerBoundingRect = this.$container.get(0).getBoundingClientRect();
3419
+
3420
+ if (containingBoundingRect.width < dropdownWidth) {
3421
+ this.$dropdown.css('max-width', containingBoundingRect.width);
3422
+ dropdownWidth = containingBoundingRect.width;
3423
+ } else {
3424
+ this.$dropdown.css('max-width', '');
3425
+ }
3426
+
3427
+ if (containingBoundingRect.height < dropdownHeight) {
3428
+ this.$dropdown.css('max-height', containingBoundingRect.height);
3429
+ dropdownHeight = containingBoundingRect.height;
3430
+ } else {
3431
+ this.$dropdown.css('max-height', '');
3432
+ }
3433
+
3434
+ var maxTop = Math.max(Math.abs(containingBoundingRect.y - containerBoundingRect.y), 0);
3435
+ var maxLeft = Math.max(Math.abs(containingBoundingRect.x - containerBoundingRect.x), 0);
3436
+ var maxRight = $containingParent.get(0).scrollWidth - (containerBoundingRect.x + containerBoundingRect.width);
3437
+ var maxBottom = $containingParent.get(0).scrollHeight - (containerBoundingRect.y + (placement === 'dropbottom' ? containerBoundingRect.height : 0));
3438
+
3439
+ if (maxLeft < dropdownWidth && dropdownPosX < dropdownTriggerPosX) {
3440
+ dropdownPosX = dropdownTriggerPosX; // would be on top of the trigger
3441
+
3442
+ if (dropdownTriggerPosY + dropdownTriggerHeight > dropdownPosY) {
3443
+ dropdownPosY = dropdownTriggerPosY + dropdownTriggerHeight + (offsetY > 0 ? offsetY : 0);
3444
+ }
3445
+ }
3446
+
3447
+ if (maxRight < dropdownWidth && dropdownPosX + dropdownWidth > dropdownTriggerPosX + dropdownTriggerWidth) {
3448
+ dropdownPosX = dropdownTriggerPosX + dropdownTriggerWidth - dropdownWidth;
3449
+
3450
+ if (dropdownTriggerPosY + dropdownTriggerHeight > dropdownPosY) {
3451
+ dropdownPosY = dropdownTriggerPosY + dropdownTriggerHeight + (offsetY > 0 ? offsetY : 0);
3452
+ }
3453
+ }
3454
+
3455
+ if (dropdownPosY < dropdownTriggerPosY && maxTop < dropdownHeight) {
3456
+ dropdownPosY = dropdownTriggerPosY + dropdownTriggerHeight + offsetY;
3457
+ }
3458
+
3459
+ if (dropdownPosY >= dropdownTriggerPosY && maxBottom < dropdownHeight) {
3460
+ if (dropdownPosX >= dropdownTriggerPosX + dropdownTriggerWidth || dropdownTriggerPosX >= dropdownPosX + dropdownWidth) {
3461
+ dropdownPosY = dropdownTriggerPosY - (dropdownHeight - maxBottom);
3462
+ } else {
3463
+ dropdownPosY = dropdownTriggerPosY - dropdownHeight - offsetY;
3464
+ }
3465
+ }
3466
+ }
3467
+
3008
3468
  this.$dropdown.css({
3009
3469
  position: 'absolute',
3010
3470
  top: '0px',
@@ -3129,6 +3589,7 @@
3129
3589
  minWidth: null,
3130
3590
  align: 'start',
3131
3591
  closeOnItemClick: true,
3592
+ positionObserver: true,
3132
3593
  content: false,
3133
3594
  scroll: true,
3134
3595
  scrollContentHeight: 100,
@@ -3216,6 +3677,9 @@
3216
3677
  this.$el.on('mouseleave' + '.' + NAME$3, function () {
3217
3678
  _this2.close();
3218
3679
  });
3680
+ this.$el.on('destroyed' + '.' + NAME$3, function () {
3681
+ _this2.close();
3682
+ });
3219
3683
  $(window).on('resize', debounce(function () {
3220
3684
  if (_this2.$tooltip) {
3221
3685
  _this2.setPosition();
@@ -3861,6 +4325,10 @@
3861
4325
  this.$indicator = $(this.$el).parent().find('[data-collapse-indicator]');
3862
4326
  }
3863
4327
 
4328
+ if (this.expanded) {
4329
+ this.$target.css('height', 'auto');
4330
+ }
4331
+
3864
4332
  this.log(this.$el);
3865
4333
  this.log(this.$target);
3866
4334
  this.log(this.$container);
@@ -3917,7 +4385,12 @@
3917
4385
  _proto.show = function show() {
3918
4386
  var _this3 = this;
3919
4387
 
3920
- this.$target.removeClass('collapse visible');
4388
+ // Update target height if something is added to dom which causes height to change
4389
+ if (this.targetHeight !== this.$target.height()) {
4390
+ this.targetHeight = this.$target.height();
4391
+ }
4392
+
4393
+ this.$target.removeClass('collapse show');
3921
4394
  this.$target.addClass('collapsing');
3922
4395
 
3923
4396
  if (this.$el.is('button')) {
@@ -3925,14 +4398,14 @@
3925
4398
  }
3926
4399
 
3927
4400
  if (this.$container.length) {
3928
- this.$container.addClass('visible');
4401
+ this.$container.addClass('show');
3929
4402
  }
3930
4403
 
3931
4404
  this.$target.css('height');
3932
4405
  this.$target.css('height', this.targetHeight);
3933
4406
 
3934
4407
  if (this.$indicator.length) {
3935
- this.$indicator.addClass('visible');
4408
+ this.$indicator.addClass('show');
3936
4409
  }
3937
4410
 
3938
4411
  this.$target.one(this.whichTransitionEvent(), function () {
@@ -3944,7 +4417,7 @@
3944
4417
 
3945
4418
  _this3.$target.removeAttr('style');
3946
4419
 
3947
- _this3.$target.addClass('collapse visible');
4420
+ _this3.$target.addClass('collapse show');
3948
4421
 
3949
4422
  _this3.$el.attr('aria-expanded', true);
3950
4423
 
@@ -3959,7 +4432,7 @@
3959
4432
  _proto.close = function close() {
3960
4433
  var _this4 = this;
3961
4434
 
3962
- this.$target.removeClass('collapse visible');
4435
+ this.$target.removeClass('collapse show');
3963
4436
  this.$target.addClass('collapsing');
3964
4437
 
3965
4438
  if (this.$el.is('button')) {
@@ -3967,7 +4440,7 @@
3967
4440
  }
3968
4441
 
3969
4442
  if (this.$container.length) {
3970
- this.$container.removeClass('visible');
4443
+ this.$container.removeClass('show');
3971
4444
  }
3972
4445
 
3973
4446
  this.$target.css('height', this.$target.height());
@@ -3975,8 +4448,8 @@
3975
4448
  _this4.$target.css('height', 0);
3976
4449
  }, 10);
3977
4450
 
3978
- if (this.$indicator.length && this.$indicator.hasClass('visible')) {
3979
- this.$indicator.removeClass('visible');
4451
+ if (this.$indicator.length && this.$indicator.hasClass('show')) {
4452
+ this.$indicator.removeClass('show');
3980
4453
  }
3981
4454
 
3982
4455
  this.$target.one(this.whichTransitionEvent(), function () {
@@ -3992,7 +4465,11 @@
3992
4465
 
3993
4466
  _this4.$el.attr('aria-expanded', false);
3994
4467
 
3995
- _this4.expanded = false;
4468
+ _this4.expanded = false; // Update target height if something is added to dom which causes height to change
4469
+
4470
+ if (_this4.targetHeight !== _this4.$target.height()) {
4471
+ _this4.targetHeight = _this4.$target.height();
4472
+ }
3996
4473
  });
3997
4474
  this.onClose();
3998
4475
  };
@@ -4575,12 +5052,17 @@
4575
5052
  animationSpeed: settings.animationSpeed,
4576
5053
  callbacks: settings.callbacks,
4577
5054
  maxBodyHeight: settings.maxBodyHeight,
5055
+ overflowVisible: settings.overflowVisible,
4578
5056
  actions: settings.actions,
4579
5057
  onInit: settings.onInit,
4580
5058
  onShow: settings.onShow,
4581
5059
  onClose: settings.onClose
4582
5060
  };
4583
5061
 
5062
+ if (dialog.maxBodyHeight == null) {
5063
+ dialog.maxBodyHeight = window.innerHeight - 200;
5064
+ }
5065
+
4584
5066
  if (typeof dialog.template === 'function') {
4585
5067
  dialog.$el = $(dialog.template());
4586
5068
  } else {
@@ -4680,16 +5162,6 @@
4680
5162
 
4681
5163
  this.$container.append(dialog.$el);
4682
5164
 
4683
- if (dialog.template === '' && touchEvents() == false) {
4684
- dialog.$el.find('.dialog-body').addClass('ps-dark');
4685
- new PerfectScrollbar(dialog.$el.find('.dialog-body')[0], {
4686
- wheelSpeed: 1,
4687
- wheelPropagation: false,
4688
- minScrollbarLength: 20
4689
- });
4690
- dialog.$el.find('.dialog-body').addClass('ps-show-rail-y');
4691
- }
4692
-
4693
5165
  if (dialog.animation) {
4694
5166
  dialog.$el.find('.dialog-content').addClass(dialog.animationSpeed).animateCss(dialog.animationIn);
4695
5167
  }
@@ -4863,6 +5335,7 @@
4863
5335
  var classes = dialog.classes ? ' ' + dialog.classes : '';
4864
5336
  var centered = dialog.centered ? ' dialog-centered' : '';
4865
5337
  var size = dialog.size ? ' dialog-' + dialog.size : '';
5338
+ var overFlowVisible = dialog.overflowVisible ? ' dialog-overflow-visible' : '';
4866
5339
  var uuid = ' data-dialog-uuid="' + dialog.uuid + '"';
4867
5340
  var backdrop = dialog.backdrop ? ' data-dialog-backdrop="true"' : ' data-dialog-backdrop="false"';
4868
5341
  var title = dialog.title;
@@ -4878,7 +5351,7 @@
4878
5351
  body = dialog.body;
4879
5352
  }
4880
5353
 
4881
- return "\n <div class=\"dialog" + classes + centered + size + "\"" + uuid + backdrop + ">\n\n <div class=\"dialog-container\">\n\n <div class=\"dialog-content\">\n\n <div class=\"dialog-header\">\n\n <span class=\"dialog-title\">\n " + title + "\n </span>\n\n " + closeBtn + "\n\n </div>\n\n <div class=\"dialog-body\"" + maxBodyHeight + ">\n\n " + body + "\n\n </div>\n\n " + footer + "\n\n </div>\n\n </div>\n\n </div>\n ";
5354
+ return "\n <div class=\"dialog" + classes + centered + size + overFlowVisible + "\"" + uuid + backdrop + ">\n\n <div class=\"dialog-container\">\n\n <div class=\"dialog-content\">\n\n <div class=\"dialog-header\">\n\n <span class=\"dialog-title\">\n " + title + "\n </span>\n\n " + closeBtn + "\n\n </div>\n\n <div class=\"dialog-body\"" + maxBodyHeight + ">\n\n " + body + "\n\n </div>\n\n " + footer + "\n\n </div>\n\n </div>\n\n </div>\n ";
4882
5355
  };
4883
5356
 
4884
5357
  Dialog._jQueryInterface = function _jQueryInterface(config) {
@@ -4933,7 +5406,8 @@
4933
5406
  animationOut: 'fadeOut',
4934
5407
  animationSpeed: 'fastest',
4935
5408
  callbacks: {},
4936
- maxBodyHeight: window.innerHeight - 200,
5409
+ maxBodyHeight: null,
5410
+ overflowVisible: false,
4937
5411
  faPro: false,
4938
5412
  debug: true,
4939
5413
  onInitialize: null,