@hero-design/rn 8.64.8 → 8.64.9-alpha.0

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/es/index.js CHANGED
@@ -2885,7 +2885,7 @@ var getPinInputTheme = function getPinInputTheme(theme) {
2885
2885
  var space = {
2886
2886
  spacer: theme.space.medium,
2887
2887
  errorMessagePadding: theme.space.xsmall,
2888
- hiddenInputText: theme.space.xlarge,
2888
+ hiddenInputText: theme.space.xsmall,
2889
2889
  hiddenInputHorrizontalPadding: theme.space.small
2890
2890
  };
2891
2891
  var radii = {
@@ -15526,6 +15526,7 @@ var StyledHiddenInput = index$9(TextInput$1)(function (_ref6) {
15526
15526
  top: 0,
15527
15527
  right: 0,
15528
15528
  width: themePinLength * cellWidth + (themePinLength - 1) * spacerWidth,
15529
+ overflow: 'hidden',
15529
15530
  height: '100%',
15530
15531
  fontSize: theme.__hd__.pinInput.fontSizes.hiddenInputText,
15531
15532
  letterSpacing: theme.__hd__.pinInput.space.hiddenInputText,
@@ -15615,7 +15616,6 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
15615
15616
  error: error
15616
15617
  });
15617
15618
  var trimmedValue = normalizeValue(value, length);
15618
- var maskedValueWithExtraSpace = Platform.OS === 'android' && !trimmedValue ? '*' : trimmedValue;
15619
15619
  var focus = useCallback(function () {
15620
15620
  if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
15621
15621
  inputRef.current.focus();
@@ -15629,13 +15629,20 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
15629
15629
  }
15630
15630
  }, []);
15631
15631
  var changeText = useCallback(function (text) {
15632
- // Prevent user from entering more than the length
15633
15632
  var trimmedPin = normalizeValue(text, length);
15634
- onChangeText === null || onChangeText === void 0 || onChangeText(trimmedPin);
15633
+ // If current value is already the length, replace it with the new text, starting from the length
15634
+ if (trimmedValue.length === length && trimmedValue.length <= text.length) {
15635
+ // Slice the text, starting from the length position
15636
+ var slicedText = text.slice(length);
15637
+ onChangeText === null || onChangeText === void 0 || onChangeText(normalizeValue(slicedText, length));
15638
+ } else {
15639
+ // Prevent user from entering more than the length
15640
+ onChangeText === null || onChangeText === void 0 || onChangeText(trimmedPin);
15641
+ }
15635
15642
  if (trimmedPin.length === length) {
15636
15643
  onFulfill === null || onFulfill === void 0 || onFulfill(trimmedPin);
15637
15644
  }
15638
- }, [length, onChangeText, onFulfill]);
15645
+ }, [length, onChangeText, onFulfill, trimmedValue.length]);
15639
15646
  useEffect(function () {
15640
15647
  // Must run after animations for keyboard to automatically open
15641
15648
  if (autoFocus) {
@@ -15668,7 +15675,7 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
15668
15675
  }), /*#__PURE__*/React__default.createElement(StyledErrorMessage, null, error)), /*#__PURE__*/React__default.createElement(StyledHiddenInput, {
15669
15676
  themePinLength: length,
15670
15677
  ref: inputRef,
15671
- value: maskedValueWithExtraSpace,
15678
+ value: trimmedValue,
15672
15679
  onChangeText: changeText,
15673
15680
  secureTextEntry: secure,
15674
15681
  editable: !disabled,
@@ -15680,7 +15687,11 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
15680
15687
  testID: "pin-hidden-input",
15681
15688
  textContentType: textContentType,
15682
15689
  autoComplete: autoComplete,
15683
- selectTextOnFocus: false
15690
+ selectTextOnFocus: false,
15691
+ selection: {
15692
+ start: trimmedValue.length,
15693
+ end: trimmedValue.length + 1
15694
+ }
15684
15695
  }));
15685
15696
  });
15686
15697
  PinInput.displayName = 'PinInput';
