Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderLabel(label: string) {
if (label === null || typeof label === "undefined") {
return null;
}
const { item, depth, focused, expanded, onLabelClick } = this.props;
return dom.span(
{
className: "object-label",
onClick: onLabelClick
? event => {
event.stopPropagation();
// If the user selected text, bail out.
if (Utils.selection.documentHasSelection()) {
return;
}
onLabelClick(item, {
depth,
focused,
expanded,
setExpanded: this.props.setExpanded
label,
value: dom.span({ className: "unavailable" }, "(optimized away)")
};
}
if (nodeIsUninitializedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(uninitialized)")
};
}
if (nodeIsUnmappedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unmapped)")
};
}
if (nodeIsUnscopedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unscoped)")
};
}
if (nodeIsOptimizedOut(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(optimized away)")
};
}
render() {
const {
expanded,
} = this.props;
const classNames = ["arrow"];
if (expanded) {
classNames.push("expanded");
}
return dom.img({
className: classNames.join(" "),
});
}
}
const treeIndent = dom.span({className: "tree-indent"}, "\u200B");
class TreeNode extends Component {
static get propTypes() {
return {
id: PropTypes.any.isRequired,
index: PropTypes.number.isRequired,
depth: PropTypes.number.isRequired,
focused: PropTypes.bool.isRequired,
expanded: PropTypes.bool.isRequired,
item: PropTypes.any.isRequired,
isExpandable: PropTypes.bool.isRequired,
onClick: PropTypes.func,
renderItem: PropTypes.func.isRequired,
};
}
separatorText = ": "
) {
const { name, role } = grip.preview;
const elements = [];
if (name) {
elements.push(
StringRep({
className: "accessible-name",
object: name,
cropLimit: nameMaxLength
}),
span({ className: "separator" }, separatorText)
);
}
elements.push(span({ className: "accessible-role" }, role));
return roleFirst ? elements.reverse() : elements;
}
label,
value: dom.span({ className: "unavailable" }, "(optimized away)")
};
}
const itemValue = getValue(item);
const unavailable =
isPrimitive &&
itemValue &&
itemValue.hasOwnProperty &&
itemValue.hasOwnProperty("unavailable");
if (nodeIsMissingArguments(item) || unavailable) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unavailable)")
};
}
if (
nodeIsFunction(item)
&& !nodeIsGetter(item)
&& !nodeIsSetter(item)
&& (
this.props.mode === MODE.TINY
|| !this.props.mode
)
) {
return {
label: Utils.renderRep(
item,
{
label?: string
}) {
const label = item.name;
const isPrimitive = nodeIsPrimitive(item);
if (nodeIsOptimizedOut(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(optimized away)")
};
}
if (nodeIsUninitializedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(uninitialized)")
};
}
if (nodeIsUnmappedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unmapped)")
};
}
if (nodeIsUnscopedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unscoped)")
};
}
label,
value: dom.span({ className: "unavailable" }, "(uninitialized)")
};
}
if (nodeIsUnmappedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unmapped)")
};
}
if (nodeIsUnscopedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unscoped)")
};
}
if (nodeIsOptimizedOut(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(optimized away)")
};
}
const itemValue = getValue(item);
const unavailable =
isPrimitive &&
itemValue &&
itemValue.hasOwnProperty &&
itemValue.hasOwnProperty("unavailable");
getTreeItemLabelAndValue(item : Node, depth: number, expanded : boolean) : ({
value?: string | Element,
label?: string
}) {
const label = item.name;
const isPrimitive = nodeIsPrimitive(item);
if (nodeIsOptimizedOut(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(optimized away)")
};
}
if (nodeIsUninitializedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(uninitialized)")
};
}
if (nodeIsUnmappedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unmapped)")
};
}
label,
value: dom.span({ className: "unavailable" }, "(optimized away)")
};
}
if (nodeIsUninitializedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(uninitialized)")
};
}
if (nodeIsUnmappedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unmapped)")
};
}
if (nodeIsUnscopedBinding(item)) {
return {
label,
value: dom.span({ className: "unavailable" }, "(unscoped)")
};
}
const itemValue = getValue(item);
const unavailable =
isPrimitive &&
itemValue &&
itemValue.hasOwnProperty &&
itemValue.hasOwnProperty("unavailable");
function getTitle(props, object) {
const title = props.title || (object && object.class ? object.class : "Map");
return span({
className: "objectTitle"},
title,
lengthBubble({
object,
mode: props.mode,
maxLengthMap,
getLength,
showZeroLength: true
})
);
}