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