@ekzo-dev/bootstrap-addons 5.2.11 → 5.2.13

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ekzo-dev/bootstrap-addons",
3
3
  "description": "Aurelia Bootstrap additional component",
4
- "version": "5.2.11",
4
+ "version": "5.2.13",
5
5
  "homepage": "https://github.com/ekzo-dev/aurelia-components/tree/main/packages/bootstrap-addons",
6
6
  "repository": {
7
7
  "type": "git",
@@ -25,18 +25,23 @@
25
25
  </fieldset>
26
26
  <template else>
27
27
  <input
28
+ id.bind="id"
28
29
  class="form-select ${bsSize ? `form-select-${bsSize}` : ''} ${valid ? 'is-valid' : valid === false ? 'is-invalid' : ''}"
29
30
  bs-dropdown-toggle="arrow.bind: false"
30
- value="${selectedOption?.group ? selectedOption.group + ' / ' : ''}${selectedOption?.text}"
31
+ value="${selectedOption?.group ? selectedOption.group + ' / ' : ''}${selectedOption?.text ?? ''}"
31
32
  disabled.bind="disabled"
32
33
  required.bind="required"
33
- readonly
34
+ form.bind="form & attr"
35
+ name.bind="name & attr"
36
+ title.bind="title & attr"
37
+ autocomplete.bind="autocomplete & attr"
38
+ keydown.trigger="$event.preventDefault()"
34
39
  />
35
40
  <bs-dropdown-menu>
36
- <div bs-dropdown-item="text" if.bind="options.length > 10">
41
+ <div bs-dropdown-item="text" if.bind="optionsCount > 10">
37
42
  <input class="form-control" placeholder="Filter options" type="search" value.bind="filter & debounce:250" />
38
43
  </div>
39
- <hr bs-dropdown-item="divider" if.bind="options.length > 10" />
44
+ <hr bs-dropdown-item="divider" if.bind="optionsCount > 10" />
40
45
  <button
41
46
  type="button"
42
47
  repeat.for="option of ungroupedOptions | filter:filter"
@@ -10,8 +10,7 @@ import {
10
10
  BsSelect as BaseBsSelect,
11
11
  ISelectOption,
12
12
  } from '@ekzo-dev/bootstrap';
13
- import { coerceBoolean } from '@ekzo-dev/toolkit';
14
- import { bindable, customElement, ICustomElementViewModel } from 'aurelia';
13
+ import { customElement, ICustomElementViewModel } from 'aurelia';
15
14
 
16
15
  import { Filter } from './filter';
17
16
 
@@ -26,13 +25,12 @@ const BS_SIZE_MULTIPLIER = {
26
25
  dependencies: [BsDropdown, BsDropdownMenu, BsDropdownToggle, BsDropdownItem, Filter],
27
26
  })
28
27
  export class BsSelect extends BaseBsSelect implements ICustomElementViewModel {
29
- @bindable(coerceBoolean)
30
- resetUnknownValue: boolean = true;
31
-
32
28
  control!: HTMLFieldSetElement;
33
29
 
34
30
  filter: string = '';
35
31
 
32
+ optionsCount: number = 0;
33
+
36
34
  attached() {
37
35
  if (this.multiple) {
38
36
  this.#setHeight();
@@ -89,18 +87,25 @@ export class BsSelect extends BaseBsSelect implements ICustomElementViewModel {
89
87
  options = Object.entries(options);
90
88
  }
91
89
 
92
- const option = (options as Array<ISelectOption | readonly [unknown, string]>).find((option) => {
93
- const val: unknown = Array.isArray(option) ? option[0] : (option as ISelectOption).value;
90
+ this.optionsCount = (options as []).length;
91
+
92
+ const isEntries = Array.isArray(options[0]);
93
+ let option = (options as Array<ISelectOption | readonly [unknown, string]>).find((option) => {
94
+ const currentValue: unknown = isEntries ? option[0] : (option as ISelectOption).value;
94
95
 
95
- return matcher ? matcher(value, val) : value === val;
96
+ return matcher ? matcher(value, currentValue) : value === currentValue;
96
97
  });
97
98
 
98
- // reset value next tick if needed
99
- if (option === undefined && value !== undefined && this.resetUnknownValue) {
100
- console.info('[bootstrap-addons] resetting <bs-select> unknown value');
101
- void Promise.resolve().then(() => (this.value = undefined));
99
+ option = isEntries && option !== undefined ? { value: option[0], text: option[1] } : (option as ISelectOption);
100
+
101
+ // update value next tick if it differs from current
102
+ const foundValue = option?.value;
103
+
104
+ if (foundValue !== value) {
105
+ console.info(`[bootstrap-addons] updating <bs-select> [id=${this.id}] value to`, foundValue);
106
+ void Promise.resolve().then(() => (this.value = foundValue));
102
107
  }
103
108
 
104
- return Array.isArray(option) ? { value: option[0], text: option[1] } : (option as ISelectOption);
109
+ return option;
105
110
  }
106
111
  }