From ec3a5bc4611ffe14a90c10a78dbe065af93a0cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Wed, 2 Jun 2021 10:09:02 +0800 Subject: [PATCH] feat: rules support `warningOnly` (#304) * 1.20.1 * feat: Support onError event * fix: Every update errors should trigger event * test: Test driven of onError * feat: All message support variable * fix: Fill template logic * feat: support warning * test: Test driven * chore: export getFieldWarning * fix: summary validate logic * test: Update coverage * test: Update coverage --- docs/examples/components/LabelField.tsx | 12 +- docs/examples/validate-perf.tsx | 18 +- docs/examples/validate.tsx | 262 ++++++++++++------------ src/Field.tsx | 88 ++++++-- src/FieldContext.ts | 3 +- src/interface.ts | 21 +- src/useForm.ts | 91 +++++--- src/utils/asyncUtil.ts | 2 +- src/utils/validateUtil.ts | 226 ++++++++++---------- tests/common/InfoField.tsx | 13 +- tests/common/index.ts | 19 +- tests/context.test.js | 9 +- tests/index.test.js | 23 ++- tests/validate-warning.test.tsx | 93 +++++++++ tests/validate.test.tsx | 8 +- 15 files changed, 561 insertions(+), 327 deletions(-) create mode 100644 tests/validate-warning.test.tsx diff --git a/docs/examples/components/LabelField.tsx b/docs/examples/components/LabelField.tsx index 2790fa9e..2608f2bd 100644 --- a/docs/examples/components/LabelField.tsx +++ b/docs/examples/components/LabelField.tsx @@ -1,11 +1,16 @@ import * as React from 'react'; import Form from 'rc-field-form'; -import { FieldProps } from '@/Field'; +import type { FieldProps } from '@/Field'; const { Field } = Form; -const Error = ({ children }) => ( -