import {Table} from "../../Table"; import {iTableNode} from "../../Table/table/utils/table.utils"; import {tPlc, tPlcType} from "../../Table/plc/utils/plc.utils"; import {PlainObject} from "@peryl/utils/event"; import '../utils/TableOption.space'; import {PlcIndex} from "../../Table/standard/PlcIndex"; import {AutoModule} from "../utils/AutoModule"; import {Fragment, iMouseEvent} from "@peryl/react-compose"; declare module '../utils/TableOption.space' { namespace TableOptionSpace { interface iTableOption { table: ReturnType; } } } export const useTableOptionTable = AutoModule.createRegistration(( { state, config, hooks, cache, fill, render, pagination, } ) => { const onRefTable = (refer: any) => { hooks.onRefBaseTable.exec(refer); state.getTable = () => refer; }; const handler = { onClickRow: (node: iTableNode, e: iMouseEvent) => {hooks.onClickRow.exec({ node, e });}, onDblclickRow: (node: iTableNode, e: iMouseEvent) => {hooks.onDblclickRow.exec({ node, e });}, onClickCell: (node: iTableNode, e: iMouseEvent, plc: tPlc) => {hooks.onClickCell.exec({ node, e, plc });}, onDblclickCell: (node: iTableNode, e: iMouseEvent, plc: tPlc) => {hooks.onDblclickCell.exec({ node, e, plc });}, onContextmenuCell: (node: iTableNode, e: iMouseEvent, plc: tPlc) => {hooks.onContextmenuCell.exec({ node, e, plc });}, onClickHead: (plc: tPlcType, e: iMouseEvent) => {hooks.onClickHead.exec({ plc, e });}, onCurrentChange: (data: PlainObject | null) => {hooks.onCurrentChange.exec(data);}, onCollectPlcData: hooks.onCollectPlcData.exec, onSetup: hooks.onBaseTableSetup.exec, }; hooks.onRenderColumns.use({ processor: ({ list, render }) => {list.push({ key: 'index', seq: 0, render });}, render: () => <> {config.indexing != false && } {render.default()} }); hooks.onTableRender.use({ processor: ({ list, render }) => {config.title && list.push({ key: 'table_title', seq: 3, render });}, render: () => (
{config.title}
) }); hooks.onTableRender.use({ processor: ({ list, render }) => {list.push({ key: 'table', seq: 5, render });}, render: () => { return ( hooks.onRenderColumns.exec(), }} /> ); }, }); return {}; });