Comparing version 1.14.0 to 1.15.0
@@ -0,1 +1,34 @@ | ||
# 1.15.0 | ||
- The way external `process`, `processAll` and `save` errors generated by a | ||
backend are stored has changed. Previously this reused the `getError` hook, | ||
but this leads to problems if paths change, which can happen if a repeating | ||
form item is inserted or deleted. Instead now we store this information as | ||
soon as it comes in directly on the accessor. | ||
- Repeating forms never worked quite well for access | ||
(readOnly/disabled/hidden/required) as the system relied on paths. By | ||
passing this information in backend processing, we can start to track this | ||
in the accessors themselves, which is more resilient. It also allows the | ||
backend to control which fields are accessible in response to changes in | ||
the form. You can control access by passing `accessUpdates` with the | ||
backend `process`. | ||
- Major internal refactoring making the accessors more consistent and reuse | ||
more code. | ||
- BREAKING CHANGE: if you define an error with `getError` and an external | ||
error is also set, that external error now takes precedence. | ||
- Introduce a new explicit `IAccessor` interface that is shared by all | ||
accessors. Also introduce `IFormAccessor`, which is shared by FormState, | ||
RepeatingFormIndexedAccessor, and SubFormAccessor. | ||
- BREAKING CHANGE: Drop the old Accessor union type in favor of `IAccessor`. | ||
- Add an `isWarningFree` value to GroupAccessors. | ||
- Add a `clearAllValidation` method to formState. We can use it to manually clear | ||
all internal and external error and warning messages. | ||
# 1.14.0 | ||
@@ -2,0 +35,0 @@ |
import { FormDefinition, RepeatingFormDefinitionType, RepeatingFormGroupDefinitionType, SubFormDefinitionType, SubFormGroupDefinitionType, RawType, ValueType } from "./form"; | ||
import { FieldAccessor } from "./field-accessor"; | ||
import { FormAccessor } from "./form-accessor"; | ||
import { RepeatingFormAccessor } from "./repeating-form-accessor"; | ||
import { RepeatingFormIndexedAccessor } from "./repeating-form-indexed-accessor"; | ||
import { SubFormAccessor } from "./sub-form-accessor"; | ||
import { GroupAccessor } from "./group-accessor"; | ||
export declare type Accessor = FormAccessor<any, any> | FieldAccessor<any, any> | RepeatingFormAccessor<any, any> | RepeatingFormIndexedAccessor<any, any> | SubFormAccessor<any, any>; | ||
import { ISubFormAccessor, IRepeatingFormAccessor } from "./interfaces"; | ||
export declare type FieldAccess<D extends FormDefinition<any>, K extends keyof D> = FieldAccessor<RawType<D[K]>, ValueType<D[K]>>; | ||
export declare type RepeatingFormAccess<D extends FormDefinition<any>, K extends keyof D> = RepeatingFormAccessor<RepeatingFormDefinitionType<D[K]>, RepeatingFormGroupDefinitionType<D[K]>>; | ||
export declare type SubFormAccess<D extends FormDefinition<any>, K extends keyof D> = SubFormAccessor<SubFormDefinitionType<D[K]>, SubFormGroupDefinitionType<D[K]>>; | ||
export declare type RepeatingFormAccess<D extends FormDefinition<any>, K extends keyof D> = IRepeatingFormAccessor<RepeatingFormDefinitionType<D[K]>, RepeatingFormGroupDefinitionType<D[K]>>; | ||
export declare type SubFormAccess<D extends FormDefinition<any>, K extends keyof D> = ISubFormAccessor<SubFormDefinitionType<D[K]>, SubFormGroupDefinitionType<D[K]>>; | ||
export declare type GroupAccess<D extends FormDefinition<any>> = GroupAccessor<D>; |
import { IAnyModelType, Instance } from "mobx-state-tree"; | ||
import { ChangeTracker, DebounceOptions } from "./changeTracker"; | ||
import { ValidationEntries, Message } from "./validationMessages"; | ||
import { Message } from "./validationMessages"; | ||
import { FormState } from "./state"; | ||
declare type Update = { | ||
@@ -10,2 +11,9 @@ path: string; | ||
}; | ||
export declare type AccessUpdate = { | ||
path: string; | ||
readOnly?: boolean; | ||
disabled?: boolean; | ||
hidden?: boolean; | ||
required?: boolean; | ||
}; | ||
declare type ValidationInfo = { | ||
@@ -17,2 +25,3 @@ id: string; | ||
updates: Update[]; | ||
accessUpdates: AccessUpdate[]; | ||
errorValidations: ValidationInfo[]; | ||
@@ -37,2 +46,3 @@ warningValidations: ValidationInfo[]; | ||
export declare class Backend<M extends IAnyModelType> { | ||
state: FormState<M, any, any>; | ||
node: Instance<M>; | ||
@@ -42,8 +52,5 @@ save?: SaveFunc<M> | undefined; | ||
processAll?: ProcessAll<M> | undefined; | ||
getLiveOnly: (() => boolean); | ||
errorValidations: ValidationEntries; | ||
warningValidations: ValidationEntries; | ||
changeTracker: ChangeTracker; | ||
applyUpdate: ApplyUpdate; | ||
constructor(node: Instance<M>, save?: SaveFunc<M> | undefined, process?: Process<M> | undefined, processAll?: ProcessAll<M> | undefined, { debounce, delay, applyUpdate }?: ProcessorOptions, getLiveOnly?: (() => boolean)); | ||
constructor(state: FormState<M, any, any>, node: Instance<M>, save?: SaveFunc<M> | undefined, process?: Process<M> | undefined, processAll?: ProcessAll<M> | undefined, { debounce, delay, applyUpdate }?: ProcessorOptions); | ||
run(path: string): void; | ||
@@ -56,5 +63,3 @@ runProcessResult(processResult: ProcessResult): void; | ||
isFinished(): Promise<void>; | ||
getError(path: string): string | undefined; | ||
getWarning(path: string): string | undefined; | ||
} | ||
export {}; |
import { IReactionDisposer } from "mobx"; | ||
import { Field, ProcessOptions } from "./form"; | ||
import { FormState } from "./state"; | ||
import { FormAccessor } from "./form-accessor"; | ||
import { Accessor } from "./accessor"; | ||
import { ValidateOptions } from "./validate-options"; | ||
export declare class FieldAccessor<R, V> { | ||
import { IAccessor, IFormAccessor } from "./interfaces"; | ||
import { AccessorBase } from "./accessor-base"; | ||
export declare class FieldAccessor<R, V> extends AccessorBase implements IAccessor { | ||
state: FormState<any, any, any>; | ||
field: Field<R, V>; | ||
parent: FormAccessor<any, any>; | ||
name: string; | ||
_raw: R | undefined; | ||
_error: string | undefined; | ||
_addMode: boolean; | ||
_value: V; | ||
_disposer: IReactionDisposer | undefined; | ||
constructor(state: FormState<any, any, any>, field: Field<R, V>, parent: FormAccessor<any, any>, name: string); | ||
constructor(state: FormState<any, any, any>, field: Field<R, V>, parent: IFormAccessor<any, any>, name: string); | ||
readonly path: string; | ||
dispose(): void; | ||
clear(): void; | ||
readonly path: string; | ||
readonly fieldref: string; | ||
readonly context: any; | ||
readonly isEmpty: boolean; | ||
@@ -32,11 +26,2 @@ readonly isEmptyAndRequired: boolean; | ||
readonly value: V; | ||
readonly errorValue: string | undefined; | ||
readonly warningValue: string | undefined; | ||
readonly canShowValidationMessages: boolean; | ||
readonly error: string | undefined; | ||
readonly warning: string | undefined; | ||
readonly disabled: boolean; | ||
readonly hidden: boolean; | ||
readonly readOnly: boolean; | ||
readonly inputAllowed: boolean; | ||
readonly required: boolean; | ||
@@ -51,3 +36,2 @@ validate(options?: ValidateOptions): boolean; | ||
setError(error: string): void; | ||
clearError(): void; | ||
handleChange: (...args: any[]) => void; | ||
@@ -58,3 +42,3 @@ handleFocus: (event: any) => void; | ||
readonly validationProps: object; | ||
accessBySteps(steps: string[]): Accessor; | ||
accessBySteps(steps: string[]): IAccessor; | ||
} |
@@ -1,23 +0,37 @@ | ||
import { FormDefinition, GroupDefinition } from "./form"; | ||
import { Accessor, FieldAccess, RepeatingFormAccess, SubFormAccess, GroupAccess } from "./accessor"; | ||
import { FormAccessor } from "./form-accessor"; | ||
import { SubForm, Field, FormDefinition, RepeatingForm, GroupDefinition, Group } from "./form"; | ||
import { FieldAccess, RepeatingFormAccess, SubFormAccess, GroupAccess } from "./accessor"; | ||
import { FieldAccessor } from "./field-accessor"; | ||
import { GroupAccessor } from "./group-accessor"; | ||
import { ValidateOptions } from "./validate-options"; | ||
export declare abstract class FormAccessorBase<D extends FormDefinition<any>, G extends GroupDefinition<D>> { | ||
abstract formAccessor: FormAccessor<D, G>; | ||
initialize(): void; | ||
import { IAccessor, IFormAccessor, ISubFormAccessor, IRepeatingFormAccessor, IParentAccessor } from "./interfaces"; | ||
import { AccessorBase } from "./accessor-base"; | ||
export declare abstract class FormAccessorBase<D extends FormDefinition<any>, G extends GroupDefinition<D>> extends AccessorBase implements IFormAccessor<D, G> { | ||
definition: any; | ||
groupDefinition: any; | ||
keys: (keyof D)[]; | ||
fieldAccessors: Map<keyof D, FieldAccessor<any, any>>; | ||
repeatingFormAccessors: Map<keyof D, IRepeatingFormAccessor<any, any>>; | ||
subFormAccessors: Map<keyof D, ISubFormAccessor<any, any>>; | ||
groupAccessors: Map<keyof G, GroupAccessor<any>>; | ||
abstract path: string; | ||
constructor(definition: any, groupDefinition: any, parent: IParentAccessor, addMode: boolean); | ||
validate(options?: ValidateOptions): boolean; | ||
readonly context: any; | ||
readonly warningValue: string | undefined; | ||
readonly errorValue: string | undefined; | ||
readonly error: string | undefined; | ||
readonly warning: string | undefined; | ||
dispose(): void; | ||
readonly value: any; | ||
readonly isValid: boolean; | ||
access(name: string): Accessor | undefined; | ||
accessBySteps(steps: string[]): Accessor | undefined; | ||
readonly accessors: IAccessor[]; | ||
setAddModeDefaults(addModeDefaults: string[]): void; | ||
readonly addMode: boolean; | ||
access(name: string): IAccessor | undefined; | ||
accessBySteps(steps: string[]): IAccessor | undefined; | ||
initialize(): void; | ||
createField<K extends keyof D>(name: K, field: Field<any, any>): void; | ||
field<K extends keyof D>(name: K): FieldAccess<D, K>; | ||
createRepeatingForm<K extends keyof D>(name: K, repeatingForm: RepeatingForm<any, any>): void; | ||
repeatingForm<K extends keyof D>(name: K): RepeatingFormAccess<D, K>; | ||
createSubForm<K extends keyof D>(name: K, subForm: SubForm<any, any>): void; | ||
subForm<K extends keyof D>(name: K): SubFormAccess<D, K>; | ||
createGroup<K extends keyof G>(name: K, group: Group<any>): void; | ||
group<K extends keyof G>(name: K): GroupAccess<D>; | ||
readonly accessors: Accessor[]; | ||
readonly flatAccessors: Accessor[]; | ||
repeatingField(name: string): any; | ||
} |
import { FormDefinition, Group } from "./form"; | ||
import { FormState } from "./state"; | ||
import { FormAccessor } from "./form-accessor"; | ||
import { FormAccessorBase } from "./form-accessor-base"; | ||
export declare class GroupAccessor<D extends FormDefinition<any>> { | ||
state: FormState<any, any, any>; | ||
definition: D; | ||
parent: FormAccessor<any, any>; | ||
parent: FormAccessorBase<any, any>; | ||
group: Group<D>; | ||
constructor(state: FormState<any, any, any>, definition: D, parent: FormAccessor<any, any>, group: Group<D>); | ||
constructor(state: FormState<any, any, any>, definition: D, parent: FormAccessorBase<any, any>, group: Group<D>); | ||
readonly isValid: boolean; | ||
readonly isWarningFree: boolean; | ||
hasFeedback(feedbackFunc: Function): boolean; | ||
notExcluded(names: (keyof D)[]): (keyof D)[]; | ||
isValidForNames(names: (keyof D)[]): boolean; | ||
isWarningFreeForNames(names: (keyof D)[]): boolean; | ||
} |
export * from "./form"; | ||
export * from "./converter"; | ||
export * from "./converters"; | ||
export * from "./accessor"; | ||
export * from "./interfaces"; | ||
export * from "./field-accessor"; | ||
export * from "./form-accessor"; | ||
export * from "./repeating-form-accessor"; | ||
@@ -8,0 +7,0 @@ export * from "./repeating-form-indexed-accessor"; |
import { FormDefinition, RepeatingForm, GroupDefinition } from "./form"; | ||
import { FormState } from "./state"; | ||
import { Accessor } from "./accessor"; | ||
import { RepeatingFormIndexedAccessor } from "./repeating-form-indexed-accessor"; | ||
import { FormAccessor } from "./form-accessor"; | ||
import { AccessorBase } from "./accessor-base"; | ||
import { ValidateOptions } from "./validate-options"; | ||
export declare class RepeatingFormAccessor<D extends FormDefinition<any>, G extends GroupDefinition<D>> { | ||
import { ExternalMessages } from "./validationMessages"; | ||
import { IAccessor, IRepeatingFormIndexedAccessor, IRepeatingFormAccessor, IFormAccessor } from "./interfaces"; | ||
export declare class RepeatingFormAccessor<D extends FormDefinition<any>, G extends GroupDefinition<D>> extends AccessorBase implements IRepeatingFormAccessor<D, G> { | ||
state: FormState<any, any, any>; | ||
repeatingForm: RepeatingForm<D, G>; | ||
parent: FormAccessor<any, any>; | ||
parent: IFormAccessor<any, any>; | ||
name: string; | ||
repeatingFormIndexedAccessors: Map<number, any>; | ||
constructor(state: FormState<any, any, any>, repeatingForm: RepeatingForm<D, G>, parent: FormAccessor<any, any>, name: string); | ||
dispose(): void; | ||
clear(): void; | ||
repeatingFormIndexedAccessors: Map<number, IRepeatingFormIndexedAccessor<D, G>>; | ||
externalErrors: ExternalMessages; | ||
externalWarnings: ExternalMessages; | ||
constructor(state: FormState<any, any, any>, repeatingForm: RepeatingForm<D, G>, parent: IFormAccessor<any, any>, name: string); | ||
readonly path: string; | ||
readonly fieldref: string; | ||
readonly value: any; | ||
readonly context: any; | ||
validate(options?: ValidateOptions): boolean; | ||
readonly isValid: boolean; | ||
readonly addMode: boolean; | ||
readonly isValid: boolean; | ||
initialize(): void; | ||
createFormIndexedAccessor(index: number): void; | ||
index(index: number): RepeatingFormIndexedAccessor<D, G>; | ||
readonly disabled: boolean; | ||
readonly hidden: boolean; | ||
readonly readOnly: boolean; | ||
readonly inputAllowed: boolean; | ||
readonly accessors: RepeatingFormIndexedAccessor<D, G>[]; | ||
readonly flatAccessors: Accessor[]; | ||
accessBySteps(steps: string[]): Accessor | undefined; | ||
index(index: number): IRepeatingFormIndexedAccessor<D, G>; | ||
readonly accessors: IRepeatingFormIndexedAccessor<D, G>[]; | ||
accessBySteps(steps: string[]): IAccessor | undefined; | ||
insert(index: number, node: any, addModeDefaults?: string[]): void; | ||
@@ -40,6 +33,2 @@ push(node: any, addModeDefaults?: string[]): void; | ||
readonly length: number; | ||
readonly errorValue: string | undefined; | ||
readonly error: string | undefined; | ||
readonly warningValue: string | undefined; | ||
readonly warning: string | undefined; | ||
} |
import { FormDefinition, GroupDefinition } from "./form"; | ||
import { FormState } from "./state"; | ||
import { RepeatingFormAccessor } from "./repeating-form-accessor"; | ||
import { FormAccessorBase } from "./form-accessor-base"; | ||
import { FormAccessor } from "./form-accessor"; | ||
export declare class RepeatingFormIndexedAccessor<D extends FormDefinition<any>, G extends GroupDefinition<D>> extends FormAccessorBase<D, G> { | ||
import { IRepeatingFormIndexedAccessor, IRepeatingFormAccessor } from "./interfaces"; | ||
export declare class RepeatingFormIndexedAccessor<D extends FormDefinition<any>, G extends GroupDefinition<D>> extends FormAccessorBase<D, G> implements IRepeatingFormIndexedAccessor<D, G> { | ||
state: FormState<any, any, any>; | ||
definition: D; | ||
groupDefinition: G | undefined; | ||
parent: RepeatingFormAccessor<D, G>; | ||
formAccessor: FormAccessor<D, G>; | ||
parent: IRepeatingFormAccessor<D, G>; | ||
index: number; | ||
_addMode: boolean; | ||
constructor(state: FormState<any, any, any>, definition: D, groupDefinition: G | undefined, parent: RepeatingFormAccessor<D, G>, index: number); | ||
dispose(): void; | ||
constructor(state: FormState<any, any, any>, definition: D, groupDefinition: G | undefined, parent: IRepeatingFormAccessor<D, G>, index: number); | ||
clear(): void; | ||
readonly disabled: boolean; | ||
readonly hidden: boolean; | ||
readonly readOnly: boolean; | ||
readonly inputAllowed: boolean; | ||
readonly path: string; | ||
readonly fieldref: string; | ||
readonly value: any; | ||
@@ -24,0 +13,0 @@ setIndex(index: number): void; |
import { IAnyModelType, Instance } from "mobx-state-tree"; | ||
import { Accessor } from "./accessor"; | ||
import { Form, FormDefinition, ValidationResponse, GroupDefinition, ErrorFunc, IDisposer } from "./form"; | ||
import { Form, FormDefinition, ValidationResponse, GroupDefinition, ErrorFunc, IDisposer, RepeatingForm } from "./form"; | ||
import { FieldAccessor } from "./field-accessor"; | ||
import { FormAccessor } from "./form-accessor"; | ||
import { FormAccessorBase } from "./form-accessor-base"; | ||
import { RepeatingFormAccessor } from "./repeating-form-accessor"; | ||
import { FormAccessorBase } from "./form-accessor-base"; | ||
import { ValidateOptions } from "./validate-options"; | ||
import { StateConverterOptions, StateConverterOptionsWithContext } from "./converter"; | ||
import { Backend, ProcessorOptions, Process, SaveFunc, ProcessAll } from "./backend"; | ||
import { Backend, ProcessorOptions, Process, SaveFunc, ProcessAll, AccessUpdate } from "./backend"; | ||
import { Validation } from "./validationMessages"; | ||
import { IAccessor, IFormAccessor, IRepeatingFormAccessor, ISubFormAccessor } from "./interfaces"; | ||
export interface AccessorAllows { | ||
(accessor: Accessor): boolean; | ||
(accessor: IAccessor): boolean; | ||
} | ||
export interface ErrorOrWarning { | ||
(accessor: Accessor): string | undefined; | ||
(accessor: IAccessor): string | undefined; | ||
} | ||
@@ -60,7 +60,6 @@ export interface ExtraValidation { | ||
export declare type SaveStatusOptions = "before" | "rightAfter" | "after"; | ||
export declare class FormState<M extends IAnyModelType, D extends FormDefinition<M>, G extends GroupDefinition<D>> extends FormAccessorBase<D, G> { | ||
export declare class FormState<M extends IAnyModelType, D extends FormDefinition<M>, G extends GroupDefinition<D>> extends FormAccessorBase<D, G> implements IFormAccessor<D, G> { | ||
form: Form<M, D, G>; | ||
node: Instance<M>; | ||
saveStatus: SaveStatusOptions; | ||
formAccessor: FormAccessor<D, G>; | ||
validationBeforeSave: ValidationOption; | ||
@@ -86,8 +85,11 @@ validationAfterSave: ValidationOption; | ||
constructor(form: Form<M, D, G>, node: Instance<M>, { addMode, isDisabled, isHidden, isReadOnly, isRequired, getError, getWarning, backend, extraValidation, validation, focus, blur, update, context, converterOptions, requiredError, addModeDefaults }?: FormStateOptions<M>); | ||
readonly state: this; | ||
readonly context: any; | ||
dispose(): void; | ||
readonly context: any; | ||
createRepeatingFormAccessor(repeatingForm: RepeatingForm<any, any>, parent: IFormAccessor<any, any>, name: string): IRepeatingFormAccessor<any, any>; | ||
createSubFormAccessor(definition: any, groupDefinition: any, parent: IFormAccessor<any, any>, name: string): ISubFormAccessor<any, any>; | ||
readonly path: string; | ||
readonly fieldref: string; | ||
readonly value: Instance<M>; | ||
readonly processPromise: Promise<void>; | ||
readonly liveOnly: boolean; | ||
stateConverterOptionsWithContext(accessor: any): StateConverterOptionsWithContext; | ||
@@ -102,7 +104,10 @@ setSaveStatus(status: SaveStatusOptions): void; | ||
processAll(): Promise<void>; | ||
setExternalValidations(validations: Validation[], messageType: "error" | "warning"): void; | ||
clearExternalValidations(messageType: "error" | "warning"): void; | ||
clearAllValidations(): void; | ||
setAccessUpdate(accessUpdate: AccessUpdate): void; | ||
getValue(path: string): any; | ||
accessByPath(path: string): Accessor | undefined; | ||
accessBySteps(steps: string[]): Accessor | undefined; | ||
readonly isWarningFree: boolean; | ||
accessByPath(path: string): IAccessor | undefined; | ||
readonly canShowValidationMessages: boolean; | ||
} | ||
export {}; |
import { FormDefinition, GroupDefinition } from "./form"; | ||
import { FormState } from "./state"; | ||
import { FormAccessor } from "./form-accessor"; | ||
import { FormAccessorBase } from "./form-accessor-base"; | ||
import { ValidateOptions } from "./validate-options"; | ||
export declare class SubFormAccessor<D extends FormDefinition<any>, G extends GroupDefinition<D>> extends FormAccessorBase<D, G> { | ||
import { ISubFormAccessor, IFormAccessor } from "./interfaces"; | ||
export declare class SubFormAccessor<D extends FormDefinition<any>, G extends GroupDefinition<D>> extends FormAccessorBase<D, G> implements ISubFormAccessor<D, G> { | ||
state: FormState<any, any, any>; | ||
definition: D; | ||
groupDefinition: G | undefined; | ||
parent: FormAccessor<any, any>; | ||
parent: IFormAccessor<any, any>; | ||
name: string; | ||
formAccessor: FormAccessor<D, G>; | ||
constructor(state: FormState<any, any, any>, definition: D, groupDefinition: G | undefined, parent: FormAccessor<any, any>, name: string); | ||
dispose(): void; | ||
clear(): void; | ||
validate(options?: ValidateOptions): boolean; | ||
readonly disabled: boolean; | ||
readonly hidden: boolean; | ||
readonly readOnly: boolean; | ||
readonly inputAllowed: boolean; | ||
constructor(state: FormState<any, any, any>, definition: D, groupDefinition: G | undefined, parent: IFormAccessor<any, any>, name: string); | ||
readonly path: string; | ||
readonly fieldref: string; | ||
readonly value: any; | ||
readonly addMode: boolean; | ||
} |
@@ -1,2 +0,1 @@ | ||
import { IObservableArray } from "mobx"; | ||
export declare type Message = { | ||
@@ -6,19 +5,11 @@ path: string; | ||
}; | ||
declare class ValidationEntry { | ||
id: string; | ||
export declare class ExternalMessages { | ||
messages: Map<string, string>; | ||
constructor(id: string, messages: Message[]); | ||
setMessages(messages: Message[]): void; | ||
getMessage(path: string): string | undefined; | ||
update(validationIdToMessage: Map<string, string> | undefined, affectedValidationIds: Set<string>): void; | ||
clear(): void; | ||
readonly message: string | undefined; | ||
} | ||
declare type Validation = { | ||
export declare type Validation = { | ||
id: string; | ||
messages: Message[]; | ||
}; | ||
export declare class ValidationEntries { | ||
validations: IObservableArray<ValidationEntry>; | ||
update(updatedValidations: Validation[]): void; | ||
clear(): void; | ||
getMessage(path: string): string | undefined; | ||
} | ||
export {}; |
{ | ||
"name": "mstform", | ||
"version": "1.14.0", | ||
"version": "1.15.0", | ||
"description": "mobx-state-tree powered forms", | ||
@@ -5,0 +5,0 @@ "main": "dist/mstform.js", |
@@ -300,4 +300,4 @@ # mstform README | ||
access it via the `group()` method on any form accessor. This is a special | ||
kind of accessor that only implements an `isValid` method. It's a way to | ||
aggregate validation results from other accessors. | ||
kind of accessor that only implements the `isValid` and `isWarningFree` methods. | ||
It's a way to aggregate validation results from other accessors. | ||
@@ -922,2 +922,3 @@ - Finally there is the `FormState` itself, which is the accessor at the root of | ||
updates: [{ path: "/a", value: "Alpha" }], | ||
accessUpdates: [{path: '/c', disabled: true }] | ||
errorValidations: [ | ||
@@ -930,4 +931,4 @@ { id: "one", messages: [{ path: "/b", message: "This is wrong" }] } | ||
`updates` is a list of fields to update. Each field is indicated by the field | ||
path. The rest of the structure is up to the developer and defines the update | ||
`updates` is a list of fields to update. Each field is indicated by `path`. The | ||
rest of the structure is up to the developer and defines the update | ||
information. By default, you need to supply a `value` with the new value to put | ||
@@ -938,2 +939,10 @@ in the form there, but you can implement by your custom update procedure based | ||
`accessUpdates` is a list of fields to update as well. Each field is indicated | ||
by `path`. The rest of the structure updates whether a field is `disabled`, | ||
`readOnly`, `hidden` and `required`. Not passing a particular boolean results | ||
in no change for that field. You can also use paths for accessors that aren't | ||
fields, such as a repeating form, in which case for | ||
`disabled,`readOnly`and`hidden`the information is inherited by all fields in it. Setting`required` only has meaning on the field accessor itself and is | ||
not inherited. | ||
Both `errorValidations` and `warningValidations` are lists of validation | ||
@@ -1143,4 +1152,7 @@ structures. These validation structures each have an `id` -- if a new | ||
You can reset the save status back to `before` with `'resetSaveStatus()`. | ||
You can reset the save status back to `before` with `state.resetSaveStatus()`. | ||
You can remove all internal and external errors and warnings by calling | ||
`state.clearAllValidations()`. | ||
## required fields | ||
@@ -1339,3 +1351,3 @@ | ||
You can access a group on the state or form accessor and check its `isValid` | ||
property: | ||
or `isWarningFree` property: | ||
@@ -1347,2 +1359,5 @@ ```js | ||
} | ||
if (first.isWarningFree) { | ||
// only executed if none of the group members have warnings | ||
} | ||
``` | ||
@@ -1349,0 +1364,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1504
1074916
1335