fluid-dnd 2.5.1 → 2.6.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.
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var n=(e,s,l)=>s in e?d(e,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[s]=l;var a=(e,s,l)=>n(e,typeof s!="symbol"?s+"":s,l);const r=require("./index-BOqB07mI.cjs");class h{constructor(){a(this,"handlers");this.handlers=[]}addSubscriber(s){this.handlers.includes(s)||(this.handlers.push(s),r.addClass(s,r.GRAB_CLASS))}toggleGrabClass(s){for(const l of this.handlers)r.toggleClass(l,r.GRAB_CLASS,s)}}exports.HandlerPublisher=h;
1
+ "use strict";var d=Object.defineProperty;var n=(e,s,l)=>s in e?d(e,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[s]=l;var a=(e,s,l)=>n(e,typeof s!="symbol"?s+"":s,l);const r=require("./index-CnlVdjmE.cjs");class h{constructor(){a(this,"handlers");this.handlers=[]}addSubscriber(s){this.handlers.includes(s)||(this.handlers.push(s),r.addClass(s,r.GRAB_CLASS))}toggleGrabClass(s){for(const l of this.handlers)r.toggleClass(l,r.GRAB_CLASS,s)}}exports.HandlerPublisher=h;
@@ -1,7 +1,7 @@
1
1
  var d = Object.defineProperty;
2
2
  var e = (a, s, l) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: l }) : a[s] = l;
3
3
  var r = (a, s, l) => e(a, typeof s != "symbol" ? s + "" : s, l);
4
- import { a as h, t as n, G as t } from "./index-CJpjY7r7.js";
4
+ import { a as h, t as n, G as t } from "./index-CJpYi4CM.js";
5
5
  class c {
6
6
  constructor() {
7
7
  r(this, "handlers");
@@ -28,6 +28,7 @@ const getConfig = (listCondig, config) => {
28
28
  isDraggable: config?.isDraggable ?? (() => true),
29
29
  onDragStart: config?.onDragStart ?? (() => { }),
30
30
  onDragEnd: config?.onDragEnd ?? (() => { }),
31
+ onDragOver: config?.onDragOver ?? (() => { }),
31
32
  droppableGroup: config?.droppableGroup,
32
33
  onRemoveAtEvent,
33
34
  onInsertEvent,
@@ -40,7 +41,7 @@ const getConfig = (listCondig, config) => {
40
41
  delayBeforeInsert: config?.delayBeforeInsert ?? 200,
41
42
  mapFrom: config?.mapFrom ?? defaultMapFrom,
42
43
  delayBeforeTouchMoveEvent: config?.delayBeforeTouchMoveEvent ?? 150,
43
- coordinateTransform: config?.coordinateTransform ?? [(coordinate) => coordinate]
44
+ coordinateTransform: config?.coordinateTransform ?? [(coordinate) => coordinate],
44
45
  };
45
46
  };
46
47
  export default function dragAndDrop(listCondig, handlerPublisher, config, indexAttr = 'index') {
@@ -70,11 +71,11 @@ export default function dragAndDrop(listCondig, handlerPublisher, config, indexA
70
71
  insertAtFromElements = insertAtFromElementList;
71
72
  };
72
73
  const childrenMutationFilter = (mutation) => {
73
- const addedNodes = mutation.addedNodes
74
+ const addedNodes = Array.from(mutation.addedNodes ?? [])
74
75
  .values()
75
76
  .filter((element) => !isTempElement(element))
76
77
  .toArray();
77
- const removedNodes = mutation.removedNodes
78
+ const removedNodes = Array.from(mutation.removedNodes ?? [])
78
79
  .values()
79
80
  .filter((element) => !isTempElement(element))
80
81
  .toArray();
@@ -29,7 +29,14 @@ export default function useDragAndDropEvents(currentConfig, index, parent, dropp
29
29
  const emitDraggingEventToSiblings = (draggedElement, event, translation, droppable, config) => {
30
30
  const [siblings] = getSiblings(draggedElement, droppable);
31
31
  const isOutside = draggableIsOutside(draggedElement, droppable);
32
- const { direction } = config;
32
+ const { direction, onDragOver } = config;
33
+ onDragOver({
34
+ element: draggedElement,
35
+ index,
36
+ targetIndex: actualIndex,
37
+ value: currentConfig.onGetValue(index),
38
+ droppable
39
+ });
33
40
  if (siblings.length == 0) {
34
41
  updateActualIndexBaseOnTranslation(translation, 1, direction, siblings);
35
42
  }
@@ -40,7 +40,7 @@ export default function useInsertEvents(currentConfig, parent, handlerPublisher,
40
40
  return [emitInsertEventToSiblings];
41
41
  }
42
42
  const childrenMutationFilter = (mutation) => {
43
- const addedNodes = mutation.addedNodes
43
+ const addedNodes = Array.from(mutation.addedNodes ?? [])
44
44
  .values()
45
45
  .filter((element) => !isTempElement(element))
46
46
  .toArray();
@@ -21,6 +21,13 @@ export interface DragEndEventData<T> {
21
21
  index: number;
22
22
  value: T;
23
23
  }
24
+ export interface DragOverEventData<T> {
25
+ index: number;
26
+ targetIndex: number;
27
+ element: Element;
28
+ value: T;
29
+ droppable: Element;
30
+ }
24
31
  export declare const HORIZONTAL = "horizontal";
25
32
  export declare const VERTICAL = "vertical";
26
33
  /**
@@ -88,6 +95,10 @@ export interface Config<T> {
88
95
  * A function that returns whether a given element of the list is draggable.
89
96
  */
90
97
  onDragEnd?: (element: DragEndEventData<T>) => void;
98
+ /**
99
+ * A function that is called when the draggable element is dragged over a droppable.
100
+ */
101
+ onDragOver?: (element: DragOverEventData<T>) => void;
91
102
  /**
92
103
  * Name of the group of the share droppables.
93
104
  */
@@ -123,6 +134,7 @@ export interface Config<T> {
123
134
  * @public
124
135
  */
125
136
  export type OnDropEvent = (source: DraggableElement, destination: DraggableElement) => void;
137
+ export type OnDragOverEvent = (source: DraggableElement) => void;
126
138
  export type OnRemoveAtEvent<T> = (index: number, sync?: boolean) => T | undefined;
127
139
  export type OnInsertEvent<T> = (index: number, value: T, sync?: boolean) => void;
128
140
  export type OnGetLength = () => number;
@@ -172,6 +184,10 @@ export type CoreConfig<T> = {
172
184
  * A function that is called when the draggable element is dropped.
173
185
  */
174
186
  onDragEnd: (element: DragEndEventData<T>) => void;
187
+ /**
188
+ * A function that is called when the draggable element is dragged over a droppable.
189
+ */
190
+ onDragOver: (element: DragOverEventData<T>) => void;
175
191
  /**
176
192
  * Name of the group of the share droppables
177
193
  */