Merged 2.0.0-m3

This commit is contained in:
Philipp Czora
2018-11-23 16:25:12 +01:00
111 changed files with 2400 additions and 3541 deletions

View File

@@ -10,7 +10,9 @@ type Props = {
disabled?: boolean,
helpText?: string
};
class Checkbox extends React.Component<Props> {
onCheckboxChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
if (this.props.onChange) {
this.props.onChange(event.target.checked, this.props.name);
@@ -20,12 +22,8 @@ class Checkbox extends React.Component<Props> {
renderHelp = () => {
const helpText = this.props.helpText;
if (helpText) {
return (
<div className="control columns is-vcentered">
<Help message={helpText} />
</div>
);
} else return null;
return <Help message={helpText} />;
}
};
render() {
@@ -39,10 +37,11 @@ class Checkbox extends React.Component<Props> {
onChange={this.onCheckboxChange}
disabled={this.props.disabled}
/>
{" "}
{this.props.label}
{this.renderHelp()}
</label>
</div>
{this.renderHelp()}
</div>
);
}

View File

@@ -1,7 +1,7 @@
//@flow
import React from "react";
import classNames from "classnames";
import { LabelWithHelpIcon } from "../index";
import LabelWithHelpIcon from "./LabelWithHelpIcon";
type Props = {
label?: string,

View File

@@ -0,0 +1,37 @@
//@flow
import React from "react";
import Help from "../Help.js";
type Props = {
label?: string,
helpText?: string
};
class LabelWithHelpIcon extends React.Component<Props> {
renderHelp() {
const { helpText } = this.props;
if (helpText) {
return (
<Help message={helpText} />
);
}
}
render() {
const {label } = this.props;
if (label) {
const help = this.renderHelp();
return (
<label className="label">
{label} { help }
</label>
);
}
return "";
}
}
export default LabelWithHelpIcon;

View File

@@ -1,7 +1,7 @@
//@flow
import React from "react";
import classNames from "classnames";
import { LabelWithHelpIcon } from "../index";
import LabelWithHelpIcon from "./LabelWithHelpIcon";
export type SelectItem = {
value: string,

View File

@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { LabelWithHelpIcon } from "../index";
import LabelWithHelpIcon from "./LabelWithHelpIcon";
export type SelectItem = {
value: string,
@@ -8,10 +8,11 @@ export type SelectItem = {
};
type Props = {
name?: string,
label?: string,
placeholder?: SelectItem[],
value?: string,
onChange: string => void,
onChange: (value: string, name?: string) => void,
helpText?: string
};
@@ -19,7 +20,7 @@ class Textarea extends React.Component<Props> {
field: ?HTMLTextAreaElement;
handleInput = (event: SyntheticInputEvent<HTMLTextAreaElement>) => {
this.props.onChange(event.target.value);
this.props.onChange(event.target.value, this.props.name);
};
render() {

View File

@@ -6,4 +6,5 @@ export { default as Checkbox } from "./Checkbox.js";
export { default as InputField } from "./InputField.js";
export { default as Select } from "./Select.js";
export { default as Textarea } from "./Textarea.js";
export { default as LabelWithHelpIcon } from "./LabelWithHelpIcon";