@stokr/components-library 3.0.72-beta.2 → 3.0.72-beta.3
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
|
|
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
|
};
|
|
@@ -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.
|
|
17
|
+
border: 1px solid ${colors.lightGrey};
|
|
18
18
|
border-radius: 8px;
|
|
19
19
|
box-shadow: none;
|
|
20
20
|
padding: 48px 40px;
|
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,
|