dgz-ui-shared
Version:
Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript, dgz-ui library
67 lines (66 loc) • 1.64 kB
JavaScript
import { j as s } from "./jsx-runtime-C5mzlN2N.js";
import { c as l, N as u, i as E, l as y, d as z, a as C } from "./radio-group-CqPTye2U-DGs9dBuR.js";
import { z as d } from "./popover-HTqpqYpJ-CwZxzUFN.js";
import { l as M } from "./lodash-CYNxjS-I.js";
import { m as h } from "./utils-B6fNqzRf-B1_jG1K7.js";
const k = ({
control: m,
name: r,
label: a,
helperText: e,
required: f,
className: t,
rules: p,
options: n = [],
onChange: o,
...c
}) => {
const i = a && /* @__PURE__ */ s.jsxs(C, { className: "my-3", children: [
a,
" ",
f && /* @__PURE__ */ s.jsx("span", { className: "text-red-600", children: "*" })
] });
return !r || !m ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
i,
/* @__PURE__ */ s.jsx(
d,
{
className: h("mt-2", t),
...c,
options: n
}
),
/* @__PURE__ */ s.jsx(l, { children: e })
] }) : /* @__PURE__ */ s.jsx(
u,
{
control: m,
name: r,
rules: p,
render: ({ field: x, formState: N }) => {
const g = (j) => {
x.onChange(j), o && o(j);
};
return /* @__PURE__ */ s.jsxs(E, { children: [
i,
/* @__PURE__ */ s.jsx(y, { children: /* @__PURE__ */ s.jsx(
d,
{
className: h("mt-2", t),
...c,
...x,
onChange: g,
options: n,
error: !!M.get(N.errors, `${r}`)
}
) }),
/* @__PURE__ */ s.jsx(l, { children: e }),
/* @__PURE__ */ s.jsx(z, {})
] });
}
}
);
};
export {
k as M
};