@finqu/cool 1.1.9 → 1.2.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.
Files changed (68) hide show
  1. package/dist/css/cool-grid.css +1 -1
  2. package/dist/css/cool-grid.css.map +1 -1
  3. package/dist/css/cool-grid.min.css.map +1 -1
  4. package/dist/css/cool-reboot.css +5 -1
  5. package/dist/css/cool-reboot.css.map +6 -4
  6. package/dist/css/cool-reboot.min.css +1 -1
  7. package/dist/css/cool-reboot.min.css.map +1 -1
  8. package/dist/css/cool.css +190 -55
  9. package/dist/css/cool.css.map +23 -19
  10. package/dist/css/cool.min.css +1 -1
  11. package/dist/css/cool.min.css.map +1 -1
  12. package/dist/js/cool.bundle.js +565 -178
  13. package/dist/js/cool.bundle.js.map +1 -1
  14. package/dist/js/cool.bundle.min.js +2 -2
  15. package/dist/js/cool.bundle.min.js.map +1 -1
  16. package/dist/js/cool.esm.js +565 -178
  17. package/dist/js/cool.esm.js.map +1 -1
  18. package/dist/js/cool.esm.min.js +2 -2
  19. package/dist/js/cool.esm.min.js.map +1 -1
  20. package/dist/js/cool.js +565 -178
  21. package/dist/js/cool.js.map +1 -1
  22. package/dist/js/cool.min.js +2 -2
  23. package/dist/js/cool.min.js.map +1 -1
  24. package/html/index.html +846 -4
  25. package/js/dist/collapse.js +1043 -629
  26. package/js/dist/collapse.js.map +1 -1
  27. package/js/dist/common.js +520 -282
  28. package/js/dist/common.js.map +1 -1
  29. package/js/dist/dropdown.js +273 -58
  30. package/js/dist/dropdown.js.map +1 -1
  31. package/js/dist/popover.js +273 -58
  32. package/js/dist/popover.js.map +1 -1
  33. package/js/dist/sectiontabs.js +273 -58
  34. package/js/dist/sectiontabs.js.map +1 -1
  35. package/js/dist/select.js +9904 -3726
  36. package/js/dist/select.js.map +1 -1
  37. package/js/dist/tooltip.js +1703 -1434
  38. package/js/dist/tooltip.js.map +1 -1
  39. package/js/src/abstract-ui-component.js +16 -5
  40. package/js/src/collapse.js +24 -10
  41. package/js/src/common.js +18 -0
  42. package/js/src/dialog.js +6 -17
  43. package/js/src/dropdown.js +2 -2
  44. package/js/src/popover.js +2 -2
  45. package/js/src/section-tabs.js +2 -2
  46. package/js/src/select.js +578 -177
  47. package/js/src/toast.js +2 -2
  48. package/js/src/tooltip.js +7 -2
  49. package/js/src/util/index.js +10 -0
  50. package/package.json +1 -1
  51. package/scss/_button-group.scss +4 -0
  52. package/scss/_buttons.scss +3 -3
  53. package/scss/_custom-forms.scss +14 -12
  54. package/scss/_dialog.scss +16 -5
  55. package/scss/_frame.scss +1 -0
  56. package/scss/_images.scss +45 -1
  57. package/scss/_input-group.scss +12 -6
  58. package/scss/_mixins.scss +1 -0
  59. package/scss/_notification.scss +13 -0
  60. package/scss/_reboot.scss +4 -0
  61. package/scss/_section.scss +14 -2
  62. package/scss/_select.scss +10 -1
  63. package/scss/_tables.scss +2 -1
  64. package/scss/_variables.scss +2 -2
  65. package/scss/cool.scss +2 -1
  66. package/scss/mixins/_notification-variant.scss +7 -0
  67. package/scss/utilities/_collapse.scss +2 -2
  68. package/scss/utilities/_cursor.scss +12 -0
package/dist/js/cool.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Cool UI v1.1.8 (https://finqu.fi)
2
+ * Cool UI v1.1.9 (https://finqu.fi)
3
3
  * Copyright 2011-2019 Finqu Oy
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  */
@@ -1377,6 +1377,21 @@
1377
1377
  } else {
1378
1378
  return;
1379
1379
  }
1380
+ }); // button toggle
1381
+
1382
+ $(document).on('click', '.btn-group-toggle .btn > input', function (e) {
1383
+ e.stopPropagation();
1384
+ });
1385
+ $(document).on('click', '.btn-group-toggle .btn', function () {
1386
+ $(this).find('input').trigger('click');
1387
+ $(this).parent().find('input').trigger('change');
1388
+ });
1389
+ $(document).on('change', '.btn-group-toggle .btn > input', function () {
1390
+ if ($(this).is(':checked')) {
1391
+ $(this).parent().addClass('active');
1392
+ } else {
1393
+ $(this).parent().removeClass('active');
1394
+ }
1380
1395
  }); // Force select element unfocus after change
1381
1396
 
1382
1397
  $('select').on('change', function () {
@@ -1513,6 +1528,14 @@
1513
1528
  return result;
1514
1529
  };
1515
1530
 
1531
+ $.event.special.destroyed = {
1532
+ remove: function remove(obj) {
1533
+ if (obj.handler) {
1534
+ obj.handler();
1535
+ }
1536
+ }
1537
+ };
1538
+
1516
1539
  var AbstractUIComponent =
1517
1540
  /*#__PURE__*/
1518
1541
  function () {
@@ -1525,7 +1548,7 @@
1525
1548
  var onInit = this.opts.onInit;
1526
1549
 
1527
1550
  if (typeof onInit === 'function') {
1528
- onInit.call(this.el);
1551
+ onInit.call(this);
1529
1552
  }
1530
1553
  } // Update callback
1531
1554
  ;
@@ -1534,7 +1557,7 @@
1534
1557
  var onUpdate = this.opts.onUpdate;
1535
1558
 
1536
1559
  if (typeof onUpdate === 'function') {
1537
- onUpdate.call(this.el);
1560
+ onUpdate.call(this);
1538
1561
  }
1539
1562
  } // Destroy callback
