dhre-ui-kit 0.0.246 → 0.0.248

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.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import React, { createContext, useContext, useRef, useEffect, useState, memo, useCallback } from 'react';
1
+ import React, { createContext, useContext, useState, useEffect, useRef, memo, useCallback } from 'react';
2
2
  import { useSelector } from 'react-redux';
3
- import { Dimensions, StyleSheet, Text, Pressable, View, Modal, KeyboardAvoidingView, Platform, Animated, Easing, TextInput, ScrollView, FlatList, TouchableOpacity, Alert, Linking, PanResponder } from 'react-native';
3
+ import { Dimensions, StyleSheet, Text, Pressable, View, Modal, KeyboardAvoidingView, Platform, TextInput, ScrollView, Animated, FlatList, TouchableOpacity, Alert, Linking, PanResponder } from 'react-native';
4
4
  import { PanGestureHandler, GestureHandlerRootView, Swipeable } from 'react-native-gesture-handler';
5
5
  import { BlurView } from '@react-native-community/blur';
6
- import Svg, { Defs, LinearGradient, Stop, Circle } from 'react-native-svg';
6
+ import LottieView from 'lottie-react-native';
7
7
  import Tooltip from 'react-native-walkthrough-tooltip';
8
8
  import Pdf from 'react-native-pdf';
9
9
  import * as Progress from 'react-native-progress';
@@ -15,6 +15,7 @@ import { Dropdown } from 'react-native-element-dropdown';
15
15
  import DocumentPicker from 'react-native-document-picker';
16
16
  import RNFS from 'react-native-fs';
17
17
  import OTPVerify, { removeListener, startOtpListener } from 'react-native-otp-verify';
18
+ import { verticalScale as verticalScale$1, moderateScale as moderateScale$1 } from 'src/utils/stylehelper';
18
19
  import Clipboard from '@react-native-clipboard/clipboard';
19
20
 
20
21
  var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
