UNPKG

@payfit/unity-components

Version:

51 lines (50 loc) 1.68 kB
import { NumberInput as e } from "../number-input/NumberInput.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/number-field/NumberField.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, onClearButtonPress: S, ...C }, w) { let { control: T, setValue: E } = u(), D = { isRequired: g, isInvalid: _, isLoading: v, isDisabled: y, isReadOnly: b }, O = S ?? (() => { E(o, NaN); }); return /* @__PURE__ */ l(n, { control: T, 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: w, onClearButtonPress: O, defaultValue: f, ...C }) }), /* @__PURE__ */ c(i, { children: m }), h ] }); } var p = o(function(e, t) { return f(e, t); }); p.displayName = "NumberField"; //#endregion export { p as NumberField, d as numberField };