mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-20 14:54:12 +00:00
## Summary Adds the linter, turns on the recommended and a few extra rules, fixes existing violations. Doesn't prohibit `../../...` imports yet, that'll be it's own PR. ## Changes - **What**: Consistent and fixable imports - **Dependencies**: The plugin and parser ## Review Focus How do you feel about the recommended rules? What about the extra ones? [Any more](https://github.com/un-ts/eslint-plugin-import-x?tab=readme-ov-file#rules) you'd want to turn on? ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5955-Lint-Add-eslint-import-plugin-2856d73d3650819985c0fb9ca3fa94b0) by [Unito](https://www.unito.io)
56 lines
1.1 KiB
TypeScript
56 lines
1.1 KiB
TypeScript
import {
|
|
draggable,
|
|
dropTargetForElements
|
|
} from '@atlaskit/pragmatic-drag-and-drop/element/adapter'
|
|
import { onBeforeUnmount, onMounted, toValue } from 'vue'
|
|
import type { MaybeRefOrGetter } from 'vue'
|
|
|
|
export function usePragmaticDroppable(
|
|
dropTargetElement: MaybeRefOrGetter<HTMLElement | null>,
|
|
options: Omit<Parameters<typeof dropTargetForElements>[0], 'element'>
|
|
) {
|
|
let cleanup = () => {}
|
|
|
|
onMounted(() => {
|
|
const element = toValue(dropTargetElement)
|
|
|
|
if (!element) {
|
|
return
|
|
}
|
|
|
|
cleanup = dropTargetForElements({
|
|
element,
|
|
...options
|
|
})
|
|
})
|
|
|
|
onBeforeUnmount(() => {
|
|
cleanup()
|
|
})
|
|
}
|
|
|
|
export function usePragmaticDraggable(
|
|
draggableElement: MaybeRefOrGetter<HTMLElement | null>,
|
|
options: Omit<Parameters<typeof draggable>[0], 'element'>
|
|
) {
|
|
let cleanup = () => {}
|
|
|
|
onMounted(() => {
|
|
const element = toValue(draggableElement)
|
|
|
|
if (!element) {
|
|
return
|
|
}
|
|
|
|
cleanup = draggable({
|
|
element,
|
|
...options
|
|
})
|
|
// TODO: Change to onScopeDispose
|
|
})
|
|
|
|
onBeforeUnmount(() => {
|
|
cleanup()
|
|
})
|
|
}
|