@max-ts/kit 1.3.1 → 1.4.1

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 (40) hide show
  1. package/lib/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  2. package/lib/components/Autocomplete/styles.css.d.ts +1 -0
  3. package/lib/components/Autocomplete/styles.css.d.ts.map +1 -1
  4. package/lib/components/Autocomplete/types.d.ts +2 -0
  5. package/lib/components/Autocomplete/types.d.ts.map +1 -1
  6. package/lib/components/Carousel/Buttons/Buttons.d.ts +1 -1
  7. package/lib/components/Carousel/Buttons/Buttons.d.ts.map +1 -1
  8. package/lib/components/Carousel/Buttons/styles.css.d.ts +3 -3
  9. package/lib/components/Carousel/Buttons/styles.css.d.ts.map +1 -1
  10. package/lib/components/Carousel/Carousel.d.ts +14 -16
  11. package/lib/components/Carousel/Carousel.d.ts.map +1 -1
  12. package/lib/components/Carousel/CarouselContext.d.ts +3 -5
  13. package/lib/components/Carousel/CarouselContext.d.ts.map +1 -1
  14. package/lib/components/Carousel/Content/Content.d.ts +2 -1
  15. package/lib/components/Carousel/Content/Content.d.ts.map +1 -1
  16. package/lib/components/Carousel/Content/styles.css.d.ts +1 -1
  17. package/lib/components/Carousel/Content/styles.css.d.ts.map +1 -1
  18. package/lib/components/Carousel/Dots/Dots.d.ts +2 -5
  19. package/lib/components/Carousel/Dots/Dots.d.ts.map +1 -1
  20. package/lib/components/Carousel/Dots/useLogic/useLogic.d.ts.map +1 -1
  21. package/lib/components/Carousel/Item/Item.d.ts +2 -1
  22. package/lib/components/Carousel/Item/Item.d.ts.map +1 -1
  23. package/lib/components/Carousel/Item/styles.css.d.ts +1 -0
  24. package/lib/components/Carousel/Item/styles.css.d.ts.map +1 -1
  25. package/lib/components/Carousel/types.d.ts +16 -6
  26. package/lib/components/Carousel/types.d.ts.map +1 -1
  27. package/lib/components/Carousel/useLogic/useLogic.d.ts +13 -13
  28. package/lib/components/Carousel/useLogic/useLogic.d.ts.map +1 -1
  29. package/lib/components/CircularProgress/styles.css.d.ts +1 -1
  30. package/lib/components/Combobox/Combobox.d.ts +2 -2
  31. package/lib/components/Combobox/Combobox.d.ts.map +1 -1
  32. package/lib/components/Combobox/types.d.ts +6 -1
  33. package/lib/components/Combobox/types.d.ts.map +1 -1
  34. package/lib/index.mjs +347 -168
  35. package/lib/stories/Autocomplete.stories.d.ts +1 -0
  36. package/lib/stories/Autocomplete.stories.d.ts.map +1 -1
  37. package/lib/stories/Carousel.stories.d.ts +1 -0
  38. package/lib/stories/Carousel.stories.d.ts.map +1 -1
  39. package/lib/styles.css +157 -95
  40. package/package.json +1 -2
package/lib/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Accordion, Checkbox } from "@base-ui/react";
3
3
  import clsx_0, { clsx } from "clsx";
4
- import { ArrowDownNarrowWide, ArrowDownUp, ArrowDownWideNarrow, Calendar1, Check, CheckIcon, ChevronDown, ChevronDownIcon, ChevronLeft, ChevronRight, ChevronRightIcon, ChevronUp, CircleCheck, CircleIcon, Copy, Ellipsis as external_lucide_react_Ellipsis, EllipsisVertical, Info, MoreHorizontalIcon, OctagonAlert, PanelLeftIcon, TriangleAlert, XIcon } from "lucide-react";
4
+ import { ArrowDownNarrowWide, ArrowDownUp, ArrowDownWideNarrow, ArrowLeft, ArrowRight, Calendar1, Check, CheckIcon, ChevronDown, ChevronDownIcon, ChevronLeft, ChevronRight, ChevronRightIcon, ChevronUp, CircleCheck, CircleIcon, Copy, Ellipsis as external_lucide_react_Ellipsis, EllipsisVertical, Info, MoreHorizontalIcon, OctagonAlert, PanelLeftIcon, TriangleAlert, XIcon } from "lucide-react";
5
5
  import { AlertDialog } from "@base-ui/react/alert-dialog";
6
6
  import { Button } from "@base-ui/react/button";
