@telefonica/mistica 16.1.0 → 16.2.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/css/mistica.css +1 -1
- package/dist/accordion.css-mistica.js +12 -9
- package/dist/accordion.css.d.ts +1 -0
- package/dist/accordion.js +36 -39
- package/dist/align.css-mistica.js +12 -0
- package/dist/align.css.d.ts +1 -0
- package/dist/align.css.ts.vanilla.css-mistica.js +11 -0
- package/dist/align.d.ts +12 -0
- package/dist/align.js +79 -0
- package/dist/box.css-mistica.js +41 -0
- package/dist/box.css.d.ts +23 -0
- package/dist/box.css.ts.vanilla.css-mistica.js +11 -0
- package/dist/box.d.ts +4 -0
- package/dist/box.js +39 -31
- package/dist/boxed.css-mistica.js +10 -5
- package/dist/boxed.css.d.ts +3 -0
- package/dist/boxed.js +20 -24
- package/dist/callout.css-mistica.js +12 -4
- package/dist/callout.css.d.ts +1 -0
- package/dist/callout.js +14 -22
- package/dist/card.css-mistica.js +26 -23
- package/dist/card.css.d.ts +1 -0
- package/dist/card.js +17 -23
- package/dist/community/advanced-data-card.css-mistica.js +32 -23
- package/dist/community/advanced-data-card.css.d.ts +3 -0
- package/dist/community/advanced-data-card.js +46 -55
- package/dist/empty-state.css-mistica.js +11 -8
- package/dist/empty-state.css.d.ts +1 -0
- package/dist/empty-state.js +10 -13
- package/dist/form.css-mistica.js +12 -0
- package/dist/form.css.d.ts +1 -0
- package/dist/form.js +8 -10
- package/dist/grid.css-mistica.js +143 -126
- package/dist/grid.css.d.ts +13 -0
- package/dist/grid.js +35 -38
- package/dist/hero.css-mistica.js +14 -8
- package/dist/hero.css.d.ts +2 -0
- package/dist/hero.js +17 -25
- package/dist/image.js +23 -25
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/inline.js +10 -11
- package/dist/list.css-mistica.js +12 -9
- package/dist/list.css.d.ts +1 -0
- package/dist/list.js +43 -46
- package/dist/loading-screen.js +16 -16
- package/dist/logo-blau.d.ts +1 -1
- package/dist/logo-blau.js +10 -10
- package/dist/logo-common.d.ts +1 -0
- package/dist/logo-movistar.d.ts +1 -1
- package/dist/logo-movistar.js +4 -4
- package/dist/logo-o2-new.d.ts +1 -1
- package/dist/logo-o2-new.js +5 -5
- package/dist/logo-o2.d.ts +1 -1
- package/dist/logo-o2.js +5 -5
- package/dist/logo-telefonica.d.ts +1 -1
- package/dist/logo-telefonica.js +4 -4
- package/dist/logo-tu.d.ts +1 -1
- package/dist/logo-tu.js +5 -5
- package/dist/logo-vivo.d.ts +1 -1
- package/dist/logo-vivo.js +7 -7
- package/dist/logo.d.ts +9 -8
- package/dist/logo.js +125 -102
- package/dist/navigation-bar.css-mistica.js +23 -20
- package/dist/navigation-bar.css.d.ts +1 -0
- package/dist/navigation-bar.js +30 -37
- package/dist/package-version.js +1 -1
- package/dist/phone-number-field.d.ts +1 -4
- package/dist/phone-number-field.js +52 -82
- package/dist/popover.d.ts +1 -0
- package/dist/popover.js +9 -10
- package/dist/sheet-common.css-mistica.js +5 -5
- package/dist/skeleton-base.js +10 -12
- package/dist/skeletons.css-mistica.js +11 -5
- package/dist/skeletons.css.d.ts +1 -0
- package/dist/snackbar.css-mistica.js +20 -14
- package/dist/snackbar.css.d.ts +3 -1
- package/dist/snackbar.js +65 -75
- package/dist/tag.css-mistica.js +15 -4
- package/dist/tag.css.d.ts +2 -0
- package/dist/tag.js +20 -24
- package/dist/text-field-base.d.ts +1 -1
- package/dist/text-field-components.css-mistica.js +16 -10
- package/dist/text-field-components.css.d.ts +1 -0
- package/dist/text-field-components.js +32 -35
- package/dist/timer.js +42 -43
- package/dist/tooltip.d.ts +3 -1
- package/dist/tooltip.js +106 -106
- package/dist/touchable.js +47 -42
- package/dist-es/accordion.css-mistica.js +3 -3
- package/dist-es/accordion.js +58 -61
- package/dist-es/align.css-mistica.js +3 -0
- package/dist-es/align.css.ts.vanilla.css-mistica.js +2 -0
- package/dist-es/align.js +70 -0
- package/dist-es/box.css-mistica.js +24 -0
- package/dist-es/box.css.ts.vanilla.css-mistica.js +2 -0
- package/dist-es/box.js +43 -35
- package/dist-es/boxed.css-mistica.js +5 -3
- package/dist-es/boxed.js +28 -32
- package/dist-es/callout.css-mistica.js +7 -2
- package/dist-es/callout.js +44 -52
- package/dist-es/card.css-mistica.js +4 -4
- package/dist-es/card.js +11 -17
- package/dist-es/community/advanced-data-card.css-mistica.js +7 -7
- package/dist-es/community/advanced-data-card.js +90 -99
- package/dist-es/empty-state.css-mistica.js +3 -3
- package/dist-es/empty-state.js +19 -22
- package/dist-es/form.css-mistica.js +3 -0
- package/dist-es/form.js +12 -14
- package/dist-es/grid.css-mistica.js +123 -112
- package/dist-es/grid.js +38 -41
- package/dist-es/hero.css-mistica.js +2 -2
- package/dist-es/hero.js +36 -44
- package/dist-es/image.js +28 -30
- package/dist-es/index.js +1844 -1843
- package/dist-es/inline.js +19 -20
- package/dist-es/list.css-mistica.js +2 -2
- package/dist-es/list.js +75 -78
- package/dist-es/loading-screen.js +30 -30
- package/dist-es/logo-blau.js +11 -11
- package/dist-es/logo-movistar.js +5 -5
- package/dist-es/logo-o2-new.js +8 -8
- package/dist-es/logo-o2.js +8 -8
- package/dist-es/logo-telefonica.js +4 -4
- package/dist-es/logo-tu.js +8 -8
- package/dist-es/logo-vivo.js +16 -16
- package/dist-es/logo.js +132 -109
- package/dist-es/navigation-bar.css-mistica.js +11 -11
- package/dist-es/navigation-bar.js +80 -87
- package/dist-es/package-version.js +1 -1
- package/dist-es/phone-number-field.js +59 -89
- package/dist-es/popover.js +17 -18
- package/dist-es/sheet-common.css-mistica.js +2 -2
- package/dist-es/skeleton-base.js +15 -17
- package/dist-es/skeletons.css-mistica.js +5 -2
- package/dist-es/snackbar.css-mistica.js +4 -4
- package/dist-es/snackbar.js +93 -103
- package/dist-es/style.css +1 -1
- package/dist-es/tag.css-mistica.js +2 -2
- package/dist-es/tag.js +34 -38
- package/dist-es/text-field-components.css-mistica.js +5 -2
- package/dist-es/text-field-components.js +48 -51
- package/dist-es/timer.js +80 -81
- package/dist-es/tooltip.js +148 -148
- package/dist-es/touchable.js +55 -50
- package/package.json +1 -1
- package/dist/sprinkles.css-mistica.js +0 -2494
- package/dist-es/sprinkles.css-mistica.js +0 -2485
package/dist-es/tag.js
CHANGED
|
@@ -51,22 +51,21 @@ function _object_spread_props(target, source) {
|
|
|
51
51
|
}
|
|
52
52
|
return target;
|
|
53
53
|
}
|
|
54
|
-
import { jsxs as
|
|
54
|
+
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
|
55
55
|
import g from "./box.js";
|
|
56
|
-
import { Text as
|
|
57
|
-
import { useThemeVariant as T, ThemeVariant as
|
|
58
|
-
import { pxToRem as
|
|
59
|
-
import { getPrefixedDataAttributes as
|
|
60
|
-
import { tag as B } from "./tag.css-mistica.js";
|
|
61
|
-
import {
|
|
62
|
-
import
|
|
63
|
-
import
|
|
64
|
-
import
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!i) return null;
|
|
56
|
+
import { Text as f } from "./text.js";
|
|
57
|
+
import { useThemeVariant as T, ThemeVariant as x } from "./theme-variant-context.js";
|
|
58
|
+
import { pxToRem as h } from "./utils/css.js";
|
|
59
|
+
import { getPrefixedDataAttributes as v } from "./utils/dom.js";
|
|
60
|
+
import { tag as k, icon as B, badge as b } from "./tag.css-mistica.js";
|
|
61
|
+
import { vars as w } from "./skins/skin-contract.css-mistica.js";
|
|
62
|
+
import A from "classnames";
|
|
63
|
+
import { useTheme as P } from "./hooks.js";
|
|
64
|
+
import V from "./badge.js";
|
|
65
|
+
const { colors: t } = w, C = (param)=>{
|
|
66
|
+
let { Icon: e, children: o, dataAttributes: c, type: m = "promo", badge: i } = param;
|
|
67
|
+
const { textPresets: d } = P(), l = T(), a = i === !0 ? void 0 : i || 0;
|
|
68
|
+
if (!o) return null;
|
|
70
69
|
const u = {
|
|
71
70
|
// [textColor, backgroundColor]
|
|
72
71
|
promo: [
|
|
@@ -80,7 +79,7 @@ const { colors: t } = b, V = (param)=>{
|
|
|
80
79
|
inactive: [
|
|
81
80
|
t.tagTextInactive,
|
|
82
81
|
// TODO: remove logic for alternative variant (https://jira.tid.es/browse/WEB-1803)
|
|
83
|
-
|
|
82
|
+
l === "alternative" ? t.neutralLowAlternative : t.tagBackgroundInactive
|
|
84
83
|
],
|
|
85
84
|
success: [
|
|
86
85
|
t.tagTextSuccess,
|
|
@@ -94,47 +93,44 @@ const { colors: t } = b, V = (param)=>{
|
|
|
94
93
|
t.tagTextError,
|
|
95
94
|
t.tagBackgroundError
|
|
96
95
|
]
|
|
97
|
-
}, [
|
|
98
|
-
return /* @__PURE__ */
|
|
99
|
-
className:
|
|
96
|
+
}, [n, p] = u[m];
|
|
97
|
+
return /* @__PURE__ */ s("span", _object_spread_props(_object_spread({}, v(c, "Tag")), {
|
|
98
|
+
className: A(k),
|
|
99
|
+
style: {
|
|
100
100
|
paddingLeft: e ? 8 : 12,
|
|
101
|
-
paddingRight:
|
|
102
|
-
background:
|
|
103
|
-
}
|
|
101
|
+
paddingRight: a !== 0 ? 8 : 12,
|
|
102
|
+
background: p
|
|
103
|
+
},
|
|
104
104
|
children: [
|
|
105
105
|
e && /* @__PURE__ */ r(g, {
|
|
106
106
|
paddingRight: 4,
|
|
107
107
|
children: /* @__PURE__ */ r(e, {
|
|
108
|
-
color:
|
|
109
|
-
size:
|
|
110
|
-
className:
|
|
111
|
-
display: "block"
|
|
112
|
-
})
|
|
108
|
+
color: n,
|
|
109
|
+
size: h(16),
|
|
110
|
+
className: B
|
|
113
111
|
})
|
|
114
112
|
}),
|
|
115
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ s(x, {
|
|
116
114
|
isInverse: !1,
|
|
117
115
|
children: [
|
|
118
|
-
/* @__PURE__ */ r(
|
|
119
|
-
color:
|
|
116
|
+
/* @__PURE__ */ r(f, {
|
|
117
|
+
color: n,
|
|
120
118
|
size: 14,
|
|
121
119
|
lineHeight: 20,
|
|
122
120
|
weight: d.indicator.weight,
|
|
123
121
|
truncate: !0,
|
|
124
|
-
children:
|
|
122
|
+
children: o
|
|
125
123
|
}),
|
|
126
|
-
|
|
124
|
+
a !== 0 && /* @__PURE__ */ r(g, {
|
|
127
125
|
paddingLeft: 4,
|
|
128
|
-
className:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
children: /* @__PURE__ */ r(P, {
|
|
132
|
-
value: o
|
|
126
|
+
className: b,
|
|
127
|
+
children: /* @__PURE__ */ r(V, {
|
|
128
|
+
value: a
|
|
133
129
|
})
|
|
134
130
|
})
|
|
135
131
|
]
|
|
136
132
|
})
|
|
137
133
|
]
|
|
138
134
|
}));
|
|
139
|
-
}, I =
|
|
135
|
+
}, I = C;
|
|
140
136
|
export { I as default };
|
|
@@ -2,5 +2,8 @@ import "./sprinkles.css.ts.vanilla.css-mistica.js";
|
|
|
2
2
|
import "./icon-button.css.ts.vanilla.css-mistica.js";
|
|
3
3
|
import "./text-field-base.css.ts.vanilla.css-mistica.js";
|
|
4
4
|
import "./text-field-components.css.ts.vanilla.css-mistica.js";
|
|
5
|
-
var a = 328, f = 0.78, e = 0.75, y =
|
|
6
|
-
|
|
5
|
+
var a = 328, f = 0.78, e = 0.75, y = {
|
|
6
|
+
default: "_1y2v1nf3q",
|
|
7
|
+
readOnly: "_1y2v1nf5k"
|
|
8
|
+
}, k = "_15k6ur97", l = "_1y2v1nfkl _1y2v1nfk1 _1y2v1nfhk _1y2v1nfka _1y2v1nfhe", i = "_15k6ur96 _1y2v1nfhk _1y2v1nfhq", t = "_1y2v1nfi7", h = "_1y2v1nfa7 _1y2v1nfbj _1y2v1nfhk", o = "_1y2v1nfi5 _1y2v1nf7j", u = "_15k6ur91 _1y2v1nfhf _1y2v1nfhk _1y2v1nfhp", d = "_15k6ur93 _1y2v1nfkl _1y2v1nfi3", p = "_15k6ur9e _1y2v1nfhk", L = "_15k6ur99 _1y2v1nfi7", E = "_15k6ur94", T = "_15k6ur9g";
|
|
9
|
+
export { a as DEFAULT_WIDTH, f as LABEL_SCALE_DESKTOP, e as LABEL_SCALE_MOBILE, y as background, k as disabled, l as field, i as fieldContainer, t as fullWidth, h as helperContainer, o as helperText, u as labelContainer, d as labelText, p as leftHelperText, L as normalWidth, E as shrinked, T as warnIcon };
|
|
@@ -51,81 +51,80 @@ function _object_spread_props(target, source) {
|
|
|
51
51
|
}
|
|
52
52
|
return target;
|
|
53
53
|
}
|
|
54
|
-
import { jsxs as c, jsx as
|
|
54
|
+
import { jsxs as c, jsx as r, Fragment as C } from "react/jsx-runtime";
|
|
55
55
|
import * as g from "react";
|
|
56
56
|
import m from "classnames";
|
|
57
57
|
import { useIsInverseOrMediaVariant as I } from "./theme-variant-context.js";
|
|
58
58
|
import { useTheme as S } from "./hooks.js";
|
|
59
59
|
import { Text1 as x } from "./text.js";
|
|
60
|
-
import { labelContainer as T, shrinked as
|
|
61
|
-
import {
|
|
62
|
-
import { vars as r } from "./skins/skin-contract.css-mistica.js";
|
|
60
|
+
import { labelContainer as T, shrinked as E, labelText as F, helperText as v, leftHelperText as O, warnIcon as k, fieldContainer as W, fullWidth as A, normalWidth as L, disabled as P, field as j, background as b, helperContainer as w } from "./text-field-components.css-mistica.js";
|
|
61
|
+
import { vars as t } from "./skins/skin-contract.css-mistica.js";
|
|
63
62
|
import { getPrefixedDataAttributes as D } from "./utils/dom.js";
|
|
64
63
|
import { formFieldOptionalLabelSuffix as H } from "./text-tokens.js";
|
|
65
64
|
import R from "./generated/mistica-icons/icon-warning-regular.js";
|
|
66
|
-
const
|
|
67
|
-
let { shrinkLabel:
|
|
68
|
-
const f =
|
|
65
|
+
const U = (param)=>{
|
|
66
|
+
let { shrinkLabel: o, forId: l, inputState: e, error: s, children: i, style: a, optional: n } = param;
|
|
67
|
+
const f = o || e === "focused" || e === "filled", [u, h] = g.useState("initial"), { texts: d, t: y } = S();
|
|
69
68
|
g.useEffect(()=>{
|
|
70
|
-
const
|
|
71
|
-
process.env.NODE_ENV !== "test" &&
|
|
69
|
+
const N = setTimeout(()=>{
|
|
70
|
+
process.env.NODE_ENV !== "test" && h("transform 150ms, width 150ms");
|
|
72
71
|
});
|
|
73
72
|
return ()=>{
|
|
74
|
-
clearTimeout(
|
|
73
|
+
clearTimeout(N);
|
|
75
74
|
};
|
|
76
75
|
}, []);
|
|
77
|
-
let
|
|
78
|
-
return s && e !== "default" ?
|
|
76
|
+
let p = t.colors.textSecondary;
|
|
77
|
+
return s && e !== "default" ? p = t.colors.textError : e === "focused" && (p = t.colors.textActivated), /* @__PURE__ */ c("label", {
|
|
79
78
|
className: m(T, {
|
|
80
|
-
[
|
|
81
|
-
},
|
|
82
|
-
color: h
|
|
83
|
-
})),
|
|
79
|
+
[E]: f
|
|
80
|
+
}),
|
|
84
81
|
htmlFor: l,
|
|
85
|
-
style: _object_spread_props(_object_spread({
|
|
82
|
+
style: _object_spread_props(_object_spread({
|
|
83
|
+
color: p
|
|
84
|
+
}, a), {
|
|
86
85
|
transition: u
|
|
87
86
|
}),
|
|
88
87
|
children: [
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
className:
|
|
88
|
+
/* @__PURE__ */ r("span", {
|
|
89
|
+
className: F,
|
|
91
90
|
children: i
|
|
92
91
|
}),
|
|
93
|
-
|
|
92
|
+
n ? /* @__PURE__ */ c("span", {
|
|
94
93
|
children: [
|
|
95
94
|
"\xa0(",
|
|
96
|
-
d.formFieldOptionalLabelSuffix ||
|
|
95
|
+
d.formFieldOptionalLabelSuffix || y(H),
|
|
97
96
|
")"
|
|
98
97
|
]
|
|
99
98
|
}) : null
|
|
100
99
|
]
|
|
101
100
|
});
|
|
102
|
-
},
|
|
103
|
-
let { leftText:
|
|
104
|
-
const i = I(),
|
|
101
|
+
}, X = (param)=>{
|
|
102
|
+
let { leftText: o, rightText: l, error: e, id: s } = param;
|
|
103
|
+
const i = I(), a = i ? t.colors.textPrimaryInverse : e ? t.colors.textError : t.colors.textSecondary, n = i ? t.colors.textPrimaryInverse : t.colors.textSecondary;
|
|
105
104
|
return /* @__PURE__ */ c(C, {
|
|
106
105
|
children: [
|
|
107
|
-
|
|
108
|
-
className: m(
|
|
106
|
+
o && /* @__PURE__ */ c("p", {
|
|
107
|
+
className: m(v, O),
|
|
109
108
|
children: [
|
|
110
|
-
e && /* @__PURE__ */
|
|
109
|
+
e && /* @__PURE__ */ r(x, {
|
|
111
110
|
regular: !0,
|
|
112
|
-
children: /* @__PURE__ */
|
|
113
|
-
color:
|
|
114
|
-
className:
|
|
111
|
+
children: /* @__PURE__ */ r(R, {
|
|
112
|
+
color: a,
|
|
113
|
+
className: k
|
|
115
114
|
})
|
|
116
115
|
}),
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
color:
|
|
116
|
+
/* @__PURE__ */ r(x, {
|
|
117
|
+
color: a,
|
|
119
118
|
regular: !0,
|
|
120
119
|
id: s,
|
|
121
|
-
children:
|
|
120
|
+
children: o
|
|
122
121
|
})
|
|
123
122
|
]
|
|
124
123
|
}),
|
|
125
|
-
l && /* @__PURE__ */
|
|
126
|
-
className: m(
|
|
127
|
-
children: /* @__PURE__ */
|
|
128
|
-
color:
|
|
124
|
+
l && /* @__PURE__ */ r("div", {
|
|
125
|
+
className: m(v),
|
|
126
|
+
children: /* @__PURE__ */ r(x, {
|
|
127
|
+
color: n,
|
|
129
128
|
regular: !0,
|
|
130
129
|
as: "p",
|
|
131
130
|
textAlign: "right",
|
|
@@ -134,31 +133,29 @@ const X = (param)=>{
|
|
|
134
133
|
})
|
|
135
134
|
]
|
|
136
135
|
});
|
|
137
|
-
},
|
|
138
|
-
let { multiline:
|
|
136
|
+
}, Y = (param)=>{
|
|
137
|
+
let { multiline: o, disabled: l, children: e, helperText: s, className: i, fieldRef: a, fullWidth: n, readOnly: f, dataAttributes: u } = param;
|
|
139
138
|
return(// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
140
139
|
/* @__PURE__ */ c("div", _object_spread_props(_object_spread({
|
|
141
|
-
className: m(
|
|
142
|
-
[
|
|
140
|
+
className: m(W, n ? A : L, {
|
|
141
|
+
[P]: l
|
|
143
142
|
}),
|
|
144
|
-
onClick: (
|
|
143
|
+
onClick: (h)=>{
|
|
145
144
|
var d;
|
|
146
|
-
(d =
|
|
145
|
+
(d = h.currentTarget.querySelector(o ? "textarea" : "input")) == null || d.focus();
|
|
147
146
|
}
|
|
148
147
|
}, D(u)), {
|
|
149
148
|
children: [
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
className: m(
|
|
152
|
-
|
|
153
|
-
}), i),
|
|
154
|
-
ref: n,
|
|
149
|
+
/* @__PURE__ */ r("div", {
|
|
150
|
+
className: m(j, f ? b.readOnly : b.default, i),
|
|
151
|
+
ref: a,
|
|
155
152
|
children: e
|
|
156
153
|
}),
|
|
157
|
-
s && /* @__PURE__ */
|
|
158
|
-
className:
|
|
154
|
+
s && /* @__PURE__ */ r("div", {
|
|
155
|
+
className: w,
|
|
159
156
|
children: s
|
|
160
157
|
})
|
|
161
158
|
]
|
|
162
159
|
})));
|
|
163
160
|
};
|
|
164
|
-
export {
|
|
161
|
+
export { Y as FieldContainer, X as HelperText, U as Label };
|
package/dist-es/timer.js
CHANGED
|
@@ -52,20 +52,19 @@ function _object_spread_props(target, source) {
|
|
|
52
52
|
return target;
|
|
53
53
|
}
|
|
54
54
|
import { jsxs as v, jsx as m } from "react/jsx-runtime";
|
|
55
|
-
import
|
|
56
|
-
import * as
|
|
57
|
-
import ee from "./
|
|
58
|
-
import
|
|
59
|
-
import re from "./inline.js";
|
|
55
|
+
import F from "classnames";
|
|
56
|
+
import * as f from "react";
|
|
57
|
+
import { useTheme as k, useIsomorphicLayoutEffect as ee } from "./hooks.js";
|
|
58
|
+
import te from "./inline.js";
|
|
60
59
|
import q from "./screen-reader-only.js";
|
|
61
|
-
import { Text2 as ne, Text6 as
|
|
62
|
-
import { useThemeVariant as
|
|
63
|
-
import { inlineText as
|
|
64
|
-
import { getPrefixedDataAttributes as
|
|
65
|
-
import { isEqual as
|
|
66
|
-
import { isRunningAcceptanceTest as
|
|
67
|
-
import { timerDaysShortLabel as
|
|
68
|
-
const $ = 24, V = 60, X = 60, C = 1e3, Z = X * C, P = V * Z,
|
|
60
|
+
import { Text2 as ne, Text6 as re } from "./text.js";
|
|
61
|
+
import { useThemeVariant as se, ThemeVariant as ae } from "./theme-variant-context.js";
|
|
62
|
+
import { inlineText as j, timerWrapper as oe, shortLabelText as ie, boxedTimerValueContainer as le, timerDisplayValue as ue, boxedTimerDisplayValue as ce, unitContainer as T } from "./timer.css-mistica.js";
|
|
63
|
+
import { getPrefixedDataAttributes as z } from "./utils/dom.js";
|
|
64
|
+
import { isEqual as de } from "./utils/helpers.js";
|
|
65
|
+
import { isRunningAcceptanceTest as B } from "./utils/platform.js";
|
|
66
|
+
import { timerDaysShortLabel as me, timerHoursShortLabel as he, timerMinutesShortLabel as Le, timerSecondsShortLabel as be, timerDayLongLabel as R, timerHourLongLabel as _, timerMinuteLongLabel as G, timerSecondLongLabel as J, timerDaysLongLabel as O, timerHoursLongLabel as E, timerMinutesLongLabel as K, timerSecondsLongLabel as Q, timerAnd as A, timerDisplayMinutesLabel as x, timerDisplaySecondsLabel as w } from "./text-tokens.js";
|
|
67
|
+
const $ = 24, V = 60, X = 60, C = 1e3, Z = X * C, P = V * Z, ge = $ * P, H = (s, a, o, i)=>{
|
|
69
68
|
a = i === "none" && a === "days" ? "hours" : a, o = i === "none" && o === "days" ? "hours" : o;
|
|
70
69
|
const c = [
|
|
71
70
|
"seconds",
|
|
@@ -91,33 +90,33 @@ const $ = 24, V = 60, X = 60, C = 1e3, Z = X * C, P = V * Z, Se = $ * P, H = (s,
|
|
|
91
90
|
unit: "seconds",
|
|
92
91
|
value: s.seconds
|
|
93
92
|
}
|
|
94
|
-
].filter((c)=>H(c.unit, a, o, i)), Y = (s)=>
|
|
93
|
+
].filter((c)=>H(c.unit, a, o, i)), Y = (s)=>B() ? 0 : Math.max(0, (typeof s == "object" ? s : new Date(s)).valueOf() - Date.now()), U = (param)=>{
|
|
95
94
|
let { endTimestamp: s, labelType: a, minTimeUnit: o, maxTimeUnit: i, onProgress: c } = param;
|
|
96
|
-
const [L, b] =
|
|
97
|
-
|
|
95
|
+
const [L, b] = f.useState(Y(s));
|
|
96
|
+
ee(()=>{
|
|
98
97
|
let u;
|
|
99
98
|
const N = ()=>{
|
|
100
99
|
const I = Y(s);
|
|
101
100
|
b(I), I || clearInterval(u);
|
|
102
101
|
};
|
|
103
|
-
if (!
|
|
102
|
+
if (!B()) return N(), u = setInterval(N, C), ()=>clearInterval(u);
|
|
104
103
|
}, [
|
|
105
104
|
s
|
|
106
105
|
]);
|
|
107
|
-
const e = H("days", o, i, a), t = H("hours", o, i, a), p = H("minutes", o, i, a), l = e ? "days" : t ? "hours" : p ? "minutes" : "seconds", g = Math.floor(L / P) % 24, M = Math.floor(L / Z) % 60, D = Math.floor(L / C) % 60, h = Math.floor(L /
|
|
106
|
+
const e = H("days", o, i, a), t = H("hours", o, i, a), p = H("minutes", o, i, a), l = e ? "days" : t ? "hours" : p ? "minutes" : "seconds", g = Math.floor(L / P) % 24, M = Math.floor(L / Z) % 60, D = Math.floor(L / C) % 60, h = Math.floor(L / ge), S = l === "hours" ? g + h * $ : g, y = l === "minutes" ? M + V * (h * $ + S) : M, n = l === "seconds" ? D + X * (h * $ * V + S * V + y) : D, [r, d] = f.useState(W({
|
|
108
107
|
days: h,
|
|
109
108
|
hours: S,
|
|
110
|
-
minutes:
|
|
111
|
-
seconds:
|
|
109
|
+
minutes: y,
|
|
110
|
+
seconds: n
|
|
112
111
|
}, o, i, a));
|
|
113
|
-
return
|
|
112
|
+
return f.useEffect(()=>{
|
|
114
113
|
const u = W({
|
|
115
114
|
days: h,
|
|
116
115
|
hours: S,
|
|
117
|
-
minutes:
|
|
118
|
-
seconds:
|
|
116
|
+
minutes: y,
|
|
117
|
+
seconds: n
|
|
119
118
|
}, o, i, a);
|
|
120
|
-
if (!
|
|
119
|
+
if (!de(u, r)) {
|
|
121
120
|
d(u);
|
|
122
121
|
const N = {};
|
|
123
122
|
u.forEach((I)=>N[I.unit] = I.value), c == null || c(N);
|
|
@@ -125,27 +124,27 @@ const $ = 24, V = 60, X = 60, C = 1e3, Z = X * C, P = V * Z, Se = $ * P, H = (s,
|
|
|
125
124
|
}, [
|
|
126
125
|
h,
|
|
127
126
|
S,
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
y,
|
|
128
|
+
n,
|
|
130
129
|
a,
|
|
131
130
|
o,
|
|
132
131
|
i,
|
|
133
|
-
|
|
132
|
+
r,
|
|
134
133
|
c
|
|
135
|
-
]),
|
|
136
|
-
},
|
|
134
|
+
]), r;
|
|
135
|
+
}, Re = (param)=>{
|
|
137
136
|
let { endTimestamp: s, labelType: a = "none", minTimeUnit: o, maxTimeUnit: i, onProgress: c, dataAttributes: L, "aria-label": b } = param;
|
|
138
|
-
const { texts: e, t } = k(), p =
|
|
137
|
+
const { texts: e, t } = k(), p = f.useId(), l = U({
|
|
139
138
|
endTimestamp: s,
|
|
140
139
|
labelType: a,
|
|
141
140
|
minTimeUnit: o,
|
|
142
141
|
maxTimeUnit: i,
|
|
143
142
|
onProgress: c
|
|
144
143
|
}), g = {
|
|
145
|
-
days: e.timerDaysShortLabel || t(
|
|
146
|
-
hours: e.timerHoursShortLabel || t(
|
|
147
|
-
minutes: e.timerMinutesShortLabel || t(
|
|
148
|
-
seconds: e.timerSecondsShortLabel || t(
|
|
144
|
+
days: e.timerDaysShortLabel || t(me),
|
|
145
|
+
hours: e.timerHoursShortLabel || t(he),
|
|
146
|
+
minutes: e.timerMinutesShortLabel || t(Le),
|
|
147
|
+
seconds: e.timerSecondsShortLabel || t(be)
|
|
149
148
|
}, M = {
|
|
150
149
|
days: e.timerDayLongLabel || t(R),
|
|
151
150
|
hours: e.timerHourLongLabel || t(_),
|
|
@@ -156,76 +155,76 @@ const $ = 24, V = 60, X = 60, C = 1e3, Z = X * C, P = V * Z, Se = $ * P, H = (s,
|
|
|
156
155
|
hours: e.timerHoursLongLabel || t(E),
|
|
157
156
|
minutes: e.timerMinutesLongLabel || t(K),
|
|
158
157
|
seconds: e.timerSecondsLongLabel || t(Q)
|
|
159
|
-
}, h = (
|
|
160
|
-
const
|
|
158
|
+
}, h = (n)=>{
|
|
159
|
+
const r = Math.max(String(n).length, a === "long" ? 1 : 2);
|
|
161
160
|
return /* @__PURE__ */ m("span", {
|
|
162
|
-
className:
|
|
161
|
+
className: T,
|
|
163
162
|
style: {
|
|
164
|
-
minWidth: `${
|
|
163
|
+
minWidth: `${r}ch`
|
|
165
164
|
},
|
|
166
|
-
children: String(
|
|
165
|
+
children: String(n).padStart(r, "0")
|
|
167
166
|
});
|
|
168
167
|
}, S = ()=>{
|
|
169
168
|
switch(a){
|
|
170
169
|
case "none":
|
|
171
|
-
return l.map((
|
|
170
|
+
return l.map((n, r)=>/* @__PURE__ */ v(f.Fragment, {
|
|
172
171
|
children: [
|
|
173
|
-
|
|
174
|
-
h(
|
|
172
|
+
r > 0 && ":",
|
|
173
|
+
h(n.value)
|
|
175
174
|
]
|
|
176
|
-
},
|
|
175
|
+
}, r));
|
|
177
176
|
case "short":
|
|
178
|
-
return l.map((
|
|
177
|
+
return l.map((n, r)=>/* @__PURE__ */ v(f.Fragment, {
|
|
179
178
|
children: [
|
|
180
|
-
|
|
179
|
+
r > 0 && " ",
|
|
181
180
|
/* @__PURE__ */ v("span", {
|
|
182
|
-
className:
|
|
181
|
+
className: ie,
|
|
183
182
|
children: [
|
|
184
|
-
h(
|
|
185
|
-
` ${g[
|
|
183
|
+
h(n.value),
|
|
184
|
+
` ${g[n.unit]}`
|
|
186
185
|
]
|
|
187
186
|
})
|
|
188
187
|
]
|
|
189
|
-
},
|
|
188
|
+
}, r));
|
|
190
189
|
case "long":
|
|
191
190
|
default:
|
|
192
|
-
return l.map((
|
|
191
|
+
return l.map((n, r)=>/* @__PURE__ */ v(f.Fragment, {
|
|
193
192
|
children: [
|
|
194
|
-
|
|
195
|
-
h(
|
|
196
|
-
` ${
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
r > 0 && " ",
|
|
194
|
+
h(n.value),
|
|
195
|
+
` ${n.value === 1 ? M[n.unit] : D[n.unit]}`,
|
|
196
|
+
r === l.length - 2 && ` ${e.timerAnd || t(A)}`,
|
|
197
|
+
r < l.length - 2 && ","
|
|
199
198
|
]
|
|
200
|
-
},
|
|
199
|
+
}, r));
|
|
201
200
|
}
|
|
202
|
-
},
|
|
201
|
+
}, y = l.map((n, r)=>`${n.value} ${n.value === 1 ? M[n.unit] : D[n.unit]}${r === l.length - 1 ? "" : r === l.length - 2 ? ` ${e.timerAnd || t(A)} ` : ", "}`).join("");
|
|
203
202
|
return /* @__PURE__ */ v("span", _object_spread_props(_object_spread({
|
|
204
203
|
role: "timer",
|
|
205
204
|
"aria-labelledby": p,
|
|
206
|
-
className:
|
|
205
|
+
className: j,
|
|
207
206
|
style: {
|
|
208
207
|
// try to keep the timer in the same line without wrapping only when label is not long
|
|
209
208
|
display: a !== "long" ? "inline-block" : void 0
|
|
210
209
|
}
|
|
211
|
-
},
|
|
210
|
+
}, z(L, "TextTimer")), {
|
|
212
211
|
children: [
|
|
213
212
|
/* @__PURE__ */ m(q, {
|
|
214
213
|
children: /* @__PURE__ */ m("span", {
|
|
215
214
|
id: p,
|
|
216
|
-
children: b ? `${b}. ${
|
|
215
|
+
children: b ? `${b}. ${y}` : y
|
|
217
216
|
})
|
|
218
217
|
}),
|
|
219
218
|
/* @__PURE__ */ m("span", {
|
|
220
219
|
"aria-hidden": !0,
|
|
221
|
-
className:
|
|
220
|
+
className: j,
|
|
222
221
|
children: S()
|
|
223
222
|
})
|
|
224
223
|
]
|
|
225
224
|
}));
|
|
226
|
-
},
|
|
225
|
+
}, _e = (param)=>{
|
|
227
226
|
let { boxed: s, endTimestamp: a, minTimeUnit: o, maxTimeUnit: i, onProgress: c, dataAttributes: L, "aria-label": b } = param;
|
|
228
|
-
const { texts: e, t } = k(), p =
|
|
227
|
+
const { texts: e, t } = k(), p = f.useId(), l = se(), g = U({
|
|
229
228
|
endTimestamp: a,
|
|
230
229
|
minTimeUnit: o,
|
|
231
230
|
maxTimeUnit: i,
|
|
@@ -233,12 +232,12 @@ const $ = 24, V = 60, X = 60, C = 1e3, Z = X * C, P = V * Z, Se = $ * P, H = (s,
|
|
|
233
232
|
}), M = {
|
|
234
233
|
days: e.timerDayLongLabel || t(R),
|
|
235
234
|
hours: e.timerHourLongLabel || t(_),
|
|
236
|
-
minutes: e.timerDisplayMinutesLabel || t(
|
|
235
|
+
minutes: e.timerDisplayMinutesLabel || t(x),
|
|
237
236
|
seconds: e.timerDisplaySecondsLabel || t(w)
|
|
238
237
|
}, D = {
|
|
239
238
|
days: e.timerDaysLongLabel || t(O),
|
|
240
239
|
hours: e.timerHoursLongLabel || t(E),
|
|
241
|
-
minutes: e.timerDisplayMinutesLabel || t(
|
|
240
|
+
minutes: e.timerDisplayMinutesLabel || t(x),
|
|
242
241
|
seconds: e.timerDisplaySecondsLabel || t(w)
|
|
243
242
|
}, h = {
|
|
244
243
|
days: e.timerDayLongLabel || t(R),
|
|
@@ -250,29 +249,29 @@ const $ = 24, V = 60, X = 60, C = 1e3, Z = X * C, P = V * Z, Se = $ * P, H = (s,
|
|
|
250
249
|
hours: e.timerHoursLongLabel || t(E),
|
|
251
250
|
minutes: e.timerMinutesLongLabel || t(K),
|
|
252
251
|
seconds: e.timerSecondsLongLabel || t(Q)
|
|
253
|
-
},
|
|
252
|
+
}, y = (d)=>{
|
|
254
253
|
const u = Math.max(String(d).length, 2);
|
|
255
|
-
return /* @__PURE__ */ m(
|
|
254
|
+
return /* @__PURE__ */ m(re, {
|
|
256
255
|
children: /* @__PURE__ */ m("div", {
|
|
257
|
-
className:
|
|
256
|
+
className: T,
|
|
258
257
|
style: {
|
|
259
258
|
minWidth: `${u}ch`
|
|
260
259
|
},
|
|
261
260
|
children: String(d).padStart(u, "0")
|
|
262
261
|
})
|
|
263
262
|
});
|
|
264
|
-
},
|
|
265
|
-
className:
|
|
266
|
-
[
|
|
263
|
+
}, n = g.map((d, u)=>`${d.value} ${d.value === 1 ? h[d.unit] : S[d.unit]}${u === g.length - 1 ? "" : u === g.length - 2 ? ` ${e.timerAnd || t(A)} ` : ", "}`).join(""), r = ()=>g.map((d, u)=>/* @__PURE__ */ m("div", {
|
|
264
|
+
className: F({
|
|
265
|
+
[le[l]]: s
|
|
267
266
|
}),
|
|
268
|
-
children: /* @__PURE__ */ m(
|
|
267
|
+
children: /* @__PURE__ */ m(ae, {
|
|
269
268
|
variant: s ? "default" : l,
|
|
270
269
|
children: /* @__PURE__ */ v("div", {
|
|
271
|
-
className:
|
|
272
|
-
[
|
|
270
|
+
className: F(ue, {
|
|
271
|
+
[ce]: s
|
|
273
272
|
}),
|
|
274
273
|
children: [
|
|
275
|
-
|
|
274
|
+
y(d.value),
|
|
276
275
|
/* @__PURE__ */ m(ne, {
|
|
277
276
|
regular: !0,
|
|
278
277
|
children: d.value === 1 ? M[d.unit] : D[d.unit]
|
|
@@ -284,24 +283,24 @@ const $ = 24, V = 60, X = 60, C = 1e3, Z = X * C, P = V * Z, Se = $ * P, H = (s,
|
|
|
284
283
|
return /* @__PURE__ */ v("div", _object_spread_props(_object_spread({
|
|
285
284
|
role: "timer",
|
|
286
285
|
"aria-labelledby": p,
|
|
287
|
-
className:
|
|
288
|
-
},
|
|
286
|
+
className: oe
|
|
287
|
+
}, z(L, "Timer")), {
|
|
289
288
|
children: [
|
|
290
289
|
/* @__PURE__ */ m(q, {
|
|
291
290
|
children: /* @__PURE__ */ m("span", {
|
|
292
291
|
id: p,
|
|
293
|
-
children: b ? `${b}. ${
|
|
292
|
+
children: b ? `${b}. ${n}` : n
|
|
294
293
|
})
|
|
295
294
|
}),
|
|
296
295
|
/* @__PURE__ */ m("div", {
|
|
297
296
|
"aria-hidden": !0,
|
|
298
|
-
children: /* @__PURE__ */ m(
|
|
297
|
+
children: /* @__PURE__ */ m(te, {
|
|
299
298
|
space: s ? 8 : 16,
|
|
300
299
|
wrap: !0,
|
|
301
|
-
children:
|
|
300
|
+
children: r()
|
|
302
301
|
})
|
|
303
302
|
})
|
|
304
303
|
]
|
|
305
304
|
}));
|
|
306
305
|
};
|
|
307
|
-
export {
|
|
306
|
+
export { Re as TextTimer, _e as Timer };
|