@swan-io/shared-business 7.4.6 → 8.1.0
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": "
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18.0.0",
|
|
6
6
|
"yarn": "^1.22.0"
|
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@formatjs/intl": "^2.10.1",
|
|
33
33
|
"@placekit/client-js": "^2.3.0",
|
|
34
|
-
"@swan-io/boxed": "^2.
|
|
35
|
-
"@swan-io/
|
|
36
|
-
"@swan-io/
|
|
34
|
+
"@swan-io/boxed": "^2.2.1",
|
|
35
|
+
"@swan-io/graphql-client": "^0.1.1",
|
|
36
|
+
"@swan-io/request": "^1.0.5",
|
|
37
|
+
"@swan-io/use-form": "^2.0.2",
|
|
37
38
|
"dayjs": "^1.11.10",
|
|
38
39
|
"iban": "^0.0.14",
|
|
39
40
|
"react": "^18.2.0",
|
|
@@ -43,7 +44,6 @@
|
|
|
43
44
|
"react-native-web": "^0.19.10",
|
|
44
45
|
"rifm": "^0.12.1",
|
|
45
46
|
"ts-pattern": "^5.1.0",
|
|
46
|
-
"urql": "^4.0.7",
|
|
47
47
|
"uuid": "^9.0.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
@@ -458,7 +458,7 @@ const MonthCalendar = ({ month, year, value, firstWeekDay, isSelectable, onChang
|
|
|
458
458
|
}) }, weekIndex)))] }));
|
|
459
459
|
};
|
|
460
460
|
const DatePickerPopoverContent = ({ value, format, firstWeekDay, desktop, isSelectable, onChange, }) => {
|
|
461
|
-
const [monthYear, setMonthYear] = useState(() => getYearMonth(value, format).
|
|
461
|
+
const [monthYear, setMonthYear] = useState(() => getYearMonth(value, format).getOr(getTodayYearMonth()));
|
|
462
462
|
// Automatically change displayed year and month when user change the value with text input
|
|
463
463
|
useEffect(() => {
|
|
464
464
|
const yearMonth = getYearMonth(value, format);
|
|
@@ -494,7 +494,7 @@ export const DatePickerModal = ({ value, format, firstWeekDay, isSelectable, onC
|
|
|
494
494
|
const handleConfirm = () => {
|
|
495
495
|
submitForm({
|
|
496
496
|
onSuccess: values => {
|
|
497
|
-
const date = values.date.
|
|
497
|
+
const date = values.date.getOr("");
|
|
498
498
|
if (isNotEmpty(date)) {
|
|
499
499
|
onChange(date);
|
|
500
500
|
}
|
|
@@ -519,8 +519,8 @@ const DateModal = ({ children, visible, maxWidth, withCloseButton, onPressClose,
|
|
|
519
519
|
const DateRangePickerModalContent = ({ value, format, firstWeekDay, desktop, displayTwoCalendar, isSelectable, onChange, }) => {
|
|
520
520
|
const isFirstMount = useFirstMountState();
|
|
521
521
|
const [periods, setPeriods] = useState(() => {
|
|
522
|
-
const startYearMonth = getYearMonth(value.start, format).
|
|
523
|
-
const endYearMonth = getYearMonth(value.end, format).
|
|
522
|
+
const startYearMonth = getYearMonth(value.start, format).getOr(getTodayYearMonth());
|
|
523
|
+
const endYearMonth = getYearMonth(value.end, format).getOr(incrementYearMonth(startYearMonth));
|
|
524
524
|
return {
|
|
525
525
|
start: startYearMonth,
|
|
526
526
|
end: isYearMonthEquals(startYearMonth, endYearMonth)
|
|
@@ -105,7 +105,7 @@ export const FileInput = ({ icon = "document-regular", accept, value, disabled =
|
|
|
105
105
|
.with(P.nullish, () => Option.None())
|
|
106
106
|
.with({ url: P.string }, ({ url, name }) => Option.Some({
|
|
107
107
|
url,
|
|
108
|
-
name: name !== null && name !== void 0 ? name : Result.fromExecution(() => new URL(url).pathname).
|
|
108
|
+
name: name !== null && name !== void 0 ? name : Result.fromExecution(() => new URL(url).pathname).getOr("untitled"),
|
|
109
109
|
}))
|
|
110
110
|
.with(P.instanceOf(File), file => Option.Some({
|
|
111
111
|
name: file.name,
|
package/src/utils/i18n.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createIntl, createIntlCache } from "@formatjs/intl";
|
|
2
2
|
import { getRifmProps } from "@swan-io/lake/src/utils/rifm";
|
|
3
|
+
import { BadStatusError } from "@swan-io/request";
|
|
3
4
|
import dayjs from "dayjs";
|
|
4
5
|
import dayjsLocaleDE from "dayjs/locale/de";
|
|
5
6
|
import dayjsLocaleEN from "dayjs/locale/en";
|
|
@@ -15,7 +16,6 @@ import relativeTime from "dayjs/plugin/relativeTime";
|
|
|
15
16
|
import utc from "dayjs/plugin/utc";
|
|
16
17
|
import { cloneElement, isValidElement } from "react";
|
|
17
18
|
import { P, match } from "ts-pattern";
|
|
18
|
-
import { CombinedError } from "urql";
|
|
19
19
|
import translationDE from "../locales/de.json";
|
|
20
20
|
import translationEN from "../locales/en.json";
|
|
21
21
|
import translationES from "../locales/es.json";
|
|
@@ -133,9 +133,7 @@ export const translateError = (error) => {
|
|
|
133
133
|
.returnType()
|
|
134
134
|
.with({ __typename: P.select(P.string) }, __typename => `rejection.${__typename}`)
|
|
135
135
|
.with(P.string, __typename => `rejection.${__typename}`)
|
|
136
|
-
.with(P.instanceOf(
|
|
137
|
-
.with({ response: { status: P.select(P.number) } }, status => `error.network.${status}`)
|
|
138
|
-
.otherwise(() => "error.generic"))
|
|
136
|
+
.with(P.instanceOf(BadStatusError), ({ status }) => `error.network.${status}`)
|
|
139
137
|
.with(P.instanceOf(Error), ({ message }) => `rejection.${message}`)
|
|
140
138
|
.otherwise(() => "error.generic");
|
|
141
139
|
return t(isTranslationKey(key) ? key : "error.generic");
|