moved to new date picker.
This commit is contained in:
@@ -251,6 +251,7 @@
|
||||
options (if allow-nil?
|
||||
(with-keys (conj rest [:option {:value nil}]))
|
||||
(with-keys rest))]
|
||||
(println "KEYS" keys (dissoc keys :allow-nil?))
|
||||
(into [dom (dissoc keys :allow-nil?)] options)))
|
||||
|
||||
|
||||
@@ -340,33 +341,6 @@
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
(defmethod do-bind "date" [dom {:keys [field event subscription class spec] :as keys} & rest]
|
||||
(let [field (if (keyword? field) [field] field)
|
||||
event (if (keyword? event) [event] event)
|
||||
selected (get-in subscription field)
|
||||
|
||||
selected (cond (string? selected)
|
||||
(c/to-date (t/to-default-time-zone (t/from-default-time-zone (str->date selected standard))))
|
||||
|
||||
(instance? goog.date.DateTime selected)
|
||||
(c/to-date (t/to-default-time-zone (t/from-default-time-zone selected)))
|
||||
|
||||
(instance? goog.date.Date selected)
|
||||
(c/to-date selected)
|
||||
|
||||
:else
|
||||
selected )
|
||||
keys (assoc keys
|
||||
:on-change (if (:cljs-date? keys)
|
||||
(dispatch-cljs-date-change (conj event field))
|
||||
(dispatch-date-change (conj event field)))
|
||||
:selected selected
|
||||
:class (str class
|
||||
(when (and spec (not (s/valid? spec (get-in subscription field))))
|
||||
" is-danger")))
|
||||
keys (dissoc keys :field :subscription :event :spec)]
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
(defmethod do-bind "date2" [dom {:keys [field event subscription class spec] :as keys} & rest]
|
||||
(let [field (if (keyword? field) [field] field)
|
||||
event (if (keyword? event) [event] event)
|
||||
selected (get-in subscription field)
|
||||
@@ -489,21 +463,6 @@
|
||||
[:div.field-body]
|
||||
(with-keys (map (fn [x] [:div.field x]) controls)))])
|
||||
|
||||
(def date-picker
|
||||
(reagent/adapt-react-class (.-default react-datepicker)))
|
||||
|
||||
(defn date-picker-friendly [params]
|
||||
[date-picker (assoc params
|
||||
:class-name "input"
|
||||
:disabled-keyboard-navigation true
|
||||
:start-open false
|
||||
:class "input"
|
||||
:format-week-number (fn [] "")
|
||||
:previous-month-button-label ""
|
||||
:next-month-button-label ""
|
||||
:next-month-label ""
|
||||
:type "date")])
|
||||
|
||||
(defn coerce-date [d]
|
||||
(cond (and (string? d)
|
||||
(some->> (re-find #"^(\d{4})" d)
|
||||
@@ -524,7 +483,7 @@
|
||||
:else
|
||||
nil ))
|
||||
|
||||
(defn date-picker-optional-internal [params]
|
||||
(defn date-picker-internal [params]
|
||||
|
||||
(let [[text set-text ] (react/useState (some-> params :value coerce-date (date->str standard)))
|
||||
[value set-value ] (react/useState (some-> params :value coerce-date))
|
||||
@@ -565,8 +524,8 @@
|
||||
:type "date" :placeholder "12/1/2021")]
|
||||
]]))
|
||||
|
||||
(defn date-picker-optional []
|
||||
[:f> date-picker-optional-internal
|
||||
(defn date-picker []
|
||||
[:f> date-picker-internal
|
||||
(r/props (r/current-component))])
|
||||
|
||||
(defn local-now []
|
||||
|
||||
Reference in New Issue
Block a user