import React from "react"; import { computed, makeObservable } from "mobx"; import { observer } from "mobx-react"; import classNames from "classnames"; import { dialog, getCurrentWindow } from "@electron/remote"; import { formatBytes } from "eez-studio-shared/formatBytes"; import { guid } from "eez-studio-shared/guid"; import { capitalize } from "eez-studio-shared/string"; import { ListContainer, List, IListNode } from "eez-studio-ui/list"; export const PropertyEnclosure = observer( class PropertyEnclosure extends React.Component< { children?: React.ReactNode; errors?: string[]; style?: React.CSSProperties; className?: string; title?: string; }, {} > { render() { let className = classNames(this.props.className); let result = ( {this.props.children} ); if (!this.props.errors) { return result; } return [ result, {this.props.errors.map(error => (
{error}
))} ]; } } ); export const StaticProperty = observer( class StaticProperty extends React.Component<{ name: string; value: string; className?: string; }> { render() { const value = (this.props.value && this.props.value.toString()) || ""; return ( {this.props.name} {value} ); } } ); export const BytesProperty = observer( class BytesProperty extends React.Component< { name: string; value: number; }, {} > { render() { return ( {this.props.name} {formatBytes(this.props.value)} ); } } ); export const InputProperty = observer( class InputProperty extends React.Component< { id?: string; name?: string; value: any; suggestions?: string[]; inputGroupButton?: React.ReactNode; title?: string; onChange: (value: any) => void; type: string; errors?: string[]; min?: number; max?: number; formText?: string; }, {} > { render() { let id = this.props.id || guid(); let input = ( this.props.onChange(event.target.value)} min={this.props.min} max={this.props.max} /> ); const suggestions = this.props.suggestions && this.props.suggestions.length ? this.props.suggestions : undefined; if (suggestions || this.props.inputGroupButton) { input = (
{input} {suggestions && ( <> ))}
)} {this.props.inputGroupButton} ); } if (this.props.formText) { input = ( <> {input}
{this.props.formText}
); } let content; if (this.props.name) { content = [ , {input} ]; } else { content = {input}; } return ( {content} ); } } ); export const TextInputProperty = observer( class TextInputProperty extends React.Component< { id?: string; name?: string; value: string; suggestions?: string[]; inputGroupButton?: React.ReactNode; title?: string; onChange: (value: string) => void; errors?: string[]; }, {} > { render() { return ; } } ); export const PasswordInputProperty = observer( class PasswordInputProperty extends React.Component< { id?: string; name?: string; value: string; suggestions?: string[]; title?: string; onChange: (value: string) => void; errors?: string[]; }, {} > { render() { return ; } } ); export const MultilineTextInputProperty = observer( class MultilineTextInputProperty extends React.Component< { id?: string; name?: string; value: any; onChange: (value: any) => void; errors?: string[]; rows: number; readOnly?: boolean; }, {} > { render() { let id = this.props.id || guid(); let input = (