import { InformationCircleSolid } from "@medusajs/icons" import { HookData, HookDataMap, EnumType, FunctionType, ObjectType, } from "@/types/ui" import { InlineCode, Table, Tooltip } from "docs-ui" interface HookTableProps { props: HookDataMap isReturn?: boolean } const HookTable = ({ props, isReturn = false }: HookTableProps) => { return ( Name Type {isReturn ? "Description" : "Default"} {/* eslint-disable-next-line react/prop-types */} {props.map((propData, index) => ( ))}
) } interface RowProps extends HookData { isReturn?: boolean } const Row = ({ value, type, description, default: defaultValue, isReturn = false, }: RowProps) => { const isEnum = (t: unknown): t is EnumType => { return (t as EnumType).type !== undefined && (t as EnumType).type === "enum" } const isObject = (t: unknown): t is ObjectType => { return ( (t as ObjectType).type !== undefined && (t as ObjectType).type === "object" ) } const isFunction = (t: unknown): t is FunctionType => { return ( (t as FunctionType).type !== undefined && (t as FunctionType).type === "function" ) } const isComplexType = isEnum(type) || isObject(type) || isFunction(type) return (
{value} {!isReturn && description && ( )}
{!isComplexType && type.toString()} {isEnum(type) && ( `"${v}"`).join(" | ")} className="font-mono" >
enum
)} {isObject(type) && ( {type.shape}} className="font-mono max-w-[500px]" tooltipClassName="!text-left" >
{type.name}
)} {isFunction(type) && ( {type.signature}} className="font-mono max-w-[500px]" >
function
)}
{isReturn ? ( description ? ( {description} ) : ( - ) ) : defaultValue !== undefined && defaultValue !== null ? ( {defaultValue.toString()} ) : ( - )}
) } export { HookTable }