import { useEffect, useId, useMemo, useRef, useState } from 'react' import { createPortal } from 'react-dom' import { cn } from '../../lib/cn' import { sameValue, summaryOf, toOptions, type OptionLike, type SelectOption } from './options' import { contentWidth, usePopup } from './use-popup' import { filterBarCls, filterInputCls, itemCls, listCls, noneCls, popCls, tickCls, triggerCls } from './parts' import { Caret } from './Caret' /** * 全站统一下拉控件(替代原生 setQuery(e.target.value)} onKeyDown={onSearchKeydown} /> {view.length === opts.length ? `${opts.length} 项` : `${view.length} / ${opts.length} 项`} )}
{view.map((i) => { const o: SelectOption = opts[i] return (
setActive(i)} onClick={() => choose(i)}> ✓ {o.label}
) })} {!opts.length &&
无可选项
} {!!opts.length && !view.length &&
没有匹配的选项
}
, document.body)} ) } /** 常用出口:把字典/枚举直接转成 options */ export { toOptions, sameValue, summaryOf } export type { SelectOption }