/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Component } from "resource://devtools/client/shared/vendor/react.mjs"; import PropTypes from "resource://devtools/client/shared/vendor/react-prop-types.mjs"; import * as dom from "resource://devtools/client/shared/vendor/react-dom-factories.mjs"; const { input, span, td } = dom; /** * This template represents a cell in TreeView row. It's rendered * using
element. const classNames = this.getCellClass(member.object, id) || []; classNames.push("treeValueCell"); classNames.push(type + "Cell"); // Render value using a default render function or custom // provided function from props or a decorator. renderValue = renderValue || defaultRenderValue; if (decorator?.renderValue) { renderValue = decorator.renderValue(member.object, id) || renderValue; } const props = Object.assign({}, this.props, { object: value, }); let cellElement; if (enableInput && this.state.inputEnabled && type !== "object") { classNames.push("inputEnabled"); cellElement = input({ autoFocus: true, onBlur: this.updateInputEnabled, readOnly: true, value, "aria-labelledby": id, }); } else { cellElement = span( { onClick: type !== "object" ? this.updateInputEnabled : null, }, renderValue(props) ); } // Render me! return td( { className: classNames.join(" "), role: "presentation", }, cellElement ); } } // Default value rendering. const defaultRenderValue = props => { return props.object + ""; }; // Exports from this module export default TreeCell; |