mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-22 04:09:22 +00:00
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
![]() |
/**
|
||
|
* React hooks for tool parameter management (URL logic removed)
|
||
|
*/
|
||
|
|
||
|
import { useCallback, useMemo } from 'react';
|
||
|
|
||
|
type ToolParameterValues = Record<string, any>;
|
||
|
|
||
|
/**
|
||
|
* Register tool parameters and get current values
|
||
|
*/
|
||
|
export function useToolParameters(
|
||
|
toolName: string,
|
||
|
parameters: Record<string, any>
|
||
|
): [ToolParameterValues, (updates: Partial<ToolParameterValues>) => void] {
|
||
|
|
||
|
// Return empty values and noop updater
|
||
|
const currentValues = useMemo(() => ({}), []);
|
||
|
const updateParameters = useCallback(() => {}, []);
|
||
|
|
||
|
return [currentValues, updateParameters];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Hook for managing a single tool parameter
|
||
|
*/
|
||
|
export function useToolParameter<T = any>(
|
||
|
toolName: string,
|
||
|
paramName: string,
|
||
|
definition: any
|
||
|
): [T, (value: T) => void] {
|
||
|
const [allParams, updateParams] = useToolParameters(toolName, { [paramName]: definition });
|
||
|
|
||
|
const value = allParams[paramName] as T;
|
||
|
|
||
|
const setValue = useCallback((newValue: T) => {
|
||
|
updateParams({ [paramName]: newValue });
|
||
|
}, [paramName, updateParams]);
|
||
|
|
||
|
return [value, setValue];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Hook for getting/setting global parameters (zoom, page, etc.)
|
||
|
*/
|
||
|
export function useGlobalParameters() {
|
||
|
const currentValues = useMemo(() => ({}), []);
|
||
|
const updateParameters = useCallback(() => {}, []);
|
||
|
|
||
|
return [currentValues, updateParameters];
|
||
|
}
|