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

mstform

Package Overview
Dependencies
Maintainers
1
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.12.1 to 1.13.0

dist/src/addMode.d.ts

22

CHANGES.md

@@ -0,1 +1,23 @@

# 1.13.0
- When you `push` or `insert` a new repeating form item you can now pass a
third argument which is a list of fieldrefs. Each fieldref indicates a field
where you want this field to start outside of add-mode; that field has its
raw reflecting that of the value, unlike other fields in add-mode.
You can give a `addModeDefaults` option when you call `state()`, which can be
used to exclude certain items from add-mode in the entire form.
If you use `addModeDefaults` with a field that is derived, the derived
value is calculated right away.
- Fix: too many accessors were initialized. This was generally not a problem
except that if you derived a field from another it would be called
excessively often.
- Add a `normalizedDecimalPlaces` option to the `decimal` converter. This
ensures that the converted decimal has a fixed number of decimal places.
This is useful if your backend delivers a fixed amount of decimal places
and you want to display less of them (with `decimalPlaces`) than you store.
# 1.12.1

@@ -2,0 +24,0 @@

8

dist/src/converters.d.ts

@@ -5,2 +5,3 @@ import { IObservableArray } from "mobx";

import { dynamic } from "./dynamic-converter";
import { DecimalOptions } from "./decimalParser";
export declare class StringConverter<V> extends Converter<string, V> {

@@ -18,8 +19,3 @@ defaultControlled: import("./controlled").Controlled;

integer: StringConverter<number>;
decimal: import("./converter").PartialConverterFactory<{
maxWholeDigits: number;
decimalPlaces: number;
allowNegative: boolean;
addZeroes: boolean;
}, string, string>;
decimal: import("./converter").PartialConverterFactory<DecimalOptions, string, string>;
boolean: Converter<boolean, boolean>;

@@ -26,0 +22,0 @@ textStringArray: Converter<string, IObservableArray<string>>;

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

allowNegative: boolean;
normalizedDecimalPlaces?: number;
};

@@ -9,0 +10,0 @@ declare type TokenOptions = {

@@ -30,2 +30,3 @@ import { IReactionDisposer } from "mobx";

setValue(value: V): void;
setValueAndRawWithoutChangeEvent(value: V): void;
readonly value: V;

@@ -32,0 +33,0 @@ readonly errorValue: string | undefined;

@@ -33,4 +33,4 @@ import { FormDefinition, RepeatingForm, GroupDefinition } from "./form";

accessBySteps(steps: string[]): Accessor | undefined;
insert(index: number, node: any): void;
push(node: any): void;
insert(index: number, node: any, addModeDefaults?: string[]): void;
push(node: any, addModeDefaults?: string[]): void;
remove(node: any): void;

@@ -37,0 +37,0 @@ removeIndex(index: number): void;

@@ -25,4 +25,4 @@ import { FormDefinition, GroupDefinition } from "./form";

setIndex(index: number): void;
setAddMode(): void;
setAddMode(addModeDefaults: string[]): void;
readonly addMode: boolean;
}

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

requiredError?: string | ErrorFunc;
addModeDefaults?: string[];
}

@@ -84,3 +85,3 @@ export declare type SaveStatusOptions = "before" | "rightAfter" | "after";

_onPatchDisposer: IDisposer;
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 }?: FormStateOptions<M>);
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>);
dispose(): void;

@@ -87,0 +88,0 @@ readonly context: any;

{
"name": "mstform",
"version": "1.12.1",
"version": "1.13.0",
"description": "mobx-state-tree powered forms",

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

@@ -361,3 +361,6 @@ # mstform README

With `allowNegative` (boolean, default true) you can specify if negative
values are allowed.
values are allowed. With `normalizedDecimalPlaces` you can set the amount
of decimal places the converted number has. It should not be lower than
`decimalPlaces`, but can be higher. If it is, the given number is
automatically padded with additional decimal places set to 0.

@@ -705,2 +708,15 @@ Conversion error types are:

In case you already have a default value for a field and you do not want it to
be in add-mode, you can exclude them by including its fieldref in the
`addModeDefaults` option:
```js
const state = form.state(node, { addMode: true, addModeDefaults: ["nr"] });
```
Now the `nr` field is shown with the value `0` in it immediately.
If the field you reference from `addModeDefaults` is configured to be derived,
this is used to calculate the derived value automatically.
### Add mode for repeating forms

@@ -715,2 +731,13 @@

If you use `.push` and `.insert` on the repeating form accessor, you can pass
in an additional argument with the `addModeDefaults` array. Here is an example:
```js
repeating.push({ a: 3, b: 5 }, ["b"]);
```
Here `a` is not mentioned and is considered to be in add-mode; instead of its
value, the empty raw is shown instead. But `b` is referenced and therefore `5`
is visible immediately in the form.
## Backend interaction (save and processing)

@@ -717,0 +744,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