slim-select 2.2.2 → 2.3.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.
@@ -303,25 +303,28 @@ export default class Store {
303
303
  this.data.forEach((dataObj: DataObject) => {
304
304
  // Optgroup
305
305
  if (dataObj instanceof Optgroup) {
306
- // If you dont want to include optgroups
307
- if (!includeOptgroup) {
308
- // Loop through each option and check if it meets the filter requirements
309
- dataObj.options.forEach((option: Option) => {
310
- if (filter && filter(option)) {
311
- dataSearch.push(option)
312
- }
313
- })
314
- } else {
315
- let optOptions: Option[] = []
316
- dataObj.options.forEach((option: Option) => {
317
- if (!filter || filter(option)) {
306
+ let optOptions: Option[] = []
307
+ dataObj.options.forEach((option: Option) => {
308
+ if (!filter || filter(option)) {
309
+ // If you dont want to include optgroups
310
+ // just push to the dataSearch array
311
+ if (!includeOptgroup) {
312
+ dataSearch.push(new Option(option))
313
+ } else {
318
314
  optOptions.push(new Option(option))
319
315
  }
320
- })
321
-
322
- if (optOptions.length > 0) {
323
- dataSearch.push(new Optgroup(dataObj))
324
316
  }
317
+ })
318
+
319
+ // If we pushed any options to the optOptions array
320
+ // push the optgroup to the dataSearch array
321
+ if (optOptions.length > 0) {
322
+ // Create new optgroup with the new options
323
+ let optgroup = new Optgroup(dataObj)
324
+ optgroup.options = optOptions
325
+
326
+ // Push optgroup to dataSearch
327
+ dataSearch.push(optgroup)
325
328
  }
326
329
  }
327
330
 
@@ -48,6 +48,7 @@ export default class Render {
48
48
  placeholder: string;
49
49
  values: string;
50
50
  single: string;
51
+ max: string;
51
52
  value: string;
52
53
  valueText: string;
53
54
  valueDelete: string;
@@ -112,5 +113,5 @@ export default class Render {
112
113
  moveContentAbove(): void;
113
114
  moveContentBelow(): void;
114
115
  ensureElementInView(container: HTMLElement, element: HTMLElement): void;
115
- putContent(el: HTMLElement, isOpen: boolean): 'up' | 'down';
116
+ putContent(): 'up' | 'down';
116
117
  }
@@ -1,25 +1,19 @@
1
1
  import { DataArray, DataArrayPartial, Optgroup, OptgroupOptional, Option } from './store';
2
2
  export default class Select {
3
3
  select: HTMLSelectElement;
4
- listen: boolean;
5
- onSelectChange?: (data: DataArrayPartial) => void;
6
4
  onValueChange?: (value: string[]) => void;
5
+ onDisabledChange?: (disabled: boolean) => void;
6
+ onOptionsChange?: (data: DataArrayPartial) => void;
7
+ listen: boolean;
7
8
  private observer;
8
9
  constructor(select: HTMLSelectElement);
9
10
  enable(): void;
10
11
  disable(): void;
11
12
  hideUI(): void;
12
13
  showUI(): void;
13
- changeListen(on: boolean): void;
14
- addSelectChangeListener(func: (data: DataArrayPartial) => void): void;
15
- removeSelectChangeListener(): void;
16
- addValueChangeListener(func: (value: string[]) => void): void;
17
- removeValueChangeListener(): void;
14
+ changeListen(listen: boolean): void;
18
15
  valueChange(ev: Event): boolean;
19
- private observeWrapper;
20
- private addObserver;
21
- private connectObserver;
22
- private disconnectObserver;
16
+ private observeCall;
23
17
  getData(): DataArrayPartial;
24
18
  getDataFromOptgroup(optgroup: HTMLOptGroupElement): OptgroupOptional;
25
19
  getDataFromOption(option: HTMLOptionElement): Option;
@@ -8,7 +8,7 @@ export default class Settings {
8
8
  isOpen: boolean;
9
9
  triggerFocus: boolean;
10
10
  intervalMove: NodeJS.Timeout | null;
11
- isEnabled: boolean;
11
+ disabled: boolean;
12
12
  alwaysOpen: boolean;
13
13
  showSearch: boolean;
14
14
  searchPlaceholder: string;
@@ -26,5 +26,7 @@ export default class Settings {
26
26
  minSelected: number;
27
27
  maxSelected: number;
28
28
  timeoutDelay: number;
29
+ maxValuesShown: number;
30
+ maxValuesMessage: string;
29
31
  constructor(settings?: SettingsPartial);
30
32
  }