@salt-ds/lab 1.0.0-alpha.65 → 1.0.0-alpha.66

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 (53) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/css/salt-lab.css +111 -16
  3. package/dist-cjs/carousel/Carousel.css.js +1 -1
  4. package/dist-cjs/carousel/Carousel.js +30 -87
  5. package/dist-cjs/carousel/Carousel.js.map +1 -1
  6. package/dist-cjs/carousel/CarouselContext.js +62 -0
  7. package/dist-cjs/carousel/CarouselContext.js.map +1 -0
  8. package/dist-cjs/carousel/CarouselControls.css.js +6 -0
  9. package/dist-cjs/carousel/CarouselControls.css.js.map +1 -0
  10. package/dist-cjs/carousel/CarouselControls.js +122 -0
  11. package/dist-cjs/carousel/CarouselControls.js.map +1 -0
  12. package/dist-cjs/carousel/CarouselReducer.js +77 -0
  13. package/dist-cjs/carousel/CarouselReducer.js.map +1 -0
  14. package/dist-cjs/carousel/CarouselSlide.css.js +6 -0
  15. package/dist-cjs/carousel/CarouselSlide.css.js.map +1 -0
  16. package/dist-cjs/carousel/CarouselSlide.js +95 -45
  17. package/dist-cjs/carousel/CarouselSlide.js.map +1 -1
  18. package/dist-cjs/carousel/CarouselSlider.css.js +6 -0
  19. package/dist-cjs/carousel/CarouselSlider.css.js.map +1 -0
  20. package/dist-cjs/carousel/CarouselSlider.js +93 -0
  21. package/dist-cjs/carousel/CarouselSlider.js.map +1 -0
  22. package/dist-cjs/index.js +6 -2
  23. package/dist-cjs/index.js.map +1 -1
  24. package/dist-es/carousel/Carousel.css.js +1 -1
  25. package/dist-es/carousel/Carousel.js +32 -89
  26. package/dist-es/carousel/Carousel.js.map +1 -1
  27. package/dist-es/carousel/CarouselContext.js +58 -0
  28. package/dist-es/carousel/CarouselContext.js.map +1 -0
  29. package/dist-es/carousel/CarouselControls.css.js +4 -0
  30. package/dist-es/carousel/CarouselControls.css.js.map +1 -0
  31. package/dist-es/carousel/CarouselControls.js +120 -0
  32. package/dist-es/carousel/CarouselControls.js.map +1 -0
  33. package/dist-es/carousel/CarouselReducer.js +75 -0
  34. package/dist-es/carousel/CarouselReducer.js.map +1 -0
  35. package/dist-es/carousel/CarouselSlide.css.js +4 -0
  36. package/dist-es/carousel/CarouselSlide.css.js.map +1 -0
  37. package/dist-es/carousel/CarouselSlide.js +96 -46
  38. package/dist-es/carousel/CarouselSlide.js.map +1 -1
  39. package/dist-es/carousel/CarouselSlider.css.js +4 -0
  40. package/dist-es/carousel/CarouselSlider.css.js.map +1 -0
  41. package/dist-es/carousel/CarouselSlider.js +91 -0
  42. package/dist-es/carousel/CarouselSlider.js.map +1 -0
  43. package/dist-es/index.js +3 -1
  44. package/dist-es/index.js.map +1 -1
  45. package/dist-types/carousel/Carousel.d.ts +10 -23
  46. package/dist-types/carousel/CarouselContext.d.ts +11 -0
  47. package/dist-types/carousel/CarouselControls.d.ts +26 -0
  48. package/dist-types/carousel/CarouselReducer.d.ts +30 -0
  49. package/dist-types/carousel/CarouselSlide.d.ts +31 -8
  50. package/dist-types/carousel/CarouselSlider.d.ts +13 -0
  51. package/dist-types/carousel/index.d.ts +2 -0
  52. package/dist-types/utils/index.d.ts +1 -1
  53. package/package.json +2 -2
