@phillips/seldon 1.139.0 → 1.140.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,64 +1,68 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as x, useState as
|
|
3
|
-
import { getCommonProps as
|
|
4
|
-
import
|
|
5
|
-
import { SupportedLanguages as
|
|
6
|
-
import { CountdownVariants as
|
|
7
|
-
import { Duration as
|
|
8
|
-
import { zhCN as
|
|
9
|
-
import { enUS as
|
|
10
|
-
import { differenceInDays as
|
|
1
|
+
import { jsxs as f, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as x, useState as M, useEffect as j, useMemo as z } from "react";
|
|
3
|
+
import { getCommonProps as P } from "../../utils/index.js";
|
|
4
|
+
import E from "../../node_modules/classnames/index.js";
|
|
5
|
+
import { SupportedLanguages as F } from "../../types/commonTypes.js";
|
|
6
|
+
import { CountdownVariants as c } from "./types.js";
|
|
7
|
+
import { Duration as a } from "./Duration.js";
|
|
8
|
+
import { zhCN as H } from "../../node_modules/date-fns/locale/zh-CN.js";
|
|
9
|
+
import { enUS as R } from "../../node_modules/date-fns/locale/en-US.js";
|
|
10
|
+
import { differenceInDays as d } from "../../node_modules/date-fns/differenceInDays.js";
|
|
11
11
|
import { differenceInHours as p } from "../../node_modules/date-fns/differenceInHours.js";
|
|
12
12
|
import { differenceInMinutes as h } from "../../node_modules/date-fns/differenceInMinutes.js";
|
|
13
13
|
import { differenceInSeconds as w } from "../../node_modules/date-fns/differenceInSeconds.js";
|
|
14
|
-
|
|
14
|
+
import { differenceInMilliseconds as S } from "../../node_modules/date-fns/differenceInMilliseconds.js";
|
|
15
|
+
const U = x(
|
|
15
16
|
({
|
|
16
17
|
endDateTime: o,
|
|
17
|
-
formatDurationStr:
|
|
18
|
-
label:
|
|
18
|
+
formatDurationStr: t,
|
|
19
|
+
label: i = "Lots Close in",
|
|
19
20
|
intervalDescription: C,
|
|
20
|
-
className:
|
|
21
|
-
locale:
|
|
22
|
-
showBottomBorder:
|
|
23
|
-
variant:
|
|
24
|
-
...
|
|
25
|
-
},
|
|
26
|
-
const { className:
|
|
27
|
-
days:
|
|
21
|
+
className: g,
|
|
22
|
+
locale: y = "en",
|
|
23
|
+
showBottomBorder: I = !0,
|
|
24
|
+
variant: m = c.default,
|
|
25
|
+
...u
|
|
26
|
+
}, N) => {
|
|
27
|
+
const { className: r, ...$ } = P(u, "Countdown"), [n, b] = M(/* @__PURE__ */ new Date()), l = y === F.zh ? H : R, s = {
|
|
28
|
+
days: d(o, n) > 0 ? d(o, n) : 0,
|
|
28
29
|
hours: p(o, n) > 0 ? p(o, n) % 24 : 0,
|
|
29
30
|
minutes: h(o, n) > 0 ? h(o, n) % 60 : 0,
|
|
30
31
|
seconds: (w(o, n) > 0 ? w(o, n) % 60 : 0) % 60
|
|
31
32
|
};
|
|
32
|
-
|
|
33
|
+
j(() => {
|
|
33
34
|
const v = setInterval(() => {
|
|
34
35
|
b(/* @__PURE__ */ new Date());
|
|
35
36
|
}, 1e3);
|
|
36
37
|
return () => clearInterval(v);
|
|
37
|
-
}, [o])
|
|
38
|
+
}, [o]);
|
|
39
|
+
const L = z(() => new Date(o).getTime() > (/* @__PURE__ */ new Date()).getTime(), [o]), _ = S(o, n) <= 3 * 60 * 1e3;
|
|
40
|
+
return L ? /* @__PURE__ */ f(
|
|
38
41
|
"div",
|
|
39
42
|
{
|
|
40
|
-
|
|
41
|
-
className:
|
|
42
|
-
[`${
|
|
43
|
-
[`${
|
|
43
|
+
...$,
|
|
44
|
+
className: E(r, g, {
|
|
45
|
+
[`${r}--compact`]: m === c.compact,
|
|
46
|
+
[`${r}--show-bottom-border`]: I,
|
|
47
|
+
[`${r}--closing-lot`]: _
|
|
44
48
|
}),
|
|
45
|
-
...
|
|
46
|
-
ref:
|
|
49
|
+
...u,
|
|
50
|
+
ref: N,
|
|
47
51
|
children: [
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
/* @__PURE__ */ f("div", { className: `${r}__countdown-container`, role: "timer", "aria-label": i, children: [
|
|
53
|
+
/* @__PURE__ */ e("span", { className: `${r}__label`, children: i }),
|
|
54
|
+
s.days > 0 ? /* @__PURE__ */ e(a, { duration: s, unit: "days", locale: l, formatDurationStr: t }) : null,
|
|
55
|
+
s.days > 0 || s.hours > 0 ? /* @__PURE__ */ e(a, { duration: s, unit: "hours", locale: l, formatDurationStr: t }) : null,
|
|
56
|
+
s.days === 0 ? /* @__PURE__ */ e(a, { duration: s, unit: "minutes", locale: l, formatDurationStr: t }) : null,
|
|
57
|
+
s.days === 0 && s.hours === 0 ? /* @__PURE__ */ e(a, { duration: s, unit: "seconds", locale: l, formatDurationStr: t }) : null
|
|
54
58
|
] }),
|
|
55
|
-
|
|
59
|
+
m === c.default ? /* @__PURE__ */ e("span", { children: C }) : null
|
|
56
60
|
]
|
|
57
61
|
}
|
|
58
62
|
) : null;
|
|
59
63
|
}
|
|
60
64
|
);
|
|
61
|
-
|
|
65
|
+
U.displayName = "Countdown";
|
|
62
66
|
export {
|
|
63
|
-
|
|
67
|
+
U as default
|
|
64
68
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CountdownProps } from './Countdown';
|
|
2
|
+
import { CountdownVariants } from './types';
|
|
2
3
|
declare const meta: {
|
|
3
4
|
title: string;
|
|
4
5
|
component: import('react').ForwardRefExoticComponent<Omit<CountdownProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -11,6 +12,10 @@ export declare const Playground: {
|
|
|
11
12
|
type: string;
|
|
12
13
|
options: string[];
|
|
13
14
|
};
|
|
15
|
+
variant: {
|
|
16
|
+
type: string;
|
|
17
|
+
options: CountdownVariants[];
|
|
18
|
+
};
|
|
14
19
|
};
|
|
15
20
|
};
|
|
16
21
|
export declare const Days: (props: CountdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,3 +23,12 @@ export declare const Hours: (props: CountdownProps) => import("react/jsx-runtime
|
|
|
18
23
|
export declare const Minutes: (props: CountdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
24
|
export declare const Seconds: (props: CountdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
25
|
export declare const Compact: (props: CountdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare const ClosingCountdown: {
|
|
27
|
+
(props: CountdownProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
argTypes: {
|
|
29
|
+
variant: {
|
|
30
|
+
type: string;
|
|
31
|
+
options: CountdownVariants[];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -31,8 +31,18 @@
|
|
|
31
31
|
&--compact {
|
|
32
32
|
.#{$px}-countdown__countdown-container {
|
|
33
33
|
@include Montserrat;
|
|
34
|
+
.#{$px}-duration {
|
|
35
|
+
@include Montserrat;
|
|
36
|
+
}
|
|
34
37
|
|
|
35
38
|
gap: $spacing-xsm;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
41
|
+
|
|
42
|
+
&--closing-lot {
|
|
43
|
+
.#{$px}-duration,
|
|
44
|
+
.#{$px}-countdown__label {
|
|
45
|
+
color: $countdown-compact;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
38
48
|
}
|