maishu-dilu-react
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -20,4 +20,5 @@ { | ||
"@babel/plugin-transform-runtime": "^7.12.10", | ||
"@babel/plugin-transform-typescript": "^7.8.3" | ||
"@babel/plugin-transform-typescript": "^7.8.3", | ||
"@babel/preset-env": "^7.13.9" | ||
} | ||
} |
/*! | ||
* | ||
* maishu-dilu-react v1.1.0 | ||
* maishu-dilu-react v1.2.0 | ||
* Copyright (c) 2016-2018, shu mai <ansiboy@163.com> | ||
@@ -115,3 +115,3 @@ * Licensed under the MIT License. | ||
* | ||
* maishu-dilu v1.8.6 | ||
* maishu-dilu v1.9.1 | ||
* https://github.com/ansiboy/dilu | ||
@@ -811,3 +811,3 @@ * | ||
element.type = 'text/css'; | ||
element.id = "maishu-jueying-core-style"; | ||
element.id = elementId; | ||
document.head.appendChild(element); | ||
@@ -851,4 +851,11 @@ element.innerHTML = ` | ||
} | ||
field(value, rules, name) { | ||
return React.createElement(value_validator_1.FieldValidator, { value: value, rules: rules, name: name, ref: e => { | ||
field(value, rules, conditionOrName, name) { | ||
let condition; | ||
if (typeof conditionOrName == "function") { | ||
condition = conditionOrName; | ||
} | ||
else { | ||
name = conditionOrName; | ||
} | ||
return React.createElement(value_validator_1.FieldValidator, { value: value, rules: rules, name: name, condition: condition, ref: e => { | ||
if (e == null || this._fieldValidators.indexOf(e) >= 0) | ||
@@ -932,2 +939,6 @@ return; | ||
let { value, rules } = props; | ||
if (this.props.condition != null && this.props.condition() == false) { | ||
this.setState({ errorMessage: "" }); | ||
return true; | ||
} | ||
let result = true; | ||
@@ -934,0 +945,0 @@ for (let i = 0; i < rules.length; i++) { |
@@ -1,10 +0,11 @@ | ||
/// <reference types="react" /> | ||
import { Rule } from "maishu-dilu"; | ||
import { FieldValidator } from "./value-validator"; | ||
import { FieldValidator, ValidityCondition } from "./value-validator"; | ||
export declare class FormValidator { | ||
private _fieldValidators; | ||
get fieldValidators(): FieldValidator[]; | ||
field(value: any, rules: Rule[], name?: string): JSX.Element; | ||
field(value: any, rules: Rule[], condition?: ValidityCondition): any; | ||
field(value: any, rules: Rule[], name?: string): any; | ||
field(value: any, rules: Rule[], condition: ValidityCondition, name: string): any; | ||
check(): boolean; | ||
clearErrors(): void; | ||
} |
@@ -13,4 +13,11 @@ "use strict"; | ||
} | ||
field(value, rules, name) { | ||
return React.createElement(value_validator_1.FieldValidator, { value: value, rules: rules, name: name, ref: e => { | ||
field(value, rules, conditionOrName, name) { | ||
let condition; | ||
if (typeof conditionOrName == "function") { | ||
condition = conditionOrName; | ||
} | ||
else { | ||
name = conditionOrName; | ||
} | ||
return React.createElement(value_validator_1.FieldValidator, { value: value, rules: rules, name: name, condition: condition, ref: e => { | ||
if (e == null || this._fieldValidators.indexOf(e) >= 0) | ||
@@ -17,0 +24,0 @@ return; |
import { ClassAttributes } from "react"; | ||
import { Rule } from "maishu-dilu"; | ||
import * as React from "react"; | ||
export declare type ValidityCondition = () => boolean; | ||
export interface FieldValidatorProps extends ClassAttributes<FieldValidator> { | ||
@@ -8,2 +9,3 @@ value: any; | ||
name?: string; | ||
condition?: ValidityCondition; | ||
} | ||
@@ -10,0 +12,0 @@ export interface FieldValidatorState { |
@@ -25,2 +25,6 @@ "use strict"; | ||
let { value, rules } = props; | ||
if (this.props.condition != null && this.props.condition() == false) { | ||
this.setState({ errorMessage: "" }); | ||
return true; | ||
} | ||
let result = true; | ||
@@ -27,0 +31,0 @@ for (let i = 0; i < rules.length; i++) { |
{ | ||
"name": "maishu-dilu-react", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"main": "./dist/idnex", | ||
@@ -9,6 +9,6 @@ "types": "./out/index.d.ts", | ||
"@types/react": "^17.0.2", | ||
"maishu-dilu": "^1.8.6", | ||
"maishu-dilu": "^1.9.1", | ||
"webpack": "^4.30.0", | ||
"webpack-cli": "^3.3.0" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
393790
7823