2025-12-09 22:12:23 +01:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { HTMLAttributes } from "vue";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
import type { InputGroupVariants } from ".";
|
|
|
|
|
import { inputGroupAddonVariants } from ".";
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(
|
|
|
|
|
defineProps<{
|
|
|
|
|
align?: InputGroupVariants["align"];
|
|
|
|
|
class?: HTMLAttributes["class"];
|
|
|
|
|
}>(),
|
|
|
|
|
{
|
|
|
|
|
align: "inline-start",
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
function handleInputGroupAddonClick(e: MouseEvent) {
|
|
|
|
|
const currentTarget = e.currentTarget as HTMLElement | null;
|
|
|
|
|
const target = e.target as HTMLElement | null;
|
|
|
|
|
if (target?.closest("button")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (currentTarget?.parentElement) {
|
|
|
|
|
currentTarget.parentElement?.querySelector("input")?.focus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-12-09 22:32:22 +01:00
|
|
|
<div
|
|
|
|
|
role="group"
|
|
|
|
|
data-slot="input-group-addon"
|
|
|
|
|
:data-align="props.align"
|
|
|
|
|
:class="cn(inputGroupAddonVariants({ align: props.align }), props.class)"
|
|
|
|
|
@click="handleInputGroupAddonClick"
|
|
|
|
|
>
|
|
|
|
|
<slot/>
|
|
|
|
|
</div>
|
2025-12-09 22:12:23 +01:00
|
|
|
</template>
|