dhre-ui-kit 0.0.377 → 0.0.378
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/lib/index.d.ts +2 -0
- package/lib/index.js +23 -2
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +22 -2
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -1
package/lib/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { createContext, useContext, useState, useEffect, useRef, memo, useCallback } from 'react';
|
|
2
2
|
import { useSelector } from 'react-redux';
|
|
3
3
|
import { Dimensions, StyleSheet, Text, Pressable, View, Platform, KeyboardAvoidingView, TextInput, ScrollView, Animated, FlatList, TouchableOpacity, Modal as Modal$1, Alert, Linking, PanResponder } from 'react-native';
|
|
4
|
+
import translate from 'google-translate-api-x';
|
|
4
5
|
import Modal from 'react-native-modal';
|
|
5
6
|
import Clipboard from '@react-native-clipboard/clipboard';
|
|
6
7
|
import LottieView from 'lottie-react-native';
|
|
@@ -343,9 +344,27 @@ const CustomTypography = ({
|
|
|
343
344
|
style,
|
|
344
345
|
text,
|
|
345
346
|
testID = "CUSTOM_TYPOGRAPHY",
|
|
347
|
+
translateToArabic = false,
|
|
346
348
|
...props
|
|
347
349
|
}) => {
|
|
350
|
+
const [translatedText, setTranslatedText] = useState(text || "");
|
|
348
351
|
const textStyle = FONT_STYLES[variant];
|
|
352
|
+
useEffect(() => {
|
|
353
|
+
const translateText = async () => {
|
|
354
|
+
if (!translateToArabic || !text || text.trim() === "") {
|
|
355
|
+
setTranslatedText(text || "");
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
try {
|
|
359
|
+
const res = await translate(text, { to: "ar" });
|
|
360
|
+
setTranslatedText(res.text);
|
|
361
|
+
} catch (error) {
|
|
362
|
+
console.error("Translation error:", error);
|
|
363
|
+
setTranslatedText(text);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
translateText();
|
|
367
|
+
}, [text, translateToArabic]);
|
|
349
368
|
return /* @__PURE__ */ React.createElement(
|
|
350
369
|
Text,
|
|
351
370
|
{
|
|
@@ -353,7 +372,7 @@ const CustomTypography = ({
|
|
|
353
372
|
style: [textStyle, styles$B.container, style],
|
|
354
373
|
...props
|
|
355
374
|
},
|
|
356
|
-
|
|
375
|
+
translatedText
|
|
357
376
|
);
|
|
358
377
|
};
|
|
359
378
|
const styles$B = StyleSheet.create({
|
|
@@ -3706,7 +3725,7 @@ const styles$l = StyleSheet.create({
|
|
|
3706
3725
|
});
|
|
3707
3726
|
|
|
3708
3727
|
const Toast = React.forwardRef(
|
|
3709
|
-
({ sucessIcon, errorIcon, warningIcon }, ref) => {
|
|
3728
|
+
({ sucessIcon, errorIcon, warningIcon, language }, ref) => {
|
|
3710
3729
|
const [visible, setVisible] = useState(false);
|
|
3711
3730
|
const [message, setMessage] = useState("");
|
|
3712
3731
|
const [isSuccess, setIsSuccess] = useState(true);
|
|
@@ -3778,6 +3797,7 @@ const Toast = React.forwardRef(
|
|
|
3778
3797
|
{
|
|
3779
3798
|
variant: "L2_REGULAR",
|
|
3780
3799
|
text: message,
|
|
3800
|
+
translateToArabic: language === "ar",
|
|
3781
3801
|
style: styles$l.messageText
|
|
3782
3802
|
}
|
|
3783
3803
|
), btnText && /* @__PURE__ */ React.createElement(
|