<commit_before>(ns re-dnd.views
  (:require [goog.dom :as dom]
            [goog.style :as style]
            [re-dnd.events :as dnd]
            [re-frame.core :as rf]
            [reagent.core :as r]
            [taoensso.timbre :as timbre
             :refer-macros (log  trace  debug  info  warn  error  fatal  report
                                 logf tracef debugf infof warnf errorf fatalf reportf
                                 spy get-env log-env)]))

(defmulti dropped-widget
  (fn [{:keys [type id]}] type))

(defmethod dropped-widget
  :dnd/drop-marker
  [{:keys [type id]}]
  [:div.drop-marker])

(defmulti drag-handle
  (fn [{:keys [type id]}] type))

(defmethod drag-handle
  :dnd/drop-marker
  [{:keys [type id]}]
  [:div.drop-marker])

(defn start-drag-fn
  [id drop-zone-id e e2]
  (let  [p (or (dom/getAncestorByClass (.-target e) "dropped-element")
               (dom/getAncestorByClass (.-target e) "draggable"))
         bounds (style/getBounds p)]
    (rf/dispatch [:dnd/start-drag id
                  drop-zone-id
                  (.-left bounds)
                  (.-top bounds)
                  (.-width bounds)
                  (.-height bounds)])))

(defn hover-fn
  [elt-id drop-zone-id hover-in?]
  (rf/dispatch [:dnd/hover elt-id drop-zone-id hover-in?]))

(defn draggable
  ([id]
   [draggable id nil])
  ([id body]
   (let [drag-status (rf/subscribe [:dnd/drag-status id nil])]
     (fn [id body]
       [:div.draggable
        {:on-mouse-down (partial start-drag-fn id nil)
         :on-mouse-over (partial hover-fn id nil true)
         :on-mouse-out (partial hover-fn id nil false)}
        (when (= :hover @drag-status)
          [:div.drag-mask<commit_msg>add default drag handle.<commit_after>(ns re-dnd.views
  (:require [goog.dom :as dom]
            [goog.style :as style]
            [re-dnd.events :as dnd]
            [re-frame.core :as rf]
            [reagent.core :as r]
            [taoensso.timbre :as timbre
             :refer-macros (log  trace  debug  info  warn  error  fatal  report
                                 logf tracef debugf infof warnf errorf fatalf reportf
                                 spy get-env log-env)]))

(defmulti dropped-widget
  (fn [{:keys [type id]}] type))

(defmethod dropped-widget
  :dnd/drop-marker
  [{:keys [type id]}]
  [:div.drop-marker])

(defmulti drag-handle
  (fn [{:keys [type id]}] type))

(defmethod drag-handle
  :dnd/drop-marker
  [{:keys [type id]}]
  [:div.drop-marker])

(defmethod drag-handle
  :default
  [{:keys [type id]}]
  [:div.drop-marker])

(defn start-drag-fn
  [id drop-zone-id e e2]
  (let  [p (or (dom/getAncestorByClass (.-target e) "dropped-element")
               (dom/getAncestorByClass (.-target e) "draggable"))
         bounds (style/getBounds p)]
    (rf/dispatch [:dnd/start-drag id
                  drop-zone-id
                  (.-left bounds)
                  (.-top bounds)
                  (.-width bounds)
                  (.-height bounds)])))

(defn hover-fn
  [elt-id drop-zone-id hover-in?]
  (rf/dispatch [:dnd/hover elt-id drop-zone-id hover-in?]))

(defn draggable
  ([id]
   [draggable id nil])
  ([id body]
   (let [drag-status (rf/subscribe [:dnd/drag-status id nil])]
     (fn [id body]
       [:div.draggable
        {:on-mouse-down (partial start-drag-fn id nil)
         :on-mouse-over (partial hover-fn id nil true)
         :on-mouse-out (partial hover-fn id nil false)}
        (when (= :hover @drag-status)
          [:div.drag-mask
{'fraction_non_alphanumeric': 0.1455117209834191, 'fraction_numerical': 0.0005717552887364208, 'mean_word_length': 1.896523178807947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3365751', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1210, 'n_words': 309}