From 59aa96507af94d18774aacb9030ef07aa392b411 Mon Sep 17 00:00:00 2001 From: honzapatCZ Date: Fri, 26 Sep 2025 20:08:56 +0200 Subject: [PATCH] Fixed up checkbox --- Parts/Input.tsx | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/Parts/Input.tsx b/Parts/Input.tsx index 686054e..d9d3151 100644 --- a/Parts/Input.tsx +++ b/Parts/Input.tsx @@ -6,8 +6,8 @@ import { IMaskInput, IMaskInputProps, IMaskMixinProps } from 'react-imask'; //const useFormikField = null; //const useFormikContext = ()=>{}; -export function useField(props) { - let getField = useFormikField; +export function useField(props) { + let getField = useFormikField; const context = useFormikContext(); if (!context) { getField = (propsOrFieldName: FieldHookConfig) => { @@ -45,8 +45,8 @@ export default function Input( {/*name={name || title} id={id || name || title}*/} {props.children} @@ -147,37 +147,41 @@ export function TextArea({ * @param {Object} props... - Additional properties for the checkbox input. * @return {ReactElement} The rendered CheckBox component. */ -export function CheckBox({ - label, - title, +export function CheckBox( + props: (Omit, "value" | "checked"> | Omit, "value">) & { + label?: React.ComponentPropsWithoutRef<"label">; + title?: string; + children?: React.ReactNode; + className?: string; + value?: boolean + } +) { + /*name, id*/ + const { children, ...otherProps } = props; - children, - ...props -}) { - - const [field, meta, helpers] = useField(props); + const [field, meta, helpers] = useField(otherProps); return (
- {title != null ? ( + {props.title && ( - ) : null} + )} {children} - {meta?.touched && meta.error ? ( -
{meta.error}
- ) : null}
); }