@nuxt/ui 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/.nuxt/ui/accordion.ts +25 -4
  2. package/.nuxt/ui/alert.ts +52 -31
  3. package/.nuxt/ui/avatar-group.ts +24 -3
  4. package/.nuxt/ui/avatar.ts +26 -5
  5. package/.nuxt/ui/badge.ts +56 -35
  6. package/.nuxt/ui/breadcrumb.ts +28 -7
  7. package/.nuxt/ui/button-group.ts +23 -2
  8. package/.nuxt/ui/button.ts +66 -45
  9. package/.nuxt/ui/calendar.ts +39 -18
  10. package/.nuxt/ui/card.ts +28 -7
  11. package/.nuxt/ui/carousel.ts +29 -8
  12. package/.nuxt/ui/checkbox-group.ts +82 -0
  13. package/.nuxt/ui/checkbox.ts +163 -29
  14. package/.nuxt/ui/chip.ts +31 -10
  15. package/.nuxt/ui/collapsible.ts +23 -2
  16. package/.nuxt/ui/color-picker.ts +26 -5
  17. package/.nuxt/ui/command-palette.ts +37 -16
  18. package/.nuxt/ui/container.ts +24 -3
  19. package/.nuxt/ui/context-menu.ts +56 -35
  20. package/.nuxt/ui/drawer.ts +33 -12
  21. package/.nuxt/ui/dropdown-menu.ts +57 -36
  22. package/.nuxt/ui/form-field.ts +29 -8
  23. package/.nuxt/ui/form.ts +23 -2
  24. package/.nuxt/ui/index.ts +1 -0
  25. package/.nuxt/ui/input-menu.ts +65 -44
  26. package/.nuxt/ui/input-number.ts +43 -22
  27. package/.nuxt/ui/input.ts +46 -25
  28. package/.nuxt/ui/kbd.ts +27 -6
  29. package/.nuxt/ui/link.ts +26 -5
  30. package/.nuxt/ui/modal.ts +28 -7
  31. package/.nuxt/ui/navigation-menu.ts +103 -84
  32. package/.nuxt/ui/pagination.ts +23 -2
  33. package/.nuxt/ui/pin-input.ts +43 -22
  34. package/.nuxt/ui/popover.ts +25 -4
  35. package/.nuxt/ui/progress.ts +40 -19
  36. package/.nuxt/ui/radio-group.ts +273 -37
  37. package/.nuxt/ui/select-menu.ts +59 -35
  38. package/.nuxt/ui/select.ts +55 -34
  39. package/.nuxt/ui/separator.ts +31 -10
  40. package/.nuxt/ui/skeleton.ts +24 -3
  41. package/.nuxt/ui/slideover.ts +27 -6
  42. package/.nuxt/ui/slider.ts +39 -18
  43. package/.nuxt/ui/stepper.ts +41 -20
  44. package/.nuxt/ui/switch.ts +44 -23
  45. package/.nuxt/ui/table.ts +38 -17
  46. package/.nuxt/ui/tabs.ts +55 -34
  47. package/.nuxt/ui/textarea.ts +63 -37
  48. package/.nuxt/ui/toast.ts +47 -26
  49. package/.nuxt/ui/toaster.ts +23 -2
  50. package/.nuxt/ui/tooltip.ts +25 -4
  51. package/.nuxt/ui/tree.ts +41 -20
  52. package/.nuxt/ui.css +56 -12
  53. package/README.md +11 -0
  54. package/cli/templates.mjs +18 -17
  55. package/dist/module.d.mts +2 -1
  56. package/dist/module.json +5 -5
  57. package/dist/module.mjs +11 -7
  58. package/dist/runtime/components/Accordion.vue +36 -92
  59. package/dist/runtime/components/Accordion.vue.d.ts +91 -0
  60. package/dist/runtime/components/Alert.vue +37 -100
  61. package/dist/runtime/components/Alert.vue.d.ts +96 -0
  62. package/dist/runtime/components/App.vue +28 -34
  63. package/dist/runtime/components/App.vue.d.ts +24 -0
  64. package/dist/runtime/components/Avatar.vue +47 -78
  65. package/dist/runtime/components/Avatar.vue.d.ts +60 -0
  66. package/dist/runtime/components/AvatarGroup.vue +40 -77
  67. package/dist/runtime/components/AvatarGroup.vue.d.ts +40 -0
  68. package/dist/runtime/components/Badge.vue +33 -62
  69. package/dist/runtime/components/Badge.vue.d.ts +62 -0
  70. package/dist/runtime/components/Breadcrumb.vue +36 -88
  71. package/dist/runtime/components/Breadcrumb.vue.d.ts +82 -0
  72. package/dist/runtime/components/Button.vue +96 -105
  73. package/dist/runtime/components/Button.vue.d.ts +73 -0
  74. package/dist/runtime/components/ButtonGroup.vue +20 -46
  75. package/dist/runtime/components/ButtonGroup.vue.d.ts +55 -0
  76. package/dist/runtime/components/Calendar.vue +73 -127
  77. package/dist/runtime/components/Calendar.vue.d.ts +107 -0
  78. package/dist/runtime/components/Card.vue +18 -40
  79. package/dist/runtime/components/Card.vue.d.ts +38 -0
  80. package/dist/runtime/components/Carousel.vue +112 -230
  81. package/dist/runtime/components/Carousel.vue.d.ts +120 -0
  82. package/dist/runtime/components/Checkbox.vue +52 -93
  83. package/dist/runtime/components/Checkbox.vue.d.ts +76 -0
  84. package/dist/runtime/components/CheckboxGroup.vue +121 -0
  85. package/dist/runtime/components/CheckboxGroup.vue.d.ts +75 -0
  86. package/dist/runtime/components/Chip.vue +26 -69
  87. package/dist/runtime/components/Chip.vue.d.ts +71 -0
  88. package/dist/runtime/components/Collapsible.vue +22 -41
  89. package/dist/runtime/components/Collapsible.vue.d.ts +50 -0
  90. package/dist/runtime/components/ColorPicker.vue +111 -197
  91. package/dist/runtime/components/ColorPicker.vue.d.ts +63 -0
  92. package/dist/runtime/components/CommandPalette.vue +94 -234
  93. package/dist/runtime/components/CommandPalette.vue.d.ts +173 -0
  94. package/dist/runtime/components/Container.vue +15 -28
  95. package/dist/runtime/components/Container.vue.d.ts +27 -0
  96. package/dist/runtime/components/ContextMenu.vue +32 -119
  97. package/dist/runtime/components/ContextMenu.vue.d.ts +127 -0
  98. package/dist/runtime/components/ContextMenuContent.vue +71 -72
  99. package/dist/runtime/components/ContextMenuContent.vue.d.ts +105 -0
  100. package/dist/runtime/components/Drawer.vue +49 -87
  101. package/dist/runtime/components/Drawer.vue.d.ts +88 -0
  102. package/dist/runtime/components/DropdownMenu.vue +37 -129
  103. package/dist/runtime/components/DropdownMenu.vue.d.ts +141 -0
  104. package/dist/runtime/components/DropdownMenuContent.vue +76 -79
  105. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +55 -0
  106. package/dist/runtime/components/Form.vue +135 -219
  107. package/dist/runtime/components/Form.vue.d.ts +66 -0
  108. package/dist/runtime/components/FormField.vue +36 -77
  109. package/dist/runtime/components/FormField.vue.d.ts +70 -0
  110. package/dist/runtime/components/Icon.vue +12 -19
  111. package/dist/runtime/components/Icon.vue.d.ts +17 -0
  112. package/dist/runtime/components/Input.vue +82 -140
  113. package/dist/runtime/components/Input.vue.d.ts +91 -0
  114. package/dist/runtime/components/InputMenu.vue +193 -302
  115. package/dist/runtime/components/InputMenu.vue.d.ts +312 -0
  116. package/dist/runtime/components/InputNumber.vue +71 -133
  117. package/dist/runtime/components/InputNumber.vue.d.ts +193 -0
  118. package/dist/runtime/components/Kbd.vue +20 -46
  119. package/dist/runtime/components/Kbd.vue.d.ts +55 -0
  120. package/dist/runtime/components/Link.vue +98 -173
  121. package/dist/runtime/components/Link.vue.d.ts +124 -0
  122. package/dist/runtime/components/LinkBase.vue +33 -41
  123. package/dist/runtime/components/LinkBase.vue.d.ts +48 -0
  124. package/dist/runtime/components/Modal.vue +53 -116
  125. package/dist/runtime/components/Modal.vue.d.ts +109 -0
  126. package/dist/runtime/components/NavigationMenu.vue +78 -186
  127. package/dist/runtime/components/NavigationMenu.vue.d.ts +159 -0
  128. package/dist/runtime/components/OverlayProvider.vue +14 -18
  129. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  130. package/dist/runtime/components/Pagination.vue +46 -140
  131. package/dist/runtime/components/Pagination.vue.d.ts +143 -0
  132. package/dist/runtime/components/PinInput.vue +61 -78
  133. package/dist/runtime/components/PinInput.vue.d.ts +68 -0
  134. package/dist/runtime/components/Popover.vue +47 -84
  135. package/dist/runtime/components/Popover.vue.d.ts +80 -0
  136. package/dist/runtime/components/Progress.vue +70 -131
  137. package/dist/runtime/components/Progress.vue.d.ts +97 -0
  138. package/dist/runtime/components/RadioGroup.vue +75 -126
  139. package/dist/runtime/components/RadioGroup.vue.d.ts +88 -0
  140. package/dist/runtime/components/Select.vue +115 -202
  141. package/dist/runtime/components/Select.vue.d.ts +139 -0
  142. package/dist/runtime/components/SelectMenu.vue +167 -281
  143. package/dist/runtime/components/SelectMenu.vue.d.ts +184 -0
  144. package/dist/runtime/components/Separator.vue +29 -71
  145. package/dist/runtime/components/Separator.vue.d.ts +75 -0
  146. package/dist/runtime/components/Skeleton.vue +21 -23
  147. package/dist/runtime/components/Skeleton.vue.d.ts +26 -0
  148. package/dist/runtime/components/Slideover.vue +53 -120
  149. package/dist/runtime/components/Slideover.vue.d.ts +111 -0
  150. package/dist/runtime/components/Slider.vue +46 -84
  151. package/dist/runtime/components/Slider.vue.d.ts +71 -0
  152. package/dist/runtime/components/Stepper.vue +44 -113
  153. package/dist/runtime/components/Stepper.vue.d.ts +89 -0
  154. package/dist/runtime/components/Switch.vue +45 -93
  155. package/dist/runtime/components/Switch.vue.d.ts +73 -0
  156. package/dist/runtime/components/Table.vue +165 -264
  157. package/dist/runtime/components/Table.vue.d.ts +183 -0
  158. package/dist/runtime/components/Tabs.vue +40 -105
  159. package/dist/runtime/components/Tabs.vue.d.ts +104 -0
  160. package/dist/runtime/components/Textarea.vue +113 -158
  161. package/dist/runtime/components/Textarea.vue.d.ts +95 -0
  162. package/dist/runtime/components/Toast.vue +49 -110
  163. package/dist/runtime/components/Toast.vue.d.ts +95 -0
  164. package/dist/runtime/components/Toaster.vue +70 -107
  165. package/dist/runtime/components/Toaster.vue.d.ts +63 -0
  166. package/dist/runtime/components/Tooltip.vue +38 -65
  167. package/dist/runtime/components/Tooltip.vue.d.ts +65 -0
  168. package/dist/runtime/components/Tree.vue +57 -150
  169. package/dist/runtime/components/Tree.vue.d.ts +128 -0
  170. package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
  171. package/dist/runtime/composables/defineShortcuts.js +0 -1
  172. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  173. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  174. package/dist/runtime/composables/useFormField.d.ts +2 -2
  175. package/dist/runtime/composables/useFormField.js +1 -1
  176. package/dist/runtime/composables/useOverlay.d.ts +16 -8
  177. package/dist/runtime/composables/useOverlay.js +14 -6
  178. package/dist/runtime/composables/usePortal.d.ts +6 -0
  179. package/dist/runtime/composables/usePortal.js +17 -0
  180. package/dist/runtime/index.css +1 -1
  181. package/dist/runtime/inertia/components/Link.vue +146 -0
  182. package/dist/runtime/inertia/components/Link.vue.d.ts +92 -0
  183. package/dist/runtime/inertia/stubs.d.ts +43 -0
  184. package/dist/runtime/inertia/stubs.js +82 -0
  185. package/dist/runtime/locale/bg.d.ts +3 -0
  186. package/dist/runtime/locale/bg.js +54 -0
  187. package/dist/runtime/locale/hy.d.ts +3 -0
  188. package/dist/runtime/locale/hy.js +54 -0
  189. package/dist/runtime/locale/index.d.ts +6 -1
  190. package/dist/runtime/locale/index.js +6 -1
  191. package/dist/runtime/locale/kk.d.ts +3 -0
  192. package/dist/runtime/locale/kk.js +54 -0
  193. package/dist/runtime/locale/tj.d.ts +3 -0
  194. package/dist/runtime/locale/tj.js +54 -0
  195. package/dist/runtime/locale/ug_cn.d.ts +3 -0
  196. package/dist/runtime/locale/ug_cn.js +55 -0
  197. package/dist/runtime/types/form.d.ts +5 -1
  198. package/dist/runtime/types/index.d.ts +2 -0
  199. package/dist/runtime/types/index.js +2 -0
  200. package/dist/runtime/types/utils.d.ts +70 -10
  201. package/dist/runtime/utils/index.d.ts +1 -0
  202. package/dist/runtime/utils/index.js +3 -0
  203. package/dist/runtime/utils/link.d.ts +4 -27
  204. package/dist/runtime/utils/link.js +32 -1
  205. package/dist/runtime/utils/tv.js +2 -2
  206. package/dist/runtime/vue/components/Icon.vue +7 -8
  207. package/dist/runtime/vue/components/Icon.vue.d.ts +14 -0
  208. package/dist/runtime/vue/components/Link.vue +118 -199
  209. package/dist/runtime/vue/components/Link.vue.d.ts +124 -0
  210. package/dist/runtime/vue/stubs.d.ts +5 -0
  211. package/dist/runtime/vue/stubs.js +11 -2
  212. package/dist/shared/{ui.BCaWD5Ek.mjs → ui.D7lOOabO.mjs} +623 -364
  213. package/dist/types.d.mts +5 -1
  214. package/dist/unplugin.d.mts +6 -1
  215. package/dist/unplugin.mjs +25 -4
  216. package/dist/vite.mjs +1 -1
  217. package/package.json +122 -64
  218. package/dist/module.cjs +0 -62
  219. package/dist/module.d.cts +0 -44
  220. package/dist/module.d.ts +0 -44
  221. package/dist/shared/ui.C6uTSFTI.cjs +0 -3555
  222. package/dist/types.d.ts +0 -1
  223. package/dist/unplugin.cjs +0 -232
  224. package/dist/unplugin.d.cts +0 -61
  225. package/dist/unplugin.d.ts +0 -61
  226. package/dist/vite.cjs +0 -23
  227. package/dist/vite.d.cts +0 -15
  228. package/dist/vite.d.ts +0 -15
