UNPKG

@payfit/unity-components

Version:

40 lines (39 loc) • 1.37 kB
import { DatePicker as e } from "../../../../core/components/date-picker/DatePicker.js"; import { useFieldContext as t } from "../../hooks/tanstack-form-context.js"; import { useFieldA11yContext as n } from "../form-field/TanstackFormField.context.js"; import { forwardRef as r } from "react"; import { jsx as i } from "react/jsx-runtime"; //#region src/modules/tanstack-form/components/date-picker/TanstackDatePicker.tsx var a = r(({ value: r, onClearButtonPress: a, onBlur: o, onFocus: s, onChange: c, onOpenChange: l, isReadOnly: u, isDisabled: d, ...f }, p) => { let m = t(), h = n(), g = m.state.meta.isTouched && !m.state.meta.isValid, _ = [h.helperTextId, h.feedbackTextId].filter(Boolean).join(" "); return /* @__PURE__ */ i(e, { ...f, ref: p, id: h.inputId, value: r === void 0 ? m.state.value : r, onChange: (e) => { r === void 0 && m.handleChange(e), c?.(e); }, onBlur: () => { m.handleBlur(), o?.(); }, onFocus: () => { s?.(); }, onOpenChange: (e) => { l?.(e); }, onClearButtonPress: () => { r === void 0 ? m.setValue(null) : c?.(null), a?.(); }, isReadOnly: u, isDisabled: d, isInvalid: g, "aria-labelledby": h.labelId, "aria-describedby": _.length > 0 ? _ : void 0, "aria-details": h.contextualLinkId }); }); a.displayName = "TanstackDatePicker"; //#endregion export { a as TanstackDatePicker };