MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / ColumnsElement

Function ColumnsElement

app/components/Columns.tsx:13–60  ·  view source on GitHub ↗
({ columns }: { columns: ColumnDefinition[] })

Source from the content-addressed store, hash-verified

11import { ColumnItem } from "./ColumnItem";
12
13function ColumnsElement({ columns }: { columns: ColumnDefinition[] }) {
14 const [json] = useJson();
15 const { selectedPath, highlightedPath, highlightedNodeId } =
16 useJsonColumnViewState();
17 const { goToNodeId } = useJsonColumnViewAPI();
18 const highlightedItemIsValue = useMemo<boolean>(() => {
19 if (highlightedNodeId == null) {
20 return false;
21 }
22
23 const path = new JSONHeroPath(highlightedNodeId);
24 let item = path.first(json);
25
26 return typeof item !== "object";
27 }, [highlightedPath, json]);
28
29 return (
30 <div className="columns flex flex-grow overflow-x-auto focus:outline-none no-scrollbar">
31 {columns.map((column) => {
32 return (
33 <Column
34 key={column.id}
35 id={column.id}
36 title={column.title}
37 icon={column.icon}
38 hasHighlightedElement={
39 highlightedPath[highlightedPath.length - 2] === column.id
40 }
41 >
42 {column.items.map((item) => (
43 <ColumnItem
44 key={item.id}
45 item={item}
46 json={json}
47 isSelected={selectedPath.includes(item.id)}
48 isHighlighted={
49 highlightedPath[highlightedPath.length - 1] === item.id
50 }
51 onClick={(id) => goToNodeId(id, "columnView")}
52 />
53 ))}
54 </Column>
55 );
56 })}
57 {highlightedItemIsValue ? <BlankColumn /> : null}
58 </div>
59 );
60}
61export const Columns = memo(ColumnsElement);

Callers

nothing calls this directly

Calls 3

useJsonFunction · 0.90
useJsonColumnViewStateFunction · 0.90
useJsonColumnViewAPIFunction · 0.90

Tested by

no test coverage detected