import { DataSourceEvent } from './ArchbaseDataSource'; /** * Hook obrigatório para compatibilidade V1/V2 * * TODOS os componentes migrados DEVEM usar este hook. */ export declare function useArchbaseV1V2Compatibility(componentName: string, dataSource: any, dataField?: string, initialValue?: T): { isDataSourceV2: boolean; dataSourceVersion: string; currentValue: T; v1State: { currentValue: T; setCurrentValue: import('react').Dispatch>; forceUpdate: () => void; }; v2State: { v2Value: T; setV2Value: import('react').Dispatch>; v2ShouldUpdate: number; }; loadDataSourceFieldValue: () => void; dataSourceEvent: (event: DataSourceEvent) => void; handleValueChange: (newValue: T, event?: any) => void; isReadOnly: any; isEditing: any; trackUsage: () => void; }; /** * Padrão para props de componentes compatíveis V1/V2 */ export interface ArchbaseV1V2CompatibleProps { dataSource?: any; dataField?: string; value?: T; defaultValue?: T; disabled?: boolean; readOnly?: boolean; required?: boolean; style?: React.CSSProperties; width?: string | number; height?: string | number; onChangeValue?: (value: T, event: any) => void; onFocusEnter?: React.FocusEventHandler; onFocusExit?: React.FocusEventHandler; innerRef?: React.RefObject; } /** * Utilitários para validação de migração */ export declare const MigrationValidation: { /** * Valida se o componente está seguindo o padrão corretamente */ validatePattern: (componentName: string, hooks: ReturnType) => boolean; /** * Testa se o comportamento V1 está preservado */ testV1Compatibility: (componentName: string, dataSource: any) => boolean; }; /** * Exemplo de uso do padrão (para documentação) */ export declare const USAGE_EXAMPLE = "\n// Em qualquer componente que use DataSource:\n\nimport { useArchbaseV1V2Compatibility } from '../core/patterns/ArchbaseV1V2CompatibilityPattern';\n\nexport function MyComponent({ dataSource, dataField, value, onChangeValue, ...props }) {\n // 1. USAR HOOK DE COMPATIBILIDADE (OBRIGAT\u00D3RIO)\n const {\n isDataSourceV2,\n currentValue,\n handleValueChange,\n dataSourceEvent,\n loadDataSourceFieldValue,\n isReadOnly\n } = useArchbaseV1V2Compatibility(\n 'MyComponent',\n dataSource,\n dataField,\n value\n );\n\n // 2. SETUP DOS LISTENERS (OBRIGAT\u00D3RIO)\n useArchbaseDataSourceListener({\n dataSource,\n listener: dataSourceEvent\n });\n\n // 3. CARREGAMENTO INICIAL (OBRIGAT\u00D3RIO)\n useEffect(() => {\n loadDataSourceFieldValue();\n }, [loadDataSourceFieldValue]);\n\n // 4. HANDLER DE MUDAN\u00C7A (OBRIGAT\u00D3RIO)\n const handleChange = useCallback((newValue: T, event: any) => {\n handleValueChange(newValue, event);\n \n // Callback externo preservado\n if (onChangeValue) {\n onChangeValue(newValue, event);\n }\n }, [handleValueChange, onChangeValue]);\n\n // 5. RENDERIZA\u00C7\u00C3O CONDICIONAL (OBRIGAT\u00D3RIO)\n return (\n \n );\n}\n"; export default useArchbaseV1V2Compatibility;