Skip to content

Commit 2d71a92

Browse files
committed
Release version 0.0.2 with new features and fixes
Updated AvalynxSelect to version 0.0.2, adding `onChange` and `onLoaded` callback options. Fixed dropdown width resizing issue and included `assetscomposer.json`. Updated examples, documentation, and changelog to reflect these changes.
1 parent 3386d88 commit 2d71a92

File tree

10 files changed

+44
-80
lines changed

10 files changed

+44
-80
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# AvalynxSelect Changelog
22

3-
## 0.0.2 (not yet released)
3+
## 0.0.2
44
- [x] Template renamed from `avalynx-select` to `avalynx-select-template`
55
- [x] Duplicate `id` fixed
6+
- [x] Dropdown width after resize fixed
7+
- [x] assetscomposer.json added
8+
- [x] `onChange` event added
9+
- [x] `onLoaded` event added
610

711
## 0.0.1
812
- [x] Initial release

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Replace `path/to/avalynx-select.js` with the actual path to the file in your pro
4343
AvalynxSelect is also available via [jsDelivr](https://www.jsdelivr.com/). You can include it in your project like this:
4444

4545
```html
46-
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.1/dist/js/avalynx-select.js"></script>
46+
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.2/dist/js/avalynx-select.js"></script>
4747
```
4848

4949
Make sure to also include Bootstrap's JS/CSS in your project to ensure AvalynxSelect displays correctly.

dist/js/avalynx-select.esm.js

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* AvalynxSelect is a lightweight, customizable select dropdown component for web applications. It is designed to be used with Bootstrap version 5.3 or higher and does not require any framework dependencies.
55
*
6-
* @version 0.0.1
6+
* @version 0.0.2
77
* @license MIT
88
* @author https://github.com/avalynx/avalynx-select/graphs/contributors
99
* @website https://github.com/avalynx/
@@ -21,6 +21,8 @@ export class name for the loader element (default: '').
2121
* @param {boolean} options.scrollList - Enable scrollable list (default: true).
2222
* @param {number} options.scrollItems - Number of items to display before scrolling (default: 8).
2323
* @param {boolean} options.noDefaultSelection - Do not select any option by default (default: false).
24+
* @param {function} options.onChange - Callback function to be executed when an option is selected (default: null).
25+
* @param {function} options.onLoaded - Callback function to be executed when the component is loaded (default: null).
2426
* @param {object} language - An object containing the following keys:
2527
* @param {string} language.searchPlaceholder - Placeholder text for the search input (default: 'Search...').
2628
* @param {string} language.selectPlaceholder - Placeholder text for the select dropdown (default: 'Please select...').
@@ -51,14 +53,21 @@ export class AvalynxSelect {
5153
scrollList: true,
5254
scrollItems: 8,
5355
noDefaultSelection: false,
56+
onChange: options.onChange || null,
57+
onLoaded: options.onLoaded || null,
5458
...options
5559
};
5660
this.language = {
5761
searchPlaceholder: 'Search...',
5862
selectPlaceholder: 'Please select...',
5963
...language
6064
};
65+
this.initialized = false;
6166
this.elements.forEach(select => this.init(select));
67+
this.initialized = true;
68+
if (this.options.onLoaded) {
69+
this.options.onLoaded();
70+
}
6271
}
6372

6473
init(select) {
@@ -218,39 +227,10 @@ export class AvalynxSelect {
218227
this.filterDropdown(dropdown, '');
219228
const dropdownMenu = new bootstrap.Dropdown(button);
220229
dropdownMenu.hide();
221-
}
222-
}
223-
224-
reset(button, dropdown, select) {
225-
button.textContent = this.language.selectPlaceholder;
226-
select.value = '';
227-
dropdown.querySelectorAll('.dropdown-item.active').forEach(activeItem => {
228-
activeItem.classList.remove('active');
229-
});
230-
const emptyOption = dropdown.querySelector('.dropdown-item[data-value=""]');
231-
if (emptyOption) {
232-
emptyOption.classList.add('active');
233-
}
234-
this.filterDropdown(dropdown, '');
235-
}
236-
237-
get value() {
238-
return Array.from(this.elements).map(select => select.value);
239-
}
240-
241-
set value(vals) {
242-
if (!Array.isArray(vals)) vals = [vals];
243-
this.elements.forEach((select, index) => {
244-
const val = vals[index] || '';
245-
const option = Array.from(select.options).find(opt => opt.value === val);
246-
const button = select.nextElementSibling;
247-
if (option) {
248-
button.textContent = option.textContent;
249-
select.value = val;
250-
} else {
251-
button.textContent = this.language.selectPlaceholder;
252-
select.value = '';
230+
if (this.initialized && this.options.onChange) {
231+
this.options.onChange(select.value);
253232
}
254-
});
233+
}
255234
}
256235
}
236+

