UNPKG

@ackplus/react-tanstack-data-table

Version:

A powerful React data table component built with MUI and TanStack Table

53 lines 2.83 kB
/** * Enhanced Slot Helper Utilities * * Utilities to help with rendering slotted components with enhanced prop merging, * type safety, and full customization support. */ import { ComponentType } from 'react'; import { DataTableSlots } from '../types/slots.types'; /** * Enhanced slot component retrieval with better type safety */ export declare function getSlotComponent<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotName: K, fallback: ComponentType<any>): ComponentType<any>; /** * Merge slot props with default props and user overrides * Handles special cases for MUI sx prop, style prop, and className */ export declare function mergeSlotProps(defaultProps?: Record<string, any>, slotProps?: Record<string, any>, userProps?: Record<string, any>): Record<string, any>; /** * Enhanced slot component retrieval with automatic prop merging */ export declare function getSlotComponentWithProps<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotProps: Record<string, any>, slotName: K, fallback: ComponentType<any>, defaultProps?: Record<string, any>): { component: ComponentType<any>; props: Record<string, any>; }; /** * Utility to check if a slot is overridden by user */ export declare function isSlotOverridden<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotName: K): boolean; /** * Utility to get all overridden slots */ export declare function getOverriddenSlots<T>(slots: Partial<DataTableSlots<T>> | undefined): Array<keyof DataTableSlots<T>>; /** * Type-safe slot prop extractor */ export declare function extractSlotProps<T, K extends keyof DataTableSlots<T>>(slotProps: Record<string, any> | undefined, slotName: K): Record<string, any>; /** * Enhanced slot component with better prop handling */ export declare function createEnhancedSlotComponent<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotName: K, fallback: ComponentType<any>, baseProps?: Record<string, any>): ComponentType<any>; /** * Utility to validate slot props at runtime (development only) */ export declare function validateSlotProps<T, K extends keyof DataTableSlots<T>>(slotName: K, props: any, requiredProps?: string[]): boolean; /** * Helper to create slot props with proper typing */ export declare function createSlotProps<T>(table: any, additionalProps?: Record<string, any>): Record<string, any>; /** * Enhanced slot component wrapper that handles all prop merging automatically */ export declare function withSlotProps<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotProps: Record<string, any>, slotName: K, fallback: ComponentType<any>): (props: any) => any; //# sourceMappingURL=slot-helpers.d.ts.map