spoko-design-system 0.2.61 → 0.2.62
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/index.ts +1 -5
- package/package.json +1 -1
- package/src/utils/getData.ts +1 -2
- package/src/utils/text.ts +23 -1
package/index.ts
CHANGED
|
@@ -53,11 +53,7 @@ export { default as getProductChecklist } from './src/utils/product/getProductCh
|
|
|
53
53
|
export { default as getShorterDescription } from './src/utils/seo/getShorterDescription';
|
|
54
54
|
|
|
55
55
|
// Utils: Text
|
|
56
|
-
|
|
57
|
-
// export { default as getData } from './src/utils/getData';
|
|
58
|
-
// export { getData } from './src/utils/getData';
|
|
59
|
-
export { getTranslation, text2paragraphs, countWords, firstSentence, removeSemicolon } from './src/utils/text';
|
|
60
|
-
export { default as getData} from './src/utils/getData';
|
|
56
|
+
export { getTranslation, text2paragraphs, countWords, firstSentence, removeSemicolon, apiInfo } from './src/utils/text';
|
|
61
57
|
export { default as formatDate } from './src/utils/text/formatDate';
|
|
62
58
|
export { default as formatLocaleNumber } from './src/utils/text/formatLocaleNumber';
|
|
63
59
|
export { default as formatPad } from './src/utils/text/formatPad';
|
package/package.json
CHANGED
package/src/utils/getData.ts
CHANGED
package/src/utils/text.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
|
|
2
1
|
import i18next, { t } from "i18next";
|
|
3
2
|
|
|
3
|
+
export function getEnvVariable(key, defaultValue = null) {
|
|
4
|
+
// First we check import.meta.env (for ES6 environments)
|
|
5
|
+
if (typeof import.meta !== 'undefined' && typeof import.meta.env !== 'undefined') {
|
|
6
|
+
return import.meta.env[key] || defaultValue;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Then check process.env (for Node.js environment)
|
|
10
|
+
if (typeof process !== 'undefined' && typeof process.env !== 'undefined') {
|
|
11
|
+
return process.env[key] || defaultValue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// If no variable is found, the default value is returned
|
|
15
|
+
return defaultValue;
|
|
16
|
+
}
|
|
17
|
+
const API_URL = getEnvVariable('API_URL', 'http://default-api.com');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
4
22
|
// import { t } from "i18next";
|
|
5
23
|
|
|
6
24
|
export const getTranslation = (translationKey: string) => {
|
|
@@ -25,4 +43,8 @@ export const firstSentence = (str: string) => {
|
|
|
25
43
|
|
|
26
44
|
export const removeSemicolon = (name: string) => {
|
|
27
45
|
return name.replace(';', '')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const apiInfo = (name: string) => {
|
|
49
|
+
return API_URL
|
|
28
50
|
}
|