Lib: Specify missing HTMLButtonAttributes explicitly

This commit is contained in:
2025-02-03 22:33:22 +01:00
parent 4cdc7713c8
commit 3bb2e318b1

View File

@ -38,6 +38,15 @@
/** Additional classes to insert */ /** Additional classes to insert */
extraclass?: string; extraclass?: string;
/** An optional onclick event for the button */
onclick?: (event: Event) => void;
/** An optional formaction for the button */
formaction?: string;
/** Optionally disable the button */
disabled?: boolean;
} }
let { let {
@ -51,6 +60,9 @@
trigger_popup = { event: "click", target: "invalid" }, trigger_popup = { event: "click", target: "invalid" },
shadow = false, shadow = false,
extraclass = "", extraclass = "",
onclick = () => {},
formaction = undefined,
disabled = false,
...restProps ...restProps
}: ButtonProps = $props(); }: ButtonProps = $props();
</script> </script>
@ -63,8 +75,11 @@
: ''} {activate_href && is_at_path(href) ? 'btn-hover' : ''} {shadow : ''} {activate_href && is_at_path(href) ? 'btn-hover' : ''} {shadow
? 'shadow' ? 'shadow'
: ''} {extraclass}" : ''} {extraclass}"
{...restProps}>{@render children()}</a {onclick}
{...restProps}
> >
{@render children()}
</a>
{:else} {:else}
<button <button
type={submit ? "submit" : "button"} type={submit ? "submit" : "button"}
@ -73,6 +88,11 @@
: ''} {shadow ? 'shadow' : ''} {extraclass}" : ''} {shadow ? 'shadow' : ''} {extraclass}"
draggable="false" draggable="false"
use:popup={trigger_popup} use:popup={trigger_popup}
{...restProps}>{@render children()}</button {onclick}
{formaction}
{disabled}
{...restProps}
> >
{@render children()}
</button>
{/if} {/if}