mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-26 17:31:02 +02:00
eb22895f00
* Add option labelId to improve a11y * Console.log entfernt * Add test case for aria-labeledby Co-authored-by: Josua Vogel <josua.vogel@t-systems.com>
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import { ClassNames } from './interfaces/class-names';
|
|
import { Options } from './interfaces/options';
|
|
import { sortByAlpha, sanitise } from './lib/utils';
|
|
|
|
export const DEFAULT_CLASSNAMES: ClassNames = {
|
|
containerOuter: 'choices',
|
|
containerInner: 'choices__inner',
|
|
input: 'choices__input',
|
|
inputCloned: 'choices__input--cloned',
|
|
list: 'choices__list',
|
|
listItems: 'choices__list--multiple',
|
|
listSingle: 'choices__list--single',
|
|
listDropdown: 'choices__list--dropdown',
|
|
item: 'choices__item',
|
|
itemSelectable: 'choices__item--selectable',
|
|
itemDisabled: 'choices__item--disabled',
|
|
itemChoice: 'choices__item--choice',
|
|
placeholder: 'choices__placeholder',
|
|
group: 'choices__group',
|
|
groupHeading: 'choices__heading',
|
|
button: 'choices__button',
|
|
activeState: 'is-active',
|
|
focusState: 'is-focused',
|
|
openState: 'is-open',
|
|
disabledState: 'is-disabled',
|
|
highlightedState: 'is-highlighted',
|
|
selectedState: 'is-selected',
|
|
flippedState: 'is-flipped',
|
|
loadingState: 'is-loading',
|
|
noResults: 'has-no-results',
|
|
noChoices: 'has-no-choices',
|
|
};
|
|
|
|
export const DEFAULT_CONFIG: Options = {
|
|
items: [],
|
|
choices: [],
|
|
silent: false,
|
|
renderChoiceLimit: -1,
|
|
maxItemCount: -1,
|
|
addItems: true,
|
|
addItemFilter: null,
|
|
removeItems: true,
|
|
removeItemButton: false,
|
|
editItems: false,
|
|
allowHTML: true,
|
|
duplicateItemsAllowed: true,
|
|
delimiter: ',',
|
|
paste: true,
|
|
searchEnabled: true,
|
|
searchChoices: true,
|
|
searchFloor: 1,
|
|
searchResultLimit: 4,
|
|
searchFields: ['label', 'value'],
|
|
position: 'auto',
|
|
resetScrollPosition: true,
|
|
shouldSort: true,
|
|
shouldSortItems: false,
|
|
sorter: sortByAlpha,
|
|
placeholder: true,
|
|
placeholderValue: null,
|
|
searchPlaceholderValue: null,
|
|
prependValue: null,
|
|
appendValue: null,
|
|
renderSelectedChoices: 'auto',
|
|
loadingText: 'Loading...',
|
|
noResultsText: 'No results found',
|
|
noChoicesText: 'No choices to choose from',
|
|
itemSelectText: 'Press to select',
|
|
uniqueItemText: 'Only unique values can be added',
|
|
customAddItemText: 'Only values matching specific conditions can be added',
|
|
addItemText: (value) => `Press Enter to add <b>"${sanitise(value)}"</b>`,
|
|
maxItemText: (maxItemCount) => `Only ${maxItemCount} values can be added`,
|
|
valueComparer: (value1, value2) => value1 === value2,
|
|
fuseOptions: {
|
|
includeScore: true,
|
|
},
|
|
labelId: '',
|
|
callbackOnInit: null,
|
|
callbackOnCreateTemplates: null,
|
|
classNames: DEFAULT_CLASSNAMES,
|
|
};
|