improved two major forms.
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.status :as status]
|
||||
[malli.core :as m]
|
||||
[malli.error :as me]))
|
||||
[malli.error :as me]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defonce ^js/React.Context form-context (react/createContext "default"))
|
||||
(def ^js/React.Provider Provider (. form-context -Provider))
|
||||
@@ -161,7 +162,9 @@
|
||||
[:div
|
||||
[:p.help.has-text-danger error-message]]))))]))])
|
||||
|
||||
(defn raw-field-v2 [{:keys [field]}]
|
||||
(defn raw-field-v2 [{:keys [field] :as props}]
|
||||
(when-not field
|
||||
(throw (ex-info (str "Missing field") (clj->js {:props props}))))
|
||||
(let [[child] (r/children (r/current-component))]
|
||||
[:> Consumer {}
|
||||
(fn [consume-form]
|
||||
@@ -188,7 +191,6 @@
|
||||
(if on-change
|
||||
(partial form-change-handler (aget consume-form "data") full-field-path (aget consume-form "on-change"))
|
||||
(partial change-handler full-field-path (aget consume-form "change-event")))
|
||||
|
||||
:on-blur (partial blur-handler full-field-path (aget consume-form "blur-event"))
|
||||
:value value)
|
||||
(update :class (fn [class]
|
||||
@@ -198,8 +200,12 @@
|
||||
""
|
||||
(not (valid-field? (aget consume-form "problems") full-field-path))
|
||||
" is-danger"
|
||||
|
||||
value
|
||||
"is-success"
|
||||
|
||||
:else
|
||||
"is-success"))))))))))]))]))
|
||||
""))))))))))]))]))
|
||||
|
||||
(defn with-scope [{:keys [scope]}]
|
||||
(r/create-element FormScopeProvider #js {:value scope}
|
||||
|
||||
Reference in New Issue
Block a user