dhre-ui-kit 0.0.190 → 0.0.192

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 CHANGED
@@ -629,6 +629,8 @@ interface CustomDropdownProps {
629
629
  itemTextStyle?: TextStyle;
630
630
  onValueChange?: (value: string) => void;
631
631
  itemContainerStyle?: ViewStyle;
632
+ keepPlaceholderOnFocus?: boolean;
633
+ selectedItemTextStyle?: TextStyle;
632
634
  menuContainerStyle?: ViewStyle;
633
635
  activeColor?: string;
634
636
  renderRightIcon?: (visible?: boolean) => JSX.Element | null | undefined;
@@ -704,7 +706,8 @@ interface IProps$1 {
704
706
  mode?: 'light' | 'dark';
705
707
  }
706
708
  type OTPInputHandle = {
707
- reset: () => void;
709
+ reset?: () => void;
710
+ set?: (newOtp: string) => void;
708
711
  };
709
712
 
710
713
  declare const _default$4: (props: IProps$1 & React$1.RefAttributes<OTPInputHandle>) => React$1.JSX.Element;
@@ -733,6 +736,8 @@ interface CustomSlideButtonProps {
733
736
  textStyle?: TextStyle;
734
737
  containerStyle?: ViewStyle;
735
738
  sliderStyle?: ViewStyle;
739
+ slideButtonTail?: boolean;
740
+ slideButtonTailColor?: string;
736
741
  }
737
742
 
738
743
  declare const _default$2: (props: CustomSlideButtonProps) => React$1.JSX.Element;
package/lib/index.js CHANGED
@@ -3418,7 +3418,9 @@ const CustomDropdown = (props) => {
3418
3418
  onValueChange,
3419
3419
  itemContainerStyle,
3420
3420
  menuContainerStyle,
3421
- activeColor
3421
+ activeColor,
3422
+ keepPlaceholderOnFocus = false,
3423
+ selectedItemTextStyle
3422
3424
  } = props;
3423
3425
  const [value, setValue] = React.useState(defaultValue);
3424
3426
  const [isFocus, setIsFocus] = React.useState(false);
@@ -3446,6 +3448,22 @@ const CustomDropdown = (props) => {
3446
3448
  onValueChange(newValue);
3447
3449
  }
3448
3450
  };
