synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
59 lines (58 loc) • 1.45 kB
JavaScript
import { jsxs as g, jsx as a } from "react/jsx-runtime";
import m from "@mui/material/FormControlLabel";
import p from "@mui/material/Radio";
import O from "@mui/material/RadioGroup";
import V from "@mui/material/TextField";
import { useState as d } from "react";
const t = "__other";
function G(v) {
const { value: o, onChange: r, options: u, radioGroupProps: c } = v, i = u.some((e) => e.value === o), [n, f] = d(
i ? o : t
), [s, h] = d(i ? "" : o);
return /* @__PURE__ */ g(
O,
{
...c,
value: n,
onChange: (e) => {
f(e.target.value);
let l = e.target.value;
l === t && (l = s), r(l);
},
children: [
u.map((e) => /* @__PURE__ */ a(
m,
{
value: e.value,
control: /* @__PURE__ */ a(p, {}),
label: e.label
},
e.value
)),
/* @__PURE__ */ a(
m,
{
value: t,
control: /* @__PURE__ */ a(p, {}),
label: "Other"
}
),
/* @__PURE__ */ a(
V,
{
value: s,
slotProps: { htmlInput: { "aria-label": "Other Value" } },
onChange: (e) => {
h(e.target.value), r(e.target.value);
},
disabled: n !== t
}
)
]
}
);
}
export {
G as default
};
//# sourceMappingURL=RadioGroupWithOtherString.js.map