feat: add Fieldset and SearchField infrastructure
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { useInheritedDisabled } from "../field/disabled";
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { Primitive } from "reka-ui";
|
||||
import type { ButtonHTMLAttributes } from "vue";
|
||||
@@ -21,7 +22,7 @@ const props = withDefaults(
|
||||
{ type: "button" },
|
||||
);
|
||||
const pending = computed(() => props.isPending || props.loading);
|
||||
const disabled = computed(() => props.isDisabled || props.disabled);
|
||||
const disabled = useInheritedDisabled(() => props.isDisabled || props.disabled);
|
||||
const hovered = ref(false),
|
||||
pressed = ref(false),
|
||||
focused = ref(false),
|
||||
@@ -37,7 +38,7 @@ watch(
|
||||
{ flush: "sync" },
|
||||
);
|
||||
function guard(e: MouseEvent) {
|
||||
if (pending.value) {
|
||||
if (pending.value || disabled.value) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
@@ -49,6 +50,7 @@ function focus(e: FocusEvent) {
|
||||
</script>
|
||||
<template>
|
||||
<Primitive
|
||||
@click.capture="guard"
|
||||
as="button"
|
||||
:as-child="asChild"
|
||||
v-bind="$attrs"
|
||||
@@ -63,7 +65,6 @@ function focus(e: FocusEvent) {
|
||||
:data-focused="focused || undefined"
|
||||
:data-focus-visible="focusVisible || undefined"
|
||||
data-slot="button"
|
||||
@click.capture="guard"
|
||||
@pointerenter="hovered = !pending && !disabled"
|
||||
@pointerleave="
|
||||
hovered = false;
|
||||
|
||||
Reference in New Issue
Block a user