aport-tools 4.1.23 → 4.1.24
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/forms/FormContext.d.ts +2 -1
- package/dist/index.esm.js +244 -233
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +243 -232
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
@@ -3,7 +3,8 @@ interface FormContextProps {
|
|
3
3
|
formValues: Record<string, any>;
|
4
4
|
setFormValue: (name: string, value: any) => void;
|
5
5
|
errors: Record<string, string[]>;
|
6
|
-
|
6
|
+
setErrors: (errors: Record<string, string[]>) => void;
|
7
|
+
handleSubmit: () => void;
|
7
8
|
}
|
8
9
|
export declare const useFormContext: () => FormContextProps;
|
9
10
|
interface FormProps {
|
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,83 +484,29 @@ StyleSheet.create({
|
|
595
484
|
// Define any default styles if needed
|
596
485
|
});
|
597
486
|
|
598
|
-
var FormContext = /*#__PURE__*/createContext(undefined);
|
599
|
-
var useFormContext = function useFormContext() {
|
600
|
-
var context = useContext(FormContext);
|
601
|
-
if (!context) {
|
602
|
-
throw new Error("useFormContext must be used within a Form");
|
603
|
-
}
|
604
|
-
return context;
|
605
|
-
};
|
606
|
-
var Form = function Form(_a) {
|
607
|
-
var children = _a.children,
|
608
|
-
onSubmit = _a.onSubmit;
|
609
|
-
var _b = useState({}),
|
610
|
-
formValues = _b[0],
|
611
|
-
setFormValues = _b[1];
|
612
|
-
var _c = useState({}),
|
613
|
-
errors = _c[0],
|
614
|
-
setErrors = _c[1];
|
615
|
-
var setFormValue = function setFormValue(name, value) {
|
616
|
-
setFormValues(function (prev) {
|
617
|
-
var _a;
|
618
|
-
return __assign(__assign({}, prev), (_a = {}, _a[name] = value, _a));
|
619
|
-
});
|
620
|
-
};
|
621
|
-
var handleSubmit = function handleSubmit(event) {
|
622
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
623
|
-
var validationErrors;
|
624
|
-
return __generator(this, function (_a) {
|
625
|
-
switch (_a.label) {
|
626
|
-
case 0:
|
627
|
-
event.preventDefault(); // Prevent native submission
|
628
|
-
return [4 /*yield*/, onSubmit(formValues)];
|
629
|
-
case 1:
|
630
|
-
validationErrors = _a.sent();
|
631
|
-
setErrors(validationErrors);
|
632
|
-
if (Object.keys(validationErrors).length > 0) {
|
633
|
-
return [2 /*return*/]; // Do not proceed if there are validation errors
|
634
|
-
}
|
635
|
-
return [2 /*return*/];
|
636
|
-
}
|
637
|
-
});
|
638
|
-
});
|
639
|
-
};
|
640
|
-
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
641
|
-
value: {
|
642
|
-
formValues: formValues,
|
643
|
-
setFormValue: setFormValue,
|
644
|
-
errors: errors,
|
645
|
-
handleSubmit: handleSubmit
|
646
|
-
}
|
647
|
-
}, /*#__PURE__*/React.createElement("form", {
|
648
|
-
onSubmit: handleSubmit
|
649
|
-
}, children));
|
650
|
-
};
|
651
|
-
|
652
487
|
// src/forms/ErrorList.tsx
|
653
488
|
var ErrorList = function ErrorList(_a) {
|
654
489
|
var errors = _a.errors;
|
655
490
|
var theme = useContext(ThemeContext).theme;
|
656
491
|
var colors = theme.colors;
|
657
492
|
return /*#__PURE__*/React.createElement(View, {
|
658
|
-
style: styles$
|
493
|
+
style: styles$5.container
|
659
494
|
}, errors.map(function (error, index) {
|
660
495
|
return /*#__PURE__*/React.createElement(View, {
|
661
496
|
key: index,
|
662
|
-
style: styles$
|
497
|
+
style: styles$5.errorItem
|
663
498
|
}, /*#__PURE__*/React.createElement(Text, {
|
664
|
-
style: [styles$
|
499
|
+
style: [styles$5.bullet, {
|
665
500
|
color: colors.error.hex
|
666
501
|
}]
|
667
502
|
}, "\u2022"), /*#__PURE__*/React.createElement(Text, {
|
668
|
-
style: [styles$
|
503
|
+
style: [styles$5.errorText, {
|
669
504
|
color: colors.error.hex
|
670
505
|
}]
|
671
506
|
}, error));
|
672
507
|
}));
|
673
508
|
};
|
674
|
-
var styles$
|
509
|
+
var styles$5 = StyleSheet.create({
|
675
510
|
container: {
|
676
511
|
marginTop: 4
|
677
512
|
},
|
@@ -706,13 +541,13 @@ var Input = function Input(_a) {
|
|
706
541
|
setFormValue(name, text);
|
707
542
|
};
|
708
543
|
return /*#__PURE__*/React.createElement(View, {
|
709
|
-
style: styles$
|
544
|
+
style: styles$4.container
|
710
545
|
}, /*#__PURE__*/React.createElement(Text, {
|
711
|
-
style: [styles$
|
546
|
+
style: [styles$4.label, {
|
712
547
|
color: colors.text.hex
|
713
548
|
}]
|
714
549
|
}, label), /*#__PURE__*/React.createElement(TextInput, __assign({
|
715
|
-
style: [styles$
|
550
|
+
style: [styles$4.input, {
|
716
551
|
backgroundColor: colors.body.hex,
|
717
552
|
borderColor: formErrors[name] ? colors.error.hex : '#CCC',
|
718
553
|
color: colors.text.hex
|
@@ -725,7 +560,7 @@ var Input = function Input(_a) {
|
|
725
560
|
errors: formErrors[name]
|
726
561
|
})));
|
727
562
|
};
|
728
|
-
var styles$
|
563
|
+
var styles$4 = StyleSheet.create({
|
729
564
|
container: {
|
730
565
|
marginBottom: 16
|
731
566
|
},
|
@@ -756,11 +591,11 @@ var TextArea = function TextArea(_a) {
|
|
756
591
|
setFormValue(name, text);
|
757
592
|
};
|
758
593
|
return /*#__PURE__*/React.createElement(View, {
|
759
|
-
style: styles$
|
594
|
+
style: styles$3.container
|
760
595
|
}, /*#__PURE__*/React.createElement(Text, {
|
761
|
-
style: styles$
|
596
|
+
style: styles$3.label
|
762
597
|
}, label), /*#__PURE__*/React.createElement(TextInput, __assign({
|
763
|
-
style: [styles$
|
598
|
+
style: [styles$3.textArea, style],
|
764
599
|
value: formValues[name] || '',
|
765
600
|
onChangeText: handleChange,
|
766
601
|
placeholder: label,
|
@@ -773,7 +608,7 @@ var TextArea = function TextArea(_a) {
|
|
773
608
|
errors: formErrors[name]
|
774
609
|
})));
|
775
610
|
};
|
776
|
-
var styles$
|
611
|
+
var styles$3 = StyleSheet.create({
|
777
612
|
container: {
|
778
613
|
marginBottom: 16
|
779
614
|
},
|
@@ -802,17 +637,193 @@ var Label = function Label(_a) {
|
|
802
637
|
var theme = useContext(ThemeContext).theme;
|
803
638
|
var colors = theme.colors;
|
804
639
|
return /*#__PURE__*/React.createElement(Text, {
|
805
|
-
style: [styles.label, style, {
|
640
|
+
style: [styles$2.label, style, {
|
806
641
|
color: colors.text.hex
|
807
642
|
}]
|
808
643
|
}, text);
|
809
644
|
};
|
810
|
-
var styles = StyleSheet.create({
|
645
|
+
var styles$2 = StyleSheet.create({
|
811
646
|
label: {
|
812
647
|
marginBottom: 4,
|
813
648
|
fontWeight: '500'
|
814
649
|
}
|
815
650
|
});
|
816
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
|
+
|
817
828
|
export { Button, Card, ErrorList, Form, Input, Label, Text, TextArea, ThemeContext, ThemeProvider, ThemeToggle, useFormContext };
|
818
829
|
//# sourceMappingURL=index.esm.js.map
|