@mantine-vue/carousel 3.0.0 → 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/esm/index.mjs CHANGED
@@ -1,138 +1,89 @@
1
- import { Comment, computed, defineComponent, h, ref, watch } from "vue";
1
+ import { AccordionChevron, Box, InlineStyles, UnstyledButton, VisuallyHidden, createSafeContext, createVarsResolver, factory, filterProps, getBaseValue, getSortedBreakpoints, getSpacing, keys, px, rem, useDirection, useMantineTheme, useProps, useStyles } from "@mantine-vue/core";
2
+ import { Comment, Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, normalizeStyle, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useAttrs, useSlots, watch, withCtx } from "vue";
2
3
  import emblaCarouselVue from "embla-carousel-vue";
3
- import { useId } from "@mantine-vue/hooks";
4
- import { AccordionChevron, Box, InlineStyles, UnstyledButton, VisuallyHidden, createSafeContext, createVarsResolver, filterProps, getBaseValue, getSortedBreakpoints, getSpacing, keys, px, rem, useDirection, useMantineTheme, useProps, useStyles, withBoxProps } from "@mantine-vue/core";
4
+ import { assignRef, useId } from "@mantine-vue/hooks";
5
5
  //#region src/Carousel.context.ts
6
6
  var [provideCarouselContext, useCarouselContext] = createSafeContext("Carousel component was not found in tree");
7
- var Carousel_module_default = {
8
- root: "_root_avx3r_1",
9
- viewport: "_viewport_avx3r_6",
10
- container: "_container_avx3r_15",
11
- controls: "_controls_avx3r_35",
12
- control: "_control_avx3r_35",
13
- indicators: "_indicators_avx3r_87",
14
- indicator: "_indicator_avx3r_87",
15
- slide: "_slide_avx3r_135"
16
- };
17
7
  //#endregion
