import type { ActionsRecordProp, } from './types/ActionsRecordProp'; import type { CTAState, } from './types/CTAState'; import type { UseCTAParameter, } from './types/UseCTAParameter'; import type { UseCTAParameterActionsOptionalDefaultRecord, } from './types/UseCTAParameterActionsOptionalDefaultRecord'; import type { UseCTAParameterActionsRecordProp, } from './types/UseCTAParameterActionsRecordProp'; // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Used in the JSDoc comment. import type { UseCTAParameterCompare, } from './types/UseCTAParameterCompare'; // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Used in the JSDoc comment. import type { UseCTAParameterOnInit, } from './types/UseCTAParameterOnInit'; // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Used in the JSDoc comment. import type { UseCTAParameterAfterActionChange, } from './types/UseCTAParameterAfterActionChange'; /** * A `function` that returns a type safe {@link UseCTAParameter} `object`. * * Useful if you want to create the parameter outside {@link useCTA}, {@link createCTA}, or {@link createCTAContext} for type safety. * * @template {CTAState} Initial - The initial state type. * @template {UseCTAParameterActionsRecordProp} Actions - The actions type. * * @param {UseCTAParameter} props - {@link UseCTAParameter} parameter. * * @param {CTAState} props.initial - initial {@link CTAState} structure for {@link CTAHistory}. * - See {@link https://rafde.github.io/react-hook-use-cta/#use-cta-parameter-initial useCTA Parameter: initial}. * * @param {UseCTAParameterOnInit} [props.onInit] - Optional {@link UseCTAParameterOnInit} * - `function` that runs once on component mount to handle `initial` parameter state before your component starts using it. * - See {@link https://rafde.github.io/react-hook-use-cta/#use-cta-parameter-on-init useCTA Parameter: onInit} * * @param {UseCTAParameterCompare} [props.compare] - Optional {@link UseCTAParameterCompare} * - `function` for custom equality logic by comparing only specific properties. * - See {@link https://rafde.github.io/react-hook-use-cta/#use-cta-parameter-compare useCTA Parameter: compare} * * @param {UseCTAParameterAfterActionChange} [props.afterActionChange] - Optional {@link UseCTAParameterAfterActionChange} * - `function` than only runs after an action has changed the hook state history. * - See {@link https://rafde.github.io/react-hook-use-cta/#use-cta-parameter-after-action-change useCTA Parameter: afterActionChange} * * @param {UseCTAParameterActionsRecordProp} [props.actions] - Optional {@link UseCTAParameterActionsRecordProp} * - `object` type to define custom and/or overridden actions for state management. * - See {@link https://rafde.github.io/react-hook-use-cta/#use-cta-parameter-actions useCTA Parameter: actions} * * @returns {UseCTAParameter} Type safe {@link UseCTAParameter} `object`. */ export function returnCTAParameter< Initial extends CTAState, Actions extends UseCTAParameterActionsRecordProp | undefined, ActionsRecord = Actions extends undefined ? UseCTAParameterActionsOptionalDefaultRecord : Actions extends UseCTAParameterActionsRecordProp ? ActionsRecordProp : never, >( props: UseCTAParameter, ): UseCTAParameter { return props; }