aport-tools 4.1.23 → 4.1.25
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/forms/FormContext.d.ts +2 -1
- package/dist/index.esm.js +242 -233
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +241 -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.25 | 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,60 @@ 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
|
+
return [2 /*return*/];
|
406
|
+
}
|
407
|
+
});
|
408
|
+
});
|
409
|
+
};
|
410
|
+
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
411
|
+
value: {
|
412
|
+
formValues: formValues,
|
413
|
+
setFormValue: setFormValue,
|
414
|
+
errors: errors,
|
415
|
+
setErrors: setErrors,
|
416
|
+
handleSubmit: handleSubmit
|
509
417
|
}
|
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));
|
418
|
+
}, children);
|
525
419
|
};
|
526
|
-
var styles$4 = StyleSheet.create({
|
527
|
-
container: {
|
528
|
-
padding: 16,
|
529
|
-
borderRadius: 12
|
530
|
-
// Shadows handled dynamically with platform logic
|
531
|
-
}
|
532
|
-
});
|
533
420
|
|
534
421
|
// src/fonts/Text.tsx
|
535
422
|
/**
|
@@ -595,83 +482,29 @@ StyleSheet.create({
|
|
595
482
|
// Define any default styles if needed
|
596
483
|
});
|
597
484
|
|
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
485
|
// src/forms/ErrorList.tsx
|
653
486
|
var ErrorList = function ErrorList(_a) {
|
654
487
|
var errors = _a.errors;
|
655
488
|
var theme = useContext(ThemeContext).theme;
|
656
489
|
var colors = theme.colors;
|
657
490
|
return /*#__PURE__*/React.createElement(View, {
|
658
|
-
style: styles$
|
491
|
+
style: styles$5.container
|
659
492
|
}, errors.map(function (error, index) {
|
660
493
|
return /*#__PURE__*/React.createElement(View, {
|
661
494
|
key: index,
|
662
|
-
style: styles$
|
495
|
+
style: styles$5.errorItem
|
663
496
|
}, /*#__PURE__*/React.createElement(Text, {
|
664
|
-
style: [styles$
|
497
|
+
style: [styles$5.bullet, {
|
665
498
|
color: colors.error.hex
|
666
499
|
}]
|
667
500
|
}, "\u2022"), /*#__PURE__*/React.createElement(Text, {
|
668
|
-
style: [styles$
|
501
|
+
style: [styles$5.errorText, {
|
669
502
|
color: colors.error.hex
|
670
503
|
}]
|
671
504
|
}, error));
|
672
505
|
}));
|
673
506
|
};
|
674
|
-
var styles$
|
507
|
+
var styles$5 = StyleSheet.create({
|
675
508
|
container: {
|
676
509
|
marginTop: 4
|
677
510
|
},
|
@@ -706,13 +539,13 @@ var Input = function Input(_a) {
|
|
706
539
|
setFormValue(name, text);
|
707
540
|
};
|
708
541
|
return /*#__PURE__*/React.createElement(View, {
|
709
|
-
style: styles$
|
542
|
+
style: styles$4.container
|
710
543
|
}, /*#__PURE__*/React.createElement(Text, {
|
711
|
-
style: [styles$
|
544
|
+
style: [styles$4.label, {
|
712
545
|
color: colors.text.hex
|
713
546
|
}]
|
714
547
|
}, label), /*#__PURE__*/React.createElement(TextInput, __assign({
|
715
|
-
style: [styles$
|
548
|
+
style: [styles$4.input, {
|
716
549
|
backgroundColor: colors.body.hex,
|
717
550
|
borderColor: formErrors[name] ? colors.error.hex : '#CCC',
|
718
551
|
color: colors.text.hex
|
@@ -725,7 +558,7 @@ var Input = function Input(_a) {
|
|
725
558
|
errors: formErrors[name]
|
726
559
|
})));
|
727
560
|
};
|
728
|
-
var styles$
|
561
|
+
var styles$4 = StyleSheet.create({
|
729
562
|
container: {
|
730
563
|
marginBottom: 16
|
731
564
|
},
|
@@ -756,11 +589,11 @@ var TextArea = function TextArea(_a) {
|
|
756
589
|
setFormValue(name, text);
|
757
590
|
};
|
758
591
|
return /*#__PURE__*/React.createElement(View, {
|
759
|
-
style: styles$
|
592
|
+
style: styles$3.container
|
760
593
|
}, /*#__PURE__*/React.createElement(Text, {
|
761
|
-
style: styles$
|
594
|
+
style: styles$3.label
|
762
595
|
}, label), /*#__PURE__*/React.createElement(TextInput, __assign({
|
763
|
-
style: [styles$
|
596
|
+
style: [styles$3.textArea, style],
|
764
597
|
value: formValues[name] || '',
|
765
598
|
onChangeText: handleChange,
|
766
599
|
placeholder: label,
|
@@ -773,7 +606,7 @@ var TextArea = function TextArea(_a) {
|
|
773
606
|
errors: formErrors[name]
|
774
607
|
})));
|
775
608
|
};
|
776
|
-
var styles$
|
609
|
+
var styles$3 = StyleSheet.create({
|
777
610
|
container: {
|
778
611
|
marginBottom: 16
|
779
612
|
},
|
@@ -802,17 +635,193 @@ var Label = function Label(_a) {
|
|
802
635
|
var theme = useContext(ThemeContext).theme;
|
803
636
|
var colors = theme.colors;
|
804
637
|
return /*#__PURE__*/React.createElement(Text, {
|
805
|
-
style: [styles.label, style, {
|
638
|
+
style: [styles$2.label, style, {
|
806
639
|
color: colors.text.hex
|
807
640
|
}]
|
808
641
|
}, text);
|
809
642
|
};
|
810
|
-
var styles = StyleSheet.create({
|
643
|
+
var styles$2 = StyleSheet.create({
|
811
644
|
label: {
|
812
645
|
marginBottom: 4,
|
813
646
|
fontWeight: '500'
|
814
647
|
}
|
815
648
|
});
|
816
649
|
|
650
|
+
// src/components/Button.tsx
|
651
|
+
/**
|
652
|
+
* Determines the styles based on the button type and whether it is disabled.
|
653
|
+
*
|
654
|
+
* @param type - The type of the button ('submit', 'button', 'cancel').
|
655
|
+
* @param disabled - Whether the button is disabled.
|
656
|
+
* @param themeColors - The theme colors.
|
657
|
+
* @returns The computed style for the button.
|
658
|
+
*/
|
659
|
+
function typeStyles(type, disabled, themeColors) {
|
660
|
+
switch (type) {
|
661
|
+
case 'submit':
|
662
|
+
return {
|
663
|
+
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, ")"),
|
664
|
+
borderWidth: 2,
|
665
|
+
borderColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.hex
|
666
|
+
};
|
667
|
+
case 'button':
|
668
|
+
return {
|
669
|
+
backgroundColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.primary.hex,
|
670
|
+
borderColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.secondary.hex,
|
671
|
+
opacity: disabled ? 0.5 : 1,
|
672
|
+
borderWidth: 2
|
673
|
+
};
|
674
|
+
case 'cancel':
|
675
|
+
return {
|
676
|
+
backgroundColor: themeColors === null || themeColors === void 0 ? void 0 : themeColors.background.hex,
|
677
|
+
borderWidth: 0
|
678
|
+
};
|
679
|
+
default:
|
680
|
+
return {};
|
681
|
+
}
|
682
|
+
}
|
683
|
+
/**
|
684
|
+
* Button component that adapts its styles based on the current theme.
|
685
|
+
* Supports dynamic styling, full-width option, rounded corners, and different types.
|
686
|
+
*
|
687
|
+
* @param disabled - If true, the button is disabled and not pressable.
|
688
|
+
* @param isFullWidth - If true, the button expands to full width of its container.
|
689
|
+
* @param children - Text content of the button.
|
690
|
+
* @param onPress - Function to call when the button is pressed.
|
691
|
+
* @param rounded - If true, the button has rounded corners.
|
692
|
+
* @param borderRadius - Custom border radius value. Overrides the `rounded` prop if provided.
|
693
|
+
* @param type - Specifies the button type for styling ('submit', 'button', 'cancel').
|
694
|
+
*/
|
695
|
+
var Button = function Button(_a) {
|
696
|
+
var children = _a.children,
|
697
|
+
_b = _a.disabled,
|
698
|
+
disabled = _b === void 0 ? false : _b,
|
699
|
+
_c = _a.type,
|
700
|
+
type = _c === void 0 ? 'button' : _c,
|
701
|
+
_d = _a.rounded,
|
702
|
+
rounded = _d === void 0 ? true : _d,
|
703
|
+
_e = _a.borderRadius,
|
704
|
+
borderRadius = _e === void 0 ? 30 : _e,
|
705
|
+
_f = _a.isFullWidth,
|
706
|
+
isFullWidth = _f === void 0 ? false : _f,
|
707
|
+
_g = _a.loading,
|
708
|
+
loading = _g === void 0 ? false : _g,
|
709
|
+
onPress = _a.onPress;
|
710
|
+
var theme = useContext(ThemeContext).theme;
|
711
|
+
var colors = theme.colors;
|
712
|
+
var handleSubmit = useFormContext().handleSubmit;
|
713
|
+
var computedStyles = useMemo(function () {
|
714
|
+
return StyleSheet.flatten([styles$1.button, typeStyles(type, disabled, colors), rounded && {
|
715
|
+
borderRadius: borderRadius
|
716
|
+
}, isFullWidth && {
|
717
|
+
width: '100%'
|
718
|
+
}, (disabled || loading) && styles$1.disabled]);
|
719
|
+
}, [type, disabled, loading, rounded, borderRadius, isFullWidth, colors]);
|
720
|
+
var textColor = useMemo(function () {
|
721
|
+
return {
|
722
|
+
color: colors.textButton.hex
|
723
|
+
};
|
724
|
+
}, [type, colors]);
|
725
|
+
var handlePress = function handlePress() {
|
726
|
+
if (type === 'submit') {
|
727
|
+
handleSubmit(); // Call the form's submit handler
|
728
|
+
} else if (onPress) {
|
729
|
+
onPress(); // Call a custom handler if needed
|
730
|
+
}
|
731
|
+
};
|
732
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
733
|
+
style: computedStyles,
|
734
|
+
disabled: disabled || loading,
|
735
|
+
onPress: handlePress,
|
736
|
+
activeOpacity: 0.7
|
737
|
+
}, loading ? (
|
738
|
+
/*#__PURE__*/
|
739
|
+
// Show loading spinner if loading
|
740
|
+
React.createElement(ActivityIndicator, {
|
741
|
+
size: "small",
|
742
|
+
color: colors.textButton.hex
|
743
|
+
})) : (/*#__PURE__*/React.createElement(Text$1, {
|
744
|
+
style: textColor
|
745
|
+
}, Array.isArray(children) ? children.join('').toUpperCase() : children === null || children === void 0 ? void 0 : children.toUpperCase())));
|
746
|
+
};
|
747
|
+
var styles$1 = StyleSheet.create({
|
748
|
+
button: {
|
749
|
+
justifyContent: 'center',
|
750
|
+
alignItems: 'center',
|
751
|
+
paddingVertical: 10,
|
752
|
+
paddingHorizontal: 20
|
753
|
+
},
|
754
|
+
disabled: {
|
755
|
+
opacity: 0.6
|
756
|
+
}
|
757
|
+
});
|
758
|
+
|
759
|
+
// src/cards/Card.tsx
|
760
|
+
/**
|
761
|
+
* Card component that adapts its styles based on the current theme.
|
762
|
+
* Supports dynamic styling, shadows, and press animations.
|
763
|
+
*
|
764
|
+
* @param children - The content to be displayed inside the Card.
|
765
|
+
* @param style - Additional styles to apply to the Card.
|
766
|
+
* @param onPress - Function to execute when the Card is pressed.
|
767
|
+
* @param pressable - Determines if the Card is pressable. Defaults to false.
|
768
|
+
* @param borderRadius - Border radius of the Card. Defaults to 12.
|
769
|
+
* @param elevation - Elevation for Android shadow. Overrides default.
|
770
|
+
* @param shadowProps - Custom shadow properties for iOS. Overrides defaults.
|
771
|
+
*/
|
772
|
+
var Card = function Card(_a) {
|
773
|
+
var children = _a.children,
|
774
|
+
style = _a.style,
|
775
|
+
onPress = _a.onPress,
|
776
|
+
_b = _a.pressable,
|
777
|
+
pressable = _b === void 0 ? false : _b,
|
778
|
+
_c = _a.borderRadius,
|
779
|
+
borderRadius = _c === void 0 ? 12 : _c,
|
780
|
+
_d = _a.elevation,
|
781
|
+
elevation = _d === void 0 ? 4 : _d,
|
782
|
+
_e = _a.shadowProps,
|
783
|
+
shadowProps = _e === void 0 ? {} : _e;
|
784
|
+
var theme = useContext(ThemeContext).theme;
|
785
|
+
var colors = theme.colors;
|
786
|
+
// Animation state for pressable effect
|
787
|
+
// Default shadow styles (improved platform-specific handling)
|
788
|
+
var defaultShadow = Platform.select({
|
789
|
+
ios: {
|
790
|
+
shadowColor: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowColor) || colors.text.hex,
|
791
|
+
// Defaulting to theme text color
|
792
|
+
shadowOffset: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOffset) || {
|
793
|
+
width: 0,
|
794
|
+
height: 2
|
795
|
+
},
|
796
|
+
shadowOpacity: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowOpacity) || 0.1,
|
797
|
+
shadowRadius: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowRadius) || 4
|
798
|
+
},
|
799
|
+
android: {
|
800
|
+
elevation: elevation // Only applies to Android
|
801
|
+
}
|
802
|
+
});
|
803
|
+
var cardStyles = [styles.container, {
|
804
|
+
borderRadius: borderRadius,
|
805
|
+
backgroundColor: colors.body.hex
|
806
|
+
}, defaultShadow,
|
807
|
+
// Dynamic shadows based on platform
|
808
|
+
style // External styles
|
809
|
+
];
|
810
|
+
return pressable ? (/*#__PURE__*/React.createElement(TouchableOpacity, {
|
811
|
+
activeOpacity: 0.8,
|
812
|
+
onPress: onPress,
|
813
|
+
style: cardStyles
|
814
|
+
}, children)) : (/*#__PURE__*/React.createElement(View, {
|
815
|
+
style: cardStyles
|
816
|
+
}, children));
|
817
|
+
};
|
818
|
+
var styles = StyleSheet.create({
|
819
|
+
container: {
|
820
|
+
padding: 16,
|
821
|
+
borderRadius: 12
|
822
|
+
// Shadows handled dynamically with platform logic
|
823
|
+
}
|
824
|
+
});
|
825
|
+
|
817
826
|
export { Button, Card, ErrorList, Form, Input, Label, Text, TextArea, ThemeContext, ThemeProvider, ThemeToggle, useFormContext };
|
818
827
|
//# sourceMappingURL=index.esm.js.map
|