@@ -60,18 +60,99 @@ export type CarouselContextBackwardCompatibilityProps = Pick<
6060} ;
6161
6262export type CarouselContextStateType = {
63+ /**
64+ * A flag indicating whether the carousel has been initialized and is ready.
65+ * Useful for preventing interactions before measurements are complete.
66+ * @type {boolean }
67+ */
6368 isReady : boolean ;
69+ /**
70+ * The CSS `transform` value (e.g., 'translateX(-200%)') applied
71+ * to the slider track to position the current slide in the viewport.
72+ * @type {string }
73+ */
6474 transformValue : string ;
75+ /**
76+ * Sets the CSS `transform` value for the slider track.
77+ * @param {string } value - The new CSS transform string.
78+ * @returns {void }
79+ */
6580 setTransformValue : ( value : string ) => void ;
81+ /**
82+ * The total number of slides in the carousel.
83+ * @type {number }
84+ */
6685 numberOfSlides : number ;
86+ /**
87+ * Sets the total number of slides.
88+ * @param {number } value - The new total number of slides.
89+ * @returns {void }
90+ */
6791 setNumberOfSlides : ( value : number ) => void ;
92+ /**
93+ * The number of individual items to display per slide.
94+ * @type {number }
95+ */
6896 itemsPerSlide : number ;
97+ /**
98+ * Sets the number of items to display per slide.
99+ * @param {number } value - The new number of items per slide.
100+ * @returns {void }
101+ */
69102 setItemsPerSlide : ( value : number ) => void ;
103+ /**
104+ * The zero-based index of the currently active slide.
105+ * @type {number }
106+ */
70107 currentSlide : number ;
108+ /**
109+ * Sets the index of the currently active slide.
110+ * @param {number } value - The new active slide index.
111+ * @returns {void }
112+ */
71113 setCurrentSlide : ( value : number ) => void ;
114+ /**
115+ * The measured width of the carousel container in pixels.
116+ * @type {number }
117+ */
72118 width : number ;
119+ /**
120+ * Sets the measured width of the carousel container.
121+ * @param {number } value - The new width in pixels.
122+ * @returns {void }
123+ */
73124 setWidth : ( value : number ) => void ;
74- handleUpdateSlideProps : ( value : number ) => void ;
125+ /**
126+ * Updates the CSS transform value and the current slide index for a slider component.
127+ *
128+ * @description This function calculates the necessary CSS `transform` value to move
129+ * to a target slide. It sets the transform to '0px' for the first slide (index 0).
130+ * For all other slides, it calculates a percentage-based transform (`value * 100%`).
131+ * The direction of the translation (positive or negative) is determined by comparing
132+ * the target slide `value` with the `currentSlide` state. It then updates the
133+ * state for the transform value and the current slide index.
134+ *
135+ * @param {number } targetSlide - The zero-based index of the target slide.
136+ * @returns {void } This function does not return a value.
137+ *
138+ * @example
139+ * // Assume currentSlide is 1, and we want to move to slide 3:
140+ * handleUpdateSlideProps(3);
141+ * // setTransformValue will be called with '-300%'
142+ * // setCurrentSlide will be called with 3
143+ *
144+ * @example
145+ * // Assume we want to go back to the first slide:
146+ * handleUpdateSlideProps(0);
147+ * // setTransformValue will be called with '0px'
148+ * // setCurrentSlide will be called with 0
149+ */
150+ handleUpdateSlideProps : ( targetSlide : number ) => void ;
151+ /**
152+ * The total number of individual items provided to the carousel.
153+ * This is used along with `itemsPerSlide` to calculate `numberOfSlides`.
154+ * @type {number }
155+ */
75156 numberOfItems : number ;
76157} ;
77158
0 commit comments