@@ -1,266 +1,148 @@
1
- <script lang="ts">
2
- import type { VariantProps } from 'tailwind-variants'
3
- import type { AppConfig } from '@nuxt/schema'
4
- import type { AcceptableValue } from 'reka-ui'
5
- import type { EmblaCarouselType, EmblaOptionsType, EmblaPluginType } from 'embla-carousel'
6
- import type { AutoplayOptionsType } from 'embla-carousel-autoplay'
7
- import type { AutoScrollOptionsType } from 'embla-carousel-auto-scroll'
8
- import type { AutoHeightOptionsType } from 'embla-carousel-auto-height'
9
- import type { ClassNamesOptionsType } from 'embla-carousel-class-names'
10
- import type { FadeOptionsType } from 'embla-carousel-fade'
11
- import type { WheelGesturesPluginOptions } from 'embla-carousel-wheel-gestures'
12
- import _appConfig from '#build/app.config'
13
- import theme from '#build/ui/carousel'
14
- import { tv } from '../utils/tv'
15
- import type { ButtonProps } from '../types'
16
- import type { PartialString } from '../types/utils'
17
-
18
- const appConfigCarousel = _appConfig as AppConfig & { ui: { carousel: Partial<typeof theme> } }
19
-
20
- const carousel = tv({ extend: tv(theme), ...(appConfigCarousel.ui?.carousel || {}) })
21
-
22
- type CarouselVariants = VariantProps<typeof carousel>
23
-
24
- export interface CarouselProps<T> extends Omit<EmblaOptionsType, 'axis' | 'container' | 'slides' | 'direction'> {
25
- /**
26
- * The element or component this component should render as.
27
- * @defaultValue 'div'
28
- */
29
- as?: any
30
- /**
31
- * Configure the prev button when arrows are enabled.
32
- * @defaultValue { size: 'md', color: 'neutral', variant: 'link' }
33
- */
34
- prev?: ButtonProps
35
- /**
36
- * The icon displayed in the prev button.
37
- * @defaultValue appConfig.ui.icons.arrowLeft
38
- * @IconifyIcon
39
- */
40
- prevIcon?: string
41
- /**
42
- * Configure the next button when arrows are enabled.
43
- * @defaultValue { size: 'md', color: 'neutral', variant: 'link' }
44
- */
45
- next?: ButtonProps
46
- /**
47
- * The icon displayed in the next button.
48
- * @defaultValue appConfig.ui.icons.arrowRight
49
- * @IconifyIcon
50
- */
51
- nextIcon?: string
52
- /**
53
- * Display prev and next buttons to scroll the carousel.
54
- * @defaultValue false
55
- */
56
- arrows?: boolean
57
- /**
58
- * Display dots to scroll to a specific slide.
59
- * @defaultValue false
60
- */
61
- dots?: boolean
62
- /**
63
- * The orientation of the carousel.
64
- * @defaultValue 'horizontal'
65
- */
66
- orientation?: CarouselVariants['orientation']
67
- items?: T[]
68
- /**
69
- * Enable Autoplay plugin
70
- * @link https://www.embla-carousel.com/plugins/autoplay/
71
- */
72
- autoplay?: boolean | AutoplayOptionsType
73
- /**
74
- * Enable Auto Scroll plugin
75
- * @link https://www.embla-carousel.com/plugins/auto-scroll/
76
- */
77
- autoScroll?: boolean | AutoScrollOptionsType
78
- /**
79
- * Enable Auto Height plugin
80
- * @link https://www.embla-carousel.com/plugins/auto-height/
81
- */
82
- autoHeight?: boolean | AutoHeightOptionsType
83
- /**
84
- * Enable Class Names plugin
85
- * @link https://www.embla-carousel.com/plugins/class-names/
86
- */
87
- classNames?: boolean | ClassNamesOptionsType
88
- /**
89
- * Enable Fade plugin
90
- * @link https://www.embla-carousel.com/plugins/fade/
91
- */
92
- fade?: boolean | FadeOptionsType
93
- /**
94
- * Enable Wheel Gestures plugin
95
- * @link https://www.embla-carousel.com/plugins/wheel-gestures/
96
- */
97
- wheelGestures?: boolean | WheelGesturesPluginOptions
98
- class?: any
99
- ui?: PartialString<typeof carousel.slots>
100
- }
101
-
102
- export type CarouselSlots<T> = {
103
- default(props: { item: T, index: number }): any
104
- }
1
+ <script>
2
+ import theme from "#build/ui/carousel";
105
3
  </script>
