import React, { ChangeEventHandler } from 'react'; import Fieldset from "../../../primitives/Fieldset"; import Legend from "../../../primitives/Legend"; import OptionWrapper from "../../../primitives/OptionWrapper"; import CheckboxInput from "./CheckboxInput"; import { RenderWithData } from "../../../index"; export default function Checkbox({ setData, heading, options, grid, disabled, property, debug, currentValue, data, update }: RenderWithData<"Checkbox">) { const handleChange = (property: string, value: any): ChangeEventHandler => (e) => { setData(`${property}.${value}`, e.target.checked); // Unset properties in the update array when the checkbox value change update?.forEach((updateProp) => { setData(updateProp, undefined, true) }) } return (
{heading} {options && options.length ? ( {options.map((option) => { const isDisabled = disabled || option.disabled; return ( ); })} ) : null}
); }