Multi selection combos working

This commit is contained in:
Jorge Manrubia
2025-09-18 17:13:05 +02:00
parent 8d2a191a91
commit cb7d260545
4 changed files with 126 additions and 36 deletions
+24
View File
@@ -11,3 +11,27 @@ export function normalizeFilteredText(string) {
export function filterMatches(text, potentialMatch) {
return normalizeFilteredText(text).includes(normalizeFilteredText(potentialMatch))
}
export function toSentence(array, options = {}) {
const defaultConnectors = {
words_connector: ", ",
two_words_connector: " and ",
last_word_connector: ", and "
}
const connectors = { ...defaultConnectors, ...options }
if (array.length === 0) {
return ""
}
if (array.length === 1) {
return array[0]
}
if (array.length === 2) {
return array.join(connectors.two_words_connector)
}
return array.slice(0, -1).join(connectors.words_connector) + connectors.last_word_connector + array[array.length - 1]
}