106
4
 
107
- <script setup lang="ts" generic="T extends AcceptableValue">
108
- import { computed, ref, watch, onMounted } from 'vue'
109
- import useEmblaCarousel from 'embla-carousel-vue'
110
- import { Primitive, useForwardProps } from 'reka-ui'
111
- import { reactivePick, computedAsync } from '@vueuse/core'
112
- import { useAppConfig } from '#imports'
113
- import { useLocale } from '../composables/useLocale'
114
- import UButton from './Button.vue'
115
-
116
- const props = withDefaults(defineProps<CarouselProps<T>>(), {
117
- orientation: 'horizontal',
118
- arrows: false,
119
- dots: false,
120
- // Embla Options
121
- active: true,
122
- align: 'center',
123
- breakpoints: () => ({}),
124
- containScroll: 'trimSnaps',
125
- dragFree: false,
126
- dragThreshold: 10,
127
- duration: 25,
128
- inViewThreshold: 0,
129
- loop: false,
130
- skipSnaps: false,
131
- slidesToScroll: 1,
132
- startIndex: 0,
133
- watchDrag: true,
134
- watchResize: true,
135
- watchSlides: true,
136
- watchFocus: true,
137
- // Embla Plugins
138
- autoplay: false,
139
- autoScroll: false,
140
- autoHeight: false,
141
- classNames: false,
142
- fade: false,
143
- wheelGestures: false
144
- })
145
- defineSlots<CarouselSlots<T>>()
146
-
147
- const appConfig = useAppConfig()
148
- const { dir, t } = useLocale()
149
- const rootProps = useForwardProps(reactivePick(props, 'active', 'align', 'breakpoints', 'containScroll', 'dragFree', 'dragThreshold', 'duration', 'inViewThreshold', 'loop', 'skipSnaps', 'slidesToScroll', 'startIndex', 'watchDrag', 'watchResize', 'watchSlides', 'watchFocus'))
150
-
151
- const prevIcon = computed(() => props.prevIcon || (dir.value === 'rtl' ? appConfig.ui.icons.arrowRight : appConfig.ui.icons.arrowLeft))
152
- const nextIcon = computed(() => props.nextIcon || (dir.value === 'rtl' ? appConfig.ui.icons.arrowLeft : appConfig.ui.icons.arrowRight))
153
-
154
- const ui = computed(() => carousel({
5
+ <script setup>
6
+ import { computed, ref, watch, onMounted } from "vue";
7
+ import useEmblaCarousel from "embla-carousel-vue";
8
+ import { Primitive, useForwardProps } from "reka-ui";
9
+ import { reactivePick, computedAsync } from "@vueuse/core";
10
+ import { useAppConfig } from "#imports";
11
+ import { useLocale } from "../composables/useLocale";
12
+ import { tv } from "../utils/tv";
13
+ import UButton from "./Button.vue";
14
+ const props = defineProps({
15
+ as: { type: null, required: false },
16
+ prev: { type: Object, required: false },
17
+ prevIcon: { type: String, required: false },
18
+ next: { type: Object, required: false },
19
+ nextIcon: { type: String, required: false },
20
+ arrows: { type: Boolean, required: false, default: false },
21
+ dots: { type: Boolean, required: false, default: false },
22
+ orientation: { type: null, required: false, default: "horizontal" },
23
+ items: { type: Array, required: false },
24
+ autoplay: { type: [Boolean, Object], required: false, default: false },
25
+ autoScroll: { type: [Boolean, Object], required: false, default: false },
26
+ autoHeight: { type: [Boolean, Object], required: false, default: false },
27
+ classNames: { type: [Boolean, Object], required: false, default: false },
28
+ fade: { type: [Boolean, Object], required: false, default: false },
29
+ wheelGestures: { type: Boolean, required: false, skipCheck: true, default: false },
30
+ class: { type: null, required: false },
31
+ ui: { type: null, required: false },
32
+ align: { type: [String, Function], required: false, default: "center" },
33
+ containScroll: { type: [Boolean, String], required: false, default: "trimSnaps" },
34
+ slidesToScroll: { type: [String, Number], required: false, default: 1 },
35
+ dragFree: { type: Boolean, required: false, default: false },
36
+ dragThreshold: { type: Number, required: false, default: 10 },
37
+ inViewThreshold: { type: null, required: false, default: 0 },
38
+ loop: { type: Boolean, required: false, default: false },
39
+ skipSnaps: { type: Boolean, required: false, default: false },
40
+ duration: { type: Number, required: false, default: 25 },
41
+ startIndex: { type: Number, required: false, default: 0 },
42
+ watchDrag: { type: [Boolean, Function], required: false, default: true },
43
+ watchResize: { type: [Boolean, Function], required: false, default: true },
44
+ watchSlides: { type: [Boolean, Function], required: false, default: true },
45
+ watchFocus: { type: [Boolean, Function], required: false, default: true },
46
+ active: { type: Boolean, required: false, default: true },
47
+ breakpoints: { type: Object, required: false, default: () => ({}) }
48
+ });
49
+ defineSlots();
50
+ const emits = defineEmits(["select"]);
51
+ const { dir, t } = useLocale();
52
+ const appConfig = useAppConfig();
53
+ const rootProps = useForwardProps(reactivePick(props, "active", "align", "breakpoints", "containScroll", "dragFree", "dragThreshold", "duration", "inViewThreshold", "loop", "skipSnaps", "slidesToScroll", "startIndex", "watchDrag", "watchResize", "watchSlides", "watchFocus"));
54
+ const prevIcon = computed(() => props.prevIcon || (dir.value === "rtl" ? appConfig.ui.icons.arrowRight : appConfig.ui.icons.arrowLeft));
55
+ const nextIcon = computed(() => props.nextIcon || (dir.value === "rtl" ? appConfig.ui.icons.arrowLeft : appConfig.ui.icons.arrowRight));
56
+ const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.carousel || {} })({
155
57
  orientation: props.orientation
156
- }))
157
-
158
- const options = computed<EmblaOptionsType>(() => ({
159
- ...(props.fade ? { align: 'center', containScroll: false } : {}),
58
+ }));
59
+ const options = computed(() => ({
60
+ ...props.fade ? { align: "center", containScroll: false } : {},
160
61
  ...rootProps.value,
161
- axis: props.orientation === 'horizontal' ? 'x' : 'y',
162
- direction: dir.value === 'rtl' ? 'rtl' : 'ltr'
163
- }))
164
-
165
- const plugins = computedAsync<EmblaPluginType[]>(async () => {
166
- const plugins = []
167
-
62
+ axis: props.orientation === "horizontal" ? "x" : "y",
63
+ direction: dir.value === "rtl" ? "rtl" : "ltr"
64
+ }));
65
+ const plugins = computedAsync(async () => {
66
+ const plugins2 = [];
168
67
  if (props.autoplay) {
169
- const AutoplayPlugin = await import('embla-carousel-autoplay').then(r => r.default)
170
- plugins.push(AutoplayPlugin(typeof props.autoplay === 'boolean' ? {} : props.autoplay))
68
+ const AutoplayPlugin = await import("embla-carousel-autoplay").then((r) => r.default);
69
+ plugins2.push(AutoplayPlugin(typeof props.autoplay === "boolean" ? {} : props.autoplay));
171
70
  }
172
-
173
71
  if (props.autoScroll) {
174
- const AutoScrollPlugin = await import('embla-carousel-auto-scroll').then(r => r.default)
175
- plugins.push(AutoScrollPlugin(typeof props.autoScroll === 'boolean' ? {} : props.autoScroll))
72
+ const AutoScrollPlugin = await import("embla-carousel-auto-scroll").then((r) => r.default);
73
+ plugins2.push(AutoScrollPlugin(typeof props.autoScroll === "boolean" ? {} : props.autoScroll));
176
74
  }
177
-
178
75
  if (props.autoHeight) {
179
- const AutoHeightPlugin = await import('embla-carousel-auto-height').then(r => r.default)
180
- plugins.push(AutoHeightPlugin(typeof props.autoHeight === 'boolean' ? {} : props.autoHeight))
76
+ const AutoHeightPlugin = await import("embla-carousel-auto-height").then((r) => r.default);
77
+ plugins2.push(AutoHeightPlugin(typeof props.autoHeight === "boolean" ? {} : props.autoHeight));
181
78
  }
182
-
183
79
  if (props.classNames) {
184
- const ClassNamesPlugin = await import('embla-carousel-class-names').then(r => r.default)
185
- plugins.push(ClassNamesPlugin(typeof props.classNames === 'boolean' ? {} : props.classNames))
80
+ const ClassNamesPlugin = await import("embla-carousel-class-names").then((r) => r.default);
81
+ plugins2.push(ClassNamesPlugin(typeof props.classNames === "boolean" ? {} : props.classNames));
186
82
  }
187
-
188
83
  if (props.fade) {
189
- const FadePlugin = await import('embla-carousel-fade').then(r => r.default)
190
- plugins.push(FadePlugin(typeof props.fade === 'boolean' ? {} : props.fade))
84
+ const FadePlugin = await import("embla-carousel-fade").then((r) => r.default);
85
+ plugins2.push(FadePlugin(typeof props.fade === "boolean" ? {} : props.fade));
191
86
  }
192
-
193
87
  if (props.wheelGestures) {
194
- const { WheelGesturesPlugin } = await import('embla-carousel-wheel-gestures')
195
- plugins.push(WheelGesturesPlugin(typeof props.wheelGestures === 'boolean' ? {} : props.wheelGestures))
88
+ const { WheelGesturesPlugin } = await import("embla-carousel-wheel-gestures");
89
+ plugins2.push(WheelGesturesPlugin(typeof props.wheelGestures === "boolean" ? {} : props.wheelGestures));
196
90
  }
197
-
198
- return plugins
199
- })
200
-
201
- const [emblaRef, emblaApi] = useEmblaCarousel(options.value, plugins.value)
202
-
91
+ return plugins2;
92
+ });
93
+ const [emblaRef, emblaApi] = useEmblaCarousel(options.value, plugins.value);
203
94
  watch([options, plugins], () => {
204
- emblaApi.value?.reInit(options.value, plugins.value)
205
- })
206
-
95
+ emblaApi.value?.reInit(options.value, plugins.value);
96
+ });
207
97
  function scrollPrev() {
208
- emblaApi.value?.scrollPrev()
98
+ emblaApi.value?.scrollPrev();
209
99
  }
