activeDragTargetId (src/drag-state.ts)

platform · packages/gantt/src/drag-state.ts · typescript · EPL-2.0
ui, tag:knn-classified

Utility to retrieve the active drag target ID from a drag state object.

// Source: https://github.com/hcengineering/platform | License: EPL-2.0 | Modified files must remain under EPL-2.0
// Modifications to this file must remain under EPL-2.0.
// Provided via justclaw.it.com; keep this notice with the code.
import type { DragState, DragTarget } from './types'

export function activeDragTargetId (state: DragState): string | null {
  if (!('target' in state)) return null

  const target = state.target
  if (!isDragTarget(target)) return null

  const id = target.doc._id
  return id !== undefined ? String(id) : null
}

function isDragTarget (target: unknown): target is DragTarget {
  return (
    typeof target === 'object' &&
    target !== null &&
    'doc' in target &&
    typeof (target as { doc?: unknown }).doc === 'object' &&
    (target as { doc?: unknown }

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key