@@ -0,0 +1,91 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { makePrefixer, useForkRef } from '@salt-ds/core';
3
+ import { useComponentCssInjection } from '@salt-ds/styles';
4
+ import { useWindow } from '@salt-ds/window';
5
+ import { forwardRef, useRef, useContext, useLayoutEffect } from 'react';
6
+ import { CarouselStateContext, CarouselDispatchContext } from './CarouselContext.js';
7
+ import css_248z from './CarouselSlider.css.js';
8
+
9
+ const withBaseName = makePrefixer("saltCarouselSlider");
10
+ const CarouselSlider = forwardRef(
11
+ function CarouselSlider2({ children, onKeyDown, onScroll, onSelectionChange, ...rest }, propRef) {
12
+ const targetWindow = useWindow();
13
+ useComponentCssInjection({
14
+ testId: "salt-carousel-slider",
15
+ css: css_248z,
16
+ window: targetWindow
17
+ });
18
+ const containerRef = useRef(null);
19
+ const hasRun = useRef(false);
20
+ const { slides, activeSlideIndex, focusedSlideIndex, visibleSlides } = useContext(CarouselStateContext);
21
+ const dispatch = useContext(CarouselDispatchContext);
22
+ const slideIds = [...slides.keys()];
23
+ const handleKeyDown = (event) => {
24
+ var _a, _b;
25
+ if (event.repeat) return;
26
+ switch (event.key) {
27
+ case "ArrowLeft": {
28
+ const prevIndex = focusedSlideIndex && focusedSlideIndex > activeSlideIndex ? focusedSlideIndex - 1 : activeSlideIndex - 1;
29
+ const prevId = slideIds[prevIndex] || null;
30
+ if (!prevId) break;
31
+ dispatch({ type: "scroll", payload: prevId });
32
+ onSelectionChange == null ? void 0 : onSelectionChange(event, prevIndex);
33
+ (_a = slides.get(prevId)) == null ? void 0 : _a.element.focus();
34
+ break;
35
+ }
36
+ case "ArrowRight": {
37
+ const nextIndex = activeSlideIndex + 1;
38
+ const nextId = slideIds[nextIndex] || null;
39
+ if (!nextId) break;
40
+ dispatch({ type: "scroll", payload: nextId });
41
+ onSelectionChange == null ? void 0 : onSelectionChange(event, nextIndex);
42
+ (_b = slides.get(nextId)) == null ? void 0 : _b.element.focus();
43
+ break;
44
+ }
45
+ }
46
+ onKeyDown == null ? void 0 : onKeyDown(event);
47
+ };
48
+ const handleScroll = (event) => {
49
+ const container = containerRef == null ? void 0 : containerRef.current;
50
+ if (!container) return;
51
+ const scrollLeft = container.scrollLeft;
52
+ const slideWidth = container.offsetWidth / visibleSlides;
53
+ const newIndex = Math.round(scrollLeft / slideWidth) || 0;
54
+ if (newIndex !== activeSlideIndex) {
55
+ dispatch({ type: "move", payload: slideIds[newIndex] });
56
+ onSelectionChange == null ? void 0 : onSelectionChange(event, newIndex);
57
+ }
58
+ onScroll == null ? void 0 : onScroll(event);
59
+ };
60
+ useLayoutEffect(() => {
61
+ const container = containerRef.current;
62
+ if (!container) return;
63
+ const scrollBehavior = hasRun.current ? "smooth" : "instant";
64
+ const slideWidth = container.offsetWidth / visibleSlides;
65
+ requestAnimationFrame(() => {
66
+ container.scrollTo({
67
+ left: focusedSlideIndex * slideWidth,
68
+ // @ts-ignore ScrollBehavior typescript definition missing instant
69
+ behavior: scrollBehavior
70
+ });
71
+ });
72
+ hasRun.current = true;
73
+ }, [focusedSlideIndex, visibleSlides]);
74
+ const ref = useForkRef(propRef, containerRef);
75
+ return /* @__PURE__ */ jsx(
76
+ "div",
77
+ {
78
+ ref,
79
+ className: withBaseName(),
80
+ tabIndex: -1,
81
+ onKeyDown: handleKeyDown,
82
+ onScroll: handleScroll,
83
+ ...rest,
84
+ children
85
+ }
86
+ );
87
+ }
88
+ );
89
+
90
+ export { CarouselSlider };
91
+ //# sourceMappingURL=CarouselSlider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CarouselSlider.js","sources":["../src/carousel/CarouselSlider.tsx"],"sourcesContent":["import { makePrefixer, useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport {\n type HTMLAttributes,\n type KeyboardEvent,\n type ReactElement,\n type SyntheticEvent,\n type UIEvent,\n forwardRef,\n useContext,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport {\n CarouselDispatchContext,\n CarouselStateContext,\n} from \"./CarouselContext\";\nimport type { CarouselSlideProps } from \"./CarouselSlide\";\nimport carouselSliderCss from \"./CarouselSlider.css\";\n\nexport interface CarouselSliderProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Collection of slides to render\n */\n children: Array<ReactElement<CarouselSlideProps>>;\n /**\n * Callback fired when the selected slide change.\n **/\n onSelectionChange?: (\n event: SyntheticEvent<HTMLDivElement>,\n index: number,\n ) => void;\n}\n\nconst withBaseName = makePrefixer(\"saltCarouselSlider\");\n\nexport const CarouselSlider = forwardRef<HTMLDivElement, CarouselSliderProps>(\n function CarouselSlider(\n { children, onKeyDown, onScroll, onSelectionChange, ...rest },\n propRef,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-carousel-slider\",\n css: carouselSliderCss,\n window: targetWindow,\n });\n const containerRef = useRef<HTMLDivElement>(null);\n const hasRun = useRef(false);\n const { slides, activeSlideIndex, focusedSlideIndex, visibleSlides } =\n useContext(CarouselStateContext);\n const dispatch = useContext(CarouselDispatchContext);\n const slideIds = [...slides.keys()];\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.repeat) return;\n switch (event.key) {\n case \"ArrowLeft\": {\n const prevIndex =\n focusedSlideIndex && focusedSlideIndex > activeSlideIndex\n ? focusedSlideIndex - 1\n : activeSlideIndex - 1;\n const prevId = slideIds[prevIndex] || null;\n\n if (!prevId) break;\n dispatch({ type: \"scroll\", payload: prevId });\n onSelectionChange?.(event, prevIndex);\n slides.get(prevId)?.element.focus();\n\n break;\n }\n case \"ArrowRight\": {\n const nextIndex = activeSlideIndex + 1;\n const nextId = slideIds[nextIndex] || null;\n\n if (!nextId) break;\n\n dispatch({ type: \"scroll\", payload: nextId });\n onSelectionChange?.(event, nextIndex);\n\n slides.get(nextId)?.element.focus();\n\n break;\n }\n }\n onKeyDown?.(event);\n };\n\n const handleScroll = (event: UIEvent<HTMLDivElement>) => {\n const container = containerRef?.current;\n if (!container) return;\n const scrollLeft = container.scrollLeft;\n const slideWidth = container.offsetWidth / visibleSlides;\n const newIndex = Math.round(scrollLeft / slideWidth) || 0;\n\n if (newIndex !== activeSlideIndex) {\n dispatch({ type: \"move\", payload: slideIds[newIndex] });\n onSelectionChange?.(event, newIndex);\n }\n onScroll?.(event);\n };\n\n useLayoutEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n const scrollBehavior = hasRun.current ? \"smooth\" : \"instant\";\n const slideWidth = container.offsetWidth / visibleSlides;\n\n requestAnimationFrame(() => {\n container.scrollTo({\n left: focusedSlideIndex * slideWidth,\n // @ts-ignore ScrollBehavior typescript definition missing instant\n behavior: scrollBehavior,\n });\n });\n\n hasRun.current = true;\n }, [focusedSlideIndex, visibleSlides]);\n\n const ref = useForkRef(propRef, containerRef);\n return (\n <div\n ref={ref}\n className={withBaseName()}\n tabIndex={-1}\n onKeyDown={handleKeyDown}\n onScroll={handleScroll}\n {...rest}\n >\n {children}\n </div>\n );\n },\n);\n"],"names":["CarouselSlider","carouselSliderCss"],"mappings":";;;;;;;;AAmCA,MAAM,YAAA,GAAe,aAAa,oBAAoB,CAAA;AAE/C,MAAM,cAAiB,GAAA,UAAA;AAAA,EAC5B,SAASA,eACP,CAAA,EAAE,QAAU,EAAA,SAAA,EAAW,UAAU,iBAAmB,EAAA,GAAG,IAAK,EAAA,EAC5D,OACA,EAAA;AACA,IAAA,MAAM,eAAe,SAAU,EAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,sBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA;AAAA,KACT,CAAA;AACD,IAAM,MAAA,YAAA,GAAe,OAAuB,IAAI,CAAA;AAChD,IAAM,MAAA,MAAA,GAAS,OAAO,KAAK,CAAA;AAC3B,IAAA,MAAM,EAAE,MAAQ,EAAA,gBAAA,EAAkB,mBAAmB,aAAc,EAAA,GACjE,WAAW,oBAAoB,CAAA;AACjC,IAAM,MAAA,QAAA,GAAW,WAAW,uBAAuB,CAAA;AACnD,IAAA,MAAM,QAAW,GAAA,CAAC,GAAG,MAAA,CAAO,MAAM,CAAA;AAElC,IAAM,MAAA,aAAA,GAAgB,CAAC,KAAyC,KAAA;AAvDpE,MAAA,IAAA,EAAA,EAAA,EAAA;AAwDM,MAAA,IAAI,MAAM,MAAQ,EAAA;AAClB,MAAA,QAAQ,MAAM,GAAK;AAAA,QACjB,KAAK,WAAa,EAAA;AAChB,UAAA,MAAM,YACJ,iBAAqB,IAAA,iBAAA,GAAoB,gBACrC,GAAA,iBAAA,GAAoB,IACpB,gBAAmB,GAAA,CAAA;AACzB,UAAM,MAAA,MAAA,GAAS,QAAS,CAAA,SAA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,GAAG,IAAA;AAAA,QAEH;AAAA;AAAA,KACH;AAAA;AAGN;;;;"}
package/dist-es/index.js CHANGED
@@ -14,9 +14,9 @@ export { isPlainObject } from './utils/isPlainObject.js';
14
14
  export { partition } from './utils/partition.js';