@@ -710,6 +711,13 @@ const BottomDrawer = ({
710
711
 
711
712
  const createStyles$3 = (theme) => {
712
713
  return StyleSheet.create({
714
+ container: {
715
+ position: "absolute",
716
+ left: 0,
717
+ right: 0,
718
+ bottom: 0,
719
+ top: 0
720
+ },
713
721
  backdrop: {
714
722
  flex: 1,
715
723
  justifyContent: "center",
@@ -746,67 +754,20 @@ const createStyles$3 = (theme) => {
746
754
  };
747
755
 
748
756
  const CustomLoader = ({ loading, loadingText = "Loading..." }) => {
749
- const rotateAnim = useRef(new Animated.Value(0)).current;
750
757
  const { theme, mode } = useTheme();
751
758
  const styles = createStyles$3(theme);
752
- useEffect(() => {
753
- if (loading) {
754
- Animated.loop(
755
- Animated.timing(rotateAnim, {
756
- toValue: 1,
757
- duration: 1500,
758
- easing: Easing.linear,
759
- useNativeDriver: true
760
- })
761
- ).start();
762
- } else {
763
- rotateAnim.stopAnimation();
764
- rotateAnim.setValue(0);
765
- }
766
- return () => {
767
- rotateAnim.stopAnimation();
768
- };
769
- }, [loading, rotateAnim]);
770
759
  if (!loading) return null;
771
- const spin = rotateAnim.interpolate({
772
- inputRange: [0, 1],
773
- outputRange: ["0deg", "360deg"]
774
- });
775
- return /* @__PURE__ */ React.createElement(Modal, { transparent: true, visible: loading, animationType: "fade" }, /* @__PURE__ */ React.createElement(View, { style: styles.backdrop }, /* @__PURE__ */ React.createElement(View, { style: styles.box }, /* @__PURE__ */ React.createElement(Animated.View, { style: [styles.loader, { transform: [{ rotate: spin }] }] }, /* @__PURE__ */ React.createElement(Svg, { width: "100", height: "100", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement(Defs, null, /* @__PURE__ */ React.createElement(LinearGradient, { id: "grad", x1: "0%", y1: "0%", x2: "100%", y2: "100%" }, /* @__PURE__ */ React.createElement(Stop, { offset: "0%", stopColor: "#000000", stopOpacity: "2" }), /* @__PURE__ */ React.createElement(
776
- Stop,
777
- {
778
- offset: "40%",
779
- stopColor: mode === "dark" ? "#5A5A5A00" : "#686868",
780
- stopOpacity: "5"
781
- }
782
- ), /* @__PURE__ */ React.createElement(
783
- Stop,
784
- {
785
- offset: "100%",
786
- stopColor: mode === "dark" ? "#FFFFFF" : "#AAAAAA",
787
- stopOpacity: ".9"
788
- }
789
- ))), /* @__PURE__ */ React.createElement(
790
- Circle,
791
- {
792
- cx: "50",
793
- cy: "50",
794
- r: "40",
795
- stroke: "url(#grad)",
796
- strokeWidth: "8",
797
- fill: "none",
798
- strokeDasharray: "250",
799
- strokeLinecap: "round"
800
- }
801
- ))), /* @__PURE__ */ React.createElement(
802
- CustomText$1,
803
- {
804
- text: loadingText,
805
- style: styles.text,
806
- variant: FontStyle.B4_REGULAR,
807
- textColor: "#000000"
808
- }
809
- ))));
760
+ else {
761
+ return /* @__PURE__ */ React.createElement(View, { style: styles.container }, /* @__PURE__ */ React.createElement(View, { style: styles.backdrop }, /* @__PURE__ */ React.createElement(View, { style: styles.box }, /* @__PURE__ */ React.createElement(View, { style: styles.loader }, /* @__PURE__ */ React.createElement(LottieView, { style: styles.loader, source: require("../../assets/json/Loading.json"), autoPlay: true, loop: true })), /* @__PURE__ */ React.createElement(
762
+ CustomText$1,
763
+ {
764
+ text: loadingText,
765
+ style: styles.text,
766
+ variant: FontStyle.B4_REGULAR,
767
+ textColor: "#000000"
768
+ }
769
+ ))));
770
+ }
810
771
  };
811
772
  var CustomLoader$1 = withThemeProvider(CustomLoader);
812
773
 
@@ -3974,15 +3935,18 @@ const styles$5 = StyleSheet.create({
3974
3935
  textDecorationLine: "underline"
3975
3936
  },
3976
3937
  resendOTPStyle: {
3977
- alignSelf: "flex-end",
3978
- marginTop: verticalScale(8)
3938
+ alignSelf: "flex-end"
3979
3939
  },
3980
3940
  timerContainer: {
3981
3941
  flexDirection: "row",
3982
3942
  justifyContent: "space-between",
3983
3943
  marginTop: verticalScale(8)
3984
3944
  },
3985
- timerIconContainer: { flexDirection: "row", gap: horizontalScale(8) }
3945
+ timerIconContainer: {
3946
+ flexDirection: "row",
3947
+ gap: horizontalScale(8),
3948
+ alignItems: "center"
3949
+ }
3986
3950
  });
3987
3951
 
3988
3952
  const OTPInput = React.forwardRef(
@@ -4158,12 +4122,12 @@ const OTPInput = React.forwardRef(
4158
4122
  autoComplete: "sms-otp",
4159
4123
  selectionColor: theme$1.CONTENT_PRIMARY
4160
4124
  }
4161
- ))), !errorMessageMaxReachCount && /* @__PURE__ */ React.createElement(View, { style: styles$5.timerContainer }, timeLeft !== 0 && /* @__PURE__ */ React.createElement(View, { style: styles$5.timerIconContainer }, timerIcon, /* @__PURE__ */ React.createElement(
4125
+ ))), !errorMessageMaxReachCount && /* @__PURE__ */ React.createElement(View, { style: styles$5.timerContainer }, (disableResendButton() || !isResendOtpEnable) && /* @__PURE__ */ React.createElement(View, { style: styles$5.timerIconContainer }, timerIcon, /* @__PURE__ */ React.createElement(
4162
4126
  CustomTypography,
4163
4127
  {
4164
- text: `${timeLeft} sec`,
4165
- variant: FontStyle.L2_REGULAR,
4166
- style: { color: theme$1.CONTENT_PRIMARY }
4128
+ text: `00:${timeLeft} secs`,
4129
+ variant: FontStyle.L1_REGULAR,
4130
+ style: { color: theme$1.INFO }
4167
4131
  }
4168
4132
  )), /* @__PURE__ */ React.createElement(
4169
4133
  Pressable,
@@ -4378,8 +4342,8 @@ const styles$3 = StyleSheet.create({
4378
4342
  alignItems: "center"
4379
4343
  },
4380
4344
  sliderContainer: {
4381
- height: verticalScale(48),
4382
- borderRadius: moderateScale(25),
4345
+ height: verticalScale$1(48),
4346
+ borderRadius: moderateScale$1(25),
4383
4347
  overflow: "hidden",
4384
4348
  justifyContent: "center"
4385
4349
  },
@@ -4390,11 +4354,11 @@ const styles$3 = StyleSheet.create({
4390
4354
  justifyContent: "center"
4391
4355
  },
4392
4356
  button: {
4393
- height: verticalScale(40),
4357
+ height: verticalScale$1(40),
4394
4358
  justifyContent: "center",
4395
4359
  alignItems: "center",
4396
- borderRadius: moderateScale(20),
4397
- margin: moderateScale(4)
4360
+ borderRadius: moderateScale$1(20),
4361
+ margin: 4
4398
4362
  },
4399
4363
  buttonTextContainer: {
4400
4364
  position: "absolute",
@@ -4403,7 +4367,8 @@ const styles$3 = StyleSheet.create({
4403
4367
  bottom: 0,
4404
4368
  top: 0,
4405
4369
  alignItems: "center",
4406
- justifyContent: "center"
4370
+ justifyContent: "center",
4371
+ borderRadius: 25
4407
4372
  }
4408
4373
  });
4409
4374
 
@@ -4412,30 +4377,25 @@ const CustomSlideButton = React.forwardRef(
4412
4377
  ({
4413
4378
  label,
4414
4379
  onComplete,
4380
+ onReset,
4415
4381
  icon,
4416
4382
  textStyle,
4417
4383
  containerStyle,
4418
4384
  sliderStyle,
4419
4385
  size = BUTTON_WIDTH,
4420
- slideButtonTail,
4421
- slideButtonTailColor = "#fff"
4386
+ sliderBackgroundColor = "#fff",
4387
+ sliderTextColor = "#000",
4388
+ resetTimer = 2e3
4422
4389
  }, ref) => {
4423
4390
  const value = useRef(0);
4424
4391
  const cardRef = useRef(null);
4425
4392
  const [translateX] = useState(new Animated.Value(0));
4426
- const slideTailCardRef = useRef(null);
4427
- slideTailCardRef?.current?.setNativeProps({
4428
- style: { width: 0 }
4429
- });
4393
+ const sliderConteinerRef = useRef(null);
4394
+ const [color, setColor] = useState(new Animated.Value(0));
4395
+ const [sliderBackgroundColorRef, setSliderBackgroundColorRef] = useState(new Animated.Value(0));
4430
4396
  React.useImperativeHandle(ref, () => ({
4431
4397
  reset() {
4432
- Animated.spring(translateX, {
4433
- toValue: 0,
4434
- useNativeDriver: false
4435
- }).start();
4436
- slideTailCardRef?.current?.setNativeProps({
4437
- style: { width: 0 }
4438
- });
4398
+ resetAll();
4439
4399
  }
4440
4400
  }));
4441
4401
  const handleLayout = (event) => {
@@ -4446,68 +4406,102 @@ const CustomSlideButton = React.forwardRef(
4446
4406
  // Change the width here
4447
4407
  });
4448
4408
  value.current = width;
4409
+ sliderConteinerRef?.current?.setNativeProps({
4410
+ style: { width }
4411
+ });
4449
4412
  }
4450
4413
  };
4414
+ const resetAll = () => {
4415
+ Animated.timing(translateX, {
4416
+ toValue: 0,
4417
+ useNativeDriver: false
4418
+ }).start();
4419
+ Animated.timing(sliderBackgroundColorRef, {
4420
+ toValue: 0,
4421
+ duration: 0,
4422
+ // no transition time, immediate change
4423
+ useNativeDriver: false
4424
+ // because we're animating the color, not layout
4425
+ }).start();
4426
+ Animated.timing(color, {
4427
+ toValue: 0,
4428
+ delay: 300,
4429
+ // no transition time, immediate change
4430
+ useNativeDriver: false
4431
+ // because we're animating the color, not layout
4432
+ }).start();
4433
+ onReset?.();
4434
+ };
4451
4435
  const panResponder = PanResponder.create({
4452
4436
  onMoveShouldSetPanResponder: (e, gestureState) => {
4453
4437
  return gestureState.dx !== 0;
4454
4438
  },
4455
4439
  onPanResponderMove: (evt, gestureState) => {
4456
- if (gestureState.dx > 0) {
4440
+ if (gestureState.dx > 0 && gestureState.dx <= value?.current - BUTTON_WIDTH - 8) {
4457
4441
  translateX.setValue(gestureState.dx);
4458
- slideTailCardRef?.current?.setNativeProps({
4459
- style: { width: gestureState.dx + BUTTON_WIDTH / 2 }
4460
- });
4442
+ let colorValue = gestureState.dx > value.current / 3 ? 1 : 0;
4443
+ Animated.timing(color, {
4444
+ toValue: colorValue,
4445
+ duration: 0,
4446
+ // no transition time, immediate change
4447
+ useNativeDriver: false
4448
+ // because we're animating the color, not layout
4449
+ }).start();
4461
4450
  }
4462
4451
  },
4463
4452
  onPanResponderRelease: (e, gestureState) => {
4464
- if (gestureState.dx >= value.current * 0.7) {
4453
+ if (gestureState.dx >= value.current * 0.8) {
4465
4454
  Animated.timing(translateX, {
4466
- toValue: value.current - BUTTON_WIDTH - 12,
4455
+ toValue: value?.current - (BUTTON_WIDTH + 8),
4467
4456
  // Slide to the end
4468
4457
  duration: 300,
4469
4458
  useNativeDriver: false
4470
- }).start(() => {
4471
- onComplete?.();
4472
- });
4473
- slideTailCardRef?.current?.setNativeProps({
4474
- style: { width: value.current + BUTTON_WIDTH }
4475
- // Change the width here
4476
- });
4477
- } else {
4478
- Animated.spring(translateX, {
4479
- toValue: 0,
4459
+ }).start();
4460
+ Animated.timing(sliderBackgroundColorRef, {
4461
+ toValue: 1,
4462
+ duration: 0,
4463
+ // no transition time, immediate change
4480
4464
  useNativeDriver: false
4465
+ // because we're animating the color, not layout
4481
4466
  }).start();
4482
- slideTailCardRef?.current?.setNativeProps({
4483
- style: { width: 0 }
4484
- });
4467
+ onComplete?.();
4468
+ setTimeout(() => {
4469
+ resetAll();
4470
+ }, resetTimer);
4471
+ } else {
4472
+ resetAll();
4485
4473
  }
4486
4474
  }
4487
4475
  });
4476
+ const textColor = color.interpolate({
4477
+ inputRange: [0, 1],
4478
+ outputRange: [sliderTextColor, "transparent"]
4479
+ });
4480
+ const backgroundColor = sliderBackgroundColorRef.interpolate({
4481
+ inputRange: [0, 1],
4482
+ outputRange: [sliderBackgroundColor, "transparent"]
4483
+ });
4488
4484
  const { theme } = useTheme();
4489
4485
  return /* @__PURE__ */ React.createElement(View, { style: {
4490
4486
  ...styles$3.sliderContainer,
4491
4487
  backgroundColor: theme.SURFACE_INVERTED,
4492
4488
  ...containerStyle
4493
- }, onLayout: handleLayout, ref: cardRef }, slideButtonTail && /* @__PURE__ */ React.createElement(
4489
+ }, onLayout: handleLayout, ref: cardRef }, /* @__PURE__ */ React.createElement(
4494
4490
  Animated.View,
4495
4491
  {
4496
- ref: slideTailCardRef,
4497
- style: [{ height: "100%", width: 0, backgroundColor: slideButtonTailColor }]
4492
+ style: [styles$3.buttonTextContainer, { backgroundColor, transform: [{ translateX }] }],
4493
+ ref: sliderConteinerRef
4498
4494
  }
4499
- ), /* @__PURE__ */ React.createElement(View, { style: styles$3.buttonTextContainer }, /* @__PURE__ */ React.createElement(
4500
- CustomTypography,
4495
+ ), /* @__PURE__ */ React.createElement(
4496
+ View,
4501
4497
  {
4502
- text: label,
4503
- variant: FontStyle.L1_REGULAR,
4504
- style: {
4505
- color: theme.CONTENT_INVERTED,
4506
- alignSelf: "center",
4507
- ...textStyle
4508
- }
4509
- }
4510
- )), /* @__PURE__ */ React.createElement(
4498
+ style: styles$3.buttonTextContainer
4499
+ },
4500
+ /* @__PURE__ */ React.createElement(Animated.Text, { style: [{
4501
+ alignSelf: "center",
4502
+ ...textStyle
4503
+ }, { color: textColor }] }, label)
4504
+ ), /* @__PURE__ */ React.createElement(
4511
4505
  Animated.View,
4512
4506
  {
4513
4507
  style: [styles$3.slider, { transform: [{ translateX }] }],