import { Key } from "react"; import { SetOptionalFn } from "../types/Fn"; import { Hoc } from "../types/Hoc"; interface Options { /** * @default "i" * * @example * // ↓ "someName" here as well * const Component = withForEach(3, {indexName: "someName"})(Example) * * // is equivalent to * <> * // ↓ "someName" here as well * * * * */ indexName?: IndexName; /** * @default "children" * * @example * const Component = withForEach( * ["a", "b"], * // ↓ "someName" here as well * {valueName: "someName"} * )(Example) * * // is equivalent to * <> * // ↓ "someName" here as well * * * */ valueName?: ValueName; /** * @default (props) => props[indexName] // which is props.i * * @example * // makes key = 2^x * const Component = withForEach(4, {key: ({i}) => 2 ** i})(Example) * * // is equivalent to * <> * // ↓ note key values * * * * * */ key?: (props: object) => Key; } interface WithForEachHoc { (target: number | Array | object, options?: Options): Hoc<[ SetOptionalFn<([IndexName & ""] extends [never] ? IndexName : "i") | ([ValueName & ""] extends [never] ? ValueName : "children")> ]>; } /** * Like Array.map but for React components. * Concatenates components for each item in array, range or object * * @experimental It needs to discuss its name * * @example * const Component = withForEach(3)(Example) * * // is equivalent to * <> * * * * * * @example * const Component = withForEach(["a", "b"])(Example) * * // is equivalent to * <> * a * b * * * @example * const Component = withForEach({ * a: 100, * b: 200, * })(Example) * * // is equivalent to * <> * 100 * 200 * */ export declare const withForEach: WithForEachHoc; export {}; //# sourceMappingURL=withForEach.d.ts.map