import React from "react"; import { observable, makeObservable } from "mobx"; import { observer } from "mobx-react"; import { Icon } from "eez-studio-ui/icon"; import { PropertyProps, getObjectPropertyDisplayName } from "project-editor/core/object"; import { getNumModifications } from "project-editor/store"; import { propertyCollapsedStore } from "./PropertyCollapsedStore"; import classNames from "classnames"; //////////////////////////////////////////////////////////////////////////////// export const PropertyName = observer( class PropertyName extends React.Component { collapsed = true; toggleCollapsed = () => { propertyCollapsedStore.toggleColapsed( this.props.objects[0], this.props.propertyInfo ); }; constructor(props: PropertyProps) { super(props); makeObservable(this, { collapsed: observable }); } render() { const { objects, propertyInfo } = this.props; let propertyName = getObjectPropertyDisplayName( objects[0], propertyInfo ); if (propertyInfo.propertyGridCollapsable) { const enabled = !propertyInfo.propertyGridCollapsableEnabled || propertyInfo.propertyGridCollapsableEnabled(objects[0]); const collapsed = propertyCollapsedStore.isCollapsed( objects[0], propertyInfo ); const numModifications = getNumModifications({ ...this.props, objects: objects.map( object => (object as any)[propertyInfo.name] ) }); if (numModifications > 0) { propertyName += ` (${numModifications})`; } return (
0 })} > {enabled && ( )} {propertyName}
); } else { return (
{propertyName}
); } } } );