@payfit/unity-components
Version:
58 lines (57 loc) • 1.89 kB
JavaScript
import { MultiSelect as e } from "../multi-select/MultiSelect.js";
import { FormHelperText as t } from "../form-field/parts/FormHelperText.js";
import { FormField as n } from "../form-field/FormField.js";
import { FormControl as r } from "../form-field/parts/FormControl.js";
import { FormFeedbackText as i } from "../form-field/parts/FormFeedbackText.js";
import { FormLabel as a } from "../form-field/parts/FormLabel.js";
import { forwardRef as o } from "react";
import { uyTv as s } from "@payfit/unity-themes";
import { jsx as c, jsxs as l } from "react/jsx-runtime";
import { useFormContext as u } from "react-hook-form";
//#region src/components/multi-select-field/MultiSelectField.tsx
var d = s({ base: "uy:flex uy:flex-col uy:gap-100" });
function f(o, s) {
let { control: f, setValue: p } = u(), { name: m, label: h, helperText: g, feedbackText: _, contextualLink: v, isRequired: y, isInvalid: b, isLoading: x, isDisabled: S, isReadOnly: C, requiredVariant: w, children: T, onClearButtonPress: E, ...D } = o, O = {
isRequired: y,
isInvalid: b,
isLoading: x,
isDisabled: S,
isReadOnly: C
}, k = {
onClearButtonPress: () => {
p(m, /* @__PURE__ */ new Set()), E?.();
},
placeholder: o.placeholder,
isSearchable: o.isSearchable,
maxVisibleItems: o.maxVisibleItems,
isDisabled: S,
isReadOnly: C,
isLoading: x,
...o.renderValue && { renderValue: o.renderValue }
};
return /* @__PURE__ */ l(n, {
control: f,
name: m,
className: d(),
...O,
children: [
/* @__PURE__ */ c(a, {
requiredVariant: w,
children: h
}),
g && /* @__PURE__ */ c(t, { children: g }),
/* @__PURE__ */ c(r, { children: /* @__PURE__ */ c(e, {
...D,
...k,
ref: s,
children: T
}) }),
/* @__PURE__ */ c(i, { children: _ }),
v
]
});
}
var p = o(f);
p.displayName = "MultiSelectField";
//#endregion
export { p as MultiSelectField };