210
100
  function scrollNext() {
211
- emblaApi.value?.scrollNext()
101
+ emblaApi.value?.scrollNext();
212
102
  }
213
- function scrollTo(index: number) {
214
- emblaApi.value?.scrollTo(index)
103
+ function scrollTo(index) {
104
+ emblaApi.value?.scrollTo(index);
215
105
  }
216
-
217
- function onKeyDown(event: KeyboardEvent) {
218
- const prevKey = props.orientation === 'vertical' ? 'ArrowUp' : 'ArrowLeft'
219
- const nextKey = props.orientation === 'vertical' ? 'ArrowDown' : 'ArrowRight'
220
-
106
+ function onKeyDown(event) {
107
+ const prevKey = props.orientation === "vertical" ? "ArrowUp" : "ArrowLeft";
108
+ const nextKey = props.orientation === "vertical" ? "ArrowDown" : "ArrowRight";
221
109
  if (event.key === prevKey) {
222
- event.preventDefault()
223
- scrollPrev()
224
-
225
- return
110
+ event.preventDefault();
111
+ scrollPrev();
112
+ return;
226
113
  }
227
-
228
114
  if (event.key === nextKey) {
229
- event.preventDefault()
230
- scrollNext()
115
+ event.preventDefault();
116
+ scrollNext();
231
117
  }
232
118
  }
233
-
234
- const canScrollNext = ref(false)
235
- const canScrollPrev = ref(false)
236
- const selectedIndex = ref<number>(0)
237
- const scrollSnaps = ref<number[]>([])
238
-
239
- function onInit(api: EmblaCarouselType) {
240
- scrollSnaps.value = api?.scrollSnapList() || []
119
+ const canScrollNext = ref(false);
120
+ const canScrollPrev = ref(false);
121
+ const selectedIndex = ref(0);
122
+ const scrollSnaps = ref([]);
123
+ function onInit(api) {
124
+ scrollSnaps.value = api?.scrollSnapList() || [];
241
125
  }
242
- function onSelect(api: EmblaCarouselType) {
243
- canScrollNext.value = api?.canScrollNext() || false
244
- canScrollPrev.value = api?.canScrollPrev() || false
245
- selectedIndex.value = api?.selectedScrollSnap() || 0
126
+ function onSelect(api) {
127
+ canScrollNext.value = api?.canScrollNext() || false;
128
+ canScrollPrev.value = api?.canScrollPrev() || false;
129
+ selectedIndex.value = api?.selectedScrollSnap() || 0;
130
+ emits("select", selectedIndex.value);
246
131
  }
247
-
248
132
  onMounted(() => {
249
133
  if (!emblaApi.value) {
250
- return
134
+ return;
251
135
  }
252
-
253
- emblaApi.value?.on('init', onInit)
254
- emblaApi.value?.on('init', onSelect)
255
- emblaApi.value?.on('reInit', onInit)
256
- emblaApi.value?.on('reInit', onSelect)
257
- emblaApi.value?.on('select', onSelect)
258
- })
259
-
136
+ emblaApi.value?.on("init", onInit);
137
+ emblaApi.value?.on("init", onSelect);
138
+ emblaApi.value?.on("reInit", onInit);
139
+ emblaApi.value?.on("reInit", onSelect);
140
+ emblaApi.value?.on("select", onSelect);
141
+ });
260
142
  defineExpose({
261
143
  emblaRef,
262
144
  emblaApi
263
- })
145
+ });
264
146
  </script>
