synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
73 lines (72 loc) • 2.01 kB
JavaScript
import { jsx as n, jsxs as S } from "react/jsx-runtime";
import { useSearchRegistry as I } from "../../synapse-queries/ror/index.js";
import { Autocomplete as b, Box as O, Typography as p, TextField as C } from "@mui/material";
import { useDebouncedEffect as R } from "@react-hookz/web";
import T from "lodash-es/noop";
import { useState as c } from "react";
function d(i) {
return i.names.find((t) => t.types.includes("ror_display"));
}
function z(i) {
const { value: t, onChange: f = T, error: m } = i, o = t !== void 0, [a, h] = c(""), [s, u] = c("");
R(
() => {
u(o ? t || "" : a);
},
[t, a, o],
500
);
const { data: y, isLoading: g } = I(
`${s}`,
{
enabled: s.length > 0
}
);
return /* @__PURE__ */ n(
b,
{
freeSolo: !0,
loading: g,
onInputChange: (e, r) => {
o || h(r), f(r);
},
renderInput: (e) => /* @__PURE__ */ n(
C,
{
...e,
label: "Current Affiliation",
placeholder: "Type to search, or enter free text.",
error: m
}
),
inputValue: o ? t : a,
getOptionLabel: (e) => typeof e == "string" ? e : d(e).value,
renderOption: (e, r) => {
const v = d(r).value, x = r.names.filter(
(l) => !l.types.includes("ror_display")
);
return /* @__PURE__ */ n(O, { component: "li", ...e, children: /* @__PURE__ */ S("div", { children: [
/* @__PURE__ */ n(p, { variant: "body1", children: v }),
/* @__PURE__ */ n(
p,
{
variant: "smallText1",
sx: {
color: "grey.700",
fontStyle: "italic",
fontSize: "11px"
},
children: x.map((l) => l.value).join(", ")
}
)
] }) });
},
filterOptions: (e) => e,
options: y?.items || []
}
);
}
export {
z as default
};
//# sourceMappingURL=RORInstitutionField.js.map