This repository was archived by the owner on Feb 29, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11### 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
33- the validation rule ` isRequired ` now checks for ` undefined ` , ` null ` or an empty string. everything else is valid
44
55### 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.
1111 - [ onValid] ( #onvalidvalues )
1212 - [ onInvalid] ( #oninvalidvalues-isvalidating )
1313 - [ className] ( #classname )
14- - [ formProps ] ( #formprops )
14+ - [ autoComplete ] ( #autocomplete )
1515- [ Input] ( #input ) (HOC for building input fields)
1616 - Retrieves
1717 - [ value] ( #value )
@@ -308,12 +308,12 @@ will result in:
308308
309309---
310310
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.
313313
314314For example:
315315``` jsx
316- < Form formProps = {{autocomplete : ' off' }} / >
316+ < Form autoComplete = " off" / >
317317```
318318
319319will result in:
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ export default class extends React.Component {
4242 < Form onValid = { this . onValid }
4343 onInvalid = { this . onInvalid }
4444 onSubmit = { this . onSubmit }
45- onValidSubmit = { this . onValidSubmit } >
45+ onValidSubmit = { this . onValidSubmit }
46+ autoComplete = "off" >
4647 < h1 > Login</ h1 >
4748 < BasicInput label = "Email address"
4849 name = "email"
Original file line number Diff line number Diff line change @@ -205,10 +205,15 @@ export default class Form extends React.Component {
205205 }
206206
207207 render ( ) {
208- const { children, className, formProps} = this . props ;
208+ const { children, className, autoComplete} = this . props ;
209+
210+ const formProps = {
211+ className,
212+ autoComplete
213+ } ;
209214
210215 return (
211- < form className = { className } { ...formProps } onSubmit = { this . onSubmit } >
216+ < form { ...formProps } onSubmit = { this . onSubmit } >
212217 { children }
213218 </ form >
214219 ) ;
Original file line number Diff line number Diff line change @@ -43,12 +43,9 @@ describe('Form', () => {
4343 expect ( onInvalid ) . not . toHaveBeenCalled ( ) ;
4444 } ) ;
4545
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>' ) ;
5249 } ) ;
5350
5451 it ( 'should add the vaidationRule' , ( ) => {
You can’t perform that action at this time.
0 commit comments