15
15
  export { useClickOutside } from './utils/useClickOutside.js';
16
16
  export { useEventCallback } from './utils/useEventCallback.js';
17
+ export { useIsViewportLargerThanBreakpoint } from './utils/useIsViewportLargerThanBreakpoint.js';
17
18
  export { useLayoutEffectOnce } from './utils/useLayoutEffectOnce.js';
18
19
  export { useLayoutEffectSkipFirst } from './utils/useLayoutEffectSkipFirst.js';
19
- export { useIsViewportLargerThanBreakpoint } from './utils/useIsViewportLargerThanBreakpoint.js';
20
20
  export { useOverflowDetection } from './utils/useOverflowDetection.js';
21
21
  export { useSlideSelection } from './utils/useSlideSelection.js';
22
22
  export { AppHeader } from './app-header/AppHeader.js';
@@ -33,6 +33,8 @@ export { useCalendar } from './calendar/useCalendar.js';
33
33
  export { isDateRangeSelection, isMultipleDateSelection, isSingleSelectionValueType, useCalendarSelection, useCalendarSelectionDay } from './calendar/useCalendarSelection.js';
34
34
  export { Carousel } from './carousel/Carousel.js';
35
35
  export { CarouselSlide } from './carousel/CarouselSlide.js';
36
+ export { CarouselSlider } from './carousel/CarouselSlider.js';
37
+ export { CarouselControls } from './carousel/CarouselControls.js';
36
38
  export { CascadingMenu } from './cascading-menu/CascadingMenu.js';
