Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const useCheckboxFoundation = (
props: CheckboxProps & React.HTMLProps
) => {
const { renderToggle, toggleRootProps, id } = useToggleFoundation(props);
const { foundation, ...elements } = useFoundation({
props,
elements: {
rootEl: true,
checkboxEl: true
},
foundation: ({ rootEl, checkboxEl, getProps }) => {
return new MDCCheckboxFoundation({
addClass: (className: string) => rootEl.addClass(className),
removeClass: (className: string) => rootEl.removeClass(className),
setNativeControlAttr: (attr: string, value: any) =>
checkboxEl.setProp(attr as any, value),
removeNativeControlAttr: (attr: string) =>
checkboxEl.removeProp(attr as any),
isIndeterminate: () => !!getProps().indeterminate,