@phillips/seldon 1.198.0 → 1.200.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/dist/components/Carousel/Carousel.d.ts +6 -3
- package/dist/components/Carousel/Carousel.js +72 -71
- package/dist/components/Carousel/Carousel.stories.d.ts +1 -1
- package/dist/components/Carousel/CarouselArrows.d.ts +4 -2
- package/dist/components/Carousel/CarouselArrows.js +64 -40
- package/dist/components/Carousel/CarouselItem.d.ts +8 -3
- package/dist/components/Carousel/CarouselItem.js +26 -24
- package/dist/patterns/BidSnapshot/BidSnapshot.d.ts +2 -2
- package/dist/patterns/BidSnapshot/BidSnapshot.js +1 -1
- package/dist/patterns/BidSnapshot/BidSnapshot.stories.d.ts +1 -1
- package/dist/scss/components/Carousel/_carousel.scss +17 -0
- package/package.json +1 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
2
1
|
import { SpacingTokens } from '../../utils';
|
|
3
2
|
import { default as useEmblaCarousel, UseEmblaCarouselType } from 'embla-carousel-react';
|
|
4
3
|
export type CarouselApi = UseEmblaCarouselType[1];
|
|
5
|
-
export interface CarouselProps extends
|
|
4
|
+
export interface CarouselProps extends React.HTMLAttributes<HTMLElement> {
|
|
5
|
+
/**
|
|
6
|
+
* Optional element to render as the top-level component e.g. 'div', 'ul', CustomComponent, etc. Defaults to 'div'.
|
|
7
|
+
*/
|
|
8
|
+
element?: React.ElementType;
|
|
6
9
|
/**
|
|
7
10
|
* Whether the carousel should loop.
|
|
8
11
|
*/
|
|
@@ -60,5 +63,5 @@ export declare const CarouselContext: import('react').Context<CarouselContextPro
|
|
|
60
63
|
*
|
|
61
64
|
* [Storybook Link](https://phillips-seldon.netlify.app/?path=/docs/components-carousel--overview)
|
|
62
65
|
*/
|
|
63
|
-
declare const Carousel: import('react').ForwardRefExoticComponent<
|
|
66
|
+
declare const Carousel: import('react').ForwardRefExoticComponent<CarouselProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
64
67
|
export default Carousel;
|
|
@@ -1,123 +1,124 @@
|
|
|
1
1
|
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { getCommonProps as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { WheelGesturesPlugin as
|
|
8
|
-
const
|
|
2
|
+
import { createContext as R, forwardRef as K, useState as f, useEffect as m, useCallback as u } from "react";
|
|
3
|
+
import { getCommonProps as W } from "../../utils/index.js";
|
|
4
|
+
import j from "../../node_modules/classnames/index.js";
|
|
5
|
+
import B from "../../node_modules/embla-carousel-class-names/esm/embla-carousel-class-names.esm.js";
|
|
6
|
+
import G from "../../node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js";
|
|
7
|
+
import { WheelGesturesPlugin as L } from "../../node_modules/embla-carousel-wheel-gestures/dist/embla-carousel-wheel-gestures.esm.js";
|
|
8
|
+
const q = R(null), z = K(
|
|
9
9
|
({
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
element: d,
|
|
11
|
+
loop: p = !1,
|
|
12
|
+
startIndex: w = 0,
|
|
12
13
|
onSlideChange: o,
|
|
13
|
-
className:
|
|
14
|
-
children:
|
|
15
|
-
columnGap:
|
|
16
|
-
useWheelGestures:
|
|
17
|
-
disableDrag:
|
|
18
|
-
disableNavigationDrag:
|
|
19
|
-
inViewThreshold:
|
|
20
|
-
...
|
|
21
|
-
},
|
|
22
|
-
const { className:
|
|
23
|
-
let
|
|
24
|
-
switch (
|
|
14
|
+
className: x,
|
|
15
|
+
children: N,
|
|
16
|
+
columnGap: v,
|
|
17
|
+
useWheelGestures: C = !1,
|
|
18
|
+
disableDrag: n = !1,
|
|
19
|
+
disableNavigationDrag: b = null,
|
|
20
|
+
inViewThreshold: h = 0.99,
|
|
21
|
+
...i
|
|
22
|
+
}, g) => {
|
|
23
|
+
const k = d || "div", { className: P, ...D } = W(i, "Carousel");
|
|
24
|
+
let l = {};
|
|
25
|
+
switch (b) {
|
|
25
26
|
case "mobile":
|
|
26
|
-
|
|
27
|
+
l = { breakpoints: { "(max-width: 960px)": { watchDrag: !1 } } };
|
|
27
28
|
break;
|
|
28
29
|
case "desktop":
|
|
29
|
-
|
|
30
|
+
l = { breakpoints: { "(min-width: 961px)": { watchDrag: !1 } } };
|
|
30
31
|
break;
|
|
31
32
|
case "all":
|
|
32
|
-
|
|
33
|
+
l = { watchDrag: !1 };
|
|
33
34
|
break;
|
|
34
35
|
default:
|
|
35
|
-
|
|
36
|
+
l = {};
|
|
36
37
|
}
|
|
37
|
-
const [
|
|
38
|
+
const [S, I] = f(!1), [E, y] = f(!1), [V, e] = G(
|
|
38
39
|
{
|
|
39
|
-
loop:
|
|
40
|
-
startIndex:
|
|
41
|
-
inViewThreshold:
|
|
42
|
-
...
|
|
40
|
+
loop: p,
|
|
41
|
+
startIndex: w,
|
|
42
|
+
inViewThreshold: h,
|
|
43
|
+
...l
|
|
43
44
|
},
|
|
44
45
|
[
|
|
45
|
-
...
|
|
46
|
-
|
|
46
|
+
...C ? [
|
|
47
|
+
L({
|
|
47
48
|
forceWheelAxis: "x"
|
|
48
49
|
})
|
|
49
50
|
] : [],
|
|
50
|
-
|
|
51
|
+
B({
|
|
51
52
|
snapped: "carousel-item-in-view"
|
|
52
53
|
})
|
|
53
54
|
]
|
|
54
55
|
);
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
m(() => {
|
|
57
|
+
n ? e?.reInit({
|
|
57
58
|
watchDrag: () => !1
|
|
58
59
|
}) : e?.reInit({
|
|
59
60
|
watchDrag: () => !0
|
|
60
61
|
});
|
|
61
|
-
}, [
|
|
62
|
-
const
|
|
63
|
-
(
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
} else if (
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
62
|
+
}, [n, e]);
|
|
63
|
+
const A = u(
|
|
64
|
+
(r) => {
|
|
65
|
+
if (r.key === "ArrowLeft") {
|
|
66
|
+
r.preventDefault(), e?.scrollPrev();
|
|
67
|
+
const s = e?.slideNodes().filter((a) => a === document.activeElement)[0]?.previousElementSibling;
|
|
68
|
+
s && s?.focus();
|
|
69
|
+
} else if (r.key === "ArrowRight") {
|
|
70
|
+
r.preventDefault(), e?.scrollNext();
|
|
71
|
+
const s = e?.slideNodes().filter((a) => a === document.activeElement)[0]?.nextElementSibling;
|
|
72
|
+
s && s?.focus();
|
|
72
73
|
}
|
|
73
74
|
},
|
|
74
75
|
[e]
|
|
75
|
-
),
|
|
76
|
-
(
|
|
77
|
-
if (!
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
76
|
+
), t = u(
|
|
77
|
+
(r) => {
|
|
78
|
+
if (!r) return;
|
|
79
|
+
I(r?.canScrollPrev()), y(r?.canScrollNext());
|
|
80
|
+
const s = r.slidesInView()?.[0];
|
|
81
|
+
s !== void 0 && o?.(s);
|
|
81
82
|
},
|
|
82
83
|
[o]
|
|
83
84
|
);
|
|
84
|
-
return
|
|
85
|
+
return m(() => {
|
|
85
86
|
if (e)
|
|
86
|
-
return e.on("slidesInView",
|
|
87
|
-
e.off("slidesInView",
|
|
87
|
+
return e.on("slidesInView", t), () => {
|
|
88
|
+
e.off("slidesInView", t);
|
|
88
89
|
};
|
|
89
|
-
}, [e,
|
|
90
|
-
|
|
90
|
+
}, [e, t]), /* @__PURE__ */ c(
|
|
91
|
+
q.Provider,
|
|
91
92
|
{
|
|
92
93
|
value: {
|
|
93
|
-
carouselRef:
|
|
94
|
+
carouselRef: V,
|
|
94
95
|
api: e,
|
|
95
96
|
scrollPrev: () => e?.scrollPrev(),
|
|
96
97
|
scrollNext: () => e?.scrollNext(),
|
|
97
|
-
canScrollPrev:
|
|
98
|
-
canScrollNext:
|
|
99
|
-
columnGap:
|
|
98
|
+
canScrollPrev: S,
|
|
99
|
+
canScrollNext: E,
|
|
100
|
+
columnGap: v,
|
|
100
101
|
onSlideChange: o
|
|
101
102
|
},
|
|
102
103
|
children: /* @__PURE__ */ c(
|
|
103
|
-
|
|
104
|
+
k,
|
|
104
105
|
{
|
|
105
|
-
ref:
|
|
106
|
-
onKeyDownCapture:
|
|
107
|
-
className:
|
|
106
|
+
ref: g,
|
|
107
|
+
onKeyDownCapture: A,
|
|
108
|
+
className: j(P, x),
|
|
108
109
|
role: "region",
|
|
109
110
|
"aria-roledescription": "carousel",
|
|
110
|
-
...
|
|
111
|
-
...
|
|
112
|
-
children:
|
|
111
|
+
...i,
|
|
112
|
+
...D,
|
|
113
|
+
children: N
|
|
113
114
|
}
|
|
114
115
|
)
|
|
115
116
|
}
|
|
116
117
|
);
|
|
117
118
|
}
|
|
118
119
|
);
|
|
119
|
-
|
|
120
|
+
z.displayName = "Carousel";
|
|
120
121
|
export {
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
q as CarouselContext,
|
|
123
|
+
z as default
|
|
123
124
|
};
|
|
@@ -2,7 +2,7 @@ import { CarouselProps } from './Carousel';
|
|
|
2
2
|
import { CarouselDotsProps } from './CarouselDots';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: import('react').ForwardRefExoticComponent<
|
|
5
|
+
component: import('react').ForwardRefExoticComponent<CarouselProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
6
6
|
};
|
|
7
7
|
export default meta;
|
|
8
8
|
export declare const Playground: {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ComponentProps } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export interface CarouselArrowsProps extends ComponentProps<'div'> {
|
|
3
|
+
areArrowsAlwaysVisible?: boolean;
|
|
4
|
+
}
|
|
3
5
|
/**
|
|
4
6
|
* ## Overview
|
|
5
7
|
*
|
|
6
8
|
* Arrow navigation for the carousel.
|
|
7
9
|
*
|
|
8
10
|
*/
|
|
9
|
-
declare const CarouselArrows: import('react').ForwardRefExoticComponent<Omit<
|
|
11
|
+
declare const CarouselArrows: import('react').ForwardRefExoticComponent<Omit<CarouselArrowsProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
10
12
|
export default CarouselArrows;
|
|
@@ -1,43 +1,67 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { getCommonProps as
|
|
5
|
-
import { useCarousel as
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (e
|
|
11
|
-
e
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsxs as b, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import n from "../../node_modules/classnames/index.js";
|
|
3
|
+
import { forwardRef as p, useCallback as l } from "react";
|
|
4
|
+
import { getCommonProps as u } from "../../utils/index.js";
|
|
5
|
+
import { useCarousel as f } from "./utils.js";
|
|
6
|
+
import a from "../Icon/Icon.js";
|
|
7
|
+
const C = p(
|
|
8
|
+
({ className: c, areArrowsAlwaysVisible: i, ...t }, d) => {
|
|
9
|
+
const { className: s, ...m } = u(t, "CarouselArrows"), { api: e } = f(), w = l(() => {
|
|
10
|
+
if (e)
|
|
11
|
+
if (e?.slidesInView().length <= 1)
|
|
12
|
+
e.scrollPrev(!0);
|
|
13
|
+
else {
|
|
14
|
+
const o = e?.slidesInView();
|
|
15
|
+
e?.scrollTo(Math.max(0, o[0] - (o.length ?? 1)));
|
|
16
|
+
}
|
|
17
|
+
}, [e]), h = l(() => {
|
|
18
|
+
if (e)
|
|
19
|
+
if (e?.slidesInView().length <= 1)
|
|
20
|
+
e?.scrollNext(!0);
|
|
21
|
+
else {
|
|
22
|
+
const v = (e?.slidesInView()).slice(-1)[0] + 1;
|
|
23
|
+
e?.scrollTo(v);
|
|
24
|
+
}
|
|
25
|
+
}, [e]);
|
|
26
|
+
return /* @__PURE__ */ b(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
ref: d,
|
|
30
|
+
"aria-roledescription": "carousel-arrow-navigation",
|
|
31
|
+
className: n(`${s}`, c),
|
|
32
|
+
...t,
|
|
33
|
+
...m,
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ r(
|
|
36
|
+
"button",
|
|
37
|
+
{
|
|
38
|
+
"data-testid": "prev-arrow",
|
|
39
|
+
className: n(`${s}-prev-btn`, {
|
|
40
|
+
[`${s}-prev-btn--always-visible`]: i,
|
|
41
|
+
[`${s}-prev-btn--disabled`]: !e?.canScrollPrev()
|
|
42
|
+
}),
|
|
43
|
+
onClick: w,
|
|
44
|
+
children: /* @__PURE__ */ r("div", { className: `${s}-prev-btn__icon`, children: /* @__PURE__ */ r(a, { icon: "ChevronLeft", height: "2rem" }) })
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ r(
|
|
48
|
+
"button",
|
|
49
|
+
{
|
|
50
|
+
"data-testid": "next-arrow",
|
|
51
|
+
className: n(`${s}-next-btn`, {
|
|
52
|
+
[`${s}-next-btn--always-visible`]: i,
|
|
53
|
+
[`${s}-next-btn--disabled`]: !e?.canScrollNext()
|
|
54
|
+
}),
|
|
55
|
+
onClick: h,
|
|
56
|
+
children: /* @__PURE__ */ r("div", { className: `${s}-next-btn__icon`, children: /* @__PURE__ */ r(a, { icon: "ChevronRight", height: "2rem" }) })
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
]
|
|
15
60
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
else {
|
|
21
|
-
const w = (e?.slidesInView()).slice(-1)[0] + 1;
|
|
22
|
-
e?.scrollTo(w);
|
|
23
|
-
}
|
|
24
|
-
}, [e]);
|
|
25
|
-
return /* @__PURE__ */ h(
|
|
26
|
-
"div",
|
|
27
|
-
{
|
|
28
|
-
ref: a,
|
|
29
|
-
"aria-roledescription": "carousel-arrow-navigation",
|
|
30
|
-
className: u(`${r}`, l),
|
|
31
|
-
...i,
|
|
32
|
-
...c,
|
|
33
|
-
children: [
|
|
34
|
-
/* @__PURE__ */ s("button", { "data-testid": "prev-arrow", className: `${r}-prev-btn`, onClick: () => m(), children: /* @__PURE__ */ s("div", { className: `${r}-prev-btn__icon`, children: /* @__PURE__ */ s(t, { icon: "ChevronLeft", height: "2rem" }) }) }),
|
|
35
|
-
/* @__PURE__ */ s("button", { "data-testid": "next-arrow", className: `${r}-next-btn`, onClick: () => d(), children: /* @__PURE__ */ s("div", { className: `${r}-next-btn__icon`, children: /* @__PURE__ */ s(t, { icon: "ChevronRight", height: "2rem" }) }) })
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
v.displayName = "CarouselArrows";
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
C.displayName = "CarouselArrows";
|
|
41
65
|
export {
|
|
42
|
-
|
|
66
|
+
C as default
|
|
43
67
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface CarouselItemProps extends React.HTMLAttributes<HTMLElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Optional element to render as the top-level component e.g. 'div', 'li', CustomComponent, etc. Defaults to 'div'.
|
|
5
|
+
*/
|
|
6
|
+
element?: React.ElementType;
|
|
7
|
+
}
|
|
3
8
|
/**
|
|
4
9
|
* ## Overview
|
|
5
10
|
*
|
|
@@ -7,5 +12,5 @@ export type CarouselItemProps = ComponentProps<'div'>;
|
|
|
7
12
|
* It will stretch to fill the width of the carousel viewport.
|
|
8
13
|
*
|
|
9
14
|
*/
|
|
10
|
-
declare const CarouselItem:
|
|
15
|
+
declare const CarouselItem: React.ForwardRefExoticComponent<CarouselItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
16
|
export default CarouselItem;
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { getCommonProps as
|
|
5
|
-
import { useCarousel as
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import i from "../../node_modules/classnames/index.js";
|
|
3
|
+
import { forwardRef as c } from "react";
|
|
4
|
+
import { getCommonProps as u } from "../../utils/index.js";
|
|
5
|
+
import { useCarousel as p } from "./utils.js";
|
|
6
|
+
const C = c(
|
|
7
|
+
({ element: m, className: s, ...o }, a) => {
|
|
8
|
+
const t = m || "div", { className: e, ...l } = u(o, "CarouselItem"), { columnGap: r } = p();
|
|
9
|
+
return /* @__PURE__ */ n(
|
|
10
|
+
t,
|
|
11
|
+
{
|
|
12
|
+
ref: a,
|
|
13
|
+
role: o.onClick ? "button" : "group",
|
|
14
|
+
"aria-roledescription": "slide",
|
|
15
|
+
className: i(`${e}`, s, {
|
|
16
|
+
[`${e}--gap-${r}`]: !!r,
|
|
17
|
+
[`${e}--cursor-pointer`]: !!o.onClick
|
|
18
|
+
}),
|
|
19
|
+
...o,
|
|
20
|
+
...l
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
C.displayName = "CarouselItem";
|
|
24
26
|
export {
|
|
25
|
-
|
|
27
|
+
C as default
|
|
26
28
|
};
|
|
@@ -59,9 +59,9 @@ export interface BidSnapshotProps extends ComponentProps<'div'> {
|
|
|
59
59
|
*/
|
|
60
60
|
startingBidText?: string;
|
|
61
61
|
/**
|
|
62
|
-
* Determines whether to show or hide sold price
|
|
62
|
+
* Determines whether to show or hide sold label and price
|
|
63
63
|
*/
|
|
64
|
-
|
|
64
|
+
showSoldLabel?: boolean;
|
|
65
65
|
/**
|
|
66
66
|
* Sold For amount
|
|
67
67
|
* */
|
|
@@ -30,7 +30,7 @@ const Y = (o) => o === 1 ? `${o} bid` : `${o} bids`, Z = q(
|
|
|
30
30
|
startingBid: u,
|
|
31
31
|
startingBidText: M = "Starting bid",
|
|
32
32
|
soldPrice: $,
|
|
33
|
-
|
|
33
|
+
showSoldLabel: j = !0,
|
|
34
34
|
soldForText: E = "Sold for",
|
|
35
35
|
wonForText: P = "Won for",
|
|
36
36
|
getCurrentDateTime: b = () => /* @__PURE__ */ new Date(),
|
|
@@ -17,6 +17,23 @@
|
|
|
17
17
|
top: 0;
|
|
18
18
|
width: 33.3%;
|
|
19
19
|
|
|
20
|
+
&--always-visible {
|
|
21
|
+
height: unset;
|
|
22
|
+
opacity: 1;
|
|
23
|
+
top: 50%;
|
|
24
|
+
transform: translateY(-50%);
|
|
25
|
+
width: unset;
|
|
26
|
+
|
|
27
|
+
.#{$px}-carousel-arrows-next-btn__icon,
|
|
28
|
+
.#{$px}-carousel-arrows-prev-btn__icon {
|
|
29
|
+
box-shadow: 0 0 1px $grey-100;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&--disabled {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
20
37
|
&:hover {
|
|
21
38
|
opacity: 1;
|
|
22
39
|
}
|