aport-tools 4.4.46 → 4.4.48

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.46 | ISC */
1
+ /*! aport-tools v4.4.48 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -1449,7 +1449,6 @@ var Button = function Button(_a) {
1449
1449
  onPress = _a.onPress;
1450
1450
  var theme = React.useContext(aportThemes.ThemeContext).theme;
1451
1451
  var colors = theme.colors;
1452
- var handleSubmit = useFormContext().handleSubmit;
1453
1452
  var computedStyles = React.useMemo(function () {
1454
1453
  return reactNative.StyleSheet.flatten([styles.button, typeStyles(type, disabled, colors), rounded && {
1455
1454
  borderRadius: borderRadius
@@ -1464,11 +1463,20 @@ var Button = function Button(_a) {
1464
1463
  color: colors.textButton.hex
1465
1464
  };
1466
1465
  }, [type, colors]);
1466
+ // Safely try to access handleSubmit from the form context
1467
+ var formContext = function () {
1468
+ try {
1469
+ return useFormContext();
1470
+ } catch (_a) {
1471
+ return null;
1472
+ }
1473
+ }();
1467
1474
  var handlePress = function handlePress() {
1468
- if (type === 'submit') {
1469
- handleSubmit(); // Call the form's submit handler
1475
+ if (type === 'submit' && (formContext === null || formContext === void 0 ? void 0 : formContext.handleSubmit)) {
1476
+ console.log("Its submit type");
1477
+ formContext.handleSubmit();
1470
1478
  } else if (onPress) {
1471
- onPress(); // Call a custom handler if needed
1479
+ onPress();
1472
1480
  }
1473
1481
  };
1474
1482
  return /*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {