@alto-avios/alto-ui 3.8.0 → 4.0.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 (123) hide show
  1. package/dist/IconButton.module-4obqG6tY.js +1050 -0
  2. package/dist/IconButton.module-4obqG6tY.js.map +1 -0
  3. package/dist/assets/AutoplayControl.css +1 -0
  4. package/dist/assets/AviosCurrency.css +1 -1
  5. package/dist/assets/AviosCurrencyBadge.css +1 -0
  6. package/dist/assets/Button.css +1 -1
  7. package/dist/assets/Carousel.css +1 -0
  8. package/dist/assets/CarouselButton.css +1 -0
  9. package/dist/assets/CarouselDots.css +1 -0
  10. package/dist/assets/ComboBox.css +1 -1
  11. package/dist/assets/LoadingSpinner.css +1 -1
  12. package/dist/assets/MonthYearField.css +1 -0
  13. package/dist/assets/SearchField.css +1 -1
  14. package/dist/assets/SelectNative.css +1 -1
  15. package/dist/assets/SkeletonLoader.css +1 -0
  16. package/dist/assets/TextAreaField.css +1 -1
  17. package/dist/components/Accordion/Accordion.js +8 -8
  18. package/dist/components/AviosCurrency/AviosCurrency.d.ts +1 -2
  19. package/dist/components/AviosCurrency/AviosCurrency.js +40 -36
  20. package/dist/components/AviosCurrency/AviosCurrency.js.map +1 -1
  21. package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.d.ts +48 -0
  22. package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.js +165 -0
  23. package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.js.map +1 -0
  24. package/dist/components/AviosCurrencyBadge/index.d.ts +1 -0
  25. package/dist/components/AviosCurrencyBadge/index.js +5 -0
  26. package/dist/components/AviosCurrencyBadge/index.js.map +1 -0
  27. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js +3 -3
  28. package/dist/components/Badge/Badge.d.ts +1 -16
  29. package/dist/components/Badge/Badge.js +3 -9
  30. package/dist/components/Badge/Badge.js.map +1 -1
  31. package/dist/components/Box/Box.d.ts +0 -4
  32. package/dist/components/Box/Box.js +1 -5
  33. package/dist/components/Box/Box.js.map +1 -1
  34. package/dist/components/Button/Button.d.ts +34 -64
  35. package/dist/components/Button/Button.js +61 -44
  36. package/dist/components/Button/Button.js.map +1 -1
  37. package/dist/components/ButtonGroup/ButtonGroup.js +2 -2
  38. package/dist/components/CalloutBanner/CalloutBanner.js +3 -3
  39. package/dist/components/Carousel/AutoplayControl/AutoplayControl.d.ts +27 -0
  40. package/dist/components/Carousel/AutoplayControl/AutoplayControl.js +115 -0
  41. package/dist/components/Carousel/AutoplayControl/AutoplayControl.js.map +1 -0
  42. package/dist/components/Carousel/Carousel.d.ts +171 -0
  43. package/dist/components/Carousel/Carousel.js +373 -0
  44. package/dist/components/Carousel/Carousel.js.map +1 -0
  45. package/dist/components/Carousel/CarouselButton/CarouselButton.d.ts +44 -0
  46. package/dist/components/Carousel/CarouselButton/CarouselButton.js +195 -0
  47. package/dist/components/Carousel/CarouselButton/CarouselButton.js.map +1 -0
  48. package/dist/components/Carousel/CarouselControls.d.ts +7 -0
  49. package/dist/components/Carousel/CarouselControls.js +305 -0
  50. package/dist/components/Carousel/CarouselControls.js.map +1 -0
  51. package/dist/components/Carousel/CarouselDots/CarouselDots.d.ts +16 -0
  52. package/dist/components/Carousel/CarouselDots/CarouselDots.js +150 -0
  53. package/dist/components/Carousel/CarouselDots/CarouselDots.js.map +1 -0
  54. package/dist/components/Carousel/index.d.ts +1 -0
  55. package/dist/components/Carousel/index.js +5 -0
  56. package/dist/components/Carousel/index.js.map +1 -0
  57. package/dist/components/ComboBox/ComboBox.js +10 -13
  58. package/dist/components/ComboBox/ComboBox.js.map +1 -1
  59. package/dist/components/CreditCardNumberField/CreditCardNumberField.js +5 -5
  60. package/dist/components/CreditCardSecurityCodeField/CreditCardSecurityCodeField.js +5 -5
  61. package/dist/components/Dialog/Dialog.js +4 -4
  62. package/dist/components/ErrorSummary/ErrorSummary.js +4 -4
  63. package/dist/components/FieldError/FieldError.d.ts +5 -1
  64. package/dist/components/FieldError/FieldError.js +8 -1
  65. package/dist/components/FieldError/FieldError.js.map +1 -1
  66. package/dist/components/FieldHeader/FieldHeader.js +1 -1
  67. package/dist/components/Grid/Grid.d.ts +6 -1
  68. package/dist/components/Grid/Grid.js +2 -0
  69. package/dist/components/Grid/Grid.js.map +1 -1
  70. package/dist/components/Heading/Heading.d.ts +1 -6
  71. package/dist/components/Heading/Heading.js +1 -6
  72. package/dist/components/Heading/Heading.js.map +1 -1
  73. package/dist/components/Icon/Icon.d.ts +1 -6
  74. package/dist/components/IconButton/IconButton.d.ts +3 -15
  75. package/dist/components/IconButton/IconButton.js +18 -128
  76. package/dist/components/IconButton/IconButton.js.map +1 -1
  77. package/dist/components/Image/Image.d.ts +0 -1
  78. package/dist/components/Image/Image.js +8 -13
  79. package/dist/components/Image/Image.js.map +1 -1
  80. package/dist/components/Link/Link.d.ts +1 -16
  81. package/dist/components/Link/Link.js +4 -11
  82. package/dist/components/Link/Link.js.map +1 -1
  83. package/dist/components/ListBoxItem/index.d.ts +1 -1
  84. package/dist/components/LoadingSpinner/LoadingSpinner.d.ts +2 -1
  85. package/dist/components/LoadingSpinner/LoadingSpinner.js +6 -4
  86. package/dist/components/LoadingSpinner/LoadingSpinner.js.map +1 -1
  87. package/dist/components/MonthYearField/MonthYearField.d.ts +107 -0
  88. package/dist/components/MonthYearField/MonthYearField.js +332 -0
  89. package/dist/components/MonthYearField/MonthYearField.js.map +1 -0
  90. package/dist/components/MonthYearField/index.d.ts +2 -0
  91. package/dist/components/MonthYearField/index.js +5 -0
  92. package/dist/components/MonthYearField/index.js.map +1 -0
  93. package/dist/components/Paragraph/Paragraph.d.ts +1 -6
  94. package/dist/components/Paragraph/Paragraph.js +1 -6
  95. package/dist/components/Paragraph/Paragraph.js.map +1 -1
  96. package/dist/components/PasswordField/PasswordField.js +3 -3
  97. package/dist/components/PhoneNumberField/PhoneNumberField.js +1 -1
  98. package/dist/components/Popover/Popover.js +2 -2
  99. package/dist/components/SearchField/SearchField.js +9 -7
  100. package/dist/components/SearchField/SearchField.js.map +1 -1
  101. package/dist/components/Section/Section.d.ts +42 -1
  102. package/dist/components/Section/Section.js +8 -13
  103. package/dist/components/Section/Section.js.map +1 -1
  104. package/dist/components/SelectCard/SelectCard.js +2 -2
  105. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +50 -0
  106. package/dist/components/SkeletonLoader/SkeletonLoader.js +150 -0
  107. package/dist/components/SkeletonLoader/SkeletonLoader.js.map +1 -0
  108. package/dist/components/SkeletonLoader/index.d.ts +1 -0
  109. package/dist/components/SkeletonLoader/index.js +5 -0
  110. package/dist/components/SkeletonLoader/index.js.map +1 -0
  111. package/dist/components/SubHeading/SubHeading.d.ts +1 -6
  112. package/dist/components/SubHeading/SubHeading.js +1 -6
  113. package/dist/components/SubHeading/SubHeading.js.map +1 -1
  114. package/dist/components/TextAreaField/TextAreaField.js +1 -1
  115. package/dist/components/_base/Field/Field.js +4 -4
  116. package/dist/components/index.d.ts +8 -0
  117. package/dist/components/index.js +8 -0
  118. package/dist/components/index.js.map +1 -1
  119. package/dist/index.js +8 -0
  120. package/dist/index.js.map +1 -1
  121. package/dist/{react-number-format.es-BjKL6crg.js → react-number-format.es-Dbc1db6s.js} +6 -6
  122. package/dist/{react-number-format.es-BjKL6crg.js.map → react-number-format.es-Dbc1db6s.js.map} +1 -1
  123. package/package.json +4 -2
