@swan-io/shared-business 8.14.0 → 8.14.1
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/package.json
CHANGED
|
@@ -5,6 +5,6 @@ export type InlineDatePickerProps = {
|
|
|
5
5
|
onValueChange: (value: ExtractedDate) => void;
|
|
6
6
|
error?: string;
|
|
7
7
|
onBlur?: () => void;
|
|
8
|
-
order: "
|
|
8
|
+
order: "DMY" | "MDY" | "YMD";
|
|
9
9
|
};
|
|
10
10
|
export declare const InlineDatePicker: ({ value, label, onValueChange, error, onBlur, order, }: InlineDatePickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,8 @@ import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
|
|
|
5
5
|
import { LakeSelect } from "@swan-io/lake/src/components/LakeSelect";
|
|
6
6
|
import { LakeTextInput } from "@swan-io/lake/src/components/LakeTextInput";
|
|
7
7
|
import { Stack } from "@swan-io/lake/src/components/Stack";
|
|
8
|
-
import { colors } from "@swan-io/lake/src/constants/design";
|
|
8
|
+
import { breakpoints, colors } from "@swan-io/lake/src/constants/design";
|
|
9
|
+
import { useResponsive } from "@swan-io/lake/src/hooks/useResponsive";
|
|
9
10
|
import { isNotNullish } from "@swan-io/lake/src/utils/nullish";
|
|
10
11
|
import { StyleSheet, View } from "react-native";
|
|
11
12
|
import { t } from "../utils/i18n";
|
|
@@ -24,10 +25,18 @@ const months = [
|
|
|
24
25
|
{ value: "12", name: t("datePicker.month.december") },
|
|
25
26
|
];
|
|
26
27
|
const styles = StyleSheet.create({
|
|
28
|
+
dayMobile: {
|
|
29
|
+
maxWidth: 60,
|
|
30
|
+
flexGrow: 0,
|
|
31
|
+
},
|
|
27
32
|
day: {
|
|
28
33
|
maxWidth: 90,
|
|
29
34
|
flexGrow: 0,
|
|
30
35
|
},
|
|
36
|
+
yearMobile: {
|
|
37
|
+
maxWidth: 80,
|
|
38
|
+
flexGrow: 0,
|
|
39
|
+
},
|
|
31
40
|
year: {
|
|
32
41
|
maxWidth: 120,
|
|
33
42
|
flexGrow: 0,
|
|
@@ -37,8 +46,9 @@ const styles = StyleSheet.create({
|
|
|
37
46
|
},
|
|
38
47
|
});
|
|
39
48
|
export const InlineDatePicker = ({ value = { day: "", month: "", year: "" }, label, onValueChange, error, onBlur, order, }) => {
|
|
49
|
+
const { desktop } = useResponsive(breakpoints.small);
|
|
40
50
|
return (_jsx(LakeLabel, { label: label, render: id => {
|
|
41
|
-
const day = (_jsx(View, { style: styles.day, children: _jsx(LakeTextInput, { id: id, style: isNotNullish(error) && styles.error, placeholder: t("datePicker.day"), value: value.day, onBlur: onBlur, hideErrors: true, onChangeText: day => {
|
|
51
|
+
const day = (_jsx(View, { style: desktop ? styles.day : styles.dayMobile, children: _jsx(LakeTextInput, { id: id, style: isNotNullish(error) && styles.error, placeholder: t("datePicker.day"), value: value.day, onBlur: onBlur, hideErrors: true, onChangeText: day => {
|
|
42
52
|
onValueChange({
|
|
43
53
|
day,
|
|
44
54
|
month: value.month,
|
|
@@ -52,11 +62,11 @@ export const InlineDatePicker = ({ value = { day: "", month: "", year: "" }, lab
|
|
|
52
62
|
year: value.year,
|
|
53
63
|
});
|
|
54
64
|
} }));
|
|
55
|
-
const year = (_jsx(View, { style: styles.year, children: _jsx(LakeTextInput, { value: value.year, style: isNotNullish(error) && styles.error, placeholder: t("datePicker.year"), onBlur: onBlur, hideErrors: true, onChangeText: year => onValueChange({
|
|
65
|
+
const year = (_jsx(View, { style: desktop ? styles.year : styles.yearMobile, children: _jsx(LakeTextInput, { value: value.year, style: isNotNullish(error) && styles.error, placeholder: t("datePicker.year"), onBlur: onBlur, hideErrors: true, onChangeText: year => onValueChange({
|
|
56
66
|
day: value.day,
|
|
57
67
|
month: value.month,
|
|
58
68
|
year,
|
|
59
69
|
}), pattern: "[0-9]", maxLength: 4, autoComplete: "bday-year" }) }));
|
|
60
|
-
return (_jsxs(Box, { children: [order === "
|
|
70
|
+
return (_jsxs(Box, { children: [order === "DMY" ? (_jsxs(Stack, { direction: "row", space: 4, children: [day, " ", month, " ", year] })) : (_jsxs(Stack, { direction: "row", space: 4, children: [month, " ", day, " ", year] })), _jsx(InputError, { message: error })] }));
|
|
61
71
|
} }));
|
|
62
72
|
};
|
package/src/locales/en.json
CHANGED
|
@@ -297,6 +297,6 @@
|
|
|
297
297
|
"transactionStatement.title.debtor": "Debtor information",
|
|
298
298
|
"transactionStatement.title.document": "Transaction confirmation",
|
|
299
299
|
"transactionStatement.title.information": "Information",
|
|
300
|
-
"validation.invalidBirthDate": "
|
|
300
|
+
"validation.invalidBirthDate": "Please enter your complete and valid birth date: month, day, and year",
|
|
301
301
|
"validation.birthdateCannotBeFuture": "Birthdate cannot be in the future"
|
|
302
302
|
}
|
package/src/utils/validation.js
CHANGED
|
@@ -106,7 +106,7 @@ export const validateIban = (iban) => {
|
|
|
106
106
|
};
|
|
107
107
|
export const validateBirthdate = (value) => {
|
|
108
108
|
const date = dayjs.utc(formatExtractedDate(value), "YYYY-MM-DD", true);
|
|
109
|
-
const isBirthdateOver150years = date.isBefore(dayjs.utc().subtract(
|
|
109
|
+
const isBirthdateOver150years = date.isBefore(dayjs.utc().subtract(100, "years"));
|
|
110
110
|
const isBirthdateWithin4years = date.isAfter(dayjs.utc().subtract(4, "years"));
|
|
111
111
|
if (!date.isValid() || isBirthdateOver150years || isBirthdateWithin4years) {
|
|
112
112
|
return t("validation.invalidBirthDate");
|