https://github.com/user-attachments/assets/5f31023d-b24f-40c8-a061-ffc0d02b63b0 Closes https://github.com/twentyhq/core-team-issues/issues/715
39 lines
1018 B
TypeScript
39 lines
1018 B
TypeScript
import { IconCube } from '@ui/display';
|
|
import { JsonNestedNode } from '@ui/json-visualizer/components/JsonNestedNode';
|
|
import { useJsonTreeContextOrThrow } from '@ui/json-visualizer/hooks/useJsonTreeContextOrThrow';
|
|
import { JsonNodeHighlighting } from '@ui/json-visualizer/types/JsonNodeHighlighting';
|
|
import { JsonObject } from 'type-fest';
|
|
|
|
export const JsonObjectNode = ({
|
|
label,
|
|
value,
|
|
depth,
|
|
keyPath,
|
|
highlighting,
|
|
}: {
|
|
label?: string;
|
|
value: JsonObject;
|
|
depth: number;
|
|
keyPath: string;
|
|
highlighting: JsonNodeHighlighting | undefined;
|
|
}) => {
|
|
const { emptyObjectLabel } = useJsonTreeContextOrThrow();
|
|
|
|
return (
|
|
<JsonNestedNode
|
|
elements={Object.entries(value).map(([key, value]) => ({
|
|
id: key,
|
|
label: key,
|
|
value,
|
|
}))}
|
|
renderElementsCount={(count) => `{${count}}`}
|
|
label={label}
|
|
Icon={IconCube}
|
|
depth={depth}
|
|
emptyElementsText={emptyObjectLabel}
|
|
keyPath={keyPath}
|
|
highlighting={highlighting}
|
|
/>
|
|
);
|
|
};
|