@payfit/unity-components
Version:
55 lines (54 loc) • 1.78 kB
JavaScript
import { DatePicker as e } from "../date-picker/DatePicker.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/date-picker-field/DatePickerField.tsx
var d = s({ base: "uy:flex uy:flex-col uy:gap-100" });
function f({ name: o, label: s, defaultValue: f, helperText: p, feedbackText: m, contextualLink: h, isRequired: g, isInvalid: _, isLoading: v, isDisabled: y, isReadOnly: b, requiredVariant: x, ...S }, C) {
let { control: w, resetField: T, setValue: E } = u(), D = {
isRequired: g,
isInvalid: _,
isLoading: v,
isDisabled: y,
isReadOnly: b
}, O = S.onClearButtonPress ?? (() => {
T(o, {
keepTouched: !1,
keepDirty: !1,
keepError: !1
}), E(o, null, { shouldValidate: !1 });
});
return /* @__PURE__ */ l(n, {
control: w,
name: o,
className: d(),
...D,
children: [
/* @__PURE__ */ c(a, {
requiredVariant: x,
children: s
}),
p && /* @__PURE__ */ c(t, { children: p }),
/* @__PURE__ */ c(r, { children: /* @__PURE__ */ c(e, {
ref: C,
defaultValue: f,
onClearButtonPress: O,
...S
}) }),
/* @__PURE__ */ c(i, { children: m }),
h
]
});
}
var p = o(function(e, t) {
return f(e, t);
});
p.displayName = "DatePickerField";
//#endregion
export { p as DatePickerField };