@swan-io/shared-business 8.14.3 → 8.14.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/shared-business",
3
- "version": "8.14.3",
3
+ "version": "8.14.5",
4
4
  "engines": {
5
5
  "node": ">=20.9.0",
6
6
  "yarn": "^1.22.0"
@@ -0,0 +1,9 @@
1
+ import { StyleProp, ViewStyle } from "react-native";
2
+ export type BirthdatePickerProps = {
3
+ label: string;
4
+ value: string | undefined;
5
+ error?: string;
6
+ onValueChange: (value: string | undefined) => void;
7
+ style?: StyleProp<ViewStyle>;
8
+ };
9
+ export declare const BirthdatePicker: ({ value, label, onValueChange, error: externalError, style, }: BirthdatePickerProps) => import("react/jsx-runtime").JSX.Element;
@@ -55,7 +55,7 @@ const order = match(getCountry().cca2)
55
55
  .with("US", () => "MDY")
56
56
  .with("CN", "JP", "KR", "KP", "TW", "HU", "MN", "LT", "BT", () => "YMD")
57
57
  .otherwise(() => "DMY");
58
- export const InlineDatePicker = ({ value, label, onValueChange }) => {
58
+ export const BirthdatePicker = ({ value, label, onValueChange, error: externalError, style, }) => {
59
59
  const { desktop } = useResponsive(breakpoints.small);
60
60
  const { Field } = useForm({
61
61
  birthdate: {
@@ -82,32 +82,32 @@ export const InlineDatePicker = ({ value, label, onValueChange }) => {
82
82
  },
83
83
  },
84
84
  });
85
- return (_jsx(Field, { name: "birthdate", children: ({ error, onBlur, onChange, value }) => (_jsx(LakeLabel, { label: label, render: id => {
86
- var _a;
87
- 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: (_a = value === null || value === void 0 ? void 0 : value.day) !== null && _a !== void 0 ? _a : undefined, onBlur: onBlur, hideErrors: true, onChangeText: day => {
85
+ return (_jsx(View, { style: style, children: _jsx(Field, { name: "birthdate", children: ({ error, onBlur, onChange, value }) => (_jsx(LakeLabel, { label: label, render: id => {
86
+ var _a;
87
+ 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 => {
88
+ var _a, _b;
89
+ onChange({
90
+ day,
91
+ month: (_a = value === null || value === void 0 ? void 0 : value.month) !== null && _a !== void 0 ? _a : "",
92
+ year: (_b = value === null || value === void 0 ? void 0 : value.year) !== null && _b !== void 0 ? _b : "",
93
+ });
94
+ }, pattern: "[0-9]", maxLength: 2, autoComplete: "bday-day" }) }));
95
+ 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 => {
88
96
  var _a, _b;
89
97
  onChange({
90
- day,
91
- month: (_a = value === null || value === void 0 ? void 0 : value.month) !== null && _a !== void 0 ? _a : "",
92
- year: (_b = value === null || value === void 0 ? void 0 : value.year) !== null && _b !== void 0 ? _b : "",
93
- });
94
- }, pattern: "[0-9]", maxLength: 2, autoComplete: "bday-day" }) }));
95
- 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) && styles.error, placeholder: t("datePicker.month"), hideErrors: true, items: months, onValueChange: month => {
96
- var _a, _b;
97
- onChange({
98
- day: (_a = value === null || value === void 0 ? void 0 : value.day) !== null && _a !== void 0 ? _a : "",
99
- month,
100
- year: (_b = value === null || value === void 0 ? void 0 : value.year) !== null && _b !== void 0 ? _b : "",
101
- });
102
- } }));
103
- 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) && styles.error, placeholder: t("datePicker.year"), onBlur: onBlur, hideErrors: true, onChangeText: year => {
104
- var _a, _b;
105
- return onChange({
106
98
  day: (_a = value === null || value === void 0 ? void 0 : value.day) !== null && _a !== void 0 ? _a : "",
107
- month: (_b = value === null || value === void 0 ? void 0 : value.month) !== null && _b !== void 0 ? _b : "",
108
- year,
99
+ month,
100
+ year: (_b = value === null || value === void 0 ? void 0 : value.year) !== null && _b !== void 0 ? _b : "",
109
101
  });
110
- }, pattern: "[0-9]", maxLength: 4, autoComplete: "bday-year" }) }));
111
- 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 })] }));
112
- } })) }));
102
+ } }));
103
+ 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 => {
104
+ var _a, _b;
105
+ return onChange({
106
+ day: (_a = value === null || value === void 0 ? void 0 : value.day) !== null && _a !== void 0 ? _a : "",
107
+ month: (_b = value === null || value === void 0 ? void 0 : value.month) !== null && _b !== void 0 ? _b : "",
108
+ year,
109
+ });
110
+ }, pattern: "[0-9]", maxLength: 4, autoComplete: "bday-year" }) }));
111
+ 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 !== null && error !== void 0 ? error : externalError })] }));
112
+ } })) }) }));
113
113
  };
@@ -1,8 +0,0 @@
1
- export type InlineDatePickerProps = {
2
- label: string;
3
- value: string | undefined;
4
- error?: string;
5
- onBlur?: () => void;
6
- onValueChange: (value: string | undefined) => void;
7
- };
8
- export declare const InlineDatePicker: ({ value, label, onValueChange }: InlineDatePickerProps) => import("react/jsx-runtime").JSX.Element;