refactor: defaults should be in their own file, respecting eslint/ react standards. all tests fail, obviously.

ref: N25B-294
This commit is contained in:
Björn Otgaar
2025-11-17 16:00:36 +01:00
parent c5dc825ca3
commit 35ff58eca8
16 changed files with 1134 additions and 1201 deletions

View File

@@ -4,13 +4,10 @@ import {
Position,
type Connection,
type Edge,
useReactFlow,
type Node,
} from '@xyflow/react';
import { Toolbar } from './NodeDefinitions';
import { Toolbar } from '../components/NodeComponents';
import styles from '../../VisProg.module.css';
import { NodeDefaults, NodeReduces } from '../NodeRegistry';
import type { FlowState } from '../VisProgTypes';
/**
* The default data dot a Norm node
@@ -25,25 +22,13 @@ export type NormNodeData = {
hasReduce: boolean;
};
/**
* Default data for this node
*/
export const NormNodeDefaults: NormNodeData = {
label: "Norm Node",
droppable: true,
normList: [],
hasReduce: true,
};
export type NormNode = Node<NormNodeData>
/**
*
* @param connection
* @returns
*/
export function NormNodeCanConnect(connection: Connection | Edge): boolean {
return true;
return (connection != undefined);
}
/**
@@ -52,7 +37,6 @@ export function NormNodeCanConnect(connection: Connection | Edge): boolean {
* @returns React.JSX.Element
*/
export default function NormNode(props: NodeProps<Node>) {
const reactFlow = useReactFlow();
const label_input_id = `Norm_${props.id}_label_input`;
const data = props.data as NormNodeData;
return (
@@ -75,6 +59,10 @@ export default function NormNode(props: NodeProps<Node>) {
* @param props: The Node Properties of this node.
*/
export function NormReduce(node: Node, nodes: Node[]) {
// Replace this for nodes functionality
if (nodes.length <= -1) {
console.warn("Impossible nodes length in NormReduce")
}
const data = node.data as NormNodeData;
return {
label: data.label,
@@ -83,4 +71,8 @@ export function NormReduce(node: Node, nodes: Node[]) {
}
export function NormConnects(thisNode: Node, otherNode: Node, isThisSource: boolean) {
// Replace this for connection logic
if (thisNode == undefined && otherNode == undefined && isThisSource == false) {
console.warn("Impossible node connection called in EndConnects")
}
}