package/lib/index.js CHANGED
@@ -2915,7 +2915,7 @@ var getPinInputTheme = function getPinInputTheme(theme) {
2915
2915
  var space = {
2916
2916
  spacer: theme.space.medium,
2917
2917
  errorMessagePadding: theme.space.xsmall,
2918
- hiddenInputText: theme.space.xlarge,
2918
+ hiddenInputText: theme.space.xsmall,
2919
2919
  hiddenInputHorrizontalPadding: theme.space.small
2920
2920
  };
2921
2921
  var radii = {
@@ -15556,6 +15556,7 @@ var StyledHiddenInput = index$9(reactNative.TextInput)(function (_ref6) {
15556
15556
  top: 0,
15557
15557
  right: 0,
15558
15558
  width: themePinLength * cellWidth + (themePinLength - 1) * spacerWidth,
15559
+ overflow: 'hidden',
15559
15560
  height: '100%',
15560
15561
  fontSize: theme.__hd__.pinInput.fontSizes.hiddenInputText,
15561
15562
  letterSpacing: theme.__hd__.pinInput.space.hiddenInputText,
@@ -15645,7 +15646,6 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
15645
15646
  error: error
15646
15647
  });
15647
15648
  var trimmedValue = normalizeValue(value, length);
15648
- var maskedValueWithExtraSpace = reactNative.Platform.OS === 'android' && !trimmedValue ? '*' : trimmedValue;
15649
15649
  var focus = React.useCallback(function () {
15650
15650
  if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
15651
15651
  inputRef.current.focus();
@@ -15659,13 +15659,20 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
15659
15659
  }
15660
15660
  }, []);
15661
15661
  var changeText = React.useCallback(function (text) {
15662
- // Prevent user from entering more than the length
15663
15662
  var trimmedPin = normalizeValue(text, length);
15664
- onChangeText === null || onChangeText === void 0 || onChangeText(trimmedPin);
15663
+ // If current value is already the length, replace it with the new text, starting from the length
15664
+ if (trimmedValue.length === length && trimmedValue.length <= text.length) {
15665
+ // Slice the text, starting from the length position
15666
+ var slicedText = text.slice(length);
15667
+ onChangeText === null || onChangeText === void 0 || onChangeText(normalizeValue(slicedText, length));
15668
+ } else {
15669
+ // Prevent user from entering more than the length
15670
+ onChangeText === null || onChangeText === void 0 || onChangeText(trimmedPin);
15671
+ }
15665
15672
  if (trimmedPin.length === length) {
15666
15673
  onFulfill === null || onFulfill === void 0 || onFulfill(trimmedPin);
15667
15674
  }
15668
- }, [length, onChangeText, onFulfill]);
15675
+ }, [length, onChangeText, onFulfill, trimmedValue.length]);
15669
15676
  React.useEffect(function () {
15670
15677
  // Must run after animations for keyboard to automatically open
15671
15678
  if (autoFocus) {
@@ -15698,7 +15705,7 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
15698
15705
  }), /*#__PURE__*/React__default["default"].createElement(StyledErrorMessage, null, error)), /*#__PURE__*/React__default["default"].createElement(StyledHiddenInput, {
15699
15706
  themePinLength: length,
15700
15707
  ref: inputRef,
15701
- value: maskedValueWithExtraSpace,
15708
+ value: trimmedValue,
15702
15709
  onChangeText: changeText,
15703
15710
  secureTextEntry: secure,
15704
15711
  editable: !disabled,
@@ -15710,7 +15717,11 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
15710
15717
  testID: "pin-hidden-input",
15711
15718
  textContentType: textContentType,
15712
15719
  autoComplete: autoComplete,
15713
- selectTextOnFocus: false
15720
+ selectTextOnFocus: false,
15721
+ selection: {
15722
+ start: trimmedValue.length,
15723
+ end: trimmedValue.length + 1
15724
+ }
15714
15725
  }));
15715
15726
  });
15716
15727
  PinInput.displayName = 'PinInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.64.8",
3
+ "version": "8.64.9-alpha.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -93,5 +93,6 @@
93
93
  "ts-jest": "^29.1.1",
94
94
  "typescript": "4.8.4"
95
95
  },
96
- "prettier": "prettier-config-hd"
96
+ "prettier": "prettier-config-hd",
97
+ "react-native": "src/index.ts"
97
98
  }
