@salt-ds/lab 1.0.0-alpha.65 → 1.0.0-alpha.67
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.
- package/CHANGELOG.md +65 -0
- package/css/salt-lab.css +111 -214
- package/dist-cjs/carousel/Carousel.css.js +1 -1
- package/dist-cjs/carousel/Carousel.js +30 -87
- package/dist-cjs/carousel/Carousel.js.map +1 -1
- package/dist-cjs/carousel/CarouselContext.js +62 -0
- package/dist-cjs/carousel/CarouselContext.js.map +1 -0
- package/dist-cjs/carousel/CarouselControls.css.js +6 -0
- package/dist-cjs/carousel/CarouselControls.css.js.map +1 -0
- package/dist-cjs/carousel/CarouselControls.js +122 -0
- package/dist-cjs/carousel/CarouselControls.js.map +1 -0
- package/dist-cjs/carousel/CarouselReducer.js +77 -0
- package/dist-cjs/carousel/CarouselReducer.js.map +1 -0
- package/dist-cjs/carousel/CarouselSlide.css.js +6 -0
- package/dist-cjs/carousel/CarouselSlide.css.js.map +1 -0
- package/dist-cjs/carousel/CarouselSlide.js +95 -45
- package/dist-cjs/carousel/CarouselSlide.js.map +1 -1
- package/dist-cjs/carousel/CarouselSlider.css.js +6 -0
- package/dist-cjs/carousel/CarouselSlider.css.js.map +1 -0
- package/dist-cjs/carousel/CarouselSlider.js +93 -0
- package/dist-cjs/carousel/CarouselSlider.js.map +1 -0
- package/dist-cjs/index.js +6 -8
- package/dist-cjs/index.js.map +1 -1
- package/dist-es/carousel/Carousel.css.js +1 -1
- package/dist-es/carousel/Carousel.js +32 -89
- package/dist-es/carousel/Carousel.js.map +1 -1
- package/dist-es/carousel/CarouselContext.js +58 -0
- package/dist-es/carousel/CarouselContext.js.map +1 -0
- package/dist-es/carousel/CarouselControls.css.js +4 -0
- package/dist-es/carousel/CarouselControls.css.js.map +1 -0
- package/dist-es/carousel/CarouselControls.js +120 -0
- package/dist-es/carousel/CarouselControls.js.map +1 -0
- package/dist-es/carousel/CarouselReducer.js +75 -0
- package/dist-es/carousel/CarouselReducer.js.map +1 -0
- package/dist-es/carousel/CarouselSlide.css.js +4 -0
- package/dist-es/carousel/CarouselSlide.css.js.map +1 -0
- package/dist-es/carousel/CarouselSlide.js +96 -46
- package/dist-es/carousel/CarouselSlide.js.map +1 -1
- package/dist-es/carousel/CarouselSlider.css.js +4 -0
- package/dist-es/carousel/CarouselSlider.css.js.map +1 -0
- package/dist-es/carousel/CarouselSlider.js +91 -0
- package/dist-es/carousel/CarouselSlider.js.map +1 -0
- package/dist-es/index.js +3 -4
- package/dist-es/index.js.map +1 -1
- package/dist-types/carousel/Carousel.d.ts +10 -23
- package/dist-types/carousel/CarouselContext.d.ts +11 -0
- package/dist-types/carousel/CarouselControls.d.ts +26 -0
- package/dist-types/carousel/CarouselReducer.d.ts +30 -0
- package/dist-types/carousel/CarouselSlide.d.ts +31 -8
- package/dist-types/carousel/CarouselSlider.d.ts +13 -0
- package/dist-types/carousel/index.d.ts +2 -0
- package/dist-types/index.d.ts +0 -1
- package/dist-types/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist-cjs/stepped-tracker/Step.Connector.css.js +0 -6
- package/dist-cjs/stepped-tracker/Step.Connector.css.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.Connector.js +0 -21
- package/dist-cjs/stepped-tracker/Step.Connector.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.Description.css.js +0 -6
- package/dist-cjs/stepped-tracker/Step.Description.css.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.Description.js +0 -35
- package/dist-cjs/stepped-tracker/Step.Description.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.ExpandTrigger.css.js +0 -6
- package/dist-cjs/stepped-tracker/Step.ExpandTrigger.css.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.ExpandTrigger.js +0 -38
- package/dist-cjs/stepped-tracker/Step.ExpandTrigger.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.Icon.css.js +0 -6
- package/dist-cjs/stepped-tracker/Step.Icon.css.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.Icon.js +0 -57
- package/dist-cjs/stepped-tracker/Step.Icon.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.Label.css.js +0 -6
- package/dist-cjs/stepped-tracker/Step.Label.css.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.Label.js +0 -37
- package/dist-cjs/stepped-tracker/Step.Label.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.SROnly.css.js +0 -6
- package/dist-cjs/stepped-tracker/Step.SROnly.css.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.SROnly.js +0 -21
- package/dist-cjs/stepped-tracker/Step.SROnly.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.css.js +0 -6
- package/dist-cjs/stepped-tracker/Step.css.js.map +0 -1
- package/dist-cjs/stepped-tracker/Step.js +0 -161
- package/dist-cjs/stepped-tracker/Step.js.map +0 -1
- package/dist-cjs/stepped-tracker/SteppedTracker.Provider.js +0 -19
- package/dist-cjs/stepped-tracker/SteppedTracker.Provider.js.map +0 -1
- package/dist-cjs/stepped-tracker/SteppedTracker.css.js +0 -6
- package/dist-cjs/stepped-tracker/SteppedTracker.css.js.map +0 -1
- package/dist-cjs/stepped-tracker/SteppedTracker.js +0 -36
- package/dist-cjs/stepped-tracker/SteppedTracker.js.map +0 -1
- package/dist-cjs/stepped-tracker/stepReducer.js +0 -155
- package/dist-cjs/stepped-tracker/stepReducer.js.map +0 -1
- package/dist-cjs/stepped-tracker/useStepReducer.js +0 -18
- package/dist-cjs/stepped-tracker/useStepReducer.js.map +0 -1
- package/dist-cjs/stepped-tracker/utils.js +0 -121
- package/dist-cjs/stepped-tracker/utils.js.map +0 -1
- package/dist-es/stepped-tracker/Step.Connector.css.js +0 -4
- package/dist-es/stepped-tracker/Step.Connector.css.js.map +0 -1
- package/dist-es/stepped-tracker/Step.Connector.js +0 -19
- package/dist-es/stepped-tracker/Step.Connector.js.map +0 -1
- package/dist-es/stepped-tracker/Step.Description.css.js +0 -4
- package/dist-es/stepped-tracker/Step.Description.css.js.map +0 -1
- package/dist-es/stepped-tracker/Step.Description.js +0 -33
- package/dist-es/stepped-tracker/Step.Description.js.map +0 -1
- package/dist-es/stepped-tracker/Step.ExpandTrigger.css.js +0 -4
- package/dist-es/stepped-tracker/Step.ExpandTrigger.css.js.map +0 -1
- package/dist-es/stepped-tracker/Step.ExpandTrigger.js +0 -36
- package/dist-es/stepped-tracker/Step.ExpandTrigger.js.map +0 -1
- package/dist-es/stepped-tracker/Step.Icon.css.js +0 -4
- package/dist-es/stepped-tracker/Step.Icon.css.js.map +0 -1
- package/dist-es/stepped-tracker/Step.Icon.js +0 -55
- package/dist-es/stepped-tracker/Step.Icon.js.map +0 -1
- package/dist-es/stepped-tracker/Step.Label.css.js +0 -4
- package/dist-es/stepped-tracker/Step.Label.css.js.map +0 -1
- package/dist-es/stepped-tracker/Step.Label.js +0 -35
- package/dist-es/stepped-tracker/Step.Label.js.map +0 -1
- package/dist-es/stepped-tracker/Step.SROnly.css.js +0 -4
- package/dist-es/stepped-tracker/Step.SROnly.css.js.map +0 -1
- package/dist-es/stepped-tracker/Step.SROnly.js +0 -19
- package/dist-es/stepped-tracker/Step.SROnly.js.map +0 -1
- package/dist-es/stepped-tracker/Step.css.js +0 -4
- package/dist-es/stepped-tracker/Step.css.js.map +0 -1
- package/dist-es/stepped-tracker/Step.js +0 -159
- package/dist-es/stepped-tracker/Step.js.map +0 -1
- package/dist-es/stepped-tracker/SteppedTracker.Provider.js +0 -15
- package/dist-es/stepped-tracker/SteppedTracker.Provider.js.map +0 -1
- package/dist-es/stepped-tracker/SteppedTracker.css.js +0 -4
- package/dist-es/stepped-tracker/SteppedTracker.css.js.map +0 -1
- package/dist-es/stepped-tracker/SteppedTracker.js +0 -34
- package/dist-es/stepped-tracker/SteppedTracker.js.map +0 -1
- package/dist-es/stepped-tracker/stepReducer.js +0 -153
- package/dist-es/stepped-tracker/stepReducer.js.map +0 -1
- package/dist-es/stepped-tracker/useStepReducer.js +0 -16
- package/dist-es/stepped-tracker/useStepReducer.js.map +0 -1
- package/dist-es/stepped-tracker/utils.js +0 -114
- package/dist-es/stepped-tracker/utils.js.map +0 -1
- package/dist-types/stepped-tracker/Step.Connector.d.ts +0 -1
- package/dist-types/stepped-tracker/Step.Description.d.ts +0 -4
- package/dist-types/stepped-tracker/Step.ExpandTrigger.d.ts +0 -5
- package/dist-types/stepped-tracker/Step.Icon.d.ts +0 -8
- package/dist-types/stepped-tracker/Step.Label.d.ts +0 -4
- package/dist-types/stepped-tracker/Step.SROnly.d.ts +0 -5
- package/dist-types/stepped-tracker/Step.d.ts +0 -2
- package/dist-types/stepped-tracker/Step.types.d.ts +0 -19
- package/dist-types/stepped-tracker/SteppedTracker.Provider.d.ts +0 -9
- package/dist-types/stepped-tracker/SteppedTracker.d.ts +0 -2
- package/dist-types/stepped-tracker/SteppedTracker.types.d.ts +0 -6
- package/dist-types/stepped-tracker/index.d.ts +0 -6
- package/dist-types/stepped-tracker/stepReducer.d.ts +0 -2
- package/dist-types/stepped-tracker/stepReducer.types.d.ts +0 -27
- package/dist-types/stepped-tracker/useStepReducer.d.ts +0 -3
- package/dist-types/stepped-tracker/utils.d.ts +0 -10
|
@@ -1,56 +1,106 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { makePrefixer } from '@salt-ds/core';
|
|
3
|
-
import {
|
|
2
|
+
import { makePrefixer, useIdMemo, useId, useForkRef } from '@salt-ds/core';
|
|
3
|
+
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
4
|
+
import { useWindow } from '@salt-ds/window';
|
|
4
5
|
import { clsx } from 'clsx';
|
|
6
|
+
import { forwardRef, useContext, useRef, useEffect } from 'react';
|
|
7
|
+
import { CarouselDispatchContext, CarouselStateContext } from './CarouselContext.js';
|
|
8
|
+
import css_248z from './CarouselSlide.css.js';
|
|
5
9
|
|
|
6
10
|
const withBaseName = makePrefixer("saltCarouselSlide");
|
|
7
11
|
const CarouselSlide = forwardRef(
|
|
8
|
-
function CarouselSlide2({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
function CarouselSlide2({
|
|
13
|
+
actions,
|
|
14
|
+
appearance,
|
|
15
|
+
media,
|
|
16
|
+
header,
|
|
17
|
+
children,
|
|
18
|
+
"aria-labelledby": ariaLabelledBy,
|
|
19
|
+
style,
|
|
20
|
+
id: idProp,
|
|
21
|
+
...rest
|
|
22
|
+
}, refProp) {
|
|
23
|
+
const targetWindow = useWindow();
|
|
24
|
+
useComponentCssInjection({
|
|
25
|
+
testId: "salt-carousel-slide",
|
|
26
|
+
css: css_248z,
|
|
27
|
+
window: targetWindow
|
|
28
|
+
});
|
|
29
|
+
const dispatch = useContext(CarouselDispatchContext);
|
|
30
|
+
const { slides, visibleSlides, activeSlideIndex } = useContext(CarouselStateContext);
|
|
31
|
+
const slideRef = useRef(null);
|
|
32
|
+
const headerRef = useRef(null);
|
|
33
|
+
const id = useIdMemo(idProp);
|
|
34
|
+
const announcerId = useId();
|
|
35
|
+
const slideCount = slides.size;
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
var _a;
|
|
38
|
+
if (!slideRef.current) return;
|
|
39
|
+
dispatch({
|
|
40
|
+
type: "register",
|
|
41
|
+
payload: [
|
|
42
|
+
id,
|
|
15
43
|
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
[withBaseName("textContainerLeft")]: contentAlignment === "left"
|
|
19
|
-
}),
|
|
20
|
-
children: [
|
|
21
|
-
title && /* @__PURE__ */ jsx(
|
|
22
|
-
"div",
|
|
23
|
-
{
|
|
24
|
-
"aria-level": 1,
|
|
25
|
-
className: withBaseName("titleContainer"),
|
|
26
|
-
role: "heading",
|
|
27
|
-
children: title
|
|
28
|
-
}
|
|
29
|
-
),
|
|
30
|
-
description && /* @__PURE__ */ jsx("div", { className: withBaseName("descriptionContainer"), children: description })
|
|
31
|
-
]
|
|
44
|
+
element: slideRef.current,
|
|
45
|
+
slideDescription: (_a = headerRef == null ? void 0 : headerRef.current) == null ? void 0 : _a.innerText
|
|
32
46
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
return () => dispatch({ type: "unregister", payload: id });
|
|
50
|
+
}, [dispatch, id]);
|
|
51
|
+
const SlideStyles = {
|
|
52
|
+
"--carousel-slide-width": visibleSlides > 1 ? `calc((100% / ${visibleSlides}) - var(--salt-spacing-200)/${visibleSlides})` : void 0,
|
|
53
|
+
...style
|
|
54
|
+
};
|
|
55
|
+
const ref = useForkRef(refProp, slideRef);
|
|
56
|
+
const slideIds = [...slides.keys()];
|
|
57
|
+
const index = slideIds.indexOf(id || slideIds[0]);
|
|
58
|
+
const helperText = `${index + 1} of ${slideCount}`;
|
|
59
|
+
const isVisible = index >= activeSlideIndex && index < activeSlideIndex + visibleSlides;
|
|
60
|
+
return /* @__PURE__ */ jsxs(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
role: "group",
|
|
64
|
+
"aria-roledescription": "slide",
|
|
65
|
+
"aria-labelledby": clsx(ariaLabelledBy, announcerId),
|
|
66
|
+
id,
|
|
67
|
+
className: clsx(withBaseName(), {
|
|
68
|
+
[withBaseName("bordered")]: appearance === "bordered"
|
|
69
|
+
}),
|
|
70
|
+
style: SlideStyles,
|
|
71
|
+
tabIndex: isVisible ? 0 : -1,
|
|
72
|
+
hidden: !isVisible,
|
|
73
|
+
...rest,
|
|
74
|
+
ref,
|
|
75
|
+
children: [
|
|
76
|
+
media,
|
|
77
|
+
children && /* @__PURE__ */ jsxs(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
className: clsx(withBaseName("container"), {
|
|
81
|
+
[withBaseName("card")]: appearance === "bordered"
|
|
82
|
+
}),
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ jsxs("div", { className: withBaseName("content"), children: [
|
|
85
|
+
isVisible && /* @__PURE__ */ jsx(
|
|
86
|
+
"span",
|
|
87
|
+
{
|
|
88
|
+
id: announcerId,
|
|
89
|
+
className: withBaseName("sr-only"),
|
|
90
|
+
"aria-hidden": "true",
|
|
91
|
+
children: helperText
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ jsx("div", { ref: headerRef, children: header }),
|
|
95
|
+
/* @__PURE__ */ jsx("div", { children })
|
|
96
|
+
] }),
|
|
97
|
+
isVisible && actions
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
);
|
|
54
104
|
}
|
|
55
105
|
);
|
|
56
106
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselSlide.js","sources":["../src/carousel/CarouselSlide.tsx"],"sourcesContent":["import { makePrefixer } from \"@salt-ds/core\";\nimport {\n type
|
|
1
|
+
{"version":3,"file":"CarouselSlide.js","sources":["../src/carousel/CarouselSlide.tsx"],"sourcesContent":["import { makePrefixer, useForkRef, useId, useIdMemo } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {\n type ComponentProps,\n type ReactNode,\n forwardRef,\n useContext,\n useEffect,\n useRef,\n} from \"react\";\nimport {\n CarouselDispatchContext,\n CarouselStateContext,\n} from \"./CarouselContext\";\nimport carouselSlideCss from \"./CarouselSlide.css\";\n\nexport type CarouselSlideId = string;\nexport type CarouselSlideElement = HTMLDivElement;\nexport type CarouselSlideMeta = {\n element: CarouselSlideElement;\n slideDescription?: string;\n};\nexport interface CarouselSlideProps extends ComponentProps<\"div\"> {\n /**\n * Actions to be displayed in the content footer.\n **/\n actions?: ReactNode;\n /**\n * Media content to be displayed inside the slide. This could include images, videos, etc., that are visually prominent.\n * It differs from children in that media is intended to be the main visual element of the slide.\n **/\n media?: ReactNode;\n /**\n * The appearance of the slide. Options are 'bordered', and 'transparent'.\n * 'transparent' is the default value.\n **/\n appearance?: \"bordered\" | \"transparent\";\n /**\n * Header content to be displayed at the top of the slide. This can be text or any other React node.\n **/\n header?: ReactNode;\n /**\n * Carousel slide id.\n */\n id?: string;\n}\n\nconst withBaseName = makePrefixer(\"saltCarouselSlide\");\n\nexport const CarouselSlide = forwardRef<HTMLDivElement, CarouselSlideProps>(\n function CarouselSlide(\n {\n actions,\n appearance,\n media,\n header,\n children,\n \"aria-labelledby\": ariaLabelledBy,\n style,\n id: idProp,\n ...rest\n },\n refProp,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-carousel-slide\",\n css: carouselSlideCss,\n window: targetWindow,\n });\n const dispatch = useContext(CarouselDispatchContext);\n const { slides, visibleSlides, activeSlideIndex } =\n useContext(CarouselStateContext);\n\n const slideRef = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const id = useIdMemo(idProp);\n const announcerId = useId();\n const slideCount = slides.size;\n\n useEffect(() => {\n if (!slideRef.current) return;\n\n dispatch({\n type: \"register\",\n payload: [\n id,\n {\n element: slideRef.current,\n slideDescription: headerRef?.current?.innerText,\n },\n ],\n });\n return () => dispatch({ type: \"unregister\", payload: id });\n }, [dispatch, id]);\n\n const SlideStyles = {\n \"--carousel-slide-width\":\n visibleSlides > 1\n ? `calc((100% / ${visibleSlides}) - var(--salt-spacing-200)/${visibleSlides})`\n : undefined,\n ...style,\n };\n\n const ref = useForkRef(refProp, slideRef);\n const slideIds = [...slides.keys()];\n const index = slideIds.indexOf(id || slideIds[0]);\n const helperText = `${index + 1} of ${slideCount}`;\n const isVisible =\n index >= activeSlideIndex && index < activeSlideIndex + visibleSlides;\n\n return (\n <div\n role=\"group\"\n aria-roledescription=\"slide\"\n aria-labelledby={clsx(ariaLabelledBy, announcerId)}\n id={id}\n className={clsx(withBaseName(), {\n [withBaseName(\"bordered\")]: appearance === \"bordered\",\n })}\n style={SlideStyles}\n tabIndex={isVisible ? 0 : -1}\n hidden={!isVisible}\n {...rest}\n ref={ref}\n >\n {media}\n {children && (\n <div\n className={clsx(withBaseName(\"container\"), {\n [withBaseName(\"card\")]: appearance === \"bordered\",\n })}\n >\n <div className={withBaseName(\"content\")}>\n {isVisible && (\n <span\n id={announcerId}\n className={withBaseName(\"sr-only\")}\n aria-hidden=\"true\"\n >\n {helperText}\n </span>\n )}\n <div ref={headerRef}>{header}</div>\n <div>{children}</div>\n </div>\n {isVisible && actions}\n </div>\n )}\n </div>\n );\n },\n);\n"],"names":["CarouselSlide","carouselSlideCss"],"mappings":";;;;;;;;;AAiDA,MAAM,YAAA,GAAe,aAAa,mBAAmB,CAAA;AAE9C,MAAM,aAAgB,GAAA,UAAA;AAAA,EAC3B,SAASA,cACP,CAAA;AAAA,IACE,OAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,iBAAmB,EAAA,cAAA;AAAA,IACnB,KAAA;AAAA,IACA,EAAI,EAAA,MAAA;AAAA,IACJ,GAAG;AAAA,KAEL,OACA,EAAA;AACA,IAAA,MAAM,eAAe,SAAU,EAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,qBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA;AAAA,KACT,CAAA;AACD,IAAM,MAAA,QAAA,GAAW,WAAW,uBAAuB,CAAA;AACnD,IAAA,MAAM,EAAE,MAAQ,EAAA,aAAA,EAAe,gBAAiB,EAAA,GAC9C,WAAW,oBAAoB,CAAA;AAE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AAA,EAAI,GAAK,EAAA,SAAA,EAAY,QAAO,EAAA,MAAA,EAAA,CAAA;AAAA,kCAC7B,GAAA,CAAC,SAAK,QAAS,EAAA;AAAA,iBACjB,EAAA,CAAA;AAAA,gBACC,SAAa,IAAA;AAAA;AAAA;AAAA;AAChB;AAAA;AAAA,KAEJ;AAAA;AAGN;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var css_248z = ".saltCarouselSlider {\n display: flex;\n scroll-snap-type: x mandatory;\n overflow-x: auto;\n scroll-behavior: smooth;\n width: 100%;\n gap: var(--salt-spacing-100);\n grid-area: slider;\n}\n@supports (scrollbar-width: none) {\n .saltCarouselSlider {\n scrollbar-width: none;\n }\n}\n@supports not (scrollbar-width: none) {\n .saltCarouselSlider::-webkit-scrollbar {\n display: none;\n }\n}\n";
|
|
2
|
+
|
|
3
|
+
export { css_248z as default };
|
|
4
|
+
//# sourceMappingURL=CarouselSlider.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CarouselSlider.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -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,IA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;AACnD,MAAM,MAAA,UAAA,GAAa,UAAU,WAAc,GAAA,aAAA;AAE3C,MAAA,qBAAA,CAAsB,MAAM;AAC1B,QAAA,SAAA,CAAU,QAAS,CAAA;AAAA,UACjB,MAAM,iBAAoB,GAAA,UAAA;AAAA;AAAA,UAE1B,QAAU,EAAA;AAAA,SACX,CAAA;AAAA,OACF,CAAA;AAED,MAAA,MAAA,CAAO,OAAU,GAAA,IAAA;AAAA,KAChB,EAAA,CAAC,iBAAmB,EAAA,aAAa,CAAC,CAAA;AAErC,IAAM,MAAA,GAAA,GAAM,UAAW,CAAA,OAAA,EAAS,YAAY,CAAA;AAC5C,IACE,uBAAA,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,WAAW,YAAa,EAAA;AAAA,QACxB,QAAU,EAAA,CAAA,CAAA;AAAA,QACV,SAAW,EAAA,aAAA;AAAA,QACX,QAAU,EAAA,YAAA;AAAA,QACT,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';
|
|
@@ -124,9 +126,6 @@ export { SplitHandle } from './splitter/SplitHandle.js';
|
|
|
124
126
|
export { StaticList } from './static-list/StaticList.js';
|
|
125
127
|
export { StaticListItem } from './static-list/StaticListItem.js';
|
|
126
128
|
export { StaticListItemContent } from './static-list/StaticListItemContent.js';
|
|
127
|
-
export { SteppedTracker } from './stepped-tracker/SteppedTracker.js';
|
|
128
|
-
export { Step } from './stepped-tracker/Step.js';
|
|
129
|
-
export { useStepReducer } from './stepped-tracker/useStepReducer.js';
|
|
130
129
|
export { SystemStatus } from './system-status/SystemStatus.js';
|
|
131
130
|
export { SystemStatusContent } from './system-status/SystemStatusContent.js';
|
|
132
131
|
export { SystemStatusActions } from './system-status/SystemStatusActions.js';
|
package/dist-es/index.js.map
CHANGED
|
@@ -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
|
|
2
|
-
import type
|
|
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
|
-
|
|
8
|
+
defaultActiveSlideIndex?: number;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* Optional. Defaults to `slide`
|
|
10
|
+
* Controlled index of active slide in the carousel.
|
|
12
11
|
**/
|
|
13
|
-
|
|
12
|
+
activeSlideIndex?: number;
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
16
|
-
* Optional. Defaults to undefined
|
|
14
|
+
* Set the placement of the CarouselControls relative to the CarouselSlider element. Defaults to `top`.
|
|
17
15
|
*/
|
|
18
|
-
|
|
16
|
+
controlsPlacement?: "top" | "bottom";
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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
|
-
|
|
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
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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>>;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -37,7 +37,6 @@ export * from "./responsive";
|
|
|
37
37
|
export * from "./search-input";
|
|
38
38
|
export * from "./splitter";
|
|
39
39
|
export * from "./static-list";
|
|
40
|
-
export * from "./stepped-tracker";
|
|
41
40
|
export * from "./system-status";
|
|
42
41
|
export * from "./tabs";
|
|
43
42
|
export * from "./tabs-next";
|
|
@@ -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.
|
|
3
|
+
"version": "1.0.0-alpha.67",
|
|
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.
|
|
24
|
+
"@salt-ds/core": "^1.45.0",
|
|
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",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var css_248z = ".saltStepConnector {\n grid-area: connector;\n\n transition-duration: inherit;\n transition-timing-function: inherit;\n transition-property: opacity, min-height;\n}\n\n.saltSteppedTracker-horizontal .saltStepConnector {\n position: absolute;\n transform: translateY(-100%);\n top: calc(var(--step-icon-size) / 2);\n left: calc(50% + calc(var(--step-icon-size) / 2 + var(--salt-spacing-100)));\n right: calc(-50% + calc(var(--step-icon-size) / 2 + var(--salt-spacing-100)));\n\n border-top-width: var(--salt-size-border-strong);\n border-top-style: var(--salt-track-borderStyle-incomplete);\n border-top-color: var(--salt-track-borderColor);\n}\n\n.saltSteppedTracker-horizontal .saltStep-stage-completed > .saltStepConnector,\n.saltSteppedTracker-horizontal .saltStep-stage-inprogress > .saltStepConnector {\n border-top-style: var(--salt-track-borderStyle-complete);\n}\n\n.saltSteppedTracker-vertical .saltStepConnector {\n min-height: var(--salt-size-base);\n align-self: stretch;\n justify-self: center;\n\n border-left-width: var(--salt-size-border-strong);\n border-left-style: var(--salt-track-borderStyle-incomplete);\n border-left-color: var(--salt-track-borderColor);\n}\n\n.saltSteppedTracker-vertical .saltStep-stage-completed > .saltStepConnector,\n.saltSteppedTracker-vertical .saltStep-stage-inprogress > .saltStepConnector {\n border-left-style: var(--salt-track-borderStyle-complete);\n}\n\n.saltStep-depth-0.saltStep:not(.saltStep-expanded):last-child > .saltStepConnector {\n opacity: 0;\n min-height: 0;\n}\n\n.saltStep-depth-0.saltStep-expanded:last-child .saltStep:not(.saltStep-expanded):last-child .saltStepConnector {\n opacity: 0;\n min-height: 0;\n}\n";
|
|
4
|
-
|
|
5
|
-
module.exports = css_248z;
|
|
6
|
-
//# sourceMappingURL=Step.Connector.css.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Step.Connector.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var core = require('@salt-ds/core');
|
|
5
|
-
var styles = require('@salt-ds/styles');
|
|
6
|
-
var window = require('@salt-ds/window');
|
|
7
|
-
var Step_Connector = require('./Step.Connector.css.js');
|
|
8
|
-
|
|
9
|
-
const withBaseName = core.makePrefixer("saltStepConnector");
|
|
10
|
-
function StepConnector() {
|
|
11
|
-
const targetWindow = window.useWindow();
|
|
12
|
-
styles.useComponentCssInjection({
|
|
13
|
-
testId: "salt-step-connector",
|
|
14
|
-
css: Step_Connector,
|
|
15
|
-
window: targetWindow
|
|
16
|
-
});
|
|
17
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": true, className: withBaseName() });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.StepConnector = StepConnector;
|
|
21
|
-
//# sourceMappingURL=Step.Connector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Step.Connector.js","sources":["../src/stepped-tracker/Step.Connector.tsx"],"sourcesContent":["import { makePrefixer } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport stepConnectorCSS from \"./Step.Connector.css\";\n\nconst withBaseName = makePrefixer(\"saltStepConnector\");\n\nexport function StepConnector() {\n const targetWindow = useWindow();\n\n useComponentCssInjection({\n testId: \"salt-step-connector\",\n css: stepConnectorCSS,\n window: targetWindow,\n });\n\n return <div aria-hidden className={withBaseName()} />;\n}\n"],"names":["makePrefixer","useWindow","useComponentCssInjection","stepConnectorCSS"],"mappings":";;;;;;;;AAMA,MAAM,YAAA,GAAeA,kBAAa,mBAAmB,CAAA;AAE9C,SAAS,aAAgB,GAAA;AAC9B,EAAA,MAAM,eAAeC,gBAAU,EAAA;AAE/B,EAAyBC,+BAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,qBAAA;AAAA,IACR,GAAK,EAAAC,cAAA;AAAA,IACL,MAAQ,EAAA;AAAA,GACT,CAAA;AAED,EAAA,sCAAQ,KAAI,EAAA,EAAA,aAAA,EAAW,IAAC,EAAA,SAAA,EAAW,cAAgB,EAAA,CAAA;AACrD;;;;"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var css_248z = ".saltStepDescription {\n grid-area: description;\n}\n\n.saltSteppedTracker-vertical .saltStepDescription {\n padding-bottom: var(--salt-spacing-300);\n padding-left: calc((var(--step-depth)) * var(--salt-spacing-100));\n}\n\n.saltStep-status-warning > .saltStepDescription {\n color: var(--salt-status-warning-foreground-informative);\n}\n\n.saltStep-status-error > .saltStepDescription {\n color: var(--salt-status-error-foreground-informative);\n}\n";
|
|
4
|
-
|
|
5
|
-
module.exports = css_248z;
|
|
6
|
-
//# sourceMappingURL=Step.Description.css.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Step.Description.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|