Просмотр исходного кода

support the `Option` type.

it's similar to the optional keys, but can be used to wrap any type.
Lucas Stadler лет назад: 12
Родитель
Сommit
607439bfb9
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      clj/clarity/cljs/clarity.cljs

+ 7 - 0
clj/clarity/cljs/clarity.cljs

@ -47,6 +47,9 @@
47 47
(defmethod empty-value 'Value [[_ v]]
48 48
  v)
49 49
50
(defmethod empty-value 'Option [[_ v]]
51
  (empty-value v))
52
50 53
(defmethod empty-value 'U [[_ & [[_ v]]]]
51 54
  v)
52 55
@ -112,6 +115,10 @@
112 115
                    (keyword? value) {:type "text", :pattern keyword-pattern}
113 116
                    :else {:type "text"}))))))
114 117
118
(defmethod make-typed-input 'Option [m owner {type :type :as opts}]
119
  (let [[_ type] type]
120
    (make-typed-input m owner (assoc opts :type type))))
121
115 122
(defmethod make-typed-input 'U [m owner {:keys [type key val]}]
116 123
  (om/component
117 124
    (dom/select #js {:onChange (update-on-change! m key r/read-string)}