-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from flickerleap/feature-add-select-input
Input and Field Updates
- Loading branch information
Showing
20 changed files
with
5,567 additions
and
5,043 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
export {Field} from './Field'; | ||
export {DynamicForm} from './DynamicForm'; | ||
|
||
export {Input} from './inputs/Input'; | ||
export {DropDown} from './inputs/DropDown'; | ||
export {DynamicForm} from './DynamicForm'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react'; | ||
|
||
export class CheckboxList extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
values: props.value || [] | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
this.props.onChange(this.getEventObject(this.state.values)); | ||
} | ||
|
||
getEventObject = (value) => { | ||
return { | ||
target: { | ||
name: this.props.name, | ||
value: value | ||
} | ||
}; | ||
}; | ||
|
||
onChange = (event) => { | ||
const index = parseInt(event.target.id.replace(this.props.name, '')); | ||
const value = event.target.value; | ||
|
||
const values = this.state.values; | ||
|
||
if(values.indexOf(value) > -1) { | ||
delete values[index]; | ||
} else { | ||
values.splice(index, 0, value); | ||
} | ||
|
||
this.props.onChange(this.getEventObject(values)); | ||
|
||
this.setState(() => ({ | ||
values | ||
})); | ||
}; | ||
|
||
isSelected = (index) => { | ||
return this.state.values[index] !== undefined; | ||
}; | ||
|
||
render() { | ||
const { | ||
name, label, className = "form-control col-md-4", items = [] | ||
} = this.props; | ||
|
||
return ( | ||
<div> | ||
<label htmlFor={name}>{label}</label> | ||
<div className="row"> | ||
{ | ||
items.map((item, index) => ( | ||
<div key={index} className={className}> | ||
<input | ||
onChange={this.onChange} | ||
id={name+index} name={name} | ||
type="checkbox" value={item.value} | ||
checked={this.isSelected(index)} /> | ||
<span> {item.label}</span> | ||
</div> | ||
)) | ||
} | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
import React from 'react'; | ||
|
||
export const TextArea = ({name, label, value, onChange, className="form-control"}) => ( | ||
<div> | ||
<label htmlFor={name}>{label}</label> | ||
<textarea | ||
name={name} | ||
className={className} | ||
value={value} | ||
onChange={onChange} | ||
> | ||
</textarea> | ||
</div> | ||
); | ||
export class TextArea extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
const {name, label, value, onChange, className = "form-control"} = this.props; | ||
|
||
return ( | ||
<div> | ||
<label htmlFor={name}>{label}</label> | ||
<textarea | ||
name={name} | ||
className={className} | ||
value={value} | ||
onChange={onChange} | ||
> | ||
</textarea> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export {Input} from './Input'; | ||
export {DropDown} from "./DropDown"; | ||
export {Date} from "./Date"; | ||
export {TextArea} from "./TextArea"; | ||
export {Time} from "./Time"; | ||
export {DateTime} from "./DateTime"; | ||
export {CheckboxList} from "./CheckboxList"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
import React from 'react'; | ||
import {Alert} from "reactstrap"; | ||
|
||
/** | ||
* | ||
* @param errors | ||
* @returns {*} | ||
* @constructor | ||
*/ | ||
export const ErrorBlock = ({error, classes = 'alert alert-danger error'}) => ( | ||
<div className={classes} role="alert"> | ||
{error} | ||
</div> | ||
); | ||
export class ErrorBlock extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
open: true | ||
}; | ||
} | ||
|
||
onDismiss = () => { | ||
this.setState(() => ({ | ||
open: false | ||
})); | ||
}; | ||
|
||
render() { | ||
const {error} = this.props; | ||
return ( | ||
<Alert color="info" isOpen={this.state.open} toggle={this.onDismiss}> | ||
{error} | ||
</Alert> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
|
||
export const contains = (haystack, needle) => { | ||
return haystack.indexOf(needle) > -1; | ||
}; | ||
|
||
export const capitalizeFirstLetter = (string) => { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
}; |
Oops, something went wrong.