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

@uform/core

Package Overview
Dependencies
Maintainers
4
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uform/core - npm Package Compare versions

Comparing version 0.3.11 to 0.4.0-beta.0

src/__test__/form.spec.js

3

lib/field.js

@@ -64,2 +64,5 @@ "use strict";

}
if (options.initialValue) {
this.lastValidateValue = options.initialValue;
}
if (this.pristine &&

@@ -66,0 +69,0 @@ !utils_1.isEmpty(this.initialValue) &&

26

lib/form.d.ts
import { Field } from './field';
import { Subject } from 'rxjs/internal/Subject';
import { IFormOptions, IFieldOptions, IFieldState, IField, IFormPathMatcher, Path } from '@uform/types';
import { IFormOptions, IFieldOptions, IFieldState, IField, IFormPathMatcher, IFormState, Path } from '@uform/types';
declare type Editable = boolean | ((name: string) => boolean);

@@ -27,15 +27,9 @@ export declare class Form {

isDirtyValues(values: any): boolean;
setFieldState: (path: string | number | (string | number)[] | IFormPathMatcher, callback?: (fieldState: IFieldState) => void) => Promise<unknown>;
getFieldState: (path: string | number | (string | number)[] | IFormPathMatcher, callback: (fieldState: IFieldState) => any) => void | IFieldState;
getFormState: (callback: any) => void | {
values: any;
valid: any;
invalid: any;
errors: any;
pristine: any;
dirty: any;
initialValues: any;
};
setFormState: (reducer: any) => Promise<any>;
registerField(name: string, options: IFieldOptions): IField;
setFieldState: (path: string | number | (string | number)[] | IFormPathMatcher, callback: (fieldState: IFieldState) => void) => Promise<void>;
getFieldState(path: Path | IFormPathMatcher, callback: (fieldState: IFieldState) => void): void;
getFieldState(path: Path | IFormPathMatcher): IFieldState;
getFormState(callback: (formState: IFormState) => void): void;
getFormState(): IFormState;
setFormState: (callback: (formState: IFormState<any>) => void) => Promise<any>;
registerField(name: string, options: IFieldOptions): IField<any>;
setIn(name: string, value: any): void;

@@ -74,4 +68,4 @@ setInitialValueIn(name: string, value: any): void;

};
validate(): Promise<unknown>;
submit(): Promise<unknown>;
validate(): Promise<IFormState>;
submit(): Promise<IFormState<any>>;
subscribe(callback: (payload: any) => void): () => any;

@@ -78,0 +72,0 @@ destructor(): void;

@@ -21,3 +21,3 @@ "use strict";

var defaults = function (opts) {
return (__assign({ initialValues: {}, values: {}, onSubmit: function (values) { }, effects: function ($) { } }, opts));
return (__assign({ initialValues: {}, values: {}, onSubmit: function () { }, effects: function () { } }, opts));
};

@@ -55,29 +55,11 @@ var Form = (function () {

};
this.getFieldState = function (path, callback) {
var field;
utils_1.each(_this.fields, function (innerField) {
if (innerField.match(path)) {
field = innerField;
return false;
}
});
if (field) {
field.syncContextValue();
return utils_1.isFn(callback)
? callback(field.publishState())
: field.publishState();
}
};
this.getFormState = function (callback) {
return utils_1.isFn(callback) ? callback(_this.publishState()) : _this.publishState();
};
this.setFormState = function (reducer) {
this.setFormState = function (callback) {
if (_this.destructed) {
return;
}
if (!utils_1.isFn(reducer)) {
if (!utils_1.isFn(callback)) {
return;
}
var published = _this.publishState();
reducer(published, reducer);
callback(published);
return Promise.resolve(_this.checkState(published));

@@ -107,2 +89,4 @@ };

};
this.getFieldState = this.getFieldState.bind(this);
this.getFormState = this.getFormState.bind(this);
this.options = defaults(opts);

@@ -138,3 +122,3 @@ this.publisher = new utils_1.Broadcast();

this.editable = editable;
utils_1.each(this.fields, function (field, name) {
utils_1.each(this.fields, function (field) {
field.changeEditable(editable);

@@ -146,2 +130,20 @@ });

};
Form.prototype.getFieldState = function (path, callback) {
var field;
utils_1.each(this.fields, function (innerField) {
if (innerField.match(path)) {
field = innerField;
return false;
}
});
if (field) {
field.syncContextValue();
return utils_1.isFn(callback)
? callback(field.publishState())
: field.publishState();
}
};
Form.prototype.getFormState = function (callback) {
return utils_1.isFn(callback) ? callback(this.publishState()) : this.publishState();
};
Form.prototype.registerField = function (name, options) {

@@ -148,0 +150,0 @@ var _this = this;

@@ -6,4 +6,4 @@ import { IFormOptions } from '@uform/types';

export * from './path';
export declare const createForm: ({ initialValues, values, onSubmit, onReset, schema, onFormChange, onFieldChange, onFormWillInit, subscribes, editable, effects, onValidateFailed, traverse }: IFormOptions) => Form;
export declare const createForm: ({ initialValues, values, onSubmit, onReset, schema, onFormChange, onFieldChange, onFormWillInit, subscribes, editable, effects, onValidateFailed, traverse }: IFormOptions<any>) => Form;
export { setValidationLocale, setValidationLanguage, Form, calculateSchemaInitialValues };
export default createForm;
{
"name": "@uform/core",
"version": "0.3.11",
"version": "0.4.0-beta.0",
"license": "MIT",

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

"dependencies": {
"@uform/types": "^0.3.11",
"@uform/utils": "^0.3.11",
"@uform/validator": "^0.3.11",
"@uform/types": "^0.4.0-beta.0",
"@uform/utils": "^0.4.0-beta.0",
"@uform/validator": "^0.4.0-beta.0",
"dot-match": "^0.1.18",

@@ -39,3 +39,3 @@ "rxjs": "^6.3.3"

},
"gitHead": "fb1ebbb1613b89775378748b90a7854efb9c1c2e"
"gitHead": "197f94a17cb1ba4f3ec8ccb1f8e35a4d684c9f48"
}

@@ -134,2 +134,6 @@ import {

if (options.initialValue) {
this.lastValidateValue = options.initialValue
}
if (

@@ -136,0 +140,0 @@ this.pristine &&

@@ -47,4 +47,4 @@ import {

values: {},
onSubmit: (values: any) => {},
effects: ($: any) => {},
onSubmit: () => {},
effects: () => {},
...opts

@@ -89,2 +89,4 @@ } as T)

constructor(opts: IFormOptions) {
this.getFieldState = this.getFieldState.bind(this)
this.getFormState = this.getFormState.bind(this)
this.options = defaults<IFormOptions>(opts)

@@ -122,3 +124,3 @@ this.publisher = new Broadcast()

this.editable = editable
each(this.fields, (field, name) => {
each(this.fields, field => {
field.changeEditable(editable)

@@ -134,4 +136,4 @@ })

path: Path | IFormPathMatcher,
callback?: (fieldState: IFieldState) => void
) => {
callback: (fieldState: IFieldState) => void
): Promise<void> => {
if (this.destructed) {

@@ -163,6 +165,12 @@ return

public getFieldState = (
public getFieldState(
path: Path | IFormPathMatcher,
callback: (fieldState: IFieldState) => any
) => {
callback: (fieldState: IFieldState) => void
): void
public getFieldState(path: Path | IFormPathMatcher): IFieldState
public getFieldState(
path: Path | IFormPathMatcher,
callback?: (fieldState: IFieldState) => void
): any {
let field: IField

@@ -183,15 +191,17 @@ each(this.fields, innerField => {

public getFormState = (callback: any) => {
public getFormState(callback: (formState: IFormState) => void): void
public getFormState(): IFormState
public getFormState(callback?: any): any {
return isFn(callback) ? callback(this.publishState()) : this.publishState()
}
public setFormState = reducer => {
public setFormState = (callback: (formState: IFormState) => void) => {
if (this.destructed) {
return
}
if (!isFn(reducer)) {
if (!isFn(callback)) {
return
}
const published = this.publishState()
reducer(published, reducer)
callback(published)
return Promise.resolve(this.checkState(published))

@@ -528,3 +538,3 @@ }

public validate() {
public validate(): Promise<IFormState> {
return this.internalValidate(this.state.values, true).then(() => {

@@ -551,3 +561,3 @@ return new Promise((resolve, reject) => {

public submit() {
return this.validate().then(formState => {
return this.validate().then((formState: IFormState) => {
this.dispatchEffect('onFormSubmit', formState)

@@ -554,0 +564,0 @@ if (isFn(this.options.onSubmit)) {

@@ -26,3 +26,3 @@ import { Path, IFormPathMatcher } from '@uform/types'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const scheduler = require('scheduler')
const scheduler = require('scheduler') as any
return compactScheduler(

@@ -29,0 +29,0 @@ [

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