+ {/* Search Input */}
+ {searchable && (
+
+
+ {
+ setSearch(e.target.value);
+ setHighlightIndex(-1);
+ }}
+ placeholder={placeholder}
+ className="flex-1 h-7 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
+ aria-label="Search options"
+ />
+ {search && (
+
+ )}
+
+ )}
+
+ {/* Options List */}
+
+ {total === 0 ? (
+
+ {search ? 'No matching options' : 'No options available'}
+
+ ) : (
+ (() => {
+ let globalIdx = 0;
+ const sortedGroups = Object.keys(grouped).sort((a, b) => {
+ if (a === '') return -1;
+ if (b === '') return 1;
+ return a.localeCompare(b);
+ });
+
+ return sortedGroups.map((group) => (
+
+ {group && (
+
+ {group}
+
+ )}
+ {grouped[group].map((opt) => {
+ const idx = globalIdx++;
+ const isSelected = opt.value === value;
+ const isHighlighted = idx === highlightIndex;
+
+ return (
+
handleSelect(opt)}
+ className={cn(
+ optionItemVariants({ isSelected, isDisabled: !!opt.disabled }),
+ isHighlighted && !isSelected && 'bg-accent/50',
+ 'pl-3',
+ )}
+ >
+
+ {/* Icon */}
+ {opt.icon && (
+
{opt.icon}
+ )}
+ {/* Content */}
+
+
+ {highlightMatch(opt.label, search)}
+
+ {opt.description && (
+
+ {highlightMatch(opt.description, search)}
+
+ )}
+
+ {/* Check mark */}
+ {isSelected && (
+
+ )}
+
+
+ );
+ })}
+
+ ));
+ })()
+ )}
+
+