37
39
  export { ColorChooser } from './color-chooser/ColorChooser.js';
38
40
  export { Color } from './color-chooser/Color.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,36 +1,23 @@
1
- import { type HTMLAttributes, type ReactElement } from "react";
2
- import type { CarouselSlideProps } from "./CarouselSlide";
1
+ import { type ResponsiveProp } from "@salt-ds/core";
2
+ import { type HTMLAttributes } from "react";
3
3
  export interface CarouselProps extends HTMLAttributes<HTMLDivElement> {
4
4
  /**
5
5
  * The initial Index enables you to select the active slide in the carousel.
6
6
  * Optional, default 0.
7
7
  **/
8
- initialIndex?: number;
8
+ defaultActiveSlideIndex?: number;
9
9
  /**
10
- * The animation when the slides are shown.
11
- * Optional. Defaults to `slide`
10
+ * Controlled index of active slide in the carousel.
12
11
  **/
13
- animation?: "slide" | "fade";
12
+ activeSlideIndex?: number;
14
13
  /**
15
- * If this props is passed it will set the aria-label with value to the carousel container.
16
- * Optional. Defaults to undefined
14
+ * Set the placement of the CarouselControls relative to the CarouselSlider element. Defaults to `top`.
17
15
  */
18
- carouselDescription?: string;
16
+ controlsPlacement?: "top" | "bottom";
19
17
  /**
20
- * Collection of slides to render
21
- * Component must implement CarouselSlideProps. Mandatory.
22
- */
23
- children: Array<ReactElement<CarouselSlideProps>>;
24
- /**
25
- * This prop will enable compact / reduced width mode.
26
- * The navigation buttons would be part of indicators
27
- * Optional. Defaults to false
18
+ * Number of slides visible at a time.
19
+ * Optional, default 1.
28
20
  **/
29
- compact?: boolean;
30
- /**
31
- * It sets the id for the Carousel Container.
32
- * String. Optional
33
- */
34
- id?: string;
21
+ visibleSlides?: ResponsiveProp<number>;
35
22
  }
