mirror of
https://github.com/github/awesome-copilot.git
synced 2026-03-23 09:35:13 +00:00
chore: rename website-astro to website, update gitignore
- Rename website-astro/ to website/ - Add website/dist/ and website/.astro/ to gitignore - Update generate-website-data.mjs output path
This commit is contained in:
34
website/src/scripts/choices.ts
Normal file
34
website/src/scripts/choices.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Choices.js wrapper with sensible defaults
|
||||
*/
|
||||
import Choices from 'choices.js';
|
||||
import 'choices.js/public/assets/styles/choices.min.css';
|
||||
|
||||
export type { Choices };
|
||||
|
||||
/**
|
||||
* Get selected values from a Choices instance
|
||||
*/
|
||||
export function getChoicesValues(choices: Choices): string[] {
|
||||
const val = choices.getValue(true);
|
||||
return Array.isArray(val) ? val : (val ? [val] : []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Choices instance with sensible defaults
|
||||
*/
|
||||
export function createChoices(selector: string | HTMLSelectElement, options: Partial<Choices['config']> = {}): Choices {
|
||||
return new Choices(selector, {
|
||||
removeItemButton: true,
|
||||
searchPlaceholderValue: 'Search...',
|
||||
noResultsText: 'No results found',
|
||||
noChoicesText: 'No options available',
|
||||
itemSelectText: '',
|
||||
shouldSort: false,
|
||||
searchResultLimit: 100,
|
||||
resetScrollPosition: false,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
export { Choices };
|
||||
Reference in New Issue
Block a user