slim-select 2.4.0 → 2.4.2

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.
@@ -60,8 +60,7 @@ var SlimSelectVue = (function (vue) {
60
60
  this.class = [];
61
61
  this.isMultiple = false;
62
62
  this.isOpen = false;
63
- this.isWindowFocused = true;
64
- this.triggerFocus = true;
63
+ this.isFullOpen = false;
65
64
  this.intervalMove = null;
66
65
  if (!settings) {
67
66
  settings = {};
@@ -504,14 +503,10 @@ var SlimSelectVue = (function (vue) {
504
503
  },
505
504
  };
506
505
  }
507
- mainFocus(trigger, eventType) {
508
- if (!trigger) {
509
- this.settings.triggerFocus = false;
510
- }
506
+ mainFocus(eventType) {
511
507
  if (eventType !== 'click') {
512
508
  this.main.main.focus({ preventScroll: true });
513
509
  }
514
- this.settings.triggerFocus = true;
515
510
  }
516
511
  placeholder() {
517
512
  const placeholderOption = this.store.filter((o) => o.placeholder, false);
@@ -745,7 +740,6 @@ var SlimSelectVue = (function (vue) {
745
740
  switch (e.key) {
746
741
  case 'ArrowUp':
747
742
  case 'ArrowDown':
748
- this.callbacks.open();
749
743
  e.key === 'ArrowDown' ? this.highlight('down') : this.highlight('up');
750
744
  return false;
751
745
  case 'Tab':
@@ -758,21 +752,17 @@ var SlimSelectVue = (function (vue) {
758
752
  case ' ':
759
753
  if (this.callbacks.addable && e.ctrlKey) {
760
754
  addable.click();
755
+ return false;
761
756
  }
762
757
  else {
763
758
  const highlighted = this.content.list.querySelector('.' + this.classes.highlighted);
764
759
  if (highlighted) {
765
760
  highlighted.click();
761
+ return false;
766
762
  }
767
763
  }
768
- return false;
769
- }
770
- };
771
- input.onfocus = () => {
772
- if (this.settings.isOpen) {
773
- return;
764
+ return true;
774
765
  }
775
- this.callbacks.open();
776
766
  };
777
767
  main.appendChild(input);
778
768
  if (this.callbacks.addable) {
@@ -846,12 +836,8 @@ var SlimSelectVue = (function (vue) {
846
836
  }
847
837
  return searchReturn;
848
838
  }
849
- searchFocus(trigger) {
850
- if (!trigger) {
851
- this.settings.triggerFocus = false;
852
- }
839
+ searchFocus() {
853
840
  this.content.search.input.focus();
854
- this.settings.triggerFocus = true;
855
841
  }
856
842
  getOptions(notPlaceholder = false, notDisabled = false, notHidden = false) {
857
843
  let query = '.' + this.classes.option;
@@ -1508,13 +1494,13 @@ var SlimSelectVue = (function (vue) {
1508
1494
  afterClose: undefined,
1509
1495
  };
1510
1496
  this.windowResize = debounce(() => {
1511
- if (!this.settings.isOpen) {
1497
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1512
1498
  return;
1513
1499
  }
1514
1500
  this.render.moveContent();
1515
1501
  });
1516
1502
  this.windowScroll = debounce(() => {
1517
- if (!this.settings.isOpen) {
1503
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1518
1504
  return;
1519
1505
  }
1520
1506
  this.render.moveContent();
@@ -1529,14 +1515,8 @@ var SlimSelectVue = (function (vue) {
1529
1515
  };
1530
1516
  this.windowVisibilityChange = () => {
1531
1517
  if (document.hidden) {
1532
- this.settings.isWindowFocused = false;
1533
1518
  this.close();
1534
1519
  }
1535
- else {
1536
- setTimeout(() => {
1537
- this.settings.isWindowFocused = true;
1538
- }, 20);
1539
- }
1540
1520
  };
1541
1521
  this.selectEl = (typeof config.select === 'string' ? document.querySelector(config.select) : config.select);
1542
1522
  if (!this.selectEl) {
@@ -1706,13 +1686,16 @@ var SlimSelectVue = (function (vue) {
1706
1686
  }
1707
1687
  this.render.open();
1708
1688
  if (this.settings.showSearch) {
1709
- this.render.searchFocus(false);
1689
+ this.render.searchFocus();
1710
1690
  }
1691
+ this.settings.isOpen = true;
1711
1692
  setTimeout(() => {
1712
1693
  if (this.events.afterOpen) {
1713
1694
  this.events.afterOpen();
1714
1695
  }
1715
- this.settings.isOpen = true;
1696
+ if (this.settings.isOpen) {
1697
+ this.settings.isFullOpen = true;
1698
+ }
1716
1699
  }, this.settings.timeoutDelay);
1717
1700
  if (this.settings.contentPosition === 'absolute') {
1718
1701
  if (this.settings.intervalMove) {
@@ -1732,12 +1715,13 @@ var SlimSelectVue = (function (vue) {
1732
1715
  if (this.render.content.search.input.value !== '') {
1733
1716
  this.search('');
1734
1717
  }
1735
- this.render.mainFocus(false, eventType);
1718
+ this.render.mainFocus(eventType);
1719
+ this.settings.isOpen = false;
1720
+ this.settings.isFullOpen = false;
1736
1721
  setTimeout(() => {
1737
1722
  if (this.events.afterClose) {
1738
1723
  this.events.afterClose();
1739
1724
  }
1740
- this.settings.isOpen = false;
1741
1725
  }, this.settings.timeoutDelay);
1742
1726
  if (this.settings.intervalMove) {
1743
1727
  clearInterval(this.settings.intervalMove);
@@ -61,8 +61,7 @@ class Settings {
61
61
  this.class = [];
62
62
  this.isMultiple = false;
63
63
  this.isOpen = false;
64
- this.isWindowFocused = true;
65
- this.triggerFocus = true;
64
+ this.isFullOpen = false;
66
65
  this.intervalMove = null;
67
66
  if (!settings) {
68
67
  settings = {};
@@ -505,14 +504,10 @@ class Render {
505
504
  },
506
505
  };
507
506
  }
508
- mainFocus(trigger, eventType) {
509
- if (!trigger) {
510
- this.settings.triggerFocus = false;
511
- }
507
+ mainFocus(eventType) {
512
508
  if (eventType !== 'click') {
513
509
  this.main.main.focus({ preventScroll: true });
514
510
  }
515
- this.settings.triggerFocus = true;
516
511
  }
517
512
  placeholder() {
518
513
  const placeholderOption = this.store.filter((o) => o.placeholder, false);
@@ -746,7 +741,6 @@ class Render {
746
741
  switch (e.key) {
747
742
  case 'ArrowUp':
748
743
  case 'ArrowDown':
749
- this.callbacks.open();
750
744
  e.key === 'ArrowDown' ? this.highlight('down') : this.highlight('up');
751
745
  return false;
752
746
  case 'Tab':
@@ -759,21 +753,17 @@ class Render {
759
753
  case ' ':
760
754
  if (this.callbacks.addable && e.ctrlKey) {
761
755
  addable.click();
756
+ return false;
762
757
  }
763
758
  else {
764
759
  const highlighted = this.content.list.querySelector('.' + this.classes.highlighted);
765
760
  if (highlighted) {
766
761
  highlighted.click();
762
+ return false;
767
763
  }
768
764
  }
769
- return false;
770
- }
771
- };
772
- input.onfocus = () => {
773
- if (this.settings.isOpen) {
774
- return;
765
+ return true;
775
766
  }
776
- this.callbacks.open();
777
767
  };
778
768
  main.appendChild(input);
779
769
  if (this.callbacks.addable) {
@@ -847,12 +837,8 @@ class Render {
847
837
  }
848
838
  return searchReturn;
849
839
  }
850
- searchFocus(trigger) {
851
- if (!trigger) {
852
- this.settings.triggerFocus = false;
853
- }
840
+ searchFocus() {
854
841
  this.content.search.input.focus();
855
- this.settings.triggerFocus = true;
856
842
  }
857
843
  getOptions(notPlaceholder = false, notDisabled = false, notHidden = false) {
858
844
  let query = '.' + this.classes.option;
@@ -1509,13 +1495,13 @@ class SlimSelect {
1509
1495
  afterClose: undefined,
1510
1496
  };
1511
1497
  this.windowResize = debounce(() => {
1512
- if (!this.settings.isOpen) {
1498
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1513
1499
  return;
1514
1500
  }
1515
1501
  this.render.moveContent();
1516
1502
  });
1517
1503
  this.windowScroll = debounce(() => {
1518
- if (!this.settings.isOpen) {
1504
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1519
1505
  return;
1520
1506
  }
1521
1507
  this.render.moveContent();
@@ -1530,14 +1516,8 @@ class SlimSelect {
1530
1516
  };
1531
1517
  this.windowVisibilityChange = () => {
1532
1518
  if (document.hidden) {
1533
- this.settings.isWindowFocused = false;
1534
1519
  this.close();
1535
1520
  }
1536
- else {
1537
- setTimeout(() => {
1538
- this.settings.isWindowFocused = true;
1539
- }, 20);
1540
- }
1541
1521
  };
1542
1522
  this.selectEl = (typeof config.select === 'string' ? document.querySelector(config.select) : config.select);
1543
1523
  if (!this.selectEl) {
@@ -1707,13 +1687,16 @@ class SlimSelect {
1707
1687
  }
1708
1688
  this.render.open();
1709
1689
  if (this.settings.showSearch) {
1710
- this.render.searchFocus(false);
1690
+ this.render.searchFocus();
1711
1691
  }
1692
+ this.settings.isOpen = true;
1712
1693
  setTimeout(() => {
1713
1694
  if (this.events.afterOpen) {
1714
1695
  this.events.afterOpen();
1715
1696
  }
1716
- this.settings.isOpen = true;
1697
+ if (this.settings.isOpen) {
1698
+ this.settings.isFullOpen = true;
1699
+ }
1717
1700
  }, this.settings.timeoutDelay);
1718
1701
  if (this.settings.contentPosition === 'absolute') {
1719
1702
  if (this.settings.intervalMove) {
@@ -1733,12 +1716,13 @@ class SlimSelect {
1733
1716
  if (this.render.content.search.input.value !== '') {
1734
1717
  this.search('');
1735
1718
  }
1736
- this.render.mainFocus(false, eventType);
1719
+ this.render.mainFocus(eventType);
1720
+ this.settings.isOpen = false;
1721
+ this.settings.isFullOpen = false;
1737
1722
  setTimeout(() => {
1738
1723
  if (this.events.afterClose) {
1739
1724
  this.events.afterClose();
1740
1725
  }
1741
- this.settings.isOpen = false;
1742
1726
  }, this.settings.timeoutDelay);
1743
1727
  if (this.settings.intervalMove) {
1744
1728
  clearInterval(this.settings.intervalMove);
@@ -35,8 +35,7 @@ declare const _default: import("vue").DefineComponent<{
35
35
  class: string[];
36
36
  isMultiple: boolean;
37
37
  isOpen: boolean;
38
- isWindowFocused: boolean;
39
- triggerFocus: boolean;
38
+ isFullOpen: boolean;
40
39
  intervalMove: {
41
40
  hasRef: () => boolean;
42
41
  refresh: () => NodeJS.Timeout;
@@ -113,8 +112,7 @@ declare const _default: import("vue").DefineComponent<{
113
112
  class: string[];
114
113
  isMultiple: boolean;
115
114
  isOpen: boolean;
116
- isWindowFocused: boolean;
117
- triggerFocus: boolean;
115
+ isFullOpen: boolean;
118
116
  intervalMove: {
119
117
  hasRef: () => boolean;
120
118
  refresh: () => NodeJS.Timeout;
@@ -245,14 +243,14 @@ declare const _default: import("vue").DefineComponent<{
245
243
  updateClassStyles: () => void;
246
244
  updateAriaAttributes: () => void;
247
245
  mainDiv: () => import("../slim-select/render").Main;
248
- mainFocus: (trigger: boolean, eventType: string | null) => void;
246
+ mainFocus: (eventType: string | null) => void;
249
247
  placeholder: () => HTMLDivElement;
250
248
  renderValues: () => void;
251
249
  multipleValue: (option: Option) => HTMLDivElement;
252
250
  contentDiv: () => import("../slim-select/render").Content;
253
251
  moveContent: () => void;
254
252
  searchDiv: () => import("../slim-select/render").Search;
255
- searchFocus: (trigger: boolean) => void;
253
+ searchFocus: () => void;
256
254
  getOptions: (notPlaceholder?: boolean, notDisabled?: boolean, notHidden?: boolean) => HTMLDivElement[];
257
255
  highlight: (dir: "up" | "down") => void;
258
256
  listDiv: () => HTMLDivElement;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slim-select/vue",
3
3
  "private": false,
4
- "version": "1.4.0",
4
+ "version": "1.4.2",
5
5
  "description": "Vue integration",
6
6
  "repository": {
7
7
  "type": "git",