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.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! aport-tools v4.4.8 | ISC */
1
+ /*! aport-tools v4.4.9 | ISC */
2
2
  import React, { useContext, useState, createContext, useCallback, useMemo } from 'react';
3
3
  import { StyleSheet, Text as Text$1, Animated, View, TouchableOpacity, Image, TextInput, Modal, Pressable, FlatList, Keyboard, Platform, Alert, ActivityIndicator } from 'react-native';
4
4
  import { ThemeContext } from 'aport-themes';
@@ -193,25 +193,35 @@ var Stepper = function Stepper(_a) {
193
193
  seterrorBack = _f[1];
194
194
  var handleStepPress = function handleStepPress(stepIndex) {
195
195
  return __awaiter(void 0, void 0, void 0, function () {
196
- var errors;
196
+ var current, target, errors;
197
197
  return __generator(this, function (_a) {
198
198
  switch (_a.label) {
199
199
  case 0:
200
200
  if (!presseable || stepIndex === currentStep) return [2 /*return*/];
201
- if (!(stepIndex > currentStep)) return [3 /*break*/, 2];
202
- return [4 /*yield*/, handleFormSubmit(formValues)];
201
+ current = currentStep;
202
+ target = stepIndex;
203
+ _a.label = 1;
203
204
  case 1:
205
+ if (!(current !== target)) return [3 /*break*/, 5];
206
+ if (!(target > current)) return [3 /*break*/, 3];
207
+ return [4 /*yield*/, handleFormSubmit(formValues)];
208
+ case 2:
204
209
  errors = _a.sent();
205
210
  if (Object.keys(errors).length > 0) {
206
- console.log("Validation failed. Cannot proceed to step", stepIndex);
211
+ console.log("Validation failed at step ".concat(current + 1, ". Cannot proceed to step ").concat(current + 2, "."));
207
212
  seterrorBack(true);
208
- return [2 /*return*/]; // Prevent step change
213
+ return [2 /*return*/]; // Stop at the first invalid step
209
214
  }
210
- _a.label = 2;
211
- case 2:
212
- // Proceed to change step
213
215
  seterrorBack(false);
214
- onPress === null || onPress === void 0 ? void 0 : onPress(stepIndex);
216
+ current += 1; // Move to the next step
217
+ return [3 /*break*/, 4];
218
+ case 3:
219
+ current -= 1;
220
+ _a.label = 4;
221
+ case 4:
222
+ onPress === null || onPress === void 0 ? void 0 : onPress(current);
223
+ return [3 /*break*/, 1];
224
+ case 5:
215
225
  return [2 /*return*/];
216
226
  }
217
227
  });
@@ -307,7 +317,7 @@ var Stepper = function Stepper(_a) {
307
317
  }
308
318
  }, /*#__PURE__*/React.createElement(View, {
309
319
  style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, {
310
- backgroundColor: currentStep >= index ? colors.primary.hex : !errorBack ? colors.body.hex : colors.error.hex
320
+ backgroundColor: currentStep >= index ? !errorBack ? colors.primary.hex : colors.error.hex : colors.body.hex
311
321
  }]
312
322
  }, renderStepContent(index)), steps && /*#__PURE__*/React.createElement(Text, {
313
323
  style: styles$9.stepText