Comparing version 1.20.0 to 1.22.0
@@ -0,1 +1,13 @@ | ||
# 1.22.0 | ||
- The string converter can now take the option `maxLength`, which validates | ||
your string on if it contains too many characters. | ||
- All converters can now be called as either an instance with options as | ||
arguments, or as a factory. | ||
# 1.21.0 | ||
- Update a few dependencies. | ||
# 1.20.0 | ||
@@ -2,0 +14,0 @@ |
@@ -60,1 +60,3 @@ import { Controlled } from "./controlled"; | ||
export declare function withDefaults<O, R, V>(converterFactory: ConverterFactory<O, R, V>, defaults: O): PartialConverterFactory<O, R, V>; | ||
export declare type ConverterOrFactory<R, V> = IConverter<R, V> | (() => IConverter<R, V>); | ||
export declare function makeConverter<R, V>(converter: ConverterOrFactory<R, V>): IConverter<R, V>; |
import { IObservableArray } from "mobx"; | ||
import { IAnyModelType, Instance } from "mobx-state-tree"; | ||
import { Converter, IConverter } from "./converter"; | ||
import { Converter, ConverterOrFactory, IConverter } from "./converter"; | ||
import { dynamic } from "./dynamic-converter"; | ||
@@ -9,15 +9,28 @@ import { DecimalOptions } from "./decimalParser"; | ||
} | ||
declare function maybe<R, V>(converter: StringConverter<V>): IConverter<string, V | undefined>; | ||
declare function maybe<M>(converter: IConverter<M | null, M | undefined>): IConverter<M | null, M | undefined>; | ||
declare function maybeNull<R, V>(converter: StringConverter<V>): IConverter<string, V | null>; | ||
declare function maybeNull<M>(converter: IConverter<M | null, M | null>): IConverter<M | null, M | null>; | ||
declare type StringOptions = { | ||
maxLength?: number; | ||
}; | ||
declare type NumberOptions = {}; | ||
declare function number(options?: NumberOptions): StringConverter<number>; | ||
declare type IntegerOptions = {}; | ||
declare function integer(options?: IntegerOptions): StringConverter<number>; | ||
declare type BooleanOptions = {}; | ||
declare function boolean(options?: BooleanOptions): Converter<boolean, boolean>; | ||
declare type StringArrayOptions = {}; | ||
declare function stringArray(options?: StringArrayOptions): Converter<string[], IObservableArray<string>>; | ||
declare type TextStringArrayOptions = {}; | ||
declare function textStringArray(options?: TextStringArrayOptions): Converter<string, IObservableArray<string>>; | ||
declare function maybe<R, V>(converter: StringConverter<V> | (() => StringConverter<V>)): IConverter<string, V | undefined>; | ||
declare function maybe<M>(converter: ConverterOrFactory<M | null, M | undefined>): IConverter<M | null, M | undefined>; | ||
declare function maybeNull<R, V>(converter: StringConverter<V> | (() => StringConverter<V>)): IConverter<string, V | null>; | ||
declare function maybeNull<M>(converter: ConverterOrFactory<M | null, M | null>): IConverter<M | null, M | null>; | ||
declare function model<M extends IAnyModelType>(model: M): Converter<Instance<M> | null, Instance<M>>; | ||
export declare const converters: { | ||
string: StringConverter<string>; | ||
number: StringConverter<number>; | ||
integer: StringConverter<number>; | ||
string: import("./converter").PartialConverterFactory<StringOptions, string, string>; | ||
number: typeof number; | ||
integer: typeof integer; | ||
decimal: import("./converter").PartialConverterFactory<DecimalOptions, string, string>; | ||
boolean: Converter<boolean, boolean>; | ||
textStringArray: Converter<string, IObservableArray<string>>; | ||
stringArray: Converter<string[], IObservableArray<string>>; | ||
boolean: typeof boolean; | ||
textStringArray: typeof textStringArray; | ||
stringArray: typeof stringArray; | ||
maybe: typeof maybe; | ||
@@ -24,0 +37,0 @@ maybeNull: typeof maybeNull; |
import { IMSTArray, IAnyModelType, ModelInstanceTypeProps, Instance } from "mobx-state-tree"; | ||
import { ConversionError, IConverter, StateConverterOptionsWithContext } from "./converter"; | ||
import { ConversionError, ConverterOrFactory, IConverter, StateConverterOptionsWithContext } from "./converter"; | ||
import { FormState, FormStateOptions } from "./state"; | ||
@@ -90,3 +90,2 @@ import { Controlled } from "./controlled"; | ||
export declare class Field<R, V> { | ||
converter: IConverter<R, V>; | ||
options?: FieldOptions<R, V, any, any> | undefined; | ||
@@ -103,3 +102,5 @@ rawValidators: Validator<R>[]; | ||
postprocess: boolean; | ||
constructor(converter: IConverter<R, V>, options?: FieldOptions<R, V, any, any> | undefined); | ||
_converter: ConverterOrFactory<R, V>; | ||
constructor(converter: ConverterOrFactory<R, V>, options?: FieldOptions<R, V, any, any> | undefined); | ||
readonly converter: IConverter<R, V>; | ||
createDefaultControlled(): Controlled; | ||
@@ -106,0 +107,0 @@ readonly RawType: R; |
{ | ||
"name": "mstform", | ||
"version": "1.20.0", | ||
"version": "1.22.0", | ||
"description": "mobx-state-tree powered forms", | ||
@@ -5,0 +5,0 @@ "main": "dist/mstform.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1106121
1488