dist/js/avalynx-select.js

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* AvalynxSelect is a lightweight, customizable select dropdown component for web applications. It is designed to be used with Bootstrap version 5.3 or higher and does not require any framework dependencies.
55
*
6-
* @version 0.0.1
6+
* @version 0.0.2
77
* @license MIT
88
* @author https://github.com/avalynx/avalynx-select/graphs/contributors
99
* @website https://github.com/avalynx/
@@ -19,6 +19,8 @@
1919
* @param {boolean} options.scrollList - Enable scrollable list (default: true).
2020
* @param {number} options.scrollItems - Number of items to display before scrolling (default: 8).
2121
* @param {boolean} options.noDefaultSelection - Do not select any option by default (default: false).
22+
* @param {function} options.onChange - Callback function to be executed when an option is selected (default: null).
23+
* @param {function} options.onLoaded - Callback function to be executed when the component is loaded (default: null).
2224
* @param {object} language - An object containing the following keys:
2325
* @param {string} language.searchPlaceholder - Placeholder text for the search input (default: 'Search...').
2426
* @param {string} language.selectPlaceholder - Placeholder text for the select dropdown (default: 'Please select...').
@@ -47,14 +49,21 @@ class AvalynxSelect {
4749
scrollList: true,
4850
scrollItems: 8,
4951
noDefaultSelection: false,
52+
onChange: options.onChange || null,
53+
onLoaded: options.onLoaded || null,
5054
...options
5155
};
5256
this.language = {
5357
searchPlaceholder: 'Search...',
5458
selectPlaceholder: 'Please select...',
5559
...language
5660
};
61+
this.initialized = false;
5762
this.elements.forEach(select => this.init(select));
63+
this.initialized = true;
64+
if (this.options.onLoaded) {
65+
this.options.onLoaded();
66+
}
5867
}
5968

6069
init(select) {
@@ -214,39 +223,10 @@ class AvalynxSelect {
214223
this.filterDropdown(dropdown, '');
215224
const dropdownMenu = new bootstrap.Dropdown(button);
216225
dropdownMenu.hide();
217-
}
218-
}
219-
220-
reset(button, dropdown, select) {
221-
button.textContent = this.language.selectPlaceholder;
222-
select.value = '';
223-
dropdown.querySelectorAll('.dropdown-item.active').forEach(activeItem => {
224-
activeItem.classList.remove('active');
225-
});
226-
const emptyOption = dropdown.querySelector('.dropdown-item[data-value=""]');
227-
if (emptyOption) {
228-
emptyOption.classList.add('active');
229-
}
230-
this.filterDropdown(dropdown, '');
231-
}
232-
233-
get value() {
234-
return Array.from(this.elements).map(select => select.value);
235-
}
236-
237-
set value(vals) {
238-
if (!Array.isArray(vals)) vals = [vals];
239-
this.elements.forEach((select, index) => {
240-
const val = vals[index] || '';
241-
const option = Array.from(select.options).find(opt => opt.value === val);
242-
const button = select.nextElementSibling;
243-
if (option) {
244-
button.textContent = option.textContent;
245-
select.value = val;
246-
} else {
247-
button.textContent = this.language.selectPlaceholder;
248-
select.value = '';
226+
if (this.initialized && this.options.onChange) {
227+
this.options.onChange(select.value);
249228
}
250-
});
229+
}
251230
}
252231
}
232+

examples/simple-select-event-listeners.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9/build/styles/stackoverflow-light.min.css" id="hljsTheme">
1717
<script>hljs.highlightAll();</script>
1818

19-
<!-- AvalynxSelect 0.0.1 -->
20-
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.1/dist/js/avalynx-select.js"></script>
19+
<!-- AvalynxSelect 0.0.2 -->
20+
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.2/dist/js/avalynx-select.js"></script>
2121

2222
<!-- Example helper -->
2323
<link href="./css/helper.css" rel="stylesheet">

examples/simple-select-livesearch.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9/build/styles/stackoverflow-light.min.css" id="hljsTheme">
1717
<script>hljs.highlightAll();</script>
1818

19-
<!-- AvalynxSelect 0.0.1 -->
20-
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.1/dist/js/avalynx-select.js"></script>
19+
<!-- AvalynxSelect 0.0.2 -->
20+
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.2/dist/js/avalynx-select.js"></script>
2121

2222
<!-- Example helper -->
2323
<link href="./css/helper.css" rel="stylesheet">

examples/simple-select-responsive.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9/build/styles/stackoverflow-light.min.css" id="hljsTheme">
1717
<script>hljs.highlightAll();</script>
1818

19-
<!-- AvalynxSelect 0.0.1 -->
20-
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.1/dist/js/avalynx-select.js"></script>
19+
<!-- AvalynxSelect 0.0.2 -->
20+
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.2/dist/js/avalynx-select.js"></script>
2121

2222
<!-- Example helper -->
2323
<link href="./css/helper.css" rel="stylesheet">

examples/simple-select.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9/build/styles/stackoverflow-light.min.css" id="hljsTheme">
1717
<script>hljs.highlightAll();</script>
1818

19-
<!-- AvalynxSelect 0.0.1 -->
20-
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.1/dist/js/avalynx-select.js"></script>
19+
<!-- AvalynxSelect 0.0.2 -->
20+
<script src="https://cdn.jsdelivr.net/npm/avalynx-select@0.0.2/dist/js/avalynx-select.js"></script>
2121

2222
<!-- Example helper -->
2323
<link href="./css/helper.css" rel="stylesheet">

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "avalynx-select",
33
"title": "AvalynxSelect",
44
"description": "AvalynxSelect is a lightweight, customizable select dropdown component for web applications. It is designed to be used with Bootstrap version 5.3 or higher and does not require any framework dependencies.",
5-
"version": "0.0.1",
5+
"version": "0.0.2",
66
"license": "MIT",
77
"main": "dist/js/avalynx-select.js",
88
"module": "dist/js/avalynx-select.esm.js",

src/js/avalynx-select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* AvalynxSelect is a lightweight, customizable select dropdown component for web applications. It is designed to be used with Bootstrap version 5.3 or higher and does not require any framework dependencies.
55
*
6-
* @version 0.0.1
6+
* @version 0.0.2
77
* @license MIT
88
* @author https://github.com/avalynx/avalynx-select/graphs/contributors
99
* @website https://github.com/avalynx/

0 commit comments

Comments
 (0)