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

@formily/core

Package Overview
Dependencies
Maintainers
1
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formily/core - npm Package Compare versions

Comparing version 1.1.1-beta.1 to 1.1.1-beta.2

28

lib/index.js

@@ -107,2 +107,4 @@ "use strict";

function syncFieldIntialValues(state) {
if (state.name === '')
return;
var initialValue = getFormInitialValuesIn(state.name);

@@ -122,3 +124,5 @@ if (!shared_1.isEqual(initialValue, state.initialValue)) {

function notifyFormValuesChange() {
if (shared_1.isFn(options.onChange) && !state.state.unmounted) {
if (shared_1.isFn(options.onChange) &&
state.state.mounted &&
!state.state.unmounted) {
clearTimeout(env.onChangeTimer);

@@ -234,6 +238,10 @@ env.onChangeTimer = setTimeout(function () {

graph.eachParent(path, function (field) {
field.setState(syncFieldIntialValues, true);
if (types_1.isField(field)) {
field.setState(syncFieldIntialValues, true);
}
});
graph.eachChildren(path, function (field) {
field.setState(syncFieldIntialValues);
if (types_1.isField(field)) {
field.setState(syncFieldIntialValues);
}
});

@@ -315,3 +323,3 @@ notifyFormInitialValuesChange();

initializeLazy(function () {
deleteFormValuesIn(path, true);
deleteFormValuesIn(path);
notifyTreeFromValues();

@@ -663,9 +671,17 @@ });

function setFormIn(path, key, value, silent) {
state.setState(function (state) {
var method = silent ? 'setSourceState' : 'setState';
state[method](function (state) {
shared_1.FormPath.setIn(state[key], transformDataPath(path), value);
if (key === 'values') {
state.modified = true;
}
}, silent);
}
function deleteFormIn(path, key, silent) {
state.setState(function (state) {
var method = silent ? 'setSourceState' : 'setState';
state[method](function (state) {
shared_1.FormPath.deleteIn(state[key], transformDataPath(path));
if (key === 'values') {
state.modified = true;
}
}, silent);

@@ -672,0 +688,0 @@ }

@@ -26,14 +26,10 @@ "use strict";

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var shared_1 = require("@formily/shared");
var immer_1 = __importStar(require("immer"));
var immer_1 = require("immer");
var hasProxy = !!shared_1.globalThisPolyfill.Proxy;
immer_1.setAutoFreeze(false);
immer_1.enablePatches();
var produce = new immer_1.Immer({
autoFreeze: false
}).produce;
exports.createStateModel = function (Factory) {

@@ -68,3 +64,3 @@ return (function (_super) {

else {
return immer_1.default(_this.state, function () { });
return produce(_this.state, function () { });
}

@@ -142,3 +138,3 @@ }

}
_this.state = immer_1.default(_this.state, function (draft) {
_this.state = produce(_this.state, function (draft) {
callback(draft);

@@ -155,3 +151,3 @@ if (shared_1.isFn(_this.props.computeState)) {

if (op === 'replace') {
if (!shared_1.isEqual(_this.state[path[0]], value)) {
if (path.length > 1 || !shared_1.isEqual(_this.state[path[0]], value)) {
_this.dirtys[path[0]] = true;

@@ -185,3 +181,3 @@ _this.dirtyNum++;

if (!_this.stackCount) {
_this.prevState = __assign({}, _this.state);
_this.prevState = _this.state;
}

@@ -200,3 +196,3 @@ }

_this.state = __assign({}, Factory.defaultState);
_this.prevState = __assign({}, Factory.defaultState);
_this.prevState = _this.state;
_this.props = shared_1.defaults(Factory.defaultProps, defaultProps);

@@ -203,0 +199,0 @@ _this.dirtys = {};

@@ -32,8 +32,2 @@ "use strict";

}
if (shared_1.isEqual(draft.initialValues, draft.values)) {
draft.pristine = true;
}
else {
draft.pristine = false;
}
if (draft.validating !== prevState.validating) {

@@ -58,3 +52,2 @@ if (draft.validating === true) {

_a.defaultState = {
pristine: true,
valid: true,

@@ -61,0 +54,0 @@ invalid: false,

@@ -75,3 +75,3 @@ /// <reference types="react" />

dirtyCheck?: (dirtys: StateDirtyMap<P>) => StateDirtyMap<P> | void;
computeState?: (state: Draft<P>, preState?: P) => Draft<P> | void;
computeState?: (state: Draft<P>, preState?: P, dirtys?: StateDirtyMap<P>) => Draft<P> | void;
}

@@ -156,3 +156,2 @@ export interface IStateModelFactory<S, P> {

export interface IFormState<FormProps = any> {
pristine: boolean;
valid: boolean;

@@ -159,0 +158,0 @@ invalid: boolean;

{
"name": "@formily/core",
"version": "1.1.1-beta.1",
"version": "1.1.1-beta.2",
"license": "MIT",

@@ -28,5 +28,5 @@ "main": "lib",

"dependencies": {
"@formily/shared": "^1.1.1-beta.1",
"@formily/validator": "^1.1.1-beta.1",
"immer": "^3.2.0"
"@formily/shared": "^1.1.1-beta.2",
"@formily/validator": "^1.1.1-beta.2",
"immer": "^6.0.3"
},

@@ -36,3 +36,3 @@ "publishConfig": {

},
"gitHead": "6f14fe66cbcce08d0cdbf1445b91716c74f41e46"
"gitHead": "4cb37a2b563b0168a4872322f7866c15c7e22138"
}

@@ -96,2 +96,3 @@ import {

function syncFieldIntialValues(state: IFieldState) {
if (state.name === '') return
const initialValue = getFormInitialValuesIn(state.name)

@@ -113,3 +114,7 @@ if (!isEqual(initialValue, state.initialValue)) {

function notifyFormValuesChange() {
if (isFn(options.onChange) && !state.state.unmounted) {
if (
isFn(options.onChange) &&
state.state.mounted &&
!state.state.unmounted
) {
clearTimeout(env.onChangeTimer)

@@ -241,6 +246,10 @@ env.onChangeTimer = setTimeout(() => {

graph.eachParent(path, (field: IField) => {
field.setState(syncFieldIntialValues, true)
if (isField(field)) {
field.setState(syncFieldIntialValues, true)
}
})
graph.eachChildren(path, (field: IField) => {
field.setState(syncFieldIntialValues)
if (isField(field)) {
field.setState(syncFieldIntialValues)
}
})

@@ -323,3 +332,3 @@ notifyFormInitialValuesChange()

initializeLazy(() => {
deleteFormValuesIn(path, true)
deleteFormValuesIn(path)
notifyTreeFromValues()

@@ -734,4 +743,8 @@ })

) {
state.setState(state => {
const method = silent ? 'setSourceState' : 'setState'
state[method](state => {
FormPath.setIn(state[key], transformDataPath(path), value)
if (key === 'values') {
state.modified = true
}
}, silent)

@@ -741,4 +754,8 @@ }

function deleteFormIn(path: FormPathPattern, key: string, silent?: boolean) {
state.setState(state => {
const method = silent ? 'setSourceState' : 'setState'
state[method](state => {
FormPath.deleteIn(state[key], transformDataPath(path))
if (key === 'values') {
state.modified = true
}
}, silent)

@@ -745,0 +762,0 @@ }

@@ -14,3 +14,3 @@ import {

} from '@formily/shared'
import produce, { Draft, setAutoFreeze } from 'immer'
import { Draft, Immer, enablePatches } from 'immer'
import {

@@ -25,4 +25,8 @@ IStateModelProvider,

setAutoFreeze(false)
enablePatches()
const { produce } = new Immer({
autoFreeze: false
})
export const createStateModel = <State = {}, Props = {}>(

@@ -51,3 +55,3 @@ Factory: IStateModelFactory<State, Props>

this.state = { ...Factory.defaultState }
this.prevState = { ...Factory.defaultState }
this.prevState = this.state
this.props = defaults(Factory.defaultProps, defaultProps)

@@ -186,3 +190,3 @@ this.dirtys = {}

if (op === 'replace') {
if (!isEqual(this.state[path[0]], value)) {
if (path.length > 1 ||!isEqual(this.state[path[0]], value)) {
this.dirtys[path[0]] = true

@@ -217,3 +221,3 @@ this.dirtyNum++

if (!this.stackCount) {
this.prevState = { ...this.state }
this.prevState = this.state
}

@@ -220,0 +224,0 @@ }

@@ -11,3 +11,2 @@ import { createStateModel } from '../shared/model'

static defaultState = {
pristine: true,
valid: true,

@@ -60,8 +59,2 @@ invalid: false,

}
if (isEqual(draft.initialValues, draft.values)) {
draft.pristine = true
} else {
draft.pristine = false
}

@@ -68,0 +61,0 @@ if (draft.validating !== prevState.validating) {

@@ -112,3 +112,7 @@ import { FormPath, FormPathPattern, isFn, Subscribable } from '@formily/shared'

dirtyCheck?: (dirtys: StateDirtyMap<P>) => StateDirtyMap<P> | void
computeState?: (state: Draft<P>, preState?: P) => Draft<P> | void
computeState?: (
state: Draft<P>,
preState?: P,
dirtys?: StateDirtyMap<P>
) => Draft<P> | void
}

@@ -228,3 +232,2 @@

export interface IFormState<FormProps = any> {
pristine: boolean
valid: boolean

@@ -231,0 +234,0 @@ invalid: boolean

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