/* eslint-disable @typescript-eslint/ban-types */ import React, { useRef } from 'react' import { classnames, flatten } from '@fexd/tools' import { ErrorBoundary, createSharedHook, createSharedContext, SharedHook, UseSharedHook, Merge } from '@fexd/pro-utils' import useProps, { defaultProps, propsContext, ProTablePropsContext } from '../useProps' import { ProTableProps } from '../types' export { default as useProps } from '../useProps' const sharedContext = createSharedContext() export interface TablePlugin
extends UseSharedHook >(plugin: P) {
// @ts-ignore
return new ChainableTablePlugins (
usePluginHook: SharedHook {
const useHook = () => {
const props = useProps ()
return usePluginHook(props)
}
Object.defineProperty(useHook, 'name', {
value: name ?? usePluginHook.name,
})
const useSharedHook = createSharedHook(useHook, {
context: sharedContext,
})
Object.defineProperty(useSharedHook, 'name', {
value: name ?? usePluginHook.name,
})
return Object.assign(useSharedHook, {
props: {},
}) as TablePlugin
}
interface TableWrapperProps extends ProTableProps {
plugins?: any[]
}
export const TableWrapper = ({ plugins = [], children, ...props }: TableWrapperProps) => {
const wrapperDomRef = useRef