@hitachivantara/uikit-react-core 5.66.13 → 5.66.14

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.
@@ -5,6 +5,7 @@ const React = require("react");
5
5
  const useCarousel = require("embla-carousel-react");
6
6
  const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
7
7
  const useDefaultProps = require("../hooks/useDefaultProps.cjs");
8
+ const useLabels = require("../hooks/useLabels.cjs");
8
9
  const useTheme = require("../hooks/useTheme.cjs");
9
10
  const helpers = require("../utils/helpers.cjs");
10
11
  const Carousel_styles = require("./Carousel.styles.cjs");
@@ -16,6 +17,12 @@ const IconButton = require("../IconButton/IconButton.cjs");
16
17
  const Typography = require("../Typography/Typography.cjs");
17
18
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
18
19
  const useCarousel__default = /* @__PURE__ */ _interopDefault(useCarousel);
20
+ const DEFAULT_LABELS = {
21
+ close: "Close",
22
+ fullscreen: "Fullscreen",
23
+ backwards: "Backwards",
24
+ forwards: "Forwards"
25
+ };
19
26
  const HvCarousel = (props) => {
20
27
  const {
21
28
  className,
@@ -33,13 +40,16 @@ const HvCarousel = (props) => {
33
40
  hideThumbnails: hideThumbnailsProp,
34
41
  controlsPosition: controlsPositionProp,
35
42
  thumbnailsPosition: thumbnailsPositionProp,
43
+ labels: labelsProps,
36
44
  carouselOptions,
37
45
  renderThumbnail,
38
46
  onChange,
47
+ onFullscreen,
39
48
  ...others
40
49
  } = useDefaultProps.useDefaultProps("HvCarousel", props);
41
50
  const { activeTheme } = useTheme.useTheme();
42
51
  const { classes, css, cx } = Carousel_styles.useClasses(classesProp);
52
+ const labels = useLabels.useLabels(DEFAULT_LABELS, labelsProps);
43
53
  const thumbnailsRef = React.useRef(null);
44
54
  const [isFullscreen, setIsFullscreen] = React.useState(false);
45
55
  const isDs3 = activeTheme?.name === "ds3";
@@ -86,6 +96,10 @@ const HvCarousel = (props) => {
86
96
  controller.reInit();
87
97
  setSelectedIndex((currentIndex) => helpers.clamp(currentIndex, numSlides));
88
98
  }, [numSlides, controller]);
99
+ const handleFullscreen = (event) => {
100
+ onFullscreen?.(event, !isFullscreen);
101
+ setIsFullscreen((curr) => !curr);
102
+ };
89
103
  const canPrev = controller?.canScrollPrev() ?? false;
90
104
  const canNext = controller?.canScrollNext() ?? false;
91
105
  const showTitle = !!title && (!xs || isFullscreen);
@@ -107,8 +121,8 @@ const HvCarousel = (props) => {
107
121
  showFullscreen && /* @__PURE__ */ jsxRuntime.jsx(
108
122
  IconButton.HvIconButton,
109
123
  {
110
- title: isFullscreen ? "Close" : "Fullscreen",
111
- onClick: () => setIsFullscreen((curr) => !curr),
124
+ title: isFullscreen ? labels.close : labels.fullscreen,
125
+ onClick: handleFullscreen,
112
126
  className: classes.closeButton,
113
127
  children: isFullscreen ? /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Close, {}) : /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Fullscreen, {})
114
128
  }
@@ -127,7 +141,11 @@ const HvCarousel = (props) => {
127
141
  canNext,
128
142
  onPreviousClick: handlePrevious,
129
143
  onNextClick: handleNext,
130
- actions: actionsPosition === "controls" && actions
144
+ actions: actionsPosition === "controls" && actions,
145
+ labels: {
146
+ backwards: labels.backwards,
147
+ forwards: labels.forwards
148
+ }
131
149
  }
132
150
  );
133
151
  const thumbnails = showThumbnails && /* @__PURE__ */ jsxRuntime.jsx(
@@ -171,7 +189,7 @@ const HvCarousel = (props) => {
171
189
  icon: true,
172
190
  disabled: !canPrev,
173
191
  variant: "secondarySubtle",
174
- "aria-label": "Backwards",
192
+ "aria-label": labels.backwards,
175
193
  onClick: handlePrevious,
176
194
  children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Backwards, { iconSize: "XS" })
177
195
  }
@@ -182,7 +200,7 @@ const HvCarousel = (props) => {
182
200
  icon: true,
183
201
  disabled: !canNext,
184
202
  variant: "secondarySubtle",
185
- "aria-label": "Forwards",
203
+ "aria-label": labels.forwards,
186
204
  onClick: handleNext,
187
205
  children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Forwards, { iconSize: "XS" })
188
206
  }
@@ -3,8 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
5
5
  const useDefaultProps = require("../hooks/useDefaultProps.cjs");
6
+ const useLabels = require("../hooks/useLabels.cjs");
6
7
  const Carousel_styles = require("./Carousel.styles.cjs");
7
8
  const Button = require("../Button/Button.cjs");
