Skip to content

Commit

Permalink
chore: cleanup list field
Browse files Browse the repository at this point in the history
  • Loading branch information
MiroslavPetrik committed Dec 2, 2023
1 parent 3cc6f7a commit ae57ab5
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/components/list-field/ListField.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
import { FieldAtom, FormAtom, FormFieldValues, FormFields } from "form-atoms";
import { FieldAtom, FormAtom, FormFields } from "form-atoms";
import { PrimitiveAtom } from "jotai";
import React, { Fragment, useCallback } from "react";
import { Fragment, useCallback } from "react";
import { RenderProp } from "react-render-prop-type";

import { useListFieldActions } from "./useListFieldActions";

export function listFieldAtoms<TValue, TFieldAtom extends FieldAtom<TValue>>(
builder: (value: TValue) => TFieldAtom,
values: TValue[],
): TFieldAtom[];
export function listFieldAtoms<Fields extends FormFields>(
builder: (values: FormFieldValues<Fields>) => Fields,
values: FormFieldValues<Fields>[],
): Fields[];
// actual type must be one of overloads, as this one is ignored
export function listFieldAtoms<Fields extends FormFields>(
builder: (values: FormFieldValues<Fields>) => Fields,
values: FormFieldValues<Fields>[],
): Fields[] {
return values.map(builder);
}

export type RemoveItemButtonProps = { remove: () => void };
export type RemoveItemButtonProp = RenderProp<
RemoveItemButtonProps,
Expand Down

0 comments on commit ae57ab5

Please sign in to comment.