aport-tools 4.2.12 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,4 +4,5 @@ export { default as TextArea } from './TextArea';
4
4
  export { default as Label } from './Label';
5
5
  export { default as ErrorList } from './ErrorList';
6
6
  export { InputList } from './InputList';
7
+ export { default as InputCheck } from './InputCheck';
7
8
  export { default as InputAttach } from './InputAttach';
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- /*! aport-tools v4.2.12 | ISC */
1
+ /*! aport-tools v4.3.0 | ISC */
2
2
  import React, { useContext, useState, createContext, useCallback, useMemo } from 'react';
3
- import { StyleSheet, Text as Text$1, View, TextInput, TouchableOpacity, Modal, Pressable, FlatList, Keyboard, Image, Alert, ActivityIndicator, Platform } from 'react-native';
3
+ import { StyleSheet, Text as Text$1, View, TextInput, TouchableOpacity, Modal, Pressable, FlatList, Keyboard, Platform, Image, Alert, ActivityIndicator } from 'react-native';
4
4
  import { ThemeContext } from 'aport-themes';
5
5
  import * as ImagePicker from 'expo-image-picker';
6
6
 
@@ -231,23 +231,23 @@ var ErrorList = function ErrorList(_a) {
231
231
  var theme = useContext(ThemeContext).theme;
232
232
  var colors = theme.colors;
233
233
  return /*#__PURE__*/React.createElement(View, {
234
- style: styles$7.container
234
+ style: styles$8.container
235
235
  }, errors.map(function (error, index) {
236
236
  return /*#__PURE__*/React.createElement(View, {
237
237
  key: index,
238
- style: styles$7.errorItem
238
+ style: styles$8.errorItem
239
239
  }, /*#__PURE__*/React.createElement(Text, {
240
- style: [styles$7.bullet, {
240
+ style: [styles$8.bullet, {
241
241
  color: colors.error.hex
242
242
  }]
243
243
  }, "\u2022"), /*#__PURE__*/React.createElement(Text, {
244
- style: [styles$7.errorText, {
244
+ style: [styles$8.errorText, {
245
245
  color: colors.error.hex
246
246
  }]
247
247
  }, error));
248
248
  }));
249
249
  };
250
- var styles$7 = StyleSheet.create({
250
+ var styles$8 = StyleSheet.create({
251
251
  container: {
252
252
  marginTop: 4
253
253
  },
@@ -325,13 +325,13 @@ var Input = function Input(_a) {
325
325
  setFormValue(name, formattedText);
326
326
  };
327
327
  return /*#__PURE__*/React.createElement(View, {
328
- style: styles$6.container
328
+ style: styles$7.container
329
329
  }, /*#__PURE__*/React.createElement(Text, {
330
- style: [styles$6.label, {
330
+ style: [styles$7.label, {
331
331
  color: colors.text.hex
332
332
  }]
333
333
  }, label), /*#__PURE__*/React.createElement(TextInput, __assign({
334
- style: [styles$6.input, {
334
+ style: [styles$7.input, {
335
335
  backgroundColor: colors.body.hex,
336
336
  borderColor: formErrors[name] ? colors.error.hex : "#CCC",
337
337
  color: colors.text.hex
@@ -344,7 +344,7 @@ var Input = function Input(_a) {
344
344
  errors: formErrors[name]
345
345
  })));
346
346
  };
347
- var styles$6 = StyleSheet.create({
347
+ var styles$7 = StyleSheet.create({
348
348
  container: {
349
349
  marginBottom: 16
350
350
  },
@@ -377,13 +377,13 @@ var TextArea = function TextArea(_a) {
377
377
  setFormValue(name, text);
378
378
  };
379
379
  return /*#__PURE__*/React.createElement(View, {
380
- style: styles$5.container
380
+ style: styles$6.container
381
381
  }, /*#__PURE__*/React.createElement(Text, {
382
- style: [styles$5.label, {
382
+ style: [styles$6.label, {
383
383
  color: colors.text.hex
384
384
  }]
385
385
  }, label), /*#__PURE__*/React.createElement(TextInput, __assign({
386
- style: [styles$5.textArea, style, {
386
+ style: [styles$6.textArea, style, {
387
387
  backgroundColor: colors.body.hex,
388
388
  color: colors.text.hex,
389
389
  borderColor: colors.placeHolder.hex
@@ -400,7 +400,7 @@ var TextArea = function TextArea(_a) {
400
400
  errors: formErrors[name]
401
401
  })));
402
402
  };
403
- var styles$5 = StyleSheet.create({
403
+ var styles$6 = StyleSheet.create({
404
404
  container: {
405
405
  marginBottom: 16
406
406
  },
@@ -423,12 +423,12 @@ var Label = function Label(_a) {
423
423
  var theme = useContext(ThemeContext).theme;
424
424
  var colors = theme.colors;
425
425
  return /*#__PURE__*/React.createElement(Text, {
426
- style: [styles$4.label, style, {
426
+ style: [styles$5.label, style, {
427
427
  color: colors.text.hex
428
428
  }]
429
429
  }, text);
430
430
  };
431
- var styles$4 = StyleSheet.create({
431
+ var styles$5 = StyleSheet.create({
432
432
  label: {
433
433
  marginBottom: 4,
434
434
  fontWeight: '500'
@@ -541,14 +541,14 @@ var InputList = function InputList(_a) {
541
541
  });
542
542
  };
543
543
  return /*#__PURE__*/React.createElement(View, {
544
- style: [styles$3.container, style]
544
+ style: [styles$4.container, style]
545
545
  }, /*#__PURE__*/React.createElement(Text$1, {
546
546
  style: {
547
547
  color: colors.text.hex,
548
548
  marginBottom: 4
549
549
  }
550
550
  }, name), /*#__PURE__*/React.createElement(TouchableOpacity, {
551
- style: styles$3.inputContainer,
551
+ style: styles$4.inputContainer,
552
552
  onPress: toggleDropdown,
553
553
  disabled: disabled
554
554
  }, /*#__PURE__*/React.createElement(Text$1, {
@@ -560,10 +560,10 @@ var InputList = function InputList(_a) {
560
560
  transparent: true,
561
561
  animationType: "fade"
562
562
  }, /*#__PURE__*/React.createElement(Pressable, {
563
- style: styles$3.overlay,
563
+ style: styles$4.overlay,
564
564
  onPress: handleCloseDropdown
565
565
  }), /*#__PURE__*/React.createElement(View, {
566
- style: [styles$3.dropdownContainer, {
566
+ style: [styles$4.dropdownContainer, {
567
567
  backgroundColor: colors.body.hex
568
568
  }]
569
569
  }, /*#__PURE__*/React.createElement(FlatList, {
@@ -581,7 +581,7 @@ var InputList = function InputList(_a) {
581
581
  onPress: function onPress() {
582
582
  return handleSelectOption(item);
583
583
  },
584
- style: [styles$3.optionItem, isSelected ? {
584
+ style: [styles$4.optionItem, isSelected ? {
585
585
  backgroundColor: colors.primary.hex
586
586
  } : {}, isDisabled ? {
587
587
  backgroundColor: colors.placeHolder.hex
@@ -592,18 +592,18 @@ var InputList = function InputList(_a) {
592
592
  color: colors.body.hex
593
593
  } : {
594
594
  color: colors.text.hex
595
- }, isDisabled ? styles$3.disabledText : {}]
595
+ }, isDisabled ? styles$4.disabledText : {}]
596
596
  }, item.label));
597
597
  },
598
598
  ItemSeparatorComponent: function ItemSeparatorComponent() {
599
599
  return separator ? /*#__PURE__*/React.createElement(View, {
600
- style: styles$3.separator
600
+ style: styles$4.separator
601
601
  }) : null;
602
602
  },
603
603
  scrollEnabled: !closeOnScroll
604
604
  }))));
605
605
  };
606
- var styles$3 = StyleSheet.create({
606
+ var styles$4 = StyleSheet.create({
607
607
  container: {},
608
608
  inputContainer: {
609
609
  padding: 12,
@@ -639,6 +639,178 @@ var styles$3 = StyleSheet.create({
639
639
  }
640
640
  });
641
641
 
642
+ // src/cards/Card.tsx
643
+ /**
644
+ * Card component that adapts its styles based on the current theme.
645
+ * Supports dynamic styling, shadows, and press animations.
646
+ *
647
+ * @param children - The content to be displayed inside the Card.
648
+ * @param style - Additional styles to apply to the Card.
649
+ * @param onPress - Function to execute when the Card is pressed.
650
+ * @param pressable - Determines if the Card is pressable. Defaults to false.
651
+ * @param borderRadius - Border radius of the Card. Defaults to 12.
652
+ * @param elevation - Elevation for Android shadow. Overrides default.
653
+ * @param shadowProps - Custom shadow properties for iOS. Overrides defaults.
654
+ */
655
+ var Card = function Card(_a) {
656
+ var children = _a.children,
657
+ style = _a.style,
658
+ onPress = _a.onPress,
659
+ _b = _a.pressable,
660
+ pressable = _b === void 0 ? false : _b,
661
+ _c = _a.borderRadius,
662
+ borderRadius = _c === void 0 ? 12 : _c,
663
+ _d = _a.elevation,
664
+ elevation = _d === void 0 ? 4 : _d,
665
+ _e = _a.shadowProps,
666
+ shadowProps = _e === void 0 ? {} : _e;
667
+ var theme = useContext(ThemeContext).theme;
668
+ var colors = theme.colors;
669
+ // Animation state for pressable effect
670
+ // Default shadow styles (improved platform-specific handling)
671
+ var defaultShadow = Platform.select({
672
+ ios: {
673
+ shadowColor: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowColor) || colors.text.hex,
674
+ // Defaulting to theme text color
675
+ shadowOffset: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOffset) || {
676
+ width: 0,
677
+ height: 2
678
+ },
679
+ shadowOpacity: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOpacity) || 0.1,
680
+ shadowRadius: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowRadius) || 4
681
+ },
682
+ android: {
683
+ elevation: elevation // Only applies to Android
684
+ }
685
+ });
686
+ var cardStyles = [styles$3.container, {
687
+ borderRadius: borderRadius,
688
+ backgroundColor: colors.background.hex
689
+ }, defaultShadow,
690
+ // Dynamic shadows based on platform
691
+ style // External styles
692
+ ];
693
+ return pressable ? (/*#__PURE__*/React.createElement(TouchableOpacity, {
694
+ activeOpacity: 0.8,
695
+ onPress: onPress,
696
+ style: cardStyles
697
+ }, children)) : (/*#__PURE__*/React.createElement(View, {
698
+ style: cardStyles
699
+ }, children));
700
+ };
701
+ var styles$3 = StyleSheet.create({
702
+ container: {
703
+ padding: 16,
704
+ borderRadius: 12
705
+ // Shadows handled dynamically with platform logic
706
+ }
707
+ });
708
+
709
+ var InputCheck = function InputCheck(_a) {
710
+ var name = _a.name,
711
+ options = _a.options,
712
+ _b = _a.multi,
713
+ multi = _b === void 0 ? false : _b,
714
+ max = _a.max,
715
+ _c = _a.rowAmount,
716
+ rowAmount = _c === void 0 ? 3 : _c,
717
+ _d = _a.iconPosition,
718
+ iconPosition = _d === void 0 ? "row" : _d,
719
+ _e = _a.disabled,
720
+ disabled = _e === void 0 ? false : _e;
721
+ var _f = useFormContext(),
722
+ formValues = _f.formValues,
723
+ setFormValue = _f.setFormValue;
724
+ var _g = useState(formValues[name] || []),
725
+ selectedValues = _g[0],
726
+ setSelectedValues = _g[1];
727
+ var theme = useContext(ThemeContext).theme;
728
+ var colors = theme.colors;
729
+ var handleSelect = function handleSelect(id) {
730
+ if (disabled) return;
731
+ var updatedSelection;
732
+ if (multi) {
733
+ if (selectedValues.includes(id)) {
734
+ updatedSelection = selectedValues.filter(function (value) {
735
+ return value !== id;
736
+ });
737
+ } else {
738
+ if (max && selectedValues.length >= max) return; // Prevent selection beyond max
739
+ updatedSelection = __spreadArray(__spreadArray([], selectedValues, true), [id], false);
740
+ }
741
+ } else {
742
+ updatedSelection = [id];
743
+ }
744
+ setSelectedValues(updatedSelection);
745
+ setFormValue(name, updatedSelection);
746
+ };
747
+ var renderItem = function renderItem(_a) {
748
+ var item = _a.item;
749
+ var isSelected = selectedValues.includes(item.id);
750
+ return /*#__PURE__*/React.createElement(Card, {
751
+ pressable: true,
752
+ onPress: function onPress() {
753
+ return handleSelect(item.id);
754
+ },
755
+ style: [styles$2.card, isSelected && {
756
+ backgroundColor: colors.primary.hex
757
+ },
758
+ // Replace with colors.primary.hex if available
759
+ disabled && styles$2.cardDisabled]
760
+ }, item.icon && (/*#__PURE__*/React.createElement(Image, {
761
+ source: {
762
+ uri: item.icon
763
+ },
764
+ style: [styles$2.icon, iconPosition === "column" && styles$2.iconColumn]
765
+ })), /*#__PURE__*/React.createElement(Text, {
766
+ style: [styles$2.label, {
767
+ color: isSelected ? colors.textButton.hex : colors.text.hex
768
+ } // Replace with colors.textButton.hex
769
+ ]
770
+ }, item.label));
771
+ };
772
+ return /*#__PURE__*/React.createElement(FlatList, {
773
+ data: options,
774
+ renderItem: renderItem,
775
+ keyExtractor: function keyExtractor(item) {
776
+ return item.id;
777
+ },
778
+ numColumns: rowAmount,
779
+ columnWrapperStyle: rowAmount > 1 ? styles$2.row : undefined,
780
+ scrollEnabled: false
781
+ });
782
+ };
783
+ var styles$2 = StyleSheet.create({
784
+ card: {
785
+ flex: 1,
786
+ margin: 5,
787
+ padding: 10,
788
+ borderWidth: 1,
789
+ borderColor: "#ccc",
790
+ borderRadius: 8,
791
+ alignItems: "center",
792
+ justifyContent: "center"
793
+ },
794
+ cardDisabled: {
795
+ opacity: 0.5
796
+ },
797
+ icon: {
798
+ width: 40,
799
+ height: 40,
800
+ marginBottom: 5
801
+ },
802
+ iconColumn: {
803
+ marginBottom: 10
804
+ },
805
+ label: {
806
+ fontSize: 14,
807
+ textAlign: "center"
808
+ },
809
+ row: {
810
+ justifyContent: "space-between"
811
+ }
812
+ });
813
+
642
814
  // src/components/InputAttach.tsx
643
815
  var InputAttach = function InputAttach(_a) {
644
816
  var name = _a.name,
@@ -720,49 +892,49 @@ var InputAttach = function InputAttach(_a) {
720
892
  setFormValue(name, updatedFiles); // Update form context
721
893
  };
722
894
  return /*#__PURE__*/React.createElement(View, {
723
- style: styles$2.container
895
+ style: styles$1.container
724
896
  }, /*#__PURE__*/React.createElement(Text, {
725
- style: [styles$2.label, {
897
+ style: [styles$1.label, {
726
898
  color: colors.text.hex
727
899
  }]
728
900
  }, placeholder), /*#__PURE__*/React.createElement(View, {
729
- style: styles$2.fileContainer
901
+ style: styles$1.fileContainer
730
902
  }, selectedFiles.map(function (file, index) {
731
903
  return /*#__PURE__*/React.createElement(View, {
732
904
  key: index,
733
- style: styles$2.fileItem
905
+ style: styles$1.fileItem
734
906
  }, /*#__PURE__*/React.createElement(Image, {
735
907
  source: {
736
908
  uri: file.uri
737
909
  },
738
- style: styles$2.imagePreview
910
+ style: styles$1.imagePreview
739
911
  }), /*#__PURE__*/React.createElement(TouchableOpacity, {
740
912
  onPress: function onPress() {
741
913
  return removeFile(index);
742
914
  },
743
- style: [styles$2.removeButton, {
915
+ style: [styles$1.removeButton, {
744
916
  backgroundColor: colors.error.hex
745
917
  }]
746
918
  }, /*#__PURE__*/React.createElement(Text, {
747
- style: styles$2.removeButtonText
919
+ style: styles$1.removeButtonText
748
920
  }, "X")));
749
921
  }), selectedFiles.length < amount && (/*#__PURE__*/React.createElement(TouchableOpacity, {
750
922
  onPress: pickImage,
751
- style: [styles$2.addButton, {
923
+ style: [styles$1.addButton, {
752
924
  backgroundColor: colors.body.hex
753
925
  }],
754
926
  disabled: disabled
755
927
  }, /*#__PURE__*/React.createElement(Text, {
756
- style: [styles$2.addButtonText, {
928
+ style: [styles$1.addButtonText, {
757
929
  color: colors.placeHolder.hex
758
930
  }]
759
931
  }, "+")))), errors[name] && /*#__PURE__*/React.createElement(Text, {
760
- style: [styles$2.error, {
932
+ style: [styles$1.error, {
761
933
  color: colors.error.hex
762
934
  }]
763
935
  }, errors[name].join(", ")));
764
936
  };
765
- var styles$2 = StyleSheet.create({
937
+ var styles$1 = StyleSheet.create({
766
938
  container: {
767
939
  marginVertical: 10
768
940
  },
@@ -878,11 +1050,11 @@ var Button = function Button(_a) {
878
1050
  var colors = theme.colors;
879
1051
  var handleSubmit = useFormContext().handleSubmit;
880
1052
  var computedStyles = useMemo(function () {
881
- return StyleSheet.flatten([styles$1.button, typeStyles(type, disabled, colors), rounded && {
1053
+ return StyleSheet.flatten([styles.button, typeStyles(type, disabled, colors), rounded && {
882
1054
  borderRadius: borderRadius
883
1055
  }, isFullWidth && {
884
1056
  width: '100%'
885
- }, (disabled || loading) && styles$1.disabled]);
1057
+ }, (disabled || loading) && styles.disabled]);
886
1058
  }, [type, disabled, loading, rounded, borderRadius, isFullWidth, colors]);
887
1059
  var textColor = useMemo(function () {
888
1060
  return type === "cancel" ? {
@@ -913,7 +1085,7 @@ var Button = function Button(_a) {
913
1085
  style: textColor
914
1086
  }, Array.isArray(children) ? children.join('').toUpperCase() : children === null || children === void 0 ? void 0 : children.toUpperCase())));
915
1087
  };
916
- var styles$1 = StyleSheet.create({
1088
+ var styles = StyleSheet.create({
917
1089
  button: {
918
1090
  justifyContent: 'center',
919
1091
  alignItems: 'center',
@@ -925,72 +1097,5 @@ var styles$1 = StyleSheet.create({
925
1097
  }
926
1098
  });
927
1099
 
928
- // src/cards/Card.tsx
929
- /**
930
- * Card component that adapts its styles based on the current theme.
931
- * Supports dynamic styling, shadows, and press animations.
932
- *
933
- * @param children - The content to be displayed inside the Card.
934
- * @param style - Additional styles to apply to the Card.
935
- * @param onPress - Function to execute when the Card is pressed.
936
- * @param pressable - Determines if the Card is pressable. Defaults to false.
937
- * @param borderRadius - Border radius of the Card. Defaults to 12.
938
- * @param elevation - Elevation for Android shadow. Overrides default.
939
- * @param shadowProps - Custom shadow properties for iOS. Overrides defaults.
940
- */
941
- var Card = function Card(_a) {
942
- var children = _a.children,
943
- style = _a.style,
944
- onPress = _a.onPress,
945
- _b = _a.pressable,
946
- pressable = _b === void 0 ? false : _b,
947
- _c = _a.borderRadius,
948
- borderRadius = _c === void 0 ? 12 : _c,
949
- _d = _a.elevation,
950
- elevation = _d === void 0 ? 4 : _d,
951
- _e = _a.shadowProps,
952
- shadowProps = _e === void 0 ? {} : _e;
953
- var theme = useContext(ThemeContext).theme;
954
- var colors = theme.colors;
955
- // Animation state for pressable effect
956
- // Default shadow styles (improved platform-specific handling)
957
- var defaultShadow = Platform.select({
958
- ios: {
959
- shadowColor: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowColor) || colors.text.hex,
960
- // Defaulting to theme text color
961
- shadowOffset: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOffset) || {
962
- width: 0,
963
- height: 2
964
- },
965
- shadowOpacity: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOpacity) || 0.1,
966
- shadowRadius: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowRadius) || 4
967
- },
968
- android: {
969
- elevation: elevation // Only applies to Android
970
- }
971
- });
972
- var cardStyles = [styles.container, {
973
- borderRadius: borderRadius,
974
- backgroundColor: colors.background.hex
975
- }, defaultShadow,
976
- // Dynamic shadows based on platform
977
- style // External styles
978
- ];
979
- return pressable ? (/*#__PURE__*/React.createElement(TouchableOpacity, {
980
- activeOpacity: 0.8,
981
- onPress: onPress,
982
- style: cardStyles
983
- }, children)) : (/*#__PURE__*/React.createElement(View, {
984
- style: cardStyles
985
- }, children));
986
- };
987
- var styles = StyleSheet.create({
988
- container: {
989
- padding: 16,
990
- borderRadius: 12
991
- // Shadows handled dynamically with platform logic
992
- }
993
- });
994
-
995
- export { Button, Card, ErrorList, Form, Input, InputAttach, InputList, Label, Text, TextArea, useFormContext };
1100
+ export { Button, Card, ErrorList, Form, Input, InputAttach, InputCheck, InputList, Label, Text, TextArea, useFormContext };
996
1101
  //# sourceMappingURL=index.esm.js.map