9
+ const DEFAULT_LABELS = {
10
+ backwards: "Backwards",
11
+ forwards: "Forwards"
12
+ };
8
13
  const HvCarouselControls = (props) => {
9
14
  const {
10
15
  classes: classesProp,
@@ -15,10 +20,12 @@ const HvCarouselControls = (props) => {
15
20
  canPrevious,
16
21
  canNext,
17
22
  actions,
23
+ labels: labelsProps,
18
24
  onPreviousClick,
19
25
  onNextClick
20
26
  } = useDefaultProps.useDefaultProps("HvCarouselControls", props);
21
27
  const { classes, cx } = Carousel_styles.useClasses(classesProp, false);
28
+ const labels = useLabels.useLabels(DEFAULT_LABELS, labelsProps);
22
29
  const selectedIndex = page || 0;
23
30
  const numSlides = pages;
24
31
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx(classes.controls, className), children: [
@@ -36,7 +43,7 @@ const HvCarouselControls = (props) => {
36
43
  {
37
44
  icon: true,
38
45
  disabled: !canPrevious,
39
- "aria-label": "Backwards",
46
+ "aria-label": labels.backwards,
40
47
  onClick: onPreviousClick,
41
48
  children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Backwards, { iconSize: "XS" })
42
49
  }
@@ -47,7 +54,7 @@ const HvCarouselControls = (props) => {
47
54
  {
48
55
  icon: true,
49
56
  disabled: !canNext,
50
- "aria-label": "Forwards",
57
+ "aria-label": labels.forwards,
51
58
  onClick: onNextClick,
52
59
  children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Forwards, { iconSize: "XS" })
53
60
  }
@@ -3,6 +3,7 @@ import { useRef, useState, Children, useCallback, useEffect } from "react";
3
3
  import useCarousel from "embla-carousel-react";
4
4
  import { Close, Fullscreen, Backwards, Forwards } from "@hitachivantara/uikit-react-icons";
5
5
  import { useDefaultProps } from "../hooks/useDefaultProps.js";
6
+ import { useLabels } from "../hooks/useLabels.js";
6
7
  import { useTheme } from "../hooks/useTheme.js";
7
8
  import { clamp } from "../utils/helpers.js";
8
9
  import { useClasses } from "./Carousel.styles.js";
@@ -13,6 +14,12 @@ import { HvContainer } from "../Container/Container.js";
13
14
  import { HvButton } from "../Button/Button.js";
14
15
  import { HvIconButton } from "../IconButton/IconButton.js";
15
16
  import { HvTypography } from "../Typography/Typography.js";
17
+ const DEFAULT_LABELS = {
18
+ close: "Close",
19
+ fullscreen: "Fullscreen",
20
+ backwards: "Backwards",
21
+ forwards: "Forwards"
22
+ };
16
23
  const HvCarousel = (props) => {
17
24
  const {
18
25
  className,
@@ -30,13 +37,16 @@ const HvCarousel = (props) => {
30
37
  hideThumbnails: hideThumbnailsProp,
31
38
  controlsPosition: controlsPositionProp,
32
39
  thumbnailsPosition: thumbnailsPositionProp,
40
+ labels: labelsProps,
33
41
  carouselOptions,
34
42
  renderThumbnail,
35
43
  onChange,
44
+ onFullscreen,
36
45
  ...others
37
46
  } = useDefaultProps("HvCarousel", props);
38
47
  const { activeTheme } = useTheme();
39
48
  const { classes, css, cx } = useClasses(classesProp);
49
+ const labels = useLabels(DEFAULT_LABELS, labelsProps);
40
50
  const thumbnailsRef = useRef(null);
41
51
  const [isFullscreen, setIsFullscreen] = useState(false);
42
52
  const isDs3 = activeTheme?.name === "ds3";
@@ -83,6 +93,10 @@ const HvCarousel = (props) => {
83
93
  controller.reInit();
84
94
  setSelectedIndex((currentIndex) => clamp(currentIndex, numSlides));
85
95
  }, [numSlides, controller]);
96
+ const handleFullscreen = (event) => {
97
+ onFullscreen?.(event, !isFullscreen);
98
+ setIsFullscreen((curr) => !curr);
99
+ };
86
100
  const canPrev = controller?.canScrollPrev() ?? false;
87
101
  const canNext = controller?.canScrollNext() ?? false;
88
102
  const showTitle = !!title && (!xs || isFullscreen);
@@ -104,8 +118,8 @@ const HvCarousel = (props) => {
104
118
  showFullscreen && /* @__PURE__ */ jsx(
105
119
  HvIconButton,
106
120
  {
107
- title: isFullscreen ? "Close" : "Fullscreen",
108
- onClick: () => setIsFullscreen((curr) => !curr),
121
+ title: isFullscreen ? labels.close : labels.fullscreen,
122
+ onClick: handleFullscreen,
109
123
  className: classes.closeButton,
110
124
  children: isFullscreen ? /* @__PURE__ */ jsx(Close, {}) : /* @__PURE__ */ jsx(Fullscreen, {})
111
125
  }
@@ -124,7 +138,11 @@ const HvCarousel = (props) => {
124
138
  canNext,
125
139
  onPreviousClick: handlePrevious,
126
140
  onNextClick: handleNext,
127
- actions: actionsPosition === "controls" && actions
141
+ actions: actionsPosition === "controls" && actions,
142
+ labels: {
143
+ backwards: labels.backwards,
144
+ forwards: labels.forwards
145
+ }
128
146
  }
129
147
  );
130
148
  const thumbnails = showThumbnails && /* @__PURE__ */ jsx(
@@ -168,7 +186,7 @@ const HvCarousel = (props) => {
168
186
  icon: true,
169
187
  disabled: !canPrev,
170
188
  variant: "secondarySubtle",
171
- "aria-label": "Backwards",
189
+ "aria-label": labels.backwards,
172
190
  onClick: handlePrevious,
173
191
  children: /* @__PURE__ */ jsx(Backwards, { iconSize: "XS" })
174
192
  }
@@ -179,7 +197,7 @@ const HvCarousel = (props) => {
179
197
  icon: true,
180
198
  disabled: !canNext,
181
199
  variant: "secondarySubtle",
182
- "aria-label": "Forwards",
200
+ "aria-label": labels.forwards,
183
201
  onClick: handleNext,
184
202
  children: /* @__PURE__ */ jsx(Forwards, { iconSize: "XS" })
185
203
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Carousel.js","sources":["../../../src/Carousel/Carousel.tsx"],"sourcesContent":["import { Children, useCallback, useEffect, useRef, useState } from \"react\";\nimport useCarousel from \"embla-carousel-react\";\nimport {\n Backwards,\n Close,\n Forwards,\n Fullscreen,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../Button\";\nimport { HvContainer } from \"../Container\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { HvIconButton } from \"../IconButton\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { clamp } from \"../utils/helpers\";\nimport { staticClasses, useClasses } from \"./Carousel.styles\";\nimport { HvCarouselControls } from \"./CarouselControls\";\nimport { HvCarouselThumbnails } from \"./CarouselThumbnails\";\n\nexport { staticClasses as carouselClasses };\n\nexport type HvCarouselClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCarouselProps\n extends HvBaseProps<HTMLDivElement, \"title\" | \"onChange\"> {\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvCarouselClasses;\n /** Height of the Slider container. If `undefined`, images will keep a 16/9 aspect-ratio */\n height?: React.CSSProperties[\"height\"];\n /** Width of the thumbnail. Height will try to maintain a 16/9 aspect-ratio */\n thumbnailWidth?: React.CSSProperties[\"width\"];\n /** Title of the carousel */\n title?: React.ReactNode;\n /** Content slides to be displayed. @see `<HvCarouselSlide />` */\n children?: React.ReactNode;\n /** Custom content to render in the actions area */\n actions?: React.ReactNode;\n /** Whether Carousel is in \"xs mode\" - to use in embedded contexts */\n xs?: boolean;\n /** Whether to show dots instead of arrow pagination. Defaults to true under 5 elements */\n showDots?: boolean;\n /** Whether to show the counter on the top-right corner of the active slide */\n showCounter?: boolean;\n /** Whether to show the back/forwards buttons over the active slide */\n showSlideControls?: boolean;\n /** Whether to enable the fullscreen toggle button */\n showFullscreen?: boolean;\n /** Whether to hide the thumbnails. Hidden by default in \"xs\" mode */\n hideThumbnails?: boolean;\n /** Controls position. */\n controlsPosition?: \"top\" | \"bottom\";\n /** Thumbnails position. */\n thumbnailsPosition?: \"top\" | \"bottom\";\n /** Carousel configuration options. @see https://www.embla-carousel.com/api/options/ */\n carouselOptions?: Parameters<typeof useCarousel>[0];\n /** Function that renders the thumbnail. */\n renderThumbnail?: (index: number) => React.ReactNode;\n /** The callback fired when the active slide changes. */\n onChange?: (index: number) => void;\n}\n\n/**\n * A Carousel is commonly used to browse images, it can also be used to browse any kind of content like text, video, or charts.\n * It allows you to focus on a particular content while having a notion of how many you have to explore.\n */\nexport const HvCarousel = (props: HvCarouselProps) => {\n const {\n className,\n classes: classesProp,\n height: heightProp = \"auto\",\n thumbnailWidth = 90,\n title,\n children,\n actions: actionsProp,\n xs,\n showDots: showDotsProp,\n showCounter: showCounterProp,\n showSlideControls,\n showFullscreen: showFullscreenProp,\n hideThumbnails: hideThumbnailsProp,\n controlsPosition: controlsPositionProp,\n thumbnailsPosition: thumbnailsPositionProp,\n carouselOptions,\n renderThumbnail,\n onChange,\n ...others\n } = useDefaultProps(\"HvCarousel\", props);\n const { activeTheme } = useTheme();\n const { classes, css, cx } = useClasses(classesProp);\n const thumbnailsRef = useRef<HTMLDivElement>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n const isDs3 = activeTheme?.name === \"ds3\";\n const actionsPosition = isDs3 ? \"header\" : \"controls\";\n const controlsPosition = controlsPositionProp ?? (isDs3 ? \"bottom\" : \"top\");\n const thumbnailsPosition = thumbnailsPositionProp ?? \"bottom\";\n\n const [containerRef, controller] = useCarousel({\n align: \"start\",\n loop: true,\n ...carouselOptions,\n });\n\n const [selectedIndex, setSelectedIndex] = useState(\n carouselOptions?.startIndex ?? 0,\n );\n\n const numSlides = Children.count(children);\n\n const handlePrevious = useCallback(() => {\n controller?.scrollPrev();\n }, [controller]);\n\n const handleNext = useCallback(() => {\n controller?.scrollNext();\n }, [controller]);\n\n const handleScroll = (index: number) => {\n controller?.scrollTo(index);\n };\n\n const handleSelect = useCallback(() => {\n if (!controller) return;\n\n const slideIndex = controller.selectedScrollSnap();\n setSelectedIndex(slideIndex);\n\n // scroll to thumbnail button\n thumbnailsRef.current\n ?.querySelectorAll(\"button\")\n ?.[slideIndex]?.scrollIntoView({\n behavior: \"smooth\",\n block: \"nearest\",\n });\n\n onChange?.(slideIndex);\n }, [controller, onChange]);\n\n useEffect(() => {\n if (!controller) return;\n\n controller.on(\"select\", handleSelect);\n\n return () => {\n controller.off(\"select\", handleSelect);\n };\n }, [controller, handleSelect]);\n\n useEffect(() => {\n if (!controller) return;\n\n controller.reInit();\n setSelectedIndex((currentIndex) => clamp(currentIndex, numSlides));\n }, [numSlides, controller]);\n\n const canPrev = controller?.canScrollPrev() ?? false;\n const canNext = controller?.canScrollNext() ?? false;\n const showTitle = !!title && (!xs || isFullscreen);\n const showFullscreen = showFullscreenProp ?? xs;\n const height = isFullscreen ? \"100%\" : (heightProp ?? \"auto\");\n const showCounter = xs;\n const hideThumbnails = hideThumbnailsProp ?? (xs && !isFullscreen);\n const showThumbnails = !hideThumbnails && !!renderThumbnail;\n const showDots = showDotsProp ?? numSlides <= 5;\n\n const actions = (\n <div\n className={cx(\n classes.actions,\n actionsPosition === \"header\"\n ? css({ position: \"relative\", top: -40, height: 0 })\n : css({ position: \"absolute\" }),\n )}\n >\n {actionsProp}\n {showFullscreen && (\n <HvIconButton\n title={isFullscreen ? \"Close\" : \"Fullscreen\"}\n onClick={() => setIsFullscreen((curr) => !curr)}\n className={classes.closeButton}\n >\n {isFullscreen ? <Close /> : <Fullscreen />}\n </HvIconButton>\n )}\n </div>\n );\n\n const controls = (\n <HvCarouselControls\n classes={classes}\n showDots={showDots}\n page={selectedIndex}\n pages={numSlides}\n canPrevious={canPrev}\n canNext={canNext}\n onPreviousClick={handlePrevious}\n onNextClick={handleNext}\n actions={actionsPosition === \"controls\" && actions}\n />\n );\n\n const thumbnails = showThumbnails && (\n <HvCarouselThumbnails\n classes={classes}\n ref={thumbnailsRef}\n page={selectedIndex}\n pages={numSlides}\n width={thumbnailWidth}\n onThumbnailClick={(evt, i) => handleScroll(i)}\n renderThumbnail={renderThumbnail}\n />\n );\n\n return (\n <HvContainer\n className={cx(classes.root, className, {\n [classes.xs]: xs,\n [classes.fullscreen]: isFullscreen,\n })}\n {...others}\n >\n {showTitle && (\n <HvTypography variant=\"title2\" className={classes.title}>\n {title}\n </HvTypography>\n )}\n\n {actionsPosition === \"header\" && actions}\n {thumbnailsPosition === \"top\" && thumbnails}\n {controlsPosition === \"top\" && controls}\n <div\n className={cx(classes.main, {\n [classes.mainXs]: xs,\n [classes.mainFullscreen]: isFullscreen,\n })}\n >\n {showCounter && (\n <div className={classes.counterContainer}>\n <span className={classes.counter}>\n {`${selectedIndex + 1}/${numSlides}`}\n </span>\n </div>\n )}\n\n {showSlideControls && (\n <div className={classes.slideControls}>\n <HvButton\n icon\n disabled={!canPrev}\n variant=\"secondarySubtle\"\n aria-label=\"Backwards\"\n onClick={handlePrevious}\n >\n <Backwards iconSize=\"XS\" />\n </HvButton>\n <HvButton\n icon\n disabled={!canNext}\n variant=\"secondarySubtle\"\n aria-label=\"Forwards\"\n onClick={handleNext}\n >\n <Forwards iconSize=\"XS\" />\n </HvButton>\n </div>\n )}\n\n <div\n ref={containerRef}\n style={{ height }}\n className={classes.slidesViewport}\n >\n <div className={classes.slidesContainer}>{children}</div>\n </div>\n </div>\n {controlsPosition === \"bottom\" && controls}\n {thumbnailsPosition === \"bottom\" && thumbnails}\n </HvContainer>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAoEa,MAAA,aAAa,CAAC,UAA2B;AAC9C,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,QAAQ,aAAa;AAAA,IACrB,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,UAAU;AAAA,IACV,aAAa;AAAA,IACb;AAAA,IACA,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB;AAA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AAAA,gBACA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,MAAI;AAAA,oBACJ,UAAU,CAAC;AAAA,oBACX,SAAQ;AAAA,oBACR,cAAW;AAAA,oBACX,SAAS;AAAA,oBAET,UAAA,oBAAC,UAAS,EAAA,UAAS,KAAK,CAAA;AAAA,kBAAA;AAAA,gBAC1B;AAAA,cAAA,GACF;AAAA,cAGF;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,KAAK;AAAA,kBACL,OAAO,EAAE,OAAO;AAAA,kBAChB,WAAW,QAAQ;AAAA,kBAEnB,UAAC,oBAAA,OAAA,EAAI,WAAW,QAAQ,iBAAkB,UAAS;AAAA,gBAAA;AAAA,cACrD;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,QACC,qBAAqB,YAAY;AAAA,QACjC,uBAAuB,YAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG1C;"}
1
+ {"version":3,"file":"Carousel.js","sources":["../../../src/Carousel/Carousel.tsx"],"sourcesContent":["import { Children, useCallback, useEffect, useRef, useState } from \"react\";\nimport useCarousel from \"embla-carousel-react\";\nimport {\n Backwards,\n Close,\n Forwards,\n Fullscreen,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../Button\";\nimport { HvContainer } from \"../Container\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { HvIconButton, HvIconButtonProps } from \"../IconButton\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { clamp } from \"../utils/helpers\";\nimport { staticClasses, useClasses } from \"./Carousel.styles\";\nimport { HvCarouselControls } from \"./CarouselControls\";\nimport { HvCarouselThumbnails } from \"./CarouselThumbnails\";\n\nexport { staticClasses as carouselClasses };\n\nexport type HvCarouselClasses = ExtractNames<typeof useClasses>;\n\nconst DEFAULT_LABELS = {\n close: \"Close\",\n fullscreen: \"Fullscreen\",\n backwards: \"Backwards\",\n forwards: \"Forwards\",\n};\n\nexport interface HvCarouselProps\n extends HvBaseProps<HTMLDivElement, \"title\" | \"onChange\"> {\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvCarouselClasses;\n /** Height of the Slider container. If `undefined`, images will keep a 16/9 aspect-ratio */\n height?: React.CSSProperties[\"height\"];\n /** Width of the thumbnail. Height will try to maintain a 16/9 aspect-ratio */\n thumbnailWidth?: React.CSSProperties[\"width\"];\n /** Title of the carousel */\n title?: React.ReactNode;\n /** Content slides to be displayed. @see `<HvCarouselSlide />` */\n children?: React.ReactNode;\n /** Custom content to render in the actions area */\n actions?: React.ReactNode;\n /** Whether Carousel is in \"xs mode\" - to use in embedded contexts */\n xs?: boolean;\n /** Whether to show dots instead of arrow pagination. Defaults to true under 5 elements */\n showDots?: boolean;\n /** Whether to show the counter on the top-right corner of the active slide */\n showCounter?: boolean;\n /** Whether to show the back/forwards buttons over the active slide */\n showSlideControls?: boolean;\n /** Whether to enable the fullscreen toggle button */\n showFullscreen?: boolean;\n /** Whether to hide the thumbnails. Hidden by default in \"xs\" mode */\n hideThumbnails?: boolean;\n /** Controls position. */\n controlsPosition?: \"top\" | \"bottom\";\n /** Thumbnails position. */\n thumbnailsPosition?: \"top\" | \"bottom\";\n /** Carousel configuration options. @see https://www.embla-carousel.com/api/options/ */\n carouselOptions?: Parameters<typeof useCarousel>[0];\n /** Function that renders the thumbnail. */\n renderThumbnail?: (index: number) => React.ReactNode;\n /** The callback fired when the active slide changes. */\n onChange?: (index: number) => void;\n /** The callback fired fullscreen is toggled. */\n onFullscreen?: (\n event: React.MouseEvent<HTMLButtonElement>,\n isFullscreen: boolean,\n ) => void;\n /** Labels used on the component. */\n labels?: Partial<typeof DEFAULT_LABELS>;\n}\n\n/**\n * A Carousel is commonly used to browse images, it can also be used to browse any kind of content like text, video, or charts.\n * It allows you to focus on a particular content while having a notion of how many you have to explore.\n */\nexport const HvCarousel = (props: HvCarouselProps) => {\n const {\n className,\n classes: classesProp,\n height: heightProp = \"auto\",\n thumbnailWidth = 90,\n title,\n children,\n actions: actionsProp,\n xs,\n showDots: showDotsProp,\n showCounter: showCounterProp,\n showSlideControls,\n showFullscreen: showFullscreenProp,\n hideThumbnails: hideThumbnailsProp,\n controlsPosition: controlsPositionProp,\n thumbnailsPosition: thumbnailsPositionProp,\n labels: labelsProps,\n carouselOptions,\n renderThumbnail,\n onChange,\n onFullscreen,\n ...others\n } = useDefaultProps(\"HvCarousel\", props);\n const { activeTheme } = useTheme();\n const { classes, css, cx } = useClasses(classesProp);\n const labels = useLabels(DEFAULT_LABELS, labelsProps);\n const thumbnailsRef = useRef<HTMLDivElement>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n const isDs3 = activeTheme?.name === \"ds3\";\n const actionsPosition = isDs3 ? \"header\" : \"controls\";\n const controlsPosition = controlsPositionProp ?? (isDs3 ? \"bottom\" : \"top\");\n const thumbnailsPosition = thumbnailsPositionProp ?? \"bottom\";\n\n const [containerRef, controller] = useCarousel({\n align: \"start\",\n loop: true,\n ...carouselOptions,\n });\n\n const [selectedIndex, setSelectedIndex] = useState(\n carouselOptions?.startIndex ?? 0,\n );\n\n const numSlides = Children.count(children);\n\n const handlePrevious = useCallback(() => {\n controller?.scrollPrev();\n }, [controller]);\n\n const handleNext = useCallback(() => {\n controller?.scrollNext();\n }, [controller]);\n\n const handleScroll = (index: number) => {\n controller?.scrollTo(index);\n };\n\n const handleSelect = useCallback(() => {\n if (!controller) return;\n\n const slideIndex = controller.selectedScrollSnap();\n setSelectedIndex(slideIndex);\n\n // scroll to thumbnail button\n thumbnailsRef.current\n ?.querySelectorAll(\"button\")\n ?.[slideIndex]?.scrollIntoView({\n behavior: \"smooth\",\n block: \"nearest\",\n });\n\n onChange?.(slideIndex);\n }, [controller, onChange]);\n\n useEffect(() => {\n if (!controller) return;\n\n controller.on(\"select\", handleSelect);\n\n return () => {\n controller.off(\"select\", handleSelect);\n };\n }, [controller, handleSelect]);\n\n useEffect(() => {\n if (!controller) return;\n\n controller.reInit();\n setSelectedIndex((currentIndex) => clamp(currentIndex, numSlides));\n }, [numSlides, controller]);\n\n const handleFullscreen: HvIconButtonProps[\"onClick\"] = (event) => {\n onFullscreen?.(event, !isFullscreen);\n setIsFullscreen((curr) => !curr);\n };\n\n const canPrev = controller?.canScrollPrev() ?? false;\n const canNext = controller?.canScrollNext() ?? false;\n const showTitle = !!title && (!xs || isFullscreen);\n const showFullscreen = showFullscreenProp ?? xs;\n const height = isFullscreen ? \"100%\" : (heightProp ?? \"auto\");\n const showCounter = xs;\n const hideThumbnails = hideThumbnailsProp ?? (xs && !isFullscreen);\n const showThumbnails = !hideThumbnails && !!renderThumbnail;\n const showDots = showDotsProp ?? numSlides <= 5;\n\n const actions = (\n <div\n className={cx(\n classes.actions,\n actionsPosition === \"header\"\n ? css({ position: \"relative\", top: -40, height: 0 })\n : css({ position: \"absolute\" }),\n )}\n >\n {actionsProp}\n {showFullscreen && (\n <HvIconButton\n title={isFullscreen ? labels.close : labels.fullscreen}\n onClick={handleFullscreen}\n className={classes.closeButton}\n >\n {isFullscreen ? <Close /> : <Fullscreen />}\n </HvIconButton>\n )}\n </div>\n );\n\n const controls = (\n <HvCarouselControls\n classes={classes}\n showDots={showDots}\n page={selectedIndex}\n pages={numSlides}\n canPrevious={canPrev}\n canNext={canNext}\n onPreviousClick={handlePrevious}\n onNextClick={handleNext}\n actions={actionsPosition === \"controls\" && actions}\n labels={{\n backwards: labels.backwards,\n forwards: labels.forwards,\n }}\n />\n );\n\n const thumbnails = showThumbnails && (\n <HvCarouselThumbnails\n classes={classes}\n ref={thumbnailsRef}\n page={selectedIndex}\n pages={numSlides}\n width={thumbnailWidth}\n onThumbnailClick={(evt, i) => handleScroll(i)}\n renderThumbnail={renderThumbnail}\n />\n );\n\n return (\n <HvContainer\n className={cx(classes.root, className, {\n [classes.xs]: xs,\n [classes.fullscreen]: isFullscreen,\n })}\n {...others}\n >\n {showTitle && (\n <HvTypography variant=\"title2\" className={classes.title}>\n {title}\n </HvTypography>\n )}\n\n {actionsPosition === \"header\" && actions}\n {thumbnailsPosition === \"top\" && thumbnails}\n {controlsPosition === \"top\" && controls}\n <div\n className={cx(classes.main, {\n [classes.mainXs]: xs,\n [classes.mainFullscreen]: isFullscreen,\n })}\n >\n {showCounter && (\n <div className={classes.counterContainer}>\n <span className={classes.counter}>\n {`${selectedIndex + 1}/${numSlides}`}\n </span>\n </div>\n )}\n\n {showSlideControls && (\n <div className={classes.slideControls}>\n <HvButton\n icon\n disabled={!canPrev}\n variant=\"secondarySubtle\"\n aria-label={labels.backwards}\n onClick={handlePrevious}\n >\n <Backwards iconSize=\"XS\" />\n </HvButton>\n <HvButton\n icon\n disabled={!canNext}\n variant=\"secondarySubtle\"\n aria-label={labels.forwards}\n onClick={handleNext}\n >\n <Forwards iconSize=\"XS\" />\n </HvButton>\n </div>\n )}\n\n <div\n ref={containerRef}\n style={{ height }}\n className={classes.slidesViewport}\n >\n <div className={classes.slidesContainer}>{children}</div>\n </div>\n </div>\n {controlsPosition === \"bottom\" && controls}\n {thumbnailsPosition === \"bottom\" && thumbnails}\n </HvContainer>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA2BA,MAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,UAAU;AACZ;AAmDa,MAAA,aAAa,CAAC,UAA2B;AAC9C,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,QAAQ,aAAa;AAAA,IACrB,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,UAAU;AAAA,IACV,aAAa;AAAA,IACb;AAAA,IACA,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB,QAAQ;AAAA,IACR;AAAA,IAC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AAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,MAAI;AAAA,oBACJ,UAAU,CAAC;AAAA,oBACX,SAAQ;AAAA,oBACR,cAAY,OAAO;AAAA,oBACnB,SAAS;AAAA,oBAET,UAAA,oBAAC,WAAU,EAAA,UAAS,KAAK,CAAA;AAAA,kBAAA;AAAA,gBAC3B;AAAA,gBACA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,MAAI;AAAA,oBACJ,UAAU,CAAC;AAAA,oBACX,SAAQ;AAAA,oBACR,cAAY,OAAO;AAAA,oBACnB,SAAS;AAAA,oBAET,UAAA,oBAAC,UAAS,EAAA,UAAS,KAAK,CAAA;AAAA,kBAAA;AAAA,gBAC1B;AAAA,cAAA,GACF;AAAA,cAGF;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,KAAK;AAAA,kBACL,OAAO,EAAE,OAAO;AAAA,kBAChB,WAAW,QAAQ;AAAA,kBAEnB,UAAC,oBAAA,OAAA,EAAI,WAAW,QAAQ,iBAAkB,UAAS;AAAA,gBAAA;AAAA,cACrD;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,QACC,qBAAqB,YAAY;AAAA,QACjC,uBAAuB,YAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG1C;"}
@@ -1,8 +1,13 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { Backwards, Forwards } from "@hitachivantara/uikit-react-icons";
3
3
  import { useDefaultProps } from "../hooks/useDefaultProps.js";
4
+ import { useLabels } from "../hooks/useLabels.js";
4
5
  import { useClasses } from "./Carousel.styles.js";
5
6
  import { HvButton } from "../Button/Button.js";
7
+ const DEFAULT_LABELS = {
8
+ backwards: "Backwards",
9
+ forwards: "Forwards"
10
+ };
6
11
  const HvCarouselControls = (props) => {
7
12
  const {
8
13
  classes: classesProp,
@@ -13,10 +18,12 @@ const HvCarouselControls = (props) => {
13
18
  canPrevious,
14
19
  canNext,
15
20
  actions,
21
+ labels: labelsProps,
16
22
  onPreviousClick,
17
23
  onNextClick
18
24
  } = useDefaultProps("HvCarouselControls", props);
19
25
  const { classes, cx } = useClasses(classesProp, false);
26
+ const labels = useLabels(DEFAULT_LABELS, labelsProps);
20
27
  const selectedIndex = page || 0;
21
28
  const numSlides = pages;
22
29
  return /* @__PURE__ */ jsxs("div", { className: cx(classes.controls, className), children: [
@@ -34,7 +41,7 @@ const HvCarouselControls = (props) => {
34
41
  {
35
42
  icon: true,
36
43
  disabled: !canPrevious,
37
- "aria-label": "Backwards",
44
+ "aria-label": labels.backwards,
38
45
  onClick: onPreviousClick,
39
46
  children: /* @__PURE__ */ jsx(Backwards, { iconSize: "XS" })
40
47
  }
@@ -45,7 +52,7 @@ const HvCarouselControls = (props) => {
45
52
  {
46
53
  icon: true,
47
54
  disabled: !canNext,
48
- "aria-label": "Forwards",
55
+ "aria-label": labels.forwards,
49
56
  onClick: onNextClick,
50
57
  children: /* @__PURE__ */ jsx(Forwards, { iconSize: "XS" })
51
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CarouselControls.js","sources":["../../../src/Carousel/CarouselControls.tsx"],"sourcesContent":["import { Backwards, Forwards } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../Button\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvPaginationProps } from \"../Pagination\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useClasses } from \"./Carousel.styles\";\n\ninterface HvCarouselControlsProps\n extends HvBaseProps<HTMLDivElement>,\n Pick<HvPaginationProps, \"page\" | \"pages\" | \"canPrevious\" | \"canNext\"> {\n showDots?: boolean;\n classes?: ExtractNames<typeof useClasses>;\n actions?: React.ReactNode;\n onPreviousClick?: React.MouseEventHandler<HTMLButtonElement>;\n onNextClick?: React.MouseEventHandler<HTMLButtonElement>;\n}\n\nexport const HvCarouselControls = (props: HvCarouselControlsProps) => {\n const {\n classes: classesProp,\n className,\n showDots,\n page,\n pages,\n canPrevious,\n canNext,\n actions,\n onPreviousClick,\n onNextClick,\n } = useDefaultProps(\"HvCarouselControls\", props);\n const { classes, cx } = useClasses(classesProp, false);\n\n const selectedIndex = page || 0;\n const numSlides = pages;\n\n return (\n <div className={cx(classes.controls, className)}>\n {showDots ? (\n <div className={classes.dots}>\n {Array.from(Array(numSlides)).map((el, index) => (\n <span\n key={`circle-${index}`}\n className={cx(classes.dot, {\n [classes.dotSelected]: index === selectedIndex,\n })}\n />\n ))}\n </div>\n ) : (\n <>\n <HvButton\n icon\n disabled={!canPrevious}\n aria-label=\"Backwards\"\n onClick={onPreviousClick}\n >\n <Backwards iconSize=\"XS\" />\n </HvButton>\n <div className={classes.pageCounter}>\n {`${selectedIndex + 1} / ${numSlides}`}\n </div>\n <HvButton\n icon\n disabled={!canNext}\n aria-label=\"Forwards\"\n onClick={onNextClick}\n >\n <Forwards iconSize=\"XS\" />\n </HvButton>\n </>\n )}\n {actions}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;AAmBa,MAAA,qBAAqB,CAAC,UAAmC;AAC9D,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,gBAAgB,sBAAsB,KAAK;AAC/C,QAAM,EAAE,SAAS,GAAA,IAAO,WAAW,aAAa,KAAK;AAErD,QAAM,gBAAgB,QAAQ;AAC9B,QAAM,YAAY;AAElB,8BACG,OAAI,EAAA,WAAW,GAAG,QAAQ,UAAU,SAAS,GAC3C,UAAA;AAAA,IAAA,WACE,oBAAA,OAAA,EAAI,WAAW,QAAQ,MACrB,UAAM,MAAA,KAAK,MAAM,SAAS,CAAC,EAAE,IAAI,CAAC,IAAI,UACrC;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,WAAW,GAAG,QAAQ,KAAK;AAAA,UACzB,CAAC,QAAQ,WAAW,GAAG,UAAU;AAAA,QAAA,CAClC;AAAA,MAAA;AAAA,MAHI,UAAU,KAAK;AAAA,IAKvB,CAAA,EACH,CAAA,IAGE,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAI;AAAA,UACJ,UAAU,CAAC;AAAA,UACX,cAAW;AAAA,UACX,SAAS;AAAA,UAET,UAAA,oBAAC,WAAU,EAAA,UAAS,KAAK,CAAA;AAAA,QAAA;AAAA,MAC3B;AAAA,MACA,oBAAC,OAAI,EAAA,WAAW,QAAQ,aACrB,aAAG,gBAAgB,CAAC,MAAM,SAAS,GACtC,CAAA;AAAA,MACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAI;AAAA,UACJ,UAAU,CAAC;AAAA,UACX,cAAW;AAAA,UACX,SAAS;AAAA,UAET,UAAA,oBAAC,UAAS,EAAA,UAAS,KAAK,CAAA;AAAA,QAAA;AAAA,MAC1B;AAAA,IAAA,GACF;AAAA,IAED;AAAA,EACH,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"CarouselControls.js","sources":["../../../src/Carousel/CarouselControls.tsx"],"sourcesContent":["import { Backwards, Forwards } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../Button\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { HvPaginationProps } from \"../Pagination\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useClasses } from \"./Carousel.styles\";\n\nconst DEFAULT_LABELS = {\n backwards: \"Backwards\",\n forwards: \"Forwards\",\n};\n\ninterface HvCarouselControlsProps\n extends HvBaseProps<HTMLDivElement>,\n Pick<HvPaginationProps, \"page\" | \"pages\" | \"canPrevious\" | \"canNext\"> {\n showDots?: boolean;\n classes?: ExtractNames<typeof useClasses>;\n actions?: React.ReactNode;\n onPreviousClick?: React.MouseEventHandler<HTMLButtonElement>;\n onNextClick?: React.MouseEventHandler<HTMLButtonElement>;\n /** Labels used on the component. */\n labels?: Partial<typeof DEFAULT_LABELS>;\n}\n\nexport const HvCarouselControls = (props: HvCarouselControlsProps) => {\n const {\n classes: classesProp,\n className,\n showDots,\n page,\n pages,\n canPrevious,\n canNext,\n actions,\n labels: labelsProps,\n onPreviousClick,\n onNextClick,\n } = useDefaultProps(\"HvCarouselControls\", props);\n const { classes, cx } = useClasses(classesProp, false);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProps);\n\n const selectedIndex = page || 0;\n const numSlides = pages;\n\n return (\n <div className={cx(classes.controls, className)}>\n {showDots ? (\n <div className={classes.dots}>\n {Array.from(Array(numSlides)).map((el, index) => (\n <span\n key={`circle-${index}`}\n className={cx(classes.dot, {\n [classes.dotSelected]: index === selectedIndex,\n })}\n />\n ))}\n </div>\n ) : (\n <>\n <HvButton\n icon\n disabled={!canPrevious}\n aria-label={labels.backwards}\n onClick={onPreviousClick}\n >\n <Backwards iconSize=\"XS\" />\n </HvButton>\n <div className={classes.pageCounter}>\n {`${selectedIndex + 1} / ${numSlides}`}\n </div>\n <HvButton\n icon\n disabled={!canNext}\n aria-label={labels.forwards}\n onClick={onNextClick}\n >\n <Forwards iconSize=\"XS\" />\n </HvButton>\n </>\n )}\n {actions}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;AAUA,MAAM,iBAAiB;AAAA,EACrB,WAAW;AAAA,EACX,UAAU;AACZ;AAca,MAAA,qBAAqB,CAAC,UAAmC;AAC9D,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EAAA,IACE,gBAAgB,sBAAsB,KAAK;AAC/C,QAAM,EAAE,SAAS,GAAA,IAAO,WAAW,aAAa,KAAK;AAE/C,QAAA,SAAS,UAAU,gBAAgB,WAAW;AAEpD,QAAM,gBAAgB,QAAQ;AAC9B,QAAM,YAAY;AAElB,8BACG,OAAI,EAAA,WAAW,GAAG,QAAQ,UAAU,SAAS,GAC3C,UAAA;AAAA,IAAA,WACE,oBAAA,OAAA,EAAI,WAAW,QAAQ,MACrB,UAAM,MAAA,KAAK,MAAM,SAAS,CAAC,EAAE,IAAI,CAAC,IAAI,UACrC;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,WAAW,GAAG,QAAQ,KAAK;AAAA,UACzB,CAAC,QAAQ,WAAW,GAAG,UAAU;AAAA,QAAA,CAClC;AAAA,MAAA;AAAA,MAHI,UAAU,KAAK;AAAA,IAKvB,CAAA,EACH,CAAA,IAGE,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAI;AAAA,UACJ,UAAU,CAAC;AAAA,UACX,cAAY,OAAO;AAAA,UACnB,SAAS;AAAA,UAET,UAAA,oBAAC,WAAU,EAAA,UAAS,KAAK,CAAA;AAAA,QAAA;AAAA,MAC3B;AAAA,MACA,oBAAC,OAAI,EAAA,WAAW,QAAQ,aACrB,aAAG,gBAAgB,CAAC,MAAM,SAAS,GACtC,CAAA;AAAA,MACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAI;AAAA,UACJ,UAAU,CAAC;AAAA,UACX,cAAY,OAAO;AAAA,UACnB,SAAS;AAAA,UAET,UAAA,oBAAC,UAAS,EAAA,UAAS,KAAK,CAAA;AAAA,QAAA;AAAA,MAC1B;AAAA,IAAA,GACF;AAAA,IAED;AAAA,EACH,EAAA,CAAA;AAEJ;"}
@@ -642,6 +642,13 @@ export declare type DeepPartial<T> = T extends {} ? Partial<{
642
642
  }> : T;
643
643
 
644
644
  declare const DEFAULT_LABELS: {
645
+ close: string;
646
+ fullscreen: string;
647
+ backwards: string;
648
+ forwards: string;
649
+ };
650
+
651
+ declare const DEFAULT_LABELS_2: {
645
652
  /** The show label. */
646
653
  pageSizePrev: string;
647
654
  /** Indicate the units of the page size selection. */
@@ -670,7 +677,7 @@ declare const DEFAULT_LABELS: {
670
677
  lastPage: string;
671
678
  };
672
679
 
673
- declare const DEFAULT_LABELS_2: {
680
+ declare const DEFAULT_LABELS_3: {
674
681
  /** The label of the clear button. */
675
682
  clearButtonLabel: string;
676
683
  /** The label of the reveal password button. */
@@ -683,12 +690,17 @@ declare const DEFAULT_LABELS_2: {
683
690
  searchButtonLabel: string;
684
691
  };
685
692
 
686
- declare const DEFAULT_LABELS_3: {
693
+ declare const DEFAULT_LABELS_4: {
694
+ backwards: string;
695
+ forwards: string;
696
+ };
697
+
698
+ declare const DEFAULT_LABELS_5: {
687
699
  recommendedColorsLabel: string;
688
700
  customColorsLabel: string;
689
701
  };
690
702
 
691
- declare const DEFAULT_LABELS_4: {
703
+ declare const DEFAULT_LABELS_6: {
692
704
  /** Label for overwrite the default header behavior. */
693
705
  select: string | undefined;
694
706
  /** Label used for the All checkbox action. */
@@ -703,7 +715,7 @@ declare const DEFAULT_LABELS_4: {
703
715
  multiSelectionConjunction: string;
704
716
  };
705
717
 
706
- declare const DEFAULT_LABELS_5: {
718
+ declare const DEFAULT_LABELS_7: {
707
719
  /** Apply button label. */
708
720
  applyLabel: string;
709
721
  /** Cancel button label. */
@@ -714,7 +726,7 @@ declare const DEFAULT_LABELS_5: {
714
726
  invalidDateLabel: string;
715
727
  };
716
728
 
717
- declare const DEFAULT_LABELS_6: {
729
+ declare const DEFAULT_LABELS_8: {
718
730
  /** Apply button label. */
719
731
  applyLabel: string;
720
732
  /** Cancel button label. */
@@ -731,7 +743,7 @@ declare const DEFAULT_LABELS_6: {
731
743
  multiSelectionConjunction: string;
732
744
  };
733
745
 
734
- declare const DEFAULT_LABELS_7: {
746
+ declare const DEFAULT_LABELS_9: {
735
747
  /** The text at the top of the kpi. */
736
748
  title: string;
737
749
  /** The text in the middle of the kpi. */
@@ -2280,6 +2292,8 @@ declare interface HvCarouselControlsProps extends HvBaseProps<HTMLDivElement>, P
2280
2292
  actions?: React.ReactNode;
2281
2293
  onPreviousClick?: React.MouseEventHandler<HTMLButtonElement>;
2282
2294
  onNextClick?: React.MouseEventHandler<HTMLButtonElement>;
2295
+ /** Labels used on the component. */
2296
+ labels?: Partial<typeof DEFAULT_LABELS_4>;
2283
2297
  }
2284
2298
 
2285
2299
  export declare interface HvCarouselProps extends HvBaseProps<HTMLDivElement, "title" | "onChange"> {
@@ -2317,6 +2331,10 @@ export declare interface HvCarouselProps extends HvBaseProps<HTMLDivElement, "ti
2317
2331
  renderThumbnail?: (index: number) => React.ReactNode;
2318
2332
  /** The callback fired when the active slide changes. */
2319
2333
  onChange?: (index: number) => void;
2334
+ /** The callback fired fullscreen is toggled. */
2335
+ onFullscreen?: (event: React.MouseEvent<HTMLButtonElement>, isFullscreen: boolean) => void;
2336
+ /** Labels used on the component. */
2337
+ labels?: Partial<typeof DEFAULT_LABELS>;
2320
2338
  }
2321
2339
 
2322
2340
  /**
@@ -2591,7 +2609,7 @@ export declare interface HvColorPickerProps {
2591
2609
  /** If `true`, the labels are shown. If `false`, they are not shown. */
2592
2610
  showLabels?: boolean;
2593
2611
  /** An object containing all the labels. */
2594
- labels?: Partial<typeof DEFAULT_LABELS_3>;
2612
+ labels?: Partial<typeof DEFAULT_LABELS_5>;
2595
2613
  /** Icon type for the input's end adornment. */
2596
2614
  dropdownIcon?: "arrow" | "colorPicker";
2597
2615
  /** If `true`, the input only shows an icon. If `false`, the input shows text and icons. */
@@ -2798,7 +2816,7 @@ export declare interface HvDatePickerProps extends Omit<HvFormElementProps, "onC
2798
2816
  /**
2799
2817
  * An object containing all the labels for the datepicker.
2800
2818
  */
2801
- labels?: Partial<typeof DEFAULT_LABELS_5>;
2819
+ labels?: Partial<typeof DEFAULT_LABELS_7>;
2802
2820
  /**
2803
2821
  * The initial value of the input when in single calendar mode.
2804
2822
  */
@@ -3058,7 +3076,7 @@ export declare interface HvDropdownColumnCellProp {
3058
3076
  dropdownProps?: HvDropdownProps;
3059
3077
  }
3060
3078
 
3061
- export declare type HvDropdownLabels = Partial<typeof DEFAULT_LABELS_4>;
3079
+ export declare type HvDropdownLabels = Partial<typeof DEFAULT_LABELS_6>;
3062
3080
 
3063
3081
  /** @deprecated use `HvDropdownLabels` instead */
3064
3082
  export declare type HvDropdownLabelsProps = HvDropdownLabels;
@@ -3554,7 +3572,7 @@ export declare type HvFilterGroupFilters = {
3554
3572
 
3555
3573
  export declare type HvFilterGroupHorizontalPlacement = "left" | "right";
3556
3574
 
3557
- export declare type HvFilterGroupLabels = Partial<typeof DEFAULT_LABELS_6>;
3575
+ export declare type HvFilterGroupLabels = Partial<typeof DEFAULT_LABELS_8>;
3558
3576
 
3559
3577
  export declare interface HvFilterGroupProps extends Omit<HvFormElementProps, "classes" | "onChange" | "defaultValue" | "statusMessage"> {
3560
3578
  /** The initial value of the input when in single calendar mode. */
@@ -4127,7 +4145,7 @@ export declare const HvInput: ForwardRefExoticComponent<HvInputProps & RefAttrib
4127
4145
 
4128
4146
  export declare type HvInputClasses = ExtractNames<typeof useClasses_45>;
4129
4147
 
4130
- export declare type HvInputLabels = Partial<typeof DEFAULT_LABELS_2>;
4148
+ export declare type HvInputLabels = Partial<typeof DEFAULT_LABELS_3>;
4131
4149
 
4132
4150
  export declare interface HvInputProps extends HvBaseProps<HTMLElement, "onChange" | "onBlur" | "onFocus" | "onKeyDown" | "color"> {
4133
4151
  /** The form element name. */
@@ -4275,7 +4293,7 @@ export declare const HvKpi: (props: HvKpiProps) => JSX_2.Element;
4275
4293
 
4276
4294
  export declare type HvKpiClasses = ExtractNames<typeof useClasses_82>;
4277
4295
 
4278
- export declare type HvKpiLabelProps = Partial<typeof DEFAULT_LABELS_7>;
4296
+ export declare type HvKpiLabelProps = Partial<typeof DEFAULT_LABELS_9>;
4279
4297
 
4280
4298
  export declare interface HvKpiProps extends HvBaseProps<HTMLDivElement, "children"> {
4281
4299
  /**
@@ -4683,7 +4701,7 @@ export declare const HvPagination: (props: HvPaginationProps) => JSX_2.Element;
4683
4701
 
4684
4702
  export declare type HvPaginationClasses = ExtractNames<typeof useClasses_46>;
4685
4703
 
4686
- export declare type HvPaginationLabels = Partial<typeof DEFAULT_LABELS>;
4704
+ export declare type HvPaginationLabels = Partial<typeof DEFAULT_LABELS_2>;
4687
4705
 
4688
4706
  export declare type HvPaginationPropGetter<D extends object> = PropGetter<D, HvTablePaginationProps>;
4689
4707
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/uikit-react-core",
3
- "version": "5.66.13",
3
+ "version": "5.66.14",
4
4
  "private": false,
5
5
  "author": "Hitachi Vantara UI Kit Team",
6
6
  "description": "Core React components for the NEXT Design System.",
@@ -34,7 +34,7 @@
34
34
  "@emotion/css": "^11.11.2",
35
35
  "@emotion/serialize": "^1.1.2",
36
36
  "@emotion/utils": "^1.2.1",
37
- "@hitachivantara/uikit-react-icons": "^5.10.4",
37
+ "@hitachivantara/uikit-react-icons": "^5.10.5",
38
38
  "@hitachivantara/uikit-react-shared": "^5.1.45",
39
39
  "@hitachivantara/uikit-styles": "^5.31.0",
40
40
  "@internationalized/date": "^3.2.0",
@@ -63,7 +63,7 @@
63
63
  "access": "public",
64
64
  "directory": "package"
65
65
  },
66
- "gitHead": "783ab99a5fb41ad89f810e44fc15c1853a7f8381",
66
+ "gitHead": "143286b6fdeed50a3265683bebb09dba16ab0395",
67
67
  "exports": {
68
68
  ".": {
69
69
  "require": "./dist/cjs/index.cjs",