Fix stringifying

This commit is contained in:
Nathan Bierema 2023-01-02 09:15:23 -05:00
parent 438d08dd7c
commit 02cb2bbaba
3 changed files with 9 additions and 6 deletions

View File

@ -176,12 +176,14 @@ const defaultOptions: Options = {
export interface Node {
name: string;
children?: this[] | null;
object?: unknown;
value?: unknown;
}
export interface InternalNode {
name: string;
children?: this[] | null;
object?: unknown;
value?: unknown;
id: string | number;
}

View File

@ -83,11 +83,11 @@ export function getNodeGroupByDepthCount(rootNode: InternalNode) {
}
export function getTooltipString(
node: unknown,
node: HierarchyPointNodeWithPrivateChildren<InternalNode>,
i: number | undefined,
{ indentationSize = 4 }
) {
if (!is(Object, node)) return '';
if (!is(Object, node.data)) return '';
const spacer = join('&nbsp;&nbsp;');
const cr2br = replace(/\n/g, '<br/>');
@ -96,9 +96,9 @@ export function getTooltipString(
const children = node.children || node._children;
if (typeof node.value !== 'undefined') return json2html(node.value);
if (typeof node.object !== 'undefined') return json2html(node.object);
if (children && children.length)
return `childrenCount: ${(children as unknown[]).length}`;
if (typeof node.data.value !== 'undefined') return json2html(node.data.value);
if (typeof node.data.object !== 'undefined')
return json2html(node.data.object);
if (children && children.length) return `childrenCount: ${children.length}`;
return 'empty';
}

View File

@ -5,6 +5,7 @@ import mapValues from 'lodash/mapValues';
export interface Node {
name: string;
children?: Node[] | null;
object?: unknown;
value?: unknown;
}