mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
Merged 2.0.0-m3
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
@@ -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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user