diff --git a/src/comps.ts b/src/comps.ts index ba4fd43..cc15ef9 100644 --- a/src/comps.ts +++ b/src/comps.ts @@ -407,6 +407,53 @@ export default [ composables: [], plugins: [], }, + { + name: "Carousel", + value: "carousel", + files: [ + { + fileName: "Carousel/Carousel.vue", + dirPath: "app/components/Ui", + fileContent: + '\n\n\n', + }, + { + fileName: "Carousel/Content.vue", + dirPath: "app/components/Ui", + fileContent: + '\n\n\n', + }, + { + fileName: "Carousel/Item.vue", + dirPath: "app/components/Ui", + fileContent: + '\n\n\n', + }, + { + fileName: "Carousel/Next.vue", + dirPath: "app/components/Ui", + fileContent: + '\n\n\n', + }, + { + fileName: "Carousel/Previous.vue", + dirPath: "app/components/Ui", + fileContent: + '\n\n\n', + }, + ], + deps: ["embla-carousel-vue", "embla-carousel"], + composables: [ + { + fileName: "useCarousel.ts", + dirPath: "composables", + fileContent: + 'import { createInjectionState } from "@vueuse/core";\nimport emblaCarouselVue from "embla-carousel-vue";\nimport type useEmblaCarousel from "embla-carousel-vue";\nimport type { EmblaCarouselVueType } from "embla-carousel-vue";\nimport type { HTMLAttributes, UnwrapRef } from "vue";\n\ntype CApi = EmblaCarouselVueType[1];\ntype UseCarouselParameters = Parameters;\ntype CarouselOptions = UseCarouselParameters[0];\ntype CarouselPlugin = UseCarouselParameters[1];\n\nexport type CarouselApi = UnwrapRef;\n\nexport interface CarouselProps {\n /**\n * The options to be passed to the EmblaCarousel instance\n */\n opts?: CarouselOptions;\n /**\n * The plugins to be passed to the EmblaCarousel instance\n */\n plugins?: CarouselPlugin;\n /**\n * The orientation of the carousel\n * @default "horizontal"\n */\n orientation?: "horizontal" | "vertical";\n}\n\nexport interface CarouselEmits {\n (e: "init-api", payload: CarouselApi): void;\n}\n\nexport interface WithClassAsProps {\n /**\n * The class name to be applied to the root element of the component\n * @default undefined\n */\n class?: HTMLAttributes["class"];\n}\n\nconst [useProvideCarousel, useInjectCarousel] = createInjectionState(\n ({ opts, orientation, plugins }: CarouselProps, emits: CarouselEmits) => {\n const [emblaNode, emblaApi] = emblaCarouselVue(\n {\n ...opts,\n axis: orientation === "horizontal" ? "x" : "y",\n },\n plugins\n );\n\n /**\n * Scroll to the previous slide\n */\n function scrollPrev() {\n emblaApi.value?.scrollPrev();\n }\n /**\n * Scroll to the next slide\n */\n function scrollNext() {\n emblaApi.value?.scrollNext();\n }\n /**\n * Whether the carousel can scroll to the next slide\n */\n const canScrollNext = ref(false);\n /**\n * Whether the carousel can scroll to the previous slide\n */\n const canScrollPrev = ref(false);\n /**\n * Method used to update the canScrollNext and canScrollPrev values\n */\n function onSelect(api: CarouselApi) {\n canScrollNext.value = api?.canScrollNext() || false;\n canScrollPrev.value = api?.canScrollPrev() || false;\n }\n\n onMounted(() => {\n if (!emblaApi.value) return;\n emblaApi.value?.on("init", onSelect);\n emblaApi.value?.on("reInit", onSelect);\n emblaApi.value?.on("select", onSelect);\n\n emits("init-api", emblaApi.value);\n });\n\n return {\n carouselRef: emblaNode,\n carouselApi: emblaApi,\n canScrollPrev,\n canScrollNext,\n scrollPrev,\n scrollNext,\n orientation,\n };\n }\n);\n\n/**\n * A composable function to be used within a component\n */\nfunction useCarousel() {\n const carouselState = useInjectCarousel();\n if (!carouselState) throw new Error("useCarousel must be used within a ");\n return carouselState;\n}\n\nexport { useCarousel, useProvideCarousel };\n', + }, + ], + utils: [], + plugins: [], + }, { name: "Chart", value: "chart",