import React from "react"; import { observer } from "mobx-react"; import classNames from "classnames"; import { Icon } from "eez-studio-ui/icon"; const Action = observer( class Action extends React.Component< { children?: React.ReactNode; title: string; onClick?: (event: any) => void; selected?: boolean; className?: string; style?: React.CSSProperties; enabled?: boolean; }, {} > { onClick = (event: any) => { event.target.blur(); if (this.props.onClick) { event.stopPropagation(); event.preventDefault(); this.props.onClick(event); } }; render() { let className = classNames( "EezStudio_Action", this.props.className, { selected: this.props.selected === true } ); const { title } = this.props; let buttonProps = { className, title, onClick: this.onClick, disabled: this.props.enabled === false, style: this.props.style }; return ; } } ); export const TextAction = observer( class TextAction extends React.Component< { text: string; icon?: string; title: string; onClick: () => void; selected?: boolean; enabled?: boolean; style?: React.CSSProperties; }, {} > { render() { return ( {this.props.icon && }{" "} {this.props.text} ); } } ); export const IconAction = observer( class IconAction extends React.Component< { icon: string | React.ReactNode; iconSize?: number; title: string; onClick?: (event: any) => void; selected?: boolean; enabled?: boolean; className?: string; style?: React.CSSProperties; color?: string; overlayText?: string; attention?: boolean; }, {} > { render() { let className = classNames( "EezStudio_IconAction", this.props.className ); let style; if (this.props.color) { style = { color: this.props.color }; } return ( ); } } ); export const ButtonAction = observer( class ButtonAction extends React.Component<{ text: React.ReactNode; icon?: string | JSX.Element; iconSize?: number; iconStyle?: React.CSSProperties; title: string; onClick?: (event: any) => void; selected?: boolean; enabled?: boolean; className?: string; style?: React.CSSProperties; attention?: boolean; }> { render() { const { style, icon, iconSize, text } = this.props; let className = classNames( "EezStudio_ButtonAction btn", this.props.className ); return ( {icon && ( )} {text} ); } } ); export const DropdownButtonAction = observer( class DropdownButtonAction extends React.Component< { children?: React.ReactNode; text: string; icon?: string; iconSize?: number; title: string; onClick?: (event: any) => void; enabled?: boolean; className?: string; style?: React.CSSProperties; }, {} > { render() { const { style, icon, iconSize, text, title, onClick, enabled } = this.props; let className = classNames( "EezStudio_ButtonAction btn dropdown-toggle", this.props.className ); let buttonProps = { className, title, onClick: onClick, disabled: enabled === false, style: style }; return (
{this.props.children}
); } } ); export const DropdownIconAction = observer( class DropdownIconAction extends React.Component< { children?: React.ReactNode; icon: string; iconSize?: number; title: string; onClick?: (event: any) => void; enabled?: boolean; className?: string; style?: React.CSSProperties; }, {} > { render() { const { style, icon, iconSize, title, onClick, enabled } = this.props; let className = classNames( "EezStudio_IconAction", this.props.className ); let buttonProps = { className, title, onClick: onClick, disabled: enabled === false, style: style }; return (
{this.props.children}
); } } ); export const DropdownItem = observer( class DropdownItem extends React.Component< { text: string; title?: string; onClick: () => void; disabled?: boolean; }, {} > { render() { const { text } = this.props; let className = classNames("dropdown-item", { disabled: this.props.disabled }); return ( {text} ); } } );