@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.
- 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 +24 -3
- 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 +103 -84
- 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 +44 -23
- 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.d.mts +2 -1
- package/dist/module.json +5 -5
- package/dist/module.mjs +11 -7
- package/dist/runtime/components/Accordion.vue +36 -92
- 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 +47 -78
- 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 +36 -88
- package/dist/runtime/components/Breadcrumb.vue.d.ts +82 -0
- package/dist/runtime/components/Button.vue +96 -105
- 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 +73 -127
- 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 -230
- 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 +94 -234
- 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 +32 -119
- package/dist/runtime/components/ContextMenu.vue.d.ts +127 -0
- package/dist/runtime/components/ContextMenuContent.vue +71 -72
- package/dist/runtime/components/ContextMenuContent.vue.d.ts +105 -0
- package/dist/runtime/components/Drawer.vue +49 -87
- package/dist/runtime/components/Drawer.vue.d.ts +88 -0
- package/dist/runtime/components/DropdownMenu.vue +37 -129
- package/dist/runtime/components/DropdownMenu.vue.d.ts +141 -0
- package/dist/runtime/components/DropdownMenuContent.vue +76 -79
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +55 -0
- package/dist/runtime/components/Form.vue +135 -219
- package/dist/runtime/components/Form.vue.d.ts +66 -0
- package/dist/runtime/components/FormField.vue +36 -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 +193 -302
- 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 -173
- package/dist/runtime/components/Link.vue.d.ts +124 -0
- package/dist/runtime/components/LinkBase.vue +33 -41
- 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 +78 -186
- 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 +75 -126
- package/dist/runtime/components/RadioGroup.vue.d.ts +88 -0
- package/dist/runtime/components/Select.vue +115 -202
- package/dist/runtime/components/Select.vue.d.ts +139 -0
- package/dist/runtime/components/SelectMenu.vue +167 -281
- 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 +44 -113
- 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 +165 -264
- package/dist/runtime/components/Table.vue.d.ts +183 -0
- package/dist/runtime/components/Tabs.vue +40 -105
- 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 +57 -150
- package/dist/runtime/components/Tree.vue.d.ts +128 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
- package/dist/runtime/composables/defineShortcuts.js +0 -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/useFormField.js +1 -1
- package/dist/runtime/composables/useOverlay.d.ts +16 -8
- 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/hy.d.ts +3 -0
- package/dist/runtime/locale/hy.js +54 -0
- package/dist/runtime/locale/index.d.ts +6 -1
- package/dist/runtime/locale/index.js +6 -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 +5 -1
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/types/utils.d.ts +70 -10
- package/dist/runtime/utils/index.d.ts +1 -0
- package/dist/runtime/utils/index.js +3 -0
- package/dist/runtime/utils/link.d.ts +4 -27
- package/dist/runtime/utils/link.js +32 -1
- 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 -199
- package/dist/runtime/vue/components/Link.vue.d.ts +124 -0
- package/dist/runtime/vue/stubs.d.ts +5 -0
- package/dist/runtime/vue/stubs.js +11 -2
- package/dist/shared/{ui.BCaWD5Ek.mjs → ui.D7lOOabO.mjs} +623 -364
- package/dist/types.d.mts +5 -1
- package/dist/unplugin.d.mts +6 -1
- package/dist/unplugin.mjs +25 -4
- package/dist/vite.mjs +1 -1
- package/package.json +122 -64
- package/dist/module.cjs +0 -62
- package/dist/module.d.cts +0 -44
- package/dist/module.d.ts +0 -44
- package/dist/shared/ui.C6uTSFTI.cjs +0 -3555
- package/dist/types.d.ts +0 -1
- package/dist/unplugin.cjs +0 -232
- package/dist/unplugin.d.cts +0 -61
- package/dist/unplugin.d.ts +0 -61
- package/dist/vite.cjs +0 -23
- package/dist/vite.d.cts +0 -15
- package/dist/vite.d.ts +0 -15
|
@@ -1,266 +1,148 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
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
|
|
108
|
-
import { computed, ref, watch, onMounted } from
|
|
109
|
-
import useEmblaCarousel from
|
|
110
|
-
import { Primitive, useForwardProps } from
|
|
111
|
-
import { reactivePick, computedAsync } from
|
|
112
|
-
import { useAppConfig } from
|
|
113
|
-
import { useLocale } from
|
|
114
|
-
import
|
|
115
|
-
|
|
116
|
-
const props =
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
const
|
|
153
|
-
|
|
154
|
-
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 || {} })({
|
|
155
57
|
orientation: props.orientation
|
|
156
|
-
}))
|
|
157
|
-
|
|
158
|
-
|
|
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 ===
|
|
162
|
-
direction: dir.value ===
|
|
163
|
-
}))
|
|
164
|
-
|
|
165
|
-
const
|
|
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(
|
|
170
|
-
|
|
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(
|
|
175
|
-
|
|
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(
|
|
180
|
-
|
|
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(
|
|
185
|
-
|
|
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(
|
|
190
|
-
|
|
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(
|
|
195
|
-
|
|
88
|
+
const { WheelGesturesPlugin } = await import("embla-carousel-wheel-gestures");
|
|
89
|
+
plugins2.push(WheelGesturesPlugin(typeof props.wheelGestures === "boolean" ? {} : props.wheelGestures));
|
|
196
90
|
}
|
|
197
|
-
|
|
198
|
-
|
|
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
|
|
214
|
-
emblaApi.value?.scrollTo(index)
|
|
103
|
+
function scrollTo(index) {
|
|
104
|
+
emblaApi.value?.scrollTo(index);
|
|
215
105
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const
|
|
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
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
|
|
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
|
|
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(
|
|
254
|
-
emblaApi.value?.on(
|
|
255
|
-
emblaApi.value?.on(
|
|
256
|
-
emblaApi.value?.on(
|
|
257
|
-
|
|
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 :
|
|
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 :
|
|
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
|
+
} & {};
|