1540
1563
  ;
@@ -1543,7 +1566,7 @@
1543
1566
  var onDestroy = this.opts.onDestroy;
1544
1567
 
1545
1568
  if (typeof onDestroy === 'function') {
1546
- onDestroy.call(this.el);
1569
+ onDestroy.call(this);
1547
1570
  }
1548
1571
  } // Show callback
1549
1572
  ;
@@ -1552,7 +1575,7 @@
1552
1575
  var onShow = this.opts.onShow;
1553
1576
 
1554
1577
  if (typeof onShow === 'function') {
1555
- onShow.call(this.el);
1578
+ onShow.call(this);
1556
1579
  }
1557
1580
  } // Close callback
1558
1581
  ;
@@ -1561,7 +1584,16 @@
1561
1584
  var onClose = this.opts.onClose;
1562
1585
 
1563
1586
  if (typeof onClose === 'function') {
1564
- onClose.call(this.el);
1587
+ onClose.call(this);
1588
+ }
1589
+ } // Reset callback
1590
+ ;
1591
+
1592
+ _proto.onReset = function onReset() {
1593
+ var onReset = this.opts.onReset;
1594
+
1595
+ if (typeof onReset === 'function') {
1596
+ onReset.call(this);
1565
1597
  }
1566
1598
  } // Debug log
1567
1599
  ;