7
7
  import react, { createContext, createElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
@@ -12,7 +12,6 @@ import { useRender } from "@base-ui/react/use-render";
12
12
  import { Separator as separator_Separator } from "@base-ui/react/separator";
13
13
  import { DayPicker } from "react-day-picker";
14
14
  import { ru } from "react-day-picker/locale";
15
- import embla_carousel_react from "embla-carousel-react";
16
15
  import { Collapsible } from "@base-ui/react/collapsible";
17
16
  import { Popover } from "@base-ui/react/popover";
18
17
  import { Tooltip } from "@base-ui/react/tooltip";
@@ -272,6 +271,49 @@ AlertDialog_AlertDialog.Title = Title;
272
271
  AlertDialog_AlertDialog.Description = Description;
273
272
  AlertDialog_AlertDialog.Action = Action;
274
273
  AlertDialog_AlertDialog.Cancel = Cancel;
274
+ var circle = 'style__m6b9n24';
275
+ var colors = {
276
+ primary: 'primary__m6b9n27',
277
+ secondary: 'secondary__m6b9n28',
278
+ inherit: 'inherit__m6b9n29'
279
+ };
280
+ var styles_css_root = 'style__m6b9n22';
281
+ var svg = 'style__m6b9n23';
282
+ var variants = {
283
+ determinate: 'determinate__m6b9n25',
284
+ indeterminate: 'indeterminate__m6b9n26'
285
+ };
286
+ const CircularProgress = ({ size = 30, thickness = 2.2, color = 'primary', value = 0, variant = 'indeterminate', className })=>{
287
+ const radius = (size - thickness) / 2;
288
+ const circumference = 2 * Math.PI * radius;
289
+ const dashOffset = 'determinate' === variant ? circumference * (1 - value / 100) : 0.25 * circumference;
290
+ return /*#__PURE__*/ jsx("div", {
291
+ className: clsx_0(styles_css_root, variants[variant], colors[color], className),
292
+ style: {
293
+ width: size,
294
+ height: size
295
+ },
296
+ children: /*#__PURE__*/ jsxs("svg", {
297
+ className: svg,
298
+ viewBox: `0 0 ${size} ${size}`,
299
+ children: [
300
+ /*#__PURE__*/ jsx("title", {
301
+ children: "Progress bar"
302
+ }),
303
+ /*#__PURE__*/ jsx("circle", {
304
+ className: clsx_0(circle, 'determinate' === variant && variants.determinate),
305
+ cx: size / 2,
306
+ cy: size / 2,
307
+ r: radius,
308
+ fill: "none",
309
+ strokeWidth: thickness,
310
+ strokeDasharray: circumference,
311
+ strokeDashoffset: dashOffset
312
+ })
313
+ ]
314
+ })
315
+ });
316
+ };
275
317
  var addon = 'style__1rv6t1j1';
276
318
  var addonAlign = {
277
319
  'inline-start': 'inline-start__1rv6t1j2',
@@ -288,13 +330,13 @@ var buttonSize = {
288
330
  };
289
331
  var control = 'style__1rv6t1jc';
290
332
  var input = 'style__1rv6t1jd';
291
- var styles_css_root = 'style__1rv6t1j0';
333
+ var InputGroup_styles_css_root = 'style__1rv6t1j0';
292
334
  var styles_css_text = 'style__1rv6t1jb';
293
335
  var styles_css_textarea = 'style__1rv6t1je';
294
336
  function InputGroup({ className, ...props }) {
295
337
  return /*#__PURE__*/ jsx("div", {
296
338
  "data-slot": "input-group",
297
- className: clsx(styles_css_root, className),
339
+ className: clsx(InputGroup_styles_css_root, className),
298
340
  ...props
299
341
  });
300
342
  }
@@ -398,7 +440,7 @@ function Clear({ className, children, ...props }) {
398
440
  })
399
441
  });
400
442
  }
