aport-tools 4.4.8 → 4.4.9

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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! aport-tools v4.4.8 | ISC */
1
+ /*! aport-tools v4.4.9 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -214,25 +214,35 @@ var Stepper = function Stepper(_a) {
214
214
  seterrorBack = _f[1];
215
215
  var handleStepPress = function handleStepPress(stepIndex) {
216
216
  return __awaiter(void 0, void 0, void 0, function () {
217
- var errors;
217
+ var current, target, errors;
218
218
  return __generator(this, function (_a) {
219
219
  switch (_a.label) {
220
220
  case 0:
221
221
  if (!presseable || stepIndex === currentStep) return [2 /*return*/];
222
- if (!(stepIndex > currentStep)) return [3 /*break*/, 2];
223
- return [4 /*yield*/, handleFormSubmit(formValues)];
222
+ current = currentStep;
223
+ target = stepIndex;
224
+ _a.label = 1;
224
225
  case 1:
226
+ if (!(current !== target)) return [3 /*break*/, 5];
227
+ if (!(target > current)) return [3 /*break*/, 3];
228
+ return [4 /*yield*/, handleFormSubmit(formValues)];
229
+ case 2:
225
230
  errors = _a.sent();
226
231
  if (Object.keys(errors).length > 0) {
227
- console.log("Validation failed. Cannot proceed to step", stepIndex);
232
+ console.log("Validation failed at step ".concat(current + 1, ". Cannot proceed to step ").concat(current + 2, "."));
228
233
  seterrorBack(true);
229
- return [2 /*return*/]; // Prevent step change
234
+ return [2 /*return*/]; // Stop at the first invalid step
230
235
  }
231
- _a.label = 2;
232
- case 2:
233
- // Proceed to change step
234
236
  seterrorBack(false);
235
- onPress === null || onPress === void 0 ? void 0 : onPress(stepIndex);
237
+ current += 1; // Move to the next step
238
+ return [3 /*break*/, 4];
239
+ case 3:
240
+ current -= 1;
241
+ _a.label = 4;
242
+ case 4:
243
+ onPress === null || onPress === void 0 ? void 0 : onPress(current);
244
+ return [3 /*break*/, 1];
245
+ case 5:
236
246
  return [2 /*return*/];
237
247
  }
238
248
  });
@@ -328,7 +338,7 @@ var Stepper = function Stepper(_a) {
328
338
  }
329
339
  }, /*#__PURE__*/React.createElement(reactNative.View, {
330
340
  style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, {
331
- backgroundColor: currentStep >= index ? colors.primary.hex : !errorBack ? colors.body.hex : colors.error.hex
341
+ backgroundColor: currentStep >= index ? !errorBack ? colors.primary.hex : colors.error.hex : colors.body.hex
332
342
  }]
333
343
  }, renderStepContent(index)), steps && /*#__PURE__*/React.createElement(Text, {
334
344
  style: styles$9.stepText