@pyreon/dnd 0.12.8 → 0.12.10

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.
@@ -38,6 +38,8 @@ export interface UseDragMonitorResult {
38
38
  * ```
39
39
  */
40
40
  export function useDragMonitor(options?: UseDragMonitorOptions): UseDragMonitorResult {
41
+ if (typeof document === 'undefined') return { isDragging: () => false, dragData: () => null }
42
+
41
43
  const isDragging = signal(false)
42
44
  const dragData = signal<DragData | null>(null)
43
45
 
@@ -22,6 +22,8 @@ import type { DragData, UseDraggableOptions, UseDraggableResult } from './types'
22
22
  export function useDraggable<T extends DragData = DragData>(
23
23
  options: UseDraggableOptions<T>,
24
24
  ): UseDraggableResult {
25
+ if (typeof document === 'undefined') return { isDragging: () => false }
26
+
25
27
  const isDragging = signal(false)
26
28
  let cleanup: (() => void) | undefined
27
29
 
@@ -23,6 +23,8 @@ import type { DragData, UseDroppableOptions, UseDroppableResult } from './types'
23
23
  export function useDroppable<T extends DragData = DragData>(
24
24
  options: UseDroppableOptions<T>,
25
25
  ): UseDroppableResult {
26
+ if (typeof document === 'undefined') return { isOver: () => false }
27
+
26
28
  const isOver = signal(false)
27
29
  let cleanup: (() => void) | undefined
28
30
 
@@ -49,6 +49,8 @@ export interface UseFileDropResult {
49
49
  * ```
50
50
  */
51
51
  export function useFileDrop(options: UseFileDropOptions): UseFileDropResult {
52
+ if (typeof document === 'undefined') return { isOver: () => false, isDraggingFiles: () => false }
53
+
52
54
  const isOver = signal(false)
53
55
  const isDraggingFiles = signal(false)
54
56
  let cleanup: (() => void) | undefined
@@ -54,6 +54,17 @@ let _sortableCounter = 0
54
54
  * ```
55
55
  */
56
56
  export function useSortable<T>(options: UseSortableOptions<T>): UseSortableResult {
57
+ if (typeof document === 'undefined') {
58
+ const noop = () => {}
59
+ return {
60
+ containerRef: noop as (el: HTMLElement) => void,
61
+ itemRef: () => noop as (el: HTMLElement) => void,
62
+ activeId: () => null,
63
+ overId: () => null,
64
+ overEdge: () => null,
65
+ }
66
+ }
67
+
57
68
  const sortableId = `sortable-${++_sortableCounter}`
58
69
  const activeId = signal<string | number | null>(null)
59
70
  const overId = signal<string | number | null>(null)