mirror of
https://github.com/penpot/penpot.git
synced 2025-05-17 01:56:11 +02:00
🔥 Remove react-dnd dependency.
This commit is contained in:
parent
77d555dbf2
commit
45bf06733f
7 changed files with 7 additions and 177 deletions
|
@ -19,7 +19,6 @@
|
|||
[uxbox.main.ui.hooks :as hooks]
|
||||
[uxbox.main.ui.keyboard :as kbd]
|
||||
[uxbox.main.ui.shapes.icon :as icon]
|
||||
[uxbox.main.ui.workspace.sortable :refer [use-sortable]]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.perf :as perf]
|
||||
[uxbox.common.uuid :as uuid]
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
[uxbox.main.store :as st]
|
||||
[uxbox.main.ui.keyboard :as kbd]
|
||||
[uxbox.main.ui.shapes.icon :as icon]
|
||||
[uxbox.main.ui.workspace.sortable :refer [use-sortable]]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.timers :as timers]
|
||||
[uxbox.common.uuid :as uuid]
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
[uxbox.main.ui.confirm :refer [confirm-dialog]]
|
||||
[uxbox.main.ui.keyboard :as kbd]
|
||||
[uxbox.main.ui.modal :as modal]
|
||||
[uxbox.main.ui.workspace.sortable :refer [use-sortable]]
|
||||
[uxbox.util.data :refer [classnames enumerate]]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.i18n :as i18n :refer [t]]
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) 2019 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.main.ui.workspace.sortable
|
||||
"A sortable React Hook implementation."
|
||||
(:require
|
||||
[rumext.alpha :as mf]
|
||||
[rumext.util :as mfu]
|
||||
[uxbox.util.rdnd :as rdnd]))
|
||||
|
||||
;; --- Page Item
|
||||
|
||||
(set! *warn-on-infer* true)
|
||||
|
||||
(defn use-sortable
|
||||
[{:keys [type data on-hover on-drop]
|
||||
:or {on-hover (constantly nil)
|
||||
on-drop (constantly nil)}
|
||||
:as options}]
|
||||
(let [ref (mf/use-ref nil)
|
||||
|
||||
on-hover
|
||||
(fn [item monitor]
|
||||
(when (mf/ref-val ref)
|
||||
(on-hover (unchecked-get item "data") monitor)))
|
||||
|
||||
on-drop
|
||||
(fn [item monitor]
|
||||
(when (mf/ref-val ref)
|
||||
(on-drop (unchecked-get item "data") monitor)))
|
||||
|
||||
on-drop-collect
|
||||
(fn [monitor]
|
||||
#js {:is-over (.isOver ^js monitor)
|
||||
:can-drop (.canDrop ^js monitor)})
|
||||
|
||||
on-drag-collect
|
||||
(fn [monitor]
|
||||
#js {:dragging? (.isDragging monitor)})
|
||||
|
||||
[props1, drop] (rdnd/useDrop
|
||||
#js {:accept type
|
||||
:collect on-drop-collect
|
||||
:hover on-hover
|
||||
:drop on-drop})
|
||||
[props2, drag] (rdnd/useDrag
|
||||
#js {:item #js {:type type :data data}
|
||||
:collect on-drag-collect})
|
||||
props (js/Object.assign props1 props2)]
|
||||
[(mfu/obj->map props)
|
||||
(drag (drop ref))]))
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) 2019 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.util.rdnd
|
||||
(:require
|
||||
["react-dnd/dist/esm/hooks" :as hooks]
|
||||
["react-dnd/dist/esm/common" :as common]
|
||||
["react-dnd-html5-backend" :as backend]))
|
||||
|
||||
(def useDrop hooks/useDrop)
|
||||
(def useDrag hooks/useDrag)
|
||||
(def provider common/DndProvider)
|
||||
(def html5 backend/default)
|
Loading…
Add table
Add a link
Reference in a new issue