/* 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/. */ "use strict"; // Make this available to both AMD and CJS environments define(function (require, exports, module) { const { Component } = require("devtools/client/shared/vendor/react"); const PropTypes = require("devtools/client/shared/vendor/react-prop-types"); const dom = require("devtools/client/shared/vendor/react-dom-factories"); 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, "aria-labelledby": id, }, 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 module.exports = TreeCell; }); |