first init
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<script lang="ts" setup>
|
||||
import { type Api } from "@zag-js/popover";
|
||||
import { cn } from "@mykopkb/core/utils/cn";
|
||||
import { inject } from "vue";
|
||||
import { popoverArrow } from "@mykopkb/core/styles/popover.styles";
|
||||
|
||||
const { class: className, ...props } = defineProps<{
|
||||
class?: string;
|
||||
}>();
|
||||
|
||||
const api = inject<Api>("popoverApi");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="cn(popoverArrow, className)" v-bind="{ ...api?.getArrowProps(), ...props, ...$attrs }">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script lang="ts" setup>
|
||||
import { type Api } from "@zag-js/popover";
|
||||
import { cn } from "@mykopkb/core/utils/cn";
|
||||
import { inject } from "vue";
|
||||
import { popoverArrowTip } from "@mykopkb/core/styles/popover.styles";
|
||||
|
||||
const { class: className, ...props } = defineProps<{
|
||||
class?: string;
|
||||
}>();
|
||||
|
||||
const api = inject<Api>("popoverApi");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="cn(popoverArrowTip, className)" v-bind="{ ...api?.getArrowTipProps(), ...props, ...$attrs }">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script lang="ts" setup>
|
||||
import { type Api } from "@zag-js/popover";
|
||||
import { cn } from "@mykopkb/core/utils/cn";
|
||||
import { inject } from "vue";
|
||||
import { Slot } from "@/components/ui/slot";
|
||||
import { popoverContent } from "@mykopkb/core/styles/popover.styles";
|
||||
import { PopoverArrow, PopoverArrowTip } from ".";
|
||||
import { Box } from "@/components/ui/box";
|
||||
|
||||
const {
|
||||
class: className,
|
||||
asChild = false,
|
||||
...props
|
||||
} = defineProps<{
|
||||
class?: string;
|
||||
asChild?: boolean;
|
||||
}>();
|
||||
|
||||
const api = inject<Api>("popoverApi");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Slot :class="cn(popoverContent, className)" v-bind="{ ...api?.getContentProps(), ...props, ...$attrs }">
|
||||
<slot v-if="asChild" />
|
||||
<Box v-else raised="single" :class="cn(popoverContent, className)">
|
||||
<div>
|
||||
<slot />
|
||||
</div>
|
||||
<PopoverArrow>
|
||||
<PopoverArrowTip />
|
||||
</PopoverArrow>
|
||||
</Box>
|
||||
</Slot>
|
||||
</template>
|
||||
@@ -0,0 +1,27 @@
|
||||
<script lang="ts" setup>
|
||||
import { type Api } from "@zag-js/popover";
|
||||
import { cn } from "@mykopkb/core/utils/cn";
|
||||
import { inject } from "vue";
|
||||
import { popoverDescription } from "@mykopkb/core/styles/popover.styles";
|
||||
import { Slot } from "@/components/ui/slot";
|
||||
|
||||
const {
|
||||
class: className,
|
||||
asChild = false,
|
||||
...props
|
||||
} = defineProps<{
|
||||
class?: string;
|
||||
asChild?: boolean;
|
||||
}>();
|
||||
|
||||
const api = inject<Api>("popoverApi");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Slot :class="cn(popoverDescription, className)" v-bind="{ ...api?.getDescriptionProps(), ...props, ...$attrs }">
|
||||
<slot v-if="asChild" />
|
||||
<div v-else>
|
||||
<slot />
|
||||
</div>
|
||||
</Slot>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script lang="ts" setup>
|
||||
import { type Api } from "@zag-js/popover";
|
||||
import { cn } from "@mykopkb/core/utils/cn";
|
||||
import { inject } from "vue";
|
||||
import { Slot } from "@/components/ui/slot";
|
||||
import { popoverIndicator } from "@mykopkb/core/styles/popover.styles";
|
||||
import { ChevronDown } from "@lucide/vue";
|
||||
|
||||
const {
|
||||
class: className,
|
||||
asChild = false,
|
||||
...props
|
||||
} = defineProps<{
|
||||
class?: string;
|
||||
asChild?: boolean;
|
||||
}>();
|
||||
|
||||
const api = inject<Api>("popoverApi");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Slot :class="cn(popoverIndicator, className)" v-bind="{ ...api?.getIndicatorProps(), ...props, ...$attrs }">
|
||||
<slot v-if="$slots.default" />
|
||||
<ChevronDown v-else />
|
||||
</Slot>
|
||||
</template>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script lang="ts" setup>
|
||||
import { type Api } from "@zag-js/popover";
|
||||
import { cn } from "@mykopkb/core/utils/cn";
|
||||
import { inject } from "vue";
|
||||
import { popoverPositioner } from "@mykopkb/core/styles/popover.styles";
|
||||
import { Slot } from "@/components/ui/slot";
|
||||
|
||||
const {
|
||||
class: className,
|
||||
asChild = false,
|
||||
...props
|
||||
} = defineProps<{
|
||||
class?: string;
|
||||
asChild?: boolean;
|
||||
}>();
|
||||
|
||||
const api = inject<Api>("popoverApi");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Slot :class="cn(popoverPositioner, className)" v-bind="{ ...api?.getPositionerProps(), ...props, ...$attrs }">
|
||||
<slot v-if="asChild" />
|
||||
<div v-else>
|
||||
<slot />
|
||||
</div>
|
||||
</Slot>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -0,0 +1,36 @@
|
||||
<script lang="ts" setup>
|
||||
import * as popover from "@zag-js/popover";
|
||||
import type { Props } from "@zag-js/popover";
|
||||
import { Slot } from "@/components/ui/slot";
|
||||
import { cn } from "@mykopkb/core/utils/cn";
|
||||
import { normalizeProps, useMachine } from "@zag-js/vue";
|
||||
import { computed, provide } from "vue";
|
||||
import { popoverRoot } from "@mykopkb/core/styles/popover.styles";
|
||||
|
||||
const {
|
||||
class: className,
|
||||
asChild = false,
|
||||
open = undefined,
|
||||
closeOnInteractOutside = undefined,
|
||||
...props
|
||||
} = defineProps<Partial<Props> & { class?: string; asChild?: boolean }>();
|
||||
|
||||
const service = useMachine(popover.machine, {
|
||||
...props,
|
||||
open,
|
||||
closeOnInteractOutside,
|
||||
id: crypto.randomUUID(),
|
||||
});
|
||||
const api = computed(() => popover.connect(service, normalizeProps));
|
||||
|
||||
provide("popoverApi", api);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Slot :class="cn(popoverRoot, className)" v-bind="{ ...props, ...$attrs }">
|
||||
<slot v-if="asChild" />
|
||||
<div v-else>
|
||||
<slot />
|
||||
</div>
|
||||
</Slot>
|
||||
</template>
|
||||
@@ -0,0 +1,27 @@
|
||||
<script lang="ts" setup>
|
||||
import { type Api } from "@zag-js/popover";
|
||||
import { cn } from "@mykopkb/core/utils/cn";
|
||||
import { inject } from "vue";
|
||||
import { Slot } from "@/components/ui/slot";
|
||||
import { popoverTitle } from "@mykopkb/core/styles/popover.styles";
|
||||
|
||||
const {
|
||||
class: className,
|
||||
asChild = false,
|
||||
...props
|
||||
} = defineProps<{
|
||||
class?: string;
|
||||
asChild?: boolean;
|
||||
}>();
|
||||
|
||||
const api = inject<Api>("popoverApi");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Slot :class="cn(popoverTitle, className)" v-bind="{ ...api?.getTitleProps(), ...props, ...$attrs }">
|
||||
<slot v-if="asChild" />
|
||||
<div v-else>
|
||||
<slot />
|
||||
</div>
|
||||
</Slot>
|
||||
</template>
|
||||
@@ -0,0 +1,30 @@
|
||||
<script lang="ts" setup>
|
||||
import { type Api } from "@zag-js/popover";
|
||||
import { cn } from "@mykopkb/core/utils/cn";
|
||||
import { inject } from "vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Slot } from "@/components/ui/slot";
|
||||
import { popoverTrigger } from "@mykopkb/core/styles/popover.styles";
|
||||
import { PopoverIndicator } from ".";
|
||||
|
||||
const {
|
||||
class: className,
|
||||
asChild = false,
|
||||
...props
|
||||
} = defineProps<{
|
||||
class?: string;
|
||||
asChild?: boolean;
|
||||
}>();
|
||||
|
||||
const api = inject<Api>("popoverApi");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Slot v-bind="{ ...api?.getTriggerProps(), ...props, ...$attrs }">
|
||||
<Button variant="ghost" v-if="!asChild" :class="cn(popoverTrigger, className)">
|
||||
<slot />
|
||||
<PopoverIndicator />
|
||||
</Button>
|
||||
<slot v-else />
|
||||
</Slot>
|
||||
</template>
|
||||
@@ -0,0 +1,9 @@
|
||||
export { default as PopoverArrow } from "./PopoverArrow.vue";
|
||||
export { default as PopoverArrowTip } from "./PopoverArrowTip.vue";
|
||||
export { default as PopoverContent } from "./PopoverContent.vue";
|
||||
export { default as PopoverDescription } from "./PopoverDescription.vue";
|
||||
export { default as PopoverIndicator } from "./PopoverIndicator.vue";
|
||||
export { default as PopoverPositioner } from "./PopoverPositioner.vue";
|
||||
export { default as PopoverRoot } from "./PopoverRoot.vue";
|
||||
export { default as PopoverTitle } from "./PopoverTitle.vue";
|
||||
export { default as PopoverTrigger } from "./PopoverTrigger.vue";
|
||||
Reference in New Issue
Block a user