@deckstar/react-final-form-arrays
Advanced tools
Comparing version 1.0.11 to 1.0.12
export { default as FieldArray } from "./FieldArray"; | ||
export type { FieldArrayMutators, FieldArrayProps, FieldArrayRenderProps, RenderableProps, UseFieldArrayConfig, } from "./types"; | ||
export type { FieldArrayMutators, FieldArrayProps, FieldArrayRenderProps, UseFieldArrayConfig, } from "./types"; | ||
export { default as useFieldArray } from "./useFieldArray"; |
import { AnyObject } from "final-form"; | ||
import * as React from "react"; | ||
import type { RenderableProps } from "./types"; | ||
import { RenderableProps } from "react-final-form"; | ||
type OptionalRefProp = { | ||
@@ -5,0 +5,0 @@ /** An optional `ref` for this node. */ |
import type { BoundMutators, FieldSubscription, FormValuesShape, FullFieldSubscription, Mutators } from "final-form"; | ||
import { BoundArrayMutators, DefaultBoundArrayMutators } from "final-form-arrays"; | ||
import { BoundArrayMutators, ConcatArguments, ConcatResult, DefaultBoundArrayMutators, InsertArguments, InsertResult, MoveArguments, MoveResult, PopArguments, PopResult, PushArguments, PushResult, RemoveArguments, RemoveBatchArguments, RemoveBatchResult, RemoveResult, ShiftArguments, ShiftResult, SwapArguments, SwapResult, UnshiftArguments, UnshiftResult, UpdateArguments, UpdateResult } from "final-form-arrays"; | ||
import { FieldInputPropsBasedOnSubscription, FieldMetaState, FieldProps, FieldRenderProps, RenderableProps, UseFieldConfig } from "react-final-form"; | ||
export type { RenderableProps }; | ||
/** Drops the first item from a tuple type. */ | ||
@@ -10,2 +9,23 @@ type DropFirst<T extends unknown[]> = T extends [any, ...infer U] ? U : never; | ||
/** | ||
* For our own mutators, we can narrow down the types to make | ||
* them more accurate, based on the `FieldValue`. | ||
* | ||
* Userland mutators, unfortunately, will lose their generics. | ||
*/ | ||
type FieldDefaultBoundArrayMutators<FormValues extends FormValuesShape = FormValuesShape, FieldValue extends any = any> = { | ||
insert: (...args: DropFirst<InsertArguments<FormValues, string, FieldValue>>) => InsertResult; | ||
concat: (...args: DropFirst<ConcatArguments<FormValues, string, FieldValue[]>>) => ConcatResult; | ||
move: (...args: DropFirst<MoveArguments>) => MoveResult; | ||
pop: (...args: DropFirst<PopArguments>) => PopResult<FormValues, string, FieldValue>; | ||
push: (...args: DropFirst<PushArguments<FormValues, string, FieldValue>>) => PushResult; | ||
remove: (...args: DropFirst<RemoveArguments>) => RemoveResult<FormValues, string, FieldValue>; | ||
removeBatch: (...args: DropFirst<RemoveBatchArguments>) => RemoveBatchResult<FormValues, string, FieldValue[]>; | ||
shift: (...args: DropFirst<ShiftArguments>) => ShiftResult<FormValues, string, FieldValue>; | ||
swap: (...args: DropFirst<SwapArguments>) => SwapResult; | ||
update: (...args: DropFirst<UpdateArguments<FormValues, string, FieldValue>>) => UpdateResult; | ||
unshift: (...args: DropFirst<UnshiftArguments<FormValues, string, FieldValue>>) => UnshiftResult; | ||
} & { | ||
[Func in keyof DefaultBoundArrayMutators<FormValues>]: unknown; | ||
}; | ||
/** | ||
* Mutators for an array item in the field render props. | ||
@@ -15,4 +35,4 @@ * | ||
*/ | ||
export type FieldArrayMutators<FormValues extends FormValuesShape = FormValuesShape, MutatorsAfterBinding extends BoundArrayMutators<Mutators<FormValues>, FormValues> = DefaultBoundArrayMutators<FormValues>> = { | ||
[Func in keyof MutatorsAfterBinding]: DropFirstArg<MutatorsAfterBinding[Func]>; | ||
export type FieldArrayMutators<FormValues extends FormValuesShape = FormValuesShape, MutatorsAfterBinding extends BoundArrayMutators<Mutators<FormValues>, FormValues> = DefaultBoundArrayMutators<FormValues>, FieldValue = any> = { | ||
[Func in keyof MutatorsAfterBinding]: Func extends keyof DefaultBoundArrayMutators ? MutatorsAfterBinding[Func] extends DefaultBoundArrayMutators<FormValues>[Func] ? FieldDefaultBoundArrayMutators<FormValues, FieldValue>[Func] : DropFirstArg<MutatorsAfterBinding[Func]> : DropFirstArg<MutatorsAfterBinding[Func]>; | ||
}; | ||
@@ -48,3 +68,3 @@ /** | ||
map: (iterator: (name: string, index: number) => any) => any[]; | ||
} & FieldArrayMutators<FormValues, MutatorsAfterBinding & DefaultBoundArrayMutators<FormValues>> & Pick<FieldInputPropsBasedOnSubscription<FieldValue[], Subscription>, "name" | "value"> & Required<Pick<FieldMetaState<FieldValue[], Subscription>, "length">>; | ||
} & FieldArrayMutators<FormValues, MutatorsAfterBinding & DefaultBoundArrayMutators<FormValues>, FieldValue> & Pick<FieldInputPropsBasedOnSubscription<FieldValue[], Subscription>, "name" | "value"> & Required<Pick<FieldMetaState<FieldValue[], Subscription>, "length">>; | ||
} & { | ||
@@ -70,1 +90,2 @@ [Key in keyof Pick<FieldRenderProps, "meta">]: Omit<FieldMetaState<FieldValue[], Subscription>, "length">; | ||
} | ||
export {}; |
export { default as FieldArray } from "./FieldArray"; | ||
export type { FieldArrayMutators, FieldArrayProps, FieldArrayRenderProps, RenderableProps, UseFieldArrayConfig, } from "./types"; | ||
export type { FieldArrayMutators, FieldArrayProps, FieldArrayRenderProps, UseFieldArrayConfig, } from "./types"; | ||
export { default as useFieldArray } from "./useFieldArray"; |
import { AnyObject } from "final-form"; | ||
import * as React from "react"; | ||
import type { RenderableProps } from "./types"; | ||
import { RenderableProps } from "react-final-form"; | ||
type OptionalRefProp = { | ||
@@ -5,0 +5,0 @@ /** An optional `ref` for this node. */ |
import type { BoundMutators, FieldSubscription, FormValuesShape, FullFieldSubscription, Mutators } from "final-form"; | ||
import { BoundArrayMutators, DefaultBoundArrayMutators } from "final-form-arrays"; | ||
import { BoundArrayMutators, ConcatArguments, ConcatResult, DefaultBoundArrayMutators, InsertArguments, InsertResult, MoveArguments, MoveResult, PopArguments, PopResult, PushArguments, PushResult, RemoveArguments, RemoveBatchArguments, RemoveBatchResult, RemoveResult, ShiftArguments, ShiftResult, SwapArguments, SwapResult, UnshiftArguments, UnshiftResult, UpdateArguments, UpdateResult } from "final-form-arrays"; | ||
import { FieldInputPropsBasedOnSubscription, FieldMetaState, FieldProps, FieldRenderProps, RenderableProps, UseFieldConfig } from "react-final-form"; | ||
export type { RenderableProps }; | ||
/** Drops the first item from a tuple type. */ | ||
@@ -10,2 +9,23 @@ type DropFirst<T extends unknown[]> = T extends [any, ...infer U] ? U : never; | ||
/** | ||
* For our own mutators, we can narrow down the types to make | ||
* them more accurate, based on the `FieldValue`. | ||
* | ||
* Userland mutators, unfortunately, will lose their generics. | ||
*/ | ||
type FieldDefaultBoundArrayMutators<FormValues extends FormValuesShape = FormValuesShape, FieldValue extends any = any> = { | ||
insert: (...args: DropFirst<InsertArguments<FormValues, string, FieldValue>>) => InsertResult; | ||
concat: (...args: DropFirst<ConcatArguments<FormValues, string, FieldValue[]>>) => ConcatResult; | ||
move: (...args: DropFirst<MoveArguments>) => MoveResult; | ||
pop: (...args: DropFirst<PopArguments>) => PopResult<FormValues, string, FieldValue>; | ||
push: (...args: DropFirst<PushArguments<FormValues, string, FieldValue>>) => PushResult; | ||
remove: (...args: DropFirst<RemoveArguments>) => RemoveResult<FormValues, string, FieldValue>; | ||
removeBatch: (...args: DropFirst<RemoveBatchArguments>) => RemoveBatchResult<FormValues, string, FieldValue[]>; | ||
shift: (...args: DropFirst<ShiftArguments>) => ShiftResult<FormValues, string, FieldValue>; | ||
swap: (...args: DropFirst<SwapArguments>) => SwapResult; | ||
update: (...args: DropFirst<UpdateArguments<FormValues, string, FieldValue>>) => UpdateResult; | ||
unshift: (...args: DropFirst<UnshiftArguments<FormValues, string, FieldValue>>) => UnshiftResult; | ||
} & { | ||
[Func in keyof DefaultBoundArrayMutators<FormValues>]: unknown; | ||
}; | ||
/** | ||
* Mutators for an array item in the field render props. | ||
@@ -15,4 +35,4 @@ * | ||
*/ | ||
export type FieldArrayMutators<FormValues extends FormValuesShape = FormValuesShape, MutatorsAfterBinding extends BoundArrayMutators<Mutators<FormValues>, FormValues> = DefaultBoundArrayMutators<FormValues>> = { | ||
[Func in keyof MutatorsAfterBinding]: DropFirstArg<MutatorsAfterBinding[Func]>; | ||
export type FieldArrayMutators<FormValues extends FormValuesShape = FormValuesShape, MutatorsAfterBinding extends BoundArrayMutators<Mutators<FormValues>, FormValues> = DefaultBoundArrayMutators<FormValues>, FieldValue = any> = { | ||
[Func in keyof MutatorsAfterBinding]: Func extends keyof DefaultBoundArrayMutators ? MutatorsAfterBinding[Func] extends DefaultBoundArrayMutators<FormValues>[Func] ? FieldDefaultBoundArrayMutators<FormValues, FieldValue>[Func] : DropFirstArg<MutatorsAfterBinding[Func]> : DropFirstArg<MutatorsAfterBinding[Func]>; | ||
}; | ||
@@ -48,3 +68,3 @@ /** | ||
map: (iterator: (name: string, index: number) => any) => any[]; | ||
} & FieldArrayMutators<FormValues, MutatorsAfterBinding & DefaultBoundArrayMutators<FormValues>> & Pick<FieldInputPropsBasedOnSubscription<FieldValue[], Subscription>, "name" | "value"> & Required<Pick<FieldMetaState<FieldValue[], Subscription>, "length">>; | ||
} & FieldArrayMutators<FormValues, MutatorsAfterBinding & DefaultBoundArrayMutators<FormValues>, FieldValue> & Pick<FieldInputPropsBasedOnSubscription<FieldValue[], Subscription>, "name" | "value"> & Required<Pick<FieldMetaState<FieldValue[], Subscription>, "length">>; | ||
} & { | ||
@@ -70,1 +90,2 @@ [Key in keyof Pick<FieldRenderProps, "meta">]: Omit<FieldMetaState<FieldValue[], Subscription>, "length">; | ||
} | ||
export {}; |
{ | ||
"name": "@deckstar/react-final-form-arrays", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "A component for rendering and editing arrays 🏁 React Final Form. Made with TypeScript.", | ||
@@ -23,5 +23,5 @@ "main": "dist/cjs", | ||
"peerDependencies": { | ||
"@deckstar/final-form": "1.0.11", | ||
"@deckstar/final-form-arrays": "1.0.11", | ||
"@deckstar/react-final-form": "1.0.11", | ||
"@deckstar/final-form": "1.0.12", | ||
"@deckstar/final-form-arrays": "1.0.12", | ||
"@deckstar/react-final-form": "1.0.12", | ||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0" | ||
@@ -45,3 +45,3 @@ }, | ||
], | ||
"gitHead": "584f335dbb8f0dee28a21c85e21da0f3ce5e09a8" | ||
"gitHead": "94877ffd58045410dd9f9cd9cd0b0c6212bfc6c1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55625
751