aport-tools 4.1.22 → 4.1.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.esm.js +254 -240
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +253 -239
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
/*! aport-tools v4.1.
|
1
|
+
/*! aport-tools v4.1.24 | ISC */
|
2
2
|
import React, { createContext, useState, useEffect, useContext, useMemo } from 'react';
|
3
|
-
import { Appearance, StyleSheet, View, Text as Text$1, Switch, TouchableOpacity, ActivityIndicator, Platform
|
3
|
+
import { Appearance, StyleSheet, View, Text as Text$1, Switch, TextInput, TouchableOpacity, ActivityIndicator, Platform } from 'react-native';
|
4
4
|
import { useAsyncStorage } from '@react-native-async-storage/async-storage';
|
5
5
|
|
6
6
|
/******************************************************************************
|
@@ -363,173 +363,62 @@ var styles$6 = StyleSheet.create({
|
|
363
363
|
}
|
364
364
|
});
|
365
365
|
|
366
|
-
// src/
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
* @param themeColors - The theme colors.
|
373
|
-
* @returns The computed style for the button.
|
374
|
-
*/
|
375
|
-
function typeStyles(type, disabled, themeColors) {
|
376
|
-
switch (type) {
|
377
|
-
case 'submit':
|
378
|
-
return {
|
379
|
-
backgroundColor: "rgba(".concat(themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.rgb.r, ", ").concat(themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.rgb.g, ", ").concat(themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.rgb.b, ", ").concat(disabled ? 0.5 : 1, ")"),
|
380
|
-
borderWidth: 2,
|
381
|
-
borderColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.hex
|
382
|
-
};
|
383
|
-
case 'button':
|
384
|
-
return {
|
385
|
-
backgroundColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.hex,
|
386
|
-
borderColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.secondary.hex,
|
387
|
-
opacity: disabled ? 0.5 : 1,
|
388
|
-
borderWidth: 2
|
389
|
-
};
|
390
|
-
case 'cancel':
|
391
|
-
return {
|
392
|
-
backgroundColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.background.hex,
|
393
|
-
borderWidth: 0
|
394
|
-
};
|
395
|
-
default:
|
396
|
-
return {};
|
366
|
+
// src/forms/FormContext.tsx
|
367
|
+
var FormContext = /*#__PURE__*/createContext(undefined);
|
368
|
+
var useFormContext = function useFormContext() {
|
369
|
+
var context = useContext(FormContext);
|
370
|
+
if (!context) {
|
371
|
+
throw new Error("useFormContext must be used within a Form");
|
397
372
|
}
|
398
|
-
|
399
|
-
/**
|
400
|
-
* Button component that adapts its styles based on the current theme.
|
401
|
-
* Supports dynamic styling, full-width option, rounded corners, and different types.
|
402
|
-
*
|
403
|
-
* @param disabled - If true, the button is disabled and not pressable.
|
404
|
-
* @param isFullWidth - If true, the button expands to full width of its container.
|
405
|
-
* @param children - Text content of the button.
|
406
|
-
* @param onPress - Function to call when the button is pressed.
|
407
|
-
* @param rounded - If true, the button has rounded corners.
|
408
|
-
* @param borderRadius - Custom border radius value. Overrides the `rounded` prop if provided.
|
409
|
-
* @param type - Specifies the button type for styling ('submit', 'button', 'cancel').
|
410
|
-
*/
|
411
|
-
var Button = function Button(_a) {
|
412
|
-
var children = _a.children,
|
413
|
-
_b = _a.disabled,
|
414
|
-
disabled = _b === void 0 ? false : _b,
|
415
|
-
_c = _a.type,
|
416
|
-
type = _c === void 0 ? 'button' : _c,
|
417
|
-
_d = _a.rounded,
|
418
|
-
rounded = _d === void 0 ? true : _d,
|
419
|
-
_e = _a.borderRadius,
|
420
|
-
borderRadius = _e === void 0 ? 30 : _e,
|
421
|
-
_f = _a.isFullWidth,
|
422
|
-
isFullWidth = _f === void 0 ? false : _f,
|
423
|
-
_g = _a.loading,
|
424
|
-
loading = _g === void 0 ? false : _g,
|
425
|
-
onPress = _a.onPress;
|
426
|
-
var theme = useContext(ThemeContext).theme;
|
427
|
-
var colors = theme.colors;
|
428
|
-
var computedStyles = useMemo(function () {
|
429
|
-
return StyleSheet.flatten([styles$5.button, typeStyles(type, disabled, colors), rounded && {
|
430
|
-
borderRadius: borderRadius
|
431
|
-
}, isFullWidth && {
|
432
|
-
width: '100%'
|
433
|
-
}, (disabled || loading) && styles$5.disabled]);
|
434
|
-
}, [type, disabled, loading, rounded, borderRadius, isFullWidth, colors]);
|
435
|
-
var textColor = useMemo(function () {
|
436
|
-
return {
|
437
|
-
color: colors.textButton.hex
|
438
|
-
};
|
439
|
-
}, [type, colors]);
|
440
|
-
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
441
|
-
style: computedStyles,
|
442
|
-
disabled: disabled || loading,
|
443
|
-
onPress: onPress,
|
444
|
-
activeOpacity: 0.7
|
445
|
-
}, loading ? (
|
446
|
-
/*#__PURE__*/
|
447
|
-
// Show loading spinner if loading
|
448
|
-
React.createElement(ActivityIndicator, {
|
449
|
-
size: "small",
|
450
|
-
color: colors.textButton.hex
|
451
|
-
})) : (/*#__PURE__*/React.createElement(Text$1, {
|
452
|
-
style: textColor
|
453
|
-
}, Array.isArray(children) ? children.join('').toUpperCase() : children === null || children === void 0 ? void 0 : children.toUpperCase())));
|
373
|
+
return context;
|
454
374
|
};
|
455
|
-
var
|
456
|
-
button: {
|
457
|
-
justifyContent: 'center',
|
458
|
-
alignItems: 'center',
|
459
|
-
paddingVertical: 10,
|
460
|
-
paddingHorizontal: 20
|
461
|
-
},
|
462
|
-
disabled: {
|
463
|
-
opacity: 0.6
|
464
|
-
}
|
465
|
-
});
|
466
|
-
|
467
|
-
// src/cards/Card.tsx
|
468
|
-
/**
|
469
|
-
* Card component that adapts its styles based on the current theme.
|
470
|
-
* Supports dynamic styling, shadows, and press animations.
|
471
|
-
*
|
472
|
-
* @param children - The content to be displayed inside the Card.
|
473
|
-
* @param style - Additional styles to apply to the Card.
|
474
|
-
* @param onPress - Function to execute when the Card is pressed.
|
475
|
-
* @param pressable - Determines if the Card is pressable. Defaults to false.
|
476
|
-
* @param borderRadius - Border radius of the Card. Defaults to 12.
|
477
|
-
* @param elevation - Elevation for Android shadow. Overrides default.
|
478
|
-
* @param shadowProps - Custom shadow properties for iOS. Overrides defaults.
|
479
|
-
*/
|
480
|
-
var Card = function Card(_a) {
|
375
|
+
var Form = function Form(_a) {
|
481
376
|
var children = _a.children,
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
377
|
+
onSubmit = _a.onSubmit;
|
378
|
+
var _b = useState({}),
|
379
|
+
formValues = _b[0],
|
380
|
+
setFormValues = _b[1];
|
381
|
+
var _c = useState({}),
|
382
|
+
errors = _c[0],
|
383
|
+
setErrors = _c[1];
|
384
|
+
var setFormValue = function setFormValue(name, value) {
|
385
|
+
setFormValues(function (prev) {
|
386
|
+
var _a;
|
387
|
+
return __assign(__assign({}, prev), (_a = {}, _a[name] = value, _a));
|
388
|
+
});
|
389
|
+
};
|
390
|
+
var handleSubmit = function handleSubmit() {
|
391
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
392
|
+
var validationErrors;
|
393
|
+
return __generator(this, function (_a) {
|
394
|
+
switch (_a.label) {
|
395
|
+
case 0:
|
396
|
+
return [4 /*yield*/, onSubmit(formValues)];
|
397
|
+
case 1:
|
398
|
+
validationErrors = _a.sent();
|
399
|
+
// Set the validation errors in state
|
400
|
+
setErrors(validationErrors);
|
401
|
+
// Prevent submission if there are any errors
|
402
|
+
if (Object.keys(validationErrors).length > 0) {
|
403
|
+
return [2 /*return*/]; // Prevent submission
|
404
|
+
}
|
405
|
+
// If no errors, continue submission process (e.g., calling an API, navigating, etc.)
|
406
|
+
console.log('Form submitted successfully:', formValues);
|
407
|
+
return [2 /*return*/];
|
408
|
+
}
|
409
|
+
});
|
410
|
+
});
|
411
|
+
};
|
412
|
+
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
413
|
+
value: {
|
414
|
+
formValues: formValues,
|
415
|
+
setFormValue: setFormValue,
|
416
|
+
errors: errors,
|
417
|
+
setErrors: setErrors,
|
418
|
+
handleSubmit: handleSubmit
|
509
419
|
}
|
510
|
-
});
|
511
|
-
var cardStyles = [styles$4.container, {
|
512
|
-
borderRadius: borderRadius,
|
513
|
-
backgroundColor: colors.body.hex
|
514
|
-
}, defaultShadow,
|
515
|
-
// Dynamic shadows based on platform
|
516
|
-
style // External styles
|
517
|
-
];
|
518
|
-
return pressable ? (/*#__PURE__*/React.createElement(TouchableOpacity, {
|
519
|
-
activeOpacity: 0.8,
|
520
|
-
onPress: onPress,
|
521
|
-
style: cardStyles
|
522
|
-
}, children)) : (/*#__PURE__*/React.createElement(View, {
|
523
|
-
style: cardStyles
|
524
|
-
}, children));
|
420
|
+
}, children);
|
525
421
|
};
|
526
|
-
var styles$4 = StyleSheet.create({
|
527
|
-
container: {
|
528
|
-
padding: 16,
|
529
|
-
borderRadius: 12
|
530
|
-
// Shadows handled dynamically with platform logic
|
531
|
-
}
|
532
|
-
});
|
533
422
|
|
534
423
|
// src/fonts/Text.tsx
|
535
424
|
/**
|
@@ -595,78 +484,29 @@ StyleSheet.create({
|
|
595
484
|
// Define any default styles if needed
|
596
485
|
});
|
597
486
|
|
598
|
-
// src/forms/FormContext.tsx
|
599
|
-
var FormContext = /*#__PURE__*/createContext(undefined);
|
600
|
-
var useFormContext = function useFormContext() {
|
601
|
-
var context = useContext(FormContext);
|
602
|
-
if (!context) {
|
603
|
-
throw new Error("useFormContext must be used within a Form");
|
604
|
-
}
|
605
|
-
return context;
|
606
|
-
};
|
607
|
-
var Form = function Form(_a) {
|
608
|
-
var children = _a.children,
|
609
|
-
onSubmit = _a.onSubmit;
|
610
|
-
var _b = useState({}),
|
611
|
-
formValues = _b[0],
|
612
|
-
setFormValues = _b[1];
|
613
|
-
var _c = useState({}),
|
614
|
-
errors = _c[0],
|
615
|
-
setErrors = _c[1];
|
616
|
-
var setFormValue = function setFormValue(name, value) {
|
617
|
-
setFormValues(function (prev) {
|
618
|
-
var _a;
|
619
|
-
return __assign(__assign({}, prev), (_a = {}, _a[name] = value, _a));
|
620
|
-
});
|
621
|
-
};
|
622
|
-
var handleSubmit = function handleSubmit() {
|
623
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
624
|
-
var validationErrors;
|
625
|
-
return __generator(this, function (_a) {
|
626
|
-
switch (_a.label) {
|
627
|
-
case 0:
|
628
|
-
return [4 /*yield*/, onSubmit(formValues)];
|
629
|
-
case 1:
|
630
|
-
validationErrors = _a.sent();
|
631
|
-
// Set the validation errors in state
|
632
|
-
setErrors(validationErrors);
|
633
|
-
// Prevent submission if there are any errors
|
634
|
-
if (Object.keys(validationErrors).length > 0) {
|
635
|
-
return [2 /*return*/]; // Prevent submission
|
636
|
-
}
|
637
|
-
return [2 /*return*/];
|
638
|
-
}
|
639
|
-
});
|
640
|
-
});
|
641
|
-
};
|
642
|
-
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
643
|
-
value: {
|
644
|
-
formValues: formValues,
|
645
|
-
setFormValue: setFormValue,
|
646
|
-
errors: errors,
|
647
|
-
setErrors: setErrors,
|
648
|
-
handleSubmit: handleSubmit
|
649
|
-
}
|
650
|
-
}, children);
|
651
|
-
};
|
652
|
-
|
653
487
|
// src/forms/ErrorList.tsx
|
654
488
|
var ErrorList = function ErrorList(_a) {
|
655
489
|
var errors = _a.errors;
|
490
|
+
var theme = useContext(ThemeContext).theme;
|
491
|
+
var colors = theme.colors;
|
656
492
|
return /*#__PURE__*/React.createElement(View, {
|
657
|
-
style: styles$
|
493
|
+
style: styles$5.container
|
658
494
|
}, errors.map(function (error, index) {
|
659
495
|
return /*#__PURE__*/React.createElement(View, {
|
660
496
|
key: index,
|
661
|
-
style: styles$
|
497
|
+
style: styles$5.errorItem
|
662
498
|
}, /*#__PURE__*/React.createElement(Text, {
|
663
|
-
style: styles$
|
499
|
+
style: [styles$5.bullet, {
|
500
|
+
color: colors.error.hex
|
501
|
+
}]
|
664
502
|
}, "\u2022"), /*#__PURE__*/React.createElement(Text, {
|
665
|
-
style: styles$
|
503
|
+
style: [styles$5.errorText, {
|
504
|
+
color: colors.error.hex
|
505
|
+
}]
|
666
506
|
}, error));
|
667
507
|
}));
|
668
508
|
};
|
669
|
-
var styles$
|
509
|
+
var styles$5 = StyleSheet.create({
|
670
510
|
container: {
|
671
511
|
marginTop: 4
|
672
512
|
},
|
@@ -677,14 +517,10 @@ var styles$3 = StyleSheet.create({
|
|
677
517
|
},
|
678
518
|
bullet: {
|
679
519
|
marginRight: 4,
|
680
|
-
color: '#FF5252',
|
681
|
-
// Should use 'error' color from theme
|
682
520
|
fontSize: 12
|
683
521
|
},
|
684
522
|
errorText: {
|
685
523
|
flex: 1,
|
686
|
-
color: '#FF5252',
|
687
|
-
// Should use 'error' color from theme
|
688
524
|
fontSize: 12
|
689
525
|
}
|
690
526
|
});
|
@@ -705,13 +541,13 @@ var Input = function Input(_a) {
|
|
705
541
|
setFormValue(name, text);
|
706
542
|
};
|
707
543
|
return /*#__PURE__*/React.createElement(View, {
|
708
|
-
style: styles$
|
544
|
+
style: styles$4.container
|
709
545
|
}, /*#__PURE__*/React.createElement(Text, {
|
710
|
-
style: [styles$
|
546
|
+
style: [styles$4.label, {
|
711
547
|
color: colors.text.hex
|
712
548
|
}]
|
713
549
|
}, label), /*#__PURE__*/React.createElement(TextInput, __assign({
|
714
|
-
style: [styles$
|
550
|
+
style: [styles$4.input, {
|
715
551
|
backgroundColor: colors.body.hex,
|
716
552
|
borderColor: formErrors[name] ? colors.error.hex : '#CCC',
|
717
553
|
color: colors.text.hex
|
@@ -724,7 +560,7 @@ var Input = function Input(_a) {
|
|
724
560
|
errors: formErrors[name]
|
725
561
|
})));
|
726
562
|
};
|
727
|
-
var styles$
|
563
|
+
var styles$4 = StyleSheet.create({
|
728
564
|
container: {
|
729
565
|
marginBottom: 16
|
730
566
|
},
|
@@ -755,11 +591,11 @@ var TextArea = function TextArea(_a) {
|
|
755
591
|
setFormValue(name, text);
|
756
592
|
};
|
757
593
|
return /*#__PURE__*/React.createElement(View, {
|
758
|
-
style: styles$
|
594
|
+
style: styles$3.container
|
759
595
|
}, /*#__PURE__*/React.createElement(Text, {
|
760
|
-
style: styles$
|
596
|
+
style: styles$3.label
|
761
597
|
}, label), /*#__PURE__*/React.createElement(TextInput, __assign({
|
762
|
-
style: [styles$
|
598
|
+
style: [styles$3.textArea, style],
|
763
599
|
value: formValues[name] || '',
|
764
600
|
onChangeText: handleChange,
|
765
601
|
placeholder: label,
|
@@ -772,7 +608,7 @@ var TextArea = function TextArea(_a) {
|
|
772
608
|
errors: formErrors[name]
|
773
609
|
})));
|
774
610
|
};
|
775
|
-
var styles$
|
611
|
+
var styles$3 = StyleSheet.create({
|
776
612
|
container: {
|
777
613
|
marginBottom: 16
|
778
614
|
},
|
@@ -798,18 +634,196 @@ var styles$1 = StyleSheet.create({
|
|
798
634
|
var Label = function Label(_a) {
|
799
635
|
var text = _a.text,
|
800
636
|
style = _a.style;
|
637
|
+
var theme = useContext(ThemeContext).theme;
|
638
|
+
var colors = theme.colors;
|
801
639
|
return /*#__PURE__*/React.createElement(Text, {
|
802
|
-
style: [styles.label, style
|
640
|
+
style: [styles$2.label, style, {
|
641
|
+
color: colors.text.hex
|
642
|
+
}]
|
803
643
|
}, text);
|
804
644
|
};
|
805
|
-
var styles = StyleSheet.create({
|
645
|
+
var styles$2 = StyleSheet.create({
|
806
646
|
label: {
|
807
647
|
marginBottom: 4,
|
808
|
-
color: '#000',
|
809
|
-
// Should be themed
|
810
648
|
fontWeight: '500'
|
811
649
|
}
|
812
650
|
});
|
813
651
|
|
652
|
+
// src/components/Button.tsx
|
653
|
+
/**
|
654
|
+
* Determines the styles based on the button type and whether it is disabled.
|
655
|
+
*
|
656
|
+
* @param type - The type of the button ('submit', 'button', 'cancel').
|
657
|
+
* @param disabled - Whether the button is disabled.
|
658
|
+
* @param themeColors - The theme colors.
|
659
|
+
* @returns The computed style for the button.
|
660
|
+
*/
|
661
|
+
function typeStyles(type, disabled, themeColors) {
|
662
|
+
switch (type) {
|
663
|
+
case 'submit':
|
664
|
+
return {
|
665
|
+
backgroundColor: "rgba(".concat(themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.rgb.r, ", ").concat(themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.rgb.g, ", ").concat(themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.rgb.b, ", ").concat(disabled ? 0.5 : 1, ")"),
|
666
|
+
borderWidth: 2,
|
667
|
+
borderColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.hex
|
668
|
+
};
|
669
|
+
case 'button':
|
670
|
+
return {
|
671
|
+
backgroundColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.hex,
|
672
|
+
borderColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.secondary.hex,
|
673
|
+
opacity: disabled ? 0.5 : 1,
|
674
|
+
borderWidth: 2
|
675
|
+
};
|
676
|
+
case 'cancel':
|
677
|
+
return {
|
678
|
+
backgroundColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.background.hex,
|
679
|
+
borderWidth: 0
|
680
|
+
};
|
681
|
+
default:
|
682
|
+
return {};
|
683
|
+
}
|
684
|
+
}
|
685
|
+
/**
|
686
|
+
* Button component that adapts its styles based on the current theme.
|
687
|
+
* Supports dynamic styling, full-width option, rounded corners, and different types.
|
688
|
+
*
|
689
|
+
* @param disabled - If true, the button is disabled and not pressable.
|
690
|
+
* @param isFullWidth - If true, the button expands to full width of its container.
|
691
|
+
* @param children - Text content of the button.
|
692
|
+
* @param onPress - Function to call when the button is pressed.
|
693
|
+
* @param rounded - If true, the button has rounded corners.
|
694
|
+
* @param borderRadius - Custom border radius value. Overrides the `rounded` prop if provided.
|
695
|
+
* @param type - Specifies the button type for styling ('submit', 'button', 'cancel').
|
696
|
+
*/
|
697
|
+
var Button = function Button(_a) {
|
698
|
+
var children = _a.children,
|
699
|
+
_b = _a.disabled,
|
700
|
+
disabled = _b === void 0 ? false : _b,
|
701
|
+
_c = _a.type,
|
702
|
+
type = _c === void 0 ? 'button' : _c,
|
703
|
+
_d = _a.rounded,
|
704
|
+
rounded = _d === void 0 ? true : _d,
|
705
|
+
_e = _a.borderRadius,
|
706
|
+
borderRadius = _e === void 0 ? 30 : _e,
|
707
|
+
_f = _a.isFullWidth,
|
708
|
+
isFullWidth = _f === void 0 ? false : _f,
|
709
|
+
_g = _a.loading,
|
710
|
+
loading = _g === void 0 ? false : _g,
|
711
|
+
onPress = _a.onPress;
|
712
|
+
var theme = useContext(ThemeContext).theme;
|
713
|
+
var colors = theme.colors;
|
714
|
+
var handleSubmit = useFormContext().handleSubmit;
|
715
|
+
var computedStyles = useMemo(function () {
|
716
|
+
return StyleSheet.flatten([styles$1.button, typeStyles(type, disabled, colors), rounded && {
|
717
|
+
borderRadius: borderRadius
|
718
|
+
}, isFullWidth && {
|
719
|
+
width: '100%'
|
720
|
+
}, (disabled || loading) && styles$1.disabled]);
|
721
|
+
}, [type, disabled, loading, rounded, borderRadius, isFullWidth, colors]);
|
722
|
+
var textColor = useMemo(function () {
|
723
|
+
return {
|
724
|
+
color: colors.textButton.hex
|
725
|
+
};
|
726
|
+
}, [type, colors]);
|
727
|
+
var handlePress = function handlePress() {
|
728
|
+
if (type === 'submit') {
|
729
|
+
handleSubmit(); // Call the form's submit handler
|
730
|
+
} else if (onPress) {
|
731
|
+
onPress(); // Call a custom handler if needed
|
732
|
+
}
|
733
|
+
};
|
734
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
735
|
+
style: computedStyles,
|
736
|
+
disabled: disabled || loading,
|
737
|
+
onPress: handlePress,
|
738
|
+
activeOpacity: 0.7
|
739
|
+
}, loading ? (
|
740
|
+
/*#__PURE__*/
|
741
|
+
// Show loading spinner if loading
|
742
|
+
React.createElement(ActivityIndicator, {
|
743
|
+
size: "small",
|
744
|
+
color: colors.textButton.hex
|
745
|
+
})) : (/*#__PURE__*/React.createElement(Text$1, {
|
746
|
+
style: textColor
|
747
|
+
}, Array.isArray(children) ? children.join('').toUpperCase() : children === null || children === void 0 ? void 0 : children.toUpperCase())));
|
748
|
+
};
|
749
|
+
var styles$1 = StyleSheet.create({
|
750
|
+
button: {
|
751
|
+
justifyContent: 'center',
|
752
|
+
alignItems: 'center',
|
753
|
+
paddingVertical: 10,
|
754
|
+
paddingHorizontal: 20
|
755
|
+
},
|
756
|
+
disabled: {
|
757
|
+
opacity: 0.6
|
758
|
+
}
|
759
|
+
});
|
760
|
+
|
761
|
+
// src/cards/Card.tsx
|
762
|
+
/**
|
763
|
+
* Card component that adapts its styles based on the current theme.
|
764
|
+
* Supports dynamic styling, shadows, and press animations.
|
765
|
+
*
|
766
|
+
* @param children - The content to be displayed inside the Card.
|
767
|
+
* @param style - Additional styles to apply to the Card.
|
768
|
+
* @param onPress - Function to execute when the Card is pressed.
|
769
|
+
* @param pressable - Determines if the Card is pressable. Defaults to false.
|
770
|
+
* @param borderRadius - Border radius of the Card. Defaults to 12.
|
771
|
+
* @param elevation - Elevation for Android shadow. Overrides default.
|
772
|
+
* @param shadowProps - Custom shadow properties for iOS. Overrides defaults.
|
773
|
+
*/
|
774
|
+
var Card = function Card(_a) {
|
775
|
+
var children = _a.children,
|
776
|
+
style = _a.style,
|
777
|
+
onPress = _a.onPress,
|
778
|
+
_b = _a.pressable,
|
779
|
+
pressable = _b === void 0 ? false : _b,
|
780
|
+
_c = _a.borderRadius,
|
781
|
+
borderRadius = _c === void 0 ? 12 : _c,
|
782
|
+
_d = _a.elevation,
|
783
|
+
elevation = _d === void 0 ? 4 : _d,
|
784
|
+
_e = _a.shadowProps,
|
785
|
+
shadowProps = _e === void 0 ? {} : _e;
|
786
|
+
var theme = useContext(ThemeContext).theme;
|
787
|
+
var colors = theme.colors;
|
788
|
+
// Animation state for pressable effect
|
789
|
+
// Default shadow styles (improved platform-specific handling)
|
790
|
+
var defaultShadow = Platform.select({
|
791
|
+
ios: {
|
792
|
+
shadowColor: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowColor) || colors.text.hex,
|
793
|
+
// Defaulting to theme text color
|
794
|
+
shadowOffset: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOffset) || {
|
795
|
+
width: 0,
|
796
|
+
height: 2
|
797
|
+
},
|
798
|
+
shadowOpacity: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOpacity) || 0.1,
|
799
|
+
shadowRadius: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowRadius) || 4
|
800
|
+
},
|
801
|
+
android: {
|
802
|
+
elevation: elevation // Only applies to Android
|
803
|
+
}
|
804
|
+
});
|
805
|
+
var cardStyles = [styles.container, {
|
806
|
+
borderRadius: borderRadius,
|
807
|
+
backgroundColor: colors.body.hex
|
808
|
+
}, defaultShadow,
|
809
|
+
// Dynamic shadows based on platform
|
810
|
+
style // External styles
|
811
|
+
];
|
812
|
+
return pressable ? (/*#__PURE__*/React.createElement(TouchableOpacity, {
|
813
|
+
activeOpacity: 0.8,
|
814
|
+
onPress: onPress,
|
815
|
+
style: cardStyles
|
816
|
+
}, children)) : (/*#__PURE__*/React.createElement(View, {
|
817
|
+
style: cardStyles
|
818
|
+
}, children));
|
819
|
+
};
|
820
|
+
var styles = StyleSheet.create({
|
821
|
+
container: {
|
822
|
+
padding: 16,
|
823
|
+
borderRadius: 12
|
824
|
+
// Shadows handled dynamically with platform logic
|
825
|
+
}
|
826
|
+
});
|
827
|
+
|
814
828
|
export { Button, Card, ErrorList, Form, Input, Label, Text, TextArea, ThemeContext, ThemeProvider, ThemeToggle, useFormContext };
|
815
829
|
//# sourceMappingURL=index.esm.js.map
|