From d95756749025186b2cd6273f9e340455b309cc81 Mon Sep 17 00:00:00 2001 From: Janry Date: Fri, 27 Dec 2019 17:10:02 +0800 Subject: [PATCH] Fix text box (#553) --- packages/antd/src/components/FormTextBox.tsx | 5 +++-- packages/core/README.md | 2 +- packages/core/README.zh-cn.md | 2 +- packages/next/src/components/FormTextBox.tsx | 5 +++-- packages/react-schema-renderer/README.md | 2 +- packages/react-schema-renderer/README.zh-cn.md | 2 +- packages/react/README.md | 2 +- packages/react/README.zh-cn.md | 2 +- packages/validator/src/rules.ts | 4 ++-- packages/validator/src/types.ts | 2 +- 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/antd/src/components/FormTextBox.tsx b/packages/antd/src/components/FormTextBox.tsx index 771177680f0..b0c633d7f41 100644 --- a/packages/antd/src/components/FormTextBox.tsx +++ b/packages/antd/src/components/FormTextBox.tsx @@ -1,5 +1,5 @@ import React, { useRef, useLayoutEffect } from 'react' -import { createControllerBox } from '@uform/react-schema-renderer' +import { createControllerBox, Schema } from '@uform/react-schema-renderer' import { IFormTextBox } from '../types' import { toArr } from '@uform/shared' import { CompatAntdFormItem } from '../compat/FormItem' @@ -8,6 +8,7 @@ import styled from 'styled-components' export const FormTextBox = createControllerBox( 'text-box', styled(({ props, className, children }) => { + const schema = new Schema(props) const { title, help, @@ -21,7 +22,7 @@ export const FormTextBox = createControllerBox( { gutter: 5 }, - props['x-component-props'] + schema.getExtendsComponentProps() ) const ref: React.RefObject = useRef() const arrChildren = toArr(children) diff --git a/packages/core/README.md b/packages/core/README.md index 5c38d125252..34d5425f777 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -717,7 +717,7 @@ interface IMutators { ```typescript type CustomValidator = ( value: any, - rescription?: ValidateDescription + description?: ValidateDescription ) => ValidateResponse type SyncValidateResponse = | null diff --git a/packages/core/README.zh-cn.md b/packages/core/README.zh-cn.md index 581aaa9b38a..c9e2f696086 100644 --- a/packages/core/README.zh-cn.md +++ b/packages/core/README.zh-cn.md @@ -742,7 +742,7 @@ interface IMutators { ```typescript type CustomValidator = ( value: any, - rescription?: ValidateDescription + description?: ValidateDescription ) => ValidateResponse type SyncValidateResponse = | null diff --git a/packages/next/src/components/FormTextBox.tsx b/packages/next/src/components/FormTextBox.tsx index 84ced3ff485..d3facbd2d50 100644 --- a/packages/next/src/components/FormTextBox.tsx +++ b/packages/next/src/components/FormTextBox.tsx @@ -1,5 +1,5 @@ import React, { useRef, useLayoutEffect } from 'react' -import { createControllerBox } from '@uform/react-schema-renderer' +import { createControllerBox, Schema } from '@uform/react-schema-renderer' import { IFormTextBox } from '../types' import { toArr } from '@uform/shared' import { CompatNextFormItem } from '../compat/FormItem' @@ -8,6 +8,7 @@ import styled from 'styled-components' export const FormTextBox = createControllerBox( 'text-box', styled(({ props, className, children }) => { + const schema = new Schema(props) const { title, help, @@ -21,7 +22,7 @@ export const FormTextBox = createControllerBox( { gutter: 5 }, - props['x-component-props'] + schema.getExtendsComponentProps() ) const ref: React.RefObject = useRef() const arrChildren = toArr(children) diff --git a/packages/react-schema-renderer/README.md b/packages/react-schema-renderer/README.md index fb077668476..d384e0657d2 100644 --- a/packages/react-schema-renderer/README.md +++ b/packages/react-schema-renderer/README.md @@ -1901,7 +1901,7 @@ type ValidateResponse = SyncValidateResponse | AsyncValidateResponse ```typescript type CustomValidator = ( value: any, - rescription?: ValidateDescription + description?: ValidateDescription ) => ValidateResponse ``` diff --git a/packages/react-schema-renderer/README.zh-cn.md b/packages/react-schema-renderer/README.zh-cn.md index 72f4b02010f..ccd530b475e 100644 --- a/packages/react-schema-renderer/README.zh-cn.md +++ b/packages/react-schema-renderer/README.zh-cn.md @@ -1907,7 +1907,7 @@ type ValidateResponse = SyncValidateResponse | AsyncValidateResponse ```typescript type CustomValidator = ( value: any, - rescription?: ValidateDescription + description?: ValidateDescription ) => ValidateResponse ``` diff --git a/packages/react/README.md b/packages/react/README.md index bc73b8f5680..3c36baa78e7 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -3149,7 +3149,7 @@ type InternalFormats = ```typescript declare type CustomValidator = ( value: any, - rescription?: ValidateDescription + description?: ValidateDescription ) => ValidateResponse ``` diff --git a/packages/react/README.zh-cn.md b/packages/react/README.zh-cn.md index cbbaad61bb3..69132c2aeb9 100644 --- a/packages/react/README.zh-cn.md +++ b/packages/react/README.zh-cn.md @@ -3194,7 +3194,7 @@ type InternalFormats = ```typescript declare type CustomValidator = ( value: any, - rescription?: ValidateDescription + description?: ValidateDescription ) => ValidateResponse ``` diff --git a/packages/validator/src/rules.ts b/packages/validator/src/rules.ts index a4be38ed7a7..4130f873b65 100644 --- a/packages/validator/src/rules.ts +++ b/packages/validator/src/rules.ts @@ -3,16 +3,16 @@ import { isEmpty, stringLength, isStr, + isArr, isFn, toArr, - isArr, isBool } from '@uform/shared' import { ValidateDescription } from './types' const isValidateEmpty = (value: any) => { if (isArr(value)) { for (let i = 0; i < value.length; i++) { - if (!isValidateEmpty(value[i])) return false + if (value[i] !== undefined) return false } return true } else { diff --git a/packages/validator/src/types.ts b/packages/validator/src/types.ts index 1ce13895917..e26447b14ca 100644 --- a/packages/validator/src/types.ts +++ b/packages/validator/src/types.ts @@ -67,7 +67,7 @@ export type ValidatePatternRules = export type CustomValidator = ( value: any, - rescription?: ValidateDescription + description?: ValidateDescription ) => ValidateResponse export type SyncValidateResponse =