feat: add initial data node
This commit is contained in:
@@ -168,6 +168,16 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
||||
[nodes, connectedNodeIds]
|
||||
)
|
||||
|
||||
const dataSignature = useMemo(
|
||||
() =>
|
||||
nodes
|
||||
.filter((n: any) => n.type === 'data' && connectedNodeIds.has(n.id))
|
||||
.map((n: any) => `${n.id}:${JSON.stringify(n.data?.rows ?? [])}:${JSON.stringify(n.data?.hiddenColumns ?? [])}`)
|
||||
.sort()
|
||||
.join('|'),
|
||||
[nodes, connectedNodeIds]
|
||||
)
|
||||
|
||||
const RENDER_DEBOUNCE_MS = 250
|
||||
|
||||
useEffect(() => {
|
||||
@@ -273,6 +283,20 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
||||
if (!configIdsUsed.has(e.target)) continue
|
||||
const src = nodes.find((n: any) => n.id === e.source)
|
||||
if (src?.type === 'variable') setVarInContext(src)
|
||||
if (src?.type === 'data') {
|
||||
const rows = (src.data?.rows as Record<string, string>[] | undefined) ?? []
|
||||
const hidden = (src.data?.hiddenColumns as string[] | undefined) ?? []
|
||||
const visibleCols = (src.data?.columns as string[] | undefined) ?? []
|
||||
.filter((c) => !hidden.includes(c))
|
||||
const filteredRows = rows.map((row) => {
|
||||
const out: Record<string, string> = {}
|
||||
for (const col of visibleCols) {
|
||||
if (col in row) out[col] = row[col]
|
||||
}
|
||||
return out
|
||||
})
|
||||
nunjucksContext[src.id] = filteredRows
|
||||
}
|
||||
}
|
||||
// All function node ids that feed (directly or transitively) into config — need to register them and collect their variables
|
||||
const functionIdsToRegister = new Set<string>()
|
||||
@@ -505,7 +529,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
||||
}
|
||||
}
|
||||
// Only re-run when inputs that affect the resolved output change (signatures + source). Debounced to avoid excessive re-renders while typing. retryCount triggers re-run on Retry.
|
||||
}, [id, sourceContent, configTypeId, configSignature, edgesSignature, variablesSignature, functionsSignature, viewportWidth, viewportHeight, retryCount])
|
||||
}, [id, sourceContent, configTypeId, configSignature, edgesSignature, variablesSignature, functionsSignature, dataSignature, viewportWidth, viewportHeight, retryCount])
|
||||
|
||||
const dimensions =
|
||||
width != null && height != null && width > 0 && height > 0
|
||||
|
||||
Reference in New Issue
Block a user