This repository was archived by the owner on Feb 29, 2024. It is now read-only.
File tree 5 files changed +17
-14
lines changed
5 files changed +17
-14
lines changed Original file line number Diff line number Diff line change 1
1
### 0.1.1 (November 21, 2017)
2
- - added possibility to add props to form element via [ formProps ] ( https://github.com/cat-react/form/blob/master/docs/api.md#formprops ) prop
2
+ - now it is possible to add an [ autoComplete ] ( https://github.com/cat-react/form/blob/master/docs/api.md#autocomplete ) prop to the form element
3
3
- the validation rule ` isRequired ` now checks for ` undefined ` , ` null ` or an empty string. everything else is valid
4
4
5
5
### 0.1.0 (October 3, 2017)
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ Welcome to the `@cat-react/form` API documentation.
11
11
- [ onValid] ( #onvalidvalues )
12
12
- [ onInvalid] ( #oninvalidvalues-isvalidating )
13
13
- [ className] ( #classname )
14
- - [ formProps ] ( #formprops )
14
+ - [ autoComplete ] ( #autocomplete )
15
15
- [ Input] ( #input ) (HOC for building input fields)
16
16
- Retrieves
17
17
- [ value] ( #value )
@@ -308,12 +308,12 @@ will result in:
308
308
309
309
---
310
310
311
- ### formProps
312
- Props which will be passed directly to the <form > html element.
311
+ ### autoComplete
312
+ AutoComplete prop which will be passed directly to the <form > html element.
313
313
314
314
For example:
315
315
``` jsx
316
- < Form formProps = {{autocomplete : ' off' }} / >
316
+ < Form autoComplete = " off" / >
317
317
```
318
318
319
319
will result in:
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ export default class extends React.Component {
42
42
< Form onValid = { this . onValid }
43
43
onInvalid = { this . onInvalid }
44
44
onSubmit = { this . onSubmit }
45
- onValidSubmit = { this . onValidSubmit } >
45
+ onValidSubmit = { this . onValidSubmit }
46
+ autoComplete = "off" >
46
47
< h1 > Login</ h1 >
47
48
< BasicInput label = "Email address"
48
49
name = "email"
Original file line number Diff line number Diff line change @@ -205,10 +205,15 @@ export default class Form extends React.Component {
205
205
}
206
206
207
207
render ( ) {
208
- const { children, className, formProps} = this . props ;
208
+ const { children, className, autoComplete} = this . props ;
209
+
210
+ const formProps = {
211
+ className,
212
+ autoComplete
213
+ } ;
209
214
210
215
return (
211
- < form className = { className } { ...formProps } onSubmit = { this . onSubmit } >
216
+ < form { ...formProps } onSubmit = { this . onSubmit } >
212
217
{ children }
213
218
</ form >
214
219
) ;
Original file line number Diff line number Diff line change @@ -43,12 +43,9 @@ describe('Form', () => {
43
43
expect ( onInvalid ) . not . toHaveBeenCalled ( ) ;
44
44
} ) ;
45
45
46
- it ( 'should pass all props' , ( ) => {
47
- let wrapper = shallow ( < Form className = "myForm" formProps = { { autocomplete : 'off' , fantasy : true } } > < span className = "abc" > abc</ span > </ Form > ) ;
48
- const props = wrapper . props ( ) ;
49
- expect ( props . autocomplete ) . toBe ( 'off' ) ;
50
- expect ( props . className ) . toBe ( 'myForm' ) ;
51
- expect ( props . fantasy ) . toBe ( true ) ;
46
+ it ( 'should pass all props correctly' , ( ) => {
47
+ let wrapper = shallow ( < Form className = "myForm" autoComplete = "off" > < span className = "abc" > abc</ span > </ Form > ) ;
48
+ expect ( wrapper . html ( ) ) . toBe ( '<form class="myForm" autocomplete="off"><span class="abc">abc</span></form>' ) ;
52
49
} ) ;
53
50
54
51
it ( 'should add the vaidationRule' , ( ) => {
You can’t perform that action at this time.
0 commit comments