slim-select 2.4.0 → 2.4.1

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.
@@ -354,10 +354,7 @@ export default class Render {
354
354
  }
355
355
  }
356
356
 
357
- public mainFocus(trigger: boolean, eventType: string | null): void {
358
- if (!trigger) {
359
- this.settings.triggerFocus = false
360
- }
357
+ public mainFocus(eventType: string | null): void {
361
358
  // Trigger focus but dont scroll to it
362
359
  // Need for prevent refocus the element if event is not keyboard event.
363
360
  // For example if event is mouse click or tachpad click this condition prevent refocus on element
@@ -365,7 +362,6 @@ export default class Render {
365
362
  if (eventType !== 'click') {
366
363
  this.main.main.focus({ preventScroll: true })
367
364
  }
368
- this.settings.triggerFocus = true
369
365
  }
370
366
 
371
367
  public placeholder(): HTMLDivElement {
@@ -685,7 +681,6 @@ export default class Render {
685
681
  switch (e.key) {
686
682
  case 'ArrowUp':
687
683
  case 'ArrowDown':
688
- this.callbacks.open()
689
684
  e.key === 'ArrowDown' ? this.highlight('down') : this.highlight('up')
690
685
  return false
691
686
  case 'Tab':
@@ -712,15 +707,6 @@ export default class Render {
712
707
  }
713
708
  }
714
709
 
715
- // If focus is on the search input, open the dropdown
716
- input.onfocus = () => {
717
- // If we are already open, do nothing
718
- if (this.settings.isOpen) {
719
- return
720
- }
721
-
722
- this.callbacks.open()
723
- }
724
710
  main.appendChild(input)
725
711
 
726
712
  // If addable is enabled, add the addable div
@@ -822,12 +808,8 @@ export default class Render {
822
808
  return searchReturn
823
809
  }
824
810
 
825
- public searchFocus(trigger: boolean): void {
826
- if (!trigger) {
827
- this.settings.triggerFocus = false
828
- }
811
+ public searchFocus(): void {
829
812
  this.content.search.input.focus()
830
- this.settings.triggerFocus = true
831
813
  }
832
814
 
833
815
  public getOptions(notPlaceholder = false, notDisabled = false, notHidden = false): HTMLDivElement[] {
@@ -10,8 +10,7 @@ export default class Settings {
10
10
  // Dynamic settings
11
11
  public isMultiple: boolean = false
12
12
  public isOpen: boolean = false
13
- public isWindowFocused: boolean = true
14
- public triggerFocus: boolean = true
13
+ public isFullOpen: boolean = false
15
14
  public intervalMove: NodeJS.Timeout | null = null
16
15
 
17
16
  // Fields set from constructor
@@ -93,7 +93,7 @@ export default class Render {
93
93
  updateClassStyles(): void;
94
94
  updateAriaAttributes(): void;
95
95
  mainDiv(): Main;
96
- mainFocus(trigger: boolean, eventType: string | null): void;
96
+ mainFocus(eventType: string | null): void;
97
97
  placeholder(): HTMLDivElement;
98
98
  renderValues(): void;
99
99
  private renderSingleValue;
@@ -102,7 +102,7 @@ export default class Render {
102
102
  contentDiv(): Content;
103
103
  moveContent(): void;
104
104
  searchDiv(): Search;
105
- searchFocus(trigger: boolean): void;
105
+ searchFocus(): void;
106
106
  getOptions(notPlaceholder?: boolean, notDisabled?: boolean, notHidden?: boolean): HTMLDivElement[];
107
107
  highlight(dir: 'up' | 'down'): void;
108
108
  listDiv(): HTMLDivElement;
@@ -6,8 +6,7 @@ export default class Settings {
6
6
  class: string[];
7
7
  isMultiple: boolean;
8
8
  isOpen: boolean;
9
- isWindowFocused: boolean;
10
- triggerFocus: boolean;
9
+ isFullOpen: boolean;
11
10
  intervalMove: NodeJS.Timeout | null;
12
11
  disabled: boolean;
13
12
  alwaysOpen: boolean;
@@ -59,8 +59,7 @@ class Settings {
59
59
  this.class = [];
60
60
  this.isMultiple = false;
61
61
  this.isOpen = false;
62
- this.isWindowFocused = true;
63
- this.triggerFocus = true;
62
+ this.isFullOpen = false;
64
63
  this.intervalMove = null;
65
64
  if (!settings) {
66
65
  settings = {};
@@ -503,14 +502,10 @@ class Render {
503
502
  },
504
503
  };
505
504
  }
506
- mainFocus(trigger, eventType) {
507
- if (!trigger) {
508
- this.settings.triggerFocus = false;
509
- }
505
+ mainFocus(eventType) {
510
506
  if (eventType !== 'click') {
511
507
  this.main.main.focus({ preventScroll: true });
512
508
  }
513
- this.settings.triggerFocus = true;
514
509
  }
515
510
  placeholder() {
516
511
  const placeholderOption = this.store.filter((o) => o.placeholder, false);
@@ -744,7 +739,6 @@ class Render {
744
739
  switch (e.key) {
745
740
  case 'ArrowUp':
746
741
  case 'ArrowDown':
747
- this.callbacks.open();
748
742
  e.key === 'ArrowDown' ? this.highlight('down') : this.highlight('up');
749
743
  return false;
750
744
  case 'Tab':
@@ -767,12 +761,6 @@ class Render {
767
761
  return false;
768
762
  }
769
763
  };
770
- input.onfocus = () => {
771
- if (this.settings.isOpen) {
772
- return;
773
- }
774
- this.callbacks.open();
775
- };
776
764
  main.appendChild(input);
777
765
  if (this.callbacks.addable) {
778
766
  addable.classList.add(this.classes.addable);
@@ -845,12 +833,8 @@ class Render {
845
833
  }
846
834
  return searchReturn;
847
835
  }
848
- searchFocus(trigger) {
849
- if (!trigger) {
850
- this.settings.triggerFocus = false;
851
- }
836
+ searchFocus() {
852
837
  this.content.search.input.focus();
853
- this.settings.triggerFocus = true;
854
838
  }
855
839
  getOptions(notPlaceholder = false, notDisabled = false, notHidden = false) {
856
840
  let query = '.' + this.classes.option;
@@ -1507,13 +1491,13 @@ class SlimSelect {
1507
1491
  afterClose: undefined,
1508
1492
  };
1509
1493
  this.windowResize = debounce(() => {
1510
- if (!this.settings.isOpen) {
1494
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1511
1495
  return;
1512
1496
  }
1513
1497
  this.render.moveContent();
1514
1498
  });
1515
1499
  this.windowScroll = debounce(() => {
1516
- if (!this.settings.isOpen) {
1500
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1517
1501
  return;
1518
1502
  }
1519
1503
  this.render.moveContent();
@@ -1528,14 +1512,8 @@ class SlimSelect {
1528
1512
  };
1529
1513
  this.windowVisibilityChange = () => {
1530
1514
  if (document.hidden) {
1531
- this.settings.isWindowFocused = false;
1532
1515
  this.close();
1533
1516
  }
1534
- else {
1535
- setTimeout(() => {
1536
- this.settings.isWindowFocused = true;
1537
- }, 20);
1538
- }
1539
1517
  };
1540
1518
  this.selectEl = (typeof config.select === 'string' ? document.querySelector(config.select) : config.select);
1541
1519
  if (!this.selectEl) {
@@ -1705,13 +1683,16 @@ class SlimSelect {
1705
1683
  }
1706
1684
  this.render.open();
1707
1685
  if (this.settings.showSearch) {
1708
- this.render.searchFocus(false);
1686
+ this.render.searchFocus();
1709
1687
  }
1688
+ this.settings.isOpen = true;
1710
1689
  setTimeout(() => {
1711
1690
  if (this.events.afterOpen) {
1712
1691
  this.events.afterOpen();
1713
1692
  }
1714
- this.settings.isOpen = true;
1693
+ if (this.settings.isOpen) {
1694
+ this.settings.isFullOpen = true;
1695
+ }
1715
1696
  }, this.settings.timeoutDelay);
1716
1697
  if (this.settings.contentPosition === 'absolute') {
1717
1698
  if (this.settings.intervalMove) {
@@ -1731,12 +1712,13 @@ class SlimSelect {
1731
1712
  if (this.render.content.search.input.value !== '') {
1732
1713
  this.search('');
1733
1714
  }
1734
- this.render.mainFocus(false, eventType);
1715
+ this.render.mainFocus(eventType);
1716
+ this.settings.isOpen = false;
1717
+ this.settings.isFullOpen = false;
1735
1718
  setTimeout(() => {
1736
1719
  if (this.events.afterClose) {
1737
1720
  this.events.afterClose();
1738
1721
  }
1739
- this.settings.isOpen = false;
1740
1722
  }, this.settings.timeoutDelay);
1741
1723
  if (this.settings.intervalMove) {
1742
1724
  clearInterval(this.settings.intervalMove);
@@ -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':
@@ -768,12 +762,6 @@ var SlimSelectVue = (function (vue) {
768
762
  return false;
769
763
  }
770
764
  };
771
- input.onfocus = () => {
772
- if (this.settings.isOpen) {
773
- return;
774
- }
775
- this.callbacks.open();
776
- };
777
765
  main.appendChild(input);
778
766
  if (this.callbacks.addable) {
779
767
  addable.classList.add(this.classes.addable);
@@ -846,12 +834,8 @@ var SlimSelectVue = (function (vue) {
846
834
  }
847
835
  return searchReturn;
848
836
  }
849
- searchFocus(trigger) {
850
- if (!trigger) {
851
- this.settings.triggerFocus = false;
852
- }
837
+ searchFocus() {
853
838
  this.content.search.input.focus();
854
- this.settings.triggerFocus = true;
855
839
  }
856
840
  getOptions(notPlaceholder = false, notDisabled = false, notHidden = false) {
857
841
  let query = '.' + this.classes.option;
@@ -1508,13 +1492,13 @@ var SlimSelectVue = (function (vue) {
1508
1492
  afterClose: undefined,
1509
1493
  };
1510
1494
  this.windowResize = debounce(() => {
1511
- if (!this.settings.isOpen) {
1495
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1512
1496
  return;
1513
1497
  }
1514
1498
  this.render.moveContent();
1515
1499
  });
1516
1500
  this.windowScroll = debounce(() => {
1517
- if (!this.settings.isOpen) {
1501
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1518
1502
  return;
1519
1503
  }
1520
1504
  this.render.moveContent();
@@ -1529,14 +1513,8 @@ var SlimSelectVue = (function (vue) {
1529
1513
  };
1530
1514
  this.windowVisibilityChange = () => {
1531
1515
  if (document.hidden) {
1532
- this.settings.isWindowFocused = false;
1533
1516
  this.close();
1534
1517
  }
1535
- else {
1536
- setTimeout(() => {
1537
- this.settings.isWindowFocused = true;
1538
- }, 20);
1539
- }
1540
1518
  };
1541
1519
  this.selectEl = (typeof config.select === 'string' ? document.querySelector(config.select) : config.select);
1542
1520
  if (!this.selectEl) {
@@ -1706,13 +1684,16 @@ var SlimSelectVue = (function (vue) {
1706
1684
  }
1707
1685
  this.render.open();
1708
1686
  if (this.settings.showSearch) {
1709
- this.render.searchFocus(false);
1687
+ this.render.searchFocus();
1710
1688
  }
1689
+ this.settings.isOpen = true;
1711
1690
  setTimeout(() => {
1712
1691
  if (this.events.afterOpen) {
1713
1692
  this.events.afterOpen();
1714
1693
  }
1715
- this.settings.isOpen = true;
1694
+ if (this.settings.isOpen) {
1695
+ this.settings.isFullOpen = true;
1696
+ }
1716
1697
  }, this.settings.timeoutDelay);
1717
1698
  if (this.settings.contentPosition === 'absolute') {
1718
1699
  if (this.settings.intervalMove) {
@@ -1732,12 +1713,13 @@ var SlimSelectVue = (function (vue) {
1732
1713
  if (this.render.content.search.input.value !== '') {
1733
1714
  this.search('');
1734
1715
  }
1735
- this.render.mainFocus(false, eventType);
1716
+ this.render.mainFocus(eventType);
1717
+ this.settings.isOpen = false;
1718
+ this.settings.isFullOpen = false;
1736
1719
  setTimeout(() => {
1737
1720
  if (this.events.afterClose) {
1738
1721
  this.events.afterClose();
1739
1722
  }
1740
- this.settings.isOpen = false;
1741
1723
  }, this.settings.timeoutDelay);
1742
1724
  if (this.settings.intervalMove) {
1743
1725
  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':
@@ -769,12 +763,6 @@ class Render {
769
763
  return false;
770
764
  }
771
765
  };
772
- input.onfocus = () => {
773
- if (this.settings.isOpen) {
774
- return;
775
- }
776
- this.callbacks.open();
777
- };
778
766
  main.appendChild(input);
779
767
  if (this.callbacks.addable) {
780
768
  addable.classList.add(this.classes.addable);
@@ -847,12 +835,8 @@ class Render {
847
835
  }
848
836
  return searchReturn;
849
837
  }
850
- searchFocus(trigger) {
851
- if (!trigger) {
852
- this.settings.triggerFocus = false;
853
- }
838
+ searchFocus() {
854
839
  this.content.search.input.focus();
855
- this.settings.triggerFocus = true;
856
840
  }
857
841
  getOptions(notPlaceholder = false, notDisabled = false, notHidden = false) {
858
842
  let query = '.' + this.classes.option;
@@ -1509,13 +1493,13 @@ class SlimSelect {
1509
1493
  afterClose: undefined,
1510
1494
  };
1511
1495
  this.windowResize = debounce(() => {
1512
- if (!this.settings.isOpen) {
1496
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1513
1497
  return;
1514
1498
  }
1515
1499
  this.render.moveContent();
1516
1500
  });
1517
1501
  this.windowScroll = debounce(() => {
1518
- if (!this.settings.isOpen) {
1502
+ if (!this.settings.isOpen && !this.settings.isFullOpen) {
1519
1503
  return;
1520
1504
  }
1521
1505
  this.render.moveContent();
@@ -1530,14 +1514,8 @@ class SlimSelect {
1530
1514
  };
1531
1515
  this.windowVisibilityChange = () => {
1532
1516
  if (document.hidden) {
1533
- this.settings.isWindowFocused = false;
1534
1517
  this.close();
1535
1518
  }
1536
- else {
1537
- setTimeout(() => {
1538
- this.settings.isWindowFocused = true;
1539
- }, 20);
1540
- }
1541
1519
  };
1542
1520
  this.selectEl = (typeof config.select === 'string' ? document.querySelector(config.select) : config.select);
1543
1521
  if (!this.selectEl) {
@@ -1707,13 +1685,16 @@ class SlimSelect {
1707
1685
  }
1708
1686
  this.render.open();
1709
1687
  if (this.settings.showSearch) {
1710
- this.render.searchFocus(false);
1688
+ this.render.searchFocus();
1711
1689
  }
1690
+ this.settings.isOpen = true;
1712
1691
  setTimeout(() => {
1713
1692
  if (this.events.afterOpen) {
1714
1693
  this.events.afterOpen();
1715
1694
  }
1716
- this.settings.isOpen = true;
1695
+ if (this.settings.isOpen) {
1696
+ this.settings.isFullOpen = true;
1697
+ }
1717
1698
  }, this.settings.timeoutDelay);
1718
1699
  if (this.settings.contentPosition === 'absolute') {
1719
1700
  if (this.settings.intervalMove) {
@@ -1733,12 +1714,13 @@ class SlimSelect {
1733
1714
  if (this.render.content.search.input.value !== '') {
1734
1715
  this.search('');
1735
1716
  }
1736
- this.render.mainFocus(false, eventType);
1717
+ this.render.mainFocus(eventType);
1718
+ this.settings.isOpen = false;
1719
+ this.settings.isFullOpen = false;
1737
1720
  setTimeout(() => {
1738
1721
  if (this.events.afterClose) {
1739
1722
  this.events.afterClose();
1740
1723
  }
1741
- this.settings.isOpen = false;
1742
1724
  }, this.settings.timeoutDelay);
1743
1725
  if (this.settings.intervalMove) {
1744
1726
  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.1",
5
5
  "description": "Vue integration",
6
6
  "repository": {
7
7
  "type": "git",