@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.
@@ -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
- id: 'drag-in-the-blank-droppable',
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}
@@ -1,13 +1,13 @@
1
1
  import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { DndContext, PointerSensor, KeyboardSensor, useSensor, useSensors } from '@dnd-kit/core';
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;
@@ -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
- id,
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
@@ -1,5 +1,5 @@
1
1
  import PlaceHolder from './placeholder';
2
- import DraggableChoice from './draggable-choice';
2
+ import DraggableChoice from './draggable-choice';
3
3
  import DragProvider from './drag-provider';
4
4
  import swap from './swap';
5
5
  import * as uid from './uid-context';
@@ -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
  );
@@ -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 { PreviewPrompt, color } from '@pie-lib/render-ui';
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
@@ -1,4 +1,4 @@
1
- import cloneDeep from 'lodash/cloneDeep';
1
+ import { cloneDeep } from 'lodash-es';
2
2
 
3
3
  export default (arr, fromIndex, toIndex) => {
4
4
  if (!arr || arr.length <= 1 || fromIndex === undefined || toIndex === undefined) {