3451
+ const renderItem = (item) => {
3452
+ const isSelected = item[valueField] === value;
3453
+ return /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: [styles$7.itemContainer, itemContainerStyle] }, /* @__PURE__ */ React__default["default"].createElement(
3454
+ reactNative.Text,
3455
+ {
3456
+ style: [
3457
+ styles$7.itemText,
3458
+ itemTextStyle,
3459
+ // Apply itemTextStyle to all items
3460
+ isSelected && selectedItemTextStyle
3461
+ // Apply selectedItemTextStyle to the selected item
3462
+ ]
3463
+ },
3464
+ item[labelField]
3465
+ ));
3466
+ };
3449
3467
  return /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: [styles$7.container, containerStyle] }, label && renderLabel(), /* @__PURE__ */ React__default["default"].createElement(
3450
3468
  reactNativeElementDropdown.Dropdown,
3451
3469
  {
@@ -3461,13 +3479,14 @@ const CustomDropdown = (props) => {
3461
3479
  data: data ?? [],
3462
3480
  labelField,
3463
3481
  valueField,
3464
- placeholder: !isFocus ? placeholder : "",
3482
+ placeholder: keepPlaceholderOnFocus || !isFocus ? placeholder : "",
3465
3483
  value,
3466
3484
  onFocus: () => setIsFocus(true),
3467
3485
  onBlur: () => setIsFocus(false),
3468
3486
  onChange: handleValueChange,
3469
3487
  iconColor,
3470
3488
  dropdownPosition: "bottom",
3489
+ renderItem,
3471
3490
  itemTextStyle,
3472
3491
  containerStyle: menuContainerStyle,
3473
3492
  activeColor,
@@ -3510,6 +3529,13 @@ const styles$7 = reactNative.StyleSheet.create({
3510
3529
  },
3511
3530
  itemListStyle: {
3512
3531
  maxHeight: verticalScale(150)
3532
+ },
3533
+ itemContainer: {
3534
+ paddingVertical: verticalScale(8),
3535
+ paddingHorizontal: horizontalScale(12)
3536
+ },
3537
+ itemText: {
3538
+ fontSize: verticalScale(14)
3513
3539
  }
3514
3540
  });
3515
3541
 
@@ -3892,6 +3918,11 @@ const OTPInput = React__default["default"].forwardRef(
3892
3918
  React__default["default"].useImperativeHandle(ref, () => ({
3893
3919
  reset() {
3894
3920
  setOTP("");
3921
+ refs.current[0]?.focus();
3922
+ },
3923
+ set(newOtp) {
3924
+ setOTP(newOtp);
3925
+ refs.current[newOtp?.length - 1]?.focus();
3895
3926
  }
3896
3927
  }));
3897
3928
  const handleChange = (index, value) => {
@@ -3904,6 +3935,9 @@ const OTPInput = React__default["default"].forwardRef(
3904
3935
  const newOTP = otp.slice(0, -1);
3905
3936
  setOTP(newOTP);
3906
3937
  refs.current[index - 1]?.focus();
3938
+ } else if (value?.length === length) {
3939
+ setOTP(value);
3940
+ refs.current[length - 1]?.focus();
3907
3941
  } else {
3908
3942
  const newOTP = otp.slice(0, -1);
3909
3943
  setOTP(newOTP);
@@ -3950,6 +3984,9 @@ const OTPInput = React__default["default"].forwardRef(
3950
3984
  keyboardType: "numeric",
3951
3985
  ref: (el) => refs.current[index] = el,
3952
3986
  returnKeyType: otp.length === length ? "done" : "next",
3987
+ importantForAutofill: "yes",
3988
+ textContentType: "oneTimeCode",
3989
+ autoComplete: "sms-otp",
3953
3990
  selectionColor: theme$1.CONTENT_PRIMARY
3954
3991
  }
3955
3992
  ))), /* @__PURE__ */ React__default["default"].createElement(
@@ -4192,11 +4229,17 @@ const CustomSlideButton = ({
4192
4229
  textStyle,
4193
4230
  containerStyle,
4194
4231
  sliderStyle,
4195
- size = BUTTON_WIDTH
4232
+ size = BUTTON_WIDTH,
4233
+ slideButtonTail,
4234
+ slideButtonTailColor = "#fff"
4196
4235
  }) => {
4197
4236
  const value = React.useRef(0);
4198
4237
  const cardRef = React.useRef(null);
4199
4238
  const pan = React.useRef(new reactNative.Animated.Value(0)).current;
4239
+ const slideTailCardRef = React.useRef(null);
4240
+ slideTailCardRef?.current?.setNativeProps({
4241
+ style: { width: 0 }
4242
+ });
4200
4243
  const handleLayout = (event) => {
4201
4244
  const { width } = event.nativeEvent.layout;
4202
4245
  if (cardRef.current) {
@@ -4217,6 +4260,9 @@ const CustomSlideButton = ({
4217
4260
  onPanResponderMove: (evt, gestureState) => {
4218
4261
  if (gestureState.dx < value.current - BUTTON_WIDTH) {
4219
4262
  pan.setValue(gestureState.dx);
4263
+ slideTailCardRef?.current?.setNativeProps({
4264
+ style: { width: gestureState.dx + BUTTON_WIDTH / 2 }
4265
+ });
4220
4266
  }
4221
4267
  },
4222
4268
  onPanResponderRelease: (evt, gestureState) => {
@@ -4226,11 +4272,18 @@ const CustomSlideButton = ({
4226
4272
  toValue: value.current - BUTTON_WIDTH - 10,
4227
4273
  useNativeDriver: false
4228
4274
  }).start();
4275
+ slideTailCardRef?.current?.setNativeProps({
4276
+ style: { width: value.current + BUTTON_WIDTH }
4277
+ // Change the width here
4278
+ });
4229
4279
  } else {
4230
4280
  reactNative.Animated.spring(pan, {
4231
4281
  toValue: 0,
4232
4282
  useNativeDriver: false
4233
4283
  }).start();
4284
+ slideTailCardRef?.current?.setNativeProps({
4285
+ style: { width: 0 }
4286
+ });
4234
4287
  }
4235
4288
  }
4236
4289
  })
@@ -4240,7 +4293,13 @@ const CustomSlideButton = ({
4240
4293
  ...styles$2.sliderContainer,
4241
4294
  backgroundColor: theme.SURFACE_INVERTED,
4242
4295
  ...containerStyle
4243
- }, onLayout: handleLayout, ref: cardRef }, /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$2.buttonTextContainer }, /* @__PURE__ */ React__default["default"].createElement(
4296
+ }, onLayout: handleLayout, ref: cardRef }, slideButtonTail && /* @__PURE__ */ React__default["default"].createElement(
4297
+ reactNative.Animated.View,
4298
+ {
4299
+ ref: slideTailCardRef,
4300
+ style: [{ height: "100%", backgroundColor: slideButtonTailColor }]
4301
+ }
4302
+ ), /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$2.buttonTextContainer }, /* @__PURE__ */ React__default["default"].createElement(
4244
4303
  CustomTypography,
4245
4304
  {
4246
4305
  text: label,