-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(listField): Refactor list field (#117)
BREAKING CHANGE: listAtom extracted to `@form-atoms/list-atom` which is now a required peer Dependency for `listField()` BREAKING CHANGE: The `builder` config property from `listField` was renamed to `fields`. BREAKING CHANGE: The `builder` config property no longer accepts `FieldAtom` as return type. `FormFields` must be returned.
- Loading branch information
1 parent
4a7e626
commit 13f5745
Showing
48 changed files
with
502 additions
and
3,538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Atom, Getter, PrimitiveAtom, atom } from "jotai"; | ||
|
||
export const extendAtom = < | ||
T extends PrimitiveAtom<any>, | ||
E extends Record<string, unknown>, | ||
>( | ||
baseAtom: T, | ||
makeAtoms: ( | ||
cfg: T extends Atom<infer Config> ? Config : never, | ||
get: Getter, | ||
) => E, | ||
) => { | ||
const extended = atom( | ||
(get) => { | ||
const base = get(baseAtom); | ||
return { | ||
...base, | ||
...makeAtoms( | ||
base as T extends Atom<infer Config> ? Config : never, | ||
get, | ||
), | ||
}; | ||
}, | ||
(get, set, update: T extends Atom<infer Config> ? Config : never) => { | ||
set(baseAtom, { ...get(baseAtom), ...update }); | ||
}, | ||
); | ||
|
||
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") { | ||
baseAtom.debugPrivate = true; | ||
extended.debugLabel = baseAtom.debugLabel; | ||
} | ||
|
||
return extended; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
export * from "./list-atom"; | ||
export * from "./upload-atom"; | ||
export * from "./_useFieldInitialValue"; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.