mirror of
https://github.com/penpot/penpot.git
synced 2025-08-01 19:28:25 +02:00
Display regular input field when token is applied [*]
[*] Numeric input renders default 0
This commit is contained in:
parent
04c43acf39
commit
975f41bc08
1 changed files with 30 additions and 15 deletions
|
@ -75,6 +75,11 @@
|
||||||
min-val (get params :min)
|
min-val (get params :min)
|
||||||
max-val (get params :max)
|
max-val (get params :max)
|
||||||
|
|
||||||
|
multiple? (= :multiple value)
|
||||||
|
token (when-not multiple?
|
||||||
|
(-> (filter :selected? options) (first)))
|
||||||
|
_ (js/console.log "token" token)
|
||||||
|
|
||||||
emit-blur? (mf/use-ref nil)
|
emit-blur? (mf/use-ref nil)
|
||||||
select-wrapper-ref (mf/use-ref)
|
select-wrapper-ref (mf/use-ref)
|
||||||
|
|
||||||
|
@ -187,21 +192,31 @@
|
||||||
|
|
||||||
[:div {:class (dm/str class " " (stl/css :editable-select))
|
[:div {:class (dm/str class " " (stl/css :editable-select))
|
||||||
:ref on-node-load}
|
:ref on-node-load}
|
||||||
(if (= type "number")
|
(when token
|
||||||
[:> numeric-input* {:value (or current-value "")
|
[:div {:class (stl/css :token-pill)}
|
||||||
:className input-class
|
(:label token)])
|
||||||
:on-change set-value
|
(cond
|
||||||
:on-focus handle-focus
|
token [:input {:value ""
|
||||||
:on-blur handle-blur
|
:class input-class
|
||||||
:placeholder placeholder}]
|
:on-change handle-change-input
|
||||||
[:input {:value (or current-value "")
|
:on-key-down handle-key-down
|
||||||
:class input-class
|
:on-focus handle-focus
|
||||||
:on-change handle-change-input
|
:on-blur handle-blur
|
||||||
:on-key-down handle-key-down
|
:type type}]
|
||||||
:on-focus handle-focus
|
(= type "number") [:> numeric-input* {:value (or current-value "")
|
||||||
:on-blur handle-blur
|
:className input-class
|
||||||
:placeholder placeholder
|
:on-change set-value
|
||||||
:type type}])
|
:on-focus handle-focus
|
||||||
|
:on-blur handle-blur
|
||||||
|
:placeholder placeholder}]
|
||||||
|
:else [:input {:value (or current-value "")
|
||||||
|
:class input-class
|
||||||
|
:on-change handle-change-input
|
||||||
|
:on-key-down handle-key-down
|
||||||
|
:on-focus handle-focus
|
||||||
|
:on-blur handle-blur
|
||||||
|
:placeholder placeholder
|
||||||
|
:type type}])
|
||||||
|
|
||||||
(when (seq options)
|
(when (seq options)
|
||||||
[:span {:class (stl/css :dropdown-button)
|
[:span {:class (stl/css :dropdown-button)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue