Projekt

Obecné

Profil

Stáhnout (1.38 KB) Statistiky
| Větev: | Tag: | Revize:
1 812b9f90 Vaclav Honzik
import { memo } from 'react'
2 7d477849 Vaclav Honzik
import {
3
    DragDropContext,
4
    Droppable,
5
    OnDragEndResponder,
6
} from 'react-beautiful-dnd'
7 c0b66eaf Vaclav Honzik
import { MapPoint } from '../trackingToolUtils'
8
import MapPointDraggableListItem from './MapPointDraggableListItem'
9 812b9f90 Vaclav Honzik
10
export interface DraggableListProps {
11
    items: MapPoint[]
12
    onDragEnd: OnDragEndResponder
13
}
14
15 f41a4cd3 Vaclav Honzik
window.addEventListener('error', (e) => {
16
    if (
17
        e.message ===
18
            'ResizeObserver loop completed with undelivered notifications.' ||
19
        e.message === 'ResizeObserver loop limit exceeded'
20
    ) {
21
        e.stopImmediatePropagation()
22
    }
23
})
24 7d477849 Vaclav Honzik
25 c0b66eaf Vaclav Honzik
const DragDropCtxWrapper = memo(({ items, onDragEnd }: DraggableListProps) => {
26 812b9f90 Vaclav Honzik
    return (
27
        <DragDropContext onDragEnd={onDragEnd}>
28
            <Droppable droppableId="droppable-list">
29
                {(provided) => (
30
                    <div ref={provided.innerRef} {...provided.droppableProps}>
31
                        {items.map((item, index) => (
32 c0b66eaf Vaclav Honzik
                            <MapPointDraggableListItem
33 812b9f90 Vaclav Honzik
                                list={items}
34 7d477849 Vaclav Honzik
                                idx={index}
35 14588cb6 Vaclav Honzik
                                key={item.reactId}
36 812b9f90 Vaclav Honzik
                            />
37
                        ))}
38
                        {provided.placeholder}
39
                    </div>
40
                )}
41
            </Droppable>
42
        </DragDropContext>
43
    )
44
})
45
46 c0b66eaf Vaclav Honzik
export default DragDropCtxWrapper