public commit

This commit is contained in:
dswbx
2024-11-16 12:01:47 +01:00
commit 90f80c4280
582 changed files with 49291 additions and 0 deletions
@@ -0,0 +1,48 @@
import { Switch } from "@mantine/core";
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from "@rjsf/utils";
import { type ChangeEvent, useCallback } from "react";
export function CheckboxWidget<
T = any,
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any
>({
schema,
uiSchema,
options,
id,
value,
disabled,
readonly,
label,
hideLabel,
autofocus = false,
onBlur,
onFocus,
onChange,
registry,
...props
}: WidgetProps<T, S, F>) {
/*console.log("addprops", value, props, label, {
label,
name: props.name,
hideLabel,
label_lower: label.toLowerCase(),
name_lower: props.name.toLowerCase(),
equals: label.toLowerCase() === props.name.toLowerCase()
});*/
const handleChange = useCallback(
(event: ChangeEvent<HTMLInputElement>) => onChange(event.target.checked),
[onChange]
);
return (
<Switch
id={id}
onChange={handleChange}
defaultChecked={value}
disabled={disabled || readonly}
label={label.toLowerCase() === props.name.toLowerCase() ? undefined : label}
/>
);
}