@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.
@@ -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 ComponentProps<'div'> {
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<Omit<CarouselProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
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 P, forwardRef as I, useEffect as f, useCallback as m } from "react";
3
- import { getCommonProps as E } from "../../utils/index.js";
4
- import y from "../../node_modules/classnames/index.js";
5
- import S from "../../node_modules/embla-carousel-class-names/esm/embla-carousel-class-names.esm.js";
6
- import V from "../../node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js";
7
- import { WheelGesturesPlugin as A } from "../../node_modules/embla-carousel-wheel-gestures/dist/embla-carousel-wheel-gestures.esm.js";
8
- const R = P(null), K = I(
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
- loop: u = !1,
11
- startIndex: d = 0,
10
+ element: d,
11
+ loop: p = !1,
12
+ startIndex: w = 0,
12
13
  onSlideChange: o,
13
- className: p,
14
- children: w,
15
- columnGap: x,
16
- useWheelGestures: N = !1,
17
- disableDrag: i = !1,
18
- disableNavigationDrag: v = null,
19
- inViewThreshold: b = 0.99,
20
- ...n
21
- }, h) => {
22
- const { className: g, ...k } = E(n, "Carousel");
23
- let s = {};
24
- switch (v) {
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
- s = { breakpoints: { "(max-width: 960px)": { watchDrag: !1 } } };
27
+ l = { breakpoints: { "(max-width: 960px)": { watchDrag: !1 } } };
27
28
  break;
28
29
  case "desktop":
29
- s = { breakpoints: { "(min-width: 961px)": { watchDrag: !1 } } };
30
+ l = { breakpoints: { "(min-width: 961px)": { watchDrag: !1 } } };
30
31
  break;
31
32
  case "all":
32
- s = { watchDrag: !1 };
33
+ l = { watchDrag: !1 };
33
34
  break;
34
35
  default:
35
- s = {};
36
+ l = {};
36
37
  }
37
- const [C, e] = V(
38
+ const [S, I] = f(!1), [E, y] = f(!1), [V, e] = G(
38
39
  {
39
- loop: u,
40
- startIndex: d,
41
- inViewThreshold: b,
42
- ...s
40
+ loop: p,
41
+ startIndex: w,
42
+ inViewThreshold: h,
43
+ ...l
43
44
  },
44
45
  [
45
- ...N ? [
46
- A({
46
+ ...C ? [
47
+ L({
47
48
  forceWheelAxis: "x"
48
49
  })
49
50
  ] : [],
50
- S({
51
+ B({
51
52
  snapped: "carousel-item-in-view"
52
53
  })
53
54
  ]
54
55
  );
55
- f(() => {
56
- i ? e?.reInit({
56
+ m(() => {
57
+ n ? e?.reInit({
57
58
  watchDrag: () => !1
58
59
  }) : e?.reInit({
59
60
  watchDrag: () => !0
60
61
  });
61
- }, [i, e]);
62
- const D = m(
63
- (l) => {
64
- if (l.key === "ArrowLeft") {
65
- l.preventDefault(), e?.scrollPrev();
66
- const r = e?.slideNodes().filter((t) => t === document.activeElement)[0]?.previousElementSibling;
67
- r && r?.focus();
68
- } else if (l.key === "ArrowRight") {
69
- l.preventDefault(), e?.scrollNext();
70
- const r = e?.slideNodes().filter((t) => t === document.activeElement)[0]?.nextElementSibling;
71
- r && r?.focus();
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
- ), a = m(
76
- (l) => {
77
- if (!l)
78
- return;
79
- const r = l.slidesInView()?.[0];
80
- r !== void 0 && o?.(r);
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 f(() => {
85
+ return m(() => {
85
86
  if (e)
86
- return e.on("slidesInView", a), () => {
87
- e.off("slidesInView", a);
87
+ return e.on("slidesInView", t), () => {
88
+ e.off("slidesInView", t);
88
89
  };
89
- }, [e, a]), /* @__PURE__ */ c(
90
- R.Provider,
90
+ }, [e, t]), /* @__PURE__ */ c(
91
+ q.Provider,
91
92
  {
92
93
  value: {
93
- carouselRef: C,
94
+ carouselRef: V,
94
95
  api: e,
95
96
  scrollPrev: () => e?.scrollPrev(),
96
97
  scrollNext: () => e?.scrollNext(),
97
- canScrollPrev: e?.canScrollPrev() ?? !1,
98
- canScrollNext: e?.canScrollNext() ?? !1,
99
- columnGap: x,
98
+ canScrollPrev: S,
99
+ canScrollNext: E,
100
+ columnGap: v,
100
101
  onSlideChange: o
101
102
  },
102
103
  children: /* @__PURE__ */ c(
103
- "div",
104
+ k,
104
105
  {
105
- ref: h,
106
- onKeyDownCapture: D,
107
- className: y(g, p),
106
+ ref: g,
107
+ onKeyDownCapture: A,
108
+ className: j(P, x),
108
109
  role: "region",
109
110
  "aria-roledescription": "carousel",
110
- ...n,
111
- ...k,
112
- children: w
111
+ ...i,
112
+ ...D,
113
+ children: N
113
114
  }
114
115
  )
115
116
  }
116
117
  );
117
118
  }
118
119
  );
119
- K.displayName = "Carousel";
120
+ z.displayName = "Carousel";
120
121
  export {
121
- R as CarouselContext,
122
- K as default
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<Omit<CarouselProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
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 type CarouselArrowsProps = ComponentProps<'div'>;
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<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
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 h, jsx as s } from "react/jsx-runtime";
2
- import u from "../../node_modules/classnames/index.js";
3
- import { forwardRef as f, useCallback as n } from "react";
4
- import { getCommonProps as p } from "../../utils/index.js";
5
- import { useCarousel as C } from "./utils.js";
6
- import t from "../Icon/Icon.js";
7
- const v = f(({ className: l, ...i }, a) => {
8
- const { className: r, ...c } = p(i, "CarouselArrows"), { api: e } = C(), m = n(() => {
9
- if (e)
10
- if (e?.slidesInView().length <= 1)
11
- e.scrollPrev(!0);
12
- else {
13
- const o = e?.slidesInView();
14
- e?.scrollTo(Math.max(0, o[0] - (o.length ?? 1)));
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
- }, [e]), d = n(() => {
17
- if (e)
18
- if (e?.slidesInView().length <= 1)
19
- e?.scrollNext(!0);
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
- v as default
66
+ C as default
43
67
  };
@@ -1,5 +1,10 @@
1
- import { ComponentProps } from 'react';
2
- export type CarouselItemProps = ComponentProps<'div'>;
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: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
15
+ declare const CarouselItem: React.ForwardRefExoticComponent<CarouselItemProps & React.RefAttributes<HTMLDivElement>>;
11
16
  export default CarouselItem;
@@ -1,26 +1,28 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import l from "../../node_modules/classnames/index.js";
3
- import { forwardRef as i } from "react";
4
- import { getCommonProps as n } from "../../utils/index.js";
5
- import { useCarousel as c } from "./utils.js";
6
- const u = i(({ className: m, ...o }, s) => {
7
- const { className: r, ...a } = n(o, "CarouselItem"), { columnGap: e } = c();
8
- return /* @__PURE__ */ t(
9
- "div",
10
- {
11
- ref: s,
12
- role: o.onClick ? "button" : "group",
13
- "aria-roledescription": "slide",
14
- className: l(`${r}`, m, {
15
- [`${r}--gap-${e}`]: !!e,
16
- [`${r}--cursor-pointer`]: !!o.onClick
17
- }),
18
- ...o,
19
- ...a
20
- }
21
- );
22
- });
23
- u.displayName = "CarouselItem";
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
- u as default
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
- showSoldPrice?: boolean;
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
- showSoldPrice: j = !0,
33
+ showSoldLabel: j = !0,
34
34
  soldForText: E = "Sold for",
35
35
  wonForText: P = "Won for",
36
36
  getCurrentDateTime: b = () => /* @__PURE__ */ new Date(),
@@ -47,7 +47,7 @@ declare const meta: {
47
47
  startingBidText: {
48
48
  control: "text";
49
49
  };
50
- showSoldPrice: {
50
+ showSoldLabel: {
51
51
  control: "boolean";
52
52
  };
53
53
  soldPrice: {
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillips/seldon",
3
- "version": "1.198.0",
3
+ "version": "1.200.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/PhillipsAuctionHouse/seldon"