aport-tools 4.4.7 → 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.7 | 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,24 +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
- onPress === null || onPress === void 0 ? void 0 : onPress(stepIndex);
215
+ seterrorBack(false);
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:
214
225
  return [2 /*return*/];
215
226
  }
216
227
  });
@@ -219,7 +230,7 @@ var Stepper = function Stepper(_a) {
219
230
  React.useEffect(function () {
220
231
  Animated.timing(progressAnim, {
221
232
  toValue: currentStep,
222
- duration: 300,
233
+ duration: 500,
223
234
  useNativeDriver: false
224
235
  }).start();
225
236
  }, [currentStep]);
@@ -306,7 +317,7 @@ var Stepper = function Stepper(_a) {
306
317
  }
307
318
  }, /*#__PURE__*/React.createElement(View, {
308
319
  style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, {
309
- backgroundColor: !errorBack ? currentStep >= index ? colors.primary.hex : colors.body.hex : colors.error.hex
320
+ backgroundColor: currentStep >= index ? !errorBack ? colors.primary.hex : colors.error.hex : colors.body.hex
310
321
  }]
311
322
  }, renderStepContent(index)), steps && /*#__PURE__*/React.createElement(Text, {
312
323
  style: styles$9.stepText