UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

31 lines (26 loc) 1.98 kB
/*! * KoliBri - The accessible HTML-Standard */ 'use strict'; var index = require('./index-BrhW8s5h.js'); var clsx = require('./clsx-Bm_HQUnh.js'); const CustomSuggestionsOptionFc = ({ disabled, index: index$1, ref, selected, onClick, onMouseOver, onFocus, onKeyDown, option, searchTerm, }) => { const highlightSearchTerm = (text, searchTerm) => { if (!(searchTerm === null || searchTerm === void 0 ? void 0 : searchTerm.trim())) return text; const regex = new RegExp(`(${searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi'); const parts = text.split(regex); return parts.map((part, partIndex) => (partIndex % 2 === 1 ? index.h("mark", null, part) : part)); }; return (index.h("li", { id: `option-${index$1}`, key: `-${index$1}`, ref: ref, "data-index": index$1, tabIndex: -1, role: "option", "aria-selected": selected ? 'true' : undefined, "aria-disabled": disabled ? 'true' : undefined, onClick: onClick, onMouseOver: onMouseOver, onFocus: onFocus, class: clsx.clsx('kol-custom-suggestions-option', { 'kol-custom-suggestions-option--disabled': disabled }), onKeyDown: onKeyDown }, index.h("span", null, highlightSearchTerm(String(option), searchTerm || '')))); }; const CustomSuggestionsOptionsGroupFc = ({ blockSuggestionMouseOver, onKeyDown, style, hidden, id }, children) => { return (index.h("ul", { id: id, role: "listbox", style: style, class: clsx.clsx('kol-custom-suggestions-options-group', { 'kol-custom-suggestions-options-group--cursor-hidden': blockSuggestionMouseOver, 'kol-custom-suggestions-options-group--open': !hidden, }), hidden: hidden, onKeyDown: onKeyDown }, children)); }; exports.CustomSuggestionsOptionFc = CustomSuggestionsOptionFc; exports.CustomSuggestionsOptionsGroupFc = CustomSuggestionsOptionsGroupFc; //# sourceMappingURL=CustomSuggestionsOptionsGroup-CStgu1WD.js.map //# sourceMappingURL=CustomSuggestionsOptionsGroup-CStgu1WD.js.map