401
- function Combobox_Input({ className, children, disabled = false, showTrigger = true, showClear = false, ...props }) {
443
+ function Combobox_Input({ className, children, disabled = false, error: _error, helperText: _helperText, showTrigger = true, showClear = false, ...props }) {
402
444
  return /*#__PURE__*/ jsxs(Combobox.InputGroup, {
403
445
  render: /*#__PURE__*/ jsx(InputGroup, {
404
446
  className: clsx(inputGroup, className)
@@ -522,7 +564,7 @@ function Chip({ className, children, showRemove = true, ...props }) {
522
564
  ]
523
565
  });
524
566
  }
525
- function ChipsInput({ className, ...props }) {
567
+ function ChipsInput({ className, error: _error, helperText: _helperText, ...props }) {
526
568
  return /*#__PURE__*/ jsx(Combobox.Input, {
527
569
  "data-slot": "combobox-chip-input",
528
570
  className: clsx(chipsInput, className),
@@ -566,7 +608,7 @@ var alignments = {
566
608
  right: 'right__1sba6zom',
567
609
  justify: 'justify__1sba6zon'
568
610
  };
569
- var colors = {
611
+ var styles_css_colors = {
570
612
  primary: 'primary__1sba6zoc',
571
613
  secondary: 'secondary__1sba6zod',
572
614
  disabled: 'disabled__1sba6zoe',
@@ -591,7 +633,7 @@ var transforms = {
591
633
  uppercase: 'uppercase__1sba6zov',
592
634
  capitalize: 'capitalize__1sba6zow'
593
635
  };
594
- var variants = {
636
+ var styles_css_variants = {
595
637
  h1: 'h1__1sba6zo0',
596
638
  h2: 'h2__1sba6zo1',
597
639
  h3: 'h3__1sba6zo2',
@@ -628,7 +670,7 @@ const VARIANT_COMPONENT_MAP = {
628
670
  const Typography = ({ className, variant = 'body1', component, color = 'primary', align = 'left', display = 'inline', weight = 'normal', transform, decoration = 'none', gutterBottom, children, ...props })=>{
629
671
  const Component = component || VARIANT_COMPONENT_MAP[variant || 'body1'];
630
672
  return /*#__PURE__*/ jsx(Component, {
631
- className: clsx(decorations[decoration], variants[variant], colors[color], weights[weight], transform && transforms[transform], displays[display], alignments[align], {
673
+ className: clsx(decorations[decoration], styles_css_variants[variant], styles_css_colors[color], weights[weight], transform && transforms[transform], displays[display], alignments[align], {
632
674
  [gutterBottomClass]: gutterBottom
633
675
  }, className),
634
676
  ...props,
@@ -641,11 +683,12 @@ var styles_css_field = 'style__17arfox0';
641
683
  var styles_css_fullWidth = 'style__17arfox1';
642
684
  var styles_css_helperText = 'style__17arfox3';
643
685
  var styles_css_label = 'style__17arfox2';
686
+ var styles_css_loading = 'style__17arfox6';
644
687
  function defaultGetOptionLabel(option) {
645
688
  return 'string' == typeof option ? option : String(option);
646
689
  }
647
690
  function Autocomplete(props) {
648
- const { className, contentClassName, defaultValue, disabled = false, error = false, fullWidth = false, getOptionLabel = defaultGetOptionLabel, getOptionValue = getOptionLabel, helperText, id, inputClassName, isOptionEqualToValue, label, labelClassName, multiple, noOptionsText = 'No results found', onChange, options, placeholder, renderOption, required, style, value, ...rootProps } = props;
691
+ const { className, contentClassName, defaultValue, disabled = false, error = false, fullWidth = false, getOptionLabel = defaultGetOptionLabel, getOptionValue = getOptionLabel, helperText, id, inputClassName, isOptionEqualToValue, isLoading = false, label, labelClassName, loadingText, multiple, noOptionsText = 'No results found', onChange, options, placeholder, renderOption, required, style, value, ...rootProps } = props;
649
692
  const generatedId = useId();
650
693
  const inputId = id ?? (label ? generatedId : void 0);
651
694
  const anchor = useComboboxAnchor();
@@ -715,17 +758,28 @@ function Autocomplete(props) {
715
758
  [styles_css_fullWidth]: fullWidth
716
759
  }, inputClassName)
717
760
  }),
718
- /*#__PURE__*/ jsxs(Combobox_Combobox.Content, {
761
+ /*#__PURE__*/ jsx(Combobox_Combobox.Content, {
719
762
  anchor: multiple ? anchor : void 0,
720
763
  className: contentClassName,
721
- children: [
722
- /*#__PURE__*/ jsx(Combobox_Combobox.Empty, {
723
- children: noOptionsText
724
- }),
725
- /*#__PURE__*/ jsx(Combobox_Combobox.List, {
726
- children: renderItem
764
+ children: isLoading ? /*#__PURE__*/ jsx("div", {
765
+ "data-slot": "autocomplete-loading",
766
+ className: styles_css_loading,
767
+ role: "status",
768
+ children: loadingText ?? /*#__PURE__*/ jsx(CircularProgress, {
769
+ thickness: 1.6,
770
+ size: 18,
771
+ color: "inherit"
727
772
  })
728
- ]
773
+ }) : /*#__PURE__*/ jsxs(Fragment, {
774
+ children: [
775
+ /*#__PURE__*/ jsx(Combobox_Combobox.Empty, {
776
+ children: noOptionsText
777
+ }),
778
+ /*#__PURE__*/ jsx(Combobox_Combobox.List, {
779
+ children: renderItem
780
+ })
781
+ ]
782
+ })
729
783
  })
730
784
  ]
731
785
  }),
@@ -1154,52 +1208,62 @@ function useCarousel() {
1154
1208
  if (!context) throw new Error('useCarousel must be used within a <Carousel />');
1155
1209
  return context;
1156
1210
  }
1157
- var next = 'style__2d6ocq1 style__2d6ocq0';
1158
- var orientations = {
1159
- horizontal: 'horizontal__2d6ocq3',
1160
- vertical: 'vertical__2d6ocq4'
1211
+ var buttonNext = {
1212
+ horizontal: 'horizontal__2d6ocq2 style__2d6ocq0',
1213
+ vertical: 'vertical__2d6ocq3 style__2d6ocq0'
1214
+ };
1215
+ var buttonPrev = {
1216
+ horizontal: 'horizontal__2d6ocq4 style__2d6ocq0',
1217
+ vertical: 'vertical__2d6ocq5 style__2d6ocq0'
1161
1218
  };
1162
- var prev = 'style__2d6ocq2 style__2d6ocq0';
1163
- function Buttons({ className, ...props }) {
1219
+ var iconWrapper = 'style__2d6ocq1';
1220
+ function Arrows({ className, ...props }) {
1164
1221
  const { orientation = 'horizontal', canScrollNext, scrollNext, canScrollPrev, scrollPrev } = useCarousel();
1165
1222
  return /*#__PURE__*/ jsxs(Fragment, {
1166
1223
  children: [
1167
1224
  /*#__PURE__*/ jsx("button", {
1168
- className: clsx(next, orientations[orientation]),
1225
+ className: clsx(buttonPrev[orientation], className),
1169
1226
  type: "button",
1170
- "data-slot": "carousel-next",
1171
- disabled: !canScrollNext,
1172
- onClick: scrollNext,
1227
+ "data-slot": "carousel-previous",
1228
+ "aria-label": "Previous slide",
1229
+ disabled: !canScrollPrev,
1230
+ onClick: scrollPrev,
1173
1231
  ...props,
1174
- children: 'horizontal' === orientation ? /*#__PURE__*/ jsx(ChevronRight, {}) : /*#__PURE__*/ jsx(ChevronDown, {})
1232
+ children: /*#__PURE__*/ jsx("span", {
1233
+ className: iconWrapper,
1234
+ children: /*#__PURE__*/ jsx(ArrowLeft, {})
1235
+ })
1175
1236
  }),
1176
1237
  /*#__PURE__*/ jsx("button", {
1177
1238
  type: "button",
1178
- className: clsx(prev, orientations[orientation]),
1179
- "data-slot": "carousel-previous",
1180
- disabled: !canScrollPrev,
1181
- onClick: scrollPrev,
1239
+ className: clsx(buttonNext[orientation], className),
1240
+ "data-slot": "carousel-next",
1241
+ "aria-label": "Next slide",
1242
+ "aria-disabled": !canScrollNext,
1243
+ disabled: !canScrollNext,
1244
+ onClick: scrollNext,
1182
1245
  ...props,
1183
- children: 'horizontal' === orientation ? /*#__PURE__*/ jsx(ChevronLeft, {}) : /*#__PURE__*/ jsx(ChevronUp, {})
1246
+ children: /*#__PURE__*/ jsx("span", {
1247
+ className: iconWrapper,
1248
+ children: /*#__PURE__*/ jsx(ArrowRight, {})
1249
+ })
1184
1250
  })
1185
1251
  ]
1186
1252
  });
1187
1253
  }
1188
- var styles_css_orientations = {
1254
+ var Content_styles_css_content = 'style__i1lems0';
1255
+ var orientations = {
1189
1256
  horizontal: 'horizontal__i1lems1',
1190
1257
  vertical: 'vertical__i1lems2'
1191
1258
  };
1192
- var wrapper = 'style__i1lems0';
1193
- function Content_Content(props) {
1259
+ function Content_Content({ className, ...props }) {
1194
1260
  const { carouselRef, orientation = 'horizontal' } = useCarousel();
1195
1261
  return /*#__PURE__*/ jsx("div", {
1196
- className: wrapper,
1262
+ className: clsx(Content_styles_css_content, orientations[orientation], className),
1197
1263
  ref: carouselRef,
1198
1264
  "data-slot": "carousel-content",
1199
- children: /*#__PURE__*/ jsx("div", {
1200
- className: styles_css_orientations[orientation],
1201
- ...props
1202
- })
1265
+ "data-orientation": orientation,
1266
+ ...props
1203
1267
  });
1204
1268
  }
1205
1269
  var dotButton = {
@@ -1207,7 +1271,7 @@ var dotButton = {
1207
1271
  vertical: 'vertical__e2zpp65 style__e2zpp63'
1208
1272
  };
1209
1273
  var styles_css_selected = 'style__e2zpp66';
1210
- var styles_css_wrapper = {
1274
+ var wrapper = {
1211
1275
  horizontal: 'horizontal__e2zpp61 style__e2zpp60',
1212
1276
  vertical: 'vertical__e2zpp62 style__e2zpp60'
1213
1277
  };
@@ -1215,24 +1279,23 @@ const useLogic = (api)=>{
1215
1279
  const [selectedIndex, setSelectedIndex] = useState(0);
1216
1280
  const [scrollSnaps, setScrollSnaps] = useState([]);
1217
1281
  const onDotButtonClick = useCallback((index)=>{
1218
- if (!api) return;
1219
1282
  api.scrollTo(index);
1220
1283
  }, [
1221
1284
  api
1222
1285
  ]);
1223
1286
  const onInit = useCallback((api)=>{
1224
- if (!api) return;
1225
1287
  setScrollSnaps(api.scrollSnapList());
1226
1288
  }, []);
1227
1289
  const onSelect = useCallback((api)=>{
1228
- if (!api) return;
1229
1290
  setSelectedIndex(api.selectedScrollSnap());
1230
1291
  }, []);
1231
1292
  useEffect(()=>{
1232
- if (!api) return;
1233
1293
  onInit(api);
1234
1294
  onSelect(api);
1235
1295
  api.on('reInit', onInit).on('reInit', onSelect).on('select', onSelect);
1296
+ return ()=>{
1297
+ api.off('reInit', onInit).off('reInit', onSelect).off('select', onSelect);
1298
+ };
1236
1299
  }, [
1237
1300
  api,
1238
1301
  onInit,
@@ -1244,12 +1307,15 @@ const useLogic = (api)=>{
1244
1307
  onDotButtonClick
1245
1308
  };
1246
1309
  };
1247
- const Dots = ({ api, orientation })=>{
1310
+ const Dots = ({ className, ...props })=>{
1311
+ const { api, orientation } = useCarousel();
1248
1312
  const { selectedIndex, scrollSnaps, onDotButtonClick } = useLogic(api);
1249
1313
  return /*#__PURE__*/ jsx("div", {
1250
- className: styles_css_wrapper[orientation],
1314
+ className: clsx(wrapper[orientation], className),
1315
+ ...props,
1251
1316
  children: scrollSnaps.map((number, index)=>/*#__PURE__*/ jsx("button", {
1252
1317
  type: "button",
1318
+ "aria-label": "Carousel Dots",
1253
1319
  className: clsx(dotButton[orientation], {
1254
1320
  [styles_css_selected]: index === selectedIndex
1255
1321
  }),
@@ -1258,51 +1324,221 @@ const Dots = ({ api, orientation })=>{
1258
1324
  });
1259
1325
  };
1260
1326
  var Item_styles_css_item = 'style__1gif6yr0';
1261
- function Item_Item(props) {
1327
+ var styles_css_orientations = {
1328
+ horizontal: 'horizontal__1gif6yr1',
1329
+ vertical: 'vertical__1gif6yr2'
1330
+ };
1331
+ function Item_Item({ className, ...props }) {
1332
+ const { orientation = 'horizontal' } = useCarousel();
1262
1333
  return /*#__PURE__*/ jsx("div", {
1263
- className: Item_styles_css_item,
1264
- role: "presentation",
1334
+ className: clsx(Item_styles_css_item, styles_css_orientations[orientation], className),
1335
+ role: "group",
1265
1336
  "aria-roledescription": "slide",
1337
+ "data-orientation": orientation,
1266
1338
  "data-slot": "carousel-item",
1267
1339
  ...props
1268
1340
  });
1269
1341
  }
1270
1342
  var styles_css_rootClass = 'Carousel__1jbydv50';
1271
- const useLogic_useLogic = ({ orientation = 'horizontal', opts, setApi, plugins, data, showDots, showArrows })=>{
1272
- const [carouselRef, api] = embla_carousel_react({
1273
- ...opts,
1274
- axis: 'horizontal' === orientation ? 'x' : 'y'
1275
- }, plugins);
1343
+ const useLogic_useLogic = ({ orientation = 'horizontal', align = 'center', setApi })=>{
1344
+ const resolvedOrientation = orientation;
1345
+ const resolvedAlign = align;
1346
+ const viewportRef = useRef(null);
1347
+ const resizeObserverRef = useRef(null);
1348
+ const mutationObserverRef = useRef(null);
1349
+ const observedSlidesRef = useRef([]);
1350
+ const orientationRef = useRef(resolvedOrientation);
1351
+ const alignRef = useRef(resolvedAlign);
1352
+ const selectedIndexRef = useRef(0);
1353
+ const canScrollPrevRef = useRef(false);
1354
+ const canScrollNextRef = useRef(false);
1355
+ const scrollSnapsRef = useRef([]);
1356
+ const listenersRef = useRef({
1357
+ reInit: new Set(),
1358
+ select: new Set()
1359
+ });
1276
1360
  const [canScrollPrev, setCanScrollPrev] = useState(false);
1277
1361
  const [canScrollNext, setCanScrollNext] = useState(false);
1278
- const isShowButtons = Boolean(showArrows && data.length > 1);
1279
- const isShowDots = Boolean(showDots && data.length > 1);
1280
- const onSelect = useCallback((api)=>{
1281
- if (!api) return;
1282
- setCanScrollPrev(api.canScrollPrev());
1283
- setCanScrollNext(api.canScrollNext());
1362
+ const getSlides = useCallback(()=>{
1363
+ if (!viewportRef.current) return [];
1364
+ return Array.from(viewportRef.current.querySelectorAll('[data-slot="carousel-item"]'));
1284
1365
  }, []);
1285
- const onDotButtonClick = useCallback((index)=>{
1286
- if (!api) return;
1287
- api.scrollTo(index);
1366
+ const getTargetFor = useCallback((index)=>{
1367
+ const viewport = viewportRef.current;
1368
+ if (!viewport) return 0;
1369
+ const slide = getSlides()[index];
1370
+ if (!slide) return 0;
1371
+ const isHorizontal = 'horizontal' === orientationRef.current;
1372
+ const viewportSize = isHorizontal ? viewport.clientWidth : viewport.clientHeight;
1373
+ const slideSize = isHorizontal ? slide.offsetWidth : slide.offsetHeight;
1374
+ const slideStart = isHorizontal ? slide.offsetLeft : slide.offsetTop;
1375
+ let target = slideStart;
1376
+ if ('center' === alignRef.current) target = slideStart - (viewportSize - slideSize) / 2;
1377
+ else if ('end' === alignRef.current) target = slideStart - (viewportSize - slideSize);
1378
+ const max = isHorizontal ? viewport.scrollWidth - viewport.clientWidth : viewport.scrollHeight - viewport.clientHeight;
1379
+ return Math.max(0, Math.min(target, Math.max(0, max)));
1288
1380
  }, [
1289
- api
1381
+ getSlides
1382
+ ]);
1383
+ const emit = useCallback((event, api)=>{
1384
+ for (const callback of listenersRef.current[event])callback(api);
1385
+ }, []);
1386
+ const rebindSlideObservers = useCallback(()=>{
1387
+ const resizeObserver = resizeObserverRef.current;
1388
+ if (!resizeObserver) return;
1389
+ for (const slide of observedSlidesRef.current)resizeObserver.unobserve(slide);
1390
+ observedSlidesRef.current = getSlides();
1391
+ for (const slide of observedSlidesRef.current)resizeObserver.observe(slide);
1392
+ }, [
1393
+ getSlides
1394
+ ]);
1395
+ const api = useMemo(()=>{
1396
+ const carouselApi = {
1397
+ scrollPrev: ()=>{
1398
+ carouselApi.scrollTo(Math.max(0, selectedIndexRef.current - 1));
1399
+ },
1400
+ scrollNext: ()=>{
1401
+ const lastIndex = getSlides().length - 1;
1402
+ if (lastIndex < 0) return;
1403
+ carouselApi.scrollTo(Math.min(lastIndex, selectedIndexRef.current + 1));
1404
+ },
1405
+ scrollTo: (index, jump = false)=>{
1406
+ const viewport = viewportRef.current;
1407
+ if (!viewport) return;
1408
+ const target = getTargetFor(index);
1409
+ viewport.scrollTo('horizontal' === orientationRef.current ? {
1410
+ left: target,
1411
+ behavior: jump ? 'auto' : 'smooth'
1412
+ } : {
1413
+ top: target,
1414
+ behavior: jump ? 'auto' : 'smooth'
1415
+ });
1416
+ },
1417
+ canScrollNext: ()=>canScrollNextRef.current,
1418
+ canScrollPrev: ()=>canScrollPrevRef.current,
1419
+ selectedScrollSnap: ()=>selectedIndexRef.current,
1420
+ scrollSnapList: ()=>scrollSnapsRef.current,
1421
+ on: (event, callback)=>{
1422
+ listenersRef.current[event].add(callback);
1423
+ return carouselApi;
1424
+ },
1425
+ off: (event, callback)=>{
1426
+ listenersRef.current[event].delete(callback);
1427
+ return carouselApi;
1428
+ },
1429
+ reInit: ()=>{
1430
+ rebindSlideObservers();
1431
+ const slides = getSlides();
1432
+ scrollSnapsRef.current = slides.map((_, index)=>getTargetFor(index));
1433
+ emit('reInit', carouselApi);
1434
+ emit('select', carouselApi);
1435
+ }
1436
+ };
1437
+ return carouselApi;
1438
+ }, [
1439
+ emit,
1440
+ getSlides,
1441
+ getTargetFor,
1442
+ rebindSlideObservers
1443
+ ]);
1444
+ const refresh = useCallback(()=>{
1445
+ const viewport = viewportRef.current;
1446
+ const slides = getSlides();
1447
+ const scrollSnaps = slides.map((_, index)=>getTargetFor(index));
1448
+ scrollSnapsRef.current = scrollSnaps;
1449
+ if (!viewport || 0 === slides.length) {
1450
+ selectedIndexRef.current = 0;
1451
+ canScrollPrevRef.current = false;
1452
+ canScrollNextRef.current = false;
1453
+ setCanScrollPrev(false);
1454
+ setCanScrollNext(false);
1455
+ emit('select', api);
1456
+ return;
1457
+ }
1458
+ const scrollPosition = 'horizontal' === orientationRef.current ? viewport.scrollLeft : viewport.scrollTop;
1459
+ let nearestIndex = 0;
1460
+ let nearestDistance = 1 / 0;
1461
+ for(let index = 0; index < scrollSnaps.length; index += 1){
1462
+ const distance = Math.abs(scrollSnaps[index] - scrollPosition);
1463
+ if (distance < nearestDistance) {
1464
+ nearestDistance = distance;
1465
+ nearestIndex = index;
1466
+ }
1467
+ }
1468
+ selectedIndexRef.current = nearestIndex;
1469
+ canScrollPrevRef.current = nearestIndex > 0;
1470
+ canScrollNextRef.current = nearestIndex < slides.length - 1;
1471
+ setCanScrollPrev(canScrollPrevRef.current);
1472
+ setCanScrollNext(canScrollNextRef.current);
1473
+ emit('select', api);
1474
+ }, [
1475
+ api,
1476
+ emit,
1477
+ getSlides,
1478
+ getTargetFor
1479
+ ]);
1480
+ const handleScroll = useCallback(()=>{
1481
+ refresh();
1482
+ }, [
1483
+ refresh
1484
+ ]);
1485
+ const detachViewport = useCallback(()=>{
1486
+ if (viewportRef.current) viewportRef.current.removeEventListener('scroll', handleScroll);
1487
+ resizeObserverRef.current?.disconnect();
1488
+ mutationObserverRef.current?.disconnect();
1489
+ resizeObserverRef.current = null;
1490
+ mutationObserverRef.current = null;
1491
+ observedSlidesRef.current = [];
1492
+ }, [
1493
+ handleScroll
1494
+ ]);
1495
+ const carouselRef = useCallback((node)=>{
1496
+ if (viewportRef.current === node) return;
1497
+ detachViewport();
1498
+ viewportRef.current = node;
1499
+ if (!node) return void refresh();
1500
+ node.addEventListener('scroll', handleScroll, {
1501
+ passive: true
1502
+ });
1503
+ if ("u" > typeof ResizeObserver) {
1504
+ resizeObserverRef.current = new ResizeObserver(refresh);
1505
+ resizeObserverRef.current.observe(node);
1506
+ }
1507
+ if ("u" > typeof MutationObserver) {
1508
+ mutationObserverRef.current = new MutationObserver(()=>{
1509
+ rebindSlideObservers();
1510
+ refresh();
1511
+ api.reInit();
1512
+ });
1513
+ mutationObserverRef.current.observe(node, {
1514
+ childList: true,
1515
+ subtree: false
1516
+ });
1517
+ }
1518
+ rebindSlideObservers();
1519
+ refresh();
1520
+ }, [
1521
+ api,
1522
+ detachViewport,
1523
+ handleScroll,
1524
+ rebindSlideObservers,
1525
+ refresh
1290
1526
  ]);
1291
1527
  const scrollPrev = useCallback(()=>{
1292
- api?.scrollPrev();
1528
+ api.scrollPrev();
1293
1529
  }, [
1294
1530
  api
1295
1531
  ]);
1296
1532
  const scrollNext = useCallback(()=>{
1297
- api?.scrollNext();
1533
+ api.scrollNext();
1298
1534
  }, [
1299
1535
  api
1300
1536
  ]);
1301
1537
  const handleKeyDown = useCallback((event)=>{
1302
- if ('ArrowLeft' === event.key) {
1538
+ if ('ArrowLeft' === event.key || 'ArrowUp' === event.key) {
1303
1539
  event.preventDefault();
1304
1540
  scrollPrev();
1305
- } else if ('ArrowRight' === event.key) {
1541
+ } else if ('ArrowRight' === event.key || 'ArrowDown' === event.key) {
1306
1542
  event.preventDefault();
1307
1543
  scrollNext();
1308
1544
  }
@@ -1311,23 +1547,25 @@ const useLogic_useLogic = ({ orientation = 'horizontal', opts, setApi, plugins,
1311
1547
  scrollNext
1312
1548
  ]);
1313
1549
  useEffect(()=>{
1314
- if (!api || !setApi) return;
1315
- setApi(api);
1550
+ orientationRef.current = resolvedOrientation;
1551
+ alignRef.current = resolvedAlign;
1552
+ refresh();
1553
+ api.reInit();
1316
1554
  }, [
1317
1555
  api,
1318
- setApi
1556
+ refresh,
1557
+ resolvedAlign,
1558
+ resolvedOrientation
1319
1559
  ]);
1320
1560
  useEffect(()=>{
1321
- if (!api) return;
1322
- onSelect(api);
1323
- api.on('reInit', onSelect);
1324
- api.on('select', onSelect);
1325
- return ()=>{
1326
- api?.off('select', onSelect);
1327
- };
1561
+ setApi?.(api);
1562
+ return ()=>setApi?.(void 0);
1328
1563
  }, [
1329
1564
  api,
1330
- onSelect
1565
+ setApi
1566
+ ]);
1567
+ useEffect(()=>()=>detachViewport(), [
1568
+ detachViewport
1331
1569
  ]);
1332
1570
  return {
1333
1571
  carouselRef,
@@ -1337,54 +1575,38 @@ const useLogic_useLogic = ({ orientation = 'horizontal', opts, setApi, plugins,
1337
1575
  canScrollPrev,
1338
1576
  canScrollNext,
1339
1577
  handleKeyDown,
1340
- opts,
1341
- orientation,
1342
- onDotButtonClick,
1343
- isShowButtons,
1344
- isShowDots,
1345
- data
1578
+ orientation
1346
1579
  };
1347
1580
  };
1348
- function Carousel({ width = '100%', height = '100%', ...props }) {
1349
- const { canScrollNext, canScrollPrev, scrollNext, scrollPrev, api, opts, orientation, carouselRef, handleKeyDown, data, isShowButtons, isShowDots } = useLogic_useLogic(props);
1581
+ function Carousel({ align, children, className, orientation: orientationProp, setApi, ...props }) {
1582
+ const { canScrollNext, canScrollPrev, scrollNext, scrollPrev, api, orientation, carouselRef, handleKeyDown } = useLogic_useLogic({
1583
+ align,
1584
+ orientation: orientationProp,
1585
+ setApi
1586
+ });
1350
1587
  return /*#__PURE__*/ jsx(CarouselContext.Provider, {
1351
1588
  value: {
1352
1589
  carouselRef,
1353
1590
  api,
1354
- opts,
1355
- orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
1591
+ orientation,
1356
1592
  scrollPrev,
1357
1593
  scrollNext,
1358
1594
  canScrollPrev,
1359
1595
  canScrollNext
1360
1596
  },
1361
- children: /*#__PURE__*/ jsxs("div", {
1597
+ children: /*#__PURE__*/ jsx("section", {
1362
1598
  onKeyDownCapture: handleKeyDown,
1363
- className: clsx(styles_css_rootClass, props.className),
1599
+ className: clsx(styles_css_rootClass, className),
1364
1600
  "data-slot": "carousel",
1365
- style: {
1366
- width,
1367
- height
1368
- },
1369
- children: [
1370
- /*#__PURE__*/ jsx(Content_Content, {
1371
- style: {
1372
- width,
1373
- height
1374
- },
1375
- children: data.map((item)=>/*#__PURE__*/ jsx(Item_Item, {
1376
- children: props.renderItem(item)
1377
- }, `${item[props.keyId]}`))
1378
- }),
1379
- isShowButtons && /*#__PURE__*/ jsx(Buttons, {}),
1380
- isShowDots && /*#__PURE__*/ jsx(Dots, {
1381
- api: api,
1382
- orientation: orientation
1383
- })
1384
- ]
1601
+ ...props,
1602
+ children: children
1385
1603
  })
1386
1604
  });
1387
1605
  }
1606
+ Carousel.Content = Content_Content;
1607
+ Carousel.Item = Item_Item;
1608
+ Carousel.Arrows = Arrows;
1609
+ Carousel.Dots = Dots;
1388
1610
  var checkbox_css_icon = 'style__b7yo4k2';
1389
1611
  var indicator = 'style__b7yo4k1';
1390
1612
  var checkbox_css_root = 'style__b7yo4k0';
@@ -1399,49 +1621,6 @@ const Checkbox_Checkbox = ({ className, ...props })=>/*#__PURE__*/ jsx(Checkbox.
1399
1621
  })
1400
1622
  })
1401
1623
  });
1402
- var circle = 'style__m6b9n24';
1403
- var styles_css_colors = {
1404
- primary: 'primary__m6b9n27',
1405
- secondary: 'secondary__m6b9n28',
1406
- inherit: 'inherit__m6b9n29'
1407
- };
1408
- var CircularProgress_styles_css_root = 'style__m6b9n22';
1409
- var svg = 'style__m6b9n23';
1410
- var styles_css_variants = {
1411
- determinate: 'determinate__m6b9n25',
1412
- indeterminate: 'indeterminate__m6b9n26'
1413
- };
1414
- const CircularProgress = ({ size = 30, thickness = 2.6, color = 'primary', value = 0, variant = 'indeterminate', className })=>{
1415
- const radius = (size - thickness) / 2;
1416
- const circumference = 2 * Math.PI * radius;
1417
- const dashOffset = 'determinate' === variant ? circumference * (1 - value / 100) : 0.25 * circumference;
1418
- return /*#__PURE__*/ jsx("div", {
1419
- className: clsx_0(CircularProgress_styles_css_root, styles_css_variants[variant], styles_css_colors[color], className),
1420
- style: {
1421
- width: size,
1422
- height: size
1423
- },
1424
- children: /*#__PURE__*/ jsxs("svg", {
1425
- className: svg,
1426
- viewBox: `0 0 ${size} ${size}`,
1427
- children: [
1428
- /*#__PURE__*/ jsx("title", {
1429
- children: "Progress bar"
1430
- }),
1431
- /*#__PURE__*/ jsx("circle", {
1432
- className: clsx_0(circle, 'determinate' === variant && styles_css_variants.determinate),
1433
- cx: size / 2,
1434
- cy: size / 2,
1435
- r: radius,
1436
- fill: "none",
1437
- strokeWidth: thickness,
1438
- strokeDasharray: circumference,
1439
- strokeDashoffset: dashOffset
1440
- })
1441
- ]
1442
- })
1443
- });
1444
- };
1445
1624
  function Collapsible_Collapsible({ ...props }) {
1446
1625
  return /*#__PURE__*/ jsx(Collapsible.Root, {
1447
1626
  "data-slot": "collapsible",
@@ -1575,11 +1754,11 @@ var sizes = {
1575
1754
  medium: 'medium__1o97kvm2',
1576
1755
  large: 'large__1o97kvm3'
1577
1756
  };
1578
- var Image_styles_css_wrapper = 'style__1o97kvm0';
1757
+ var styles_css_wrapper = 'style__1o97kvm0';
1579
1758
  const Image_Image = (props)=>/*#__PURE__*/ jsx("img", {
1580
1759
  alt: props.alt,
1581
1760
  src: props.src,
1582
- className: clsx_0(Image_styles_css_wrapper, sizes[props.size || 'medium'], props.className),
1761
+ className: clsx_0(styles_css_wrapper, sizes[props.size || 'medium'], props.className),
1583
1762
  width: props.width,
1584
1763
  height: props.height
1585
1764
  });
@@ -2030,7 +2209,7 @@ function Header_Header({ columns, height }) {
2030
2209
  var DataGrid_styles_css_container = 'style__1gqvluf0';
2031
2210
  var DataGrid_styles_css_disabled = 'style__1gqvluf3';
2032
2211
  var fullHeight = 'style__1gqvluf2';
2033
- var styles_css_loading = 'style__1gqvluf4';
2212
+ var DataGrid_styles_css_loading = 'style__1gqvluf4';
2034
2213
  var table = 'style__1gqvluf1';
2035
2214
  var titleClass = 'style__1gqvluf5';
2036
2215
  function DataGrid({ rows, columns, height = '100%', className, rowHeight = 40, headerHeight = 40, keyId, onRowClick, isLoading, isDisabled, isError, emptyState, errorState, footer, title, onRetry }) {
@@ -2045,7 +2224,7 @@ function DataGrid({ rows, columns, height = '100%', className, rowHeight = 40, h
2045
2224
  /*#__PURE__*/ jsxs("table", {
2046
2225
  className: clsx(table, {
2047
2226
  [DataGrid_styles_css_disabled]: isDisabled,
2048
- [styles_css_loading]: isLoading,
2227
+ [DataGrid_styles_css_loading]: isLoading,
2049
2228
  [fullHeight]: isFullHeight
2050
2229
  }, className),
2051
2230
  children: [
@@ -3009,7 +3188,7 @@ var Drawer_styles_css_footer = 'style__ccss508';
3009
3188
  var Drawer_styles_css_header = 'style__ccss507';
3010
3189
  var Drawer_styles_css_overlay = 'style__ccss502';
3011
3190
  var Drawer_styles_css_title = 'style__ccss509';
3012
- var viewport = 'style__ccss503';
3191
+ var styles_css_viewport = 'style__ccss503';
3013
3192
  const Drawer_Drawer = ({ children, trigger, className, title, description = '', footer, closeButton, swipeDirection = 'down', ...props })=>/*#__PURE__*/ jsxs(Drawer.Root, {
3014
3193
  swipeDirection: swipeDirection,
3015
3194
  ...props,
@@ -3026,7 +3205,7 @@ const Drawer_Drawer = ({ children, trigger, className, title, description = '',
3026
3205
  className: Drawer_styles_css_overlay
3027
3206
  }),
3028
3207
  /*#__PURE__*/ jsx(Drawer.Viewport, {
3029
- className: viewport,
3208
+ className: styles_css_viewport,
3030
3209
  children: /*#__PURE__*/ jsx(Drawer.Popup, {
3031
3210
  "data-slot": "drawer-content",
3032
3211
  className: clsx('group/drawer-content', Drawer_styles_css_content, className),
@@ -3138,7 +3317,7 @@ var carouselInner = 'style__a5l83v1';
3138
3317
  var ImageCarousel_styles_css_image = 'style__a5l83v3';
3139
3318
  var styles_css_indicator = 'style__a5l83v8';
3140
3319
  var indicators = 'style__a5l83v7';
3141
- var slide = 'style__a5l83v2';
3320
+ var styles_css_slide = 'style__a5l83v2';
3142
3321
  const ImageCarousel = ({ images = [], autoPlay = false, interval = 5000 })=>{
3143
3322
  const [currentIndex, setCurrentIndex] = useState(0);
3144
3323
  const goToPrevious = ()=>{
@@ -3174,7 +3353,7 @@ const ImageCarousel = ({ images = [], autoPlay = false, interval = 5000 })=>{
3174
3353
  transform: `translateX(-${100 * currentIndex}%)`
3175
3354
  },
3176
3355
  children: images.map((image, index)=>/*#__PURE__*/ jsx("div", {
3177
- className: slide,
3356
+ className: styles_css_slide,
3178
3357
  children: /*#__PURE__*/ jsx("img", {
3179
3358
  src: image.src,
3180
3359
  alt: image.alt || `Slide ${index + 1}`,
@@ -4110,7 +4289,7 @@ var Select_styles_css_sizes = {
4110
4289
  large: 'large__5ilg7o5'
4111
4290
  };
4112
4291
  var Select_styles_css_trigger = 'style__5ilg7o2';
4113
- var styles_css_viewport = 'style__5ilg7o9';
4292
+ var Select_styles_css_viewport = 'style__5ilg7o9';
4114
4293
  const Select_Select = ({ onValueChange, ...props })=>/*#__PURE__*/ jsx(Select.Root, {
4115
4294
  ...props,
4116
4295
  onValueChange: (value, eventDetails)=>{
@@ -4163,7 +4342,7 @@ const SelectContent = ({ className, children, side = 'bottom', sideOffset = 4, a
4163
4342
  children: [
4164
4343
  /*#__PURE__*/ jsx(SelectScrollUpButton, {}),
4165
4344
  /*#__PURE__*/ jsx(Select.List, {
4166
- className: styles_css_viewport,
4345
+ className: Select_styles_css_viewport,
4167
4346
  children: children
4168
4347
  }),
4169
4348
  /*#__PURE__*/ jsx(SelectScrollDownButton, {})
@@ -4844,4 +5023,4 @@ const ToggleGroup = ({ value, onChange, options, size, className, label, multipl
4844
5023
  ]
4845
5024
  });
4846
5025
  };
4847
- export { Accordion_Accordion as Accordion, AlertDialog_AlertDialog as AlertDialog, Autocomplete, Avatar_Avatar as Avatar, Badge_Badge as Badge, Breadcrumb, ButtonGroup, Button_Button as Button, Button_buttonSizes as buttonSizes, Button_buttonVariants as buttonVariants, Calendar, Card, Carousel, Checkbox_Checkbox as Checkbox, CircularProgress, Collapsible_Collapsible as Collapsible, Combobox_Combobox as Combobox, ConfirmAction, ContentState, CopyTypography, DEFAULT_SEPARATOR, DEFAULT_SYMBOL, DESCRIPTION_ROOT_CLASSNAME, DashboardLayout, DataGrid, DataGridActionCell, DataGridSortHeader, DataList, DatePicker, Description_Description as Description, Dialog_Dialog as Dialog, Drawer_Drawer as Drawer, DropdownMenu, Empty_Empty as Empty, ImageCarousel, Image_Image as Image, InputGroup, InputOTP, Input_Input as Input, Label, MaskField, NOTIFICATION_POSITIONS, NOTIFY_CLASSNAME, Notification, NotificationContainer, OverflowTypography, PageLayout, Pagination, PeriodPicker, Placeholder, Popover_Popover as Popover, RadioGroupItem, RadioGroup_RadioGroup as RadioGroup, RangeInput, ScrollTopButton, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Select_Select as Select, Sheet, Sidebar_Sidebar as Sidebar, Slider_Slider as Slider, Tabs_Tabs as Tabs, TextField, Textarea_Textarea as Textarea, ToggleGroup, Tooltip_Tooltip as Tooltip, Typography, alignments, badgeVariants, calculateSize, colors, constants_NotificationVariantTypes as NotificationVariantTypes, createHandle, displays, negativeSpacing, notification, spacing, theme, transforms, useComboboxAnchor, useDashboard, useIsMobile, useOverflowed, useSidebar, variants, weights };
5026
+ export { Accordion_Accordion as Accordion, AlertDialog_AlertDialog as AlertDialog, Autocomplete, Avatar_Avatar as Avatar, Badge_Badge as Badge, Breadcrumb, ButtonGroup, Button_Button as Button, Button_buttonSizes as buttonSizes, Button_buttonVariants as buttonVariants, Calendar, Card, Carousel, Checkbox_Checkbox as Checkbox, CircularProgress, Collapsible_Collapsible as Collapsible, Combobox_Combobox as Combobox, ConfirmAction, ContentState, CopyTypography, DEFAULT_SEPARATOR, DEFAULT_SYMBOL, DESCRIPTION_ROOT_CLASSNAME, DashboardLayout, DataGrid, DataGridActionCell, DataGridSortHeader, DataList, DatePicker, Description_Description as Description, Dialog_Dialog as Dialog, Drawer_Drawer as Drawer, DropdownMenu, Empty_Empty as Empty, ImageCarousel, Image_Image as Image, InputGroup, InputOTP, Input_Input as Input, Label, MaskField, NOTIFICATION_POSITIONS, NOTIFY_CLASSNAME, Notification, NotificationContainer, OverflowTypography, PageLayout, Pagination, PeriodPicker, Placeholder, Popover_Popover as Popover, RadioGroupItem, RadioGroup_RadioGroup as RadioGroup, RangeInput, ScrollTopButton, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Select_Select as Select, Sheet, Sidebar_Sidebar as Sidebar, Slider_Slider as Slider, Tabs_Tabs as Tabs, TextField, Textarea_Textarea as Textarea, ToggleGroup, Tooltip_Tooltip as Tooltip, Typography, alignments, badgeVariants, calculateSize, constants_NotificationVariantTypes as NotificationVariantTypes, createHandle, displays, negativeSpacing, notification, spacing, styles_css_colors as colors, styles_css_variants as variants, theme, transforms, useComboboxAnchor, useDashboard, useIsMobile, useOverflowed, useSidebar, weights };