@finqu/cool 1.2.5 → 1.2.7

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 (44) hide show
  1. package/dist/css/cool-grid.css +2 -2
  2. package/dist/css/cool-grid.css.map +1 -1
  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 +2 -2
  6. package/dist/css/cool-reboot.css.map +1 -1
  7. package/dist/css/cool-reboot.min.css +1 -1
  8. package/dist/css/cool-reboot.min.css.map +1 -1
  9. package/dist/css/cool.css +3 -2
  10. package/dist/css/cool.css.map +3 -3
  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 +83 -23
  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 +83 -23
  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 +83 -23
  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/index.html +86 -0
  26. package/js/dist/collapse.js +2 -2
  27. package/js/dist/common.js +2 -2
  28. package/js/dist/dropdown.js +792 -691
  29. package/js/dist/dropdown.js.map +1 -1
  30. package/js/dist/popover.js +1840 -1727
  31. package/js/dist/popover.js.map +1 -1
  32. package/js/dist/sectiontabs.js +2 -2
  33. package/js/dist/select.js +4456 -3710
  34. package/js/dist/select.js.map +1 -1
  35. package/js/dist/tooltip.js +2 -2
  36. package/js/src/dropdown.js +10 -3
  37. package/js/src/popover.js +6 -0
  38. package/js/src/select.js +72 -20
  39. package/package.json +1 -1
  40. package/scss/LISENCE +1 -1
  41. package/scss/_frame.scss +1 -0
  42. package/scss/cool-grid.scss +2 -2
  43. package/scss/cool-reboot.scss +2 -2
  44. package/scss/cool.scss +2 -2
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * Cool UI tooltip.js v1.2.4 (https://finqu.fi)
3
- * Copyright 2011-2019 Finqu Oy
2
+ * Cool UI tooltip.js v1.2.6 (https://finqu.fi)
3
+ * Copyright 2011-2020 Finqu Oy
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  */
6
6
  (function (global, factory) {
@@ -300,17 +300,24 @@ class Dropdown extends AbstractUIComponent {
300
300
  // and let's assume that this containing parent fits and is inside
301
301
  // viewport
302
302
  let $containingParent = this.$container.parent();
303
-
303
+ let index = 0;
304
304
  while (
305
305
  $containingParent.css('overflow-x') !== 'hidden' && 
306
306
  $containingParent.css('overflow') !== 'hidden' &&
307
- ($containingParent.prop('tagName') || '').toLowerCase() !== 'body'
307
+ ($containingParent.prop('tagName') || '').toLowerCase() !== 'body' &&
308
+ index < 100
308
309
  ) {
309
310
  $containingParent = $containingParent.parent();
310
311
 
311
- if (!$containingParent) {
312
+ if (!$containingParent.get(0)) {
312
313
  return;
313
314
  }
315
+
316
+ ++index;
317
+ }
318
+
319
+ if (!$containingParent.get(0)) {
320
+ return;
314
321
  }
315
322
 
316
323
  const containingBoundingRect = $containingParent.get(0).getBoundingClientRect();
package/js/src/popover.js CHANGED
@@ -55,6 +55,7 @@ class Popover extends AbstractUIComponent {
55
55
 
56
56
  this.$el = $(this.el);
57
57
  this.$container = this.$el.data('container') ? $(this.$el.data('container')) : $(this.opts.container);
58
+ this.containerAutoDetect = this.$el.data('containerAutoDetect') ? this.$el.data('containerAutoDetect') : this.opts.containerAutoDetect;
58
59
  this.id = 'popover-'+this.generateUUID();
59
60
  this.animation = this.$el.data('animation') ? this.$el.data('animation') : this.opts.animation;
60
61
  this.animationIn = this.$el.data('animationIn') ? this.$el.data('animationIn') : this.opts.animationIn;
@@ -65,6 +66,10 @@ class Popover extends AbstractUIComponent {
65
66
  this.placementChanged = false;
66
67
  this.title = this.$el.data('title') ? this.$el.data('title') : this.opts.title;
67
68
  this.content = this.$el.data('content') ? this.$el.data('content') : this.opts.content;
69
+
70
+ if (this.containerAutoDetect) {
71
+ this.$container = this.$el.offsetParent();
72
+ }
68
73
  }
69
74
 
70
75
  // Bind events that trigger methods
@@ -595,6 +600,7 @@ if (typeof $ !== 'undefined') {
595
600
 
596
601
  $.fn[NAME].defaults = {
597
602
  container: '.content-inner',
603
+ containerAutoDetect: false,
598
604
  trigger: 'focus',
599
605
  placement: 'bottom',
600
606
  animation: true,
package/js/src/select.js CHANGED
@@ -130,6 +130,7 @@ class Select extends AbstractUIComponent {
130
130
  this.allowNoneOnRadioSelect = this.$el.data('allowNoneOnRadioSelect') ? this.$el.data('allowNoneOnRadioSelect') : this.opts.allowNoneOnRadioSelect;
131
131
  this.showValidStateIcon = this.$el.data('showValidStateIcon') ? this.$el.data('showValidStateIcon') : this.opts.showValidStateIcon;
132
132
  this.itemsToExclude = this.$el.data('itemsToExclude') ? this.$el.data('itemsToExclude').replace(/\s/g, '').split(',') : this.opts.itemsToExclude;
133
+ this.primaryKeyword = this.$el.data('primaryKeyword') ? this.$el.data('primaryKeyword') : this.opts.primaryKeyword;
133
134
  this.preventClose = false;
134
135
 
135
136
  if (this.itemsToExclude.length > 0) {
@@ -144,13 +145,15 @@ class Select extends AbstractUIComponent {
144
145
  this.data = this.$el.data('setData');
145
146
  }
146
147
 
147
- if (typeof this.data[this.name].filter !== 'undefined' && self.itemsToExclude) {
148
+ if (this.data[this.name] !== 'undefined' && this.data[this.name].length > 0 && self.itemsToExclude) {
149
+
148
150
  this.data[this.name] = this.data[this.name].filter(function(item) {
149
151
  return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
150
152
  });
151
153
  }
152
154
 
153
- if (typeof this.items.filter !== 'undefined' && self.itemsToExclude) {
155
+ if (this.items !== 'undefined' && this.items.lengths > 0 && self.itemsToExclude) {
156
+
154
157
  this.items = this.items.filter(function(item) {
155
158
  return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
156
159
  });
@@ -181,7 +184,7 @@ class Select extends AbstractUIComponent {
181
184
 
182
185
  ${this._renderSearch()}
183
186
 
184
- <div class="select-scrollable-content">${items}</div>
187
+ <div class="select-scrollable-content"></div>
185
188
 
186
189
  ${this._renderFooter()}
187
190
 
@@ -189,6 +192,7 @@ class Select extends AbstractUIComponent {
189
192
  `);
190
193
 
191
194
  this.$el.append(this.$select);
195
+ this.$select.find('.select-scrollable-content').append(items);
192
196
 
193
197
  secondaryResolve();
194
198
 
@@ -568,19 +572,34 @@ class Select extends AbstractUIComponent {
568
572
 
569
573
  let items = data.map(item => {
570
574
 
571
- item.id = item.id.toString();
575
+ item.id = item[self.primaryKeyword].toString();
572
576
 
573
577
  return item;
574
578
  });
575
579
 
580
+ let itemIds = items.map(item => {
581
+ return parseInt(item.id, 10);
582
+ });
583
+
584
+ // Remove value from data if it doesn't exist anymore
585
+ self.data[self.name] = self.data[self.name].filter(function(value) {
586
+ return itemIds.indexOf(parseInt(value, 10)) > -1;
587
+ });
588
+
589
+ if (self.data[self.name].length == 0) {
590
+ self.$selectIconContainer.html(self.selectIconDefault);
591
+ }
592
+
576
593
  items = items.filter(function(item) {
577
594
  return self.data[self.name].indexOf(item.id) > -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
578
595
  });
579
596
 
580
- let result = $(self._renderItemList(items));
597
+ let result = self._renderItemList(items);
581
598
 
582
599
  $.when(self.$scrollableContent.append(result)).then(function() {
583
600
 
601
+ let $inputs = self.$scrollableContent.find(':input');
602
+
584
603
  if (self.$scrollableContent[0].offsetHeight < self.$scrollableContent[0].scrollHeight) {
585
604
 
586
605
  self.scroll.update();
@@ -594,9 +613,9 @@ class Select extends AbstractUIComponent {
594
613
  self.$scrollableContent.removeClass('ps-show-rail-y');
595
614
  }
596
615
 
597
- if (self.$select.find(':input[type="checkbox"]').length) {
616
+ if (self.$scrollableContent.find(':input[type="checkbox"]').length) {
598
617
  self.type = 'checkbox';
599
- } else if (self.$select.find(':input[type="radio"]').length) {
618
+ } else if (self.$scrollableContent.find(':input[type="radio"]').length) {
600
619
  self.type = 'radio';
601
620
  }
602
621
 
@@ -604,7 +623,7 @@ class Select extends AbstractUIComponent {
604
623
 
605
624
  self.data[self.name].forEach(function(value) {
606
625
 
607
- let $input = self.$select.find(':input').filter(function() { return this.value == value });
626
+ let $input = $inputs.filter(function() { return this.value == value });
608
627
 
609
628
  $input.prop('checked', true);
610
629
 
@@ -613,7 +632,7 @@ class Select extends AbstractUIComponent {
613
632
 
614
633
  } else if (self.type == 'radio') {
615
634
 
616
- let $input = self.$select.find(':input').filter(function() { return this.value == self.data[self.name] });
635
+ let $input = $inputs.filter(function() { return this.value == self.data[self.name] });
617
636
 
618
637
  $input.prop('checked', true);
619
638
  $input.addClass('checked');
@@ -629,9 +648,23 @@ class Select extends AbstractUIComponent {
629
648
 
630
649
  } else {
631
650
 
632
- if (this.$select.find(':input[type="checkbox"]').length) {
651
+ // Remove value from data if it doesn't exist anymore
652
+ let $inputs = this.$scrollableContent.find(':input');
653
+ let inputValues = $inputs.length > 0 ? $inputs.map(function() {
654
+ return parseInt(this.value, 10);
655
+ }).get() : [];
656
+
657
+ this.data[this.name] = this.data[this.name].filter(function(value) {
658
+ return inputValues.indexOf(parseInt(value, 10)) > -1;
659
+ });
660
+
661
+ if (this.data[this.name].length == 0) {
662
+ this.$selectIconContainer.html(this.selectIconDefault);
663
+ }
664
+
665
+ if (this.$scrollableContent.find(':input[type="checkbox"]').length) {
633
666
  this.type = 'checkbox';
634
- } else if (this.$select.find(':input[type="radio"]').length) {
667
+ } else if (this.$scrollableContent.find(':input[type="radio"]').length) {
635
668
  this.type = 'radio';
636
669
  }
637
670
 
@@ -639,7 +672,9 @@ class Select extends AbstractUIComponent {
639
672
 
640
673
  this.data[this.name].forEach(function(value) {
641
674
 
642
- let $input = self.$select.find(':input').filter(function() { return this.value == value });
675
+ let $input = $inputs.filter(function() {
676
+ return this.value == value
677
+ });
643
678
 
644
679
  $input.prop('checked', true);
645
680
 
@@ -648,7 +683,9 @@ class Select extends AbstractUIComponent {
648
683
 
649
684
  } else if (this.type == 'radio') {
650
685
 
651
- let $input = this.$select.find(':input').filter(function() { return this.value == self.data[self.name] });
686
+ let $input = $inputs.filter(function() {
687
+ return this.value == self.data[self.name]
688
+ });
652
689
 
653
690
  $input.prop('checked', true);
654
691
  $input.addClass('checked');
@@ -681,7 +718,7 @@ class Select extends AbstractUIComponent {
681
718
 
682
719
  let items = data.map(item => {
683
720
 
684
- item.id = item.id.toString();
721
+ item.id = item[self.primaryKeyword].toString();
685
722
 
686
723
  return item;
687
724
  });
@@ -690,7 +727,7 @@ class Select extends AbstractUIComponent {
690
727
  return self.data[self.name].indexOf(item.id) === -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
691
728
  });
692
729
 
693
- let result = $(self._renderItemList(items));
730
+ let result = self._renderItemList(items);
694
731
 
695
732
  $.when(self.$scrollableContent.append(result)).then(function() {
696
733
 
@@ -832,11 +869,25 @@ class Select extends AbstractUIComponent {
832
869
  // On select
833
870
  onSelect(el) {
834
871
 
872
+ let self = this;
835
873
  let onSelect = this.opts.onSelect;
874
+ let data = $(el).parents('.select-item').data();
875
+
876
+ if (this.searchApi.length && !$.isEmptyObject(data)) {
877
+
878
+ if ($(el).length && el.checked) {
879
+
880
+ this.items.push(data);
881
+
882
+ } else {
883
+
884
+ this.items = $.grep(this.items, function(item) { return item[self.primaryKeyword] != data.id });
885
+ }
886
+ }
836
887
 
837
888
  if (typeof onSelect === 'function') {
838
889
 
839
- onSelect.call(el);
890
+ onSelect.call(el, data, this);
840
891
  }
841
892
  }
842
893
 
@@ -1045,7 +1096,7 @@ class Select extends AbstractUIComponent {
1045
1096
 
1046
1097
  _renderItemList(items) {
1047
1098
 
1048
- let result = '';
1099
+ let result = [];
1049
1100
 
1050
1101
  for (let i = 0; i < items.length; ++i) {
1051
1102
 
@@ -1067,7 +1118,7 @@ class Select extends AbstractUIComponent {
1067
1118
  }
1068
1119
  }
1069
1120
 
1070
- result += `
1121
+ result.push($(`
1071
1122
 
1072
1123
  <div class="select-item">
1073
1124
 
@@ -1097,7 +1148,7 @@ class Select extends AbstractUIComponent {
1097
1148
 
1098
1149
  </div>
1099
1150
 
1100
- `;
1151
+ `).data(item));
1101
1152
  }
1102
1153
 
1103
1154
  return result;
@@ -1228,7 +1279,8 @@ if (typeof $ !== 'undefined') {
1228
1279
  allowNoneOnRadioSelect: true,
1229
1280
  preventUncheck: false,
1230
1281
  showValidStateIcon: true,
1231
- itemsToExclude: []
1282
+ itemsToExclude: [],
1283
+ primaryKeyword: 'id'
1232
1284
  }
1233
1285
  }
1234
1286
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finqu/cool",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Finqu UI package",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/scss/LISENCE CHANGED
@@ -1,6 +1,6 @@
1
1
  ISC License
2
2
 
3
- Copyright (c) 2019, Finqu Oy
3
+ Copyright (c) 2020, Finqu Oy
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
6
6
  purpose with or without fee is hereby granted, provided that the above
package/scss/_frame.scss CHANGED
@@ -315,6 +315,7 @@
315
315
  font-size: $frame-sidebar-nav-icon-size;
316
316
  margin: 0 auto;
317
317
  color: $frame-sidebar-nav-icon-color;
318
+ min-width: 23px;
318
319
 
319
320
  & + span {
320
321
  margin-left: 20px;
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * Cool UI - Grid v1.2.5 (https://finqu.fi)
3
- * Copyright 2019 Finqu Oy.
2
+ * Cool UI - Grid v1.2.7 (https://finqu.fi)
3
+ * Copyright 2020 Finqu Oy.
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  * Forked from Bootstrap, licensed MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * Cool UI - Reboot v1.2.5 (https://finqu.fi)
3
- * Copyright 2019 Finqu Oy.
2
+ * Cool UI - Reboot v1.2.7 (https://finqu.fi)
3
+ * Copyright 2020 Finqu Oy.
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  * Forked from Bootstrap, licensed MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6
6
  */
package/scss/cool.scss CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * Cool UI v1.2.5 (https://finqu.fi)
3
- * Copyright 2019 Finqu Oy.
2
+ * Cool UI v1.2.7 (https://finqu.fi)
3
+ * Copyright 2020 Finqu Oy.
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  * Forked from Bootstrap, licensed MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6
6
  */