18
- //#region src/CarouselSlide.ts
19
- var CarouselSlideBaseComponent = defineComponent({
20
- name: "CarouselSlide",
21
- inheritAttrs: false,
22
- props: {
23
- classNames: {
24
- type: [Object, Function],
25
- default: void 0
26
- },
27
- styles: {
28
- type: [Object, Function],
29
- default: void 0
30
- },
31
- mod: {
32
- type: [Object, Array],
33
- default: void 0
34
- }
35
- },
36
- setup(props, { attrs, slots }) {
37
- const ctx = useCarouselContext();
38
- return () => h(Box, {
39
- mod: [{ orientation: ctx.orientation }, props.mod],
40
- role: "group",
41
- "aria-roledescription": "slide",
42
- "aria-label": "Carousel slide",
43
- ...attrs,
44
- ...ctx.getStyles("slide", {
45
- className: attrs.class,
46
- style: attrs.style,
47
- classNames: props.classNames,
48
- styles: props.styles
49
- })
50
- }, slots);
51
- }
8
+ //#region src/components/CarouselVariables/CarouselVariables.utils.ts
9
+ var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
10
+ var getBaseStyles = (props) => filterProps({
11
+ "--carousel-slide-gap": getSpacing(getBaseValue(props.slideGap)),
12
+ "--carousel-slide-size": rem(getBaseValue(props.slideSize))
52
13
  });
53
- var CarouselSlide = Object.assign(withBoxProps(CarouselSlideBaseComponent), { classes: Carousel_module_default });
54
14
  //#endregion
55
- //#region src/CarouselVariables.ts
56
- function isObject(value) {
57
- return typeof value === "object" && value !== null && !Array.isArray(value);
58
- }
59
- var sharedProps = {
60
- selector: {
61
- type: String,
62
- required: true
63
- },
64
- slideSize: {
65
- type: [
66
- String,
67
- Number,
68
- Object
69
- ],
70
- default: void 0
15
+ //#region src/components/CarouselVariables/CarouselContainerVariables.vue
16
+ var CarouselContainerVariables_default = /* @__PURE__ */ defineComponent({
17
+ name: "CarouselContainerVariables",
18
+ __name: "CarouselContainerVariables",
19
+ props: {
20
+ selector: {},
21
+ slideSize: {},
22
+ slideGap: {}
71
23
  },
72
- slideGap: {
73
- type: [
74
- String,
75
- Number,
76
- Object
77
- ],
78
- default: void 0
79
- }
80
- };
81
- var CarouselVariables = defineComponent({
82
- name: "CarouselVariables",
83
- props: sharedProps,
84
- setup(props) {
85
- const theme = useMantineTheme();
86
- return () => {
87
- const baseStyles = filterProps({
88
- "--carousel-slide-gap": getSpacing(getBaseValue(props.slideGap)),
89
- "--carousel-slide-size": rem(getBaseValue(props.slideSize))
90
- });
91
- const queries = keys(theme.value.breakpoints).reduce((acc, breakpoint) => {
92
- acc[breakpoint] = acc[breakpoint] ?? {};
93
- if (isObject(props.slideGap) && props.slideGap[breakpoint] !== void 0) acc[breakpoint]["--carousel-slide-gap"] = getSpacing(props.slideGap[breakpoint]);
94
- if (isObject(props.slideSize) && props.slideSize[breakpoint] !== void 0) acc[breakpoint]["--carousel-slide-size"] = rem(props.slideSize[breakpoint]);
95
- return acc;
96
- }, {});
97
- const media = getSortedBreakpoints(theme.value.breakpoints).reduce((acc, item) => {
98
- if (keys(queries[item.breakpoint] ?? {}).length > 0) acc[`(min-width: ${theme.value.breakpoints[item.breakpoint]})`] = queries[item.breakpoint];
99
- return acc;
24
+ setup(__props) {
25
+ const props = __props;
26
+ const styles = computed(() => getBaseStyles(props));
27
+ const container = computed(() => {
28
+ const getBreakpoints = (value) => isObject(value) ? keys(value).filter((key) => key !== "base") : [];
29
+ return [...new Set([...getBreakpoints(props.slideGap), ...getBreakpoints(props.slideSize)])].sort((a, b) => px(a) - px(b)).reduce((result, breakpoint) => {
30
+ const values = {};
31
+ if (isObject(props.slideGap) && props.slideGap[breakpoint] !== void 0) values["--carousel-slide-gap"] = getSpacing(props.slideGap[breakpoint]);
32
+ if (isObject(props.slideSize) && props.slideSize[breakpoint] !== void 0) values["--carousel-slide-size"] = rem(props.slideSize[breakpoint]);
33
+ result[`carousel (min-width: ${breakpoint})`] = values;
34
+ return result;
100
35
  }, {});
101
- return h(InlineStyles, {
36
+ });
37
+ return (_ctx, _cache) => {
38
+ return openBlock(), createBlock(unref(InlineStyles), {
102
39
  selector: props.selector,
103
- styles: baseStyles,
104
- media
105
- });
40
+ styles: styles.value,
41
+ container: container.value
42
+ }, null, 8, [
43
+ "selector",
44
+ "styles",
45
+ "container"
46
+ ]);
106
47
  };
107
48
  }
108
49
  });
109
- function getBreakpoints(values) {
110
- return isObject(values) ? keys(values).filter((breakpoint) => breakpoint !== "base") : [];
111
- }
112
- function sortBreakpoints(breakpoints) {
113
- return breakpoints.sort((a, b) => px(a) - px(b));
114
- }
115
- var CarouselContainerVariables = defineComponent({
116
- name: "CarouselContainerVariables",
117
- props: sharedProps,
118
- setup(props) {
119
- return () => {
120
- const baseStyles = filterProps({
121
- "--carousel-slide-gap": getSpacing(getBaseValue(props.slideGap)),
122
- "--carousel-slide-size": rem(getBaseValue(props.slideSize))
123
- });
124
- const container = sortBreakpoints(Array.from(new Set([...getBreakpoints(props.slideGap), ...getBreakpoints(props.slideSize)]))).reduce((acc, breakpoint) => {
125
- const key = `carousel (min-width: ${breakpoint})`;
126
- acc[key] = {};
127
- if (isObject(props.slideGap) && props.slideGap[breakpoint] !== void 0) acc[key]["--carousel-slide-gap"] = getSpacing(props.slideGap[breakpoint]);
128
- if (isObject(props.slideSize) && props.slideSize[breakpoint] !== void 0) acc[key]["--carousel-slide-size"] = rem(props.slideSize[breakpoint]);
129
- return acc;
50
+ //#endregion
51
+ //#region src/components/CarouselVariables/CarouselVariables.vue
52
+ var CarouselVariables_default = /* @__PURE__ */ defineComponent({
53
+ name: "CarouselVariables",
54
+ __name: "CarouselVariables",
55
+ props: {
56
+ selector: {},
57
+ slideSize: {},
58
+ slideGap: {}
59
+ },
60
+ setup(__props) {
61
+ const props = __props;
62
+ const theme = useMantineTheme();
63
+ const styles = computed(() => getBaseStyles(props));
64
+ const media = computed(() => {
65
+ const queries = keys(theme.value.breakpoints).reduce((result, breakpoint) => {
66
+ const values = {};
67
+ if (isObject(props.slideGap) && props.slideGap[breakpoint] !== void 0) values["--carousel-slide-gap"] = getSpacing(props.slideGap[breakpoint]);
68
+ if (isObject(props.slideSize) && props.slideSize[breakpoint] !== void 0) values["--carousel-slide-size"] = rem(props.slideSize[breakpoint]);
69
+ result[breakpoint] = values;
70
+ return result;
130
71
  }, {});
131
- return h(InlineStyles, {
72
+ return getSortedBreakpoints(theme.value.breakpoints).reduce((result, item) => {
73
+ if (keys(queries[item.breakpoint] ?? {}).length) result[`(min-width: ${theme.value.breakpoints[item.breakpoint]})`] = queries[item.breakpoint];
74
+ return result;
75
+ }, {});
76
+ });
77
+ return (_ctx, _cache) => {
78
+ return openBlock(), createBlock(unref(InlineStyles), {
132
79
  selector: props.selector,
133
- styles: baseStyles,
134
- container
135
- });
80
+ styles: styles.value,
81
+ media: media.value
82
+ }, null, 8, [
83
+ "selector",
84
+ "styles",
85
+ "media"
86
+ ]);
136
87
  };
137
88
  }
138
89
  });
@@ -153,200 +104,108 @@ function getPreviousIndicatorIndex(index, total) {
153
104
  function clamp(value, min, max) {
154
105
  return Math.min(Math.max(value, min), max);
155
106
  }
156
- //#endregion
157
- //#region src/Carousel.ts
158
- var defaultProps = {
159
- controlSize: 26,
160
- controlsOffset: "sm",
161
- slideSize: "100%",
162
- slideGap: 0,
163
- orientation: "horizontal",
164
- includeGapInSize: true,
165
- initialSlide: 0,
166
- withControls: true,
167
- withIndicators: false,
168
- withKeyboardEvents: true,
169
- type: "media"
170
- };
171
- var defaultEmblaOptions = {
172
- align: "center",
173
- loop: false,
174
- slidesToScroll: 1,
175
- dragFree: false,
176
- inViewThreshold: 0,
177
- skipSnaps: false,
178
- containScroll: "trimSnaps"
107
+ var Carousel_module_default = {
108
+ root: "_root_avx3r_1",
109
+ viewport: "_viewport_avx3r_6",
110
+ container: "_container_avx3r_15",
111
+ controls: "_controls_avx3r_35",
112
+ control: "_control_avx3r_35",
113
+ indicators: "_indicators_avx3r_87",
114
+ indicator: "_indicator_avx3r_87",
115
+ slide: "_slide_avx3r_135"
179
116
  };
117
+ //#endregion
118
+ //#region src/components/Carousel/Carousel.vue?vue&type=script&setup=true&lang.ts
119
+ var _hoisted_1 = ["data-orientation"];
120
+ var _hoisted_2 = ["data-type"];
121
+ var _hoisted_3 = ["data-orientation"];
122
+ var _hoisted_4 = ["data-orientation"];
180
123
  var varsResolver = createVarsResolver((_, { height, controlSize, controlsOffset }) => ({ root: {
181
124
  "--carousel-height": rem(height),
182
125
  "--carousel-control-size": rem(controlSize),
183
126
  "--carousel-controls-offset": getSpacing(controlsOffset)
184
127
  } }));
185
- function useRandomClassName() {
186
- return `__mantine-vue-carousel-${Math.random().toString(36).slice(2, 9)}`;
187
- }
188
- function countRealSlides(nodes) {
189
- if (!nodes) return 0;
190
- return nodes.filter((node) => node.type !== Comment).length;
191
- }
192
- var CarouselBaseComponent = defineComponent({
128
+ //#endregion
129
+ //#region src/components/Carousel/Carousel.vue
130
+ var Carousel_default = /* @__PURE__ */ defineComponent({
193
131
  name: "Carousel",
194
132
  inheritAttrs: false,
133
+ __name: "Carousel",
195
134
  props: {
196
- emblaOptions: {
197
- type: Object,
198
- default: void 0
199
- },
200
- onNextSlide: {
201
- type: Function,
202
- default: void 0
203
- },
204
- onPreviousSlide: {
205
- type: Function,
206
- default: void 0
207
- },
208
- onSlideChange: {
209
- type: Function,
210
- default: void 0
211
- },
212
- getEmblaApi: {
213
- type: Function,
214
- default: void 0
215
- },
216
- nextControlProps: {
217
- type: Object,
218
- default: void 0
219
- },
220
- previousControlProps: {
221
- type: Object,
222
- default: void 0
223
- },
224
- controlSize: {
225
- type: [String, Number],
226
- default: void 0
227
- },
228
- controlsOffset: {
229
- type: [String, Number],
230
- default: void 0
231
- },
232
- slideSize: {
233
- type: [
234
- String,
235
- Number,
236
- Object
237
- ],
238
- default: void 0
239
- },
240
- slideGap: {
241
- type: [
242
- String,
243
- Number,
244
- Object
245
- ],
246
- default: void 0
247
- },
248
- orientation: {
249
- type: String,
250
- default: void 0
251
- },
252
- type: {
253
- type: String,
254
- default: void 0
255
- },
256
- height: {
257
- type: [String, Number],
258
- default: void 0
259
- },
135
+ rootRef: {},
136
+ emblaOptions: {},
137
+ nextControlProps: {},
138
+ previousControlProps: {},
139
+ controlSize: { default: 26 },
140
+ controlsOffset: { default: "sm" },
141
+ slideSize: { default: "100%" },
142
+ slideGap: { default: 0 },
143
+ orientation: { default: "horizontal" },
144
+ type: { default: "media" },
145
+ height: {},
260
146
  includeGapInSize: {
261
147
  type: Boolean,
262
- default: void 0
263
- },
264
- initialSlide: {
265
- type: Number,
266
- default: void 0
148
+ default: true
267
149
  },
150
+ initialSlide: { default: 0 },
268
151
  withControls: {
269
152
  type: Boolean,
270
- default: void 0
153
+ default: true
271
154
  },
272
155
  withIndicators: {
273
156
  type: Boolean,
274
- default: void 0
275
- },
276
- plugins: {
277
- type: Array,
278
- default: void 0
279
- },
280
- nextControlIcon: {
281
- type: null,
282
- default: void 0
283
- },
284
- previousControlIcon: {
285
- type: null,
286
- default: void 0
157
+ default: false
287
158
  },
159
+ plugins: {},
160
+ nextControlIcon: {},
161
+ previousControlIcon: {},
288
162
  withKeyboardEvents: {
289
163
  type: Boolean,
290
- default: void 0
291
- },
292
- getIndicatorProps: {
293
- type: Function,
294
- default: void 0
295
- },
296
- id: {
297
- type: String,
298
- default: void 0
299
- },
300
- mod: {
301
- type: [Object, Array],
302
- default: void 0
303
- },
304
- classNames: {
305
- type: [Object, Function],
306
- default: void 0
164
+ default: true
307
165
  },
308
- styles: {
309
- type: [Object, Function],
310
- default: void 0
311
- },
312
- vars: {
313
- type: [Object, Function],
314
- default: void 0
315
- },
316
- unstyled: {
317
- type: Boolean,
318
- default: false
319
- }
166
+ getIndicatorProps: {},
167
+ id: {},
168
+ classNames: {},
169
+ styles: {},
170
+ vars: {},
171
+ unstyled: { type: Boolean },
172
+ mod: {}
320
173
  },
321
- setup(rawProps, { attrs, slots }) {
322
- const props = useProps("Carousel", defaultProps, rawProps);
174
+ emits: [
175
+ "next-slide",
176
+ "previous-slide",
177
+ "slide-change",
178
+ "embla-api-ready"
179
+ ],
180
+ setup(__props, { expose: __expose, emit: __emit }) {
181
+ const props = useProps("Carousel", null, __props);
182
+ const emit = __emit;
183
+ const attrs = useAttrs();
184
+ const slots = useSlots();
323
185
  const getStyles = useStyles({
324
186
  name: "Carousel",
325
187
  classes: Carousel_module_default,
326
188
  props,
327
- get className() {
328
- return attrs.class;
329
- },
330
- get style() {
331
- return attrs.style;
332
- },
333
- get classNames() {
334
- return props.classNames;
335
- },
336
- get styles() {
337
- return props.styles;
338
- },
339
- get unstyled() {
340
- return props.unstyled;
341
- },
342
- get vars() {
343
- return props.vars;
344
- },
189
+ className: attrs.class,
190
+ style: attrs.style,
191
+ classNames: props.classNames,
192
+ styles: props.styles,
193
+ unstyled: props.unstyled,
194
+ vars: props.vars,
345
195
  varsResolver
346
196
  });
347
- const _id = useId(props.id);
348
- const responsiveClassName = useRandomClassName();
197
+ const id = useId(props.id);
198
+ const responsiveClassName = `__mantine-vue-carousel-${Math.random().toString(36).slice(2, 9)}`;
349
199
  const { dir } = useDirection();
200
+ const defaultEmblaOptions = {
201
+ align: "center",
202
+ loop: false,
203
+ slidesToScroll: 1,
204
+ dragFree: false,
205
+ inViewThreshold: 0,
206
+ skipSnaps: false,
207
+ containScroll: "trimSnaps"
208
+ };
350
209
  const [emblaNode, embla] = emblaCarouselVue(computed(() => ({
351
210
  axis: props.orientation === "horizontal" ? "x" : "y",
352
211
  direction: props.orientation === "horizontal" ? dir.value : void 0,
@@ -357,81 +216,136 @@ var CarouselBaseComponent = defineComponent({
357
216
  const selected = ref(0);
358
217
  const slidesCount = ref(0);
359
218
  const slotSlideCount = ref(0);
360
- const handleScroll = (index) => {
219
+ const canScrollPrev = computed(() => selected.value >= 0 && embla.value?.canScrollPrev() || false);
220
+ const canScrollNext = computed(() => selected.value >= 0 && embla.value?.canScrollNext() || false);
221
+ const variablesProps = computed(() => ({
222
+ selector: `.${responsiveClassName}`,
223
+ slideSize: props.slideSize,
224
+ slideGap: props.slideGap
225
+ }));
226
+ function countRealSlides(nodes) {
227
+ return nodes.filter((node) => node.type !== Comment).length;
228
+ }
229
+ function renderSlides() {
230
+ const nodes = slots.default?.() ?? [];
231
+ slotSlideCount.value = countRealSlides(nodes);
232
+ return nodes;
233
+ }
234
+ function scrollTo(index) {
361
235
  embla.value?.scrollTo(index);
362
- };
363
- const handleSelect = () => {
236
+ }
237
+ function select() {
364
238
  const instance = embla.value;
365
239
  if (!instance) return;
366
240
  const slide = instance.selectedScrollSnap();
367
241
  const changed = slide !== selected.value;
368
242
  selected.value = slide;
369
- if (changed) props.onSlideChange?.(slide);
370
- };
371
- const handlePrevious = () => {
243
+ if (changed) emit("slide-change", slide);
244
+ }
245
+ function previous() {
372
246
  embla.value?.scrollPrev();
373
- props.onPreviousSlide?.();
374
- };
375
- const handleNext = () => {
247
+ emit("previous-slide");
248
+ }
249
+ function next() {
376
250
  embla.value?.scrollNext();
377
- props.onNextSlide?.();
378
- };
379
- const handleKeydown = (event) => {
251
+ emit("next-slide");
252
+ }
253
+ function keydown(event) {
380
254
  if (!props.withKeyboardEvents) return;
381
255
  if (event.key === "ArrowRight") {
382
256
  event.preventDefault();
383
- handleNext();
257
+ next();
384
258
  }
385
259
  if (event.key === "ArrowLeft") {
386
260
  event.preventDefault();
387
- handlePrevious();
261
+ previous();
388
262
  }
389
263
  if (event.key === "Home") {
390
264
  event.preventDefault();
391
- embla.value?.scrollTo(0);
265
+ scrollTo(0);
392
266
  }
393
267
  if (event.key === "End") {
394
268
  event.preventDefault();
395
- embla.value?.scrollTo(embla.value.scrollSnapList().length - 1);
269
+ scrollTo((embla.value?.scrollSnapList().length ?? 1) - 1);
396
270
  }
397
- };
398
- const handleIndicatorKeyDown = (event, index) => {
399
- const isHorizontal = props.orientation === "horizontal";
400
- const nextKey = isHorizontal ? "ArrowRight" : "ArrowDown";
401
- const prevKey = isHorizontal ? "ArrowLeft" : "ArrowUp";
402
- const parent = event.currentTarget?.parentElement;
403
- if (event.key === nextKey) {
404
- event.preventDefault();
405
- const nextIndex = getNextIndicatorIndex(index, slidesCount.value);
406
- handleScroll(nextIndex);
407
- (parent?.children[nextIndex])?.focus();
408
- }
409
- if (event.key === prevKey) {
410
- event.preventDefault();
411
- const prevIndex = getPreviousIndicatorIndex(index, slidesCount.value);
412
- handleScroll(prevIndex);
413
- (parent?.children[prevIndex])?.focus();
414
- }
415
- if (event.key === "Home") {
416
- event.preventDefault();
417
- handleScroll(0);
418
- (parent?.children[0])?.focus();
419
- }
420
- if (event.key === "End") {
271
+ }
272
+ function indicatorKeydown(event, index) {
273
+ const nextKey = props.orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
274
+ const previousKey = props.orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
275
+ const parent = event.currentTarget.parentElement;
276
+ let target = null;
277
+ if (event.key === nextKey) target = getNextIndicatorIndex(index, slidesCount.value);
278
+ if (event.key === previousKey) target = getPreviousIndicatorIndex(index, slidesCount.value);
279
+ if (event.key === "Home") target = 0;
280
+ if (event.key === "End") target = slidesCount.value - 1;
281
+ if (target !== null) {
421
282
  event.preventDefault();
422
- handleScroll(slidesCount.value - 1);
423
- (parent?.children[slidesCount.value - 1])?.focus();
283
+ scrollTo(target);
284
+ (parent?.children[target])?.focus();
424
285
  }
425
- };
426
- watch(embla, (instance, _prev, onCleanup) => {
286
+ }
287
+ function indicatorAttrs(index) {
288
+ return {
289
+ ...getStyles("indicator"),
290
+ role: "tab",
291
+ "aria-label": `Go to slide ${index + 1}`,
292
+ "aria-selected": index === selected.value,
293
+ tabindex: index === selected.value ? 0 : -1,
294
+ "data-active": index === selected.value || void 0,
295
+ "data-orientation": props.orientation,
296
+ onClick: () => scrollTo(index),
297
+ onKeydown: (event) => indicatorKeydown(event, index),
298
+ onMousedown: (event) => event.preventDefault(),
299
+ ...props.getIndicatorProps?.(index)
300
+ };
301
+ }
302
+ function previousAttrs() {
303
+ return {
304
+ "aria-controls": id.value,
305
+ "aria-label": "Previous slide",
306
+ "aria-disabled": !canScrollPrev.value,
307
+ "data-inactive": !canScrollPrev.value || void 0,
308
+ "data-type": "previous",
309
+ tabindex: canScrollPrev.value ? 0 : -1,
310
+ ...props.previousControlProps,
311
+ ...getStyles("control", {
312
+ className: props.previousControlProps?.className,
313
+ style: props.previousControlProps?.style
314
+ }),
315
+ onClick: (event) => {
316
+ previous();
317
+ props.previousControlProps?.onClick?.(event);
318
+ }
319
+ };
320
+ }
321
+ function nextAttrs() {
322
+ return {
323
+ "aria-controls": id.value,
324
+ "aria-label": "Next slide",
325
+ "aria-disabled": !canScrollNext.value,
326
+ "data-inactive": !canScrollNext.value || void 0,
327
+ "data-type": "next",
328
+ tabindex: canScrollNext.value ? 0 : -1,
329
+ ...getStyles("control", {
330
+ className: props.nextControlProps?.className,
331
+ style: props.nextControlProps?.style
332
+ }),
333
+ ...props.nextControlProps,
334
+ onClick: (event) => {
335
+ next();
336
+ props.nextControlProps?.onClick?.(event);
337
+ }
338
+ };
339
+ }
340
+ const renderPreviousIcon = () => props.previousControlIcon;
341
+ const renderNextIcon = () => props.nextControlIcon;
342
+ watch(embla, (instance, _previous, onCleanup) => {
427
343
  if (!instance) return;
428
- props.getEmblaApi?.(instance);
429
- handleSelect();
344
+ emit("embla-api-ready", instance);
345
+ select();
430
346
  slidesCount.value = instance.scrollSnapList().length;
431
- instance.on("select", handleSelect);
432
- onCleanup(() => {
433
- instance.off("select", handleSelect);
434
- });
347
+ instance.on("select", select);
348
+ onCleanup(() => instance.off("select", select));
435
349
  }, { immediate: true });
436
350
  watch([slotSlideCount, () => props.emblaOptions?.slidesToScroll], ([childrenCount]) => {
437
351
  const instance = embla.value;
@@ -446,110 +360,122 @@ var CarouselBaseComponent = defineComponent({
446
360
  return props.orientation;
447
361
  }
448
362
  });
449
- return () => {
450
- const canScrollPrev = embla.value?.canScrollPrev() || false;
451
- const canScrollNext = embla.value?.canScrollNext() || false;
452
- const defaultSlot = slots.default?.();
453
- slotSlideCount.value = countRealSlides(defaultSlot);
454
- const indicators = Array(slidesCount.value).fill(0).map((_, index) => h(UnstyledButton, {
455
- ...getStyles("indicator"),
456
- key: index,
457
- role: "tab",
458
- "aria-label": `Go to slide ${index + 1}`,
459
- "aria-selected": index === selected.value,
460
- tabindex: index === selected.value ? 0 : -1,
461
- "data-active": index === selected.value || void 0,
462
- onClick: () => handleScroll(index),
463
- onKeydown: (event) => handleIndicatorKeyDown(event, index),
464
- "data-orientation": props.orientation,
465
- onMousedown: (event) => event.preventDefault(),
466
- ...props.getIndicatorProps?.(index)
467
- }));
468
- const variablesProps = {
469
- selector: `.${responsiveClassName}`,
470
- slideSize: props.slideSize,
471
- slideGap: props.slideGap
472
- };
473
- return [props.type === "container" ? h(CarouselContainerVariables, variablesProps) : h(CarouselVariables, variablesProps), h(Box, {
363
+ const rootElement = ref(null);
364
+ const setRootRef = (node) => {
365
+ rootElement.value = node;
366
+ assignRef(props.rootRef, node);
367
+ };
368
+ __expose({
369
+ embla,
370
+ rootElement
371
+ });
372
+ return (_ctx, _cache) => {
373
+ return openBlock(), createElementBlock(Fragment, null, [unref(props).type === "container" ? (openBlock(), createBlock(CarouselContainerVariables_default, normalizeProps(mergeProps({ key: 0 }, variablesProps.value)), null, 16)) : (openBlock(), createBlock(CarouselVariables_default, normalizeProps(mergeProps({ key: 1 }, variablesProps.value)), null, 16)), createVNode(unref(Box), mergeProps({ rootRef: setRootRef }, {
474
374
  role: "region",
475
375
  "aria-roledescription": "carousel",
476
- ...attrs,
477
- ...getStyles("root", { className: responsiveClassName }),
478
- id: _id.value,
376
+ ...unref(attrs),
377
+ ...unref(getStyles)("root", { className: responsiveClassName })
378
+ }, {
379
+ id: unref(id),
479
380
  mod: [{
480
- orientation: props.orientation,
481
- "include-gap-in-size": props.includeGapInSize
482
- }, props.mod],
483
- onKeydownCapture: handleKeydown
484
- }, () => [
485
- h(VisuallyHidden, {
486
- role: "status",
487
- "aria-live": "polite",
488
- "aria-atomic": "true"
489
- }, () => slidesCount.value > 0 ? `Slide ${selected.value + 1} of ${slidesCount.value}` : ""),
490
- props.withControls && h("div", {
491
- ...getStyles("controls"),
492
- "data-orientation": props.orientation
493
- }, [h(UnstyledButton, {
494
- "aria-controls": _id.value,
495
- "aria-label": "Previous slide",
496
- "aria-disabled": !canScrollPrev,
497
- "data-inactive": !canScrollPrev || void 0,
498
- "data-type": "previous",
499
- tabindex: canScrollPrev ? 0 : -1,
500
- ...props.previousControlProps,
501
- ...getStyles("control", {
502
- className: props.previousControlProps?.className,
503
- style: props.previousControlProps?.style
381
+ orientation: unref(props).orientation,
382
+ "include-gap-in-size": unref(props).includeGapInSize
383
+ }, unref(props).mod],
384
+ onKeydownCapture: keydown
385
+ }), {
386
+ default: withCtx(() => [
387
+ createVNode(unref(VisuallyHidden), {
388
+ role: "status",
389
+ "aria-live": "polite",
390
+ "aria-atomic": "true"
391
+ }, {
392
+ default: withCtx(() => [createTextVNode(toDisplayString(slidesCount.value > 0 ? `Slide ${selected.value + 1} of ${slidesCount.value}` : ""), 1)]),
393
+ _: 1
504
394
  }),
505
- onClick: (event) => {
506
- handlePrevious();
507
- props.previousControlProps?.onClick?.(event);
508
- }
509
- }, () => typeof props.previousControlIcon !== "undefined" ? props.previousControlIcon : h(AccordionChevron, { style: { transform: `rotate(${getChevronRotation({
510
- dir: dir.value,
511
- orientation: props.orientation,
512
- direction: "previous"
513
- })}deg)` } })), h(UnstyledButton, {
514
- "aria-controls": _id.value,
515
- "aria-label": "Next slide",
516
- "aria-disabled": !canScrollNext,
517
- "data-inactive": !canScrollNext || void 0,
518
- "data-type": "next",
519
- tabindex: canScrollNext ? 0 : -1,
520
- ...getStyles("control", {
521
- className: props.nextControlProps?.className,
522
- style: props.nextControlProps?.style
523
- }),
524
- ...props.nextControlProps,
525
- onClick: (event) => {
526
- handleNext();
527
- props.nextControlProps?.onClick?.(event);
528
- }
529
- }, () => typeof props.nextControlIcon !== "undefined" ? props.nextControlIcon : h(AccordionChevron, { style: { transform: `rotate(${getChevronRotation({
530
- dir: dir.value,
531
- orientation: props.orientation,
532
- direction: "next"
533
- })}deg)` } }))]),
534
- h("div", {
535
- ...getStyles("viewport"),
536
- ref: emblaNode,
537
- "data-type": props.type
538
- }, [h("div", {
539
- ...getStyles("container", { className: responsiveClassName }),
540
- "data-orientation": props.orientation
541
- }, defaultSlot)]),
542
- props.withIndicators && h("div", {
543
- ...getStyles("indicators"),
544
- role: "tablist",
545
- "aria-label": "Slides",
546
- "data-orientation": props.orientation
547
- }, indicators)
548
- ])];
395
+ unref(props).withControls ? (openBlock(), createElementBlock("div", mergeProps({ key: 0 }, unref(getStyles)("controls"), { "data-orientation": unref(props).orientation }), [createVNode(unref(UnstyledButton), normalizeProps(guardReactiveProps(previousAttrs())), {
396
+ default: withCtx(() => [unref(props).previousControlIcon !== void 0 ? (openBlock(), createBlock(resolveDynamicComponent(renderPreviousIcon), { key: 0 })) : (openBlock(), createBlock(unref(AccordionChevron), {
397
+ key: 1,
398
+ style: normalizeStyle({ transform: `rotate(${unref(getChevronRotation)({
399
+ dir: unref(dir),
400
+ orientation: unref(props).orientation,
401
+ direction: "previous"
402
+ })}deg)` })
403
+ }, null, 8, ["style"]))]),
404
+ _: 1
405
+ }, 16), createVNode(unref(UnstyledButton), normalizeProps(guardReactiveProps(nextAttrs())), {
406
+ default: withCtx(() => [unref(props).nextControlIcon !== void 0 ? (openBlock(), createBlock(resolveDynamicComponent(renderNextIcon), { key: 0 })) : (openBlock(), createBlock(unref(AccordionChevron), {
407
+ key: 1,
408
+ style: normalizeStyle({ transform: `rotate(${unref(getChevronRotation)({
409
+ dir: unref(dir),
410
+ orientation: unref(props).orientation,
411
+ direction: "next"
412
+ })}deg)` })
413
+ }, null, 8, ["style"]))]),
414
+ _: 1
415
+ }, 16)], 16, _hoisted_1)) : createCommentVNode("", true),
416
+ createElementVNode("div", mergeProps({
417
+ ref_key: "emblaNode",
418
+ ref: emblaNode
419
+ }, unref(getStyles)("viewport"), { "data-type": unref(props).type }), [createElementVNode("div", mergeProps(unref(getStyles)("container", { className: responsiveClassName }), { "data-orientation": unref(props).orientation }), [(openBlock(), createBlock(resolveDynamicComponent(renderSlides)))], 16, _hoisted_3)], 16, _hoisted_2),
420
+ unref(props).withIndicators ? (openBlock(), createElementBlock("div", mergeProps({ key: 1 }, unref(getStyles)("indicators"), {
421
+ role: "tablist",
422
+ "aria-label": "Slides",
423
+ "data-orientation": unref(props).orientation
424
+ }), [(openBlock(true), createElementBlock(Fragment, null, renderList(slidesCount.value, (index) => {
425
+ return openBlock(), createBlock(unref(UnstyledButton), mergeProps({ key: index - 1 }, { ref_for: true }, indicatorAttrs(index - 1)), null, 16);
426
+ }), 128))], 16, _hoisted_4)) : createCommentVNode("", true)
427
+ ]),
428
+ _: 1
429
+ }, 16, ["id", "mod"])], 64);
549
430
  };
550
431
  }
551
432
  });
552
- var Carousel = Object.assign(withBoxProps(CarouselBaseComponent), {
433
+ //#endregion
434
+ //#region src/components/CarouselSlide/index.ts
435
+ var CarouselSlide = factory(/* @__PURE__ */ defineComponent({
436
+ name: "CarouselSlide",
437
+ inheritAttrs: false,
438
+ __name: "CarouselSlide",
439
+ props: {
440
+ rootRef: { type: [Object, Function] },
441
+ classNames: {},
442
+ styles: {},
443
+ mod: {}
444
+ },
445
+ setup(__props, { expose: __expose }) {
446
+ const props = __props;
447
+ const attrs = useAttrs();
448
+ const context = useCarouselContext();
449
+ const rootElement = ref(null);
450
+ const setRootRef = (node) => {
451
+ rootElement.value = node;
452
+ assignRef(props.rootRef, node);
453
+ };
454
+ __expose({ rootElement });
455
+ return (_ctx, _cache) => {
456
+ return openBlock(), createBlock(unref(Box), mergeProps({ rootRef: setRootRef }, {
457
+ ...unref(attrs),
458
+ ...unref(context).getStyles("slide", {
459
+ className: unref(attrs).class,
460
+ style: unref(attrs).style,
461
+ classNames: props.classNames,
462
+ styles: props.styles
463
+ })
464
+ }, {
465
+ mod: [{ orientation: unref(context).orientation }, props.mod],
466
+ role: "group",
467
+ "aria-roledescription": "slide",
468
+ "aria-label": "Carousel slide"
469
+ }), {
470
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
471
+ _: 3
472
+ }, 16, ["mod"]);
473
+ };
474
+ }
475
+ }), { classes: Carousel_module_default });
476
+ //#endregion
477
+ //#region src/components/Carousel/index.ts
478
+ var Carousel = factory(Carousel_default, {
553
479
  classes: Carousel_module_default,
554
480
  varsResolver,
555
481
  Slide: CarouselSlide