forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopilotModalHeaderCloseButton.ts
More file actions
38 lines (35 loc) · 1.16 KB
/
Copy pathCopilotModalHeaderCloseButton.ts
File metadata and controls
38 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { computed, defineComponent, h, useAttrs } from "vue";
import { IconX } from "../icons";
export default defineComponent({
name: "CopilotModalHeaderCloseButton",
inheritAttrs: false,
setup(_, { slots }) {
const attrs = useAttrs();
const ariaLabel = computed(() =>
typeof attrs["aria-label"] === "string" ? attrs["aria-label"] : "Close",
);
return () => {
const {
class: className,
type,
...rest
} = attrs as Record<string, unknown>;
return h(
"button",
{
...rest,
type: typeof type === "string" ? type : "button",
class: [
"cpk:inline-flex cpk:size-8 cpk:items-center cpk:justify-center cpk:rounded-full cpk:text-muted-foreground cpk:transition cpk:cursor-pointer",
"cpk:hover:bg-muted cpk:hover:text-foreground cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-ring",
className,
],
"aria-label": ariaLabel.value,
},
slots.default
? slots.default()
: [h(IconX, { class: "cpk:h-4 cpk:w-4", "aria-hidden": true })],
);
};
},
});