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