@pega/cosmos-react-dnd 4.0.0-dev.1.1 → 4.0.0-dev.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/DragDropList/DragDropList.d.ts +1 -1
- package/lib/components/DragDropList/DragDropList.d.ts.map +1 -1
- package/lib/components/DragDropList/DragDropList.js +66 -29
- package/lib/components/DragDropList/DragDropList.js.map +1 -1
- package/lib/components/DragDropList/DragDropList.types.d.ts +12 -3
- package/lib/components/DragDropList/DragDropList.types.d.ts.map +1 -1
- package/lib/components/DragDropList/DragDropList.types.js.map +1 -1
- package/lib/components/DragDropManager/DragDropManager.d.ts +1 -0
- package/lib/components/DragDropManager/DragDropManager.d.ts.map +1 -1
- package/lib/components/DragDropManager/DragDropManager.js +2 -2
- package/lib/components/DragDropManager/DragDropManager.js.map +1 -1
- package/lib/components/StandardDragDropList/StandardDragDropList.styles.js +1 -1
- package/lib/components/StandardDragDropList/StandardDragDropList.styles.js.map +1 -1
- package/lib/components/StandardDragDropList/StandardDragDropList.types.d.ts +2 -2
- package/lib/components/StandardDragDropList/StandardDragDropList.types.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
3
|
import { DragDropListProps } from './DragDropList.types';
|
|
4
|
-
declare const DragDropList: <T extends object = object>({ accept, items, itemRenderer: ItemRenderer, emptyRenderer: EmptyRenderer, onChange, pullMode, pushMode, as: Component, ...restProps }: DragDropListProps<T> & ForwardProps) => JSX.Element;
|
|
4
|
+
declare const DragDropList: <T extends object = object>({ id: idProp, accept, items, itemRenderer: ItemRenderer, emptyRenderer: EmptyRenderer, onChange, onEnter, pullMode, pushMode, dragToRemove, as: Component, ...restProps }: DragDropListProps<T> & ForwardProps) => JSX.Element;
|
|
5
5
|
export default DragDropList;
|
|
6
6
|
//# sourceMappingURL=DragDropList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropList.d.ts","sourceRoot":"","sources":["../../../src/components/DragDropList/DragDropList.tsx"],"names":[],"mappings":";AAGA,OAAO,EAIL,YAAY,
|
|
1
|
+
{"version":3,"file":"DragDropList.d.ts","sourceRoot":"","sources":["../../../src/components/DragDropList/DragDropList.tsx"],"names":[],"mappings":";AAGA,OAAO,EAIL,YAAY,EAGb,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAgBzD,QAAA,MAAM,YAAY,4PAwRjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useState, useRef } from 'react';
|
|
3
|
-
import { useElement, useAfterInitialEffect, useTriggerableEffect } from '@pega/cosmos-react-core';
|
|
3
|
+
import { useElement, useAfterInitialEffect, useTriggerableEffect, useUID } from '@pega/cosmos-react-core';
|
|
4
4
|
import Draggable from '../Draggable';
|
|
5
5
|
import Droppable from '../Droppable';
|
|
6
6
|
const middleYOfRect = ({ top, bottom }) => top + (bottom - top) / 2;
|
|
7
|
-
const DragDropList = ({ accept, items, itemRenderer: ItemRenderer, emptyRenderer: EmptyRenderer, onChange, pullMode = 'remove', pushMode = 'insert', as: Component = 'ul', ...restProps }) => {
|
|
7
|
+
const DragDropList = ({ id: idProp, accept, items, itemRenderer: ItemRenderer, emptyRenderer: EmptyRenderer, onChange, onEnter, pullMode = 'remove', pushMode = 'insert', dragToRemove = false, as: Component = 'ul', ...restProps }) => {
|
|
8
8
|
const [internalItems, setInternalItems] = useState(items);
|
|
9
9
|
const itemRectsRef = useRef(null);
|
|
10
|
+
const transformedItem = useRef(null);
|
|
10
11
|
const [listEl, setListEl] = useElement();
|
|
12
|
+
const uniqueId = useUID();
|
|
13
|
+
const listId = idProp ?? uniqueId;
|
|
11
14
|
const getItemRects = useCallback(() => {
|
|
12
15
|
if (!listEl || listEl.children.length === 0)
|
|
13
16
|
return null;
|
|
@@ -20,9 +23,34 @@ const DragDropList = ({ accept, items, itemRenderer: ItemRenderer, emptyRenderer
|
|
|
20
23
|
}, [items]);
|
|
21
24
|
const internalItemsRef = useRef(internalItems);
|
|
22
25
|
internalItemsRef.current = internalItems;
|
|
23
|
-
const triggerOnChange = useTriggerableEffect(useCallback((newItems) => {
|
|
24
|
-
onChange(newItems);
|
|
26
|
+
const triggerOnChange = useTriggerableEffect(useCallback((newItems, insertIndex) => {
|
|
27
|
+
onChange(newItems, insertIndex);
|
|
25
28
|
}, [onChange]));
|
|
29
|
+
const getTransformedItem = useCallback((item) => {
|
|
30
|
+
if (!onEnter) {
|
|
31
|
+
transformedItem.current = null;
|
|
32
|
+
return item;
|
|
33
|
+
}
|
|
34
|
+
if (transformedItem.current)
|
|
35
|
+
return transformedItem.current;
|
|
36
|
+
const newItem = {
|
|
37
|
+
...item,
|
|
38
|
+
...onEnter(item),
|
|
39
|
+
id: item.id
|
|
40
|
+
};
|
|
41
|
+
transformedItem.current = newItem;
|
|
42
|
+
return newItem;
|
|
43
|
+
}, [onEnter]);
|
|
44
|
+
const changeSource = useCallback((itemId, destinationId) => {
|
|
45
|
+
const sourcePullMode = typeof pullMode === 'function' ? pullMode(destinationId) : pullMode;
|
|
46
|
+
if (sourcePullMode === 'remove') {
|
|
47
|
+
const newList = internalItems.filter(({ id }) => id !== itemId);
|
|
48
|
+
triggerOnChange(newList);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
setInternalItems(items);
|
|
52
|
+
}
|
|
53
|
+
}, [pullMode, items, internalItems, triggerOnChange]);
|
|
26
54
|
const getInsertIndex = useCallback((item, monitor) => {
|
|
27
55
|
itemRectsRef.current = getItemRects();
|
|
28
56
|
const { current: itemRects } = itemRectsRef;
|
|
@@ -62,10 +90,8 @@ const DragDropList = ({ accept, items, itemRenderer: ItemRenderer, emptyRenderer
|
|
|
62
90
|
return insertIndex;
|
|
63
91
|
}, [getItemRects, internalItems]);
|
|
64
92
|
const removeById = useCallback((itemId) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
}, [pullMode]);
|
|
93
|
+
setInternalItems(currentItems => currentItems.filter(({ id }) => id !== itemId));
|
|
94
|
+
}, []);
|
|
69
95
|
const normalizeItems = useCallback(() => {
|
|
70
96
|
setInternalItems(currentItems => currentItems.map(({ id, data, type }) => ({
|
|
71
97
|
id,
|
|
@@ -82,10 +108,12 @@ const DragDropList = ({ accept, items, itemRenderer: ItemRenderer, emptyRenderer
|
|
|
82
108
|
item.removeFromCurrent = () => {
|
|
83
109
|
removeById(item.id);
|
|
84
110
|
};
|
|
85
|
-
item.normalizeDestination = normalizeItems;
|
|
86
|
-
item.changeDestination = triggerOnChange;
|
|
87
|
-
item.destinationItemsRef = internalItemsRef;
|
|
88
111
|
}
|
|
112
|
+
item.normalizeDestination = normalizeItems;
|
|
113
|
+
item.changeDestination = triggerOnChange;
|
|
114
|
+
item.destinationItemsRef = internalItemsRef;
|
|
115
|
+
item.transformedItemCache?.add(transformedItem);
|
|
116
|
+
item.destinationId = listId;
|
|
89
117
|
let insertIndex = 0;
|
|
90
118
|
if (pushMode === 'insert')
|
|
91
119
|
insertIndex = getInsertIndex(item, monitor);
|
|
@@ -97,7 +125,7 @@ const DragDropList = ({ accept, items, itemRenderer: ItemRenderer, emptyRenderer
|
|
|
97
125
|
if (insertIndex === prevIndex || pushMode !== 'insert')
|
|
98
126
|
return;
|
|
99
127
|
newItems = internalItems.filter(({ id }) => id !== item.id);
|
|
100
|
-
newItems.splice(insertIndex, 0, item);
|
|
128
|
+
newItems.splice(insertIndex, 0, transformedItem.current ?? item);
|
|
101
129
|
if (typeof pushMode === 'function')
|
|
102
130
|
setInternalItems(newItems.sort(pushMode));
|
|
103
131
|
else
|
|
@@ -105,21 +133,18 @@ const DragDropList = ({ accept, items, itemRenderer: ItemRenderer, emptyRenderer
|
|
|
105
133
|
}
|
|
106
134
|
else {
|
|
107
135
|
newItems = [...internalItems];
|
|
108
|
-
newItems.splice(insertIndex, 0, item);
|
|
136
|
+
newItems.splice(insertIndex, 0, getTransformedItem(item));
|
|
109
137
|
if (typeof pushMode === 'function')
|
|
110
138
|
setInternalItems(newItems.sort(pushMode));
|
|
111
139
|
else
|
|
112
140
|
setInternalItems(newItems);
|
|
113
141
|
}
|
|
114
|
-
}, [internalItems, pushMode, getInsertIndex, normalizeItems, triggerOnChange, removeById]);
|
|
142
|
+
}, [internalItems, pushMode, getInsertIndex, normalizeItems, triggerOnChange, removeById, listId]);
|
|
115
143
|
const onHover = positionItems;
|
|
116
144
|
const onDrop = positionItems;
|
|
117
145
|
const onBegin = useCallback((itemId) => () => {
|
|
118
146
|
const initialIndex = internalItems.findIndex(({ id }) => id === itemId);
|
|
119
147
|
return {
|
|
120
|
-
removeFromCurrent: () => {
|
|
121
|
-
removeById(itemId);
|
|
122
|
-
},
|
|
123
148
|
returnToSource: (item) => {
|
|
124
149
|
setInternalItems(currentItems => {
|
|
125
150
|
const newItems = currentItems.filter(({ id }) => id !== itemId);
|
|
@@ -129,29 +154,41 @@ const DragDropList = ({ accept, items, itemRenderer: ItemRenderer, emptyRenderer
|
|
|
129
154
|
normalizeItems();
|
|
130
155
|
},
|
|
131
156
|
normalizeDestination: normalizeItems,
|
|
132
|
-
changeSource
|
|
133
|
-
sourceItemsRef: internalItemsRef,
|
|
157
|
+
changeSource,
|
|
134
158
|
changeDestination: triggerOnChange,
|
|
135
|
-
destinationItemsRef: internalItemsRef
|
|
159
|
+
destinationItemsRef: internalItemsRef,
|
|
160
|
+
transformedItemCache: new Set([transformedItem]),
|
|
161
|
+
sourceId: listId,
|
|
162
|
+
destinationId: listId
|
|
136
163
|
};
|
|
137
|
-
}, [internalItems, normalizeItems, triggerOnChange, removeById]);
|
|
164
|
+
}, [internalItems, normalizeItems, triggerOnChange, changeSource, removeById, listId]);
|
|
138
165
|
const onEnd = useCallback((item, monitor) => {
|
|
139
166
|
if (!item)
|
|
140
167
|
return;
|
|
141
168
|
if (monitor.didDrop()) {
|
|
142
|
-
const
|
|
143
|
-
|
|
169
|
+
const { id: itemId, sourceId, destinationId } = item;
|
|
170
|
+
let insertIndex;
|
|
144
171
|
item.normalizeDestination?.();
|
|
145
|
-
|
|
146
|
-
|
|
172
|
+
const destinationItems = item.destinationItemsRef.current;
|
|
173
|
+
if (sourceId && destinationId && sourceId !== destinationId) {
|
|
174
|
+
item.changeSource?.(itemId, destinationId);
|
|
175
|
+
insertIndex = destinationItems.findIndex(({ id }) => id === itemId);
|
|
147
176
|
}
|
|
148
|
-
item.changeDestination?.(destinationItems);
|
|
177
|
+
item.changeDestination?.(destinationItems, insertIndex);
|
|
149
178
|
}
|
|
150
179
|
else {
|
|
151
180
|
item.removeFromCurrent?.();
|
|
152
|
-
|
|
181
|
+
if (dragToRemove) {
|
|
182
|
+
removeById(item.id);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
item.returnToSource?.(item);
|
|
186
|
+
}
|
|
153
187
|
}
|
|
154
|
-
|
|
188
|
+
item.transformedItemCache?.forEach(ref => {
|
|
189
|
+
ref.current = null;
|
|
190
|
+
});
|
|
191
|
+
}, [dragToRemove]);
|
|
155
192
|
const emptyContent = EmptyRenderer ? _jsx(EmptyRenderer, {}) : null;
|
|
156
193
|
return (_jsx(Droppable, { accept: accept, onHover: onHover, onDrop: onDrop, children: ({ dropRef }) => {
|
|
157
194
|
return (_jsx(Component, { ref: (el) => {
|
|
@@ -166,7 +203,7 @@ const DragDropList = ({ accept, items, itemRenderer: ItemRenderer, emptyRenderer
|
|
|
166
203
|
dragRef,
|
|
167
204
|
previewRef,
|
|
168
205
|
...collected,
|
|
169
|
-
isDragging:
|
|
206
|
+
isDragging: !!item.sourceId
|
|
170
207
|
} }));
|
|
171
208
|
} }, item.id));
|
|
172
209
|
}) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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AC,CAAC,KAAC,aAAa,KAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9D,OAAO,CACL,KAAC,SAAS,IAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YACxD,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;YACf,OAAO,CACL,KAAC,SAAS,IACR,GAAG,EAAE,CAAC,EAAe,EAAE,EAAE;oBACvB,OAAO,CAAC,EAAE,CAAC,CAAC;oBACZ,SAAS,CAAC,EAAE,CAAC,CAAC;gBAChB,CAAC,KACG,SAAS,YAEZ,aAAa,CAAC,MAAM,KAAK,CAAC;oBACzB,CAAC,CAAC,YAAY;oBACd,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;wBACvB,OAAO,CACL,KAAC,SAAS,IAER,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EACzB,KAAK,EAAE,KAAK,YAEX,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE;gCACtC,OAAO,CACL,KAAC,YAAY,OACP;wCACF,GAAG,IAAI;wCACP,OAAO;wCACP,UAAU;wCACV,GAAG,SAAS;wCACZ,UAAU,EAAE,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,CAAC,iBAAiB;qCAC7D,GACD,CACH,CAAC;4BACJ,CAAC,IAnBI,IAAI,CAAC,EAAE,CAoBF,CACb,CAAC;oBACJ,CAAC,CAAC,GACI,CACb,CAAC;QACJ,CAAC,GACS,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useCallback, useState, useRef, RefObject } from 'react';\nimport { DragSourceMonitor, DropTargetMonitor } from 'react-dnd';\n\nimport {\n useElement,\n useAfterInitialEffect,\n useTriggerableEffect,\n ForwardProps,\n OmitStrict\n} from '@pega/cosmos-react-core';\n\nimport Draggable, { DraggableItem } from '../Draggable';\nimport Droppable from '../Droppable';\n\nimport { DragDropListProps } from './DragDropList.types';\n\ninterface DragDropListItem<T extends object = object> extends DraggableItem<T> {\n removeFromCurrent?: () => void;\n returnToSource?: (item: DraggableItem<T>) => void;\n normalizeDestination?: () => void;\n changeSource?: (items: DragDropListItem<T>[]) => void;\n sourceItemsRef?: RefObject<DragDropListItem<T>[]>;\n changeDestination?: (items: DragDropListItem<T>[]) => void;\n destinationItemsRef?: RefObject<DragDropListItem<T>[]>;\n}\n\nconst middleYOfRect = ({ top, bottom }: DOMRect): number => top + (bottom - top) / 2;\n\nconst DragDropList = <T extends object = object>({\n accept,\n items,\n itemRenderer: ItemRenderer,\n emptyRenderer: EmptyRenderer,\n onChange,\n pullMode = 'remove',\n pushMode = 'insert',\n as: Component = 'ul',\n ...restProps\n}: DragDropListProps<T> & ForwardProps) => {\n const [internalItems, setInternalItems] = useState<DragDropListItem<T>[]>(items);\n const itemRectsRef = useRef<DOMRect[] | null>(null);\n const [listEl, setListEl] = useElement<HTMLElement>();\n\n const getItemRects = useCallback((): DOMRect[] | null => {\n if (!listEl || listEl.children.length === 0) return null;\n return [...listEl.children].map(itemEl => {\n return itemEl.getBoundingClientRect();\n });\n }, [listEl]);\n\n useAfterInitialEffect(() => {\n setInternalItems(items);\n }, [items]);\n\n const internalItemsRef = useRef(internalItems);\n internalItemsRef.current = internalItems;\n\n const triggerOnChange = useTriggerableEffect(\n useCallback(\n (newItems: DragDropListItem<T>[]) => {\n onChange(newItems);\n },\n [onChange]\n )\n );\n\n const getInsertIndex = useCallback(\n (item: DraggableItem<T>, monitor: DropTargetMonitor | DragSourceMonitor): number => {\n itemRectsRef.current = getItemRects();\n const { current: itemRects } = itemRectsRef;\n let insertIndex = -1;\n const prevIndex = internalItems.findIndex(({ id }) => id === item.id);\n\n const clientXY = monitor.getClientOffset();\n if (!itemRects || !clientXY) return insertIndex;\n\n const dragPreviewRectTop = clientXY.y;\n const atHead = dragPreviewRectTop < middleYOfRect(itemRects[0]);\n const atTail = dragPreviewRectTop >= middleYOfRect(itemRects[itemRects.length - 1]);\n\n if (atHead) {\n insertIndex = 0;\n } else if (atTail) {\n insertIndex = prevIndex === itemRects.length - 1 ? prevIndex : itemRects.length;\n } else {\n itemRects.some((rect, i, rects) => {\n if (i === rects.length - 1) {\n if (prevIndex === i) insertIndex = i;\n return true;\n }\n const belowCurrent = dragPreviewRectTop >= middleYOfRect(rect);\n const aboveNext = dragPreviewRectTop < middleYOfRect(rects[i + 1]);\n if (belowCurrent && aboveNext) {\n if (prevIndex !== -1 && i >= prevIndex) insertIndex = i;\n else insertIndex = i + 1;\n return true;\n }\n return false;\n });\n }\n\n return insertIndex;\n },\n [getItemRects, internalItems]\n );\n\n const removeById = useCallback(\n (itemId: DraggableItem<T>['id']): void => {\n if (pullMode === 'remove') {\n setInternalItems(currentItems => currentItems.filter(({ id }) => id !== itemId));\n }\n },\n [pullMode]\n );\n\n const normalizeItems = useCallback(() => {\n setInternalItems(currentItems =>\n currentItems.map(({ id, data, type }) => ({\n id,\n data,\n type\n }))\n );\n }, []);\n\n const positionItems = useCallback(\n (item: DragDropListItem<T>, monitor: DropTargetMonitor): void => {\n if (!monitor.canDrop() || !monitor.isOver({ shallow: true })) return;\n\n const prevIndex = internalItems.findIndex(({ id }) => id === item.id);\n\n if (prevIndex === -1) {\n item.removeFromCurrent?.();\n item.removeFromCurrent = () => {\n removeById(item.id);\n };\n item.normalizeDestination = normalizeItems;\n item.changeDestination = triggerOnChange;\n item.destinationItemsRef = internalItemsRef;\n }\n\n let insertIndex = 0;\n if (pushMode === 'insert') insertIndex = getInsertIndex(item, monitor);\n if (pushMode === 'append') insertIndex = internalItems.length + 1;\n\n let newItems: DraggableItem<T>[];\n\n // Is the current being dragged is within its own list\n if (prevIndex !== -1) {\n if (insertIndex === prevIndex || pushMode !== 'insert') return;\n\n newItems = internalItems.filter(({ id }) => id !== item.id);\n newItems.splice(insertIndex, 0, item);\n\n if (typeof pushMode === 'function') setInternalItems(newItems.sort(pushMode));\n else setInternalItems(newItems);\n } else {\n newItems = [...internalItems];\n newItems.splice(insertIndex, 0, item);\n\n if (typeof pushMode === 'function') setInternalItems(newItems.sort(pushMode));\n else setInternalItems(newItems);\n }\n },\n [internalItems, pushMode, getInsertIndex, normalizeItems, triggerOnChange, removeById]\n );\n\n const onHover = positionItems;\n const onDrop = positionItems;\n\n const onBegin = useCallback(\n (itemId: DraggableItem<T>['id']) =>\n (): OmitStrict<DragDropListItem<T>, keyof DraggableItem<T>> => {\n const initialIndex = internalItems.findIndex(({ id }) => id === itemId);\n\n return {\n removeFromCurrent: () => {\n removeById(itemId);\n },\n returnToSource: (item: DraggableItem<T>) => {\n setInternalItems(currentItems => {\n const newItems = currentItems.filter(({ id }) => id !== itemId);\n newItems.splice(initialIndex, 0, item);\n return newItems;\n });\n normalizeItems();\n },\n normalizeDestination: normalizeItems,\n changeSource: triggerOnChange,\n sourceItemsRef: internalItemsRef,\n changeDestination: triggerOnChange,\n destinationItemsRef: internalItemsRef\n };\n },\n [internalItems, normalizeItems, triggerOnChange, removeById]\n );\n\n const onEnd = useCallback((item: DragDropListItem<T> | undefined, monitor: DragSourceMonitor) => {\n if (!item) return;\n\n if (monitor.didDrop()) {\n const sourceItems = item.sourceItemsRef!.current!;\n const destinationItems = item.destinationItemsRef!.current!;\n\n item.normalizeDestination?.();\n if (item.changeSource !== item.changeDestination) {\n item.changeSource?.(sourceItems);\n }\n item.changeDestination?.(destinationItems);\n } else {\n item.removeFromCurrent?.();\n item.returnToSource?.(item);\n }\n }, []);\n\n const emptyContent = EmptyRenderer ? <EmptyRenderer /> : null;\n\n return (\n <Droppable accept={accept} onHover={onHover} onDrop={onDrop}>\n {({ dropRef }) => {\n return (\n <Component\n ref={(el: HTMLElement) => {\n dropRef(el);\n setListEl(el);\n }}\n {...restProps}\n >\n {internalItems.length === 0\n ? emptyContent\n : internalItems.map(item => {\n return (\n <Draggable\n key={item.id}\n id={item.id}\n type={item.type}\n data={item.data}\n onBegin={onBegin(item.id)}\n onEnd={onEnd}\n >\n {({ dragRef, previewRef, collected }) => {\n return (\n <ItemRenderer\n {...{\n ...item,\n dragRef,\n previewRef,\n ...collected,\n isDragging: collected.isDragging || !!item.removeFromCurrent\n }}\n />\n );\n }}\n </Draggable>\n );\n })}\n </Component>\n );\n }}\n </Droppable>\n );\n};\n\nexport default DragDropList;\n"]}
|
|
1
|
+
{"version":3,"file":"DragDropList.js","sourceRoot":"","sources":["../../../src/components/DragDropList/DragDropList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAA+B,MAAM,OAAO,CAAC;AAGnF,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EAGpB,MAAM,EACP,MAAM,yBAAyB,CAAC;AAEjC,OAAO,SAA4B,MAAM,cAAc,CAAC;AACxD,OAAO,SAAS,MAAM,cAAc,CAAC;AAgBrC,MAAM,aAAa,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,EAAW,EAAU,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;AAErF,MAAM,YAAY,GAAG,CAA4B,EAC/C,EAAE,EAAE,MAAM,EACV,MAAM,EACN,KAAK,EACL,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,QAAQ,EACR,OAAO,EACP,QAAQ,GAAG,QAAQ,EACnB,QAAQ,GAAG,QAAQ,EACnB,YAAY,GAAG,KAAK,EACpB,EAAE,EAAE,SAAS,GAAG,IAAI,EACpB,GAAG,SAAS,EACwB,EAAE,EAAE;IACxC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAwB,KAAK,CAAC,CAAC;IACjF,MAAM,YAAY,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;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E,CAAC,CAAC;gBAChB,CAAC,KACG,SAAS,YAEZ,aAAa,CAAC,MAAM,KAAK,CAAC;oBACzB,CAAC,CAAC,YAAY;oBACd,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;wBACvB,OAAO,CACL,KAAC,SAAS,IAER,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EACzB,KAAK,EAAE,KAAK,YAEX,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE;gCACtC,OAAO,CACL,KAAC,YAAY,OACP;wCACF,GAAG,IAAI;wCACP,OAAO;wCACP,UAAU;wCACV,GAAG,SAAS;wCACZ,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;qCAC5B,GACD,CACH,CAAC;4BACJ,CAAC,IAnBI,IAAI,CAAC,EAAE,CAoBF,CACb,CAAC;oBACJ,CAAC,CAAC,GACI,CACb,CAAC;QACJ,CAAC,GACS,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useCallback, useState, useRef, RefObject, MutableRefObject } from 'react';\nimport { DragSourceMonitor, DropTargetMonitor } from 'react-dnd';\n\nimport {\n useElement,\n useAfterInitialEffect,\n useTriggerableEffect,\n ForwardProps,\n OmitStrict,\n useUID\n} from '@pega/cosmos-react-core';\n\nimport Draggable, { DraggableItem } from '../Draggable';\nimport Droppable from '../Droppable';\n\nimport { DragDropListProps } from './DragDropList.types';\n\ninterface DragDropListItem<T extends object = object> extends DraggableItem<T> {\n removeFromCurrent?: () => void;\n returnToSource?: (item: DraggableItem<T>) => void;\n normalizeDestination?: () => void;\n changeSource?: (itemId: DraggableItem<T>['id'], destinationId: string) => void;\n changeDestination?: (items: DragDropListItem<T>[], insertIndex?: number) => void;\n destinationItemsRef?: RefObject<DragDropListItem<T>[]>;\n transformedItemCache?: Set<MutableRefObject<DraggableItem<T> | null>>;\n sourceId?: string;\n destinationId?: string;\n}\n\nconst middleYOfRect = ({ top, bottom }: DOMRect): number => top + (bottom - top) / 2;\n\nconst DragDropList = <T extends object = object>({\n id: idProp,\n accept,\n items,\n itemRenderer: ItemRenderer,\n emptyRenderer: EmptyRenderer,\n onChange,\n onEnter,\n pullMode = 'remove',\n pushMode = 'insert',\n dragToRemove = false,\n as: Component = 'ul',\n ...restProps\n}: DragDropListProps<T> & ForwardProps) => {\n const [internalItems, setInternalItems] = useState<DragDropListItem<T>[]>(items);\n const itemRectsRef = useRef<DOMRect[] | null>(null);\n const transformedItem = useRef<DraggableItem<T> | null>(null);\n const [listEl, setListEl] = useElement<HTMLElement>();\n const uniqueId = useUID();\n const listId = idProp ?? uniqueId;\n\n const getItemRects = useCallback((): DOMRect[] | null => {\n if (!listEl || listEl.children.length === 0) return null;\n return [...listEl.children].map(itemEl => {\n return itemEl.getBoundingClientRect();\n });\n }, [listEl]);\n\n useAfterInitialEffect(() => {\n setInternalItems(items);\n }, [items]);\n\n const internalItemsRef = useRef(internalItems);\n internalItemsRef.current = internalItems;\n\n const triggerOnChange = useTriggerableEffect(\n useCallback(\n (newItems: DragDropListItem<T>[], insertIndex?: number) => {\n onChange(newItems, insertIndex);\n },\n [onChange]\n )\n );\n\n const getTransformedItem = useCallback(\n (item: DragDropListItem<T>) => {\n if (!onEnter) {\n transformedItem.current = null;\n return item;\n }\n\n if (transformedItem.current) return transformedItem.current;\n\n const newItem = {\n ...item,\n ...onEnter(item),\n id: item.id\n };\n transformedItem.current = newItem;\n return newItem;\n },\n [onEnter]\n );\n\n const changeSource = useCallback(\n (itemId: DraggableItem<T>['id'], destinationId: string) => {\n const sourcePullMode = typeof pullMode === 'function' ? pullMode(destinationId) : pullMode;\n if (sourcePullMode === 'remove') {\n const newList = internalItems.filter(({ id }) => id !== itemId);\n triggerOnChange(newList);\n } else {\n setInternalItems(items);\n }\n },\n [pullMode, items, internalItems, triggerOnChange]\n );\n\n const getInsertIndex = useCallback(\n (item: DraggableItem<T>, monitor: DropTargetMonitor | DragSourceMonitor): number => {\n itemRectsRef.current = getItemRects();\n const { current: itemRects } = itemRectsRef;\n let insertIndex = -1;\n const prevIndex = internalItems.findIndex(({ id }) => id === item.id);\n\n const clientXY = monitor.getClientOffset();\n if (!itemRects || !clientXY) return insertIndex;\n\n const dragPreviewRectTop = clientXY.y;\n const atHead = dragPreviewRectTop < middleYOfRect(itemRects[0]);\n const atTail = dragPreviewRectTop >= middleYOfRect(itemRects[itemRects.length - 1]);\n\n if (atHead) {\n insertIndex = 0;\n } else if (atTail) {\n insertIndex = prevIndex === itemRects.length - 1 ? prevIndex : itemRects.length;\n } else {\n itemRects.some((rect, i, rects) => {\n if (i === rects.length - 1) {\n if (prevIndex === i) insertIndex = i;\n return true;\n }\n const belowCurrent = dragPreviewRectTop >= middleYOfRect(rect);\n const aboveNext = dragPreviewRectTop < middleYOfRect(rects[i + 1]);\n if (belowCurrent && aboveNext) {\n if (prevIndex !== -1 && i >= prevIndex) insertIndex = i;\n else insertIndex = i + 1;\n return true;\n }\n return false;\n });\n }\n\n return insertIndex;\n },\n [getItemRects, internalItems]\n );\n\n const removeById = useCallback((itemId: DraggableItem<T>['id']): void => {\n setInternalItems(currentItems => currentItems.filter(({ id }) => id !== itemId));\n }, []);\n\n const normalizeItems = useCallback(() => {\n setInternalItems(currentItems =>\n currentItems.map(({ id, data, type }) => ({\n id,\n data,\n type\n }))\n );\n }, []);\n\n const positionItems = useCallback(\n (item: DragDropListItem<T>, monitor: DropTargetMonitor): void => {\n if (!monitor.canDrop() || !monitor.isOver({ shallow: true })) return;\n\n const prevIndex = internalItems.findIndex(({ id }) => id === item.id);\n\n if (prevIndex === -1) {\n item.removeFromCurrent?.();\n item.removeFromCurrent = () => {\n removeById(item.id);\n };\n }\n\n item.normalizeDestination = normalizeItems;\n item.changeDestination = triggerOnChange;\n item.destinationItemsRef = internalItemsRef;\n item.transformedItemCache?.add(transformedItem);\n item.destinationId = listId;\n\n let insertIndex = 0;\n if (pushMode === 'insert') insertIndex = getInsertIndex(item, monitor);\n if (pushMode === 'append') insertIndex = internalItems.length + 1;\n\n let newItems: DraggableItem<T>[];\n\n // Is the current being dragged is within its own list\n if (prevIndex !== -1) {\n if (insertIndex === prevIndex || pushMode !== 'insert') return;\n\n newItems = internalItems.filter(({ id }) => id !== item.id);\n newItems.splice(insertIndex, 0, transformedItem.current ?? item);\n\n if (typeof pushMode === 'function') setInternalItems(newItems.sort(pushMode));\n else setInternalItems(newItems);\n } else {\n newItems = [...internalItems];\n newItems.splice(insertIndex, 0, getTransformedItem(item));\n\n if (typeof pushMode === 'function') setInternalItems(newItems.sort(pushMode));\n else setInternalItems(newItems);\n }\n },\n [internalItems, pushMode, getInsertIndex, normalizeItems, triggerOnChange, removeById, listId]\n );\n\n const onHover = positionItems;\n const onDrop = positionItems;\n\n const onBegin = useCallback(\n (itemId: DraggableItem<T>['id']) =>\n (): OmitStrict<DragDropListItem<T>, keyof DraggableItem<T>> => {\n const initialIndex = internalItems.findIndex(({ id }) => id === itemId);\n\n return {\n returnToSource: (item: DraggableItem<T>) => {\n setInternalItems(currentItems => {\n const newItems = currentItems.filter(({ id }) => id !== itemId);\n newItems.splice(initialIndex, 0, item);\n return newItems;\n });\n normalizeItems();\n },\n normalizeDestination: normalizeItems,\n changeSource,\n changeDestination: triggerOnChange,\n destinationItemsRef: internalItemsRef,\n transformedItemCache: new Set([transformedItem]),\n sourceId: listId,\n destinationId: listId\n };\n },\n [internalItems, normalizeItems, triggerOnChange, changeSource, removeById, listId]\n );\n\n const onEnd = useCallback(\n (item: DragDropListItem<T> | undefined, monitor: DragSourceMonitor) => {\n if (!item) return;\n\n if (monitor.didDrop()) {\n const { id: itemId, sourceId, destinationId } = item;\n let insertIndex;\n item.normalizeDestination?.();\n const destinationItems = item.destinationItemsRef!.current!;\n if (sourceId && destinationId && sourceId !== destinationId) {\n item.changeSource?.(itemId, destinationId);\n insertIndex = destinationItems.findIndex(({ id }) => id === itemId);\n }\n item.changeDestination?.(destinationItems, insertIndex);\n } else {\n item.removeFromCurrent?.();\n if (dragToRemove) {\n removeById(item.id);\n } else {\n item.returnToSource?.(item);\n }\n }\n item.transformedItemCache?.forEach(ref => {\n ref.current = null;\n });\n },\n [dragToRemove]\n );\n\n const emptyContent = EmptyRenderer ? <EmptyRenderer /> : null;\n\n return (\n <Droppable accept={accept} onHover={onHover} onDrop={onDrop}>\n {({ dropRef }) => {\n return (\n <Component\n ref={(el: HTMLElement) => {\n dropRef(el);\n setListEl(el);\n }}\n {...restProps}\n >\n {internalItems.length === 0\n ? emptyContent\n : internalItems.map(item => {\n return (\n <Draggable\n key={item.id}\n id={item.id}\n type={item.type}\n data={item.data}\n onBegin={onBegin(item.id)}\n onEnd={onEnd}\n >\n {({ dragRef, previewRef, collected }) => {\n return (\n <ItemRenderer\n {...{\n ...item,\n dragRef,\n previewRef,\n ...collected,\n isDragging: !!item.sourceId\n }}\n />\n );\n }}\n </Draggable>\n );\n })}\n </Component>\n );\n }}\n </Droppable>\n );\n};\n\nexport default DragDropList;\n"]}
|
|
@@ -7,6 +7,8 @@ export interface ItemRendererProps<T extends object = object> extends DraggableI
|
|
|
7
7
|
previewRef: RefCallback<HTMLElement>;
|
|
8
8
|
}
|
|
9
9
|
export interface DragDropListProps<T extends object = object> extends AsProp, BaseProps, NoChildrenProp {
|
|
10
|
+
/** Unique identifier for the list */
|
|
11
|
+
id?: string;
|
|
10
12
|
/** Type of item allowed to be dropped on this list (useful when there is multiple lists that share data). */
|
|
11
13
|
accept: DroppableProps['accept'];
|
|
12
14
|
/** Array of data objects used for the list. */
|
|
@@ -14,7 +16,7 @@ export interface DragDropListProps<T extends object = object> extends AsProp, Ba
|
|
|
14
16
|
/**
|
|
15
17
|
* @default "remove"
|
|
16
18
|
*/
|
|
17
|
-
pullMode?: 'clone' | 'remove';
|
|
19
|
+
pullMode?: 'clone' | 'remove' | ((destinationId: string) => 'clone' | 'remove');
|
|
18
20
|
/**
|
|
19
21
|
* @default "insert"
|
|
20
22
|
*/
|
|
@@ -26,9 +28,16 @@ export interface DragDropListProps<T extends object = object> extends AsProp, Ba
|
|
|
26
28
|
* @default false
|
|
27
29
|
*/
|
|
28
30
|
dragHandles?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Enables "Drag to remove from list" behavior
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
dragToRemove?: boolean;
|
|
29
36
|
/** User defined function(Component) that should return content for when the list is empty. */
|
|
30
37
|
emptyRenderer?: ComponentType;
|
|
31
|
-
/** Called when list data is updated. */
|
|
32
|
-
onChange: (items: DragDropListProps<T>['items']) => void;
|
|
38
|
+
/** Called when list data is updated. "insertIndex" is only defined when a new item has been added to the list. */
|
|
39
|
+
onChange: (items: DragDropListProps<T>['items'], insertIndex?: number) => void;
|
|
40
|
+
/** Called when an item enters a list. Allows for transformation of the item to fit the new list. */
|
|
41
|
+
onEnter?: (item: DraggableItem<T>) => DraggableItem<T>;
|
|
33
42
|
}
|
|
34
43
|
//# sourceMappingURL=DragDropList.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropList.types.d.ts","sourceRoot":"","sources":["../../../src/components/DragDropList/DragDropList.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAC1D,SAAQ,aAAa,CAAC,CAAC,CAAC,EACtB,uBAAuB;IACzB,O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AAC,CAAC,EAAE,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,GAAG,QAAQ,CAAC,CAAC;IAChF;;OAEG;IACH,QAAQ,CAAC,EACL,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;IAC3D,kFAAkF;IAClF,YAAY,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,8FAA8F;IAC9F,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,kHAAkH;IAClH,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/E,oGAAoG;IACpG,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,CAAC;CACxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropList.types.js","sourceRoot":"","sources":["../../../src/components/DragDropList/DragDropList.types.ts"],"names":[],"mappings":"","sourcesContent":["import { RefCallback, ComponentType } from 'react';\n\nimport { AsProp, BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport { DraggableItem, DraggableCollectedProps } from '../Draggable';\nimport { DroppableProps } from '../Droppable';\n\nexport interface ItemRendererProps<T extends object = object>\n extends DraggableItem<T>,\n DraggableCollectedProps {\n dragRef: RefCallback<HTMLElement>;\n previewRef: RefCallback<HTMLElement>;\n}\n\nexport interface DragDropListProps<T extends object = object>\n extends AsProp,\n BaseProps,\n NoChildrenProp {\n /** Type of item allowed to be dropped on this list (useful when there is multiple lists that share data). */\n accept: DroppableProps['accept'];\n /** Array of data objects used for the list. */\n items: DraggableItem<T>[];\n /**\n * @default \"remove\"\n */\n pullMode?: 'clone' | 'remove';\n /**\n * @default \"insert\"\n */\n pushMode?:\n | 'insert'\n | 'prepend'\n | 'append'\n | ((a: DraggableItem<T>, b: DraggableItem<T>) => number);\n /** User defined function that should return content for the draggable element. */\n itemRenderer: ComponentType<ItemRendererProps<T>>;\n /**\n * Enable drag handle elements for each of the list items. By default the entire element is draggable.\n * @default false\n */\n dragHandles?: boolean;\n /** User defined function(Component) that should return content for when the list is empty. */\n emptyRenderer?: ComponentType;\n /** Called when list data is updated. */\n onChange: (items: DragDropListProps<T>['items']) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DragDropList.types.js","sourceRoot":"","sources":["../../../src/components/DragDropList/DragDropList.types.ts"],"names":[],"mappings":"","sourcesContent":["import { RefCallback, ComponentType } from 'react';\n\nimport { AsProp, BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport { DraggableItem, DraggableCollectedProps } from '../Draggable';\nimport { DroppableProps } from '../Droppable';\n\nexport interface ItemRendererProps<T extends object = object>\n extends DraggableItem<T>,\n DraggableCollectedProps {\n dragRef: RefCallback<HTMLElement>;\n previewRef: RefCallback<HTMLElement>;\n}\n\nexport interface DragDropListProps<T extends object = object>\n extends AsProp,\n BaseProps,\n NoChildrenProp {\n /** Unique identifier for the list */\n id?: string;\n /** Type of item allowed to be dropped on this list (useful when there is multiple lists that share data). */\n accept: DroppableProps['accept'];\n /** Array of data objects used for the list. */\n items: DraggableItem<T>[];\n /**\n * @default \"remove\"\n */\n pullMode?: 'clone' | 'remove' | ((destinationId: string) => 'clone' | 'remove');\n /**\n * @default \"insert\"\n */\n pushMode?:\n | 'insert'\n | 'prepend'\n | 'append'\n | ((a: DraggableItem<T>, b: DraggableItem<T>) => number);\n /** User defined function that should return content for the draggable element. */\n itemRenderer: ComponentType<ItemRendererProps<T>>;\n /**\n * Enable drag handle elements for each of the list items. By default the entire element is draggable.\n * @default false\n */\n dragHandles?: boolean;\n /**\n * Enables \"Drag to remove from list\" behavior\n * @default false\n */\n dragToRemove?: boolean;\n /** User defined function(Component) that should return content for when the list is empty. */\n emptyRenderer?: ComponentType;\n /** Called when list data is updated. \"insertIndex\" is only defined when a new item has been added to the list. */\n onChange: (items: DragDropListProps<T>['items'], insertIndex?: number) => void;\n /** Called when an item enters a list. Allows for transformation of the item to fit the new list. */\n onEnter?: (item: DraggableItem<T>) => DraggableItem<T>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropManager.d.ts","sourceRoot":"","sources":["../../../src/components/DragDropManager/DragDropManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"DragDropManager.d.ts","sourceRoot":"","sources":["../../../src/components/DragDropManager/DragDropManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,IAAI,CAAC;CACpB;AAED,QAAA,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,CAS5D,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DndProvider } from 'react-dnd';
|
|
3
3
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
4
|
-
const DragDropManager = ({ children }) => {
|
|
5
|
-
return _jsx(DndProvider, { backend: HTML5Backend, children: children });
|
|
4
|
+
const DragDropManager = ({ children, rootElement }) => {
|
|
5
|
+
return (_jsx(DndProvider, { backend: HTML5Backend, options: { rootElement }, children: children }));
|
|
6
6
|
};
|
|
7
7
|
export default DragDropManager;
|
|
8
8
|
//# sourceMappingURL=DragDropManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropManager.js","sourceRoot":"","sources":["../../../src/components/DragDropManager/DragDropManager.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"DragDropManager.js","sourceRoot":"","sources":["../../../src/components/DragDropManager/DragDropManager.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAOvD,MAAM,eAAe,GAA4C,CAAC,EAChE,QAAQ,EACR,WAAW,EACU,EAAE,EAAE;IACzB,OAAO,CACL,KAAC,WAAW,IAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,YACzD,QAAQ,GACG,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { FunctionComponent, ReactNode } from 'react';\nimport { DndProvider } from 'react-dnd';\nimport { HTML5Backend } from 'react-dnd-html5-backend';\n\nexport interface DragDropManagerProps {\n children: ReactNode;\n rootElement?: Node;\n}\n\nconst DragDropManager: FunctionComponent<DragDropManagerProps> = ({\n children,\n rootElement\n}: DragDropManagerProps) => {\n return (\n <DndProvider backend={HTML5Backend} options={{ rootElement }}>\n {children}\n </DndProvider>\n );\n};\n\nexport default DragDropManager;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StandardDragDropList.styles.js","sourceRoot":"","sources":["../../../src/components/StandardDragDropList/StandardDragDropList.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEnG,MAAM,CAAC,MAAM,0BAA0B,GAAkB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpF,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;IAC/B,OAAO,GAAG,CAAA;;;;;QAKJ,UAAU;8BACY,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI;;;+BAG7D,UAAU;2BACd,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;;GAEtC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACvD,OAAO,GAAG,CAAA;MACN,UAAU;;;;
|
|
1
|
+
{"version":3,"file":"StandardDragDropList.styles.js","sourceRoot":"","sources":["../../../src/components/StandardDragDropList/StandardDragDropList.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEnG,MAAM,CAAC,MAAM,0BAA0B,GAAkB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpF,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;IAC/B,OAAO,GAAG,CAAA;;;;;QAKJ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AA0B,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACjE,OAAO,GAAG,CAAA;;wBAEY,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;;;;;;;mCAO7B,KAAK,CAAC,IAAI,CAAC,OAAO;;QAE7C,8BAA8B;;;;;;;;GAQnC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,0BAA0B,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { Button, defaultThemeProp, StyledIcon, Text, useDirection } from '@pega/cosmos-react-core';\n\nexport const StyledExpandCollapseToggle: typeof Button = styled(Button)(({ theme }) => {\n const { ltr } = useDirection();\n return css`\n & > div {\n vertical-align: middle;\n }\n\n & ${StyledIcon} {\n transition: transform ${theme.base.animation.speed} ${theme.base.animation.timing.ease};\n }\n\n &[aria-expanded='false'] ${StyledIcon} {\n transform: rotateZ(${ltr ? '-' : ''}90deg);\n }\n `;\n});\n\nexport const StyledItemStatus = styled.div(({ theme }) => {\n return css`\n ${StyledIcon} {\n outline: none;\n\n &:focus {\n box-shadow: ${theme.base.shadow['focus-inset']};\n }\n }\n `;\n});\n\nStyledItemStatus.defaultProps = defaultThemeProp;\n\nexport const StyledDragHandle = styled.div`\n padding: 0 ${({ theme }) => theme.base.spacing} 0 0;\n cursor: move;\n > svg {\n display: block;\n }\n`;\n\nStyledDragHandle.defaultProps = defaultThemeProp;\n\nexport const StyledItemContent = styled.div`\n & > :nth-child(2) {\n overflow: hidden;\n text-overflow: ellipsis;\n }\n`;\n\nStyledItemContent.defaultProps = defaultThemeProp;\n\nexport const StyledItemActions = styled.div``;\nexport const StyledSecondary = styled(Text)``;\n\nexport const StyledListItemInner = styled.div(({ theme }) => {\n return css`\n padding-inline: calc(${theme.base.spacing} / 2);\n white-space: nowrap;\n `;\n});\n\nStyledListItemInner.defaultProps = defaultThemeProp;\n\nexport const StyledStandardDragDropListItem = styled.li<{ isDragging?: boolean; empty?: boolean }>(\n ({ theme, isDragging, empty }) => {\n const bdrColor = theme.base.palette['border-line'];\n const bdr = `0.0625rem dashed ${isDragging || empty ? bdrColor : 'transparent'}`;\n\n if (empty) {\n return css`\n text-align: center;\n padding: ${theme.base.spacing};\n border: ${bdr};\n font-style: italic;\n `;\n }\n\n return css`\n position: relative;\n background: ${theme.base.palette['primary-background']};\n\n ${isDragging &&\n css`\n z-index: 1;\n\n & > div,\n span {\n /* visibility: hidden; */\n opacity: 0.5;\n }\n `}\n\n &::before,\n &::after {\n content: '';\n display: block;\n position: absolute;\n height: 0.0625rem;\n left: 0;\n right: 0;\n background: ${isDragging ? theme.base.palette['primary-background'] : bdrColor};\n }\n\n &::before {\n top: 0;\n border-top: ${bdr};\n ${isDragging &&\n css`\n box-shadow: 0 0.0625rem 0 ${theme.base.palette.interactive};\n `}\n }\n\n &::after {\n bottom: -0.0625rem;\n border-bottom: ${bdr};\n ${isDragging &&\n css`\n box-shadow: 0 -0.0625rem 0 ${theme.base.palette.interactive};\n `}\n }\n\n & > ${StyledListItemInner} {\n min-height: calc(${theme.base['hit-area'].mouse} + ${theme.base.spacing});\n\n @media (pointer: coarse) {\n min-height: calc(${theme.base['hit-area']['finger-min']} + ${theme.base.spacing});\n }\n }\n `;\n }\n);\n\nStyledStandardDragDropListItem.defaultProps = defaultThemeProp;\n\nexport const StyledStandardDragDropList = styled.div(({ theme }) => {\n return css`\n flex-grow: 1;\n background-color: ${theme.base.palette['primary-background']};\n\n ul {\n list-style: none;\n }\n\n & & {\n padding-inline: calc(3.5 * ${theme.base.spacing}) 0;\n\n ${StyledStandardDragDropListItem} {\n &:last-child {\n &::after {\n display: none;\n }\n }\n }\n }\n `;\n});\n\nStyledStandardDragDropList.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -16,8 +16,8 @@ export interface StandardDragDropListProps extends OmitStrict<DragDropListProps<
|
|
|
16
16
|
/** A ref to the root HTMLElement for the component. */
|
|
17
17
|
ref?: Ref<HTMLDivElement>;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
export
|
|
19
|
+
type ItemAction = (id: StandardDragDropListItemProps['id'], e: MouseEvent<HTMLButtonElement>) => void;
|
|
20
|
+
export type StandardDragDropListItemProps = ForwardProps & {
|
|
21
21
|
/** An identifier unique within the entire list hierarchy. */
|
|
22
22
|
id: string;
|
|
23
23
|
/** Indicates the type of item for determining drop acceptance by a target list. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StandardDragDropList.types.d.ts","sourceRoot":"","sources":["../../../src/components/StandardDragDropList/StandardDragDropList.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,yBACf,SAAQ,UAAU,CACd,iBAAiB,CAAC,6BAA6B,CAAC,EAChD,aAAa,GAAG,cAAc,GAAG,eAAe,GAAG,OAAO,GAAG,UAAU,CACxE,EACD,SAAS,EACT,cAAc;IAChB,gCAAgC;IAChC,KAAK,EAAE,6BAA6B,EAAE,CAAC;IACvC,4BAA4B;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAC9D,uDAAuD;IACvD,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,
|
|
1
|
+
{"version":3,"file":"StandardDragDropList.types.d.ts","sourceRoot":"","sources":["../../../src/components/StandardDragDropList/StandardDragDropList.types.ts"],"names":[],"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IACzD,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,0DAA0D;IAC1D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB,GAAG,CACE;IACE,sDAAsD;IACtD,KAAK,EAAE,6BAA6B,EAAE,CAAC;IACvC,kHAAkH;IAClH,MAAM,CAAC,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC;IAC7C,6DAA6D;IAC7D,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB,GACD;IACE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,CACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-dnd",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.10.0",
|
|
4
4
|
"author": "Pegasystems",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"build": "tsc -b"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@pega/cosmos-react-core": "4.0.0-dev.
|
|
23
|
+
"@pega/cosmos-react-core": "4.0.0-dev.10.0",
|
|
24
24
|
"@types/react": "^16.14.24 || ^17.0.38",
|
|
25
25
|
"@types/react-dom": "^16.9.14 || ^17.0.11",
|
|
26
26
|
"@types/styled-components": "^5.1.26",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"@storybook/addons": "^6.4.19",
|
|
41
41
|
"@storybook/react": "^6.4.19",
|
|
42
42
|
"@storybook/theming": "^6.4.19",
|
|
43
|
-
"typescript": "~4.
|
|
43
|
+
"typescript": "~4.9.5"
|
|
44
44
|
}
|
|
45
45
|
}
|