refactor(monorepo): decouple api and webui into workspaces packages

This commit is contained in:
yiling
2026-06-01 23:35:00 +08:00
parent e3f4fa219e
commit 1f341c15d0
288 changed files with 18024 additions and 21178 deletions
@@ -0,0 +1,35 @@
import { Modifier, configurator } from '@dnd-kit/abstract'
import type { DragOperation } from '@dnd-kit/abstract'
import type { DragDropManager } from '@dnd-kit/dom'
interface Anchor {
x: number
y: number
}
interface Options {
anchor?: Anchor
}
const DEFAULT_ANCHOR: Anchor = { x: 0.5, y: 0.5 }
export class SnapToPointer extends Modifier<DragDropManager, Options> {
apply({ activatorEvent, shape, transform }: DragOperation) {
if (!shape || !(activatorEvent instanceof PointerEvent)) {
return transform
}
const anchor = this.options?.anchor ?? DEFAULT_ANCHOR
const { boundingRectangle } = shape.initial
const anchorX = boundingRectangle.left + boundingRectangle.width * anchor.x
const anchorY = boundingRectangle.top + boundingRectangle.height * anchor.y
return {
x: transform.x + activatorEvent.clientX - anchorX,
y: transform.y + activatorEvent.clientY - anchorY,
}
}
static configure = configurator(SnapToPointer)
}