@nuxt/ui 2.12.2 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/module.d.mts +109 -38
  2. package/dist/module.d.ts +109 -38
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +6 -3
  5. package/dist/runtime/components/elements/Button.vue.d.ts +6 -6
  6. package/dist/runtime/components/elements/Carousel.vue +149 -0
  7. package/dist/runtime/components/elements/Carousel.vue.d.ts +104 -0
  8. package/dist/runtime/components/elements/Chip.vue.d.ts +3 -3
  9. package/dist/runtime/components/elements/Dropdown.vue +2 -2
  10. package/dist/runtime/components/elements/Dropdown.vue.d.ts +4 -4
  11. package/dist/runtime/components/elements/Link.vue +2 -2
  12. package/dist/runtime/components/elements/Link.vue.d.ts +6 -6
  13. package/dist/runtime/components/elements/Meter.vue.d.ts +3 -3
  14. package/dist/runtime/components/elements/MeterGroup.d.ts +3 -3
  15. package/dist/runtime/components/elements/Progress.vue.d.ts +3 -3
  16. package/dist/runtime/components/forms/Form.vue +7 -3
  17. package/dist/runtime/components/forms/InputMenu.vue +8 -0
  18. package/dist/runtime/components/forms/InputMenu.vue.d.ts +9 -0
  19. package/dist/runtime/components/forms/Select.vue +5 -1
  20. package/dist/runtime/components/forms/SelectMenu.vue +1 -1
  21. package/dist/runtime/components/forms/Toggle.vue +1 -1
  22. package/dist/runtime/components/forms/Toggle.vue.d.ts +2 -2
  23. package/dist/runtime/components/navigation/HorizontalNavigation.vue +102 -0
  24. package/dist/runtime/components/navigation/HorizontalNavigation.vue.d.ts +44 -0
  25. package/dist/runtime/components/navigation/Pagination.vue.d.ts +2 -2
  26. package/dist/runtime/components/navigation/VerticalNavigation.vue +12 -3
  27. package/dist/runtime/components/overlays/Modal.vue +6 -2
  28. package/dist/runtime/components/overlays/Modal.vue.d.ts +2 -1
  29. package/dist/runtime/components/overlays/Popover.vue +2 -2
  30. package/dist/runtime/components/overlays/Popover.vue.d.ts +4 -4
  31. package/dist/runtime/components/overlays/Slideover.vue +6 -2
  32. package/dist/runtime/components/overlays/Slideover.vue.d.ts +2 -1
  33. package/dist/runtime/components/overlays/Tooltip.vue +2 -2
  34. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +4 -4
  35. package/dist/runtime/composables/useCarouselScroll.d.ts +2 -0
  36. package/dist/runtime/composables/useCarouselScroll.mjs +35 -0
  37. package/dist/runtime/composables/usePopper.d.ts +3 -3
  38. package/dist/runtime/types/horizontal-navigation.d.ts +13 -0
  39. package/dist/runtime/types/index.d.ts +1 -0
  40. package/dist/runtime/types/vertical-navigation.d.ts +2 -1
  41. package/dist/runtime/ui.config/elements/carousel.d.ts +27 -0
  42. package/dist/runtime/ui.config/elements/carousel.mjs +26 -0
  43. package/dist/runtime/ui.config/elements/dropdown.d.ts +5 -1
  44. package/dist/runtime/ui.config/elements/dropdown.mjs +8 -4
  45. package/dist/runtime/ui.config/forms/inputMenu.d.ts +1 -1
  46. package/dist/runtime/ui.config/forms/inputMenu.mjs +5 -5
  47. package/dist/runtime/ui.config/forms/select.mjs +1 -1
  48. package/dist/runtime/ui.config/forms/selectMenu.d.ts +1 -1
  49. package/dist/runtime/ui.config/index.d.ts +2 -0
  50. package/dist/runtime/ui.config/index.mjs +2 -0
  51. package/dist/runtime/ui.config/navigation/breadcrumb.mjs +4 -4
  52. package/dist/runtime/ui.config/navigation/commandPalette.d.ts +1 -1
  53. package/dist/runtime/ui.config/navigation/commandPalette.mjs +8 -8
  54. package/dist/runtime/ui.config/navigation/horizontalNavigation.d.ts +27 -0
  55. package/dist/runtime/ui.config/navigation/horizontalNavigation.mjs +26 -0
  56. package/dist/runtime/ui.config/navigation/verticalNavigation.d.ts +4 -3
  57. package/dist/runtime/ui.config/navigation/verticalNavigation.mjs +8 -7
  58. package/dist/runtime/ui.config/overlays/popover.d.ts +4 -0
  59. package/dist/runtime/ui.config/overlays/popover.mjs +4 -0
  60. package/dist/runtime/ui.config/overlays/slideover.mjs +2 -2
  61. package/dist/runtime/ui.config/overlays/tooltip.d.ts +4 -0
  62. package/dist/runtime/ui.config/overlays/tooltip.mjs +4 -0
  63. package/dist/runtime/ui.css +1 -1
  64. package/dist/runtime/utils/link.d.ts +0 -1
  65. package/dist/types.d.mts +1 -1
  66. package/dist/types.d.ts +1 -1
  67. package/package.json +8 -8