@@ -0,0 +1,115 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { f as CarouselAutoplayControl, i as iconButtonStyles } from "../../../IconButton.module-4obqG6tY.js";
4
+ import { useFocusRing } from "@react-aria/focus";
5
+ import { Icon } from "../../Icon/Icon.js";
6
+ import { focusStyleVariants } from "../../../utils/focus/focusStyles.js";
7
+ import '../../../assets/AutoplayControl.css';const autoplayControl = "_autoplayControl_kk1sb_1";
8
+ const iconButton = "_iconButton_kk1sb_17";
9
+ const sizeMd = "_sizeMd_kk1sb_25";
10
+ const sizeSm = "_sizeSm_kk1sb_31";
11
+ const neutralVibrant = "_neutralVibrant_kk1sb_38";
12
+ const whiteVibrant = "_whiteVibrant_kk1sb_44";
13
+ const neutralSubtle = "_neutralSubtle_kk1sb_55";
14
+ const whiteSubtle = "_whiteSubtle_kk1sb_61";
15
+ const styles = {
16
+ autoplayControl,
17
+ iconButton,
18
+ sizeMd,
19
+ sizeSm,
20
+ neutralVibrant,
21
+ whiteVibrant,
22
+ neutralSubtle,
23
+ whiteSubtle
24
+ };
25
+ const AutoplayControl = ({
26
+ variant = "neutralVibrant",
27
+ size = "md",
28
+ focusStyle = "default",
29
+ className = "",
30
+ buttonClassName = ""
31
+ }) => {
32
+ const {
33
+ isFocusVisible,
34
+ focusProps,
35
+ isFocused
36
+ } = useFocusRing();
37
+ const [isHovered, setIsHovered] = useState(false);
38
+ const [isPressed, setIsPressed] = useState(false);
39
+ const variantClass = styles[variant] || "";
40
+ const iconSize = size === "md" ? "1.25x" : "1x";
41
+ const getIconColor = () => {
42
+ switch (variant) {
43
+ case "whiteVibrant":
44
+ return "whiteOnVibrant";
45
+ case "whiteSubtle":
46
+ return "whiteOnSubtle";
47
+ case "neutralVibrant":
48
+ return "inverseOnVibrant";
49
+ case "neutralSubtle":
50
+ return "inverseOnSubtle";
51
+ default:
52
+ return "whiteOnVibrant";
53
+ }
54
+ };
55
+ const handleKeyDown = (e) => {
56
+ if (e.key === " " || e.key === "Enter") {
57
+ e.preventDefault();
58
+ setIsPressed(true);
59
+ }
60
+ };
61
+ const handleKeyUp = (e) => {
62
+ if (e.key === " " || e.key === "Enter") {
63
+ e.preventDefault();
64
+ setIsPressed(false);
65
+ }
66
+ };
67
+ const getTitle = (autoplayUserPreference) => {
68
+ return autoplayUserPreference ? "Pause slideshow" : "Start slideshow";
69
+ };
70
+ return /* @__PURE__ */ jsx(
71
+ CarouselAutoplayControl,
72
+ {
73
+ className: `${styles.autoplayControl} ${styles[`size${size.toUpperCase()}`]} ${variantClass} ${className || ""}`,
74
+ ...focusProps,
75
+ onMouseEnter: () => setIsHovered(true),
76
+ onMouseLeave: () => {
77
+ setIsHovered(false);
78
+ setIsPressed(false);
79
+ },
80
+ onMouseDown: () => setIsPressed(true),
81
+ onMouseUp: () => setIsPressed(false),
82
+ onKeyDown: handleKeyDown,
83
+ onKeyUp: handleKeyUp,
84
+ "data-hovered": isHovered ? true : void 0,
85
+ "data-pressed": isPressed ? true : void 0,
86
+ "data-focused": isFocused ? true : void 0,
87
+ "data-size": size,
88
+ tabIndex: 0,
89
+ role: "button",
90
+ children: ({
91
+ autoplayUserPreference
92
+ }) => /* @__PURE__ */ jsx(
93
+ "div",
94
+ {
95
+ className: `${styles.iconButton} ${iconButtonStyles.iconButton} ${iconButtonStyles[size] || ""} ${focusStyleVariants({
96
+ focusStyle
97
+ })} ${buttonClassName || ""}`,
98
+ "data-focused": isFocused ? true : void 0,
99
+ "data-focus-visible": isFocusVisible ? true : void 0,
100
+ "data-parent-hovered": isHovered ? true : void 0,
101
+ "data-parent-pressed": isPressed ? true : void 0,
102
+ "data-size": size,
103
+ "aria-hidden": "true",
104
+ title: getTitle(autoplayUserPreference),
105
+ children: /* @__PURE__ */ jsx(Icon, { iconPrefix: "fas", iconName: autoplayUserPreference ? "pause" : "play", color: getIconColor(), iconSize, "aria-hidden": "true" })
106
+ }
107
+ )
108
+ }
109
+ );
110
+ };
111
+ export {
112
+ AutoplayControl,
113
+ AutoplayControl as default
114
+ };
115
+ //# sourceMappingURL=AutoplayControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoplayControl.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,171 @@
1
+ import { default as React } from 'react';
2
+ import { WithResponsive } from '../../utils/breakpoint/responsive';
3
+ export interface CarouselBaseProps {
4
+ /**
5
+ * Content to be displayed in the carousel
6
+ */
7
+ children?: React.ReactNode | React.ReactNode[];
8
+ /**
9
+ * Accessible name for the carousel
10
+ * Describes the purpose or content of the carousel for screen readers
11
+ * @example "Featured products" or "Customer testimonials"
12
+ */
13
+ 'aria-label'?: string;
14
+ /**
15
+ * ID of an element that provides additional description for the carousel
16
+ * Can reference an element that gives more context about the carousel's content
17
+ * @example "carousel-description"
18
+ */
19
+ 'aria-describedby'?: string;
20
+ /**
21
+ * Looping behavior
22
+ * - 'infinite': Carousel loops continuously
23
+ * - 'backToStart': Carousel loops back to start after reaching end
24
+ * - 'off': Looping is disabled
25
+ * @default 'off'
26
+ */
27
+ looping?: 'infinite' | 'backToStart' | 'off';
28
+ /**
29
+ * Number of items to display per page (minimum: 1)
30
+ * Decimal values (e.g., 2.25) can be used to show partial items
31
+ * @default 1
32
+ * @min 1
33
+ */
34
+ itemsPerPage?: number;
35
+ /**
36
+ * Space between carousel items in pixels
37
+ * @default 0
38
+ */
39
+ spaceBetweenItems?: number;
40
+ /**
41
+ * Amount of padding added to the scroll container to create a "peek" effect.
42
+ * This shows a portion of the adjacent items.
43
+ * Accepts any valid CSS dimension (px, rem, em, %) - e.g., "15%", "20px", "2rem"
44
+ * @example "15%" or "20px" or "2rem"
45
+ * @default undefined
46
+ */
47
+ scrollPadding?: string;
48
+ /**
49
+ * Icon type for navigation buttons
50
+ * @default 'chevron'
51
+ */
52
+ iconType?: 'chevron';
53
+ /**
54
+ * Style of carousel arrow buttons
55
+ * @default 'neutral'
56
+ */
57
+ arrowStyleVariant?: 'neutral' | 'white' | 'shapeFlat' | 'shapeElevated' | 'gradient';
58
+ /**
59
+ * Size of navigation buttons
60
+ * @default 'md'
61
+ */
62
+ arrowSize?: 'sm' | 'md' | 'lg';
63
+ /**
64
+ * Whether to hide navigation buttons when disabled
65
+ * Note: Navigation buttons are automatically hidden when all items fit on one page
66
+ * @default false
67
+ */
68
+ hideDisabledArrow?: boolean;
69
+ /**
70
+ * Whether to show arrows only when hovering over the carousel or when it has focus
71
+ * @default false
72
+ */
73
+ showArrowsOnHover?: boolean;
74
+ /**
75
+ * Focus style for interactive elements
76
+ * @default 'default'
77
+ */
78
+ focusStyle?: 'default' | 'white';
79
+ /**
80
+ * Size of pagination dots
81
+ * @default 'md'
82
+ */
83
+ dotsSize?: 'md' | 'lg';
84
+ /**
85
+ * Visual style of pagination dots
86
+ * @default 'standard'
87
+ */
88
+ dotsVariant?: 'standard' | 'transparent';
89
+ /**
90
+ * Whether to hide pagination dots
91
+ * Note: Dots are automatically hidden when there's only one page
92
+ * @default false
93
+ */
94
+ hideDots?: boolean;
95
+ /**
96
+ * Whether the autoplay is enabled
97
+ * @default false
98
+ */
99
+ autoPlay?: boolean;
100
+ /**
101
+ * Interval in milliseconds between slides during autoplay
102
+ * @default 2000
103
+ */
104
+ autoPlayInterval?: number;
105
+ /**
106
+ * Style variant for autoplay control button
107
+ * @default 'neutralVibrant'
108
+ */
109
+ autoPlayStyleVariant?: 'neutralVibrant' | 'neutralSubtle' | 'whiteVibrant' | 'whiteSubtle';
110
+ /**
111
+ * Size of autoplay control button
112
+ * @default 'md'
113
+ */
114
+ autoPlayControlSize?: 'sm' | 'md';
115
+ /**
116
+ * Whether to enable mouse dragging for the carousel
117
+ * @default true
118
+ */
119
+ mouseDragging?: boolean;
120
+ /**
121
+ * Class name for the outermost wrapper of the carousel
122
+ */
123
+ carouselWrapperClassName?: string;
124
+ /**
125
+ * Class name for the previous button
126
+ * Use this to position the previous button
127
+ */
128
+ prevArrowClassName?: string;
129
+ /**
130
+ * Class name for the next button
131
+ * Use this to position the next button
132
+ */
133
+ nextArrowClassName?: string;
134
+ /**
135
+ * Class name for the autoplay control
136
+ * Use this to position the autoplay button
137
+ */
138
+ autoplayControlClassName?: string;
139
+ /**
140
+ * Class name for the dots container
141
+ * Use this to position the pagination dots
142
+ */
143
+ dotsContainerClassName?: string;
144
+ /**
145
+ * Class name for the dots wrapper
146
+ * Use this to style the dots wrapper
147
+ */
148
+ dotsWrapperClassName?: string;
149
+ /**
150
+ * Class name for individual dots
151
+ */
152
+ dotClassName?: string;
153
+ /**
154
+ * Class name for the active dot
155
+ */
156
+ activeDotClassName?: string;
157
+ /**
158
+ * Class name for individual carousel item wrappers
159
+ * Use this to style the wrapper div around each carousel item
160
+ */
161
+ itemWrapperClassName?: string;
162
+ /**
163
+ * Class name for the currently active/visible carousel item
164
+ * This class is applied to the item that corresponds to the current page
165
+ */
166
+ activeItemClassName?: string;
167
+ }
168
+ type ResponsiveKeys = 'itemsPerPage' | 'spaceBetweenItems' | 'scrollPadding' | 'showArrowsOnHover' | 'arrowSize' | 'hideDots';
169
+ export type CarouselProps = WithResponsive<CarouselBaseProps, ResponsiveKeys>;
170
+ export declare const Carousel: ({ children, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, looping, itemsPerPage, spaceBetweenItems, scrollPadding, iconType, arrowStyleVariant, arrowSize, hideDisabledArrow, showArrowsOnHover, focusStyle, dotsSize, dotsVariant, hideDots, autoPlay, autoPlayInterval, autoPlayStyleVariant, autoPlayControlSize, mouseDragging, carouselWrapperClassName, prevArrowClassName, nextArrowClassName, autoplayControlClassName, dotsContainerClassName, dotsWrapperClassName, dotClassName, activeDotClassName, itemWrapperClassName, activeItemClassName, }: CarouselProps) => import("react/jsx-runtime").JSX.Element;
171
+ export default Carousel;
@@ -0,0 +1,373 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import React__default, { useRef, useState, useEffect } from "react";
3
+ import { c as cva } from "../../index-DdUYounA.js";
4
+ import { C as Carousel$1, a as CarouselScroller, b as CarouselItem, c as CarouselTabs, d as CarouselTab } from "../../IconButton.module-4obqG6tY.js";
5
+ import { CarouselButton } from "./CarouselButton/CarouselButton.js";
6
+ import { CarouselDots } from "./CarouselDots/CarouselDots.js";
7
+ import { AutoplayControl } from "./AutoplayControl/AutoplayControl.js";
8
+ import { focusStyleVariants } from "../../utils/focus/focusStyles.js";
9
+ import { useFocusRing } from "@react-aria/focus";
10
+ import { resolveResponsiveProp } from "../../utils/breakpoint/responsive.js";
11
+ import { useBreakpoint } from "../../utils/breakpoint/hooks/useBreakpoint.js";
12
+ import '../../assets/Carousel.css';const carouselWrapper = "_carouselWrapper_53fml_2";
13
+ const showPartialItems = "_showPartialItems_53fml_14";
14
+ const carousel$1 = "_carousel_53fml_2";
15
+ const hasScrollPadding = "_hasScrollPadding_53fml_25";
16
+ const scroller = "_scroller_53fml_43";
17
+ const item = "_item_53fml_85";
18
+ const slideLeft = "_slideLeft_53fml_123";
19
+ const slideRight = "_slideRight_53fml_127";
20
+ const controls = "_controls_53fml_150";
21
+ const defaultPrevButton = "_defaultPrevButton_53fml_161";
22
+ const defaultNextButton = "_defaultNextButton_53fml_169";
23
+ const defaultDotsContainer = "_defaultDotsContainer_53fml_178";
24
+ const defaultCarouselWrapper = "_defaultCarouselWrapper_53fml_189";
25
+ const autoplayControlWrapper = "_autoplayControlWrapper_53fml_196";
26
+ const defaultAutoplayControl = "_defaultAutoplayControl_53fml_196";
27
+ const showOnHover = "_showOnHover_53fml_205";
28
+ const hidden = "_hidden_53fml_215";
29
+ const hiddenTabs = "_hiddenTabs_53fml_246";
30
+ const infinite = "_infinite_53fml_265";
31
+ const native = "_native_53fml_270";
32
+ const styles = {
33
+ carouselWrapper,
34
+ showPartialItems,
35
+ carousel: carousel$1,
36
+ hasScrollPadding,
37
+ scroller,
38
+ item,
39
+ slideLeft,
40
+ slideRight,
41
+ controls,
42
+ defaultPrevButton,
43
+ defaultNextButton,
44
+ defaultDotsContainer,
45
+ defaultCarouselWrapper,
46
+ autoplayControlWrapper,
47
+ defaultAutoplayControl,
48
+ showOnHover,
49
+ hidden,
50
+ hiddenTabs,
51
+ infinite,
52
+ native
53
+ };
54
+ const carousel = cva(styles.carousel, {
55
+ variants: {
56
+ looping: {
57
+ infinite: styles.infinite,
58
+ backToStart: styles.native,
59
+ off: void 0
60
+ }
61
+ }
62
+ });
63
+ const Carousel = ({
64
+ children = [],
65
+ "aria-label": ariaLabel,
66
+ "aria-describedby": ariaDescribedby,
67
+ looping = "off",
68
+ itemsPerPage = 1,
69
+ spaceBetweenItems = 0,
70
+ scrollPadding,
71
+ // Button and Controls Props
72
+ iconType = "chevron",
73
+ arrowStyleVariant = "neutral",
74
+ arrowSize = "md",
75
+ hideDisabledArrow = false,
76
+ showArrowsOnHover = false,
77
+ focusStyle = "default",
78
+ // Dots/Tabs Props
79
+ dotsSize = "md",
80
+ dotsVariant = "standard",
81
+ hideDots = false,
82
+ // Autoplay Props
83
+ autoPlay = false,
84
+ autoPlayInterval = 2e3,
85
+ autoPlayStyleVariant = "neutralVibrant",
86
+ autoPlayControlSize = "md",
87
+ // Mouse Dragging
88
+ mouseDragging = true,
89
+ // Custom Class Names
90
+ carouselWrapperClassName = "",
91
+ prevArrowClassName = "",
92
+ nextArrowClassName = "",
93
+ autoplayControlClassName = "",
94
+ dotsContainerClassName = "",
95
+ dotsWrapperClassName = "",
96
+ dotClassName = "",
97
+ activeDotClassName = "",
98
+ itemWrapperClassName = "",
99
+ activeItemClassName = ""
100
+ }) => {
101
+ const getLoopValue = () => {
102
+ if (looping === "infinite") return "infinite";
103
+ if (looping === "backToStart") return "native";
104
+ if (looping === "off") return void 0;
105
+ return looping;
106
+ };
107
+ const items = React__default.Children.toArray(children);
108
+ const totalItems = items.length;
109
+ const breakpoint = useBreakpoint();
110
+ const resolvedItemsPerPage = resolveResponsiveProp(itemsPerPage, breakpoint) ?? 1;
111
+ const resolvedSpaceBetweenItems = resolveResponsiveProp(spaceBetweenItems, breakpoint) ?? 0;
112
+ const resolvedScrollPadding = resolveResponsiveProp(scrollPadding, breakpoint) ?? void 0;
113
+ const resolvedArrowSize = resolveResponsiveProp(arrowSize, breakpoint) ?? "md";
114
+ const resolvedHideDots = resolveResponsiveProp(hideDots, breakpoint) ?? false;
115
+ const safeItemsPerPage = Math.max(1, resolvedItemsPerPage);
116
+ const totalPages = Math.ceil(totalItems / safeItemsPerPage);
117
+ const shouldShowDots = !resolvedHideDots && totalPages > 1;
118
+ const carouselRef = useRef(null);
119
+ const ariaCarouselRef = useRef(null);
120
+ const [currentPage, setCurrentPage] = useState(0);
121
+ const [prevPage, setPrevPage] = useState(0);
122
+ const [isDragging, setIsDragging] = useState(false);
123
+ const [isHovered, setIsHovered] = useState(false);
124
+ const [isFocused, setIsFocused] = useState(false);
125
+ const [isTransitioning] = useState(false);
126
+ const [dragStartPosition, setDragStartPosition] = useState(null);
127
+ const dragThreshold = 5;
128
+ const getClassNameWithDefault = (customClassName, defaultClassName) => {
129
+ return customClassName || defaultClassName;
130
+ };
131
+ const getCarouselWrapperClasses = () => {
132
+ const classes = [styles.carouselWrapper];
133
+ if (!Number.isInteger(safeItemsPerPage)) {
134
+ classes.push(styles.showPartialItems);
135
+ }
136
+ if (resolvedScrollPadding) {
137
+ classes.push(styles.hasScrollPadding);
138
+ }
139
+ if (carouselWrapperClassName && carouselWrapperClassName.trim()) {
140
+ classes.push(carouselWrapperClassName);
141
+ } else {
142
+ classes.push(styles.defaultCarouselWrapper);
143
+ }
144
+ return classes.join(" ");
145
+ };
146
+ const getCssVariables = () => {
147
+ const cssVars2 = {};
148
+ if (resolvedItemsPerPage !== 1) {
149
+ cssVars2["--items-per-page"] = String(safeItemsPerPage);
150
+ }
151
+ if (resolvedSpaceBetweenItems > 0) {
152
+ cssVars2["--space-between-items"] = `${resolvedSpaceBetweenItems}px`;
153
+ }
154
+ if (resolvedScrollPadding) {
155
+ cssVars2["--scroll-padding"] = resolvedScrollPadding;
156
+ }
157
+ return Object.keys(cssVars2).length > 0 ? cssVars2 : void 0;
158
+ };
159
+ const getActiveItemIndices = () => {
160
+ const startIndex = currentPage * Math.floor(safeItemsPerPage);
161
+ const endIndex = Math.min(startIndex + Math.ceil(safeItemsPerPage), totalItems);
162
+ const activeIndices = [];
163
+ for (let i = startIndex; i < endIndex; i++) {
164
+ activeIndices.push(i);
165
+ }
166
+ return activeIndices;
167
+ };
168
+ const navigateToSlide = (index) => {
169
+ if (index === currentPage || index < 0 || index >= totalPages) {
170
+ return;
171
+ }
172
+ if (carouselRef.current) {
173
+ const targetTab = carouselRef.current.querySelector(`[data-slide-tab="true"][data-index="${index}"]`);
174
+ if (targetTab) {
175
+ targetTab.click();
176
+ }
177
+ }
178
+ };
179
+ useEffect(() => {
180
+ if (!carouselRef.current || !mouseDragging) return;
181
+ const preventLinkActivation = (e) => {
182
+ if (isDragging) {
183
+ e.preventDefault();
184
+ e.stopPropagation();
185
+ setTimeout(() => {
186
+ setIsDragging(false);
187
+ }, 0);
188
+ }
189
+ };
190
+ const handleMouseDown = (e) => {
191
+ setDragStartPosition({
192
+ x: e.clientX,
193
+ y: e.clientY
194
+ });
195
+ };
196
+ const handleMouseMove = (e) => {
197
+ if (dragStartPosition === null) return;
198
+ const dx = Math.abs(e.clientX - dragStartPosition.x);
199
+ const dy = Math.abs(e.clientY - dragStartPosition.y);
200
+ const distance = Math.sqrt(dx * dx + dy * dy);
201
+ if (distance > dragThreshold) {
202
+ setIsDragging(true);
203
+ }
204
+ };
205
+ const handleMouseUp = () => {
206
+ if (!isDragging) {
207
+ setDragStartPosition(null);
208
+ return;
209
+ }
210
+ setTimeout(() => {
211
+ setIsDragging(false);
212
+ setDragStartPosition(null);
213
+ }, 50);
214
+ };
215
+ const carouselElement = carouselRef.current;
216
+ carouselElement.addEventListener("mousedown", handleMouseDown, true);
217
+ carouselElement.addEventListener("mousemove", handleMouseMove, true);
218
+ carouselElement.addEventListener("mouseup", handleMouseUp, true);
219
+ carouselElement.addEventListener("click", preventLinkActivation, true);
220
+ return () => {
221
+ carouselElement.removeEventListener("mousedown", handleMouseDown, true);
222
+ carouselElement.removeEventListener("mousemove", handleMouseMove, true);
223
+ carouselElement.removeEventListener("mouseup", handleMouseUp, true);
224
+ carouselElement.removeEventListener("click", preventLinkActivation, true);
225
+ };
226
+ }, [mouseDragging, isDragging, dragStartPosition, dragThreshold]);
227
+ useEffect(() => {
228
+ if (carouselRef.current) {
229
+ const scroller2 = carouselRef.current.querySelector(`.${styles.scroller}`);
230
+ if (scroller2 && scroller2 instanceof HTMLElement) {
231
+ if (prevPage < currentPage) {
232
+ scroller2.classList.remove(styles.slideLeft);
233
+ scroller2.classList.add(styles.slideRight);
234
+ } else if (prevPage > currentPage) {
235
+ scroller2.classList.remove(styles.slideRight);
236
+ scroller2.classList.add(styles.slideLeft);
237
+ }
238
+ }
239
+ }
240
+ }, [currentPage, prevPage]);
241
+ useEffect(() => {
242
+ if (!carouselRef.current) return;
243
+ const checkCurrentPage = () => {
244
+ if (!carouselRef.current) return;
245
+ const selectedTab = carouselRef.current.querySelector('[data-slide-tab="true"][aria-selected="true"]');
246
+ if (selectedTab) {
247
+ const indexStr = selectedTab.getAttribute("data-index");
248
+ if (indexStr) {
249
+ const newIndex = parseInt(indexStr, 10);
250
+ if (!isNaN(newIndex) && newIndex !== currentPage && newIndex >= 0 && newIndex < totalPages) {
251
+ setPrevPage(currentPage);
252
+ setCurrentPage(newIndex);
253
+ }
254
+ }
255
+ }
256
+ };
257
+ const observer = new MutationObserver((mutations) => {
258
+ let shouldCheck = false;
259
+ mutations.forEach((mutation) => {
260
+ if (mutation.type === "attributes" && mutation.attributeName === "aria-selected") {
261
+ shouldCheck = true;
262
+ }
263
+ });
264
+ if (shouldCheck) {
265
+ setTimeout(checkCurrentPage, 10);
266
+ }
267
+ });
268
+ const hiddenTabs2 = carouselRef.current.querySelectorAll('[data-slide-tab="true"]');
269
+ hiddenTabs2.forEach((tab) => {
270
+ observer.observe(tab, {
271
+ attributes: true,
272
+ attributeFilter: ["aria-selected"]
273
+ });
274
+ });
275
+ checkCurrentPage();
276
+ const interval = setInterval(checkCurrentPage, 500);
277
+ return () => {
278
+ observer.disconnect();
279
+ clearInterval(interval);
280
+ };
281
+ }, [currentPage, totalPages]);
282
+ const interactionHandlers = showArrowsOnHover ? {
283
+ onMouseEnter: () => setIsHovered(true),
284
+ onMouseLeave: () => setIsHovered(false),
285
+ onFocus: () => setIsFocused(true),
286
+ onBlur: (e) => {
287
+ if (!e.currentTarget.contains(e.relatedTarget)) {
288
+ setIsFocused(false);
289
+ }
290
+ }
291
+ } : {};
292
+ const shouldShowArrows = totalPages > 1;
293
+ const arrowsVisible = shouldShowArrows && (!showArrowsOnHover || isHovered || isFocused);
294
+ const cssVars = getCssVariables();
295
+ const {
296
+ focusProps,
297
+ isFocusVisible
298
+ } = useFocusRing();
299
+ const getScrollerStyles = () => {
300
+ if (resolvedItemsPerPage <= 1 || !resolvedSpaceBetweenItems) {
301
+ return {};
302
+ }
303
+ const gapSpacePerItem = resolvedSpaceBetweenItems * (safeItemsPerPage - 1) / safeItemsPerPage;
304
+ return {
305
+ gridAutoColumns: `calc(${100 / safeItemsPerPage}% - ${gapSpacePerItem}px)`,
306
+ gap: `${resolvedSpaceBetweenItems}px`
307
+ };
308
+ };
309
+ const activeItemIndices = getActiveItemIndices();
310
+ const handleCarouselKeyDown = (e) => {
311
+ var _a, _b;
312
+ if (e.key === "ArrowLeft") {
313
+ e.preventDefault();
314
+ const prevButton = (_a = carouselRef.current) == null ? void 0 : _a.querySelector('[dir="prev"]');
315
+ if (prevButton && !prevButton.disabled) {
316
+ prevButton.click();
317
+ }
318
+ } else if (e.key === "ArrowRight") {
319
+ e.preventDefault();
320
+ const nextButton = (_b = carouselRef.current) == null ? void 0 : _b.querySelector('[dir="next"]');
321
+ if (nextButton && !nextButton.disabled) {
322
+ nextButton.click();
323
+ }
324
+ } else if (e.key === "Home") {
325
+ e.preventDefault();
326
+ navigateToSlide(0);
327
+ } else if (e.key === "End") {
328
+ e.preventDefault();
329
+ navigateToSlide(totalPages - 1);
330
+ }
331
+ };
332
+ const getDefaultAriaLabel = () => {
333
+ if (ariaLabel) return ariaLabel;
334
+ const currentSlideNumber = currentPage + 1;
335
+ const autoplayStatus = autoPlay ? ", autoplay enabled" : "";
336
+ return `Carousel with ${totalItems} items, currently showing slide ${currentSlideNumber} of ${totalPages}${autoplayStatus}`;
337
+ };
338
+ return /* @__PURE__ */ jsx("div", { className: getCarouselWrapperClasses(), ref: carouselRef, style: cssVars, "data-dots-size": dotsSize, ...interactionHandlers, "data-arrows-visible": arrowsVisible ? "true" : "false", "data-transitioning": isTransitioning ? "true" : void 0, "data-scroll-padding": resolvedScrollPadding, role: "region", "aria-label": getDefaultAriaLabel(), "aria-describedby": ariaDescribedby, "aria-roledescription": "carousel", children: /* @__PURE__ */ jsxs(Carousel$1, { className: `${carousel({
339
+ looping
340
+ })}`, loop: getLoopValue(), ref: ariaCarouselRef, autoplay: autoPlay, autoplayInterval: autoPlayInterval, mouseDragging: mouseDragging && !isTransitioning, onDragStart: (e) => {
341
+ setIsDragging(true);
342
+ if (e && e.nativeEvent) {
343
+ setDragStartPosition({
344
+ x: e.nativeEvent.clientX,
345
+ y: e.nativeEvent.clientY
346
+ });
347
+ }
348
+ }, onDragEnd: () => {
349
+ setTimeout(() => {
350
+ setIsDragging(false);
351
+ }, 50);
352
+ }, "data-dragging": isDragging ? "true" : "false", itemsPerPage: safeItemsPerPage, spaceBetweenItems: resolvedSpaceBetweenItems > 0 ? `${resolvedSpaceBetweenItems}px` : void 0, scrollPadding: resolvedScrollPadding, "data-has-space-between": resolvedSpaceBetweenItems > 0 ? "true" : void 0, "data-items-per-page": resolvedItemsPerPage !== 1 ? safeItemsPerPage.toString() : void 0, children: [
353
+ /* @__PURE__ */ jsx(CarouselScroller, { className: `${styles.scroller} ${focusStyleVariants({
354
+ focusStyle
355
+ })}`, ...focusProps, "data-focused": isFocusVisible ? true : void 0, "data-focus-visible": isFocusVisible ? true : void 0, "data-transitioning": isTransitioning ? "true" : void 0, style: getScrollerStyles(), tabIndex: 0, role: "region", "aria-label": "Carousel content", onKeyDown: handleCarouselKeyDown, children: items.map((child, index) => {
356
+ const isActiveItem = activeItemIndices.includes(index);
357
+ const itemClasses = [styles.item, itemWrapperClassName || "", isActiveItem && activeItemClassName ? activeItemClassName : ""].filter(Boolean).join(" ");
358
+ return /* @__PURE__ */ jsx(CarouselItem, { className: itemClasses, "data-is-active": isActiveItem ? "true" : void 0, "data-item-index": index, "aria-label": `Slide ${index + 1} of ${totalItems}`, children: child }, index);
359
+ }) }),
360
+ /* @__PURE__ */ jsxs("div", { className: `${styles.controls} ${showArrowsOnHover ? styles.showOnHover : ""}`, children: [
361
+ /* @__PURE__ */ jsx(CarouselButton, { dir: "prev", variant: arrowStyleVariant, size: resolvedArrowSize, focusStyle, iconType, hideDisabledArrow, className: `${getClassNameWithDefault(prevArrowClassName, styles.defaultPrevButton)} ${!arrowsVisible ? styles.hidden : ""}` }),
362
+ /* @__PURE__ */ jsx(CarouselButton, { dir: "next", variant: arrowStyleVariant, size: resolvedArrowSize, focusStyle, iconType, hideDisabledArrow, className: `${getClassNameWithDefault(nextArrowClassName, styles.defaultNextButton)} ${!arrowsVisible ? styles.hidden : ""}` })
363
+ ] }),
364
+ /* @__PURE__ */ jsx("div", { className: styles.hiddenTabs, children: /* @__PURE__ */ jsx(CarouselTabs, { children: (page) => /* @__PURE__ */ jsx(CarouselTab, { index: page.index, "data-index": page.index, "data-slide-tab": "true", tabIndex: -1 }, page.index) }) }),
365
+ autoPlay && /* @__PURE__ */ jsx("div", { className: `${styles.autoplayControlWrapper} ${getClassNameWithDefault(autoplayControlClassName, styles.defaultAutoplayControl)}`, children: /* @__PURE__ */ jsx(AutoplayControl, { variant: autoPlayStyleVariant, size: autoPlayControlSize, className: "" }) }),
366
+ shouldShowDots && /* @__PURE__ */ jsx(CarouselDots, { totalItems: totalPages, currentPage, onDotClick: (index) => navigateToSlide(index), focusStyle, dotsSize, variant: dotsVariant, className: getClassNameWithDefault(dotsContainerClassName, styles.defaultDotsContainer), dotsWrapperClassName, dotClassName, activeDotClassName, isTransitioning })
367
+ ] }) });
368
+ };
369
+ export {
370
+ Carousel,
371
+ Carousel as default
372
+ };
373
+ //# sourceMappingURL=Carousel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Carousel.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}