Skip to content

Commit

Permalink
Fix text box (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang authored Dec 27, 2019
1 parent 9c513d0 commit d957567
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 13 deletions.
5 changes: 3 additions & 2 deletions packages/antd/src/components/FormTextBox.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -8,6 +8,7 @@ import styled from 'styled-components'
export const FormTextBox = createControllerBox<IFormTextBox>(
'text-box',
styled(({ props, className, children }) => {
const schema = new Schema(props)
const {
title,
help,
Expand All @@ -21,7 +22,7 @@ export const FormTextBox = createControllerBox<IFormTextBox>(
{
gutter: 5
},
props['x-component-props']
schema.getExtendsComponentProps()
)
const ref: React.RefObject<HTMLDivElement> = useRef()
const arrChildren = toArr(children)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ interface IMutators {
```typescript
type CustomValidator = (
value: any,
rescription?: ValidateDescription
description?: ValidateDescription
) => ValidateResponse
type SyncValidateResponse =
| null
Expand Down
2 changes: 1 addition & 1 deletion packages/core/README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ interface IMutators {
```typescript
type CustomValidator = (
value: any,
rescription?: ValidateDescription
description?: ValidateDescription
) => ValidateResponse
type SyncValidateResponse =
| null
Expand Down
5 changes: 3 additions & 2 deletions packages/next/src/components/FormTextBox.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -8,6 +8,7 @@ import styled from 'styled-components'
export const FormTextBox = createControllerBox<IFormTextBox>(
'text-box',
styled(({ props, className, children }) => {
const schema = new Schema(props)
const {
title,
help,
Expand All @@ -21,7 +22,7 @@ export const FormTextBox = createControllerBox<IFormTextBox>(
{
gutter: 5
},
props['x-component-props']
schema.getExtendsComponentProps()
)
const ref: React.RefObject<HTMLDivElement> = useRef()
const arrChildren = toArr(children)
Expand Down
2 changes: 1 addition & 1 deletion packages/react-schema-renderer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ type ValidateResponse = SyncValidateResponse | AsyncValidateResponse
```typescript
type CustomValidator = (
value: any,
rescription?: ValidateDescription
description?: ValidateDescription
) => ValidateResponse
```
Expand Down
2 changes: 1 addition & 1 deletion packages/react-schema-renderer/README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ type ValidateResponse = SyncValidateResponse | AsyncValidateResponse
```typescript
type CustomValidator = (
value: any,
rescription?: ValidateDescription
description?: ValidateDescription
) => ValidateResponse
```
Expand Down
2 changes: 1 addition & 1 deletion packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ type InternalFormats =
```typescript
declare type CustomValidator = (
value: any,
rescription?: ValidateDescription
description?: ValidateDescription
) => ValidateResponse
```

Expand Down
2 changes: 1 addition & 1 deletion packages/react/README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -3194,7 +3194,7 @@ type InternalFormats =
```typescript
declare type CustomValidator = (
value: any,
rescription?: ValidateDescription
description?: ValidateDescription
) => ValidateResponse
```

Expand Down
4 changes: 2 additions & 2 deletions packages/validator/src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/validator/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type ValidatePatternRules =

export type CustomValidator = (
value: any,
rescription?: ValidateDescription
description?: ValidateDescription
) => ValidateResponse

export type SyncValidateResponse =
Expand Down

0 comments on commit d957567

Please sign in to comment.