@telia/teddy 0.1.4 → 0.1.5
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/dist/components/card/card-carousel.cjs +4 -0
- package/dist/components/card/card-carousel.d.ts +2 -1
- package/dist/components/card/card-carousel.js +5 -1
- package/dist/components/carousel/carousel-root.cjs +5 -2
- package/dist/components/carousel/carousel-root.d.ts +2 -1
- package/dist/components/carousel/carousel-root.js +6 -3
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ const utils_breakpointToNumber = require("../../utils/breakpointToNumber.cjs");
|
|
|
10
10
|
const tokens_breakpoint_variables = require("../../tokens/breakpoint/variables.cjs");
|
|
11
11
|
const ImageSlider = React.forwardRef(
|
|
12
12
|
({
|
|
13
|
+
sliderRef,
|
|
13
14
|
settings,
|
|
14
15
|
variants,
|
|
15
16
|
className,
|
|
@@ -22,9 +23,12 @@ const ImageSlider = React.forwardRef(
|
|
|
22
23
|
const [selectedSlide, setSelectedSlide] = React.useState((settings == null ? void 0 : settings.initialSlide) || 0);
|
|
23
24
|
const rootCarouselClass = `${components_card_card.rootClassName}__carousel`;
|
|
24
25
|
const classes = clsx([components_card_card.styles[rootCarouselClass]], className);
|
|
26
|
+
const internalSliderRef = React.useRef(null);
|
|
27
|
+
const innerSliderRef = sliderRef || internalSliderRef;
|
|
25
28
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: forwardRef, className: classes, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
26
29
|
components_carousel_carouselRoot.Carousel,
|
|
27
30
|
{
|
|
31
|
+
sliderRef: innerSliderRef,
|
|
28
32
|
size: "sm",
|
|
29
33
|
onClickNext,
|
|
30
34
|
onClickPrev,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { Settings } from 'react-slick';
|
|
2
|
+
import { default as Slider, Settings } from 'react-slick';
|
|
3
3
|
|
|
4
4
|
export type ImageSliderVariant = {
|
|
5
5
|
color: string;
|
|
@@ -10,6 +10,7 @@ export interface ImageSliderProps {
|
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
className?: string;
|
|
12
12
|
settings?: Settings;
|
|
13
|
+
sliderRef?: React.RefObject<Slider>;
|
|
13
14
|
onClick?: () => void;
|
|
14
15
|
onClickNext?: () => void;
|
|
15
16
|
onClickPrev?: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import React__default, { useState } from "react";
|
|
2
|
+
import React__default, { useState, useRef } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { s as styles, rootClassName } from "./card.js";
|
|
5
5
|
import { Carousel } from "../carousel/carousel-root.js";
|
|
@@ -8,6 +8,7 @@ import { breakpointToNumber } from "../../utils/breakpointToNumber.js";
|
|
|
8
8
|
import { teddyBreakpointMd } from "../../tokens/breakpoint/variables.js";
|
|
9
9
|
const ImageSlider = React__default.forwardRef(
|
|
10
10
|
({
|
|
11
|
+
sliderRef,
|
|
11
12
|
settings,
|
|
12
13
|
variants,
|
|
13
14
|
className,
|
|
@@ -20,9 +21,12 @@ const ImageSlider = React__default.forwardRef(
|
|
|
20
21
|
const [selectedSlide, setSelectedSlide] = useState((settings == null ? void 0 : settings.initialSlide) || 0);
|
|
21
22
|
const rootCarouselClass = `${rootClassName}__carousel`;
|
|
22
23
|
const classes = clsx([styles[rootCarouselClass]], className);
|
|
24
|
+
const internalSliderRef = useRef(null);
|
|
25
|
+
const innerSliderRef = sliderRef || internalSliderRef;
|
|
23
26
|
return /* @__PURE__ */ jsx("div", { ref: forwardRef, className: classes, children: /* @__PURE__ */ jsx(
|
|
24
27
|
Carousel,
|
|
25
28
|
{
|
|
29
|
+
sliderRef: innerSliderRef,
|
|
26
30
|
size: "sm",
|
|
27
31
|
onClickNext,
|
|
28
32
|
onClickPrev,
|
|
@@ -41,8 +41,11 @@ const Carousel = ({
|
|
|
41
41
|
onClick = () => void 0,
|
|
42
42
|
navigationIcon,
|
|
43
43
|
settings,
|
|
44
|
-
size = "lg"
|
|
44
|
+
size = "lg",
|
|
45
|
+
sliderRef
|
|
45
46
|
}) => {
|
|
47
|
+
const internalSliderRef = React.useRef(null);
|
|
48
|
+
const innerSliderRef = sliderRef || internalSliderRef;
|
|
46
49
|
const computedSettings = {
|
|
47
50
|
responsive: [],
|
|
48
51
|
centerMode: false,
|
|
@@ -64,7 +67,7 @@ const Carousel = ({
|
|
|
64
67
|
[styles[`${rootClassName}--${size}`]]: size,
|
|
65
68
|
[className]: className
|
|
66
69
|
}),
|
|
67
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(SliderComponent, { ...computedSettings, children: React.Children.map(filteredChildren, (child) => {
|
|
70
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(SliderComponent, { ref: innerSliderRef, ...computedSettings, children: React.Children.map(filteredChildren, (child) => {
|
|
68
71
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { onClick, className: clsx(styles[`${rootClassName}__item`]), children: child });
|
|
69
72
|
}) })
|
|
70
73
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { Settings } from 'react-slick';
|
|
2
|
+
import { default as Slider, Settings } from 'react-slick';
|
|
3
3
|
import { IconName } from '../icon';
|
|
4
4
|
|
|
5
5
|
export type CarouselProps = {
|
|
@@ -8,6 +8,7 @@ export type CarouselProps = {
|
|
|
8
8
|
navigationIcon?: IconName;
|
|
9
9
|
settings?: Settings;
|
|
10
10
|
size?: 'sm' | 'lg';
|
|
11
|
+
sliderRef?: React.RefObject<Slider>;
|
|
11
12
|
onClickNext?: () => void;
|
|
12
13
|
onClickPrev?: () => void;
|
|
13
14
|
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import React__default from "react";
|
|
2
|
+
import React__default, { useRef } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import Slider from "react-slick";
|
|
5
5
|
import "../../assets/sprite.269ba410-teddy.svg";
|
|
@@ -39,8 +39,11 @@ const Carousel = ({
|
|
|
39
39
|
onClick = () => void 0,
|
|
40
40
|
navigationIcon,
|
|
41
41
|
settings,
|
|
42
|
-
size = "lg"
|
|
42
|
+
size = "lg",
|
|
43
|
+
sliderRef
|
|
43
44
|
}) => {
|
|
45
|
+
const internalSliderRef = useRef(null);
|
|
46
|
+
const innerSliderRef = sliderRef || internalSliderRef;
|
|
44
47
|
const computedSettings = {
|
|
45
48
|
responsive: [],
|
|
46
49
|
centerMode: false,
|
|
@@ -62,7 +65,7 @@ const Carousel = ({
|
|
|
62
65
|
[styles[`${rootClassName}--${size}`]]: size,
|
|
63
66
|
[className]: className
|
|
64
67
|
}),
|
|
65
|
-
children: /* @__PURE__ */ jsx(SliderComponent, { ...computedSettings, children: React__default.Children.map(filteredChildren, (child) => {
|
|
68
|
+
children: /* @__PURE__ */ jsx(SliderComponent, { ref: innerSliderRef, ...computedSettings, children: React__default.Children.map(filteredChildren, (child) => {
|
|
66
69
|
return /* @__PURE__ */ jsx("div", { onClick, className: clsx(styles[`${rootClassName}__item`]), children: child });
|
|
67
70
|
}) })
|
|
68
71
|
}
|