import type { JBButtonWebComponent } from "jb-button"; import { type RefObject, useEffect } from "react"; export type JBButtonAttributes = { isLoading?: boolean, disabled?: boolean, square?: boolean, } export function useJBButtonAttribute(element: RefObject, props: JBButtonAttributes) { useEffect(() => { if (props.disabled) { element.current?.setAttribute('disabled', 'disabled'); } else { element.current?.removeAttribute('disabled'); } }, [props.disabled]); useEffect(() => { if (element.current) { element.current.isLoading = props.isLoading || false; } }, [props.isLoading]); useEffect(() => { if (props.square) { element.current?.setAttribute("square", ""); } else { element.current?.removeAttribute("square"); } }, [props.square]); }