@hero-design/rn 8.64.6 → 8.64.7-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 +9 -7
- package/lib/index.js +9 -7
- package/package.json +3 -2
- package/src/components/PinInput/index.tsx +10 -7
- package/.turbo/turbo-build.log +0 -5
package/es/index.js
CHANGED
|
@@ -15609,7 +15609,8 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
15609
15609
|
disabled: disabled,
|
|
15610
15610
|
error: error
|
|
15611
15611
|
});
|
|
15612
|
-
var
|
|
15612
|
+
var trimmedValue = ((value === null || value === void 0 ? void 0 : value.match(/\d/g)) || []).join('').slice(0, length);
|
|
15613
|
+
var maskedValueWithExtraSpace = Platform.OS === 'android' && !trimmedValue ? '*' : trimmedValue;
|
|
15613
15614
|
var focus = useCallback(function () {
|
|
15614
15615
|
if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
|
|
15615
15616
|
inputRef.current.focus();
|
|
@@ -15624,9 +15625,11 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
15624
15625
|
}, []);
|
|
15625
15626
|
var changeText = useCallback(function (text) {
|
|
15626
15627
|
var pin = (text.match(/\d/g) || []).join('');
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
|
|
15628
|
+
// Prevent user from entering more than the length
|
|
15629
|
+
var trimmedPin = pin.slice(0, length);
|
|
15630
|
+
onChangeText === null || onChangeText === void 0 || onChangeText(trimmedPin);
|
|
15631
|
+
if (trimmedPin.length === length) {
|
|
15632
|
+
onFulfill === null || onFulfill === void 0 || onFulfill(trimmedPin);
|
|
15630
15633
|
}
|
|
15631
15634
|
}, [length, onChangeText, onFulfill]);
|
|
15632
15635
|
useEffect(function () {
|
|
@@ -15648,9 +15651,9 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
15648
15651
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
|
|
15649
15652
|
key: index
|
|
15650
15653
|
}, index !== 0 && /*#__PURE__*/React__default.createElement(StyledSpacer, null), /*#__PURE__*/React__default.createElement(PinCell, {
|
|
15651
|
-
value:
|
|
15654
|
+
value: trimmedValue.charAt(index),
|
|
15652
15655
|
secure: secure,
|
|
15653
|
-
focused: focused && index ===
|
|
15656
|
+
focused: focused && index === trimmedValue.length,
|
|
15654
15657
|
state: state
|
|
15655
15658
|
}));
|
|
15656
15659
|
})), state === 'error' && /*#__PURE__*/React__default.createElement(StyledErrorContainer, null, /*#__PURE__*/React__default.createElement(Icon, {
|
|
@@ -15668,7 +15671,6 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
15668
15671
|
autoFocus: autoFocus,
|
|
15669
15672
|
onFocus: focus,
|
|
15670
15673
|
onBlur: blur,
|
|
15671
|
-
maxLength: length,
|
|
15672
15674
|
pointerEvents: "box-none",
|
|
15673
15675
|
keyboardType: "numeric",
|
|
15674
15676
|
testID: "pin-hidden-input",
|
package/lib/index.js
CHANGED
|
@@ -15639,7 +15639,8 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
15639
15639
|
disabled: disabled,
|
|
15640
15640
|
error: error
|
|
15641
15641
|
});
|
|
15642
|
-
var
|
|
15642
|
+
var trimmedValue = ((value === null || value === void 0 ? void 0 : value.match(/\d/g)) || []).join('').slice(0, length);
|
|
15643
|
+
var maskedValueWithExtraSpace = reactNative.Platform.OS === 'android' && !trimmedValue ? '*' : trimmedValue;
|
|
15643
15644
|
var focus = React.useCallback(function () {
|
|
15644
15645
|
if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
|
|
15645
15646
|
inputRef.current.focus();
|
|
@@ -15654,9 +15655,11 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
15654
15655
|
}, []);
|
|
15655
15656
|
var changeText = React.useCallback(function (text) {
|
|
15656
15657
|
var pin = (text.match(/\d/g) || []).join('');
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15658
|
+
// Prevent user from entering more than the length
|
|
15659
|
+
var trimmedPin = pin.slice(0, length);
|
|
15660
|
+
onChangeText === null || onChangeText === void 0 || onChangeText(trimmedPin);
|
|
15661
|
+
if (trimmedPin.length === length) {
|
|
15662
|
+
onFulfill === null || onFulfill === void 0 || onFulfill(trimmedPin);
|
|
15660
15663
|
}
|
|
15661
15664
|
}, [length, onChangeText, onFulfill]);
|
|
15662
15665
|
React.useEffect(function () {
|
|
@@ -15678,9 +15681,9 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
15678
15681
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
|
|
15679
15682
|
key: index
|
|
15680
15683
|
}, index !== 0 && /*#__PURE__*/React__default["default"].createElement(StyledSpacer, null), /*#__PURE__*/React__default["default"].createElement(PinCell, {
|
|
15681
|
-
value:
|
|
15684
|
+
value: trimmedValue.charAt(index),
|
|
15682
15685
|
secure: secure,
|
|
15683
|
-
focused: focused && index ===
|
|
15686
|
+
focused: focused && index === trimmedValue.length,
|
|
15684
15687
|
state: state
|
|
15685
15688
|
}));
|
|
15686
15689
|
})), state === 'error' && /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer, null, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
@@ -15698,7 +15701,6 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
15698
15701
|
autoFocus: autoFocus,
|
|
15699
15702
|
onFocus: focus,
|
|
15700
15703
|
onBlur: blur,
|
|
15701
|
-
maxLength: length,
|
|
15702
15704
|
pointerEvents: "box-none",
|
|
15703
15705
|
keyboardType: "numeric",
|
|
15704
15706
|
testID: "pin-hidden-input",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.64.
|
|
3
|
+
"version": "8.64.7-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
|
}
|
|
@@ -121,8 +121,10 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
|
|
|
121
121
|
const inputRef = useRef<TextInput>(null);
|
|
122
122
|
const [focused, setFocused] = useState(autoFocus);
|
|
123
123
|
const state = getState({ disabled, error });
|
|
124
|
+
const trimmedValue = (value?.match(/\d/g) || []).join('').slice(0, length);
|
|
125
|
+
|
|
124
126
|
const maskedValueWithExtraSpace =
|
|
125
|
-
Platform.OS === 'android' && !
|
|
127
|
+
Platform.OS === 'android' && !trimmedValue ? '*' : trimmedValue;
|
|
126
128
|
|
|
127
129
|
const focus = useCallback(() => {
|
|
128
130
|
if (inputRef?.current) {
|
|
@@ -141,11 +143,13 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
|
|
|
141
143
|
const changeText = useCallback(
|
|
142
144
|
(text: string) => {
|
|
143
145
|
const pin = (text.match(/\d/g) || []).join('');
|
|
146
|
+
// Prevent user from entering more than the length
|
|
147
|
+
const trimmedPin = pin.slice(0, length);
|
|
144
148
|
|
|
145
|
-
onChangeText?.(
|
|
149
|
+
onChangeText?.(trimmedPin);
|
|
146
150
|
|
|
147
|
-
if (
|
|
148
|
-
onFulfill?.(
|
|
151
|
+
if (trimmedPin.length === length) {
|
|
152
|
+
onFulfill?.(trimmedPin);
|
|
149
153
|
}
|
|
150
154
|
},
|
|
151
155
|
[length, onChangeText, onFulfill]
|
|
@@ -170,9 +174,9 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
|
|
|
170
174
|
<React.Fragment key={index}>
|
|
171
175
|
{index !== 0 && <StyledSpacer />}
|
|
172
176
|
<PinCell
|
|
173
|
-
value={
|
|
177
|
+
value={trimmedValue.charAt(index)}
|
|
174
178
|
secure={secure}
|
|
175
|
-
focused={focused && index ===
|
|
179
|
+
focused={focused && index === trimmedValue.length}
|
|
176
180
|
state={state}
|
|
177
181
|
/>
|
|
178
182
|
</React.Fragment>
|
|
@@ -199,7 +203,6 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
|
|
|
199
203
|
autoFocus={autoFocus}
|
|
200
204
|
onFocus={focus}
|
|
201
205
|
onBlur={blur}
|
|
202
|
-
maxLength={length}
|
|
203
206
|
pointerEvents="box-none"
|
|
204
207
|
keyboardType="numeric"
|
|
205
208
|
testID="pin-hidden-input"
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
[36m
|
|
2
|
-
[1msrc/index.ts[22m → [1mlib/index.js, es/index.js[22m...[39m
|
|
3
|
-
[1m[33m(!) 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`.[39m[22m
|
|
4
|
-
[1m[33m(!) 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[39m[22m
|
|
5
|
-
[32mcreated [1mlib/index.js, es/index.js[22m in [1m1m 1.2s[22m[39m
|