Skip to content

Commit

Permalink
remove additional parens
Browse files Browse the repository at this point in the history
  • Loading branch information
TrangPham committed Mar 11, 2024
1 parent c999ffc commit 5abaac6
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/antd/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
import { CellProps, WithClassname, Helpers } from "@jsonforms/core"
import { Checkbox as AntDCheckbox } from "antd"
import { CheckboxChangeEvent } from "antd/es/checkbox"
import { CellProps, WithClassname, Helpers } from "@jsonforms/core";
import { Checkbox as AntDCheckbox } from "antd";
import { CheckboxChangeEvent } from "antd/es/checkbox";

interface CheckboxProps extends CellProps, WithClassname {
label?: string
label?: string;
}

export function Checkbox({ data, className, id, enabled, uischema, schema, path, handleChange, label } : CheckboxProps) {
const checked = !!data // convert undefined to false
export function Checkbox({
data,
className,
id,
enabled,
uischema,
schema,
path,
handleChange,
label,
}: CheckboxProps) {
const checked = !!data; // convert undefined to false

const labelDescription = Helpers.createLabelDescriptionFrom(uischema, schema);
const defaultLabel = labelDescription.show ? labelDescription.text : '';
const defaultLabel = labelDescription.show ? labelDescription.text : "";

return (
<AntDCheckbox
checked={checked}
onChange={(e: CheckboxChangeEvent) => {handleChange(path, e.target.checked)}}
onChange={(e: CheckboxChangeEvent) =>
handleChange(path, e.target.checked)
}
className={className}
id={id}
disabled={!enabled}
>
{label ?? defaultLabel}
</AntDCheckbox>
)
);
}

0 comments on commit 5abaac6

Please sign in to comment.