Tweaks for editing invoices
This commit is contained in:
@@ -39,58 +39,58 @@
|
||||
|
||||
(defn typeahead- [params]
|
||||
[:div.relative {:x-data (hx/json {:open false
|
||||
:baseUrl (if (str/includes? (:url params) "?")
|
||||
(str (:url params) "&q=")
|
||||
(str (:url params) "?q="))
|
||||
:value {:value ((:value-fn params identity) (:value params)) :label ((:content-fn params identity) (:value params))}
|
||||
:search ""
|
||||
:active -1
|
||||
:elements (if ((:value-fn params identity) (:value params))
|
||||
[{:value ((:value-fn params identity) (:value params)) :label ((:content-fn params identity) (:value params))}]
|
||||
[])
|
||||
:popper nil
|
||||
:baseUrl (if (str/includes? (:url params) "?")
|
||||
(str (:url params) "&q=")
|
||||
(str (:url params) "?q="))
|
||||
:value {:value ((:value-fn params identity) (:value params)) :label ((:content-fn params identity) (:value params))}
|
||||
:search ""
|
||||
:active -1
|
||||
:elements (if ((:value-fn params identity) (:value params))
|
||||
[{:value ((:value-fn params identity) (:value params)) :label ((:content-fn params identity) (:value params))}]
|
||||
[])
|
||||
:popper nil
|
||||
:warning_badge nil})
|
||||
:x-modelable "value.value"
|
||||
:x-model (:x-model params)
|
||||
:x-init "popper = Popper.createPopper($refs.input, $refs.dropdown, {placement: 'bottom-start', strategy: 'fixed', modifiers: {name: 'offset', options: {offset: [0, 10]}}})
|
||||
warning_badge = Popper.createPopper($refs.warning_badge, $refs.warning_pop, {placement: 'top', strategy: 'fixed', modifiers: {name: 'offset', options: {offset: [10,0 ]}}})"
|
||||
}
|
||||
[:a {:class (-> (hh/add-class (or (:class params) "") default-input-classes)
|
||||
(hh/add-class "cursor-pointer"))
|
||||
"@click.prevent" "open = !open; popper.update()"
|
||||
"@keydown.down.prevent.stop" "open = true; popper.update()"
|
||||
"@keydown.backspace" "value = {value: '', label: '' }"
|
||||
:tabindex 0
|
||||
:x-init (:x-init params)
|
||||
:x-ref "input"
|
||||
}
|
||||
[:input (-> params
|
||||
(dissoc :class)
|
||||
(dissoc :value-fn)
|
||||
(dissoc :content-fn)
|
||||
:x-modelable "value.value"
|
||||
:x-model (:x-model params)
|
||||
:x-init "popper = Popper.createPopper($refs.input, $refs.dropdown, {placement: 'bottom-start', strategy: 'fixed', modifiers: {name: 'offset', options: {offset: [0, 10]}}})
|
||||
warning_badge = Popper.createPopper($refs.warning_badge, $refs.warning_pop, {placement: 'top', strategy: 'fixed', modifiers: {name: 'offset', options: {offset: [10,0 ]}}})"}
|
||||
(if (:disabled params)
|
||||
[:span {:x-text "value.label"}]
|
||||
[:a {:class (-> (hh/add-class (or (:class params) "") default-input-classes)
|
||||
(hh/add-class "cursor-pointer"))
|
||||
"@click.prevent" "open = !open; popper.update()"
|
||||
"@keydown.down.prevent.stop" "open = true; popper.update()"
|
||||
"@keydown.backspace" "value = {value: '', label: '' }"
|
||||
:tabindex 0
|
||||
:x-init (:x-init params)
|
||||
:x-ref "input"}
|
||||
[:input (-> params
|
||||
(dissoc :class)
|
||||
(dissoc :value-fn)
|
||||
(dissoc :content-fn)
|
||||
|
||||
(dissoc :placeholder)
|
||||
(dissoc :x-model)
|
||||
(assoc
|
||||
"x-ref" "hidden"
|
||||
:type "hidden"
|
||||
":value" "value.value"
|
||||
:x-init (hiccup/raw (str "$watch('value', v => $dispatch('change')); "))))]
|
||||
[:div.flex.w-full.justify-items-stretch
|
||||
[:span.flex-grow.text-left {"x-text" "value.label"}]
|
||||
[:div {:class "w-3 h-3 m-1 inline ml-1 justify-self-end text-gray-500 self-center"}
|
||||
svg/drop-down]
|
||||
[:div {:x-show "value.warning"
|
||||
:x-ref "warning_badge"
|
||||
:x-effect "if (value.warning) { $nextTick(()=> warning_badge.update()) }"}
|
||||
(tags/badge- {:class "peer"} "!")
|
||||
(dissoc :placeholder)
|
||||
(dissoc :x-model)
|
||||
|
||||
(assoc
|
||||
"x-ref" "hidden"
|
||||
:type "hidden"
|
||||
":value" "value.value"
|
||||
:x-init (hiccup/raw (str "$watch('value', v => $dispatch('change')); "))))]
|
||||
[:div.flex.w-full.justify-items-stretch
|
||||
[:span.flex-grow.text-left {"x-text" "value.label"}]
|
||||
[:div {:class "w-3 h-3 m-1 inline ml-1 justify-self-end text-gray-500 self-center"}
|
||||
svg/drop-down]
|
||||
[:div {:x-show "value.warning"
|
||||
:x-ref "warning_badge"
|
||||
:x-effect "if (value.warning) { $nextTick(()=> warning_badge.update()) }"}
|
||||
(tags/badge- {:class "peer"} "!")
|
||||
|
||||
|
||||
[:div {:x-show "value.warning"
|
||||
:x-ref "warning_pop"
|
||||
:class "hidden peer-hover:block bg-red-50 dark:bg-gray-600 rounded-lg shadow-2xl w-max z-50 p-4"
|
||||
:x-text "value.warning"}
|
||||
]]]]
|
||||
[:div {:x-show "value.warning"
|
||||
:x-ref "warning_pop"
|
||||
:class "hidden peer-hover:block bg-red-50 dark:bg-gray-600 rounded-lg shadow-2xl w-max z-50 p-4"
|
||||
:x-text "value.warning"}]]]])
|
||||
|
||||
[:ul.dropdown-contents {:class "bg-gray-100 dark:bg-gray-600 rounded-lg shadow-2xl w-max z-50 ring-1"
|
||||
"x-ref" "dropdown"
|
||||
@@ -104,12 +104,12 @@
|
||||
"x-show " "open"
|
||||
"x-trap" "open"
|
||||
"@click.outside" "open=false;"}
|
||||
|
||||
|
||||
[:input {:type "text"
|
||||
:class (-> (:class params)
|
||||
(or "")
|
||||
(hh/add-class default-input-classes)
|
||||
(hh/replace-wildcard ["rounded" "border"] "border-bottom bg-gray-100 rounded-t-lg w-full"))
|
||||
(or "")
|
||||
(hh/add-class default-input-classes)
|
||||
(hh/replace-wildcard ["rounded" "border"] "border-bottom bg-gray-100 rounded-t-lg w-full"))
|
||||
"x-model" "search"
|
||||
"placeholder" (:placeholder params)
|
||||
"@keydown.down.prevent" "active ++; active = active >= elements.length - 1 ? elements.length - 1 : active"
|
||||
@@ -127,8 +127,7 @@
|
||||
"x-html" "element.label"}]]]
|
||||
[:template {:x-if "elements.length == 0"}
|
||||
[:li {:class "px-4 py-2 flex gap-2 items-center outline-0 focus:bg-neutral-100 hover:bg-neutral-100 whitespace-nowrap [&.active]:bg-primary-500 text-gray-800 dark:text-gray-100 text-xs "}
|
||||
"No results found"]]]
|
||||
]])
|
||||
"No results found"]]]]])
|
||||
|
||||
|
||||
(defn use-size [size]
|
||||
|
||||
Reference in New Issue
Block a user