import {designComponent, getComponentCls, iHTMLDivElement, PropType, RenderNode} from "@peryl/react-compose"; import {renderDropdownPanel} from "../Dropdown/dropdown.utils"; import {iSelectOptionProps, SelectPanelOptionPropOptions} from "./select.utils"; import {Loading} from "../Loading"; import Empty from "../Empty"; import {ApplicationConfigurationProvider} from "../Application/utils/application.utils"; import i18n from "../i18n"; import {useSearchText} from "../SelectGroup"; export const SelectPanel = designComponent({ name: 'select-panel', props: { ...SelectPanelOptionPropOptions, current: { type: Number }, // 当前高亮的选项的索引 isActivated: { type: Function as PropType<(props: iSelectOptionProps) => boolean> }, // 判断选项是否已经选中 matchLength: { type: Number, required: true }, // 没有匹配搜索关键字时显示的文本 dataLength: { type: Number, required: true }, // 没有选项时显示的文本 loading: { type: Boolean }, // 是否处于加载状态 }, inheritPropsType: iHTMLDivElement, emits: { onSelect: (selectOptionProps: any, e: MouseEvent) => true, onEnterOption: (selectOptionProps: any, e: MouseEvent) => true, }, provideRefer: true, slots: ['default', 'noMatch', 'noData', 'loadingContent'], setup({ props, slots, event: { emit } }) { const applicationConfiguration = ApplicationConfigurationProvider.inject(); useSearchText.provide(() => props.searchText); const handler = { onClickOption: (selectOptionProps: any, e: MouseEvent,) => {emit.onSelect(selectOptionProps, e);}, onEnterOption: emit.onEnterOption, }; return { refer: { handler, props, }, render: () => { let content: RenderNode; if (props.loading) { content = slots.loadingContent(