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