import {TreeScopeSlotsOption} from "../TreeCore/TreeCore.type"; import {ExtractPropTypes, getComponentCls} from "@peryl/react-compose"; import {Input} from "../Input"; import {delay} from "@peryl/utils/delay"; import {Tree} from "../Tree"; import {unit} from "@peryl/utils/unit"; import {CascadePanel} from "../CascadePanel"; import {CascadePropsOptions} from "./cascade.utils"; import {Table} from "../Table"; import {PlcTree} from "../Table/standard/PlcTree/PlcTree"; import {tStyleComputed} from "../../uses/useStyle"; import {getTableRowHeight} from "../Table/table/utils/table.utils"; import {PlcIndex} from "../Table/standard/PlcIndex"; import {createPopupEditor} from "../usePopupEditor"; import {tEditControl} from "../../uses/useEdit"; export function createCascadePopper( { getPublicPopperAttrs, onPopperClose, onPopperShow, editControl, refs, scopeSlots, getTreeAttrs, getCascadeAttrs, getPlcTreeAttrs, panelHeight, props, styleComputed, }: { getPublicPopperAttrs: () => any, onPopperClose: () => void, onPopperShow?: () => void, editControl: tEditControl refs: { input: typeof Input.use.class | null | undefined }, scopeSlots: any, getTreeAttrs: () => any, getCascadeAttrs: () => any, getPlcTreeAttrs: () => any, panelHeight: { value: number | undefined }, props: ExtractPropTypes, styleComputed: tStyleComputed, } ) { const onMousedownPanel = () => {delay().then(() => {refs.input?.focus();});}; const panels = { tree: (param: { passScopeSlots: any }) => ( ), cascade: (param: { passScopeSlots: any }) => ( ), table: (param: { passScopeSlots: any }) => { const plcTreeAttrs = getPlcTreeAttrs(); // console.log('plcTreeAttrs.filterText', plcTreeAttrs.filterText); const { bodyRowHeight, headRowHeight } = getTableRowHeight(styleComputed.value.size); const showRows = 5; return (
{param.passScopeSlots.tree?.(plcTreeAttrs) || } {param.passScopeSlots.default()}
); } } as const; const popper = createPopupEditor({ option: { popperAttrs: () => { const publicPopperAttrs = getPublicPopperAttrs(); return ({ ...publicPopperAttrs, sizeEqual: props.panel === 'cascade' || props.panel === 'table' ? false : publicPopperAttrs.sizeEqual, ...props.panel === 'table' ? { height: null, noScroll: true, } : { scrollAttrs: { scrollX: true, fitHostWidth: true, ...publicPopperAttrs.scrollAttrs, }, }, onClose: () => { publicPopperAttrs.onClose?.(); onPopperClose(); }, onShow: () => { publicPopperAttrs.onShow?.(); onPopperShow?.(); }, }); }, reference: () => !editControl.editComputed.value.editable ? null : refs.input?.refs.el, popper: () => { /*传递作用域插槽*/ const passScopeSlots = Object.keys(TreeScopeSlotsOption).reduce((prev, key) => { const scopeSlotFunc = (scopeSlots as any)[key]; if (!!scopeSlotFunc && scopeSlotFunc.isExist()) { prev[key] = (...args: any[]) => scopeSlotFunc(...args); } return prev; }, {} as any); return ( /*虚拟滚动的情况下限制高度,使用Tree自带的滚动容器*/
{panels[props.panel]({ passScopeSlots })}
); } } }); return { popper }; }