mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
cleanup
This commit is contained in:
parent
a948bd1310
commit
21ba3c63de
@ -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);
|
|
@ -19,7 +19,6 @@ const AppDndContext = (props: PropsWithChildren) => {
|
|||||||
|
|
||||||
const handleDragStart = useCallback(
|
const handleDragStart = useCallback(
|
||||||
(event: DragStartEvent) => {
|
(event: DragStartEvent) => {
|
||||||
console.log('handling drag start', event.active.data.current);
|
|
||||||
log.trace({ dragData: parseify(event.active.data.current) }, 'Drag started');
|
log.trace({ dragData: parseify(event.active.data.current) }, 'Drag started');
|
||||||
const activeData = event.active.data.current;
|
const activeData = event.active.data.current;
|
||||||
if (!activeData) {
|
if (!activeData) {
|
||||||
|
@ -23,7 +23,7 @@ const DndSortable = (props: Props) => {
|
|||||||
const sensors = useSensors(mouseSensor, touchSensor);
|
const sensors = useSensors(mouseSensor, touchSensor);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DndContextTypesafe sensors={sensors}>
|
<DndContextTypesafe onDragEnd={props.onDragEnd} sensors={sensors}>
|
||||||
<SortableContext items={props.items}>{props.children}</SortableContext>
|
<SortableContext items={props.items}>{props.children}</SortableContext>
|
||||||
</DndContextTypesafe>
|
</DndContextTypesafe>
|
||||||
);
|
);
|
||||||
|
@ -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 & {
|
export type ImageDraggableData = BaseDragData & {
|
||||||
payloadType: 'IMAGE_DTO';
|
payloadType: 'IMAGE_DTO';
|
||||||
payload: { imageDTO: ImageDTO };
|
payload: { imageDTO: ImageDTO };
|
||||||
@ -100,7 +92,6 @@ export type GallerySelectionDraggableData = BaseDragData & {
|
|||||||
|
|
||||||
export type TypesafeDraggableData =
|
export type TypesafeDraggableData =
|
||||||
| NodeFieldDraggableData
|
| NodeFieldDraggableData
|
||||||
| LinearViewFieldDraggableData
|
|
||||||
| ImageDraggableData
|
| ImageDraggableData
|
||||||
| GallerySelectionDraggableData;
|
| GallerySelectionDraggableData;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ const LinearViewField = ({ nodeId, fieldName }: Props) => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { isMouseOverNode, handleMouseOut, handleMouseOver } = useMouseOverNode(nodeId);
|
const { isMouseOverNode, handleMouseOut, handleMouseOver } = useMouseOverNode(nodeId);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleRemoveField = useCallback(() => {
|
const handleRemoveField = useCallback(() => {
|
||||||
dispatch(workflowExposedFieldRemoved({ nodeId, fieldName }));
|
dispatch(workflowExposedFieldRemoved({ nodeId, fieldName }));
|
||||||
}, [dispatch, fieldName, nodeId]);
|
}, [dispatch, fieldName, nodeId]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user