@salt-ds/embla-carousel 0.0.0-snapshot-20250627090641 → 0.1.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.
- package/CHANGELOG.md +14 -10
- package/css/salt-embla-carousel.css +14 -14
- package/dist-cjs/Carousel.css.js +1 -1
- package/dist-cjs/Carousel.js.map +1 -1
- package/dist-cjs/CarouselAnnouncementPlugin.js +9 -12
- package/dist-cjs/CarouselAnnouncementPlugin.js.map +1 -1
- package/dist-cjs/CarouselAutoplayIndicator.css.js +1 -1
- package/dist-cjs/CarouselAutoplayIndicator.js +64 -54
- package/dist-cjs/CarouselAutoplayIndicator.js.map +1 -1
- package/dist-cjs/CarouselAutoplayIndicatorSVG.js.map +1 -1
- package/dist-cjs/CarouselCard.css.js +1 -1
- package/dist-cjs/CarouselCard.js +1 -1
- package/dist-cjs/CarouselCard.js.map +1 -1
- package/dist-cjs/CarouselNextButton.js +4 -7
- package/dist-cjs/CarouselNextButton.js.map +1 -1
- package/dist-cjs/CarouselPreviousButton.js +4 -7
- package/dist-cjs/CarouselPreviousButton.js.map +1 -1
- package/dist-cjs/CarouselProgressLabel.css.js +1 -1
- package/dist-cjs/CarouselProgressLabel.js +24 -24
- package/dist-cjs/CarouselProgressLabel.js.map +1 -1
- package/dist-cjs/CarouselSlides.css.js +1 -1
- package/dist-cjs/CarouselSlides.js +33 -3
- package/dist-cjs/CarouselSlides.js.map +1 -1
- package/dist-cjs/CarouselTab.css.js +1 -1
- package/dist-cjs/CarouselTab.js +11 -15
- package/dist-cjs/CarouselTab.js.map +1 -1
- package/dist-cjs/CarouselTabList.js.map +1 -1
- package/dist-cjs/createCustomSettle.js +14 -0
- package/dist-cjs/createCustomSettle.js.map +1 -0
- package/dist-cjs/usePrevNextButtons.js +11 -13
- package/dist-cjs/usePrevNextButtons.js.map +1 -1
- package/dist-es/Carousel.css.js +1 -1
- package/dist-es/Carousel.js.map +1 -1
- package/dist-es/CarouselAnnouncementPlugin.js +9 -12
- package/dist-es/CarouselAnnouncementPlugin.js.map +1 -1
- package/dist-es/CarouselAutoplayIndicator.css.js +1 -1
- package/dist-es/CarouselAutoplayIndicator.js +64 -54
- package/dist-es/CarouselAutoplayIndicator.js.map +1 -1
- package/dist-es/CarouselAutoplayIndicatorSVG.js.map +1 -1
- package/dist-es/CarouselCard.css.js +1 -1
- package/dist-es/CarouselCard.js +1 -1
- package/dist-es/CarouselCard.js.map +1 -1
- package/dist-es/CarouselNextButton.js +5 -8
- package/dist-es/CarouselNextButton.js.map +1 -1
- package/dist-es/CarouselPreviousButton.js +5 -8
- package/dist-es/CarouselPreviousButton.js.map +1 -1
- package/dist-es/CarouselProgressLabel.css.js +1 -1
- package/dist-es/CarouselProgressLabel.js +25 -25
- package/dist-es/CarouselProgressLabel.js.map +1 -1
- package/dist-es/CarouselSlides.css.js +1 -1
- package/dist-es/CarouselSlides.js +34 -4
- package/dist-es/CarouselSlides.js.map +1 -1
- package/dist-es/CarouselTab.css.js +1 -1
- package/dist-es/CarouselTab.js +12 -16
- package/dist-es/CarouselTab.js.map +1 -1
- package/dist-es/CarouselTabList.js.map +1 -1
- package/dist-es/createCustomSettle.js +12 -0
- package/dist-es/createCustomSettle.js.map +1 -0
- package/dist-es/usePrevNextButtons.js +12 -14
- package/dist-es/usePrevNextButtons.js.map +1 -1
- package/dist-types/Carousel.d.ts +1 -1
- package/dist-types/CarouselAnnouncementPlugin.d.ts +8 -18
- package/dist-types/CarouselAutoplayIndicator.d.ts +4 -0
- package/dist-types/CarouselAutoplayIndicatorSVG.d.ts +2 -2
- package/dist-types/CarouselNextButton.d.ts +1 -1
- package/dist-types/CarouselPreviousButton.d.ts +1 -1
- package/dist-types/createCustomSettle.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# @salt-ds/embla-carousel
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.1.0
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Minor Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 9c4575b: ### Summary
|
|
8
8
|
|
|
9
9
|
The `Carousel` component has been moved from the Lab package to its own package, `@salt-ds/embla-carousel`.
|
|
10
|
-
Initially released as a pre-release in Lab, the Carousel was not fully featured. We have now pivoted to treating Carousel as a pattern using
|
|
10
|
+
Initially released as a pre-release in Lab, the Carousel was not fully featured. We have now pivoted to treating Carousel as a pattern using Embla, that can compose Salt components as its slides.
|
|
11
11
|
|
|
12
|
-
[
|
|
12
|
+
[Embla](https://www.embla-carousel.com) is a headless open-source carousel library offering a comprehensive set of features and an extensible API.
|
|
13
13
|
|
|
14
14
|
### Migration Guide
|
|
15
15
|
|
|
16
|
-
To allow consumers to manage their own version of
|
|
16
|
+
To allow consumers to manage their own version of Embla, it's defined as a peer dependency.
|
|
17
17
|
|
|
18
18
|
To migrate from the current Lab version of `Carousel`:
|
|
19
19
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
2.
|
|
28
|
+
2. Update your imports.
|
|
29
29
|
|
|
30
30
|
```diff
|
|
31
31
|
import {
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
|
|
91
91
|
The Carousel can be configured using the Embla API.
|
|
92
92
|
|
|
93
|
-
To configure
|
|
93
|
+
To configure Embla, pass `emblaOptions` or `emblaPlugins` to the Carousel.
|
|
94
94
|
|
|
95
|
-
To control the behavior of the Carousel through the
|
|
95
|
+
To control the behavior of the Carousel through the Embla API, obtain a reference to the Embla API through the `getEmblaApi` prop.
|
|
96
96
|
|
|
97
97
|
```
|
|
98
98
|
const [emblaApi, setEmblaApi] = useState<CarouselEmblaApiType | null>(null);
|
|
@@ -153,9 +153,13 @@
|
|
|
153
153
|
- `CarouselAutoplayIndicator`: An animated countdown indicator for autoplay functionality.
|
|
154
154
|
- `CarouselAnnouncementPlugin`: A plugin for announcing slide changes to assistive technologies.
|
|
155
155
|
|
|
156
|
+
### Patch Changes
|
|
157
|
+
|
|
156
158
|
- Updated dependencies [62975de]
|
|
159
|
+
- Updated dependencies [b96166e]
|
|
157
160
|
- Updated dependencies [73ccf6b]
|
|
158
161
|
- Updated dependencies [95dd874]
|
|
159
162
|
- Updated dependencies [c93c943]
|
|
160
163
|
- Updated dependencies [104d776]
|
|
161
|
-
|
|
164
|
+
- Updated dependencies [621253b]
|
|
165
|
+
- @salt-ds/core@1.47.1
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* src/Carousel.css */
|
|
2
2
|
.saltCarousel {
|
|
3
|
-
--
|
|
4
|
-
--
|
|
5
|
-
--
|
|
3
|
+
--carousel-slide-height: 310px;
|
|
4
|
+
--carousel-slide-spacing: var(--salt-spacing-100);
|
|
5
|
+
--carousel-slide-size: 100%;
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
gap: var(--salt-spacing-100);
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
/* src/CarouselAutoplayIndicator.css */
|
|
13
13
|
.saltCarouselAutoplayIndicator {
|
|
14
|
-
--
|
|
14
|
+
--carousel-svg-circumference: 0;
|
|
15
15
|
display: flex;
|
|
16
16
|
align-self: center;
|
|
17
17
|
}
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
.saltCarouselAutoplayIndicatorSVG-bar {
|
|
26
26
|
fill: none;
|
|
27
27
|
stroke: var(--salt-accent-background);
|
|
28
|
-
stroke-dasharray: var(--
|
|
29
|
-
stroke-dashoffset: var(--
|
|
28
|
+
stroke-dasharray: var(--carousel-svg-circumference);
|
|
29
|
+
stroke-dashoffset: var(--carousel-svg-circumference);
|
|
30
30
|
animation: indicatorAnimation 0.5s linear;
|
|
31
31
|
animation-play-state: paused;
|
|
32
32
|
}
|
|
33
33
|
@keyframes indicatorAnimation {
|
|
34
34
|
from {
|
|
35
|
-
stroke-dashoffset: var(--
|
|
35
|
+
stroke-dashoffset: var(--carousel-svg-circumference);
|
|
36
36
|
}
|
|
37
37
|
to {
|
|
38
38
|
stroke-dashoffset: 0;
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
.saltCarouselCard {
|
|
44
44
|
display: flex;
|
|
45
45
|
transform: translate3d(0, 0, 0);
|
|
46
|
-
flex: 0 0 var(--
|
|
46
|
+
flex: 0 0 var(--carousel-slide-size);
|
|
47
47
|
min-width: 0;
|
|
48
|
-
padding-left: var(--
|
|
48
|
+
padding-left: var(--carousel-slide-spacing);
|
|
49
49
|
box-sizing: border-box;
|
|
50
50
|
}
|
|
51
51
|
.saltCarouselCard-content {
|
|
@@ -73,13 +73,13 @@
|
|
|
73
73
|
}
|
|
74
74
|
.saltCarouselCard-bordered {
|
|
75
75
|
background: var(--salt-container-primary-background);
|
|
76
|
-
border: var(--salt-size-
|
|
76
|
+
border: var(--salt-size-fixed-100) var(--salt-container-borderStyle) var(--salt-container-primary-borderColor);
|
|
77
77
|
border-radius: var(--salt-palette-corner, 0);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/* src/CarouselProgressLabel.css */
|
|
81
81
|
.saltCarouselTabList.saltText {
|
|
82
|
-
font-weight: var(--salt-
|
|
82
|
+
font-weight: var(--salt-text-fontWeight-strong);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/* src/CarouselSlides.css */
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
.saltCarouselSlides-container {
|
|
90
90
|
display: flex;
|
|
91
91
|
touch-action: pan-y pinch-zoom;
|
|
92
|
-
margin-left: calc(var(--
|
|
92
|
+
margin-left: calc(var(--carousel-slide-spacing) * -1);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/* src/CarouselTab.css */
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
width: var(--salt-size-selectable);
|
|
99
99
|
height: var(--salt-size-selectable);
|
|
100
100
|
border: none;
|
|
101
|
-
box-shadow: inset 0 0 0 var(--salt-size-
|
|
101
|
+
box-shadow: inset 0 0 0 var(--salt-size-fixed-100) var(--salt-selectable-borderColor);
|
|
102
102
|
-webkit-tap-highlight-color: var(--salt-selectable-borderColor-hover);
|
|
103
103
|
-webkit-appearance: none;
|
|
104
104
|
appearance: none;
|
|
@@ -152,4 +152,4 @@
|
|
|
152
152
|
outline-color: var(--salt-focused-outlineColor);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
/* src/
|
|
155
|
+
/* src/55a330ae-262e-4577-91e9-4c6270057f5e.css */
|
package/dist-cjs/Carousel.css.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".saltCarousel {\n --
|
|
3
|
+
var css_248z = ".saltCarousel {\n --carousel-slide-height: 310px;\n --carousel-slide-spacing: var(--salt-spacing-100);\n --carousel-slide-size: 100%;\n display: flex;\n flex-direction: column;\n gap: var(--salt-spacing-100);\n margin: auto;\n}\n";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=Carousel.css.js.map
|
package/dist-cjs/Carousel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Carousel.js","sources":["../src/Carousel.tsx"],"sourcesContent":["import { makePrefixer } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport useEmblaCarousel, {\n type UseEmblaCarouselType,\n} from \"embla-carousel-react\";\nimport { type ComponentPropsWithoutRef, forwardRef, useEffect } from \"react\";\nimport carouselCss from \"./Carousel.css\";\nimport { CarouselContext } from \"./CarouselContext\";\n\nconst withBaseName = makePrefixer(\"saltCarousel\");\n\nexport type CarouselEmblaRefType = UseEmblaCarouselType[0];\nexport type CarouselEmblaApiType = UseEmblaCarouselType[1];\n\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>;\nexport type CarouselOptions = UseCarouselParameters[0];\nexport type CarouselPlugin = UseCarouselParameters[1];\n\n/**\n * Props for the Carousel component.\n * Pass a ref to the carousel to get it to return a reference to the embla API\n */\nexport interface CarouselProps extends ComponentPropsWithoutRef<\"section\"> {\n /**\n * Options to configure the Embla Carousel.\n * These options are passed directly to the Embla Carousel instance.\n */\n emblaOptions?: CarouselOptions;\n\n /**\n * Plugins to enhance the functionality of the Embla Carousel.\n * These options are passed directly to the Embla Carousel instance.\n */\n emblaPlugins?: CarouselPlugin;\n /** Get embla API
|
|
1
|
+
{"version":3,"file":"Carousel.js","sources":["../src/Carousel.tsx"],"sourcesContent":["import { makePrefixer } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport useEmblaCarousel, {\n type UseEmblaCarouselType,\n} from \"embla-carousel-react\";\nimport { type ComponentPropsWithoutRef, forwardRef, useEffect } from \"react\";\nimport carouselCss from \"./Carousel.css\";\nimport { CarouselContext } from \"./CarouselContext\";\n\nconst withBaseName = makePrefixer(\"saltCarousel\");\n\nexport type CarouselEmblaRefType = UseEmblaCarouselType[0];\nexport type CarouselEmblaApiType = UseEmblaCarouselType[1];\n\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>;\nexport type CarouselOptions = UseCarouselParameters[0];\nexport type CarouselPlugin = UseCarouselParameters[1];\n\n/**\n * Props for the Carousel component.\n * Pass a ref to the carousel to get it to return a reference to the embla API\n */\nexport interface CarouselProps extends ComponentPropsWithoutRef<\"section\"> {\n /**\n * Options to configure the Embla Carousel.\n * These options are passed directly to the Embla Carousel instance.\n */\n emblaOptions?: CarouselOptions;\n\n /**\n * Plugins to enhance the functionality of the Embla Carousel.\n * These options are passed directly to the Embla Carousel instance.\n */\n emblaPlugins?: CarouselPlugin;\n /** Get embla API instance, use this to manage the state of the Carousel */\n getEmblaApi?: (embla: CarouselEmblaApiType) => void;\n}\n\nexport const Carousel = forwardRef<HTMLElement, CarouselProps>(\n function Carousel(\n {\n children,\n className,\n emblaOptions = {},\n emblaPlugins = [],\n getEmblaApi,\n ...rest\n },\n ref,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-carousel\",\n css: carouselCss,\n window: targetWindow,\n });\n\n const [emblaRef, emblaApi] = useEmblaCarousel(emblaOptions, [\n ...emblaPlugins,\n ]);\n\n useEffect(() => {\n if (emblaApi) {\n getEmblaApi?.(emblaApi);\n }\n return undefined;\n }, [emblaApi]);\n\n return (\n <CarouselContext.Provider value={{ emblaApi, emblaRef }}>\n <section\n aria-roledescription=\"carousel\"\n role=\"region\"\n className={clsx(withBaseName(), className)}\n ref={ref}\n {...rest}\n >\n {children}\n </section>\n </CarouselContext.Provider>\n );\n },\n);\n"],"names":["makePrefixer","forwardRef","Carousel","useWindow","useComponentCssInjection","carouselCss","useEffect","jsx","CarouselContext","clsx"],"mappings":";;;;;;;;;;;;AAWA,MAAM,YAAA,GAAeA,kBAAa,cAAc,CAAA;AA6BzC,MAAM,QAAW,GAAAC,gBAAA;AAAA,EACtB,SAASC,SACP,CAAA;AAAA,IACE,QAAA;AAAA,IACA,SAAA;AAAA,IACA,eAAe,EAAC;AAAA,IAChB,eAAe,EAAC;AAAA,IAChB,WAAA;AAAA,IACA,GAAG;AAAA,KAEL,GACA,EAAA;AACA,IAAA,MAAM,eAAeC,gBAAU,EAAA;AAC/B,IAAyBC,+BAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,eAAA;AAAA,MACR,GAAK,EAAAC,UAAA;AAAA,MACL,MAAQ,EAAA;AAAA,KACT,CAAA;AAED,IAAA,MAAM,CAAC,QAAA,EAAU,QAAQ,CAAA,GAAI,iBAAiB,YAAc,EAAA;AAAA,MAC1D,GAAG;AAAA,KACJ,CAAA;AAED,IAAAC,eAAA,CAAU,MAAM;AACd,MAAA,IAAI,QAAU,EAAA;AACZ,QAAc,WAAA,IAAA,IAAA,GAAA,MAAA,GAAA,WAAA,CAAA,QAAA,CAAA;AAAA;AAEhB,MAAO,OAAA,MAAA;AAAA,KACT,EAAG,CAAC,QAAQ,CAAC,CAAA;AAEb,IACE,uBAAAC,cAAA,CAACC,gCAAgB,QAAhB,EAAA,EAAyB,OAAO,EAAE,QAAA,EAAU,UAC3C,EAAA,QAAA,kBAAAD,cAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QACC,sBAAqB,EAAA,UAAA;AAAA,QACrB,IAAK,EAAA,QAAA;AAAA,QACL,SAAW,EAAAE,SAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,QACzC,GAAA;AAAA,QACC,GAAG,IAAA;AAAA,QAEH;AAAA;AAAA,KAEL,EAAA,CAAA;AAAA;AAGN;;;;"}
|
|
@@ -3,33 +3,30 @@
|
|
|
3
3
|
var core = require('@salt-ds/core');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
|
|
6
|
-
const getSlideLabel = (
|
|
6
|
+
const getSlideLabel = (emblaApi) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const slideCount = (emblaApi == null ? void 0 : emblaApi.slideNodes().length) ?? 0;
|
|
9
|
+
const slideIndexInView = ((_a = emblaApi == null ? void 0 : emblaApi.slidesInView()) == null ? void 0 : _a[0]) ?? 0;
|
|
10
|
+
const slideElement = emblaApi == null ? void 0 : emblaApi.slideNodes()[slideIndexInView];
|
|
7
11
|
let description = slideElement == null ? void 0 : slideElement.getAttribute("aria-label");
|
|
8
12
|
if (!description) {
|
|
9
13
|
const labelledById = slideElement == null ? void 0 : slideElement.getAttribute("aria-labelledby");
|
|
14
|
+
const { ownerDocument } = emblaApi.internalEngine();
|
|
10
15
|
if (labelledById) {
|
|
11
|
-
const labelledByElement =
|
|
16
|
+
const labelledByElement = ownerDocument.getElementById(labelledById);
|
|
12
17
|
description = (labelledByElement == null ? void 0 : labelledByElement.textContent) || "No description available";
|
|
13
18
|
} else {
|
|
14
19
|
description = "No description available";
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
|
-
return `slide ${
|
|
22
|
+
return `slide ${slideIndexInView + 1} of ${slideCount}. ${description}`;
|
|
18
23
|
};
|
|
19
24
|
function CarouselAnnouncement(userOptions = {}) {
|
|
20
25
|
let emblaApi;
|
|
21
26
|
const { announce } = core.useAriaAnnouncer();
|
|
22
27
|
const handleSettle = react.useCallback(
|
|
23
28
|
(emblaApi2) => {
|
|
24
|
-
|
|
25
|
-
const slideCount = (emblaApi2 == null ? void 0 : emblaApi2.slideNodes().length) ?? 0;
|
|
26
|
-
const slideIndexInView = ((_a = emblaApi2 == null ? void 0 : emblaApi2.slidesInView()) == null ? void 0 : _a[0]) ?? 0;
|
|
27
|
-
const slideElement = emblaApi2 == null ? void 0 : emblaApi2.slideNodes()[slideIndexInView];
|
|
28
|
-
const slideLabel = getSlideLabel(
|
|
29
|
-
slideElement,
|
|
30
|
-
slideIndexInView,
|
|
31
|
-
slideCount
|
|
32
|
-
);
|
|
29
|
+
const slideLabel = getSlideLabel(emblaApi2);
|
|
33
30
|
announce(slideLabel);
|
|
34
31
|
},
|
|
35
32
|
[announce]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselAnnouncementPlugin.js","sources":["../src/CarouselAnnouncementPlugin.ts"],"sourcesContent":["import { useAriaAnnouncer } from \"@salt-ds/core\";\nimport type {\n CreateOptionsType,\n CreatePluginType,\n EmblaCarouselType,\n} from \"embla-carousel\";\nimport { useCallback } from \"react\";\n\ndeclare module \"embla-carousel\" {\n interface EmblaPluginsType {\n announcement: CarouselAnnouncementType;\n }\n}\n\n/**\n * Type definition for the parameters of the getSlideLabel function.\n
|
|
1
|
+
{"version":3,"file":"CarouselAnnouncementPlugin.js","sources":["../src/CarouselAnnouncementPlugin.ts"],"sourcesContent":["import { useAriaAnnouncer } from \"@salt-ds/core\";\nimport type {\n CreateOptionsType,\n CreatePluginType,\n EmblaCarouselType,\n} from \"embla-carousel\";\nimport { useCallback } from \"react\";\n\ndeclare module \"embla-carousel\" {\n interface EmblaPluginsType {\n announcement: CarouselAnnouncementType;\n }\n}\n\n/**\n * Type definition for the parameters of the getSlideLabel function.\n * @returns A string that describes the slide, including its index and total count.\n */\nexport type GetSlideLabelProps = (emblaApi: EmblaCarouselType) => string;\n\n/** * Generates a label for a carousel slide based on ARIA attributes.\n * This function retrieves the slide's ARIA label or text content and formats it into a descriptive string.\n * @param slideElement\n * @param slideIndex\n * @param slideCount\n * @returns A string description of the slide, including its position and ARIA label or text content.\n */\nexport const getSlideLabel: GetSlideLabelProps = (emblaApi): string => {\n const slideCount = emblaApi?.slideNodes().length ?? 0;\n const slideIndexInView = emblaApi?.slidesInView()?.[0] ?? 0;\n const slideElement = emblaApi?.slideNodes()[slideIndexInView];\n\n let description = slideElement?.getAttribute(\"aria-label\");\n if (!description) {\n const labelledById = slideElement?.getAttribute(\"aria-labelledby\");\n const { ownerDocument } = emblaApi.internalEngine();\n if (labelledById) {\n const labelledByElement = ownerDocument.getElementById(labelledById);\n description =\n labelledByElement?.textContent || \"No description available\";\n } else {\n description = \"No description available\";\n }\n }\n return `slide ${slideIndexInView + 1} of ${slideCount}. ${description}`;\n};\n\n// biome-ignore lint/complexity/noBannedTypes: Replicated from embla docs/code\ntype OptionsType = CreateOptionsType<{}>;\n// biome-ignore lint/complexity/noBannedTypes: Replicated from embla docs/code\nexport type CarouselAnnouncementType = CreatePluginType<{}, OptionsType>;\n\nexport type CarouselAnnouncementOptionsType =\n CarouselAnnouncementType[\"options\"];\n\nexport function CarouselAnnouncement(\n userOptions: CarouselAnnouncementOptionsType = {},\n): CarouselAnnouncementType {\n let emblaApi: EmblaCarouselType;\n\n const { announce } = useAriaAnnouncer();\n\n const handleSettle = useCallback(\n (emblaApi: EmblaCarouselType) => {\n const slideLabel = getSlideLabel(emblaApi);\n announce(slideLabel);\n },\n [announce],\n );\n\n function init(emblaApiInstance: EmblaCarouselType): void {\n emblaApi = emblaApiInstance;\n emblaApi.on(\"settle\", handleSettle);\n }\n\n function destroy(): void {\n emblaApi.off(\"settle\", handleSettle);\n }\n\n const self: CarouselAnnouncementType = {\n name: \"announcement\",\n options: userOptions,\n init,\n destroy,\n };\n return self;\n}\n"],"names":["useAriaAnnouncer","useCallback","emblaApi"],"mappings":";;;;;AA2Ba,MAAA,aAAA,GAAoC,CAAC,QAAqB,KAAA;AA3BvE,EAAA,IAAA,EAAA;AA4BE,EAAM,MAAA,UAAA,GAAA,CAAa,QAAU,IAAA,IAAA,GAAA,MAAA,GAAA,QAAA,CAAA,UAAA,EAAA,CAAa,MAAU,KAAA,CAAA;AACpD,EAAA,MAAM,gBAAmB,GAAA,CAAA,CAAA,EAAA,GAAA,QAAA,IAAA,IAAA,GAAA,MAAA,GAAA,QAAA,CAAU,YAAV,EAAA,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAA2B,CAAM,CAAA,KAAA,CAAA;AAC1D,EAAM,MAAA,YAAA,GAAe,qCAAU,UAAa,EAAA,CAAA,gBAAA,CAAA;AAE5C,EAAI,IAAA,WAAA,GAAc,6CAAc,YAAa,CAAA,YAAA,CAAA;AAC7C,EAAA,IAAI,CAAC,WAAa,EAAA;AAChB,IAAM,MAAA,YAAA,GAAe,6CAAc,YAAa,CAAA,iBAAA,CAAA;AAChD,IAAA,MAAM,EAAE,aAAA,EAAkB,GAAA,QAAA,CAAS,cAAe,EAAA;AAClD,IAAA,IAAI,YAAc,EAAA;AAChB,MAAM,MAAA,iBAAA,GAAoB,aAAc,CAAA,cAAA,CAAe,YAAY,CAAA;AACnE,MAAA,WAAA,GAAA,CACE,uDAAmB,WAAe,KAAA,0BAAA;AAAA,KAC/B,MAAA;AACL,MAAc,WAAA,GAAA,0BAAA;AAAA;AAChB;AAEF,EAAA,OAAO,SAAS,gBAAmB,GAAA,CAAC,CAAO,IAAA,EAAA,UAAU,KAAK,WAAW,CAAA,CAAA;AACvE;AAUgB,SAAA,oBAAA,CACd,WAA+C,GAAA,EACrB,EAAA;AAC1B,EAAI,IAAA,QAAA;AAEJ,EAAM,MAAA,EAAE,QAAS,EAAA,GAAIA,qBAAiB,EAAA;AAEtC,EAAA,MAAM,YAAe,GAAAC,iBAAA;AAAA,IACnB,CAACC,SAAgC,KAAA;AAC/B,MAAM,MAAA,UAAA,GAAa,cAAcA,SAAQ,CAAA;AACzC,MAAA,QAAA,CAAS,UAAU,CAAA;AAAA,KACrB;AAAA,IACA,CAAC,QAAQ;AAAA,GACX;AAEA,EAAA,SAAS,KAAK,gBAA2C,EAAA;AACvD,IAAW,QAAA,GAAA,gBAAA;AACX,IAAS,QAAA,CAAA,EAAA,CAAG,UAAU,YAAY,CAAA;AAAA;AAGpC,EAAA,SAAS,OAAgB,GAAA;AACvB,IAAS,QAAA,CAAA,GAAA,CAAI,UAAU,YAAY,CAAA;AAAA;AAGrC,EAAA,MAAM,IAAiC,GAAA;AAAA,IACrC,IAAM,EAAA,cAAA;AAAA,IACN,OAAS,EAAA,WAAA;AAAA,IACT,IAAA;AAAA,IACA;AAAA,GACF;AACA,EAAO,OAAA,IAAA;AACT;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".saltCarouselAutoplayIndicator {\n --
|
|
3
|
+
var css_248z = ".saltCarouselAutoplayIndicator {\n --carousel-svg-circumference: 0;\n display: flex;\n align-self: center;\n}\n\n.saltCarouselAutoplayIndicatorSVG {\n transform: rotate(-90deg);\n}\n\n.saltCarouselAutoplayIndicatorSVG-track {\n fill: none;\n stroke: var(--salt-accent-foreground);\n}\n\n.saltCarouselAutoplayIndicatorSVG-bar {\n fill: none;\n stroke: var(--salt-accent-background);\n stroke-dasharray: var(--carousel-svg-circumference);\n stroke-dashoffset: var(--carousel-svg-circumference);\n animation: indicatorAnimation 0.5s linear;\n animation-play-state: paused;\n}\n\n@keyframes indicatorAnimation {\n from {\n stroke-dashoffset: var(--carousel-svg-circumference);\n }\n to {\n stroke-dashoffset: 0;\n }\n}\n";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=CarouselAutoplayIndicator.css.js.map
|
|
@@ -16,67 +16,77 @@ const sizeAndStrokeWidthMapping = {
|
|
|
16
16
|
low: { size: 14, strokeWidth: 2 },
|
|
17
17
|
touch: { size: 16, strokeWidth: 2 }
|
|
18
18
|
};
|
|
19
|
-
const CarouselAutoplayIndicator = react.forwardRef(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
const CarouselAutoplayIndicator = react.forwardRef(
|
|
20
|
+
({
|
|
21
|
+
className,
|
|
22
|
+
duration,
|
|
23
|
+
slideIndex,
|
|
24
|
+
isPlaying,
|
|
25
|
+
isPaused = false,
|
|
26
|
+
children,
|
|
27
|
+
...props
|
|
28
|
+
}, ref) => {
|
|
29
|
+
const targetWindow = window.useWindow();
|
|
30
|
+
styles.useComponentCssInjection({
|
|
31
|
+
testId: "salt-carousel-autoplay-indicator",
|
|
32
|
+
css: CarouselAutoplayIndicator$1,
|
|
33
|
+
window: targetWindow
|
|
34
|
+
});
|
|
35
|
+
const barRef = react.useRef(null);
|
|
36
|
+
const animationFrameId = react.useRef(null);
|
|
37
|
+
const density = core.useDensity();
|
|
38
|
+
const { size, strokeWidth } = sizeAndStrokeWidthMapping[density];
|
|
39
|
+
const radius = (size - strokeWidth) / 2;
|
|
40
|
+
const circumference = 2 * Math.PI * radius;
|
|
41
|
+
react.useEffect(() => {
|
|
42
|
+
if (barRef.current) {
|
|
40
43
|
animationFrameId.current = requestAnimationFrame(() => {
|
|
41
44
|
if (!barRef.current) {
|
|
42
45
|
return;
|
|
43
46
|
}
|
|
44
|
-
barRef.current.style.animation =
|
|
45
|
-
barRef.current.style.
|
|
47
|
+
barRef.current.style.animation = "none";
|
|
48
|
+
barRef.current.style.strokeDashoffset = `${circumference}`;
|
|
49
|
+
animationFrameId.current = requestAnimationFrame(() => {
|
|
50
|
+
if (!barRef.current) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
barRef.current.style.animation = `indicatorAnimation ${duration}ms linear`;
|
|
54
|
+
barRef.current.style.animationPlayState = isPaused ? "paused" : isPlaying ? "running" : "paused";
|
|
55
|
+
});
|
|
46
56
|
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return () => {
|
|
50
|
-
if (animationFrameId.current !== null) {
|
|
51
|
-
cancelAnimationFrame(animationFrameId.current);
|
|
52
|
-
animationFrameId.current = null;
|
|
53
57
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
ref,
|
|
60
|
-
style: {
|
|
61
|
-
width: size,
|
|
62
|
-
height: size,
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
"--salt-carousel-svg-circumference": circumference
|
|
65
|
-
},
|
|
66
|
-
className: clsx(withBaseName(), className),
|
|
67
|
-
...props,
|
|
68
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
69
|
-
CarouselAutoplayIndicatorSVG.CarouselAutoplayIndicatorSVG,
|
|
70
|
-
{
|
|
71
|
-
size,
|
|
72
|
-
strokeWidth,
|
|
73
|
-
barRef,
|
|
74
|
-
radius
|
|
58
|
+
return () => {
|
|
59
|
+
if (animationFrameId.current !== null) {
|
|
60
|
+
cancelAnimationFrame(animationFrameId.current);
|
|
61
|
+
animationFrameId.current = null;
|
|
75
62
|
}
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
63
|
+
};
|
|
64
|
+
}, [circumference, duration, slideIndex, isPlaying, isPaused]);
|
|
65
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
ref,
|
|
69
|
+
style: {
|
|
70
|
+
width: size,
|
|
71
|
+
height: size,
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
"--carousel-svg-circumference": circumference
|
|
74
|
+
},
|
|
75
|
+
className: clsx(withBaseName(), className),
|
|
76
|
+
...props,
|
|
77
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
|
+
CarouselAutoplayIndicatorSVG.CarouselAutoplayIndicatorSVG,
|
|
79
|
+
{
|
|
80
|
+
size,
|
|
81
|
+
strokeWidth,
|
|
82
|
+
barRef,
|
|
83
|
+
radius
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
80
90
|
|
|
81
91
|
exports.CarouselAutoplayIndicator = CarouselAutoplayIndicator;
|
|
82
92
|
//# sourceMappingURL=CarouselAutoplayIndicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselAutoplayIndicator.js","sources":["../src/CarouselAutoplayIndicator.tsx"],"sourcesContent":["import { makePrefixer, useDensity } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport clsx from \"classnames\";\nimport {\n type ComponentPropsWithoutRef,\n forwardRef,\n useEffect,\n useRef,\n} from \"react\";\nimport carouselAutoplayIndicator from \"./CarouselAutoplayIndicator.css\";\nimport { CarouselAutoplayIndicatorSVG } from \"./CarouselAutoplayIndicatorSVG\";\n\nexport interface CarouselAutoplayIndicatorProps\n extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Duration of each slide in milliseconds.\n */\n duration: number;\n /**\n * Index of slide currently displayed.\n */\n slideIndex: number;\n /**\n * If `true`, the indicator is animated to visualize the time until the next slide.\n */\n isPlaying: boolean;\n}\n\nconst withBaseName = makePrefixer(\"saltCarouselAutoplayIndicator\");\n\nconst sizeAndStrokeWidthMapping = {\n high: { size: 10, strokeWidth: 2 },\n medium: { size: 12, strokeWidth: 2 },\n low: { size: 14, strokeWidth: 2 },\n touch: { size: 16, strokeWidth: 2 },\n};\n\nexport const CarouselAutoplayIndicator = forwardRef<\n HTMLDivElement,\n CarouselAutoplayIndicatorProps\n>(({
|
|
1
|
+
{"version":3,"file":"CarouselAutoplayIndicator.js","sources":["../src/CarouselAutoplayIndicator.tsx"],"sourcesContent":["import { makePrefixer, useDensity } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport clsx from \"classnames\";\nimport {\n type ComponentPropsWithoutRef,\n forwardRef,\n useEffect,\n useRef,\n} from \"react\";\nimport carouselAutoplayIndicator from \"./CarouselAutoplayIndicator.css\";\nimport { CarouselAutoplayIndicatorSVG } from \"./CarouselAutoplayIndicatorSVG\";\n\nexport interface CarouselAutoplayIndicatorProps\n extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Duration of each slide in milliseconds.\n */\n duration: number;\n /**\n * Index of slide currently displayed.\n */\n slideIndex: number;\n /**\n * If `true`, the indicator is animated to visualize the time until the next slide.\n */\n isPlaying: boolean;\n /**\n * If `true`, the animation is paused.\n */\n isPaused?: boolean;\n}\n\nconst withBaseName = makePrefixer(\"saltCarouselAutoplayIndicator\");\n\nconst sizeAndStrokeWidthMapping = {\n high: { size: 10, strokeWidth: 2 },\n medium: { size: 12, strokeWidth: 2 },\n low: { size: 14, strokeWidth: 2 },\n touch: { size: 16, strokeWidth: 2 },\n};\n\nexport const CarouselAutoplayIndicator = forwardRef<\n HTMLDivElement,\n CarouselAutoplayIndicatorProps\n>(\n (\n {\n className,\n duration,\n slideIndex,\n isPlaying,\n isPaused = false,\n children,\n ...props\n },\n ref,\n ) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-carousel-autoplay-indicator\",\n css: carouselAutoplayIndicator,\n window: targetWindow,\n });\n\n const barRef = useRef<SVGCircleElement>(null);\n const animationFrameId = useRef<number | null>(null);\n\n const density = useDensity();\n const { size, strokeWidth } = sizeAndStrokeWidthMapping[density];\n const radius = (size - strokeWidth) / 2;\n const circumference = 2 * Math.PI * radius;\n\n useEffect(() => {\n if (barRef.current) {\n animationFrameId.current = requestAnimationFrame(() => {\n if (!barRef.current) {\n return;\n }\n barRef.current.style.animation = \"none\"; // Reset animation\n barRef.current.style.strokeDashoffset = `${circumference}`;\n animationFrameId.current = requestAnimationFrame(() => {\n if (!barRef.current) {\n return;\n }\n barRef.current.style.animation = `indicatorAnimation ${duration}ms linear`;\n barRef.current.style.animationPlayState = isPaused\n ? \"paused\"\n : isPlaying\n ? \"running\"\n : \"paused\";\n });\n });\n }\n\n return () => {\n if (animationFrameId.current !== null) {\n cancelAnimationFrame(animationFrameId.current);\n animationFrameId.current = null;\n }\n };\n }, [circumference, duration, slideIndex, isPlaying, isPaused]);\n\n return (\n <div\n ref={ref}\n style={{\n width: size,\n height: size,\n // @ts-ignore\n \"--carousel-svg-circumference\": circumference,\n }}\n className={clsx(withBaseName(), className)}\n {...props}\n >\n <CarouselAutoplayIndicatorSVG\n size={size}\n strokeWidth={strokeWidth}\n barRef={barRef}\n radius={radius}\n />\n </div>\n );\n },\n);\n"],"names":["makePrefixer","forwardRef","useWindow","useComponentCssInjection","carouselAutoplayIndicator","useRef","useDensity","useEffect","jsx","CarouselAutoplayIndicatorSVG"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselAutoplayIndicatorSVG.js","sources":["../src/CarouselAutoplayIndicatorSVG.tsx"],"sourcesContent":["import { makePrefixer } from \"@salt-ds/core\";\nimport clsx from \"classnames\";\nimport { type SVGAttributes, forwardRef } from \"react\";\nconst withBaseName = makePrefixer(\"saltCarouselAutoplayIndicatorSVG\");\n\nexport interface CarouselAutoplayIndicatorSVGProps\n extends SVGAttributes<SVGSVGElement> {\n /**\n * Class name to apply to the SVG element.\n */\n className?: string;\n /**\n * Ref to attach to progress indicator element\n */\n barRef:
|
|
1
|
+
{"version":3,"file":"CarouselAutoplayIndicatorSVG.js","sources":["../src/CarouselAutoplayIndicatorSVG.tsx"],"sourcesContent":["import { makePrefixer } from \"@salt-ds/core\";\nimport clsx from \"classnames\";\nimport { type Ref, type SVGAttributes, forwardRef } from \"react\";\n\nconst withBaseName = makePrefixer(\"saltCarouselAutoplayIndicatorSVG\");\n\nexport interface CarouselAutoplayIndicatorSVGProps\n extends SVGAttributes<SVGSVGElement> {\n /**\n * Class name to apply to the SVG element.\n */\n className?: string;\n /**\n * Ref to attach to progress indicator element\n */\n barRef: Ref<SVGCircleElement>;\n /**\n * Size of the SVG in pixels.\n */\n size: number;\n /**\n * Stroke width of the progress indicator in pixels.\n */\n strokeWidth: number;\n /**\n * Radius of the progress indicator circle.\n */\n radius: number;\n}\n\nexport const CarouselAutoplayIndicatorSVG = forwardRef<\n SVGSVGElement,\n CarouselAutoplayIndicatorSVGProps\n>(\n (\n {\n barRef,\n className,\n radius,\n size,\n strokeWidth,\n }: CarouselAutoplayIndicatorSVGProps,\n ref,\n ) => {\n return (\n <svg\n className={clsx(withBaseName(), className)}\n width={size}\n height={size}\n aria-hidden\n ref={ref}\n >\n <circle\n className={withBaseName(\"track\")}\n cx={size / 2}\n cy={size / 2}\n r={radius}\n strokeWidth={strokeWidth}\n />\n <circle\n ref={barRef}\n className={withBaseName(\"bar\")}\n cx={size / 2}\n cy={size / 2}\n r={radius}\n strokeWidth={strokeWidth}\n />\n </svg>\n );\n },\n);\n"],"names":["makePrefixer","forwardRef","jsxs","jsx"],"mappings":";;;;;;;AAIA,MAAM,YAAA,GAAeA,kBAAa,kCAAkC,CAAA;AA0B7D,MAAM,4BAA+B,GAAAC,gBAAA;AAAA,EAI1C,CACE;AAAA,IACE,MAAA;AAAA,IACA,SAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,KAEF,GACG,KAAA;AACH,IACE,uBAAAC,eAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,SAAW,EAAA,IAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,QACzC,KAAO,EAAA,IAAA;AAAA,QACP,MAAQ,EAAA,IAAA;AAAA,QACR,aAAW,EAAA,IAAA;AAAA,QACX,GAAA;AAAA,QAEA,QAAA,EAAA;AAAA,0BAAAC,cAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,cAC/B,IAAI,IAAO,GAAA,CAAA;AAAA,cACX,IAAI,IAAO,GAAA,CAAA;AAAA,cACX,CAAG,EAAA,MAAA;AAAA,cACH;AAAA;AAAA,WACF;AAAA,0BACAA,cAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,GAAK,EAAA,MAAA;AAAA,cACL,SAAA,EAAW,aAAa,KAAK,CAAA;AAAA,cAC7B,IAAI,IAAO,GAAA,CAAA;AAAA,cACX,IAAI,IAAO,GAAA,CAAA;AAAA,cACX,CAAG,EAAA,MAAA;AAAA,cACH;AAAA;AAAA;AACF;AAAA;AAAA,KACF;AAAA;AAGN;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".saltCarouselCard {\n display: flex;\n transform: translate3d(0, 0, 0);\n flex: 0 0 var(--
|
|
3
|
+
var css_248z = ".saltCarouselCard {\n display: flex;\n transform: translate3d(0, 0, 0);\n flex: 0 0 var(--carousel-slide-size);\n min-width: 0;\n padding-left: var(--carousel-slide-spacing);\n box-sizing: border-box;\n}\n\n.saltCarouselCard-content {\n display: flex;\n user-select: none;\n overflow: hidden;\n flex-direction: column;\n gap: var(--salt-spacing-200);\n flex-grow: 1;\n}\n\n.saltCarouselCard-body {\n display: flex;\n overflow: hidden;\n flex-direction: column;\n gap: var(--salt-spacing-200);\n flex-grow: 1;\n padding: 0 var(--salt-spacing-200) var(--salt-spacing-200) var(--salt-spacing-200);\n}\n\n.saltCarouselCard-content h2,\n.saltCarouselCard-content h3 {\n margin: 0;\n}\n\n.saltCarouselCard[data-visibility=\"off-screen\"] a {\n visibility: hidden;\n}\n\n.saltCarouselCard-bordered {\n background: var(--salt-container-primary-background);\n border: var(--salt-size-fixed-100) var(--salt-container-borderStyle) var(--salt-container-primary-borderColor);\n border-radius: var(--salt-palette-corner, 0);\n}\n";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=CarouselCard.css.js.map
|
package/dist-cjs/CarouselCard.js
CHANGED
|
@@ -13,7 +13,7 @@ const CarouselCard = react.forwardRef(
|
|
|
13
13
|
function CarouselCard2({ actions, appearance, children, className, header, media, ...rest }, ref) {
|
|
14
14
|
const targetWindow = window.useWindow();
|
|
15
15
|
styles.useComponentCssInjection({
|
|
16
|
-
testId: "salt-carousel-
|
|
16
|
+
testId: "salt-carousel-card",
|
|
17
17
|
css: CarouselCard$1,
|
|
18
18
|
window: targetWindow
|
|
19
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselCard.js","sources":["../src/CarouselCard.tsx"],"sourcesContent":["import { makePrefixer } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport { type ComponentProps, type ReactNode, forwardRef } from \"react\";\nimport saltCarouselCardCss from \"./CarouselCard.css\";\n\nconst withBaseName = makePrefixer(\"saltCarouselCard\");\n\n/**\n * Props for the CarouselCard component.\n */\nexport interface CarouselCardProps extends ComponentProps<\"div\"> {\n /**\n * Actions to be displayed in the content footer.\n * This can include buttons or any other interactive elements.\n */\n actions?: ReactNode;\n\n /**\n * Media content to be displayed inside the slide.\n * 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 /**\n * The appearance of the slide. Options are 'bordered', and 'transparent'.\n * 'transparent' is the default value.\n **/\n appearance?: \"bordered\" | \"transparent\";\n\n /**\n * Header content to be displayed at the top of the slide.\n * This can be text or any other React node.\n */\n header?: ReactNode;\n\n /**\n * Carousel slide id.\n * This can be used to uniquely identify the slide.\n */\n id?: string;\n}\n\nexport const CarouselCard = forwardRef<HTMLDivElement, CarouselCardProps>(\n function CarouselCard(\n { actions, appearance, children, className, header, media, ...rest },\n ref,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-carousel-
|
|
1
|
+
{"version":3,"file":"CarouselCard.js","sources":["../src/CarouselCard.tsx"],"sourcesContent":["import { makePrefixer } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport { type ComponentProps, type ReactNode, forwardRef } from \"react\";\nimport saltCarouselCardCss from \"./CarouselCard.css\";\n\nconst withBaseName = makePrefixer(\"saltCarouselCard\");\n\n/**\n * Props for the CarouselCard component.\n */\nexport interface CarouselCardProps extends ComponentProps<\"div\"> {\n /**\n * Actions to be displayed in the content footer.\n * This can include buttons or any other interactive elements.\n */\n actions?: ReactNode;\n\n /**\n * Media content to be displayed inside the slide.\n * 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 /**\n * The appearance of the slide. Options are 'bordered', and 'transparent'.\n * 'transparent' is the default value.\n **/\n appearance?: \"bordered\" | \"transparent\";\n\n /**\n * Header content to be displayed at the top of the slide.\n * This can be text or any other React node.\n */\n header?: ReactNode;\n\n /**\n * Carousel slide id.\n * This can be used to uniquely identify the slide.\n */\n id?: string;\n}\n\nexport const CarouselCard = forwardRef<HTMLDivElement, CarouselCardProps>(\n function CarouselCard(\n { actions, appearance, children, className, header, media, ...rest },\n ref,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-carousel-card\",\n css: saltCarouselCardCss,\n window: targetWindow,\n });\n\n return (\n <div\n role=\"tabpanel\"\n aria-roledescription=\"slide\"\n className={clsx(withBaseName(), className)}\n {...rest}\n ref={ref}\n >\n <div\n className={clsx(withBaseName(\"content\"), {\n [withBaseName(\"bordered\")]: appearance === \"bordered\",\n })}\n >\n {media}\n {children && (\n <div className={withBaseName(\"body\")}>\n <div>{header}</div>\n <div>{children}</div>\n {actions}\n </div>\n )}\n </div>\n </div>\n );\n },\n);\n"],"names":["makePrefixer","forwardRef","CarouselCard","useWindow","useComponentCssInjection","saltCarouselCardCss","jsx","clsx","jsxs"],"mappings":";;;;;;;;;;AAOA,MAAM,YAAA,GAAeA,kBAAa,kBAAkB,CAAA;AAsC7C,MAAM,YAAe,GAAAC,gBAAA;AAAA,EAC1B,SAASC,aAAAA,CACP,EAAE,OAAA,EAAS,UAAY,EAAA,QAAA,EAAU,SAAW,EAAA,MAAA,EAAQ,KAAO,EAAA,GAAG,IAAK,EAAA,EACnE,GACA,EAAA;AACA,IAAA,MAAM,eAAeC,gBAAU,EAAA;AAC/B,IAAyBC,+BAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,oBAAA;AAAA,MACR,GAAK,EAAAC,cAAA;AAAA,MACL,MAAQ,EAAA;AAAA,KACT,CAAA;AAED,IACE,uBAAAC,cAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,IAAK,EAAA,UAAA;AAAA,QACL,sBAAqB,EAAA,OAAA;AAAA,QACrB,SAAW,EAAAC,SAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,QACxC,GAAG,IAAA;AAAA,QACJ,GAAA;AAAA,QAEA,QAAA,kBAAAC,eAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,SAAW,EAAAD,SAAA,CAAK,YAAa,CAAA,SAAS,CAAG,EAAA;AAAA,cACvC,CAAC,YAAA,CAAa,UAAU,CAAC,GAAG,UAAe,KAAA;AAAA,aAC5C,CAAA;AAAA,YAEA,QAAA,EAAA;AAAA,cAAA,KAAA;AAAA,cACA,4BACEC,eAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,YAAA,CAAa,MAAM,CACjC,EAAA,QAAA,EAAA;AAAA,gCAAAF,cAAA,CAAC,SAAK,QAAO,EAAA,MAAA,EAAA,CAAA;AAAA,gCACbA,cAAA,CAAC,SAAK,QAAS,EAAA,CAAA;AAAA,gBACd;AAAA,eACH,EAAA;AAAA;AAAA;AAAA;AAEJ;AAAA,KACF;AAAA;AAGN;;;;"}
|
|
@@ -8,13 +8,10 @@ var usePrevNextButtons = require('./usePrevNextButtons.js');
|
|
|
8
8
|
const CarouselNextButton = react.forwardRef(function CarouselNextButton2({ className, onClick, ...rest }, ref) {
|
|
9
9
|
const { NextIcon } = core.useIcon();
|
|
10
10
|
const { nextBtnDisabled, onNextButtonClick } = usePrevNextButtons.usePrevNextButtons();
|
|
11
|
-
const handleClick =
|
|
12
|
-
(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
[onNextButtonClick, onClick]
|
|
17
|
-
);
|
|
11
|
+
const handleClick = (event) => {
|
|
12
|
+
onNextButtonClick();
|
|
13
|
+
onClick == null ? void 0 : onClick(event);
|
|
14
|
+
};
|
|
18
15
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
19
16
|
core.Button,
|
|
20
17
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselNextButton.js","sources":["../src/CarouselNextButton.tsx"],"sourcesContent":["import { Button, type ButtonProps, useIcon } from \"@salt-ds/core\";\nimport { type MouseEventHandler, forwardRef
|
|
1
|
+
{"version":3,"file":"CarouselNextButton.js","sources":["../src/CarouselNextButton.tsx"],"sourcesContent":["import { Button, type ButtonProps, useIcon } from \"@salt-ds/core\";\nimport { type MouseEventHandler, forwardRef } from \"react\";\nimport { usePrevNextButtons } from \"./usePrevNextButtons\";\n\n/**\n * Props for the CarouselNextButton component.\n */\nexport interface CarouselNextButtonProps\n extends Omit<ButtonProps, \"variant\" | \"loading\" | \"loadingAnnouncement\"> {}\n\nexport const CarouselNextButton = forwardRef<\n HTMLButtonElement,\n CarouselNextButtonProps\n>(function CarouselNextButton({ className, onClick, ...rest }, ref) {\n const { NextIcon } = useIcon();\n const { nextBtnDisabled, onNextButtonClick } = usePrevNextButtons();\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {\n onNextButtonClick();\n onClick?.(event);\n };\n\n return (\n <Button\n onClick={handleClick}\n disabled={nextBtnDisabled}\n focusableWhenDisabled\n appearance=\"bordered\"\n sentiment=\"neutral\"\n aria-label=\"Next slide\"\n ref={ref}\n {...rest}\n >\n <NextIcon aria-hidden />\n </Button>\n );\n});\n"],"names":["forwardRef","CarouselNextButton","useIcon","usePrevNextButtons","jsx","Button"],"mappings":";;;;;;;AAUa,MAAA,kBAAA,GAAqBA,gBAGhC,CAAA,SAASC,mBAAmB,CAAA,EAAE,WAAW,OAAS,EAAA,GAAG,IAAK,EAAA,EAAG,GAAK,EAAA;AAClE,EAAM,MAAA,EAAE,QAAS,EAAA,GAAIC,YAAQ,EAAA;AAC7B,EAAA,MAAM,EAAE,eAAA,EAAiB,iBAAkB,EAAA,GAAIC,qCAAmB,EAAA;AAElE,EAAM,MAAA,WAAA,GAAoD,CAAC,KAAU,KAAA;AACnE,IAAkB,iBAAA,EAAA;AAClB,IAAU,OAAA,IAAA,IAAA,GAAA,MAAA,GAAA,OAAA,CAAA,KAAA,CAAA;AAAA,GACZ;AAEA,EACE,uBAAAC,cAAA;AAAA,IAACC,WAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,WAAA;AAAA,MACT,QAAU,EAAA,eAAA;AAAA,MACV,qBAAqB,EAAA,IAAA;AAAA,MACrB,UAAW,EAAA,UAAA;AAAA,MACX,SAAU,EAAA,SAAA;AAAA,MACV,YAAW,EAAA,YAAA;AAAA,MACX,GAAA;AAAA,MACC,GAAG,IAAA;AAAA,MAEJ,QAAA,kBAAAD,cAAA,CAAC,QAAS,EAAA,EAAA,aAAA,EAAW,IAAC,EAAA;AAAA;AAAA,GACxB;AAEJ,CAAC;;;;"}
|
|
@@ -8,13 +8,10 @@ var usePrevNextButtons = require('./usePrevNextButtons.js');
|
|
|
8
8
|
const CarouselPreviousButton = react.forwardRef(function CarouselPreviousButton2({ className, onClick, ...rest }, ref) {
|
|
9
9
|
const { PreviousIcon } = core.useIcon();
|
|
10
10
|
const { prevBtnDisabled, onPrevButtonClick } = usePrevNextButtons.usePrevNextButtons();
|
|
11
|
-
const handleClick =
|
|
12
|
-
(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
[onPrevButtonClick, onClick]
|
|
17
|
-
);
|
|
11
|
+
const handleClick = (event) => {
|
|
12
|
+
onPrevButtonClick();
|
|
13
|
+
onClick == null ? void 0 : onClick(event);
|
|
14
|
+
};
|
|
18
15
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
19
16
|
core.Button,
|
|
20
17
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselPreviousButton.js","sources":["../src/CarouselPreviousButton.tsx"],"sourcesContent":["import { Button, type ButtonProps, useIcon } from \"@salt-ds/core\";\nimport { type MouseEventHandler, forwardRef
|
|
1
|
+
{"version":3,"file":"CarouselPreviousButton.js","sources":["../src/CarouselPreviousButton.tsx"],"sourcesContent":["import { Button, type ButtonProps, useIcon } from \"@salt-ds/core\";\nimport { type MouseEventHandler, forwardRef } from \"react\";\nimport { usePrevNextButtons } from \"./usePrevNextButtons\";\n\n/**\n * Props for the CarouselPreviousButton component.\n */\nexport interface CarouselPreviousButtonProps\n extends Omit<ButtonProps, \"variant\" | \"loading\" | \"loadingAnnouncement\"> {}\n\nexport const CarouselPreviousButton = forwardRef<\n HTMLButtonElement,\n CarouselPreviousButtonProps\n>(function CarouselPreviousButton({ className, onClick, ...rest }, ref) {\n const { PreviousIcon } = useIcon();\n const { prevBtnDisabled, onPrevButtonClick } = usePrevNextButtons();\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {\n onPrevButtonClick();\n onClick?.(event);\n };\n\n return (\n <Button\n onClick={handleClick}\n disabled={prevBtnDisabled}\n focusableWhenDisabled\n appearance=\"bordered\"\n sentiment=\"neutral\"\n aria-label=\"Previous slide\"\n ref={ref}\n {...rest}\n >\n <PreviousIcon aria-hidden />\n </Button>\n );\n});\n"],"names":["forwardRef","CarouselPreviousButton","useIcon","usePrevNextButtons","jsx","Button"],"mappings":";;;;;;;AAUa,MAAA,sBAAA,GAAyBA,gBAGpC,CAAA,SAASC,uBAAuB,CAAA,EAAE,WAAW,OAAS,EAAA,GAAG,IAAK,EAAA,EAAG,GAAK,EAAA;AACtE,EAAM,MAAA,EAAE,YAAa,EAAA,GAAIC,YAAQ,EAAA;AACjC,EAAA,MAAM,EAAE,eAAA,EAAiB,iBAAkB,EAAA,GAAIC,qCAAmB,EAAA;AAElE,EAAM,MAAA,WAAA,GAAoD,CAAC,KAAU,KAAA;AACnE,IAAkB,iBAAA,EAAA;AAClB,IAAU,OAAA,IAAA,IAAA,GAAA,MAAA,GAAA,OAAA,CAAA,KAAA,CAAA;AAAA,GACZ;AAEA,EACE,uBAAAC,cAAA;AAAA,IAACC,WAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,WAAA;AAAA,MACT,QAAU,EAAA,eAAA;AAAA,MACV,qBAAqB,EAAA,IAAA;AAAA,MACrB,UAAW,EAAA,UAAA;AAAA,MACX,SAAU,EAAA,SAAA;AAAA,MACV,YAAW,EAAA,gBAAA;AAAA,MACX,GAAA;AAAA,MACC,GAAG,IAAA;AAAA,MAEJ,QAAA,kBAAAD,cAAA,CAAC,YAAa,EAAA,EAAA,aAAA,EAAW,IAAC,EAAA;AAAA;AAAA,GAC5B;AAEJ,CAAC;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".saltCarouselTabList.saltText {\n font-weight: var(--salt-
|
|
3
|
+
var css_248z = ".saltCarouselTabList.saltText {\n font-weight: var(--salt-text-fontWeight-strong);\n}\n";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=CarouselProgressLabel.css.js.map
|