@pie-lib/drag 3.1.1-next.0 → 3.1.1-next.1
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/drag-in-the-blank-dp.js +0 -1
- package/lib/drag-in-the-blank-dp.js.map +1 -1
- package/lib/drag-provider.js +0 -7
- package/lib/drag-provider.js.map +1 -1
- package/lib/drag-type.js +0 -1
- package/lib/drag-type.js.map +1 -1
- package/lib/draggable-choice.js +0 -1
- package/lib/draggable-choice.js.map +1 -1
- package/lib/droppable-placeholder.js +0 -1
- package/lib/droppable-placeholder.js.map +1 -1
- package/lib/ica-dp.js +0 -1
- package/lib/ica-dp.js.map +1 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +1 -1
- package/lib/match-list-dp.js +1 -2
- package/lib/match-list-dp.js.map +1 -1
- package/lib/placeholder.js +0 -11
- package/lib/placeholder.js.map +1 -1
- package/lib/preview-component.js +0 -15
- package/lib/preview-component.js.map +1 -1
- package/lib/swap.js +2 -5
- package/lib/swap.js.map +1 -1
- package/lib/uid-context.js +0 -2
- package/lib/uid-context.js.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/drag-provider.test.jsx +313 -0
- package/src/__tests__/preview-component.test.jsx +537 -0
- package/src/__tests__/swap.test.js +161 -0
- package/src/__tests__/uid-context.test.jsx +1 -1
- package/src/drag-in-the-blank-dp.jsx +4 -4
- package/src/drag-provider.jsx +7 -7
- package/src/draggable-choice.jsx +5 -16
- package/src/droppable-placeholder.jsx +3 -10
- package/src/index.js +1 -1
- package/src/match-list-dp.jsx +4 -14
- package/src/placeholder.jsx +3 -12
- package/src/preview-component.jsx +1 -1
- package/src/swap.js +1 -1
|
@@ -23,18 +23,18 @@ export function DragInTheBlankDroppable({
|
|
|
23
23
|
// The actual drop handling will be managed by the parent component
|
|
24
24
|
// through the DragProvider's onDragEnd callback
|
|
25
25
|
const { setNodeRef, isOver } = useDroppable({
|
|
26
|
-
|
|
26
|
+
id: 'drag-in-the-blank-droppable',
|
|
27
27
|
data: {
|
|
28
28
|
type: 'MaskBlank',
|
|
29
29
|
accepts: ['MaskBlank'],
|
|
30
30
|
id: 'drag-in-the-blank-droppable',
|
|
31
31
|
toChoiceBoard: true,
|
|
32
|
-
instanceId
|
|
33
|
-
}
|
|
32
|
+
instanceId,
|
|
33
|
+
},
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
|
-
<div ref={setNodeRef}
|
|
37
|
+
<div ref={setNodeRef}>
|
|
38
38
|
<DroppablePlaceholderContainer>
|
|
39
39
|
<PlaceHolder
|
|
40
40
|
isOver={isOver}
|
package/src/drag-provider.jsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { DndContext,
|
|
3
|
+
import { DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
4
4
|
|
|
5
5
|
export function DragProvider({ children, onDragEnd, onDragStart, collisionDetection, modifiers, autoScroll }) {
|
|
6
6
|
const [activeId, setActiveId] = useState(null);
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
const sensors = useSensors(
|
|
9
|
-
useSensor(PointerSensor, { activationConstraint: { distance: 8 }}),
|
|
10
|
-
useSensor(KeyboardSensor)
|
|
9
|
+
useSensor(PointerSensor, { activationConstraint: { distance: 8 } }),
|
|
10
|
+
useSensor(KeyboardSensor),
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
const handleDragStart = (event) => {
|
|
@@ -25,8 +25,8 @@ export function DragProvider({ children, onDragEnd, onDragStart, collisionDetect
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<DndContext
|
|
29
|
-
sensors={sensors}
|
|
28
|
+
<DndContext
|
|
29
|
+
sensors={sensors}
|
|
30
30
|
onDragStart={handleDragStart}
|
|
31
31
|
onDragEnd={handleDragEnd}
|
|
32
32
|
collisionDetection={collisionDetection}
|
|
@@ -47,4 +47,4 @@ DragProvider.propTypes = {
|
|
|
47
47
|
autoScroll: PropTypes.object,
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export default DragProvider;
|
|
50
|
+
export default DragProvider;
|
package/src/draggable-choice.jsx
CHANGED
|
@@ -29,14 +29,9 @@ export function DraggableChoice({
|
|
|
29
29
|
choiceIndex,
|
|
30
30
|
onRemoveChoice,
|
|
31
31
|
type,
|
|
32
|
-
id
|
|
32
|
+
id,
|
|
33
33
|
}) {
|
|
34
|
-
const {
|
|
35
|
-
attributes,
|
|
36
|
-
listeners,
|
|
37
|
-
setNodeRef,
|
|
38
|
-
isDragging
|
|
39
|
-
} = useDraggable({
|
|
34
|
+
const { attributes, listeners, setNodeRef, isDragging } = useDraggable({
|
|
40
35
|
id: id || choice.id, // id to be used for dnd-kit
|
|
41
36
|
disabled: disabled,
|
|
42
37
|
categoryId: category?.id,
|
|
@@ -50,18 +45,12 @@ export function DraggableChoice({
|
|
|
50
45
|
alternateResponseIndex,
|
|
51
46
|
choiceIndex,
|
|
52
47
|
onRemoveChoice,
|
|
53
|
-
type
|
|
54
|
-
}
|
|
48
|
+
type,
|
|
49
|
+
},
|
|
55
50
|
});
|
|
56
51
|
|
|
57
52
|
return (
|
|
58
|
-
<StyledChoice
|
|
59
|
-
ref={setNodeRef}
|
|
60
|
-
className={className}
|
|
61
|
-
isDragging={isDragging}
|
|
62
|
-
{...attributes}
|
|
63
|
-
{...listeners}
|
|
64
|
-
>
|
|
53
|
+
<StyledChoice ref={setNodeRef} className={className} isDragging={isDragging} {...attributes} {...listeners}>
|
|
65
54
|
{children}
|
|
66
55
|
</StyledChoice>
|
|
67
56
|
);
|
|
@@ -7,17 +7,10 @@ const preventInteractionStyle = {
|
|
|
7
7
|
flex: 1,
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export function DroppablePlaceholder({
|
|
11
|
-
|
|
12
|
-
children,
|
|
13
|
-
disabled,
|
|
14
|
-
classes,
|
|
15
|
-
isVerticalPool,
|
|
16
|
-
minHeight
|
|
17
|
-
}) {
|
|
18
|
-
const { setNodeRef, isOver } = useDroppable({
|
|
10
|
+
export function DroppablePlaceholder({ id, children, disabled, classes, isVerticalPool, minHeight }) {
|
|
11
|
+
const { setNodeRef, isOver } = useDroppable({
|
|
19
12
|
id,
|
|
20
|
-
disabled
|
|
13
|
+
disabled,
|
|
21
14
|
});
|
|
22
15
|
|
|
23
16
|
return (
|
package/src/index.js
CHANGED
package/src/match-list-dp.jsx
CHANGED
|
@@ -5,17 +5,11 @@ import { DroppablePlaceholder } from './droppable-placeholder';
|
|
|
5
5
|
// With @dnd-kit, the drop logic is handled in the DragProvider's onDragEnd callback
|
|
6
6
|
// This component now just wraps DroppablePlaceholder with match-list specific logic
|
|
7
7
|
|
|
8
|
-
export function MatchListDroppable({
|
|
9
|
-
id,
|
|
10
|
-
children,
|
|
11
|
-
disabled,
|
|
12
|
-
onRemoveAnswer,
|
|
13
|
-
...rest
|
|
14
|
-
}) {
|
|
8
|
+
export function MatchListDroppable({ id, children, disabled, onRemoveAnswer, ...rest }) {
|
|
15
9
|
// The actual drop handling will be managed by the parent component
|
|
16
10
|
// through the DragProvider's onDragEnd callback
|
|
17
11
|
// The onRemoveAnswer logic should be handled in the parent's onDragEnd:
|
|
18
|
-
//
|
|
12
|
+
//
|
|
19
13
|
// const handleDragEnd = (event) => {
|
|
20
14
|
// if (event.over && event.active) {
|
|
21
15
|
// const item = event.active.data.current;
|
|
@@ -24,13 +18,9 @@ export function MatchListDroppable({
|
|
|
24
18
|
// }
|
|
25
19
|
// }
|
|
26
20
|
// };
|
|
27
|
-
|
|
21
|
+
|
|
28
22
|
return (
|
|
29
|
-
<DroppablePlaceholder
|
|
30
|
-
id={id}
|
|
31
|
-
disabled={disabled}
|
|
32
|
-
{...rest}
|
|
33
|
-
>
|
|
23
|
+
<DroppablePlaceholder id={id} disabled={disabled} {...rest}>
|
|
34
24
|
{children}
|
|
35
25
|
</DroppablePlaceholder>
|
|
36
26
|
);
|
package/src/placeholder.jsx
CHANGED
|
@@ -72,16 +72,10 @@ export const PlaceHolder = (props) => {
|
|
|
72
72
|
isCategorize,
|
|
73
73
|
isVerticalPool,
|
|
74
74
|
minHeight,
|
|
75
|
-
extraStyles
|
|
75
|
+
extraStyles,
|
|
76
76
|
} = props;
|
|
77
77
|
|
|
78
|
-
const names = classNames(
|
|
79
|
-
'placeholder',
|
|
80
|
-
disabled && 'disabled',
|
|
81
|
-
isOver && 'over',
|
|
82
|
-
type,
|
|
83
|
-
className,
|
|
84
|
-
);
|
|
78
|
+
const names = classNames('placeholder', disabled && 'disabled', isOver && 'over', type, className);
|
|
85
79
|
|
|
86
80
|
const style = {};
|
|
87
81
|
|
|
@@ -109,10 +103,7 @@ export const PlaceHolder = (props) => {
|
|
|
109
103
|
return (
|
|
110
104
|
<StyledPlaceholder
|
|
111
105
|
style={{ ...style, minHeight: minHeight, ...extraStyles }}
|
|
112
|
-
className={classNames(
|
|
113
|
-
choiceBoard ? boardStyle : names,
|
|
114
|
-
isVerticalPool && 'verticalPool',
|
|
115
|
-
)}
|
|
106
|
+
className={classNames(choiceBoard ? boardStyle : names, isVerticalPool && 'verticalPool')}
|
|
116
107
|
>
|
|
117
108
|
{children}
|
|
118
109
|
</StyledPlaceholder>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { DragOverlay, useDndContext } from '@dnd-kit/core';
|
|
3
|
-
import {
|
|
3
|
+
import { color, PreviewPrompt } from '@pie-lib/render-ui';
|
|
4
4
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
5
5
|
|
|
6
6
|
const styles = {
|
package/src/swap.js
CHANGED