@swan-io/shared-business 15.3.0 → 15.3.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swan-io/shared-business",
|
|
3
|
-
"version": "15.3.
|
|
3
|
+
"version": "15.3.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">22.12.0"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"react": ">=19.0.0",
|
|
29
29
|
"react-dom": ">=19.0.0",
|
|
30
30
|
"react-native-web": ">=0.21.2",
|
|
31
|
-
"@swan-io/lake": "15.3.
|
|
31
|
+
"@swan-io/lake": "15.3.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@formatjs/intl": "^4.1.11",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"iban": "^0.0.14",
|
|
41
41
|
"react-atomic-state": "^2.1.0",
|
|
42
42
|
"react-dropzone": "^15.0.0",
|
|
43
|
-
"prism-react-renderer": "^2.4.1",
|
|
44
43
|
"rifm": "^0.12.1",
|
|
45
44
|
"ts-pattern": "^5.9.0",
|
|
46
45
|
"uuid": "^14.0.0"
|
|
@@ -54,6 +53,6 @@
|
|
|
54
53
|
"react-dom": "^19.2.7",
|
|
55
54
|
"react-native-web": "^0.21.2",
|
|
56
55
|
"type-fest": "^5.6.0",
|
|
57
|
-
"@swan-io/lake": "15.3.
|
|
56
|
+
"@swan-io/lake": "15.3.1"
|
|
58
57
|
}
|
|
59
58
|
}
|
|
@@ -40,6 +40,7 @@ const styles = StyleSheet.create({
|
|
|
40
40
|
triggerErrored: { borderColor: colors.negative[500] },
|
|
41
41
|
triggerDisabled: { borderColor: colors.gray[50] },
|
|
42
42
|
list: { height: 230 },
|
|
43
|
+
listDropdown: { width: 360 },
|
|
43
44
|
searchIcon: { position: "absolute", left: 16 },
|
|
44
45
|
searchInput: {
|
|
45
46
|
...texts.regular,
|
|
@@ -94,7 +95,7 @@ export const PhoneCountryPicker = ({ value, onValueChange, countries, style, dis
|
|
|
94
95
|
!visible && pressed && styles.triggerPressed,
|
|
95
96
|
(disabled || readOnly) && styles.triggerDisabled,
|
|
96
97
|
isNotNullishOrEmpty(error) && styles.triggerErrored,
|
|
97
|
-
], children: [_jsx(Flag, { code: value.cca2, width: 16 }), _jsx(Space, { width: 8 }), _jsxs(LakeText, { color: colors.gray[600], numberOfLines: 1, userSelect: "none", variant: "smallSemibold", children: ["+", value.idd] }), _jsx(Space, { width: 8 }), _jsx(Icon, { name: "chevron-down-filled", color: colors.gray[600], size: 16 })] }), _jsx(Popover, { referenceRef: referenceRef, visible: visible, onDismiss: close, matchReferenceWidth: false, children: _jsxs(View, { style: styles.list, children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(Icon, { name: "search-filled", color: colors.gray[300], size: 18, style: styles.searchIcon }), _jsx(TextInput, { ref: inputRef, inputMode: "search", style: styles.searchInput, onChangeText: handleOnChangeText, onSubmitEditing: () => {
|
|
98
|
+
], children: [_jsx(Flag, { code: value.cca2, width: 16 }), _jsx(Space, { width: 8 }), _jsxs(LakeText, { color: colors.gray[600], numberOfLines: 1, userSelect: "none", variant: "smallSemibold", children: ["+", value.idd] }), _jsx(Space, { width: 8 }), _jsx(Icon, { name: "chevron-down-filled", color: colors.gray[600], size: 16 })] }), _jsx(Popover, { referenceRef: referenceRef, visible: visible, onDismiss: close, matchReferenceWidth: false, children: ({ mode }) => (_jsxs(View, { style: [styles.list, mode === "dropdown" && styles.listDropdown], children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(Icon, { name: "search-filled", color: colors.gray[300], size: 18, style: styles.searchIcon }), _jsx(TextInput, { ref: inputRef, inputMode: "search", style: styles.searchInput, onChangeText: handleOnChangeText, onSubmitEditing: () => {
|
|
98
99
|
if (isNotNullish(filteredCountries[0])) {
|
|
99
100
|
onValueChange(filteredCountries[0]);
|
|
100
101
|
close();
|
|
@@ -106,5 +107,5 @@ export const PhoneCountryPicker = ({ value, onValueChange, countries, style, dis
|
|
|
106
107
|
], onPress: () => {
|
|
107
108
|
onValueChange(item);
|
|
108
109
|
close();
|
|
109
|
-
}, children: [_jsx(Flag, { code: item.cca2, width: 16 }), _jsx(Space, { width: 12 }), _jsx(LakeText, { numberOfLines: 1, style: styles.rowName, userSelect: "none", variant: "smallRegular", children: item.name }), item.uid === value.uid && (_jsxs(_Fragment, { children: [_jsx(Space, { width: 12 }), _jsx(Icon, { name: "checkmark-filled", color: colors.positive[500], size: 16 })] })), _jsx(Space, { width: 12 }), _jsxs(LakeText, { userSelect: "none", variant: "smallRegular", children: ["+", item.idd] })] })) })] }) })] }));
|
|
110
|
+
}, children: [_jsx(Flag, { code: item.cca2, width: 16 }), _jsx(Space, { width: 12 }), _jsx(LakeText, { numberOfLines: 1, style: styles.rowName, userSelect: "none", variant: "smallRegular", children: item.name }), item.uid === value.uid && (_jsxs(_Fragment, { children: [_jsx(Space, { width: 12 }), _jsx(Icon, { name: "checkmark-filled", color: colors.positive[500], size: 16 })] })), _jsx(Space, { width: 12 }), _jsxs(LakeText, { userSelect: "none", variant: "smallRegular", children: ["+", item.idd] })] })) })] })) })] }));
|
|
110
111
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BadStatusError } from "@swan-io/request";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { formatCurrencyIso, formatCurrencySymbol, isTranslationKey, translateError, } from "../i18n";
|
|
3
|
+
import { formatCurrencyIso, formatCurrencySymbol, getRejectionReasonLabel, isTranslationKey, translateError, } from "../i18n";
|
|
4
4
|
// The i18n module reads `navigator.languages` at import time to pick its locale.
|
|
5
5
|
// In the Vitest jsdom environment, `navigator.languages` defaults to ["en-US"],
|
|
6
6
|
// so the module locks to English. Assertions below assume that locale.
|
|
@@ -44,6 +44,17 @@ describe("translateError maps an arbitrary error value to a translated message",
|
|
|
44
44
|
expect(translateError(new Error("boom"))).toBe("An error occurred");
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
|
+
describe("getRejectionReasonLabel maps a document rejection reason code to a translated label", () => {
|
|
48
|
+
it("translates a known reason code", () => {
|
|
49
|
+
expect(getRejectionReasonLabel("BadDocumentQuality")).toBe("The document quality is too low to read. Upload a higher-resolution scan or photo.");
|
|
50
|
+
});
|
|
51
|
+
it("falls back to the generic 'Other' label for an unknown or future reason code", () => {
|
|
52
|
+
expect(getRejectionReasonLabel("SomeFutureReasonCodeNotYetSupported")).toBe("See the reason and explanation provided by Swan.");
|
|
53
|
+
});
|
|
54
|
+
it("falls back to the generic 'Other' label for an empty string", () => {
|
|
55
|
+
expect(getRejectionReasonLabel("")).toBe("See the reason and explanation provided by Swan.");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
47
58
|
describe("formatCurrencyIso formats an amount as a decimal followed by the currency code", () => {
|
|
48
59
|
it("formats a positive amount with two fraction digits", () => {
|
|
49
60
|
expect(formatCurrencyIso(1234.5, "EUR")).toBe("1,234.50 EUR");
|