in src/select/select.tsx [253:335]
function getListItems<T = unknown>(
props: SelectProps<T>,
state: Partial<SelectState<T>>,
rawFilterString: string,
data = props.data,
) {
let filterString = rawFilterString.trim();
if (
isInputMode(props.type) &&
!props.allowAny &&
state.selected &&
!Array.isArray(state.selected) &&
filterString === state.selected.label
) {
filterString = ''; // ignore multiple if it is exactly the selected item
}
const lowerCaseString = filterString.toLowerCase();
const filteredData = [];
let exactMatch = false;
const check = getFilterFn(props.filter);
for (let i = 0; i < data.length; i++) {
const item = {...data[i]};
if (check(item, lowerCaseString, data)) {
exactMatch = item.label === filterString;
if (props.multiple && !(typeof props.multiple === 'object' && props.multiple.removeSelectedItems)) {
item.checkbox = !!state.multipleMap?.[item.key];
}
if (
props.multiple &&
typeof props.multiple === 'object' &&
props.multiple.limit &&
Array.isArray(state.selected)
) {
item.disabled =
props.multiple.limit === state.selected.length &&
!state.selected.find(selectedItem => selectedItem.key === item.key);
}
// Ignore item if it's multiple and is already selected
if (
!(
props.multiple &&
typeof props.multiple === 'object' &&
props.multiple.removeSelectedItems &&
state.multipleMap?.[item.key]
)
) {
filteredData.push(item);
}
}
}
let addButton = null;
const {add} = props;
if ((add && filterString && !exactMatch) || (add && add.alwaysVisible)) {
if (
(!(add.regexp && !add.regexp.test(filterString)) && !(add.minlength && filterString.length < +add.minlength)) ||
add.alwaysVisible
) {
let label;
if (add.label) {
label = typeof add.label === 'function' ? add.label(filterString) : add.label;
} else {
label = filterString;
}
addButton = {
prefix: add.prefix,
label,
delayed: add.delayed ?? true,
};
}
}
return {filteredData, addButton};
}