Skip to content

Instantly share code, notes, and snippets.

@geraldodev
Created November 20, 2020 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geraldodev/be8fb754019dc3e633b67dea5db6ff6c to your computer and use it in GitHub Desktop.
Save geraldodev/be8fb754019dc3e633b67dea5db6ff6c to your computer and use it in GitHub Desktop.
mui Autocomplete with helix. The render-input node needs to be created with plain react
(ns app.ui.contratualizacao.regra
(:require
["@material-ui/lab/Autocomplete" :default Autocomplete]
["@material-ui/core/TextField" :default TextField]
["react" :as r]
[goog.object :as gobj]
))
($ ^:native
Autocomplete
{:id "grupofiltro"
:options (or grupos-json #js [])
:get-option-label #(gobj/get % "descricao")
:get-option-selected #(gobj/get % "codigo")
:style {:width 300}
:render-input (fn [params]
(.createElement r TextField
(doto (js/Object.assign #js {} params)
(gobj/set "label" "Escolha um grupo")
(gobj/set "variant" "outlined")
(gobj/set "fullWidth" true)))) })
@geraldodev
Copy link
Author

geraldodev commented Nov 26, 2020

($ AutocompleteHelix {:id "mylookup" :js-options #js [{:name "john" :id "1"}] :label "Client" :label-field :name :value-field :id :value simple-cljs-variable-that-has-the-id-of-the-client :on-change (fn [e value reason] (setter-from-helix-use-state-hook assoc :client-id value)) :style {:width "200px"})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment