import { useCallback, useState } from "react";
//#region src/components/PisellSuperTabs/hooks/useTabsState.ts
/**
* Tabs 状态管理 Hook
* @description 处理受控/非受控模式的状态管理
* @template T - 数据项类型
*/
const useTabsState = (params) => {
	const { value, defaultValue, onChange, isControlled } = params;
	const [innerValue, setInnerValue] = useState(defaultValue);
	return {
		activeKey: isControlled ? value : innerValue,
		handleTabChange: useCallback((key, item) => {
			if (!isControlled) setInnerValue(key);
			onChange === null || onChange === void 0 || onChange(key, item);
		}, [isControlled, onChange])
	};
};
//#endregion
export { useTabsState };
