@phillips/seldon 1.99.0 → 1.100.1

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.
@@ -19,4 +19,11 @@ export declare const CarouselWithDots: {
19
19
  };
20
20
  argTypes: {};
21
21
  };
22
+ export declare const CarouselWithDotsOverflow: {
23
+ (props: CarouselProps & CarouselDotsProps): import("react/jsx-runtime").JSX.Element;
24
+ args: {
25
+ maxDots: number;
26
+ };
27
+ argTypes: {};
28
+ };
22
29
  export declare const ControlledCarousel: (props: CarouselProps & CarouselDotsProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ interface Props {
2
+ /** Whether the dot is selected */
3
+ isSelected: boolean;
4
+ /** Callback function when the dot is clicked */
5
+ onClick: () => void;
6
+ /** Base class name for styling */
7
+ baseClassName: string;
8
+ /** Reference to the scrollable container */
9
+ scrollableContainerRef: React.RefObject<HTMLDivElement>;
10
+ /** Callback function when the dot comes into view within the scrollable container */
11
+ onInViewChange: (inView: boolean) => void;
12
+ /** Variant of the dot */
13
+ variant?: 'sm' | 'md';
14
+ }
15
+ export declare const CarouselDot: ({ isSelected, onClick, baseClassName, scrollableContainerRef, onInViewChange, variant, }: Props) => import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,40 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import r from "../../node_modules/classnames/index.js";
3
+ import { useInView as m } from "../../node_modules/react-intersection-observer/dist/index.js";
4
+ const l = ({
5
+ isSelected: i,
6
+ onClick: e,
7
+ baseClassName: o,
8
+ scrollableContainerRef: c,
9
+ onInViewChange: p,
10
+ variant: t = "md"
11
+ }) => {
12
+ const { ref: d } = m({
13
+ threshold: 0,
14
+ root: c.current,
15
+ onChange(a) {
16
+ p(a);
17
+ }
18
+ });
19
+ return /* @__PURE__ */ n(
20
+ "button",
21
+ {
22
+ ref: d,
23
+ role: "button",
24
+ onClick: e,
25
+ className: r(`${o}-pagination-dot__container`),
26
+ children: /* @__PURE__ */ n(
27
+ "span",
28
+ {
29
+ className: r(`${o}-pagination-dot`, {
30
+ [`${o}-pagination-dot--selected`]: i,
31
+ [`${o}-pagination-dot--${t}`]: t
32
+ })
33
+ }
34
+ )
35
+ }
36
+ );
37
+ };
38
+ export {
39
+ l as CarouselDot
40
+ };
@@ -1,75 +1,92 @@
1
- import { jsx as c } from "react/jsx-runtime";
2
- import d from "../../node_modules/classnames/index.js";
3
- import { forwardRef as D, useId as P, useState as S, useCallback as f, useEffect as V } from "react";
4
- import { useCarousel as _ } from "./utils.js";
5
- import { getCommonProps as j } from "../../utils/index.js";
6
- const w = D(
7
- ({ className: $, maxDots: l = 7, position: h = "inline", numberOfSlides: b = 0, ...u }, N) => {
8
- const { className: s, ...C } = j(u, "Carousel"), M = P(), { api: e, onSlideChange: o } = _(), [g, v] = S(0), [i, k] = S(
9
- Array.from({ length: b }, (t, n) => n)
10
- ), x = f(
11
- (t) => {
12
- e && (e.scrollTo(t, !0), o == null || o(t));
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import B from "../../node_modules/classnames/index.js";
3
+ import { forwardRef as E, useId as L, useState as S, useRef as M, useCallback as a, useEffect as W, useMemo as q } from "react";
4
+ import { useCarousel as z } from "./utils.js";
5
+ import { getCommonProps as A } from "../../utils/index.js";
6
+ import { CarouselDot as F } from "./CarouselDot.js";
7
+ const G = E(
8
+ ({ className: w, maxDots: g = 9, position: N = "inline", numberOfSlides: v = 0, ...h }, V) => {
9
+ const { className: l, ...b } = A(h, "Carousel"), k = L(), { api: o, onSlideChange: n } = z(), [y, R] = S(0), [i, T] = S(
10
+ Array.from({ length: v }, (e, t) => t)
11
+ ), c = M(null), [C, D] = S([]), $ = a((e) => {
12
+ var t, m;
13
+ c.current && ((m = (t = c.current).scrollTo) == null || m.call(t, {
14
+ // 8px width + 12px gap
15
+ left: e * 20 - c.current.offsetWidth / 2 + 10,
16
+ // Center dot in container
17
+ behavior: "smooth"
18
+ }));
19
+ }, []), O = a(
20
+ (e) => {
21
+ o && (o.scrollTo(e, !0), n == null || n(e));
13
22
  },
14
- [e, o]
15
- ), p = f((t) => {
16
- k(t.scrollSnapList());
17
- }, []), a = f((t) => {
18
- v(t.selectedScrollSnap());
19
- }, []), m = f(
20
- (t) => {
21
- o == null || o(t.selectedScrollSnap());
23
+ [o, n]
24
+ ), f = a((e) => {
25
+ T(e.scrollSnapList());
26
+ }, []), s = a(
27
+ (e) => {
28
+ R(e.selectedScrollSnap()), $(e.selectedScrollSnap());
22
29
  },
23
- [o]
30
+ [$]
31
+ ), p = a(
32
+ (e) => {
33
+ n == null || n(e.selectedScrollSnap());
34
+ },
35
+ [n]
24
36
  );
25
- V(() => {
26
- if (e)
27
- return p(e), a(e), e.on("reInit", p).on("reInit", a).on("select", a).on("settle", m), () => {
28
- e.off("reInit", p).off("reInit", a).off("select", a).off("settle", m);
37
+ W(() => {
38
+ if (o)
39
+ return f(o), s(o), o.on("reInit", f).on("reInit", s).on("select", s).on("settle", p), () => {
40
+ o.off("reInit", f).off("reInit", s).off("select", s).off("settle", p);
29
41
  };
30
- }, [e, p, a, m]);
31
- const I = (() => {
32
- if (i.length <= l) return i;
33
- const t = Math.floor(l / 2);
34
- let n = Math.max(0, g - t);
35
- const r = Math.min(i.length, n + l);
36
- return r - n < l && (n = Math.max(0, r - l)), i.slice(n, r);
37
- })();
38
- return /* @__PURE__ */ c(
42
+ }, [o, f, s, p]);
43
+ const r = q(() => C.sort((e, t) => e - t), [C]);
44
+ return /* @__PURE__ */ u(
39
45
  "div",
40
46
  {
41
- ref: N,
47
+ ref: V,
42
48
  role: "group",
43
49
  "aria-roledescription": "pagination",
44
50
  "aria-label": "pagination",
45
- className: d(`${s}-pagination`, $, `${s}-pagination-${h}`),
46
- ...u,
47
- ...C,
48
- children: /* @__PURE__ */ c("div", { className: `${s}-pagination-container`, children: /* @__PURE__ */ c("div", { className: `${s}-pagination-container-inner`, children: I.map((t, n) => {
49
- const r = i.indexOf(I[n]), y = g === r;
50
- return /* @__PURE__ */ c(
51
- "button",
52
- {
53
- role: "button",
54
- onClick: () => x(r),
55
- className: d(`${s}-pagination-dot-container`),
56
- children: /* @__PURE__ */ c(
57
- "span",
51
+ className: B(`${l}-pagination`, w, `${l}-pagination-${N}`),
52
+ ...h,
53
+ ...b,
54
+ children: /* @__PURE__ */ u("div", { className: `${l}-pagination-container`, children: /* @__PURE__ */ u(
55
+ "div",
56
+ {
57
+ style: { "--max-width": `${g * 8 + (g - 1) * 12}px` },
58
+ className: `${l}-pagination-container-inner`,
59
+ ref: c,
60
+ children: i.map((e, t) => {
61
+ const m = y === t, d = r.indexOf(t), P = (
62
+ // The dot is out of view
63
+ d === -1 || // The dot must be either among the first two or last two visible dots
64
+ (d <= 1 || d >= r.length - 2) && // Don't shrink if we're showing the first two dots (index 0,1) and both are visible
65
+ !(t <= 1 && r.includes(0) && r.includes(1)) && // Don't shrink if we're showing the last two dots and both are visible
66
+ !(t >= i.length - 2 && r.includes(i.length - 1) && r.includes(i.length - 2))
67
+ );
68
+ return /* @__PURE__ */ u(
69
+ F,
58
70
  {
59
- className: d(`${s}-pagination-dot`, {
60
- [`${s}-pagination-dot-selected`]: y
61
- })
62
- }
63
- )
64
- },
65
- `${M}-dot-${n}`
66
- );
67
- }) }) })
71
+ onClick: () => O(t),
72
+ isSelected: m,
73
+ baseClassName: l,
74
+ scrollableContainerRef: c,
75
+ onInViewChange: (_) => {
76
+ D(_ ? (I) => [...I, t] : (I) => I.filter((j) => j !== t));
77
+ },
78
+ variant: P ? "sm" : "md"
79
+ },
80
+ `${k}-dot-${t}`
81
+ );
82
+ })
83
+ }
84
+ ) })
68
85
  }
69
86
  );
70
87
  }
71
88
  );
72
- w.displayName = "CarouselDots";
89
+ G.displayName = "CarouselDots";
73
90
  export {
74
- w as default
91
+ G as default
75
92
  };
@@ -4,6 +4,14 @@ export interface PinchZoomProps extends React.HTMLAttributes<HTMLDivElement> {
4
4
  * Function to call when the zoom changes.
5
5
  */
6
6
  onZoomChange?: (isZoomed: boolean) => void;
7
+ /**
8
+ * Function to call when the user is at the left edge.
9
+ */
10
+ onAtLeftEdge?: (isAtLeftEdge: boolean) => void;
11
+ /**
12
+ * Function to call when the user is at the right edge.
13
+ */
14
+ onAtRightEdge?: (isAtRightEdge: boolean) => void;
7
15
  /**
8
16
  * Children to render.
9
17
  */
@@ -12,6 +20,10 @@ export interface PinchZoomProps extends React.HTMLAttributes<HTMLDivElement> {
12
20
  * max zoom level
13
21
  */
14
22
  maxZoom?: number;
23
+ /**
24
+ * Force reset the zoom state.
25
+ */
26
+ isZoomReset?: boolean;
15
27
  }
16
28
  /**
17
29
  * ## Overview
@@ -1,48 +1,66 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import { useState as b, useCallback as n, isValidElement as N, cloneElement as S } from "react";
3
- import { getCommonProps as w } from "../../utils/index.js";
4
- import { TransformWrapper as x, TransformComponent as T } from "../../node_modules/react-zoom-pan-pinch/dist/index.esm.js";
5
- import c from "../../node_modules/classnames/index.js";
6
- const $ = ({ onZoomChange: s, children: e, maxZoom: i = 10, className: f, ...r }) => {
7
- var l;
8
- const { className: t, ...d } = w(r, "PinchZoom"), [a, m] = b(!1), u = n(
9
- (P) => {
10
- const { state: o } = P;
11
- o.scale > 0.99 && o.scale < 1.01 ? (m(!1), s == null || s(!1)) : (m(!0), s == null || s(!0));
1
+ import { jsx as S } from "react/jsx-runtime";
2
+ import { useState as j, useRef as y, useEffect as I, useCallback as V, isValidElement as W, cloneElement as q } from "react";
3
+ import { getCommonProps as v } from "../../utils/index.js";
4
+ import { TransformWrapper as B, TransformComponent as D } from "../../node_modules/react-zoom-pan-pinch/dist/index.esm.js";
5
+ import T from "../../node_modules/classnames/index.js";
6
+ const F = ({
7
+ onZoomChange: s,
8
+ onAtLeftEdge: r,
9
+ onAtRightEdge: e,
10
+ children: a,
11
+ maxZoom: X = 10,
12
+ className: w,
13
+ isZoomReset: p = !1,
14
+ ...f
15
+ }) => {
16
+ var b;
17
+ const { className: l, ...$ } = v(f, "PinchZoom"), [i, m] = j(!1), u = y(null);
18
+ I(() => {
19
+ var t;
20
+ p && ((t = u.current) == null || t.resetTransform(), m(!1), s == null || s(!1));
21
+ }, [p, s]);
22
+ const k = V(
23
+ (t) => {
24
+ var o, N, d, x;
25
+ const { state: c, instance: P } = t;
26
+ c.scale > 0.99 && c.scale < 1.01 ? (m(!1), s == null || s(!1)) : (m(!0), s == null || s(!0));
27
+ const z = Math.abs(c.positionX - ((N = (o = P.bounds) == null ? void 0 : o.maxPositionX) != null ? N : 0)) < 0.01, M = Math.abs(c.positionX - ((x = (d = P.bounds) == null ? void 0 : d.minPositionX) != null ? x : 0)) < 0.01;
28
+ r == null || r(z), e == null || e(M);
12
29
  },
13
- [s]
30
+ [s, r, e]
14
31
  );
15
- return /* @__PURE__ */ p(
16
- x,
32
+ return /* @__PURE__ */ S(
33
+ B,
17
34
  {
18
- maxScale: i,
19
- onTransformed: u,
35
+ maxScale: X,
36
+ onTransformed: k,
20
37
  minScale: 1,
21
38
  disablePadding: !0,
22
39
  doubleClick: {
23
- mode: a ? "reset" : "toggle"
40
+ mode: i ? "reset" : "toggle"
24
41
  },
25
42
  wheel: {
26
43
  smoothStep: 0.01
27
44
  },
28
45
  panning: {
29
- disabled: !a
46
+ disabled: !i
30
47
  },
31
- children: /* @__PURE__ */ p(
32
- T,
48
+ ref: u,
49
+ children: /* @__PURE__ */ S(
50
+ D,
33
51
  {
34
- wrapperProps: { ...d, ...r },
35
- wrapperClass: c(t, f, {
36
- [`${t}-zoomed`]: a
52
+ wrapperProps: { ...$, ...f },
53
+ wrapperClass: T(l, w, {
54
+ [`${l}-zoomed`]: i
37
55
  }),
38
- contentClass: `${t}-content`,
39
- children: N(e) ? S(e, { className: c(`${t}-child`, (l = e == null ? void 0 : e.props) == null ? void 0 : l.className) }) : e
56
+ contentClass: `${l}-content`,
57
+ children: W(a) ? q(a, { className: T(`${l}-child`, (b = a == null ? void 0 : a.props) == null ? void 0 : b.className) }) : a
40
58
  }
41
59
  )
42
60
  }
43
61
  );
44
62
  };
45
- $.displayName = "PinchZoom";
63
+ F.displayName = "PinchZoom";
46
64
  export {
47
- $ as default
65
+ F as default
48
66
  };
@@ -0,0 +1,122 @@
1
+ import * as v from "react";
2
+ var S = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new WeakMap(), E = 0, M = void 0;
3
+ function O(e) {
4
+ return e ? (h.has(e) || (E += 1, h.set(e, E.toString())), h.get(e)) : "0";
5
+ }
6
+ function T(e) {
7
+ return Object.keys(e).sort().filter(
8
+ (t) => e[t] !== void 0
9
+ ).map((t) => `${t}_${t === "root" ? O(e.root) : e[t]}`).toString();
10
+ }
11
+ function _(e) {
12
+ const t = T(e);
13
+ let n = S.get(t);
14
+ if (!n) {
15
+ const u = /* @__PURE__ */ new Map();
16
+ let c;
17
+ const i = new IntersectionObserver((s) => {
18
+ s.forEach((r) => {
19
+ var o;
20
+ const g = r.isIntersecting && c.some((d) => r.intersectionRatio >= d);
21
+ e.trackVisibility && typeof r.isVisible == "undefined" && (r.isVisible = g), (o = u.get(r.target)) == null || o.forEach((d) => {
22
+ d(g, r);
23
+ });
24
+ });
25
+ }, e);
26
+ c = i.thresholds || (Array.isArray(e.threshold) ? e.threshold : [e.threshold || 0]), n = {
27
+ id: t,
28
+ observer: i,
29
+ elements: u
30
+ }, S.set(t, n);
31
+ }
32
+ return n;
33
+ }
34
+ function x(e, t, n = {}, u = M) {
35
+ if (typeof window.IntersectionObserver == "undefined" && u !== void 0) {
36
+ const o = e.getBoundingClientRect();
37
+ return t(u, {
38
+ isIntersecting: u,
39
+ target: e,
40
+ intersectionRatio: typeof n.threshold == "number" ? n.threshold : 0,
41
+ time: 0,
42
+ boundingClientRect: o,
43
+ intersectionRect: o,
44
+ rootBounds: o
45
+ }), () => {
46
+ };
47
+ }
48
+ const { id: c, observer: i, elements: s } = _(n), r = s.get(e) || [];
49
+ return s.has(e) || s.set(e, r), r.push(t), i.observe(e), function() {
50
+ r.splice(r.indexOf(t), 1), r.length === 0 && (s.delete(e), i.unobserve(e)), s.size === 0 && (i.disconnect(), S.delete(c));
51
+ };
52
+ }
53
+ function B({
54
+ threshold: e,
55
+ delay: t,
56
+ trackVisibility: n,
57
+ rootMargin: u,
58
+ root: c,
59
+ triggerOnce: i,
60
+ skip: s,
61
+ initialInView: r,
62
+ fallbackInView: o,
63
+ onChange: g
64
+ } = {}) {
65
+ var d;
66
+ const [b, V] = v.useState(null), l = v.useRef(), [R, y] = v.useState({
67
+ inView: !!r,
68
+ entry: void 0
69
+ });
70
+ l.current = g, v.useEffect(
71
+ () => {
72
+ if (s || !b) return;
73
+ let a;
74
+ return a = x(
75
+ b,
76
+ (A, I) => {
77
+ y({
78
+ inView: A,
79
+ entry: I
80
+ }), l.current && l.current(A, I), I.isIntersecting && i && a && (a(), a = void 0);
81
+ },
82
+ {
83
+ root: c,
84
+ rootMargin: u,
85
+ threshold: e,
86
+ // @ts-ignore
87
+ trackVisibility: n,
88
+ // @ts-ignore
89
+ delay: t
90
+ },
91
+ o
92
+ ), () => {
93
+ a && a();
94
+ };
95
+ },
96
+ // We break the rule here, because we aren't including the actual `threshold` variable
97
+ // eslint-disable-next-line react-hooks/exhaustive-deps
98
+ [
99
+ // If the threshold is an array, convert it to a string, so it won't change between renders.
100
+ Array.isArray(e) ? e.toString() : e,
101
+ b,
102
+ c,
103
+ u,
104
+ i,
105
+ s,
106
+ n,
107
+ o,
108
+ t
109
+ ]
110
+ );
111
+ const w = (d = R.entry) == null ? void 0 : d.target, p = v.useRef();
112
+ !b && w && !i && !s && p.current !== w && (p.current = w, y({
113
+ inView: !!r,
114
+ entry: void 0
115
+ }));
116
+ const f = [V, R.inView, R.entry];
117
+ return f.ref = f[0], f.inView = f[1], f.entry = f[2], f;
118
+ }
119
+ export {
120
+ x as observe,
121
+ B as useInView
122
+ };
@@ -60,26 +60,47 @@
60
60
  }
61
61
 
62
62
  &-container-inner {
63
+ align-items: center;
63
64
  display: flex;
64
65
  gap: 12px;
66
+ max-width: var(--max-width);
67
+ overflow: auto;
68
+ -webkit-overflow-scrolling: touch;
69
+ -ms-overflow-style: none; /* Internet Explorer 10+ */
70
+ scroll-snap-type: x mandatory;
71
+ scrollbar-width: none; /* Firefox */
72
+
73
+ &::-webkit-scrollbar {
74
+ display: none; /* Safari and Chrome */
75
+ }
65
76
  }
66
77
 
67
- &-dot-container {
78
+ &-dot__container {
68
79
  align-items: center;
69
80
  display: flex;
70
81
  height: 8px;
71
82
  justify-content: center;
83
+ min-width: 8px;
72
84
  padding: 1px;
85
+ scroll-snap-align: center;
73
86
  width: 8px;
74
87
  }
75
88
 
76
89
  &-dot {
77
90
  border-radius: 50%;
78
- height: 100%;
79
91
  outline: 1px solid #adadad;
80
- width: 100%;
81
92
 
82
- &-selected {
93
+ &--md {
94
+ height: 100%;
95
+ width: 100%;
96
+ }
97
+
98
+ &--sm {
99
+ height: 50%;
100
+ width: 50%;
101
+ }
102
+
103
+ &--selected {
83
104
  background-color: #525050;
84
105
  outline-color: #525050;
85
106
  }
@@ -23,7 +23,8 @@
23
23
  padding: $spacing-md 0;
24
24
 
25
25
  &__mobile-countdown {
26
- display: block;
26
+ display: flex;
27
+ width: 100%;
27
28
 
28
29
  @include media($size-md, $type: 'min') {
29
30
  display: none;
@@ -32,9 +33,10 @@
32
33
 
33
34
  &__desktop-countdown {
34
35
  display: none;
36
+ width: 100%;
35
37
 
36
38
  @include media($size-md, $type: 'min') {
37
- display: block;
39
+ display: flex;
38
40
  }
39
41
  }
40
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillips/seldon",
3
- "version": "1.99.0",
3
+ "version": "1.100.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/PhillipsAuctionHouse/seldon"
@@ -55,6 +55,7 @@
55
55
  "embla-carousel-wheel-gestures": "^8.0.1",
56
56
  "flatpickr": "^4.6.13",
57
57
  "html-react-parser": "^5.1.12",
58
+ "react-intersection-observer": "^9.13.1",
58
59
  "react-modal": "^3.16.1",
59
60
  "react-transition-group": "^4.4.5",
60
61
  "react-zoom-pan-pinch": "^3.6.1",