chore(ui): lint

This commit is contained in:
psychedelicious
2025-02-14 15:37:21 +10:00
parent 0671fec844
commit 436d5ee0c6
8 changed files with 5 additions and 61 deletions

View File

@@ -6,7 +6,7 @@ import {
useConnectionValidationResult,
useIsConnectionInProgress,
useIsConnectionStartField,
} from 'features/nodes/hooks/useInputFieldConnectionState';
} from 'features/nodes/hooks/useFieldConnectionState';
import { useInputFieldTemplate } from 'features/nodes/hooks/useInputFieldTemplate';
import { useFieldTypeName } from 'features/nodes/hooks/usePrettyFieldType';
import { HANDLE_TOOLTIP_OPEN_DELAY, MODEL_TYPES } from 'features/nodes/types/constants';

View File

@@ -7,7 +7,7 @@ import {
useConnectionValidationResult,
useIsConnectionInProgress,
useIsConnectionStartField,
} from 'features/nodes/hooks/useInputFieldConnectionState';
} from 'features/nodes/hooks/useFieldConnectionState';
import { useInputFieldIsConnected } from 'features/nodes/hooks/useInputFieldIsConnected';
import { useInputFieldLabel } from 'features/nodes/hooks/useInputFieldLabel';
import { useInputFieldTemplateTitle } from 'features/nodes/hooks/useInputFieldTemplateTitle';

View File

@@ -6,7 +6,7 @@ import {
useConnectionValidationResult,
useIsConnectionInProgress,
useIsConnectionStartField,
} from 'features/nodes/hooks/useInputFieldConnectionState';
} from 'features/nodes/hooks/useFieldConnectionState';
import { useOutputFieldTemplate } from 'features/nodes/hooks/useOutputFieldTemplate';
import { useFieldTypeName } from 'features/nodes/hooks/usePrettyFieldType';
import { HANDLE_TOOLTIP_OPEN_DELAY, MODEL_TYPES } from 'features/nodes/types/constants';

View File

@@ -5,7 +5,7 @@ import {
useConnectionValidationResult,
useIsConnectionInProgress,
useIsConnectionStartField,
} from 'features/nodes/hooks/useInputFieldConnectionState';
} from 'features/nodes/hooks/useFieldConnectionState';
import { useInputFieldIsConnected } from 'features/nodes/hooks/useInputFieldIsConnected';
import { useOutputFieldTemplate } from 'features/nodes/hooks/useOutputFieldTemplate';
import { HANDLE_TOOLTIP_OPEN_DELAY } from 'features/nodes/types/constants';

View File

@@ -1,35 +0,0 @@
import { useStore } from '@nanostores/react';
import { useAppSelector } from 'app/store/storeHooks';
import { $edgePendingUpdate, $pendingConnection, $templates } from 'features/nodes/store/nodesSlice';
import { makeConnectionErrorSelector } from 'features/nodes/store/util/makeConnectionErrorSelector';
import { useMemo } from 'react';
export const useOutputFieldConnectionState = (nodeId: string, fieldName: string) => {
const pendingConnection = useStore($pendingConnection);
const templates = useStore($templates);
const edgePendingUpdate = useStore($edgePendingUpdate);
const selectValidationResult = useMemo(
() => makeConnectionErrorSelector(templates, nodeId, fieldName, 'source', pendingConnection, edgePendingUpdate),
[templates, nodeId, fieldName, pendingConnection, edgePendingUpdate]
);
const isConnectionInProgress = useMemo(() => Boolean(pendingConnection), [pendingConnection]);
const isConnectionStartField = useMemo(() => {
if (!pendingConnection) {
return false;
}
return (
pendingConnection.nodeId === nodeId &&
pendingConnection.handleId === fieldName &&
pendingConnection.fieldTemplate.fieldKind === 'output'
);
}, [fieldName, nodeId, pendingConnection]);
const validationResult = useAppSelector(selectValidationResult);
return {
isConnectionInProgress,
isConnectionStartField,
validationResult,
};
};

View File

@@ -1,21 +0,0 @@
import { createSelector } from '@reduxjs/toolkit';
import { useAppSelector } from 'app/store/storeHooks';
import { selectNodesSlice } from 'features/nodes/store/selectors';
import { useMemo } from 'react';
export const useOutputFieldIsConnected = (nodeId: string, fieldName: string) => {
const selector = useMemo(
() =>
createSelector(selectNodesSlice, (nodes) => {
const firstConnectedEdge = nodes.edges.find((edge) => {
return edge.source === nodeId && edge.sourceHandle === fieldName;
});
return firstConnectedEdge !== undefined;
}),
[fieldName, nodeId]
);
const isConnected = useAppSelector(selector);
return isConnected;
};

View File

@@ -9,7 +9,7 @@ import type { SetNonNullable } from 'type-fest';
type Connection = SetNonNullable<NullableConnection>;
export type ValidationResult =
type ValidationResult =
| {
isValid: true;
messageTKey?: string;