dhre-ui-kit 0.0.205 → 0.0.207

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
@@ -741,8 +741,11 @@ interface CustomSlideButtonProps {
741
741
  slideButtonTail?: boolean;
742
742
  slideButtonTailColor?: string;
743
743
  }
744
+ type SlideButtonHandle = {
745
+ reset?: () => void;
746
+ };
744
747
 
745
- declare const _default$2: (props: CustomSlideButtonProps) => React$1.JSX.Element;
748
+ declare const _default$2: (props: CustomSlideButtonProps & React$1.RefAttributes<SlideButtonHandle>) => React$1.JSX.Element;
746
749
 
747
750
  declare const width: number;
748
751
  declare const height: number;
package/lib/index.js CHANGED
@@ -3951,6 +3951,9 @@ const OTPInput = React__default["default"].forwardRef(
3951
3951
  const otpRegex = new RegExp(`(\\d{${length}})`, "g");
3952
3952
  const otp2 = otpRegex.exec(message)?.[1];
3953
3953
  setOTP(otp2 ?? "");
3954
+ if (otp2) {
3955
+ refs.current[otp2?.length - 1]?.focus();
3956
+ }
3954
3957
  });
3955
3958
  };
3956
3959
  React__default["default"].useImperativeHandle(ref, () => ({
@@ -3968,14 +3971,12 @@ const OTPInput = React__default["default"].forwardRef(
3968
3971
  if (value.length === 1 && regex.test(value) && index >= 0 && index < length) {
3969
3972
  const newOTP = `${otp}${value}`;
3970
3973
  setOTP(newOTP);
3971
- if (index < length - 1) {
3972
- refs.current[index + 1]?.focus();
3973
- }
3974
+ refs.current[index + 1]?.focus();
3974
3975
  } else if (value.length === 0 && index > 0) {
3975
3976
  const newOTP = otp.slice(0, -1);
3976
3977
  setOTP(newOTP);
3977
3978
  refs.current[index - 1]?.focus();
3978
- } else if (value.length === length) {
3979
+ } else if (value?.length === length) {
3979
3980
  setOTP(value);
3980
3981
  refs.current[length - 1]?.focus();
3981
3982
  } else {
@@ -4262,116 +4263,126 @@ const styles$3 = reactNative.StyleSheet.create({
4262
4263
  });
4263
4264
 
4264
4265
  const BUTTON_WIDTH = 40;
4265
- const CustomSlideButton = ({
4266
- label,
4267
- onComplete,
4268
- icon,
4269
- textStyle,
4270
- containerStyle,
4271
- sliderStyle,
4272
- size = BUTTON_WIDTH,
4273
- slideButtonTail,
4274
- slideButtonTailColor = "#fff"
4275
- }) => {
4276
- const value = React.useRef(0);
4277
- const cardRef = React.useRef(null);
4278
- const pan = React.useRef(new reactNative.Animated.Value(0)).current;
4279
- const slideTailCardRef = React.useRef(null);
4280
- slideTailCardRef?.current?.setNativeProps({
4281
- style: { width: 0 }
4282
- });
4283
- const handleLayout = (event) => {
4284
- const { width } = event.nativeEvent.layout;
4285
- if (cardRef.current) {
4286
- cardRef.current.setNativeProps({
4287
- style: { width }
4288
- // Change the width here
4289
- });
4290
- value.current = width;
4291
- }
4292
- };
4293
- const panResponder = React.useRef(
4294
- reactNative.PanResponder.create({
4295
- onMoveShouldSetPanResponder: (evt, gestureState) => {
4296
- return gestureState.dx > 0;
4297
- },
4298
- onPanResponderGrant: () => {
4299
- },
4300
- onPanResponderMove: (evt, gestureState) => {
4301
- if (gestureState.dx < value.current - BUTTON_WIDTH) {
4302
- pan.setValue(gestureState.dx);
4303
- slideTailCardRef?.current?.setNativeProps({
4304
- style: { width: gestureState.dx + BUTTON_WIDTH / 2 }
4305
- });
4306
- }
4307
- },
4308
- onPanResponderRelease: (evt, gestureState) => {
4309
- if (gestureState.dx > value.current - BUTTON_WIDTH - 100) {
4310
- onComplete && onComplete();
4311
- reactNative.Animated.spring(pan, {
4312
- toValue: value.current - BUTTON_WIDTH - 10,
4313
- useNativeDriver: false
4314
- }).start();
4315
- slideTailCardRef?.current?.setNativeProps({
4316
- style: { width: value.current + BUTTON_WIDTH }
4317
- // Change the width here
4318
- });
4319
- } else {
4320
- reactNative.Animated.spring(pan, {
4321
- toValue: 0,
4322
- useNativeDriver: false
4323
- }).start();
4324
- slideTailCardRef?.current?.setNativeProps({
4325
- style: { width: 0 }
4326
- });
4327
- }
4266
+ const CustomSlideButton = React__default["default"].forwardRef(
4267
+ ({
4268
+ label,
4269
+ onComplete,
4270
+ icon,
4271
+ textStyle,
4272
+ containerStyle,
4273
+ sliderStyle,
4274
+ size = BUTTON_WIDTH,
4275
+ slideButtonTail,
4276
+ slideButtonTailColor = "#fff"
4277
+ }, ref) => {
4278
+ const value = React.useRef(0);
4279
+ const cardRef = React.useRef(null);
4280
+ const pan = React.useRef(new reactNative.Animated.Value(0)).current;
4281
+ const slideTailCardRef = React.useRef(null);
4282
+ slideTailCardRef?.current?.setNativeProps({
4283
+ style: { width: 0 }
4284
+ });
4285
+ React__default["default"].useImperativeHandle(ref, () => ({
4286
+ reset() {
4287
+ reactNative.Animated.spring(pan, {
4288
+ toValue: 0,
4289
+ useNativeDriver: false
4290
+ }).start();
4328
4291
  }
4329
- })
4330
- ).current;
4331
- const { theme } = useTheme();
4332
- return /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: {
4333
- ...styles$3.sliderContainer,
4334
- backgroundColor: theme.SURFACE_INVERTED,
4335
- ...containerStyle
4336
- }, onLayout: handleLayout, ref: cardRef }, slideButtonTail && /* @__PURE__ */ React__default["default"].createElement(
4337
- reactNative.Animated.View,
4338
- {
4339
- ref: slideTailCardRef,
4340
- style: [{ height: "100%", backgroundColor: slideButtonTailColor }]
4341
- }
4342
- ), /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$3.buttonTextContainer }, /* @__PURE__ */ React__default["default"].createElement(
4343
- CustomTypography,
4344
- {
4345
- text: label,
4346
- variant: FontStyle.L1_REGULAR,
4347
- style: {
4348
- color: theme.CONTENT_INVERTED,
4349
- alignSelf: "center",
4350
- ...textStyle
4292
+ }));
4293
+ const handleLayout = (event) => {
4294
+ const { width } = event.nativeEvent.layout;
4295
+ if (cardRef.current) {
4296
+ cardRef.current.setNativeProps({
4297
+ style: { width }
4298
+ // Change the width here
4299
+ });
4300
+ value.current = width;
4351
4301
  }
4352
- }
4353
- )), /* @__PURE__ */ React__default["default"].createElement(
4354
- reactNative.Animated.View,
4355
- {
4356
- style: [styles$3.slider, { transform: [{ translateX: pan }] }],
4357
- ...panResponder.panHandlers
4358
- },
4359
- /* @__PURE__ */ React__default["default"].createElement(
4360
- reactNative.View,
4302
+ };
4303
+ const panResponder = React.useRef(
4304
+ reactNative.PanResponder.create({
4305
+ onMoveShouldSetPanResponder: (evt, gestureState) => {
4306
+ return gestureState.dx > 0;
4307
+ },
4308
+ onPanResponderGrant: () => {
4309
+ },
4310
+ onPanResponderMove: (evt, gestureState) => {
4311
+ if (gestureState.dx < value.current - BUTTON_WIDTH) {
4312
+ pan.setValue(gestureState.dx);
4313
+ slideTailCardRef?.current?.setNativeProps({
4314
+ style: { width: gestureState.dx + BUTTON_WIDTH / 2 }
4315
+ });
4316
+ }
4317
+ },
4318
+ onPanResponderRelease: (evt, gestureState) => {
4319
+ if (gestureState.dx > value.current - BUTTON_WIDTH - 100) {
4320
+ onComplete && onComplete();
4321
+ reactNative.Animated.spring(pan, {
4322
+ toValue: value.current - BUTTON_WIDTH - 10,
4323
+ useNativeDriver: false
4324
+ }).start();
4325
+ slideTailCardRef?.current?.setNativeProps({
4326
+ style: { width: value.current + BUTTON_WIDTH }
4327
+ // Change the width here
4328
+ });
4329
+ } else {
4330
+ reactNative.Animated.spring(pan, {
4331
+ toValue: 0,
4332
+ useNativeDriver: false
4333
+ }).start();
4334
+ slideTailCardRef?.current?.setNativeProps({
4335
+ style: { width: 0 }
4336
+ });
4337
+ }
4338
+ }
4339
+ })
4340
+ ).current;
4341
+ const { theme } = useTheme();
4342
+ return /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: {
4343
+ ...styles$3.sliderContainer,
4344
+ backgroundColor: theme.SURFACE_INVERTED,
4345
+ ...containerStyle
4346
+ }, onLayout: handleLayout, ref: cardRef }, slideButtonTail && /* @__PURE__ */ React__default["default"].createElement(
4347
+ reactNative.Animated.View,
4361
4348
  {
4349
+ ref: slideTailCardRef,
4350
+ style: [{ height: "100%", backgroundColor: slideButtonTailColor }]
4351
+ }
4352
+ ), /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$3.buttonTextContainer }, /* @__PURE__ */ React__default["default"].createElement(
4353
+ CustomTypography,
4354
+ {
4355
+ text: label,
4356
+ variant: FontStyle.L1_REGULAR,
4362
4357
  style: {
4363
- ...styles$3.button,
4364
- backgroundColor: theme.SURFACE_PRIMARY,
4365
- width: verticalScale(size),
4366
- height: verticalScale(size),
4367
- borderRadius: verticalScale(size / 2),
4368
- ...sliderStyle
4358
+ color: theme.CONTENT_INVERTED,
4359
+ alignSelf: "center",
4360
+ ...textStyle
4369
4361
  }
4362
+ }
4363
+ )), /* @__PURE__ */ React__default["default"].createElement(
4364
+ reactNative.Animated.View,
4365
+ {
4366
+ style: [styles$3.slider, { transform: [{ translateX: pan }] }],
4367
+ ...panResponder.panHandlers
4370
4368
  },
4371
- icon
4372
- )
4373
- ));
4374
- };
4369
+ /* @__PURE__ */ React__default["default"].createElement(
4370
+ reactNative.View,
4371
+ {
4372
+ style: {
4373
+ ...styles$3.button,
4374
+ backgroundColor: theme.SURFACE_PRIMARY,
4375
+ width: verticalScale(size),
4376
+ height: verticalScale(size),
4377
+ borderRadius: verticalScale(size / 2),
4378
+ ...sliderStyle
4379
+ }
4380
+ },
4381
+ icon
4382
+ )
4383
+ ));
4384
+ }
4385
+ );
4375
4386
  var index$2 = withThemeProvider(CustomSlideButton);
4376
4387
 
4377
4388
  const copyToClipboard = (textToCopy) => {