265
147
 
266
148
  <template>
@@ -295,7 +177,7 @@ defineExpose({
295
177
  color="neutral"
296
178
  variant="outline"
297
179
  :aria-label="t('carousel.prev')"
298
- v-bind="typeof prev === 'object' ? prev : undefined"
180
+ v-bind="typeof prev === 'object' ? prev : void 0"
299
181
  :class="ui.prev({ class: props.ui?.prev })"
300
182
  @click="scrollPrev"
301
183
  />
@@ -306,7 +188,7 @@ defineExpose({
306
188
  color="neutral"
307
189
  variant="outline"
308
190
  :aria-label="t('carousel.next')"
309
- v-bind="typeof next === 'object' ? next : undefined"
191
+ v-bind="typeof next === 'object' ? next : void 0"
310
192
  :class="ui.next({ class: props.ui?.next })"
311
193
  @click="scrollNext"
312
194
  />
@@ -0,0 +1,120 @@
1
+ import type { AppConfig } from '@nuxt/schema';
2
+ import type { AcceptableValue } from 'reka-ui';
3
+ import type { EmblaCarouselType, EmblaOptionsType } from 'embla-carousel';
4
+ import type { AutoplayOptionsType } from 'embla-carousel-autoplay';
5
+ import type { AutoScrollOptionsType } from 'embla-carousel-auto-scroll';
6
+ import type { AutoHeightOptionsType } from 'embla-carousel-auto-height';
7
+ import type { ClassNamesOptionsType } from 'embla-carousel-class-names';
8
+ import type { FadeOptionsType } from 'embla-carousel-fade';
9
+ import type { WheelGesturesPluginOptions } from 'embla-carousel-wheel-gestures';
10
+ import theme from '#build/ui/carousel';
11
+ import type { ButtonProps } from '../types';
12
+ import type { ComponentConfig } from '../types/utils';
13
+ type Carousel = ComponentConfig<typeof theme, AppConfig, 'carousel'>;
14
+ export type CarouselItem = AcceptableValue;
15
+ export interface CarouselProps<T extends CarouselItem = CarouselItem> extends Omit<EmblaOptionsType, 'axis' | 'container' | 'slides' | 'direction'> {
16
+ /**
17
+ * The element or component this component should render as.
18
+ * @defaultValue 'div'
19
+ */
20
+ as?: any;
21
+ /**
22
+ * Configure the prev button when arrows are enabled.
23
+ * @defaultValue { size: 'md', color: 'neutral', variant: 'link' }
24
+ */
25
+ prev?: ButtonProps;
26
+ /**
27
+ * The icon displayed in the prev button.
28
+ * @defaultValue appConfig.ui.icons.arrowLeft
29
+ * @IconifyIcon
30
+ */
31
+ prevIcon?: string;
32
+ /**
33
+ * Configure the next button when arrows are enabled.
34
+ * @defaultValue { size: 'md', color: 'neutral', variant: 'link' }
35
+ */
36
+ next?: ButtonProps;
37
+ /**
38
+ * The icon displayed in the next button.
39
+ * @defaultValue appConfig.ui.icons.arrowRight
40
+ * @IconifyIcon
41
+ */
42
+ nextIcon?: string;
43
+ /**
44
+ * Display prev and next buttons to scroll the carousel.
45
+ * @defaultValue false
46
+ */
47
+ arrows?: boolean;
48
+ /**
49
+ * Display dots to scroll to a specific slide.
50
+ * @defaultValue false
51
+ */
52
+ dots?: boolean;
53
+ /**
54
+ * The orientation of the carousel.
55
+ * @defaultValue 'horizontal'
56
+ */
57
+ orientation?: Carousel['variants']['orientation'];
58
+ items?: T[];
59
+ /**
60
+ * Enable Autoplay plugin
61
+ * @link https://www.embla-carousel.com/plugins/autoplay/
62
+ */
63
+ autoplay?: boolean | AutoplayOptionsType;
64
+ /**
65
+ * Enable Auto Scroll plugin
66
+ * @link https://www.embla-carousel.com/plugins/auto-scroll/
67
+ */
68
+ autoScroll?: boolean | AutoScrollOptionsType;
69
+ /**
70
+ * Enable Auto Height plugin
71
+ * @link https://www.embla-carousel.com/plugins/auto-height/
72
+ */
73
+ autoHeight?: boolean | AutoHeightOptionsType;
74
+ /**
75
+ * Enable Class Names plugin
76
+ * @link https://www.embla-carousel.com/plugins/class-names/
77
+ */
78
+ classNames?: boolean | ClassNamesOptionsType;
79
+ /**
80
+ * Enable Fade plugin
81
+ * @link https://www.embla-carousel.com/plugins/fade/
82
+ */
83
+ fade?: boolean | FadeOptionsType;
84
+ /**
85
+ * Enable Wheel Gestures plugin
86
+ * @link https://www.embla-carousel.com/plugins/wheel-gestures/
87
+ */
88
+ wheelGestures?: boolean | WheelGesturesPluginOptions;
89
+ class?: any;
90
+ ui?: Carousel['slots'];
91
+ }
92
+ export type CarouselSlots<T extends CarouselItem = CarouselItem> = {
93
+ default(props: {
94
+ item: T;
95
+ index: number;
96
+ }): any;
97
+ };
98
+ export interface CarouselEmits {
99
+ /**
100
+ * Emitted when the selected slide changes
101
+ * @param selectedIndex The index of the selected slide
102
+ */
103
+ select: [selectedIndex: number];
104
+ }
105
+ declare const _default: <T extends CarouselItem>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
106
+ props: __VLS_PrettifyLocal<any & CarouselProps<T> & Partial<{}>> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
107
+ expose(exposed: import("vue").ShallowUnwrapRef<{
108
+ emblaRef: import("vue").Ref<HTMLElement | undefined, HTMLElement | undefined>;
109
+ emblaApi: import("vue").Ref<EmblaCarouselType | undefined, EmblaCarouselType | undefined>;
110
+ }>): void;
111
+ attrs: any;
112
+ slots: Readonly<CarouselSlots<T>> & CarouselSlots<T>;
113
+ emit: (evt: "select", selectedIndex: number) => void;
114
+ }>) => import("vue").VNode & {
115
+ __ctx?: Awaited<typeof __VLS_setup>;
116
+ };
117
+ export default _default;
118
+ type __VLS_PrettifyLocal<T> = {
119
+ [K in keyof T]: T[K];
120
+ } & {};