New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mstform

Package Overview
Dependencies
Maintainers
2
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mstform - npm Package Compare versions

Comparing version 1.33.2 to 1.34.0

10

CHANGES.md

@@ -0,1 +1,11 @@

# 1.34.0
- Added `zeroIsEmpty` parameter for the `stringDecimal` converter. When this is enabled,
0 and equivalent inputs (e.g. 0.00) will be treated as an empty string.
- Converters now have an `isEmpty` hook that allows you to customize the behavior of
the empty check for your custom converter.
- Added new "bulkProcess" option on form states.
This is used to process all changed paths at once instead of one at a time.
This is useful when the latter is too strenuous and affects app performance.
# 1.33.2

@@ -2,0 +12,0 @@

8

dist/src/backend.d.ts

@@ -33,3 +33,3 @@ import { IAnyModelType, Instance } from "mobx-state-tree";

export interface Process<M> {
(node: Instance<M>, path: string, liveOnly: boolean): Promise<Partial<ProcessResult>>;
(node: Instance<M>, path: string, liveOnly: boolean, paths?: string[]): Promise<Partial<ProcessResult>>;
}

@@ -44,2 +44,3 @@ export interface ProcessAll<M> {

applyUpdate?: ApplyUpdate;
bulkProcess?: boolean;
} & Partial<DebounceOptions>;

@@ -54,3 +55,4 @@ export declare class Backend<M extends IAnyModelType> {

applyUpdate: ApplyUpdate;
constructor(state: FormState<any, any, M>, node: Instance<M>, save?: SaveFunc<M> | undefined, process?: Process<M> | undefined, processAll?: ProcessAll<M> | undefined, { debounce, delay, applyUpdate }?: ProcessorOptions);
bulkProcess: boolean;
constructor(state: FormState<any, any, M>, node: Instance<M>, save?: SaveFunc<M> | undefined, process?: Process<M> | undefined, processAll?: ProcessAll<M> | undefined, { debounce, delay, applyUpdate, bulkProcess, }?: ProcessorOptions);
run(path: string): void;

@@ -61,5 +63,5 @@ runProcessResult(processResult: ProcessResult): void;

clearValidations(): Promise<void>;
realProcess(path: string): Promise<void>;
realProcess(path: string, paths: string[]): Promise<void>;
isFinished(): Promise<void>;
}
export {};
interface ProcessChange {
(path: string): Promise<any>;
(path: string, paths?: string[]): Promise<any>;
}

@@ -26,3 +26,4 @@ export interface DebounceFunc {

debounceProcess: DebounceProcess;
constructor(process: ProcessChange, options: Partial<DebounceOptions>);
bulkProcess: boolean;
constructor(process: ProcessChange, options: Partial<DebounceOptions>, bulkProcess?: boolean);
change(path: string): void;

@@ -29,0 +30,0 @@ startChange(path: string): void;

@@ -21,2 +21,3 @@ import { Controlled } from "./controlled";

preprocessRaw?(raw: R, options?: StateConverterOptionsWithContext): R;
isEmpty?(raw: R): boolean;
}

@@ -32,2 +33,3 @@ export interface IConverter<R, V> {

preprocessRaw(raw: R, options: StateConverterOptionsWithContext): R;
isEmpty(raw: R): boolean;
}

@@ -51,2 +53,3 @@ export declare class ConversionValue<V> {

constructor(definition: ConverterOptions<R, V>);
isEmpty(raw: R): boolean;
preprocessRaw(raw: R, options?: StateConverterOptionsWithContext): R;

@@ -53,0 +56,0 @@ convert(raw: R, options: StateConverterOptionsWithContext): ConversionResponse<V>;

@@ -9,2 +9,3 @@ import { StateConverterOptions, StateConverterOptionsWithContext } from "./converter";

maxZeroesPadding?: number;
zeroIsEmpty?: boolean;
};

@@ -11,0 +12,0 @@ declare type TokenOptions = {

{
"name": "mstform",
"version": "1.33.2",
"version": "1.34.0",
"description": "mobx-state-tree powered forms",

@@ -5,0 +5,0 @@ "main": "dist/mstform.js",

@@ -406,2 +406,4 @@ # mstform README

3 decimals, we do not want to show all trailing zeros
`zeroIsEmpty` can be set to treat 0 and similar inputs (e.g. 0.00 or 0.0000) as
empty values.

@@ -609,2 +611,7 @@ ### Boolean

Something else you can define is `isEmpty`. This is a hook that overwrites the
default empty check, that works by taking the raw and comparing it to the
`emptyRaw`. This should be a function that takes the raw as argument, and
returns a boolean.
`convert` and `render` take an optional second argument, `options`. With

@@ -1037,2 +1044,29 @@ `options`, you can pass `converterOptions` and a `context`. `context` is an

By default, process kicks off for every path in sequence. However, this can be too
strenuous on your system. If you want to process all paths at once, you can define
`bulkProcess` on your form state.
```js
form.state(o, { backend: { process: myProcess, bulkProcess: true } });
```
Now, your process function expects a list of paths, rather than one path. You can use
this to call one URL with all paths that need processing.
```js
const M = types.model("M", {
foo: types.string,
});
const o = M.create({ foo: "FOO" });
async function myProcess(node, path, liveOnly, paths?) {
// call the backend, turn into ProcessResult and return it
}
form.state(o, { backend: { process: myProcess, bulkProcess: true } });
```
`paths` is an optional argument, so it doesn't have to be defined.
### Save errors

@@ -1039,0 +1073,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc