Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

formulr

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formulr - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

9

lib/field-array.d.ts
import { FieldArrayModel, BasicModel, FieldArrayChild, ModelRef } from './models';
import { IValidators } from './validate';
export declare type IUseFieldArray<Item, Child extends BasicModel<Item>> = [FieldArrayChild<Item, Child>[], FieldArrayModel<Item, Child>];
/**
* @param field 字段名,当`FormStrategy`是`View`的时候才能用字段名
* @param validators 当`field`是字段名的时候,可以传入`validator`
* @param defaultValue 默认值
*/
export declare function useFieldArray<Item, Child extends BasicModel<Item>>(field: string | ModelRef<readonly Item[], any, FieldArrayModel<Item, Child>>, validators?: IValidators<readonly (Item | null)[]>, defaultValue?: Item[]): FieldArrayModel<Item, Child>;
/**
*
* @param field model
*/
export declare function useFieldArray<Item, Child extends BasicModel<Item>>(field: FieldArrayModel<Item, Child>): FieldArrayModel<Item, Child>;
//# sourceMappingURL=field-array.d.ts.map

4

lib/field-set.d.ts

@@ -5,3 +5,7 @@ import { IFormContext } from './context';

export declare type IUseFieldSet<T extends Record<string, BasicModel<any>>> = [IFormContext, FieldSetModel<T>];
/**
* @param field model 或者字段名,当`FormStrategy`是`View`的时候才能用字段名
* @param validators 当`field`是字段名的时候,可以传入`validator`
*/
export declare function useFieldSet<T extends Record<string, BasicModel<any>>>(field: string | FieldSetModel<T> | ModelRef<$FieldSetValue<T>, any, FieldSetModel<T>>, validators?: IValidators<T>): IUseFieldSet<T>;
//# sourceMappingURL=field-set.d.ts.map

@@ -52,2 +52,6 @@ import { useMemo } from 'react';

}
/**
* @param field model 或者字段名,当`FormStrategy`是`View`的时候才能用字段名
* @param validators 当`field`是字段名的时候,可以传入`validator`
*/
export function useFieldSet(field, validators) {

@@ -54,0 +58,0 @@ if (validators === void 0) { validators = []; }

@@ -24,3 +24,28 @@ import { FieldModel } from './models/field';

/**
* This triggers a validation
* 生成一个默认的`onChange`回调,这个回调会触发`model.validate`
* 如果不需要在onChange的时候触发校验,如下即可:
* ```js
* const onChange = useCallback(value => model.value = value, [model]);
* ```
* 例如是一个`input`:
* ```ts
* const onChange = useCallback((value: React.ChangeEvent<HTMLInputElement>) => {
* model.value = e.target.value;
* }, [model]);
* ```
* 可以配合usePipe使用:
* ```js
* function mapEventToValue(e) {
* return e.target.value;
* }
*
* function Foo() {
* const onChange = FieldUtils.usePipe(
* mapEventToValue,
* FieldUtils.makeChangeHandler(model),
* );
* }
*
*
* ```
*/

@@ -27,0 +52,0 @@ export declare function makeChangeHandler<Value>(model: FieldModel<Value>, option: ValidateOption): (value: Value) => void;

@@ -38,3 +38,28 @@ import { useCallback, useMemo, useRef } from 'react';

/**
* This triggers a validation
* 生成一个默认的`onChange`回调,这个回调会触发`model.validate`
* 如果不需要在onChange的时候触发校验,如下即可:
* ```js
* const onChange = useCallback(value => model.value = value, [model]);
* ```
* 例如是一个`input`:
* ```ts
* const onChange = useCallback((value: React.ChangeEvent<HTMLInputElement>) => {
* model.value = e.target.value;
* }, [model]);
* ```
* 可以配合usePipe使用:
* ```js
* function mapEventToValue(e) {
* return e.target.value;
* }
*
* function Foo() {
* const onChange = FieldUtils.usePipe(
* mapEventToValue,
* FieldUtils.makeChangeHandler(model),
* );
* }
*
*
* ```
*/

@@ -41,0 +66,0 @@ export function makeChangeHandler(model, option) {

import { FieldModel, ModelRef } from './models';
import { IValidators } from './validate';
/**
* @param field 字段名,当`FormStrategy`是`View`的时候才能用字段名
* @param validators 当`field`是字段名的时候,可以传入`validator`
* @param defaultValue 默认值
*/
export declare function useField<Value>(field: string, defaultValue: Value | (() => Value), validators?: IValidators<Value>): FieldModel<Value>;
/**
*
* @param field model
*/
export declare function useField<Value>(field: FieldModel<Value> | ModelRef<Value, any, FieldModel<Value>>): FieldModel<Value>;
//# sourceMappingURL=field.d.ts.map

4

package.json
{
"name": "formulr",
"version": "0.2.0",
"version": "0.2.1",
"description": "Form toolkit for React",

@@ -33,3 +33,2 @@ "keywords": [

"dependencies": {
"@types/big.js": "^4.0.5",
"big.js": "^5.2.2",

@@ -43,2 +42,3 @@ "rxjs": "^6.4.0",

"@babel/preset-react": "^7.0.0",
"@types/big.js": "^4.0.5",
"@types/react": "^16.8.0",

@@ -45,0 +45,0 @@ "@types/react-dom": "^16.8.0",

@@ -82,3 +82,28 @@ import { useCallback, useMemo, useRef } from 'react';

/**
* This triggers a validation
* 生成一个默认的`onChange`回调,这个回调会触发`model.validate`
* 如果不需要在onChange的时候触发校验,如下即可:
* ```js
* const onChange = useCallback(value => model.value = value, [model]);
* ```
* 例如是一个`input`:
* ```ts
* const onChange = useCallback((value: React.ChangeEvent<HTMLInputElement>) => {
* model.value = e.target.value;
* }, [model]);
* ```
* 可以配合usePipe使用:
* ```js
* function mapEventToValue(e) {
* return e.target.value;
* }
*
* function Foo() {
* const onChange = FieldUtils.usePipe(
* mapEventToValue,
* FieldUtils.makeChangeHandler(model),
* );
* }
*
*
* ```
*/

@@ -85,0 +110,0 @@ export function makeChangeHandler<Value>(model: FieldModel<Value>, option: ValidateOption) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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