@@ -2120,7 +2152,7 @@
2120
2152
  _proto.init = function init() {
2121
2153
  var _this2 = this;
2122
2154
 
2123
- $.when(this.buildCache()).then(function () {
2155
+ this.buildCache().then(function () {
2124
2156
  _this2.buildScroll();
2125
2157
 
2126
2158
  _this2.bindEvents();
@@ -2145,112 +2177,165 @@
2145
2177
  this.buildCache();
2146
2178
  this.bindEvents();
2147
2179
  this.onUpdate();
2148
- } // Cache DOM nodes for performance
2180
+ } // Reset plugin data
2149
2181
  ;
2150
2182
 
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;
2183
+ _proto.reset = function reset() {
2160
2184
  this.data = {};
2161
2185
  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;
2186
+ this.items = [];
2187
+ this.$select.find('.select-item').remove();
2188
+ this.$selectItems = [];
2189
+ this.$selectIconContainer.html(this.selectIconDefault);
2166
2190
 
2167
- if (this.$el.data('setData') && this.$el.data('setData') != '') {
2168
- this.data = this.$el.data('setData');
2191
+ 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)) {
2192
+ this.$selectTitle.html(this.dynamicTitleDefault);
2169
2193
  }
2170
2194
 
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;
2195
+ if (this.$selectItems.length == 0 && !this.searchApi && this.dynamicTitle && this.dynamicTitleEmptyDefault && this.dynamicTitleEmptyDefault !== 0) {
2196
+ this.$selectHeader.css('cursor', 'default');
2197
+ this.$selectIconContainer.addClass('d-none');
2198
+ this.$selectTitle.html(this.dynamicTitleEmptyDefault);
2175
2199
  }
2176
2200
 
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;
2201
+ if (this.showSearch) {
2202
+ this.searchData = [];
2203
+ this.$searchInput.val('');
2204
+ this.searchString = '';
2205
+ this.search.call(this);
2181
2206
  }
2207
+ } // Cache DOM nodes for performance
2208
+ ;
2182
2209
 
2183
- if (this.items.length) {
2184
- var items = this._renderItemList(this.items);
2185
-
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]');
2210
+ _proto.buildCache = function buildCache() {
2211
+ var _this3 = this;
2191
2212
 
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]');
2213
+ return new Promise(function (primaryResolve, primaryReject) {
2214
+ var self = _this3;
2215
+ _this3.$el = $(_this3.el);
2216
+ _this3.$container = _this3.$el.parent();
2217
+ _this3.$selectHeader = _this3.$el.find('.select-header');
2218
+ _this3.$selectTitle = _this3.$el.find('.select-title');
2219
+ _this3.$selectIconContainer = _this3.$selectHeader.find('.select-icon');
2220
+ _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>';
2221
+ _this3.name = _this3.$el.data('name') ? _this3.$el.data('name') : _this3.opts.name;
2222
+ _this3.scrollContentHeight = _this3.$el.data('scrollContentHeight') ? _this3.$el.data('scrollContentHeight') : _this3.opts.scrollContentHeight;
2223
+ _this3.items = _this3.$el.data('items') ? _this3.$el.data('items') : _this3.opts.items;
2224
+ _this3.data = {};
2225
+ _this3.data[_this3.name] = [];
2226
+ _this3.searchData = [];
2227
+ _this3.searchApi = _this3.$el.data('searchApi') ? _this3.$el.data('searchApi') : _this3.opts.searchApi;
2228
+ _this3.type = _this3.$el.data('type') ? _this3.$el.data('type') : _this3.opts.type;
2229
+ _this3.contentOpen = false;
2230
+ _this3.searchPlaceholder = _this3.$el.data('search-placeholder') ? _this3.$el.data('search-placeholder') : _this3.opts.searchPlaceholder;
2231
+ _this3.btnCloseText = _this3.$el.data('btn-close-text') ? _this3.$el.data('btn-close-text') : _this3.opts.btnCloseText;
2232
+ _this3.labelTemplate = _this3.opts.labelTemplate;
2233
+ _this3.confirmCheck = _this3.opts.confirmCheck;
2234
+ _this3.confirmUncheck = _this3.opts.confirmUncheck;
2235
+ _this3.preventUncheck = _this3.opts.preventUncheck;
2236
+ _this3.dynamicTitle = _this3.$el.data('dynamicTitle') ? _this3.$el.data('dynamicTitle') : _this3.opts.dynamicTitle;
2237
+ _this3.dynamicTitleDefault = _this3.$el.data('dynamicTitleDefault') ? _this3.$el.data('dynamicTitleDefault') : _this3.opts.dynamicTitleDefault;
2238
+ _this3.dynamicTitleEmptyDefault = _this3.$el.data('dynamicTitleEmptyDefault') ? _this3.$el.data('dynamicTitleEmptyDefault') : _this3.opts.dynamicTitleEmptyDefault;
2239
+ _this3.allowNoneOnRadioSelect = _this3.$el.data('allowNoneOnRadioSelect') ? _this3.$el.data('allowNoneOnRadioSelect') : _this3.opts.allowNoneOnRadioSelect;
2240
+ _this3.showValidStateIcon = _this3.$el.data('showValidStateIcon') ? _this3.$el.data('showValidStateIcon') : _this3.opts.showValidStateIcon;
2241
+ _this3.itemsToExclude = _this3.$el.data('itemsToExclude') ? _this3.$el.data('itemsToExclude').replace(/\s/g, '').split(',') : _this3.opts.itemsToExclude;
2242
+ _this3.preventClose = false;
2243
+
2244
+ if (_this3.opts.setData) {
2245
+ _this3.data = _this3.opts.setData;
2197
2246
  }
2198
2247
 
2199
- if (this.showFooter) {
2200
- this.$footerContainer = this.$select.find('.select-footer');
2201
- this.$closeButton = this.$select.find('[data-select-close]');
2248
+ if (_this3.$el.data('setData') && _this3.$el.data('setData') != '') {
2249
+ _this3.data = _this3.$el.data('setData');
2202
2250
  }
2203
2251
 
2204
- $.each(this.$selectLabels, function (i, el) {
2205
- this.searchData.push({
2206
- id: i,
2207
- val: $(el).text().trim()
2208
- });
2252
+ _this3.data[_this3.name] = _this3.data[_this3.name].filter(function (item) {
2253
+ return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2254
+ });
2255
+ _this3.items = _this3.items.filter(function (item) {
2256
+ return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2209
2257
  });
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]');
2224
2258
 
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]');
2259
+ if (_this3.$el.find('.select-search').length) {
2260
+ _this3.showSearch = true;
2261
+ } else {
2262
+ _this3.showSearch = _this3.$el.data('showSearch') ? _this3.$el.data('showSearch') : _this3.opts.showSearch;
2230
2263
  }
2231
2264
 
2232
- if (this.showFooter) {
2233
- this.$footerContainer = this.$select.find('.select-footer');
2234
- this.$closeButton = this.$select.find('[data-select-close]');
2265
+ if (_this3.$el.find('.select-footer').length) {
2266
+ _this3.showFooter = true;
2267
+ } else {
2268
+ _this3.showFooter = _this3.$el.data('showFooter') ? _this3.$el.data('showFooter') : _this3.opts.showFooter;
2235
2269
  }
2236
2270
 
2237
- $.each(this.$selectLabels, function (i, el) {
2238
- _this3.searchData.push({
2239
- id: i,
2240
- val: $(el).text().trim()
2241
- });
2271
+ _this3.$select = _this3.$el.find('.select-content');
2272
+ new Promise(function (secondaryResolve, secondaryReject) {
2273
+ if (!_this3.$select.length) {
2274
+ var items = _this3._renderItemList(_this3.items);
2275
+
2276
+ _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 ");
2277
+
2278
+ _this3.$el.append(_this3.$select);
2279
+
2280
+ secondaryResolve();
2281
+ } else {
2282
+ secondaryResolve();
2283
+ }
2284
+ }).then(function () {
2285
+ _this3.$scrollableContent = _this3.$select.find('.select-scrollable-content') ? _this3.$select.find('.select-scrollable-content') : false;
2286
+ _this3.$selectItems = _this3.$select.find('.select-item');
2287
+
2288
+ 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)) {
2289
+ _this3.$selectTitle.html(_this3.dynamicTitleDefault);
2290
+ }
2291
+
2292
+ if (_this3.$selectItems.length == 0 && !_this3.searchApi && _this3.dynamicTitle && _this3.dynamicTitleEmptyDefault && _this3.dynamicTitleEmptyDefault !== 0) {
2293
+ _this3.$selectHeader.css('cursor', 'default');
2294
+
2295
+ _this3.$selectIconContainer.addClass('d-none');
2296
+
2297
+ _this3.$selectTitle.html(_this3.dynamicTitleEmptyDefault);
2298
+ }
2299
+
2300
+ if (_this3.showSearch) {
2301
+ _this3.$searchContainer = _this3.$select.find('.select-search');
2302
+ _this3.$searchInput = _this3.$select.find('[name="select-search"]');
2303
+ _this3.$searchIconContainer = _this3.$select.find('.select-search-icon');
2304
+ _this3.$clearSearchButton = _this3.$select.find('[data-clear-search]'); // Prevent tabfocus from breaking select functionality
2305
+
2306
+ _this3.$searchInput[0].tabIndex = -1;
2307
+ }
2308
+
2309
+ if (_this3.showFooter) {
2310
+ _this3.$footerContainer = _this3.$select.find('.select-footer');
2311
+ _this3.$closeButton = _this3.$select.find('[data-select-close]'); // Prevent tabfocus from breaking select functionality
2312
+
2313
+ _this3.$closeButton[0].tabIndex = -1;
2314
+ }
2315
+
2316
+ _this3.buildSearchData();
2317
+
2318
+ _this3.log(_this3.$el);
2319
+
2320
+ _this3.log(_this3.$select);
2321
+
2322
+ _this3.log(_this3.$scrollableContent);
2323
+
2324
+ _this3.log('Name: ' + _this3.name);
2325
+
2326
+ _this3.log('Show search: ' + _this3.showSearch);
2327
+
2328
+ _this3.log('Show footer: ' + _this3.showFooter);
2329
+
2330
+ _this3.log('Scroll content height: ' + _this3.scrollContentHeight + 'px');
2331
+
2332
+ _this3.log(_this3.items);
2333
+
2334
+ _this3.log(_this3.searchData);
2335
+
2336
+ primaryResolve();
2242
2337
  });
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
- }
2338
+ });
2254
2339
  } // Build scroll
2255
2340
  ;
2256
2341
 
@@ -2283,7 +2368,9 @@
2283
2368
  scrollYMarginOffset: -1,
2284
2369
  suppressScrollY: true,
2285
2370
  suppressScrollX: true
2286
- });
2371
+ }); // Prevent tabfocus from breaking select functionality
2372
+
2373
+ this.$scrollableContent.find('[tabindex="0"]').attr('tabindex', -1);
2287
2374
 
