-
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 fixes #116 * docs(list): add custom schema example * docs: update readme, focus on fields * docs(storybook): update intro * bump --------- Co-authored-by: semantic-release-bot <[email protected]>
- Loading branch information
1 parent
4a7e626
commit 8bc738f
Showing
47 changed files
with
495 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 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.