@swan-io/shared-business 8.15.9 → 8.15.11
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
|
@@ -3,7 +3,8 @@ export type BirthdatePickerProps = {
|
|
|
3
3
|
label: string;
|
|
4
4
|
value: string | undefined;
|
|
5
5
|
error?: string;
|
|
6
|
-
onValueChange
|
|
6
|
+
onValueChange?: (value: string | undefined) => void;
|
|
7
7
|
style?: StyleProp<ViewStyle>;
|
|
8
|
+
readOnly?: boolean;
|
|
8
9
|
};
|
|
9
|
-
export declare const BirthdatePicker: ({ value, label, onValueChange, error: externalError, style, }: BirthdatePickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const BirthdatePicker: ({ value, label, readOnly, onValueChange, error: externalError, style, }: BirthdatePickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -56,7 +56,7 @@ const order = match(getCountry().cca2)
|
|
|
56
56
|
.with("US", () => "MDY")
|
|
57
57
|
.with("CN", "JP", "KR", "KP", "TW", "HU", "MN", "LT", "BT", () => "YMD")
|
|
58
58
|
.otherwise(() => "DMY");
|
|
59
|
-
export const BirthdatePicker = ({ value, label, onValueChange, error: externalError, style, }) => {
|
|
59
|
+
export const BirthdatePicker = ({ value, label, readOnly = false, onValueChange, error: externalError, style, }) => {
|
|
60
60
|
const { desktop } = useResponsive(breakpoints.small);
|
|
61
61
|
const { Field } = useForm({
|
|
62
62
|
birthdate: {
|
|
@@ -72,10 +72,10 @@ export const BirthdatePicker = ({ value, label, onValueChange, error: externalEr
|
|
|
72
72
|
validate: date => {
|
|
73
73
|
const errorMessage = validateBirthdate(date);
|
|
74
74
|
if (isNullish(errorMessage) && isNotNullish(date)) {
|
|
75
|
-
return onValueChange(formatExtractedDate(date));
|
|
75
|
+
return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(formatExtractedDate(date));
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
onValueChange(undefined);
|
|
78
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(undefined);
|
|
79
79
|
return errorMessage;
|
|
80
80
|
}
|
|
81
81
|
},
|
|
@@ -83,7 +83,7 @@ export const BirthdatePicker = ({ value, label, onValueChange, error: externalEr
|
|
|
83
83
|
});
|
|
84
84
|
return (_jsx(View, { style: [styles.container, style], children: _jsx(Field, { name: "birthdate", children: ({ error, onBlur, onChange, value }) => (_jsx(LakeLabel, { label: label, render: id => {
|
|
85
85
|
var _a;
|
|
86
|
-
const day = (_jsx(View, { style: desktop ? styles.day : styles.dayMobile, children: _jsx(LakeTextInput, { id: id, style: (isNotNullish(error) || isNotNullish(externalError)) && styles.error, placeholder: t("datePicker.day"), value: (_a = value === null || value === void 0 ? void 0 : value.day) !== null && _a !== void 0 ? _a : undefined, onBlur: onBlur, hideErrors: true, onChangeText: day => {
|
|
86
|
+
const day = (_jsx(View, { style: desktop ? styles.day : styles.dayMobile, children: _jsx(LakeTextInput, { id: id, readOnly: readOnly, style: (isNotNullish(error) || isNotNullish(externalError)) && styles.error, placeholder: t("datePicker.day"), value: (_a = value === null || value === void 0 ? void 0 : value.day) !== null && _a !== void 0 ? _a : undefined, onBlur: onBlur, hideErrors: true, onChangeText: day => {
|
|
87
87
|
var _a, _b;
|
|
88
88
|
onChange({
|
|
89
89
|
day,
|
|
@@ -91,7 +91,7 @@ export const BirthdatePicker = ({ value, label, onValueChange, error: externalEr
|
|
|
91
91
|
year: (_b = value === null || value === void 0 ? void 0 : value.year) !== null && _b !== void 0 ? _b : "",
|
|
92
92
|
});
|
|
93
93
|
}, pattern: "[0-9]", maxLength: 2, autoComplete: "bday-day" }) }));
|
|
94
|
-
const month = (_jsx(LakeSelect, { value: (value === null || value === void 0 ? void 0 : value.month) === "" ? undefined : value === null || value === void 0 ? void 0 : value.month, style: (isNotNullish(error) || isNotNullish(externalError)) && styles.error, placeholder: t("datePicker.month"), hideErrors: true, items: months, onValueChange: month => {
|
|
94
|
+
const month = (_jsx(LakeSelect, { value: (value === null || value === void 0 ? void 0 : value.month) === "" ? undefined : value === null || value === void 0 ? void 0 : value.month, style: (isNotNullish(error) || isNotNullish(externalError)) && styles.error, readOnly: readOnly, placeholder: t("datePicker.month"), hideErrors: true, items: months, onValueChange: month => {
|
|
95
95
|
var _a, _b;
|
|
96
96
|
onChange({
|
|
97
97
|
day: (_a = value === null || value === void 0 ? void 0 : value.day) !== null && _a !== void 0 ? _a : "",
|
|
@@ -99,7 +99,7 @@ export const BirthdatePicker = ({ value, label, onValueChange, error: externalEr
|
|
|
99
99
|
year: (_b = value === null || value === void 0 ? void 0 : value.year) !== null && _b !== void 0 ? _b : "",
|
|
100
100
|
});
|
|
101
101
|
} }));
|
|
102
|
-
const year = (_jsx(View, { style: desktop ? styles.year : styles.yearMobile, children: _jsx(LakeTextInput, { value: value === null || value === void 0 ? void 0 : value.year, style: (isNotNullish(error) || isNotNullish(externalError)) && styles.error, placeholder: t("datePicker.year"), onBlur: onBlur, hideErrors: true, onChangeText: year => {
|
|
102
|
+
const year = (_jsx(View, { style: desktop ? styles.year : styles.yearMobile, children: _jsx(LakeTextInput, { value: value === null || value === void 0 ? void 0 : value.year, style: (isNotNullish(error) || isNotNullish(externalError)) && styles.error, readOnly: readOnly, placeholder: t("datePicker.year"), onBlur: onBlur, hideErrors: true, onChangeText: year => {
|
|
103
103
|
var _a, _b;
|
|
104
104
|
return onChange({
|
|
105
105
|
day: (_a = value === null || value === void 0 ? void 0 : value.day) !== null && _a !== void 0 ? _a : "",
|