package/dist/module.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { CollectionNames, IconsPluginOptions } from '@egoist/tailwindcss-icons';
3
3
 
4
- declare const _default$F: {
4
+ declare const _default$H: {
5
5
  wrapper: string;
6
6
  base: string;
7
7
  divide: string;
@@ -61,7 +61,7 @@ declare const _default$F: {
61
61
  };
62
62
  };
63
63
 
64
- declare const _default$E: {
64
+ declare const _default$G: {
65
65
  wrapper: string;
66
66
  background: string;
67
67
  rounded: string;
@@ -121,13 +121,13 @@ declare const _default$E: {
121
121
  };
122
122
  };
123
123
 
124
- declare const _default$D: {
124
+ declare const _default$F: {
125
125
  wrapper: string;
126
126
  ring: string;
127
127
  margin: string;
128
128
  };
129
129
 
130
- declare const _default$C: {
130
+ declare const _default$E: {
131
131
  base: string;
132
132
  rounded: string;
133
133
  font: string;
@@ -161,7 +161,7 @@ declare const _default$C: {
161
161
  };
162
162
  };
163
163
 
164
- declare const _default$B: {
164
+ declare const _default$D: {
165
165
  base: string;
166
166
  font: string;
167
167
  rounded: string;
@@ -242,7 +242,7 @@ declare const _default$B: {
242
242
  };
243
243
  };
244
244
 
245
- declare const _default$A: {
245
+ declare const _default$C: {
246
246
  wrapper: {
247
247
  horizontal: string;
248
248
  vertical: string;
@@ -343,7 +343,7 @@ declare const _default$A: {
343
343
  };
344
344
  };
345
345
 
346
- declare const _default$z: {
346
+ declare const _default$B: {
347
347
  wrapper: string;
348
348
  base: string;
349
349
  background: string;
@@ -378,7 +378,7 @@ declare const _default$z: {
378
378
  };
379
379
  };
380
380
 
381
- declare const _default$y: {
381
+ declare const _default$A: {
382
382
  wrapper: string;
383
383
  container: string;
384
384
  trigger: string;
@@ -406,7 +406,7 @@ declare const _default$y: {
406
406
  };
407
407
  avatar: {
408
408
  base: string;
409
- size: "3xs";
409
+ size: "2xs";
410
410
  };
411
411
  label: string;
412
412
  shortcuts: string;
@@ -423,6 +423,10 @@ declare const _default$y: {
423
423
  placement: string;
424
424
  strategy: string;
425
425
  };
426
+ default: {
427
+ openDelay: number;
428
+ closeDelay: number;
429
+ };
426
430
  arrow: {
427
431
  ring: string;
428
432
  background: string;
@@ -433,7 +437,7 @@ declare const _default$y: {
433
437
  };
434
438
  };
435
439
 
436
- declare const _default$x: {
440
+ declare const _default$z: {
437
441
  wrapper: string;
438
442
  item: {
439
443
  base: string;
@@ -454,7 +458,7 @@ declare const _default$x: {
454
458
  };
455
459
  };
456
460
 
457
- declare const _default$w: {
461
+ declare const _default$y: {
458
462
  wrapper: string;
459
463
  inner: string;
460
464
  title: string;
@@ -495,7 +499,7 @@ declare const _default$w: {
495
499
  };
496
500
  };
497
501
 
498
- declare const _default$v: {
502
+ declare const _default$x: {
499
503
  base: string;
500
504
  padding: string;
501
505
  size: {
@@ -512,7 +516,7 @@ declare const _default$v: {
512
516
  };
513
517
  };
514
518
 
515
- declare const _default$u: {
519
+ declare const _default$w: {
516
520
  wrapper: string;
517
521
  indicator: {
518
522
  container: {
@@ -587,7 +591,7 @@ declare const _default$u: {
587
591
  };
588
592
  };
589
593
 
590
- declare const _default$t: {
594
+ declare const _default$v: {
591
595
  wrapper: string;
592
596
  indicator: {
593
597
  container: string;
@@ -664,7 +668,7 @@ declare const _default$t: {
664
668
  };
665
669
  };
666
670
 
667
- declare const _default$s: {
671
+ declare const _default$u: {
668
672
  wrapper: string;
669
673
  base: string;
670
674
  background: string;
@@ -716,7 +720,34 @@ declare const _default$s: {
716
720
  };
717
721
  };
718
722
 
719
- declare const _default$r: {
723
+ declare const _default$t: {
724
+ wrapper: string;
725
+ container: string;
726
+ item: string;
727
+ arrows: {
728
+ wrapper: string;
729
+ };
730
+ indicators: {
731
+ wrapper: string;
732
+ base: string;
733
+ active: string;
734
+ inactive: string;
735
+ };
736
+ default: {
737
+ prevButton: {
738
+ color: "black";
739
+ class: string;
740
+ icon: string;
741
+ };
742
+ nextButton: {
743
+ color: "black";
744
+ class: string;
745
+ icon: string;
746
+ };
747
+ };
748
+ };
749
+
750
+ declare const _default$s: {
720
751
  wrapper: string;
721
752
  base: string;
722
753
  form: string;
@@ -823,7 +854,7 @@ declare const _default$r: {
823
854
  };
824
855
  };
825
856
 
826
- declare const _default$q: {
857
+ declare const _default$r: {
827
858
  container: string;
828
859
  trigger: string;
829
860
  width: string;
@@ -859,7 +890,7 @@ declare const _default$q: {
859
890
  };
860
891
  avatar: {
861
892
  base: string;
862
- size: "3xs";
893
+ size: "2xs";
863
894
  };
864
895
  chip: {
865
896
  base: string;
@@ -887,7 +918,7 @@ declare const _default$q: {
887
918
  };
888
919
  };
889
920
 
890
- declare const _default$p: {
921
+ declare const _default$q: {
891
922
  wrapper: string;
892
923
  label: {
893
924
  wrapper: string;
@@ -912,7 +943,7 @@ declare const _default$p: {
912
943
  };
913
944
  };
914
945
 
915
- declare const _default$o: {
946
+ declare const _default$p: {
916
947
  form: string;
917
948
  default: {
918
949
  size: string;
@@ -1018,7 +1049,7 @@ declare const _default$o: {
1018
1049
  };
1019
1050
  };
1020
1051
 
1021
- declare const _default$n: {
1052
+ declare const _default$o: {
1022
1053
  form: string;
1023
1054
  placeholder: string;
1024
1055
  default: {
@@ -1126,7 +1157,7 @@ declare const _default$n: {
1126
1157
  };
1127
1158
  };
1128
1159
 
1129
- declare const _default$m: {
1160
+ declare const _default$n: {
1130
1161
  select: string;
1131
1162
  input: string;
1132
1163
  required: string;
@@ -1156,7 +1187,7 @@ declare const _default$m: {
1156
1187
  };
1157
1188
  avatar: {
1158
1189
  base: string;
1159
- size: "3xs";
1190
+ size: "2xs";
1160
1191
  };
1161
1192
  chip: {
1162
1193
  base: string;
@@ -1196,7 +1227,7 @@ declare const _default$m: {
1196
1227
  empty: string;
1197
1228
  };
1198
1229
 
1199
- declare const _default$l: {
1230
+ declare const _default$m: {
1200
1231
  wrapper: string;
1201
1232
  legend: string;
1202
1233
  default: {
@@ -1204,7 +1235,7 @@ declare const _default$l: {
1204
1235
  };
1205
1236
  };
1206
1237
 
1207
- declare const _default$k: {
1238
+ declare const _default$l: {
1208
1239
  wrapper: string;
1209
1240
  container: string;
1210
1241
  base: string;
@@ -1222,7 +1253,7 @@ declare const _default$k: {
1222
1253
  };
1223
1254
  };
1224
1255
 
1225
- declare const _default$j: {
1256
+ declare const _default$k: {
1226
1257
  wrapper: string;
1227
1258
  container: string;
1228
1259
  base: string;
@@ -1241,7 +1272,7 @@ declare const _default$j: {
1241
1272
  };
1242
1273
  };
1243
1274
 
1244
- declare const _default$i: {
1275
+ declare const _default$j: {
1245
1276
  base: string;
1246
1277
  rounded: string;
1247
1278
  ring: string;
@@ -1302,7 +1333,7 @@ declare const _default$i: {
1302
1333
  };
1303
1334
  };
1304
1335
 
1305
- declare const _default$h: {
1336
+ declare const _default$i: {
1306
1337
  wrapper: string;
1307
1338
  base: string;
1308
1339
  rounded: string;
@@ -1366,7 +1397,7 @@ declare const _default$h: {
1366
1397
  };
1367
1398
  };
1368
1399
 
1369
- declare const _default$g: {
1400
+ declare const _default$h: {
1370
1401
  base: string;
1371
1402
  background: string;
1372
1403
  divide: string;
@@ -1390,19 +1421,19 @@ declare const _default$g: {
1390
1421
  };
1391
1422
  };
1392
1423
 
1393
- declare const _default$f: {
1424
+ declare const _default$g: {
1394
1425
  base: string;
1395
1426
  padding: string;
1396
1427
  constrained: string;
1397
1428
  };
1398
1429
 
1399
- declare const _default$e: {
1430
+ declare const _default$f: {
1400
1431
  base: string;
1401
1432
  background: string;
1402
1433
  rounded: string;
1403
1434
  };
1404
1435
 
1405
- declare const _default$d: {
1436
+ declare const _default$e: {
1406
1437
  wrapper: {
1407
1438
  base: string;
1408
1439
  horizontal: string;
@@ -1437,7 +1468,7 @@ declare const _default$d: {
1437
1468
  label: string;
1438
1469
  };
1439
1470
 
1440
- declare const _default$c: {
1471
+ declare const _default$d: {
1441
1472
  wrapper: string;
1442
1473
  base: string;
1443
1474
  ring: string;
@@ -1456,12 +1487,13 @@ declare const _default$c: {
1456
1487
  };
1457
1488
  avatar: {
1458
1489
  base: string;
1459
- size: "3xs";
1490
+ size: "2xs";
1460
1491
  };
1461
1492
  badge: {
1462
1493
  base: string;
1463
- active: string;
1464
- inactive: string;
1494
+ color: "gray";
1495
+ variant: "solid";
1496
+ size: "xs";
1465
1497
  };
1466
1498
  divider: {
1467
1499
  wrapper: {
@@ -1470,6 +1502,33 @@ declare const _default$c: {
1470
1502
  };
1471
1503
  };
1472
1504
 
1505
+ declare const _default$c: {
1506
+ wrapper: string;
1507
+ container: string;
1508
+ inner: string;
1509
+ base: string;
1510
+ before: string;
1511
+ after: string;
1512
+ active: string;
1513
+ inactive: string;
1514
+ label: string;
1515
+ icon: {
1516
+ base: string;
1517
+ active: string;
1518
+ inactive: string;
1519
+ };
1520
+ avatar: {
1521
+ base: string;
1522
+ size: "2xs";
1523
+ };
1524
+ badge: {
1525
+ base: string;
1526
+ color: "gray";
1527
+ variant: "solid";
1528
+ size: "xs";
1529
+ };
1530
+ };
1531
+
1473
1532
  declare const _default$b: {
1474
1533
  wrapper: string;
1475
1534
  container: string;
@@ -1518,7 +1577,7 @@ declare const _default$b: {
1518
1577
  };
1519
1578
  avatar: {
1520
1579
  base: string;
1521
- size: "3xs";
1580
+ size: "2xs";
1522
1581
  };
1523
1582
  chip: {
1524
1583
  base: string;
@@ -1723,6 +1782,10 @@ declare const _default$5: {
1723
1782
  popper: {
1724
1783
  strategy: string;
1725
1784
  };
1785
+ default: {
1786
+ openDelay: number;
1787
+ closeDelay: number;
1788
+ };
1726
1789
  arrow: {
1727
1790
  base: string;
1728
1791
  ring: string;
@@ -1766,6 +1829,10 @@ declare const _default$4: {
1766
1829
  popper: {
1767
1830
  strategy: string;
1768
1831
  };
1832
+ default: {
1833
+ openDelay: number;
1834
+ closeDelay: number;
1835
+ };
1769
1836
  arrow: {
1770
1837
  base: string;
1771
1838
  ring: string;
@@ -1865,7 +1932,7 @@ declare const _default$1: {
1865
1932
  };
1866
1933
 
1867
1934
  declare namespace config {
1868
- export { _default$x as accordion, _default$w as alert, _default$E as avatar, _default$D as avatarGroup, _default$C as badge, _default$8 as breadcrumb, _default$B as button, _default$A as buttonGroup, _default$g as card, _default$j as checkbox, _default$z as chip, _default$b as commandPalette, _default$f as container, _default$3 as contextMenu, _default$d as divider, _default$y as dropdown, _default$p as formGroup, _default$r as input, _default$q as inputMenu, _default$v as kbd, _default$t as meter, _default$s as meterGroup, _default$7 as modal, _default$2 as notification, _default$1 as notifications, _default$a as pagination, _default$4 as popover, _default$u as progress, _default$k as radio, _default$l as radioGroup, _default$h as range, _default$n as select, _default$m as selectMenu, _default$e as skeleton, _default$6 as slideover, _default$F as table, _default$9 as tabs, _default$o as textarea, _default$i as toggle, _default$5 as tooltip, _default$c as verticalNavigation };
1935
+ export { _default$z as accordion, _default$y as alert, _default$G as avatar, _default$F as avatarGroup, _default$E as badge, _default$8 as breadcrumb, _default$D as button, _default$C as buttonGroup, _default$h as card, _default$t as carousel, _default$k as checkbox, _default$B as chip, _default$b as commandPalette, _default$g as container, _default$3 as contextMenu, _default$e as divider, _default$A as dropdown, _default$q as formGroup, _default$c as horizontalNavigation, _default$s as input, _default$r as inputMenu, _default$x as kbd, _default$v as meter, _default$u as meterGroup, _default$7 as modal, _default$2 as notification, _default$1 as notifications, _default$a as pagination, _default$4 as popover, _default$w as progress, _default$l as radio, _default$m as radioGroup, _default$i as range, _default$o as select, _default$n as selectMenu, _default$f as skeleton, _default$6 as slideover, _default$H as table, _default$9 as tabs, _default$p as textarea, _default$j as toggle, _default$5 as tooltip, _default$d as verticalNavigation };
1869
1936
  }
1870
1937
 
1871
1938
  type Strategy = 'merge' | 'override'
@@ -1902,6 +1969,10 @@ interface ModuleOptions {
1902
1969
  global?: boolean;
1903
1970
  icons: CollectionNames[] | 'all' | IconsPluginOptions;
1904
1971
  safelistColors?: string[];
1972
+ /**
1973
+ * Disables the global css styles added by the module.
1974
+ */
1975
+ disableGlobalStyles?: boolean;
1905
1976
  }
1906
1977
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
1907
1978
 
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/ui",
3
- "version": "2.12.2",
3
+ "version": "2.13.0",
4
4
  "configKey": "ui",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.0.0-rc.8"
package/dist/module.mjs CHANGED
@@ -14,7 +14,7 @@ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
14
14
  const __dirname = __cjs_path__.dirname(__filename);
15
15
  const require = __cjs_mod__.createRequire(import.meta.url);
16
16
  const name = "@nuxt/ui";
17
- const version = "2.12.2";
17
+ const version = "2.13.0";
18
18
 
19
19
  function omit(object, keysToOmit) {
20
20
  const result = { ...object };
@@ -319,7 +319,8 @@ const module = defineNuxtModule({
319
319
  defaults: {
320
320
  prefix: "U",
321
321
  icons: ["heroicons"],
322
- safelistColors: ["primary"]
322
+ safelistColors: ["primary"],
323
+ disableGlobalStyles: false
323
324
  },
324
325
  async setup(options, nuxt) {
325
326
  const { resolve } = createResolver(import.meta.url);
@@ -327,7 +328,9 @@ const module = defineNuxtModule({
327
328
  nuxt.options.build.transpile.push(runtimeDir);
328
329
  nuxt.options.build.transpile.push("@popperjs/core", "@headlessui/vue");
329
330
  nuxt.options.alias["#ui"] = runtimeDir;
330
- nuxt.options.css.push(resolve(runtimeDir, "ui.css"));
331
+ if (!options.disableGlobalStyles) {
332
+ nuxt.options.css.push(resolve(runtimeDir, "ui.css"));
333
+ }
331
334
  nuxt.hook("tailwindcss:config", function(tailwindConfig) {
332
335
  tailwindConfig.theme = tailwindConfig.theme || {};
333
336
  tailwindConfig.theme.extend = tailwindConfig.theme.extend || {};
@@ -81,11 +81,11 @@ declare const _default: import("vue").DefineComponent<{
81
81
  default: () => {};
82
82
  };
83
83
  to: {
84
- readonly type: PropType<import("vue-router").RouteLocationRaw>;
84
+ readonly type: PropType<RouteLocationRaw>;
85
85
  readonly default: undefined;
86
86
  };
87
87
  href: {
88
- readonly type: PropType<import("vue-router").RouteLocationRaw>;
88
+ readonly type: PropType<RouteLocationRaw>;
89
89
  readonly default: undefined;
90
90
  };
91
91
  target: {
@@ -227,11 +227,11 @@ declare const _default: import("vue").DefineComponent<{
227
227
  default: () => {};
228
228
  };
229
229
  to: {
230
- readonly type: PropType<import("vue-router").RouteLocationRaw>;
230
+ readonly type: PropType<RouteLocationRaw>;
231
231
  readonly default: undefined;
232
232
  };
233
233
  href: {
234
- readonly type: PropType<import("vue-router").RouteLocationRaw>;
234
+ readonly type: PropType<RouteLocationRaw>;
235
235
  readonly default: undefined;
236
236
  };
237
237
  target: {
@@ -299,8 +299,8 @@ declare const _default: import("vue").DefineComponent<{
299
299
  trailingIcon: string;
300
300
  trailing: boolean;
301
301
  square: boolean;
302
- to: import("vue-router").RouteLocationRaw;
303
- href: import("vue-router").RouteLocationRaw;
302
+ to: RouteLocationRaw;
303
+ href: RouteLocationRaw;
304
304
  target: (string & {}) | "_blank" | "_parent" | "_self" | "_top" | null;
305
305
  rel: string | null;
306
306
  noRel: boolean;
@@ -0,0 +1,149 @@
1
+ <template>
2
+ <div :class="ui.wrapper" v-bind="attrs">
3
+ <div ref="carouselRef" :class="ui.container" class="no-scrollbar">
4
+ <div
5
+ v-for="(item, index) in items"
6
+ :key="index"
7
+ :class="ui.item"
8
+ >
9
+ <slot :item="item" :index="index" />
10
+ </div>
11
+ </div>
12
+
13
+ <div v-if="arrows" :class="ui.arrows.wrapper">
14
+ <slot name="prev" :on-click="onClickPrev" :disabled="isFirst">
15
+ <UButton
16
+ v-if="prevButton"
17
+ :disabled="isFirst"
18
+ v-bind="{ ...ui.default.prevButton, ...prevButton }"
19
+ :class="twMerge(ui.default.prevButton.class, prevButton?.class)"
20
+ aria-label="Prev"
21
+ @click="onClickPrev"
22
+ />
23
+ </slot>
24
+
25
+ <slot name="next" :on-click="onClickNext" :disabled="isLast">
26
+ <UButton
27
+ v-if="nextButton"
28
+ :disabled="isLast"
29
+ v-bind="{ ...ui.default.nextButton, ...nextButton }"
30
+ :class="twMerge(ui.default.nextButton.class, nextButton?.class)"
31
+ aria-label="Next"
32
+ @click="onClickNext"
33
+ />
34
+ </slot>
35
+ </div>
36
+
37
+ <div v-if="indicators" :class="ui.indicators.wrapper">
38
+ <template v-for="index in indicatorsCount" :key="index">
39
+ <slot name="indicator" :on-click="onClick" :active="index === currentIndex" :index="index">
40
+ <button
41
+ type="button"
42
+ :class="[
43
+ ui.indicators.base,
44
+ index === currentIndex ? ui.indicators.active : ui.indicators.inactive
45
+ ]"
46
+ :aria-label="`set slide ${index}`"
47
+ @click="onClick(index)"
48
+ />
49
+ </slot>
50
+ </template>
51
+ </div>
52
+ </div>
53
+ </template>
54
+
55
+ <script>
56
+ import { ref, toRef, toRefs, computed, defineComponent } from "vue";
57
+ import { twMerge } from "tailwind-merge";
58
+ import { mergeConfig } from "../../utils";
59
+ import UButton from "../elements/Button.vue";
60
+ import { useUI } from "../../composables/useUI";
61
+ import { useCarouselScroll } from "../../composables/useCarouselScroll";
62
+ import { useScroll, useResizeObserver, useElementSize } from "@vueuse/core";
63
+ import appConfig from "#build/app.config";
64
+ import { carousel } from "#ui/ui.config";
65
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.carousel, carousel);
66
+ export default defineComponent({
67
+ components: {
68
+ UButton
69
+ },
70
+ inheritAttrs: false,
71
+ props: {
72
+ items: {
73
+ type: Array,
74
+ default: () => []
75
+ },
76
+ arrows: {
77
+ type: Boolean,
78
+ default: false
79
+ },
80
+ indicators: {
81
+ type: Boolean,
82
+ default: false
83
+ },
84
+ prevButton: {
85
+ type: Object,
86
+ default: () => config.default.prevButton
87
+ },
88
+ nextButton: {
89
+ type: Object,
90
+ default: () => config.default.nextButton
91
+ },
92
+ class: {
93
+ type: [String, Object, Array],
94
+ default: () => ""
95
+ },
96
+ ui: {
97
+ type: Object,
98
+ default: void 0
99
+ }
100
+ },
101
+ setup(props) {
102
+ const { ui, attrs } = useUI("carousel", toRef(props, "ui"), config, toRef(props, "class"));
103
+ const carouselRef = ref();
104
+ const itemWidth = ref(0);
105
+ const { x, arrivedState } = useScroll(carouselRef, { behavior: "smooth" });
106
+ const { width: carouselWidth } = useElementSize(carouselRef);
107
+ const { left: isFirst, right: isLast } = toRefs(arrivedState);
108
+ useCarouselScroll(carouselRef);
109
+ useResizeObserver(carouselRef, (entries) => {
110
+ const [entry] = entries;
111
+ itemWidth.value = entry?.target?.firstElementChild?.clientWidth || 0;
112
+ });
113
+ const currentIndex = computed(() => Math.round(x.value / itemWidth.value) + 1);
114
+ const indicatorsCount = computed(() => {
115
+ if (!itemWidth.value) {
116
+ return 0;
117
+ }
118
+ return props.items.length - Math.round(carouselWidth.value / itemWidth.value) + 1;
119
+ });
120
+ function onClickNext() {
121
+ x.value += itemWidth.value;
122
+ }
123
+ function onClickPrev() {
124
+ x.value -= itemWidth.value;
125
+ }
126
+ function onClick(index) {
127
+ x.value = (index - 1) * itemWidth.value;
128
+ }
129
+ return {
130
+ // eslint-disable-next-line vue/no-dupe-keys
131
+ ui,
132
+ attrs,
133
+ isFirst,
134
+ isLast,
135
+ carouselRef,
136
+ indicatorsCount,
137
+ currentIndex,
138
+ onClickNext,
139
+ onClickPrev,
140
+ onClick,
141
+ twMerge
142
+ };
143
+ }
144
+ });
145
+ </script>
146
+
147
+ <style scoped>
148
+ .no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}
149
+ </style>