This commit is contained in:
Jennifer Player 2024-02-14 14:52:48 -05:00
parent a948bd1310
commit 21ba3c63de
5 changed files with 2 additions and 57 deletions

View File

@ -1,45 +0,0 @@
import { Box } from '@invoke-ai/ui-library';
import { useDroppableTypesafe } from 'features/dnd/hooks/typesafeHooks';
import type { TypesafeDroppableData } from 'features/dnd/types';
import { isValidDrop } from 'features/dnd/util/isValidDrop';
import { AnimatePresence } from 'framer-motion';
import type { ReactNode } from 'react';
import { memo, useRef } from 'react';
import { v4 as uuidv4 } from 'uuid';
import IAIDropOverlay from './IAIDropOverlay';
type IAISortableItemProps = {
dropLabel?: ReactNode;
disabled?: boolean;
data?: TypesafeDroppableData;
};
const IAISortableItem = (props: IAISortableItemProps) => {
const { dropLabel, data, disabled } = props;
const dndId = useRef(uuidv4());
const { isOver, setNodeRef, active } = useDroppableTypesafe({
id: dndId.current,
disabled,
data,
});
return (
<Box
ref={setNodeRef}
position="absolute"
top={0}
insetInlineStart={0}
w="full"
h="full"
pointerEvents={active ? 'auto' : 'none'}
>
<AnimatePresence>
{isValidDrop(data, active) && <IAIDropOverlay isOver={isOver} label={dropLabel} />}
</AnimatePresence>
</Box>
);
};
export default memo(IAISortableItem);

View File

@ -19,7 +19,6 @@ const AppDndContext = (props: PropsWithChildren) => {
const handleDragStart = useCallback(
(event: DragStartEvent) => {
console.log('handling drag start', event.active.data.current);
log.trace({ dragData: parseify(event.active.data.current) }, 'Drag started');
const activeData = event.active.data.current;
if (!activeData) {

View File

@ -23,7 +23,7 @@ const DndSortable = (props: Props) => {
const sensors = useSensors(mouseSensor, touchSensor);
return (
<DndContextTypesafe sensors={sensors}>
<DndContextTypesafe onDragEnd={props.onDragEnd} sensors={sensors}>
<SortableContext items={props.items}>{props.children}</SortableContext>
</DndContextTypesafe>
);

View File

@ -80,14 +80,6 @@ export type NodeFieldDraggableData = BaseDragData & {
};
};
export type LinearViewFieldDraggableData = BaseDragData & {
payloadType: 'LINEAR_VIEW_FIELD';
payload: {
nodeId: string;
fieldName: string;
};
};
export type ImageDraggableData = BaseDragData & {
payloadType: 'IMAGE_DTO';
payload: { imageDTO: ImageDTO };
@ -100,7 +92,6 @@ export type GallerySelectionDraggableData = BaseDragData & {
export type TypesafeDraggableData =
| NodeFieldDraggableData
| LinearViewFieldDraggableData
| ImageDraggableData
| GallerySelectionDraggableData;

View File

@ -23,7 +23,7 @@ const LinearViewField = ({ nodeId, fieldName }: Props) => {
const dispatch = useAppDispatch();
const { isMouseOverNode, handleMouseOut, handleMouseOver } = useMouseOverNode(nodeId);
const { t } = useTranslation();
const handleRemoveField = useCallback(() => {
dispatch(workflowExposedFieldRemoved({ nodeId, fieldName }));
}, [dispatch, fieldName, nodeId]);