-
- {content}
+}) {
+ let className = "list-item";
+ if (selected) {
+ className += " selected";
+ }
+ let content =
{label}
;
+ if (error) {
+ content =
;
}
+ return
;
}
-export class ListBox extends React.Component<{
+export function ListBox({ height, value, onSelect, children }: {
height: number;
value?: any;
onSelect?: (value: any) => void;
-}, {
-
- }> {
- constructor(props: any) {
- super(props);
- }
-
- render() {
- const { children, onSelect } = this.props;
-
- const newChildren = React.Children.map(children, (child: any, index) => {
- return React.cloneElement(child as any, {
- onClick: () => {
- return onSelect && onSelect(child.props.value);
- },
- selected: this.props.value === child.props.value
- });
+ children: any;
+}) {
+ const newChildren = React.Children.map(children, (child: any, index) => {
+ return React.cloneElement(child as any, {
+ onClick: () => {
+ return onSelect && onSelect(child.props.value);
+ },
+ selected: value === child.props.value
});
+ });
- return
- {newChildren}
-
;
- }
+ return
+ {newChildren}
+
;
}
diff --git a/src/components/editor/Tabs.tsx b/src/components/editor/Tabs.tsx
index fbea548dc..e79503833 100644
--- a/src/components/editor/Tabs.tsx
+++ b/src/components/editor/Tabs.tsx
@@ -65,7 +65,7 @@ export class Tabs extends Component
{
e.preventDefault();
}
- onDoubleClick = (e: MouseEvent) => { this.props.onDoubleClick(); };
+ onDoubleClick = (e: any) => { this.props.onDoubleClick(); };
setContainerRef = (ref: HTMLDivElement) => { this.container = ref; };
render() {
@@ -110,20 +110,20 @@ export class Tab extends PureComponent {
onClose: () => {},
};
- onMouseHandle = (e: MouseEvent, handler: Function) => {
+ onMouseHandle = (e: any, handler: Function) => {
e.stopPropagation();
handler(this.props.value);
}
- onClick = (e: MouseEvent) => {
+ onClick = (e: any) => {
this.onMouseHandle(e, this.props.onClick);
}
- onDoubleClick = (e: MouseEvent) => {
+ onDoubleClick = (e: any) => {
this.onMouseHandle(e, this.props.onDoubleClick);
}
- onClose = (e: MouseEvent) => {
+ onClose = (e: any) => {
this.onMouseHandle(e, this.props.onClose);
}
diff --git a/src/components/shared/Button.tsx b/src/components/shared/Button.tsx
index 8e5673484..ae762224d 100644
--- a/src/components/shared/Button.tsx
+++ b/src/components/shared/Button.tsx
@@ -21,8 +21,10 @@
import * as React from "react";
-export class Button extends React.Component<{
- icon?: JSX.Element;
+export function Button({
+ icon, label, title, isDisabled, onClick, customClassName, href, target, rel
+}: {
+ icon: JSX.Element;
label?: string;
title?: string;
isDisabled?: boolean;
@@ -31,38 +33,36 @@ export class Button extends React.Component<{
href?: string,
target?: string,
rel?: string
-}, {}> {
- render() {
- let className = "button ";
- if (this.props.customClassName) {
- className += this.props.customClassName;
- }
- if (this.props.isDisabled) {
- className += " disabled";
- }
- if (this.props.href && !this.props.isDisabled) {
- return (
-
- {this.props.icon} {this.props.label}
-
- );
- }
- return {
- if (this.props.onClick && !this.props.isDisabled) {
- this.props.onClick();
- }
- }}
- title={this.props.title}
- >
- {this.props.icon} {this.props.label}
-
;
+}) {
+ let className = "button ";
+ if (customClassName) {
+ className += customClassName;
}
+ if (isDisabled) {
+ className += " disabled";
+ }
+ if (href && !isDisabled) {
+ return (
+
+ {icon} {label}
+
+ );
+ }
+ return {
+ if (onClick && !isDisabled) {
+ onClick();
+ }
+ }}
+ title={title}
+ >
+ {icon} {label}
+
;
}