@@ -70,6 +70,7 @@ export const StyledHiddenInput = styled(TextInput)<{ themePinLength: number }>(
70
70
  top: 0,
71
71
  right: 0,
72
72
  width: themePinLength * cellWidth + (themePinLength - 1) * spacerWidth,
73
+ overflow: 'hidden',
73
74
  height: '100%',
74
75
  fontSize: theme.__hd__.pinInput.fontSizes.hiddenInputText,
75
76
  letterSpacing: theme.__hd__.pinInput.space.hiddenInputText,
@@ -7,7 +7,7 @@ import React, {
7
7
  useRef,
8
8
  useState,
9
9
  } from 'react';
10
- import { InteractionManager, Platform, TextInput } from 'react-native';
10
+ import { InteractionManager, TextInput } from 'react-native';
11
11
  import type { StyleProp, ViewStyle } from 'react-native';
12
12
  import Icon from '../Icon';
13
13
  import PinCell from './PinCell';
@@ -127,9 +127,6 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
127
127
  const state = getState({ disabled, error });
128
128
  const trimmedValue = normalizeValue(value, length);
129
129
 
130
- const maskedValueWithExtraSpace =
131
- Platform.OS === 'android' && !trimmedValue ? '*' : trimmedValue;
132
-
133
130
  const focus = useCallback(() => {
134
131
  if (inputRef?.current) {
135
132
  inputRef.current.focus();
@@ -143,19 +140,29 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
143
140
  setFocused(false);
144
141
  }
145
142
  }, []);
146
-
147
143
  const changeText = useCallback(
148
144
  (text: string) => {
149
- // Prevent user from entering more than the length
150
145
  const trimmedPin = normalizeValue(text, length);
151
146
 
152
- onChangeText?.(trimmedPin);
147
+ // If current value is already the length, replace it with the new text, starting from the length
148
+ if (
149
+ trimmedValue.length === length &&
150
+ trimmedValue.length <= text.length
151
+ ) {
152
+ // Slice the text, starting from the length position
153
+ const slicedText = text.slice(length);
154
+
155
+ onChangeText?.(normalizeValue(slicedText, length));
156
+ } else {
157
+ // Prevent user from entering more than the length
158
+ onChangeText?.(trimmedPin);
159
+ }
153
160
 
154
161
  if (trimmedPin.length === length) {
155
162
  onFulfill?.(trimmedPin);
156
163
  }
157
164
  },
158
- [length, onChangeText, onFulfill]
165
+ [length, onChangeText, onFulfill, trimmedValue.length]
159
166
  );
160
167
 
161
168
  useEffect(() => {
@@ -199,7 +206,7 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
199
206
  <StyledHiddenInput
200
207
  themePinLength={length}
201
208
  ref={inputRef}
202
- value={maskedValueWithExtraSpace}
209
+ value={trimmedValue}
203
210
  onChangeText={changeText}
204
211
  secureTextEntry={secure}
205
212
  editable={!disabled}
@@ -212,6 +219,10 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
212
219
  textContentType={textContentType}
213
220
  autoComplete={autoComplete}
214
221
  selectTextOnFocus={false}
222
+ selection={{
223
+ start: trimmedValue.length,
224
+ end: trimmedValue.length + 1,
225
+ }}
215
226
  />
216
227
  </StyledWrapper>
217
228
  );
@@ -37,7 +37,7 @@ const getPinInputTheme = (theme: GlobalTheme) => {
37
37
  const space = {
38
38
  spacer: theme.space.medium,
39
39
  errorMessagePadding: theme.space.xsmall,
40
- hiddenInputText: theme.space.xlarge,
40
+ hiddenInputText: theme.space.xsmall,
41
41
  hiddenInputHorrizontalPadding: theme.space.small,
42
42
  };
43
43
 
@@ -4840,3 +4840,5 @@ var drawChart = (function (exports) {
4840
4840
  </body>
4841
4841
  </html>
4842
4842
 
4843
+ >
4844
+
@@ -1,5 +0,0 @@
1
- 
2
- src/index.ts → lib/index.js, es/index.js...
3
- (!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
4
- (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
5
- created lib/index.js, es/index.js in 1m 2.7s