36
23
  export declare const Carousel: import("react").ForwardRefExoticComponent<CarouselProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ import { type CarouselReducerDispatch, type CarouselReducerState } from "./CarouselReducer";
3
+ export declare const CarouselStateContext: import("react").Context<CarouselReducerState>;
4
+ export declare const CarouselDispatchContext: import("react").Context<CarouselReducerDispatch>;
5
+ export declare function CarouselProvider({ children, activeSlideIndex: activeSlideIndexProp, defaultActiveSlideIndex, visibleSlides, id, }: {
6
+ children: ReactNode;
7
+ activeSlideIndex?: number;
8
+ defaultActiveSlideIndex?: number;
9
+ visibleSlides?: number;
10
+ id?: string;
11
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { type HTMLAttributes, type ReactNode, type SyntheticEvent } from "react";
2
+ export interface CarouselControlsProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
3
+ /**
4
+ * Callback when Back button is clicked.
5
+ */
6
+ onPrevious?: (event: SyntheticEvent<HTMLButtonElement>, index: number) => void;
7
+ /**
8
+ * Callback when Next button is clicked.
9
+ */
10
+ onNext?: (event: SyntheticEvent<HTMLButtonElement>, index: number) => void;
11
+ /**
12
+ * Location of the label relative to the controls.
13
+ *
14
+ * Either 'left', or 'right'`.
15
+ */
16
+ labelPlacement?: "left" | "right";
17
+ /**
18
+ * If `true`, the carousel controls will be disabled.
19
+ * **/
20
+ disabled?: boolean;
21
+ /**
22
+ * The title of the carousel that accompanies the controls.
23
+ */
24
+ title?: ReactNode;
25
+ }
26
+ export declare const CarouselControls: import("react").ForwardRefExoticComponent<CarouselControlsProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,30 @@
1
+ import type { Dispatch } from "react";
2
+ import type { CarouselSlideId, CarouselSlideMeta } from "./CarouselSlide";
3
+ export interface CarouselReducerState {
4
+ slides: Map<CarouselSlideId, CarouselSlideMeta>;
5
+ activeSlideIndex: number;
6
+ visibleSlides: number;
7
+ focusedSlideIndex: number;
8
+ carouselId?: string;
9
+ }
10
+ export declare type CarouselReducerAction = {
11
+ type: "register";
12
+ payload: [CarouselSlideId, CarouselSlideMeta];
13
+ } | {
14
+ type: "unregister";
15
+ payload: CarouselSlideId;
16
+ } | {
17
+ type: "updateSlideCount";
18
+ payload: number;
19
+ } | {
20
+ type: "move";
21
+ payload: CarouselSlideId;
22
+ } | {
23
+ type: "moveToIndex";
24
+ payload: number;
25
+ } | {
26
+ type: "scroll";
27
+ payload: CarouselSlideId;
28
+ };
29
+ export declare type CarouselReducerDispatch = Dispatch<CarouselReducerAction>;
30
+ export declare function carouselReducer(state: CarouselReducerState, action: CarouselReducerAction): CarouselReducerState;
@@ -1,9 +1,32 @@
1
- import { type ElementType, type HTMLAttributes, type ReactElement } from "react";
2
- export interface CarouselSlideProps extends HTMLAttributes<HTMLDivElement> {
3
- ButtonBar?: ElementType;
4
- Media: ReactElement;
5
- description?: string;
6
- title?: string;
7
- contentAlignment?: "center" | "left" | "right";
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ export declare type CarouselSlideId = string;
3
+ export declare type CarouselSlideElement = HTMLDivElement;
4
+ export declare type CarouselSlideMeta = {
5
+ element: CarouselSlideElement;
6
+ slideDescription?: string;
7
+ };
8
+ export interface CarouselSlideProps extends ComponentProps<"div"> {
9
+ /**
10
+ * Actions to be displayed in the content footer.
11
+ **/
12
+ actions?: ReactNode;
13
+ /**
14
+ * Media content to be displayed inside the slide. This could include images, videos, etc., that are visually prominent.
15
+ * It differs from children in that media is intended to be the main visual element of the slide.
16
+ **/
17
+ media?: ReactNode;
18
+ /**
19
+ * The appearance of the slide. Options are 'bordered', and 'transparent'.
20
+ * 'transparent' is the default value.
21
+ **/
22
+ appearance?: "bordered" | "transparent";
23
+ /**
24
+ * Header content to be displayed at the top of the slide. This can be text or any other React node.
25
+ **/
26
+ header?: ReactNode;
27
+ /**
28
+ * Carousel slide id.
29
+ */
30
+ id?: string;
8
31
  }
9
- export declare const CarouselSlide: import("react").ForwardRefExoticComponent<CarouselSlideProps & import("react").RefAttributes<HTMLDivElement>>;
32
+ export declare const CarouselSlide: import("react").ForwardRefExoticComponent<Omit<CarouselSlideProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,13 @@
1
+ import { type HTMLAttributes, type ReactElement, type SyntheticEvent } from "react";
2
+ import type { CarouselSlideProps } from "./CarouselSlide";
3
+ export interface CarouselSliderProps extends HTMLAttributes<HTMLDivElement> {
4
+ /**
5
+ * Collection of slides to render
6
+ */
7
+ children: Array<ReactElement<CarouselSlideProps>>;
8
+ /**
9
+ * Callback fired when the selected slide change.
10
+ **/
11
+ onSelectionChange?: (event: SyntheticEvent<HTMLDivElement>, index: number) => void;
12
+ }
13
+ export declare const CarouselSlider: import("react").ForwardRefExoticComponent<CarouselSliderProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,2 +1,4 @@
1
1
  export * from "./Carousel";
2
2
  export * from "./CarouselSlide";
3
+ export * from "./CarouselSlider";
4
+ export * from "./CarouselControls";
@@ -5,8 +5,8 @@ export * from "./isPlainObject";
5
5
  export * from "./partition";
6
6
  export * from "./useClickOutside";
7
7
  export * from "./useEventCallback";
8
+ export * from "./useIsViewportLargerThanBreakpoint";
8
9
  export * from "./useLayoutEffectOnce";
9
10
  export * from "./useLayoutEffectSkipFirst";
10
- export * from "./useIsViewportLargerThanBreakpoint";
11
11
  export * from "./useOverflowDetection";
12
12
  export * from "./useSlideSelection";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salt-ds/lab",
3
- "version": "1.0.0-alpha.65",
3
+ "version": "1.0.0-alpha.66",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@floating-ui/react": "^0.26.28",
24
- "@salt-ds/core": "^1.44.0",
24
+ "@salt-ds/core": "^1.44.1",
25
25
  "@salt-ds/date-adapters": "0.1.0-alpha.3",
26
26
  "@salt-ds/icons": "^1.13.2",
27
27
  "@salt-ds/styles": "0.2.1",