oa-componentbook 0.18.303 → 0.18.304
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.
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = CustomPinPatternCaptureWidget;
|
|
8
8
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
9
|
require("core-js/modules/es.json.stringify.js");
|
|
10
|
+
require("core-js/modules/es.string.trim.js");
|
|
10
11
|
require("core-js/modules/es.symbol.description.js");
|
|
11
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -53,7 +54,8 @@ function CustomPinPatternCaptureWidget(_ref) {
|
|
|
53
54
|
greyDisabledDots,
|
|
54
55
|
heading,
|
|
55
56
|
hideFooter,
|
|
56
|
-
showSequence
|
|
57
|
+
showSequence,
|
|
58
|
+
minAllowedlength
|
|
57
59
|
} = _ref;
|
|
58
60
|
const [pin, setPin] = (0, _react.useState)('');
|
|
59
61
|
const decreaseValueIndexbyOne = array => array.map(num => num - 1);
|
|
@@ -81,9 +83,22 @@ function CustomPinPatternCaptureWidget(_ref) {
|
|
|
81
83
|
setPattern((prePoPulatedPattern === null || prePoPulatedPattern === void 0 ? void 0 : prePoPulatedPattern.length) > 0 ? decreaseValueIndexbyOne(prePoPulatedPattern) : []);
|
|
82
84
|
setSavedPattern((prePoPulatedPattern === null || prePoPulatedPattern === void 0 ? void 0 : prePoPulatedPattern.length) > 0 ? decreaseValueIndexbyOne(prePoPulatedPattern) : []);
|
|
83
85
|
}, [prePoPulatedPattern]);
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Validates the PIN form and handles the submission of the PIN to the parent component.
|
|
89
|
+
* It checks if the PIN length is at least 4 characters, and if the confirm PIN matches the PIN.
|
|
90
|
+
* If the PIN is valid, it calls the finalPatternOrPassword callback with the PIN as the first argument.
|
|
91
|
+
*/
|
|
84
92
|
const handlePinSave = () => {
|
|
85
93
|
form.validateFields().then(values => {
|
|
86
94
|
// Passing the form data upto the parent.
|
|
95
|
+
if (values.confirmPin.length < minAllowedlength) {
|
|
96
|
+
form.setFields([{
|
|
97
|
+
name: 'pin',
|
|
98
|
+
errors: ['Pin/Pattern must be at least 4 characters long']
|
|
99
|
+
}]);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
87
102
|
if (values.pin !== values.confirmPin) {
|
|
88
103
|
form.setFields([{
|
|
89
104
|
name: 'confirmPin',
|
|
@@ -102,7 +117,7 @@ function CustomPinPatternCaptureWidget(_ref) {
|
|
|
102
117
|
|
|
103
118
|
// Pattern handling
|
|
104
119
|
const handleSubmitPatternComplete = () => {
|
|
105
|
-
if (pattern.length
|
|
120
|
+
if (pattern.length < minAllowedlength) {
|
|
106
121
|
setModalInfo({
|
|
107
122
|
heading: 'Short Pattern',
|
|
108
123
|
type: 'short-pattern',
|
|
@@ -172,6 +187,20 @@ function CustomPinPatternCaptureWidget(_ref) {
|
|
|
172
187
|
key: num
|
|
173
188
|
}, /*#__PURE__*/_react.default.createElement("span", null, num))));
|
|
174
189
|
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Helper function to check if a field has at least the minimum allowed length.
|
|
193
|
+
* If the length is less than the minimum allowed length, it sets an error on the field.
|
|
194
|
+
* @param {String} field - The name of the field to check.
|
|
195
|
+
*/
|
|
196
|
+
const checkIfMinLength = field => {
|
|
197
|
+
if (form.getFieldValue(field).length && form.getFieldValue(field).length < minAllowedlength) {
|
|
198
|
+
form.setFields([{
|
|
199
|
+
name: field,
|
|
200
|
+
errors: ['Pin/Pattern must be at least 4 characters long']
|
|
201
|
+
}]);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
175
204
|
/**
|
|
176
205
|
* Cancels the mismatch modal and resets the state.
|
|
177
206
|
*
|
|
@@ -227,14 +256,30 @@ function CustomPinPatternCaptureWidget(_ref) {
|
|
|
227
256
|
required: true,
|
|
228
257
|
message: 'Required'
|
|
229
258
|
}]
|
|
230
|
-
}, /*#__PURE__*/_react.default.createElement(_CustomInput.default,
|
|
259
|
+
}, /*#__PURE__*/_react.default.createElement(_CustomInput.default, {
|
|
260
|
+
onBlur: e => {
|
|
261
|
+
const trimmedValue = e.target.value.trim();
|
|
262
|
+
form.setFieldsValue({
|
|
263
|
+
pin: trimmedValue
|
|
264
|
+
});
|
|
265
|
+
checkIfMinLength('pin');
|
|
266
|
+
}
|
|
267
|
+
})), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
231
268
|
label: "Re-enter Pin/Password",
|
|
232
269
|
name: "confirmPin",
|
|
233
270
|
rules: [{
|
|
234
271
|
required: true,
|
|
235
272
|
message: 'Required'
|
|
236
273
|
}]
|
|
237
|
-
}, /*#__PURE__*/_react.default.createElement(_CustomInput.default,
|
|
274
|
+
}, /*#__PURE__*/_react.default.createElement(_CustomInput.default, {
|
|
275
|
+
onBlur: e => {
|
|
276
|
+
const trimmedValue = e.target.value.trim();
|
|
277
|
+
form.setFieldsValue({
|
|
278
|
+
confirmPin: trimmedValue
|
|
279
|
+
});
|
|
280
|
+
checkIfMinLength('confirmPin');
|
|
281
|
+
}
|
|
282
|
+
}))), /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
|
|
238
283
|
type: "primary",
|
|
239
284
|
onClick: handlePinSave,
|
|
240
285
|
label: "Save",
|
|
@@ -242,7 +287,7 @@ function CustomPinPatternCaptureWidget(_ref) {
|
|
|
242
287
|
}))) : /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
243
288
|
className: "flexAlignPattern"
|
|
244
289
|
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
245
|
-
className: "padding-bottom-8 padding-top-
|
|
290
|
+
className: "padding-bottom-8 padding-top-12"
|
|
246
291
|
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
247
292
|
color: "primary-content",
|
|
248
293
|
className: "type-t2-700"
|
|
@@ -314,7 +359,8 @@ CustomPinPatternCaptureWidget.propTypes = {
|
|
|
314
359
|
greyDisabledDots: _propTypes.default.bool,
|
|
315
360
|
heading: _propTypes.default.string,
|
|
316
361
|
hideFooter: _propTypes.default.bool,
|
|
317
|
-
showSequence: _propTypes.default.bool
|
|
362
|
+
showSequence: _propTypes.default.bool,
|
|
363
|
+
minAllowedlength: _propTypes.default.number
|
|
318
364
|
};
|
|
319
365
|
CustomPinPatternCaptureWidget.defaultProps = {
|
|
320
366
|
type: 'pattern',
|
|
@@ -326,5 +372,6 @@ CustomPinPatternCaptureWidget.defaultProps = {
|
|
|
326
372
|
greyDisabledDots: false,
|
|
327
373
|
heading: '',
|
|
328
374
|
hideFooter: false,
|
|
329
|
-
showSequence: true
|
|
375
|
+
showSequence: true,
|
|
376
|
+
minAllowedlength: 0
|
|
330
377
|
};
|