-
+const ForeignTableNode = ({ data, targetPosition }) => (
+
+
+ {data.name}
+{targetPosition && generateHandle(data.name, 'target', cn(HIDDEN_NODE_CONNECTOR, '!left-0'))}
+
+
+);
- {data.columns.map((column) => (
-
-
- {column.isPrimary && (
-
- )}
- {column.isNullable && (
-
- )}
- {!column.isNullable && (
-
- )}
- {column.isUnique && (
-
- )}
- {column.isIdentity && (
-
- )}
-
-
-
- {column.name}
-
-
- {column.format}
-
-
- {targetPosition && (
-
- )}
- {sourcePosition && (
-
- )}
-
- ))}
-
+
+
+/**
+ * Renders a local table node within a schema flow diagram.
+ *
+ * This component is responsible for visually representing a local table, including its name, columns,
+ * and their respective properties. It supports interactive elements such as handles, allowing connections
+ * between nodes within the schema flow based on the table's relationships.
+ *
+ * @param {TableNodeData} data - An object containing the table's name, an indication if it is a foreign table,
+ * and an array of column objects detailing the column name, properties and format.
+ * @param {'top' | 'bottom' | 'left' | 'right' | undefined} targetPosition - Designates the position of the target handle within the node for incoming connections.
+ * @param {'top' | 'bottom' | 'left' | 'right' | undefined} sourcePosition - Specifies the position of the source handle within the node for outgoing connections.
+ * @returns A JSX element representing the local table node with appropriately placed handles for establishing connections, if `targetPosition` or `sourcePosition` are provided.
+ */
+const LocalTableNode = ({ data, targetPosition, sourcePosition }) => (
+
+
- )
-}
+ >
+
+ {data.name}
+
+
+ {data.columns && data.columns.map((column) => (
+
+
+ {column.isPrimary && (
+
+ )}
+ {column.isNullable && (
+
+ )}
+ {!column.isNullable && (
+
+ )}
+ {column.isUnique && (
+
+ )}
+ {column.isIdentity && (
+
+ )}
+
+
+
+ {column.name}
+
+
+ {column.format}
+
+
+{targetPosition && generateHandle(column.id, 'target', cn(HIDDEN_NODE_CONNECTOR, '!left-0'))}
+{sourcePosition && generateHandle(column.id, 'source', cn(HIDDEN_NODE_CONNECTOR, '!right-0'))}
+
+ ))}
+
+);
-export default TableNode
+export default TableNode;