import { useMemo } from "react";
import { isNumber, isString } from "@pisell/utils";
//#region src/components/dataSourceComponents/hooks/useValueMap.ts
/**
* 将 options 转换为 valueMap
* 使用在 ReadPretty Select Radio Checkbox 组件中
* @param options 
* @returns 
*/
const useValueMap = (options) => {
	return useMemo(() => {
		return (options === null || options === void 0 ? void 0 : options.reduce((acc, item) => {
			const itemValue = item.value;
			const itemLabel = item.label;
			if ((isString(itemValue) || isNumber(itemValue)) && isString(itemLabel)) acc[itemValue] = itemLabel;
			return acc;
		}, {})) || {};
	}, [options]);
};
//#endregion
export { useValueMap as default };