2288
2375
  if (this.$scrollableContent[0].offsetHeight < this.$scrollableContent[0].scrollHeight) {
2289
2376
  this.$scrollableContent.addClass('ps-show-rail-y');
@@ -2291,32 +2378,94 @@
2291
2378
  }
2292
2379
  }
2293
2380
  }
2381
+ } // Build search data
2382
+ ;
2383
+
2384
+ _proto.buildSearchData = function buildSearchData() {
2385
+ var _this4 = this;
2386
+
2387
+ return new Promise(function (resolve, reject) {
2388
+ _this4.searchData = [];
2389
+
2390
+ var selectLabels = _this4.$select.find('[data-label]');
2391
+
2392
+ $.each(selectLabels, function (i, el) {
2393
+ _this4.searchData.push({
2394
+ id: i,
2395
+ val: $(el).text().trim()
2396
+ });
2397
+ });
2398
+ resolve();
2399
+ });
2294
2400
  } // Bind events that trigger methods
2295
2401
  ;
2296
2402
 
2297
2403
  _proto.bindEvents = function bindEvents() {
2298
- var _this4 = this;
2404
+ var _this5 = this;
2299
2405
 
2300
2406
  var self = this;
2301
2407
  this.$selectHeader.on('click' + '.' + NAME$1, function () {
2302
- if (_this4.contentOpen) {
2303
- _this4.close();
2304
- } else {
2305
- _this4.show();
2408
+ if (_this5.contentOpen) {
2409
+ _this5.close();
2410
+ } else if (_this5.$selectItems.length > 0 || _this5.searchApi) {
2411
+ _this5.show();
2306
2412
  }
2307
2413
  });
2308
2414
  this.$el.on('change' + '.' + NAME$1, 'input[type="checkbox"]', function () {
2415
+ var el = this;
2309
2416
  var val = $(this).val();
2310
-
2311
- if (this.checked) {
2417
+ self.preventClose = true;
2418
+
2419
+ if (typeof self.confirmCheck === 'function' && el.checked) {
2420
+ el.checked = false;
2421
+ self.confirmCheck(function (cb) {
2422
+ if (cb == 'confirmed') {
2423
+ self.data[self.name].indexOf(val) === -1 ? self.data[self.name].push(val) : false;
2424
+ el.checked = true;
2425
+ self.onSelect(el);
2426
+ self.preventClose = false;
2427
+ } else {
2428
+ setTimeout(function () {
2429
+ self.preventClose = false;
2430
+ }, 800);
2431
+ }
2432
+ }, el);
2433
+ } else if (el.checked) {
2312
2434
  self.data[self.name].indexOf(val) === -1 ? self.data[self.name].push(val) : false;
2313
- } else {
2435
+ self.onSelect(el);
2436
+ setTimeout(function () {
2437
+ self.preventClose = false;
2438
+ }, 800);
2439
+ } else if (typeof self.confirmUncheck === 'function' && !el.checked) {
2440
+ el.checked = true;
2441
+ self.confirmUncheck(function (cb) {
2442
+ if (cb == 'confirmed') {
2443
+ self.data[self.name] = self.data[self.name].filter(function (n) {
2444
+ return n != val;
2445
+ });
2446
+ el.checked = false;
2447
+ self.onSelect(el);
2448
+ self.preventClose = false;
2449
+ } else {
2450
+ setTimeout(function () {
2451
+ self.preventClose = false;
2452
+ }, 800);
2453
+ }
2454
+ }, el);
2455
+ } else if (!el.checked && !self.preventUncheck) {
2314
2456
  self.data[self.name] = self.data[self.name].filter(function (n) {
2315
2457
  return n != val;
2316
2458
  });
2459
+ self.onSelect(el);
2460
+ setTimeout(function () {
2461
+ self.preventClose = false;
2462
+ }, 800);
2463
+ } else if (!el.checked && self.preventUncheck) {
2464
+ el.checked = true;
2465
+ setTimeout(function () {
2466
+ self.preventClose = false;
2467
+ }, 800);
2317
2468
  }
2318
-
2319
- self.onSelect(this);
2320
2469
  });
2321
2470
  this.$el.on('change' + '.' + NAME$1, 'input[type="radio"]', function () {
2322
2471
  var val = $(this).val();
@@ -2330,12 +2479,20 @@
2330
2479
  }
2331
2480
  });
2332
2481
  this.$el.on('click' + '.' + NAME$1, 'input[type="radio"]', function () {
2333
- if ($(this).hasClass('checked')) {
2334
- self.data[plugin.name] = [];
2482
+ if ($(this).hasClass('checked') && self.allowNoneOnRadioSelect) {
2483
+ self.data[self.name] = [];
2335
2484
  $(this).prop('checked', false);
2336
2485
  $(this).removeClass('checked');
2486
+
2487
+ if (self.dynamicTitle) {
2488
+ self.$selectTitle.html(self.dynamicTitleDefault);
2489
+ }
2337
2490
  } else {
2338
2491
  $(this).addClass('checked');
2492
+
2493
+ if (self.dynamicTitle) {
2494
+ self.$selectTitle.html($(this).parent().find('[data-label]').text());
2495
+ }
2339
2496
  }
2340
2497
 
2341
2498
  self.onSelect(this);
@@ -2363,7 +2520,7 @@
2363
2520
  this.$searchInput.on('focusout' + '.' + NAME$1, function () {
2364
2521
  self.$searchContainer.removeClass('focused');
2365
2522
  });
2366
- this.$clearSearchButton.on('click' + '.' + NAME$1, function () {
2523
+ this.$searchContainer.on('click' + '.' + NAME$1, '[data-clear-search]', function () {
2367
2524
  if (self.searchString.length) {
2368
2525
  self.$searchInput.val('');
2369
2526
  self.searchString = '';
@@ -2376,12 +2533,12 @@
2376
2533
 
2377
2534
  if (this.showFooter) {
2378
2535
  this.$closeButton.on('click' + '.' + NAME$1, function () {
2379
- _this4.close();
2536
+ _this5.close();
2380
2537
  });
2381
2538
  }
2382
2539
 
2383
2540
  $(document).on('touchstart click', function (e) {
2384
- if (!self.$el.is(e.target) && self.$el.has(e.target).length === 0 && self.contentOpen) {
2541
+ if (!self.$el.is(e.target) && !self.$el.has(e.target).length && self.contentOpen && !self.preventClose) {
2385
2542
  self.close.call(self);
2386
2543
  }
2387
2544
  });
@@ -2404,9 +2561,13 @@
2404
2561
 
2405
2562
  _proto.setData = function setData() {
2406
2563
  var self = this;
2407
- var type = null;
2408
2564
  var faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2409
- this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-check text-green icon\"></i>");
2565
+
2566
+ if (this.showValidStateIcon) {
2567
+ this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-check text-green icon\"></i>");
2568
+ } else {
2569
+ this.$selectIconContainer.html(this.selectIconDefault);
2570
+ }
2410
2571
 
2411
2572
  if (this.searchApi.length) {
2412
2573
  var searchUrl = this.searchApi;
@@ -2425,23 +2586,11 @@
2425
2586
  url: searchUrl
2426
2587
  }).done(function (data) {
2427
2588
  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
- };
2589
+ item.id = item.id.toString();
2590
+ return item;
2442
2591
  });
2443
2592
  items = items.filter(function (item) {
2444
- return self.data[self.name].indexOf(item.id) > -1;
2593
+ return !(self.data[self.name].indexOf(item.id) > -1) && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2445
2594
  });
2446
2595
  var result = $(self._renderItemList(items));
2447
2596
  $.when(self.$scrollableContent.append(result)).then(function () {
@@ -2456,12 +2605,12 @@
2456
2605
  }
2457
2606
 
2458
2607
  if (self.$select.find(':input[type="checkbox"]').length) {
2459
- type = 'checkbox';
2608
+ self.type = 'checkbox';
2460
2609
  } else if (self.$select.find(':input[type="radio"]').length) {
2461
- type = 'radio';
2610
+ self.type = 'radio';
2462
2611
  }
2463
2612
 
2464
- if (type == 'checkbox') {
2613
+ if (self.type == 'checkbox') {
2465
2614
  self.data[self.name].forEach(function (value) {
2466
2615
  var $input = self.$select.find(':input').filter(function () {
2467
2616
  return this.value == value;
@@ -2469,24 +2618,29 @@
2469
2618
  $input.prop('checked', true);
2470
2619
  self.onSelect($input[0]);
2471
2620
  });
2472
- } else if (type == 'radio') {
2621
+ } else if (self.type == 'radio') {
2473
2622
  var $input = self.$select.find(':input').filter(function () {
2474
2623
  return this.value == self.data[self.name];
2475
2624
  });
2476
2625
  $input.prop('checked', true);
2477
2626
  $input.addClass('checked');
2627
+
2628
+ if (self.dynamicTitle) {
2629
+ self.$selectTitle.html($input.parent().find('[data-label]').text());
2630
+ }
2631
+
2478
2632
  self.onSelect($input[0]);
2479
2633
  }
2480
2634
  });
2481
2635
  });
2482
2636
  } else {
2483
2637
  if (this.$select.find(':input[type="checkbox"]').length) {
2484
- type = 'checkbox';
2638
+ this.type = 'checkbox';
2485
2639
  } else if (this.$select.find(':input[type="radio"]').length) {
2486
- type = 'radio';
2640
+ this.type = 'radio';
2487
2641
  }
2488
2642
 
2489
- if (type == 'checkbox') {
2643
+ if (this.type == 'checkbox') {
2490
2644
  this.data[this.name].forEach(function (value) {
2491
2645
  var $input = self.$select.find(':input').filter(function () {
2492
2646
  return this.value == value;
@@ -2494,12 +2648,17 @@
2494
2648
  $input.prop('checked', true);
2495
2649
  self.onSelect($input[0]);
2496
2650
  });
2497
- } else if (type == 'radio') {
2651
+ } else if (this.type == 'radio') {
2498
2652
  var $input = this.$select.find(':input').filter(function () {
2499
2653
  return this.value == self.data[self.name];
2500
2654
  });
2501
2655
  $input.prop('checked', true);
2502
2656
  $input.addClass('checked');
2657
+
2658
+ if (this.dynamicTitle) {
2659
+ this.$selectTitle.html($input.parent().find('[data-label]').text());
2660
+ }
2661
+
2503
2662
  this.onSelect($input[0]);
2504
2663
  }
2505
2664
  }
@@ -2518,13 +2677,11 @@
2518
2677
  url: this.searchApi + this.searchString
2519
2678
  }).done(function (data) {
2520
2679
  var items = data.map(function (item) {
2521
- return {
2522
- id: item.id.toString(),
2523
- label: item.name || item.label || item.value || null
2524
- };
2680
+ item.id = item.id.toString();
2681
+ return item;
2525
2682
  });
2526
2683
  items = items.filter(function (item) {
2527
- return !(self.data[self.name].indexOf(item.id) > -1);
2684
+ return !(self.data[self.name].indexOf(item.id) > -1) && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2528
2685
  }); // Remove id with value 0 from results
2529
2686
 
2530
2687
  items = items.filter(function (item) {
@@ -2582,6 +2739,8 @@
2582
2739
  ;
2583
2740
 
2584
2741
  _proto.show = function show() {
2742
+ var _this6 = this;
2743
+
2585
2744
  if (this.$el.hasClass('show')) {
2586
2745
  return;
2587
2746
  }
@@ -2615,29 +2774,39 @@
2615
2774
  }
2616
2775
 
2617
2776
  this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-angle-up icon\"></i>");
2777
+ setTimeout(function () {
2778
+ _this6.$el[0].scrollIntoView({
2779
+ behavior: 'smooth',
2780
+ block: 'nearest',
2781
+ inline: 'nearest'
2782
+ });
2783
+ }, 300);
2618
2784
  this.contentOpen = true;
2619
2785
  this.onShow();
2620
2786
  } // Close
2621
2787
  ;
2622
2788
 
2623
2789
  _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);
2790
+ if (!this.preventClose) {
2791
+ var self = this;
2792
+ var faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2793
+ this.$el.css('max-height', '');
2794
+ this.$el.removeClass('show');
2795
+ setTimeout(function () {
2796
+ self.$el.removeAttr('style');
2797
+ }, 300);
2631
2798
 
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
- }
2799
+ if (this.data[this.name].length > 0 && this.showValidStateIcon) {
2800
+ this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-check text-green icon\"></i>");
2801
+ } else {
2802
+ this.$selectIconContainer.html(this.selectIconDefault);
2803
+ }
2637
2804
 
2638
- this.contentOpen = false;
2639
- this.onClose();
2640
- };
2805
+ this.contentOpen = false;
2806
+ this.onClose();
2807
+ }
2808
+ } // On select
2809
+ ;
2641
2810
 
2642
2811
  _proto.onSelect = function onSelect(el) {
2643
2812
  var onSelect = this.opts.onSelect;
@@ -2645,13 +2814,210 @@
2645
2814
  if (typeof onSelect === 'function') {
2646
2815
  onSelect.call(el);
2647
2816
  }
2817
+ } // Add more items after plugin is already initialized
2818
+ ;
2819
+
2820
+ _proto.appendItems = function appendItems(items, selectItems) {
2821
+ var _this7 = this;
2822
+
2823
+ return new Promise(function (resolve, reject) {
2824
+ var self = _this7;
2825
+
2826
+ if (!$.isArray(items)) {
2827
+ var itemsArr = [];
2828
+ itemsArr.push(items);
2829
+ items = itemsArr;
2830
+ }
2831
+
2832
+ items = items.filter(function (item) {
2833
+ return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2834
+ });
2835
+ items.forEach(function (item) {
2836
+ _this7.items.push(item);
2837
+ });
2838
+
2839
+ var domItems = _this7._renderItemList(items);
2840
+
2841
+ _this7.$scrollableContent.prepend(domItems);
2842
+
2843
+ _this7.$selectItems = _this7.$select.find('.select-item');
2844
+
2845
+ _this7.buildSearchData().then(function () {
2846
+ if (_this7.$selectItems.length > 0) {
2847
+ if (_this7.$select.find(':input[type="checkbox"]').length) {
2848
+ _this7.type = 'checkbox';
2849
+ } else if (_this7.$select.find(':input[type="radio"]').length) {
2850
+ _this7.type = 'radio';
2851
+ }
2852
+
2853
+ if (_this7.type == 'checkbox') {
2854
+ items.forEach(function (item) {
2855
+ var $input = _this7.$select.find(':input').filter(function () {
2856
+ return this.value == item.id;
2857
+ });
2858
+
2859
+ var val = parseInt($input.val(), 10);
2860
+ $input.prop('checked', true);
2861
+ _this7.data[_this7.name].indexOf(val) === -1 ? _this7.data[_this7.name].push(val) : false;
2862
+
2863
+ _this7.onSelect($input[0]);
2864
+ });
2865
+ } else if (_this7.type == 'radio') {
2866
+ var item = items[0];
2867
+
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
+ $input.addClass('checked');
2875
+ _this7.data[_this7.name].indexOf(val) === -1 ? _this7.data[_this7.name].push(val) : false;
2876
+
2877
+ if (_this7.dynamicTitle) {
2878
+ _this7.$selectTitle.html($input.parent().find('[data-label]').text());
2879
+ }
2880
+
2881
+ _this7.$select.find('input[type="radio"]').not($input).prop('checked', false);
2882
+
2883
+ _this7.$select.find('input[type="radio"]').not($input).removeClass('checked');
2884
+
2885
+ _this7.onSelect($input[0]);
2886
+ }
2887
+ }
2888
+
2889
+ 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)) {
2890
+ _this7.$selectTitle.html(_this7.dynamicTitleDefault);
2891
+ }
2892
+
2893
+ if (_this7.$selectHeader.attr('style')) {
2894
+ _this7.$selectHeader.removeAttr('style');
2895
+ }
2896
+
2897
+ if (_this7.$selectIconContainer.hasClass('d-none')) {
2898
+ _this7.$selectIconContainer.removeClass('d-none');
2899
+ }
2900
+
2901
+ resolve();
2902
+ });
2903
+ });
2904
+ } // Deselect items
2905
+ ;
2906
+
2907
+ _proto.deselectItems = function deselectItems(array) {
2908
+ var _this8 = this;
2909
+
2910
+ return new Promise(function (resolve, reject) {
2911
+ array.forEach(function (id) {
2912
+ var $input = _this8.$select.find(':input').filter(function () {
2913
+ return this.value == id;
2914
+ });
2915
+
2916
+ if ($input[0].checked) {
2917
+ $input.trigger('click');
2918
+ }
2919
+ });
2920
+
2921
+ if (_this8.data[_this8.name].length == 0) {
2922
+ _this8.$selectIconContainer.html(_this8.selectIconDefault);
2923
+ }
2924
+ });
2925
+ } // Get item
2926
+ ;
2927
+
2928
+ _proto.getItem = function getItem(key, val) {
2929
+ var result = $.grep(this.items, function (item) {
2930
+ return item[key] == val;
2931
+ })[0];
2932
+ return result ? result : null;
2933
+ } // Get selected items
2934
+ ;
2935
+
2936
+ _proto.getSelectedItems = function getSelectedItems(segment) {
2937
+ var ids = [];
2938
+ var result = [];
2939
+ var data = this.data[this.name];
2940
+
2941
+ if (!$.isArray(data)) {
2942
+ ids.push(data);
2943
+ } else {
2944
+ ids = data;
2945
+ }
2946
+
2947
+ ids = ids.map(Number);
2948
+
2949
+ if (this.items.length > 0) {
2950
+ result = $.grep(this.items, function (item) {
2951
+ return ids.indexOf(parseInt(item.id, 10)) > -1;
2952
+ });
2953
+
2954
+ if (segment) {
2955
+ result = result.map(function (obj) {
2956
+ return obj[segment];
2957
+ }).filter(function (obj) {
2958
+ return obj != null;
2959
+ });
2960
+ }
2961
+ } else {
2962
+ result = ids;
2963
+ }
2964
+
2965
+ return result;
2966
+ } // Get selected item
2967
+ ;
2968
+
2969
+ _proto.getSelectedItem = function getSelectedItem(segment) {
2970
+ var ids = [];
2971
+ var result = [];
2972
+ var data = this.data[this.name];
2973
+
2974
+ if (!$.isArray(data)) {
2975
+ ids.push(data);
2976
+ } else {
2977
+ ids = data;
2978
+ }
2979
+
2980
+ ids = ids.map(Number);
2981
+
2982
+ if (this.items.length > 0) {
2983
+ result = $.grep(this.items, function (item) {
2984
+ return ids.indexOf(parseInt(item.id, 10)) > -1;
2985
+ });
2986
+
2987
+ if (segment) {
2988
+ result = result.map(function (obj) {
2989
+ return obj[segment];
2990
+ }).filter(function (obj) {
2991
+ return obj != null;
2992
+ });
2993
+ }
2994
+ } else {
2995
+ result = ids;
2996
+ }
2997
+
2998
+ return result[0] == null ? null : result[0];
2648
2999
  };
2649
3000
 
2650
3001
  _proto._renderItemList = function _renderItemList(items) {
2651
3002
  var result = '';
2652
3003
 
2653
3004
  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 ";
3005
+ var item = items[i];
3006
+ var label = '';
3007
+
3008
+ if (typeof this.labelTemplate === 'function') {
3009
+ label = this.labelTemplate(item);
3010
+ } else {
3011
+ if (item.name) {
3012
+ label = item.name;
3013
+ } else if (item.label) {
3014
+ label = item.label;
3015
+ } else if (item.value) {
3016
+ label = item.value;
3017
+ }
3018
+ }
3019
+
3020
+ 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
3021
  }
2656
3022
 
2657
3023
  return result;
@@ -2660,18 +3026,18 @@
2660
3026
  _proto._renderSearch = function _renderSearch() {
2661
3027
  if (!this.showSearch) {
2662
3028
  return '';
3029
+ } else {
3030
+ var faNameSpace = this.opts.faPro ? 'fal' : 'fas';
3031
+ 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
3032
  }
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
3033
  };
2668
3034
 
2669
3035
  _proto._renderFooter = function _renderFooter() {
2670
3036
  if (!this.showFooter) {
2671
3037
  return '';
3038
+ } else {
3039
+ 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
3040
  }
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
3041
  };
2676
3042
 
2677
3043
  Select._jQueryInterface = function _jQueryInterface(config) {
@@ -2712,6 +3078,10 @@
2712
3078
  $.fn[NAME$1].defaults = {
2713
3079
  name: '',
2714
3080
  type: 'checkbox',
3081
+ labelTemplate: null,
3082
+ confirmCheck: null,
3083
+ confirmUncheck: null,
3084
+ setData: null,
2715
3085
  scrollContentHeight: 100,
2716
3086
  faPro: false,
2717
3087
  items: [],
@@ -2723,12 +3093,20 @@
2723
3093
  onDestroy: null,
2724
3094
  onShow: null,
2725
3095
  onClose: null,
3096
+ onReset: null,
2726
3097
  onSearch: null,
2727
3098
  onSelect: null,
2728
3099
  buildScroll: null,
2729
3100
  searchPlaceholder: null,
2730
3101
  btnCloseText: null,
2731
- debug: false
3102
+ debug: false,
3103
+ dynamicTitle: false,
3104
+ dynamicTitleDefault: '',
3105
+ dynamicTitleEmptyDefault: '',
3106
+ allowNoneOnRadioSelect: true,
3107
+ preventUncheck: false,
3108
+ showValidStateIcon: true,
3109
+ itemsToExclude: []
2732
3110
  };
2733
3111
  }
2734
3112
 
@@ -3216,6 +3594,9 @@
3216
3594
  this.$el.on('mouseleave' + '.' + NAME$3, function () {
3217
3595
  _this2.close();
3218
3596
  });
3597
+ this.$el.on('destroyed' + '.' + NAME$3, function () {
3598
+ _this2.close();
3599
+ });
3219
3600
  $(window).on('resize', debounce(function () {
3220
3601
  if (_this2.$tooltip) {
3221
3602
  _this2.setPosition();
@@ -3861,6 +4242,10 @@
3861
4242
  this.$indicator = $(this.$el).parent().find('[data-collapse-indicator]');
3862
4243
  }
3863
4244
 
4245
+ if (this.expanded) {
4246
+ this.$target.css('height', 'auto');
4247
+ }
4248
+
3864
4249
  this.log(this.$el);
3865
4250
  this.log(this.$target);
3866
4251
  this.log(this.$container);
@@ -3917,7 +4302,12 @@
3917
4302
  _proto.show = function show() {
3918
4303
  var _this3 = this;
3919
4304
 
3920
- this.$target.removeClass('collapse visible');
4305
+ // Update target height if something is added to dom which causes height to change
4306
+ if (this.targetHeight !== this.$target.height()) {
4307
+ this.targetHeight = this.$target.height();
4308
+ }
4309
+
4310
+ this.$target.removeClass('collapse show');
3921
4311
  this.$target.addClass('collapsing');
3922
4312
 
3923
4313
  if (this.$el.is('button')) {
@@ -3925,14 +4315,14 @@
3925
4315
  }
3926
4316
 
3927
4317
  if (this.$container.length) {
3928
- this.$container.addClass('visible');
4318
+ this.$container.addClass('show');
3929
4319
  }
3930
4320
 
3931
4321
  this.$target.css('height');
3932
4322
  this.$target.css('height', this.targetHeight);
3933
4323
 
3934
4324
  if (this.$indicator.length) {
3935
- this.$indicator.addClass('visible');
4325
+ this.$indicator.addClass('show');
3936
4326
  }
3937
4327
 
3938
4328
  this.$target.one(this.whichTransitionEvent(), function () {
@@ -3944,7 +4334,7 @@
3944
4334
 
3945
4335
  _this3.$target.removeAttr('style');
3946
4336
 
3947
- _this3.$target.addClass('collapse visible');
4337
+ _this3.$target.addClass('collapse show');
3948
4338
 
3949
4339
  _this3.$el.attr('aria-expanded', true);
3950
4340
 
@@ -3959,7 +4349,7 @@
3959
4349
  _proto.close = function close() {
3960
4350
  var _this4 = this;
3961
4351
 
3962
- this.$target.removeClass('collapse visible');
4352
+ this.$target.removeClass('collapse show');
3963
4353
  this.$target.addClass('collapsing');
3964
4354
 
3965
4355
  if (this.$el.is('button')) {
@@ -3967,7 +4357,7 @@
3967
4357
  }
3968
4358
 
3969
4359
  if (this.$container.length) {
3970
- this.$container.removeClass('visible');
4360
+ this.$container.removeClass('show');
3971
4361
  }
3972
4362
 
3973
4363
  this.$target.css('height', this.$target.height());
@@ -3975,8 +4365,8 @@
3975
4365
  _this4.$target.css('height', 0);
3976
4366
  }, 10);
3977
4367
 
3978
- if (this.$indicator.length && this.$indicator.hasClass('visible')) {
3979
- this.$indicator.removeClass('visible');
4368
+ if (this.$indicator.length && this.$indicator.hasClass('show')) {
4369
+ this.$indicator.removeClass('show');
3980
4370
  }
3981
4371
 
3982
4372
  this.$target.one(this.whichTransitionEvent(), function () {
@@ -3992,7 +4382,11 @@
3992
4382
 
3993
4383
  _this4.$el.attr('aria-expanded', false);
3994
4384
 
3995
- _this4.expanded = false;
4385
+ _this4.expanded = false; // Update target height if something is added to dom which causes height to change
4386
+
4387
+ if (_this4.targetHeight !== _this4.$target.height()) {
4388
+ _this4.targetHeight = _this4.$target.height();
4389
+ }
3996
4390
  });
3997
4391
  this.onClose();
3998
4392
  };
@@ -4575,6 +4969,7 @@
4575
4969
  animationSpeed: settings.animationSpeed,
4576
4970
  callbacks: settings.callbacks,
4577
4971
  maxBodyHeight: settings.maxBodyHeight,
4972
+ overflowVisible: settings.overflowVisible,
4578
4973
  actions: settings.actions,
4579
4974
  onInit: settings.onInit,
4580
4975
  onShow: settings.onShow,
@@ -4680,16 +5075,6 @@
4680
5075
 
4681
5076
  this.$container.append(dialog.$el);
4682
5077
 
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
5078
  if (dialog.animation) {
4694
5079
  dialog.$el.find('.dialog-content').addClass(dialog.animationSpeed).animateCss(dialog.animationIn);
4695
5080
  }
@@ -4863,6 +5248,7 @@
4863
5248
  var classes = dialog.classes ? ' ' + dialog.classes : '';
4864
5249
  var centered = dialog.centered ? ' dialog-centered' : '';
4865
5250
  var size = dialog.size ? ' dialog-' + dialog.size : '';
5251
+ var overFlowVisible = dialog.overflowVisible ? ' dialog-overflow-visible' : '';
4866
5252
  var uuid = ' data-dialog-uuid="' + dialog.uuid + '"';
4867
5253
  var backdrop = dialog.backdrop ? ' data-dialog-backdrop="true"' : ' data-dialog-backdrop="false"';
4868
5254
  var title = dialog.title;
@@ -4878,7 +5264,7 @@
4878
5264
  body = dialog.body;
4879
5265
  }
4880
5266
 
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 ";
5267
+ 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
5268
  };
4883
5269
 
4884
5270
  Dialog._jQueryInterface = function _jQueryInterface(config) {
@@ -4934,6 +5320,7 @@
4934
5320
  animationSpeed: 'fastest',
4935
5321
  callbacks: {},
4936
5322
  maxBodyHeight: window.innerHeight - 200,
5323
+ overflowVisible: false,
4937
5324
  faPro: false,
4938
5325
  debug: true,
4939
5326
  onInitialize: null,