@stokr/components-library 3.0.72-beta.2 → 3.0.72-beta.4

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,15 +1,17 @@
1
1
  import { jsx, Fragment } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import PropTypes from "prop-types";
4
- import { resolveCopy } from "./copySource.js";
5
- const Copy = ({ id, fallback }) => {
6
- const value = resolveCopy(id);
7
- return /* @__PURE__ */ jsx(Fragment, { children: value ?? fallback ?? id });
4
+ import { resolveCopy, interpolate } from "./copySource.js";
5
+ const Copy = ({ id, fallback, values }) => {
6
+ const value = resolveCopy(id) ?? fallback ?? id;
7
+ return /* @__PURE__ */ jsx(Fragment, { children: interpolate(value, values) });
8
8
  };
9
9
  Copy.propTypes = {
10
10
  id: PropTypes.string.isRequired,
11
11
  /** Shown when the copy source has no value for this id (or none is registered). */
12
- fallback: PropTypes.string
12
+ fallback: PropTypes.string,
13
+ /** Values for `{token}` placeholders in the copy string, e.g. { amount: '1,000' }. */
14
+ values: PropTypes.object
13
15
  };
14
16
  export {
15
17
  Copy
@@ -9,8 +9,17 @@ function resolveCopy(id) {
9
9
  function getCopySource() {
10
10
  return source;
11
11
  }
12
+ function interpolate(str, values) {
13
+ if (!values || typeof str !== "string") return str;
14
+ return str.replace(/\{(\w+)\}/g, (_, k) => k in values ? String(values[k]) : `{${k}}`);
15
+ }
16
+ function t(id, values) {
17
+ return interpolate(resolveCopy(id) ?? id, values);
18
+ }
12
19
  export {
13
20
  getCopySource,
21
+ interpolate,
14
22
  resolveCopy,
15
- setCopySource
23
+ setCopySource,
24
+ t
16
25
  };
@@ -1,13 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useRef, useCallback, useEffect } from "react";
3
3
  import PropTypes from "prop-types";
4
- import { DotLottieReact, setWasmUrl } from "@lottiefiles/dotlottie-react";
4
+ import { DotLottieReact } from "@lottiefiles/dotlottie-react";
5
5
  import { AnimationWrapper } from "./LottieAnimation.styles.js";
6
6
  import progressAnimation from "../../static/animations/progress.lottie.js";
7
7
  import uploadAnimation from "../../static/animations/upload.lottie.js";
8
8
  import successAnimation from "../../static/animations/checked.lottie.js";
9
- import dotLottiePlayerWasm from "@lottiefiles/dotlottie-web/dotlottie-player.wasm?url";
10
- setWasmUrl(dotLottiePlayerWasm);
11
9
  const LOTTIE_ANIMATIONS = {
12
10
  progress: { src: progressAnimation, segment: null, loop: false },
13
11
  upload: { src: uploadAnimation, segment: null, loop: false },
@@ -28,7 +28,9 @@ const DetailRows = ({ rows = [] }) => {
28
28
  target: row.target,
29
29
  tooltip: row.tooltip,
30
30
  placeholder: row.placeholder,
31
- isCustom: row.isCustom
31
+ isCustom: row.isCustom,
32
+ labelIcon: row.labelIcon,
33
+ valueIcon: row.valueIcon
32
34
  }
33
35
  ),
34
36
  index < rows.length - 1 && /* @__PURE__ */ jsx(RowDivider, {})
@@ -27,6 +27,16 @@ const Chevron = styled.svg`
27
27
  transform: ${(props) => props.$expanded ? "rotate(180deg)" : "none"};
28
28
  transition: transform 0.2s;
29
29
  `;
30
+ const AnimatedRows = styled.div.withConfig({
31
+ shouldForwardProp: (prop) => !["$open"].includes(prop)
32
+ })`
33
+ width: 100%;
34
+ overflow: hidden;
35
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
36
+ opacity: ${(props) => props.$open ? 1 : 0};
37
+ transform: ${(props) => props.$open ? "translateY(0)" : "translateY(-10px)"};
38
+ max-height: ${(props) => props.$open ? "1000px" : "0"};
39
+ `;
30
40
  const DetailsToggle = ({
31
41
  rows = [],
32
42
  defaultOpen = false,
@@ -44,6 +54,7 @@ const DetailsToggle = ({
44
54
  if (!isControlled) setUncontrolledOpen(next);
45
55
  };
46
56
  return /* @__PURE__ */ jsxs(Fragment, { children: [
57
+ /* @__PURE__ */ jsx(AnimatedRows, { $open: open, "aria-hidden": !open, children: /* @__PURE__ */ jsx(DetailRows, { rows }) }),
47
58
  /* @__PURE__ */ jsxs(ToggleButton, { type: "button", onClick: handleClick, "aria-expanded": open, children: [
48
59
  open ? hideLabel : showLabel,
49
60
  /* @__PURE__ */ jsx(
@@ -59,8 +70,7 @@ const DetailsToggle = ({
59
70
  children: /* @__PURE__ */ jsx("path", { d: "M1 2L7 8L13 2", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
60
71
  }
61
72
  )
62
- ] }),
63
- open && /* @__PURE__ */ jsx(DetailRows, { rows })
73
+ ] })
64
74
  ] });
65
75
  };
66
76
  export {
@@ -168,6 +168,10 @@ const DetailLabel = styled.div`
168
168
  }
169
169
  `;
170
170
  const DetailValue = styled.div`
171
+ display: flex;
172
+ align-items: center;
173
+ justify-content: flex-end;
174
+ gap: 6px;
171
175
  font-size: 14px;
172
176
  font-weight: 600;
173
177
  line-height: 20px;
@@ -214,7 +218,7 @@ const ExternalLinkIconImg = styled.img`
214
218
  height: 12px;
215
219
  flex-shrink: 0;
216
220
  `;
217
- const DetailItem = ({ label, value, tooltip, placeholder, isCustom, href, target }) => {
221
+ const DetailItem = ({ label, value, tooltip, placeholder, isCustom, href, target, labelIcon, valueIcon }) => {
218
222
  const renderValue = () => {
219
223
  if (isCustom && value) {
220
224
  return value;
@@ -236,9 +240,13 @@ const DetailItem = ({ label, value, tooltip, placeholder, isCustom, href, target
236
240
  return /* @__PURE__ */ jsxs(DetailRow, { children: [
237
241
  /* @__PURE__ */ jsxs(DetailLabel, { children: [
238
242
  label,
239
- tooltip && /* @__PURE__ */ jsx(InfoIcon, { containerStyle: { width: 14, height: 14 }, title: tooltip, noMargin: true })
243
+ tooltip && /* @__PURE__ */ jsx(InfoIcon, { containerStyle: { width: 14, height: 14 }, title: tooltip, noMargin: true }),
244
+ labelIcon
240
245
  ] }),
241
- /* @__PURE__ */ jsx(DetailValue, { children: renderValue() })
246
+ /* @__PURE__ */ jsxs(DetailValue, { children: [
247
+ valueIcon,
248
+ renderValue()
249
+ ] })
242
250
  ] });
243
251
  };
244
252
  const AmountBlock = ({ config }) => {
@@ -295,7 +303,9 @@ const DetailGroup = ({ group, isLast }) => {
295
303
  placeholder: detail.placeholder,
296
304
  isCustom: detail.isCustom,
297
305
  href: detail.href,
298
- target: detail.target
306
+ target: detail.target,
307
+ labelIcon: detail.labelIcon,
308
+ valueIcon: detail.valueIcon
299
309
  },
300
310
  detail.key || index
301
311
  ))
@@ -342,7 +352,9 @@ const PaymentDetailsCard = ({
342
352
  placeholder: detail.placeholder,
343
353
  isCustom: detail.isCustom,
344
354
  href: detail.href,
345
- target: detail.target
355
+ target: detail.target,
356
+ labelIcon: detail.labelIcon,
357
+ valueIcon: detail.valueIcon
346
358
  },
347
359
  detail.key || index
348
360
  )) });
@@ -14,7 +14,7 @@ const CodeWrapper = styled.div.withConfig({
14
14
  shouldForwardProp: (props) => !["maxWidth"].includes(props)
15
15
  })`
16
16
  background: ${colors.white};
17
- border: 1px solid ${colors.grey4};
17
+ border: 1px solid ${colors.lightGrey};
18
18
  border-radius: 8px;
19
19
  box-shadow: none;
20
20
  padding: 48px 40px;
@@ -6,7 +6,6 @@ import { colors } from "../../styles/colors.js";
6
6
  import { Button } from "../Button/Button.styles.js";
7
7
  import { DetailRows } from "./DetailRows.js";
8
8
  import { CodeWrapper } from "./PaymentDisplay.js";
9
- import externalLinkIcon from "../../static/images/external-link-icon.svg.js";
10
9
  const spin = keyframes`
11
10
  to { transform: rotate(360deg); }
12
11
  `;
@@ -44,12 +43,6 @@ const Description = styled.p`
44
43
  letter-spacing: 0.6px;
45
44
  color: ${colors.black};
46
45
  `;
47
- const ButtonIcon = styled.img`
48
- width: 12px;
49
- height: 12px;
50
- margin-left: 8px;
51
- vertical-align: -1px;
52
- `;
53
46
  const FooterNote = styled.p`
54
47
  margin: 0;
55
48
  font-size: 12px;
@@ -63,9 +56,9 @@ const PaymentPendingCard = ({
63
56
  title,
64
57
  description,
65
58
  rows = [],
66
- explorerLabel = "View on explorer",
67
- explorerHref,
68
- onExplorerClick,
59
+ actionLabel,
60
+ actionHref,
61
+ onActionClick,
69
62
  footerNote,
70
63
  maxWidth,
71
64
  containerStyle,
@@ -81,20 +74,17 @@ const PaymentPendingCard = ({
81
74
  description && /* @__PURE__ */ jsx(Description, { children: description })
82
75
  ] }),
83
76
  /* @__PURE__ */ jsx(DetailRows, { rows }),
84
- (explorerHref || onExplorerClick) && /* @__PURE__ */ jsxs(
77
+ (actionHref || onActionClick) && actionLabel && /* @__PURE__ */ jsx(
85
78
  Button,
86
79
  {
87
- as: explorerHref ? "a" : "button",
88
- href: explorerHref,
89
- target: explorerHref ? "_blank" : void 0,
90
- rel: explorerHref ? "noopener noreferrer" : void 0,
91
- onClick: onExplorerClick,
80
+ as: actionHref ? "a" : "button",
81
+ href: actionHref,
82
+ target: actionHref ? "_blank" : void 0,
83
+ rel: actionHref ? "noopener noreferrer" : void 0,
84
+ onClick: onActionClick,
92
85
  outlineBlack: true,
93
86
  fluid: true,
94
- children: [
95
- explorerLabel,
96
- /* @__PURE__ */ jsx(ButtonIcon, { src: externalLinkIcon, alt: "" })
97
- ]
87
+ children: actionLabel
98
88
  }
99
89
  ),
100
90
  footerNote && /* @__PURE__ */ jsx(FooterNote, { children: footerNote }),
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { ReactTable } from "./components/AdminDashboard/Table/ReactTable.js";
4
4
  import { ReactTableWrapper } from "./components/AdminDashboard/Table/ReactTableWrapper.js";
5
5
  import { AgreementItem } from "./components/AgreementItem/AgreementItem.js";
6
6
  import { Copy } from "./components/Copy/Copy.js";
7
- import { getCopySource, resolveCopy, setCopySource } from "./components/Copy/copySource.js";
7
+ import { getCopySource, interpolate, resolveCopy, setCopySource, t } from "./components/Copy/copySource.js";
8
8
  import { flatten, isCopyKey } from "./components/Copy/flatten.js";
9
9
  import { BackButton } from "./components/BackButton/BackButton.js";
10
10
  import { Background } from "./components/Background/Background.js";
@@ -638,6 +638,7 @@ export {
638
638
  iconsMap,
639
639
  identify,
640
640
  initAnalytics,
641
+ interpolate,
641
642
  isAccountLockedError,
642
643
  isAlreadyOnOnboardingFlow,
643
644
  isCopyKey,
@@ -668,6 +669,7 @@ export {
668
669
  showSuccess,
669
670
  sizes,
670
671
  default7 as spacing,
672
+ t,
671
673
  default8 as theme,
672
674
  timeEvent,
673
675
  track,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "3.0.72-beta.2",
3
+ "version": "3.0.72-beta.4",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",
@@ -55,7 +55,6 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@lottiefiles/dotlottie-react": "^0.19.4",
58
- "@lottiefiles/dotlottie-web": "^0.74.0",
59
58
  "axios": "^1.13.5",
60
59
  "country-flag-icons": "^1.6.17",
61
60
  "date-fns": "^4.1.0",