aport-tools 4.2.11 → 4.2.13

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.2.11 | ISC */
1
+ /*! aport-tools v4.2.13 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -252,23 +252,23 @@ var ErrorList = function ErrorList(_a) {
252
252
  var theme = React.useContext(aportThemes.ThemeContext).theme;
253
253
  var colors = theme.colors;
254
254
  return /*#__PURE__*/React.createElement(reactNative.View, {
255
- style: styles$7.container
255
+ style: styles$8.container
256
256
  }, errors.map(function (error, index) {
257
257
  return /*#__PURE__*/React.createElement(reactNative.View, {
258
258
  key: index,
259
- style: styles$7.errorItem
259
+ style: styles$8.errorItem
260
260
  }, /*#__PURE__*/React.createElement(Text, {
261
- style: [styles$7.bullet, {
261
+ style: [styles$8.bullet, {
262
262
  color: colors.error.hex
263
263
  }]
264
264
  }, "\u2022"), /*#__PURE__*/React.createElement(Text, {
265
- style: [styles$7.errorText, {
265
+ style: [styles$8.errorText, {
266
266
  color: colors.error.hex
267
267
  }]
268
268
  }, error));
269
269
  }));
270
270
  };
271
- var styles$7 = reactNative.StyleSheet.create({
271
+ var styles$8 = reactNative.StyleSheet.create({
272
272
  container: {
273
273
  marginTop: 4
274
274
  },
@@ -346,13 +346,13 @@ var Input = function Input(_a) {
346
346
  setFormValue(name, formattedText);
347
347
  };
348
348
  return /*#__PURE__*/React.createElement(reactNative.View, {
349
- style: styles$6.container
349
+ style: styles$7.container
350
350
  }, /*#__PURE__*/React.createElement(Text, {
351
- style: [styles$6.label, {
351
+ style: [styles$7.label, {
352
352
  color: colors.text.hex
353
353
  }]
354
354
  }, label), /*#__PURE__*/React.createElement(reactNative.TextInput, __assign({
355
- style: [styles$6.input, {
355
+ style: [styles$7.input, {
356
356
  backgroundColor: colors.body.hex,
357
357
  borderColor: formErrors[name] ? colors.error.hex : "#CCC",
358
358
  color: colors.text.hex
@@ -365,7 +365,7 @@ var Input = function Input(_a) {
365
365
  errors: formErrors[name]
366
366
  })));
367
367
  };
368
- var styles$6 = reactNative.StyleSheet.create({
368
+ var styles$7 = reactNative.StyleSheet.create({
369
369
  container: {
370
370
  marginBottom: 16
371
371
  },
@@ -398,13 +398,13 @@ var TextArea = function TextArea(_a) {
398
398
  setFormValue(name, text);
399
399
  };
400
400
  return /*#__PURE__*/React.createElement(reactNative.View, {
401
- style: styles$5.container
401
+ style: styles$6.container
402
402
  }, /*#__PURE__*/React.createElement(Text, {
403
- style: [styles$5.label, {
403
+ style: [styles$6.label, {
404
404
  color: colors.text.hex
405
405
  }]
406
406
  }, label), /*#__PURE__*/React.createElement(reactNative.TextInput, __assign({
407
- style: [styles$5.textArea, style, {
407
+ style: [styles$6.textArea, style, {
408
408
  backgroundColor: colors.body.hex,
409
409
  color: colors.text.hex,
410
410
  borderColor: colors.placeHolder.hex
@@ -421,7 +421,7 @@ var TextArea = function TextArea(_a) {
421
421
  errors: formErrors[name]
422
422
  })));
423
423
  };
424
- var styles$5 = reactNative.StyleSheet.create({
424
+ var styles$6 = reactNative.StyleSheet.create({
425
425
  container: {
426
426
  marginBottom: 16
427
427
  },
@@ -444,12 +444,12 @@ var Label = function Label(_a) {
444
444
  var theme = React.useContext(aportThemes.ThemeContext).theme;
445
445
  var colors = theme.colors;
446
446
  return /*#__PURE__*/React.createElement(Text, {
447
- style: [styles$4.label, style, {
447
+ style: [styles$5.label, style, {
448
448
  color: colors.text.hex
449
449
  }]
450
450
  }, text);
451
451
  };
452
- var styles$4 = reactNative.StyleSheet.create({
452
+ var styles$5 = reactNative.StyleSheet.create({
453
453
  label: {
454
454
  marginBottom: 4,
455
455
  fontWeight: '500'
@@ -562,14 +562,14 @@ var InputList = function InputList(_a) {
562
562
  });
563
563
  };
564
564
  return /*#__PURE__*/React.createElement(reactNative.View, {
565
- style: [styles$3.container, style]
565
+ style: [styles$4.container, style]
566
566
  }, /*#__PURE__*/React.createElement(reactNative.Text, {
567
567
  style: {
568
568
  color: colors.text.hex,
569
569
  marginBottom: 4
570
570
  }
571
571
  }, name), /*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
572
- style: styles$3.inputContainer,
572
+ style: styles$4.inputContainer,
573
573
  onPress: toggleDropdown,
574
574
  disabled: disabled
575
575
  }, /*#__PURE__*/React.createElement(reactNative.Text, {
@@ -581,10 +581,10 @@ var InputList = function InputList(_a) {
581
581
  transparent: true,
582
582
  animationType: "fade"
583
583
  }, /*#__PURE__*/React.createElement(reactNative.Pressable, {
584
- style: styles$3.overlay,
584
+ style: styles$4.overlay,
585
585
  onPress: handleCloseDropdown
586
586
  }), /*#__PURE__*/React.createElement(reactNative.View, {
587
- style: [styles$3.dropdownContainer, {
587
+ style: [styles$4.dropdownContainer, {
588
588
  backgroundColor: colors.body.hex
589
589
  }]
590
590
  }, /*#__PURE__*/React.createElement(reactNative.FlatList, {
@@ -602,7 +602,7 @@ var InputList = function InputList(_a) {
602
602
  onPress: function onPress() {
603
603
  return handleSelectOption(item);
604
604
  },
605
- style: [styles$3.optionItem, isSelected ? {
605
+ style: [styles$4.optionItem, isSelected ? {
606
606
  backgroundColor: colors.primary.hex
607
607
  } : {}, isDisabled ? {
608
608
  backgroundColor: colors.placeHolder.hex
@@ -613,18 +613,18 @@ var InputList = function InputList(_a) {
613
613
  color: colors.body.hex
614
614
  } : {
615
615
  color: colors.text.hex
616
- }, isDisabled ? styles$3.disabledText : {}]
616
+ }, isDisabled ? styles$4.disabledText : {}]
617
617
  }, item.label));
618
618
  },
619
619
  ItemSeparatorComponent: function ItemSeparatorComponent() {
620
620
  return separator ? /*#__PURE__*/React.createElement(reactNative.View, {
621
- style: styles$3.separator
621
+ style: styles$4.separator
622
622
  }) : null;
623
623
  },
624
624
  scrollEnabled: !closeOnScroll
625
625
  }))));
626
626
  };
627
- var styles$3 = reactNative.StyleSheet.create({
627
+ var styles$4 = reactNative.StyleSheet.create({
628
628
  container: {},
629
629
  inputContainer: {
630
630
  padding: 12,
@@ -660,6 +660,178 @@ var styles$3 = reactNative.StyleSheet.create({
660
660
  }
661
661
  });
662
662
 
663
+ // src/cards/Card.tsx
664
+ /**
665
+ * Card component that adapts its styles based on the current theme.
666
+ * Supports dynamic styling, shadows, and press animations.
667
+ *
668
+ * @param children - The content to be displayed inside the Card.
669
+ * @param style - Additional styles to apply to the Card.
670
+ * @param onPress - Function to execute when the Card is pressed.
671
+ * @param pressable - Determines if the Card is pressable. Defaults to false.
672
+ * @param borderRadius - Border radius of the Card. Defaults to 12.
673
+ * @param elevation - Elevation for Android shadow. Overrides default.
674
+ * @param shadowProps - Custom shadow properties for iOS. Overrides defaults.
675
+ */
676
+ var Card = function Card(_a) {
677
+ var children = _a.children,
678
+ style = _a.style,
679
+ onPress = _a.onPress,
680
+ _b = _a.pressable,
681
+ pressable = _b === void 0 ? false : _b,
682
+ _c = _a.borderRadius,
683
+ borderRadius = _c === void 0 ? 12 : _c,
684
+ _d = _a.elevation,
685
+ elevation = _d === void 0 ? 4 : _d,
686
+ _e = _a.shadowProps,
687
+ shadowProps = _e === void 0 ? {} : _e;
688
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
689
+ var colors = theme.colors;
690
+ // Animation state for pressable effect
691
+ // Default shadow styles (improved platform-specific handling)
692
+ var defaultShadow = reactNative.Platform.select({
693
+ ios: {
694
+ shadowColor: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowColor) || colors.text.hex,
695
+ // Defaulting to theme text color
696
+ shadowOffset: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOffset) || {
697
+ width: 0,
698
+ height: 2
699
+ },
700
+ shadowOpacity: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOpacity) || 0.1,
701
+ shadowRadius: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowRadius) || 4
702
+ },
703
+ android: {
704
+ elevation: elevation // Only applies to Android
705
+ }
706
+ });
707
+ var cardStyles = [styles$3.container, {
708
+ borderRadius: borderRadius,
709
+ backgroundColor: colors.background.hex
710
+ }, defaultShadow,
711
+ // Dynamic shadows based on platform
712
+ style // External styles
713
+ ];
714
+ return pressable ? (/*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
715
+ activeOpacity: 0.8,
716
+ onPress: onPress,
717
+ style: cardStyles
718
+ }, children)) : (/*#__PURE__*/React.createElement(reactNative.View, {
719
+ style: cardStyles
720
+ }, children));
721
+ };
722
+ var styles$3 = reactNative.StyleSheet.create({
723
+ container: {
724
+ padding: 16,
725
+ borderRadius: 12
726
+ // Shadows handled dynamically with platform logic
727
+ }
728
+ });
729
+
730
+ var InputCheck = function InputCheck(_a) {
731
+ var name = _a.name,
732
+ options = _a.options,
733
+ _b = _a.multi,
734
+ multi = _b === void 0 ? false : _b,
735
+ max = _a.max,
736
+ _c = _a.rowAmount,
737
+ rowAmount = _c === void 0 ? 3 : _c,
738
+ _d = _a.iconPosition,
739
+ iconPosition = _d === void 0 ? "row" : _d,
740
+ _e = _a.disabled,
741
+ disabled = _e === void 0 ? false : _e;
742
+ var _f = useFormContext(),
743
+ formValues = _f.formValues,
744
+ setFormValue = _f.setFormValue;
745
+ var _g = React.useState(formValues[name] || []),
746
+ selectedValues = _g[0],
747
+ setSelectedValues = _g[1];
748
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
749
+ var colors = theme.colors;
750
+ var handleSelect = function handleSelect(id) {
751
+ if (disabled) return;
752
+ var updatedSelection;
753
+ if (multi) {
754
+ if (selectedValues.includes(id)) {
755
+ updatedSelection = selectedValues.filter(function (value) {
756
+ return value !== id;
757
+ });
758
+ } else {
759
+ if (max && selectedValues.length >= max) return; // Prevent selection beyond max
760
+ updatedSelection = __spreadArray(__spreadArray([], selectedValues, true), [id], false);
761
+ }
762
+ } else {
763
+ updatedSelection = [id];
764
+ }
765
+ setSelectedValues(updatedSelection);
766
+ setFormValue(name, updatedSelection);
767
+ };
768
+ var renderItem = function renderItem(_a) {
769
+ var item = _a.item;
770
+ var isSelected = selectedValues.includes(item.id);
771
+ return /*#__PURE__*/React.createElement(Card, {
772
+ pressable: true,
773
+ onPress: function onPress() {
774
+ return handleSelect(item.id);
775
+ },
776
+ style: [styles$2.card, isSelected && {
777
+ backgroundColor: colors.primary.hex
778
+ },
779
+ // Replace with colors.primary.hex if available
780
+ disabled && styles$2.cardDisabled]
781
+ }, item.icon && (/*#__PURE__*/React.createElement(reactNative.Image, {
782
+ source: {
783
+ uri: item.icon
784
+ },
785
+ style: [styles$2.icon, iconPosition === "column" && styles$2.iconColumn]
786
+ })), /*#__PURE__*/React.createElement(Text, {
787
+ style: [styles$2.label, {
788
+ color: isSelected ? colors.textButton.hex : colors.text.hex
789
+ } // Replace with colors.textButton.hex
790
+ ]
791
+ }, item.label));
792
+ };
793
+ return /*#__PURE__*/React.createElement(reactNative.FlatList, {
794
+ data: options,
795
+ renderItem: renderItem,
796
+ keyExtractor: function keyExtractor(item) {
797
+ return item.id;
798
+ },
799
+ numColumns: rowAmount,
800
+ columnWrapperStyle: rowAmount > 1 ? styles$2.row : undefined,
801
+ scrollEnabled: false
802
+ });
803
+ };
804
+ var styles$2 = reactNative.StyleSheet.create({
805
+ card: {
806
+ flex: 1,
807
+ margin: 5,
808
+ padding: 10,
809
+ borderWidth: 1,
810
+ borderColor: "#ccc",
811
+ borderRadius: 8,
812
+ alignItems: "center",
813
+ justifyContent: "center"
814
+ },
815
+ cardDisabled: {
816
+ opacity: 0.5
817
+ },
818
+ icon: {
819
+ width: 40,
820
+ height: 40,
821
+ marginBottom: 5
822
+ },
823
+ iconColumn: {
824
+ marginBottom: 10
825
+ },
826
+ label: {
827
+ fontSize: 14,
828
+ textAlign: "center"
829
+ },
830
+ row: {
831
+ justifyContent: "space-between"
832
+ }
833
+ });
834
+
663
835
  // src/components/InputAttach.tsx
664
836
  var InputAttach = function InputAttach(_a) {
665
837
  var name = _a.name,
@@ -741,49 +913,49 @@ var InputAttach = function InputAttach(_a) {
741
913
  setFormValue(name, updatedFiles); // Update form context
742
914
  };
743
915
  return /*#__PURE__*/React.createElement(reactNative.View, {
744
- style: styles$2.container
916
+ style: styles$1.container
745
917
  }, /*#__PURE__*/React.createElement(Text, {
746
- style: [styles$2.label, {
918
+ style: [styles$1.label, {
747
919
  color: colors.text.hex
748
920
  }]
749
921
  }, placeholder), /*#__PURE__*/React.createElement(reactNative.View, {
750
- style: styles$2.fileContainer
922
+ style: styles$1.fileContainer
751
923
  }, selectedFiles.map(function (file, index) {
752
924
  return /*#__PURE__*/React.createElement(reactNative.View, {
753
925
  key: index,
754
- style: styles$2.fileItem
926
+ style: styles$1.fileItem
755
927
  }, /*#__PURE__*/React.createElement(reactNative.Image, {
756
928
  source: {
757
929
  uri: file.uri
758
930
  },
759
- style: styles$2.imagePreview
931
+ style: styles$1.imagePreview
760
932
  }), /*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
761
933
  onPress: function onPress() {
762
934
  return removeFile(index);
763
935
  },
764
- style: [styles$2.removeButton, {
936
+ style: [styles$1.removeButton, {
765
937
  backgroundColor: colors.error.hex
766
938
  }]
767
939
  }, /*#__PURE__*/React.createElement(Text, {
768
- style: styles$2.removeButtonText
940
+ style: styles$1.removeButtonText
769
941
  }, "X")));
770
942
  }), selectedFiles.length < amount && (/*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
771
943
  onPress: pickImage,
772
- style: [styles$2.addButton, {
944
+ style: [styles$1.addButton, {
773
945
  backgroundColor: colors.body.hex
774
946
  }],
775
947
  disabled: disabled
776
948
  }, /*#__PURE__*/React.createElement(Text, {
777
- style: [styles$2.addButtonText, {
949
+ style: [styles$1.addButtonText, {
778
950
  color: colors.placeHolder.hex
779
951
  }]
780
952
  }, "+")))), errors[name] && /*#__PURE__*/React.createElement(Text, {
781
- style: [styles$2.error, {
953
+ style: [styles$1.error, {
782
954
  color: colors.error.hex
783
955
  }]
784
956
  }, errors[name].join(", ")));
785
957
  };
786
- var styles$2 = reactNative.StyleSheet.create({
958
+ var styles$1 = reactNative.StyleSheet.create({
787
959
  container: {
788
960
  marginVertical: 10
789
961
  },
@@ -899,11 +1071,11 @@ var Button = function Button(_a) {
899
1071
  var colors = theme.colors;
900
1072
  var handleSubmit = useFormContext().handleSubmit;
901
1073
  var computedStyles = React.useMemo(function () {
902
- return reactNative.StyleSheet.flatten([styles$1.button, typeStyles(type, disabled, colors), rounded && {
1074
+ return reactNative.StyleSheet.flatten([styles.button, typeStyles(type, disabled, colors), rounded && {
903
1075
  borderRadius: borderRadius
904
1076
  }, isFullWidth && {
905
1077
  width: '100%'
906
- }, (disabled || loading) && styles$1.disabled]);
1078
+ }, (disabled || loading) && styles.disabled]);
907
1079
  }, [type, disabled, loading, rounded, borderRadius, isFullWidth, colors]);
908
1080
  var textColor = React.useMemo(function () {
909
1081
  return type === "cancel" ? {
@@ -934,7 +1106,7 @@ var Button = function Button(_a) {
934
1106
  style: textColor
935
1107
  }, Array.isArray(children) ? children.join('').toUpperCase() : children === null || children === void 0 ? void 0 : children.toUpperCase())));
936
1108
  };
937
- var styles$1 = reactNative.StyleSheet.create({
1109
+ var styles = reactNative.StyleSheet.create({
938
1110
  button: {
939
1111
  justifyContent: 'center',
940
1112
  alignItems: 'center',
@@ -946,79 +1118,13 @@ var styles$1 = reactNative.StyleSheet.create({
946
1118
  }
947
1119
  });
948
1120
 
949
- // src/cards/Card.tsx
950
- /**
951
- * Card component that adapts its styles based on the current theme.
952
- * Supports dynamic styling, shadows, and press animations.
953
- *
954
- * @param children - The content to be displayed inside the Card.
955
- * @param style - Additional styles to apply to the Card.
956
- * @param onPress - Function to execute when the Card is pressed.
957
- * @param pressable - Determines if the Card is pressable. Defaults to false.
958
- * @param borderRadius - Border radius of the Card. Defaults to 12.
959
- * @param elevation - Elevation for Android shadow. Overrides default.
960
- * @param shadowProps - Custom shadow properties for iOS. Overrides defaults.
961
- */
962
- var Card = function Card(_a) {
963
- var children = _a.children,
964
- style = _a.style,
965
- onPress = _a.onPress,
966
- _b = _a.pressable,
967
- pressable = _b === void 0 ? false : _b,
968
- _c = _a.borderRadius,
969
- borderRadius = _c === void 0 ? 12 : _c,
970
- _d = _a.elevation,
971
- elevation = _d === void 0 ? 4 : _d,
972
- _e = _a.shadowProps,
973
- shadowProps = _e === void 0 ? {} : _e;
974
- var theme = React.useContext(aportThemes.ThemeContext).theme;
975
- var colors = theme.colors;
976
- // Animation state for pressable effect
977
- // Default shadow styles (improved platform-specific handling)
978
- var defaultShadow = reactNative.Platform.select({
979
- ios: {
980
- shadowColor: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowColor) || colors.text.hex,
981
- // Defaulting to theme text color
982
- shadowOffset: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOffset) || {
983
- width: 0,
984
- height: 2
985
- },
986
- shadowOpacity: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOpacity) || 0.1,
987
- shadowRadius: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowRadius) || 4
988
- },
989
- android: {
990
- elevation: elevation // Only applies to Android
991
- }
992
- });
993
- var cardStyles = [styles.container, {
994
- borderRadius: borderRadius,
995
- backgroundColor: colors.background.hex
996
- }, defaultShadow,
997
- // Dynamic shadows based on platform
998
- style // External styles
999
- ];
1000
- return pressable ? (/*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
1001
- activeOpacity: 0.8,
1002
- onPress: onPress,
1003
- style: cardStyles
1004
- }, children)) : (/*#__PURE__*/React.createElement(reactNative.View, {
1005
- style: cardStyles
1006
- }, children));
1007
- };
1008
- var styles = reactNative.StyleSheet.create({
1009
- container: {
1010
- padding: 16,
1011
- borderRadius: 12
1012
- // Shadows handled dynamically with platform logic
1013
- }
1014
- });
1015
-
1016
1121
  exports.Button = Button;
1017
1122
  exports.Card = Card;
1018
1123
  exports.ErrorList = ErrorList;
1019
1124
  exports.Form = Form;
1020
1125
  exports.Input = Input;
1021
1126
  exports.InputAttach = InputAttach;
1127
+ exports.InputCheck = InputCheck;
1022
1128
  exports.InputList = InputList;
1023
1129
  exports.Label = Label;
1024
1130
  exports.Text = Text;