@swan-io/shared-business 1.0.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/HISTORY.md +3 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/package.json +46 -0
- package/src/components/CountryPicker.d.ts +20 -0
- package/src/components/CountryPicker.js +26 -0
- package/src/components/SkipToContent.d.ts +3 -0
- package/src/components/SkipToContent.js +35 -0
- package/src/components/SupportChat.d.ts +26 -0
- package/src/components/SupportChat.js +87 -0
- package/src/components/SupportingDocument.d.ts +33 -0
- package/src/components/SupportingDocument.js +166 -0
- package/src/components/UploadArea.d.ts +26 -0
- package/src/components/UploadArea.js +161 -0
- package/src/constants/business.d.ts +12 -0
- package/src/constants/business.js +36 -0
- package/src/constants/countries.d.ts +2002 -0
- package/src/constants/countries.js +2363 -0
- package/src/constants/legal.d.ts +3 -0
- package/src/constants/legal.js +9 -0
- package/src/constants/registrationNumbers.d.ts +14 -0
- package/src/constants/registrationNumbers.js +117 -0
- package/src/constants/termsAndConditions.d.ts +7 -0
- package/src/constants/termsAndConditions.js +28 -0
- package/src/constants/ubos.d.ts +6 -0
- package/src/constants/ubos.js +47 -0
- package/src/constants/uploads.d.ts +1 -0
- package/src/constants/uploads.js +2 -0
- package/src/third-party/Pappers.d.ts +8 -0
- package/src/third-party/Pappers.js +36 -0
- package/src/utils/date.d.ts +3 -0
- package/src/utils/date.js +13 -0
- package/src/utils/i18n.d.ts +21 -0
- package/src/utils/i18n.js +115 -0
- package/src/utils/languages.d.ts +6 -0
- package/src/utils/languages.js +44 -0
- package/src/utils/validation.d.ts +7 -0
- package/src/utils/validation.js +65 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "@swan-io/lake/src/components/Box";
|
|
3
|
+
import { FileTile } from "@swan-io/lake/src/components/FileTile";
|
|
4
|
+
import { Icon } from "@swan-io/lake/src/components/Icon";
|
|
5
|
+
import { LakeHeading } from "@swan-io/lake/src/components/LakeHeading";
|
|
6
|
+
import { LakeText } from "@swan-io/lake/src/components/LakeText";
|
|
7
|
+
import { Space } from "@swan-io/lake/src/components/Space";
|
|
8
|
+
import { commonStyles } from "@swan-io/lake/src/constants/commonStyles";
|
|
9
|
+
import { backgroundColor, colors, gray75, radii, shadows, spacings, } from "@swan-io/lake/src/constants/design";
|
|
10
|
+
import { useBoolean } from "@swan-io/lake/src/hooks/useBoolean";
|
|
11
|
+
import { getIconNameFromFilename } from "@swan-io/lake/src/utils/file";
|
|
12
|
+
import { isNotNullish, isNullish } from "@swan-io/lake/src/utils/nullish";
|
|
13
|
+
import { formatNestedMessage, t } from "@swan-io/shared-business/src/utils/i18n";
|
|
14
|
+
import { Fragment, useLayoutEffect, useRef } from "react";
|
|
15
|
+
import { useDropzone } from "react-dropzone";
|
|
16
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
17
|
+
const styles = StyleSheet.create({
|
|
18
|
+
container: {
|
|
19
|
+
backgroundColor: backgroundColor.accented,
|
|
20
|
+
borderWidth: 1,
|
|
21
|
+
borderColor: colors.gray[200],
|
|
22
|
+
borderStyle: "dashed",
|
|
23
|
+
borderRadius: radii[8],
|
|
24
|
+
padding: spacings[32],
|
|
25
|
+
cursor: "pointer",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
cursor: "default",
|
|
30
|
+
backgroundColor: backgroundColor.default,
|
|
31
|
+
},
|
|
32
|
+
horizontalContainer: {
|
|
33
|
+
flexDirection: "row",
|
|
34
|
+
},
|
|
35
|
+
icon: {
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
justifyContent: "center",
|
|
38
|
+
},
|
|
39
|
+
hoveredContainer: {
|
|
40
|
+
boxShadow: shadows.tile,
|
|
41
|
+
},
|
|
42
|
+
activeContainer: {
|
|
43
|
+
borderColor: colors.current[500],
|
|
44
|
+
boxShadow: shadows.tile,
|
|
45
|
+
},
|
|
46
|
+
browse: {
|
|
47
|
+
color: colors.current[500],
|
|
48
|
+
},
|
|
49
|
+
browseBlock: {
|
|
50
|
+
flex: 1,
|
|
51
|
+
},
|
|
52
|
+
decorativeIconLeft: {
|
|
53
|
+
position: "absolute",
|
|
54
|
+
bottom: 0,
|
|
55
|
+
left: "50%",
|
|
56
|
+
opacity: 0,
|
|
57
|
+
transform: [{ translateX: "-50%" }, { scale: 0.6 }],
|
|
58
|
+
transitionProperty: ["opacity", "transform"],
|
|
59
|
+
transitionDuration: "300ms",
|
|
60
|
+
transitionTimingFunction: "ease-in-out",
|
|
61
|
+
},
|
|
62
|
+
decorativeIconLeftHovered: {
|
|
63
|
+
opacity: 0.3,
|
|
64
|
+
transform: [{ translateX: "-50%" }, { translateX: -24 }, { scale: 0.6 }, { rotate: "-5deg" }],
|
|
65
|
+
},
|
|
66
|
+
decorativeIconRight: {
|
|
67
|
+
position: "absolute",
|
|
68
|
+
bottom: 0,
|
|
69
|
+
left: "50%",
|
|
70
|
+
opacity: 0,
|
|
71
|
+
transform: [{ translateX: "-50%" }, { scale: 0.6 }],
|
|
72
|
+
transitionProperty: ["opacity", "transform"],
|
|
73
|
+
transitionDuration: "300ms",
|
|
74
|
+
transitionTimingFunction: "ease-in-out",
|
|
75
|
+
},
|
|
76
|
+
decorativeIconRightHovered: {
|
|
77
|
+
opacity: 0.3,
|
|
78
|
+
transform: [{ translateX: "-50%" }, { translateX: 24 }, { scale: 0.6 }, { rotate: "5deg" }],
|
|
79
|
+
},
|
|
80
|
+
progressBar: {
|
|
81
|
+
flex: 1,
|
|
82
|
+
height: 4,
|
|
83
|
+
borderRadius: 2,
|
|
84
|
+
backgroundColor: gray75,
|
|
85
|
+
},
|
|
86
|
+
progress: {
|
|
87
|
+
height: 4,
|
|
88
|
+
transitionProperty: "width",
|
|
89
|
+
transitionDuration: "300ms",
|
|
90
|
+
transitionTimingFunction: "ease-in-out",
|
|
91
|
+
borderRadius: 2,
|
|
92
|
+
backgroundColor: colors.current[500],
|
|
93
|
+
},
|
|
94
|
+
item: {
|
|
95
|
+
backgroundColor: backgroundColor.accented,
|
|
96
|
+
borderRadius: 8,
|
|
97
|
+
boxShadow: shadows.tile,
|
|
98
|
+
height: 56,
|
|
99
|
+
paddingHorizontal: spacings[20],
|
|
100
|
+
},
|
|
101
|
+
errorContainer: {
|
|
102
|
+
borderColor: colors.negative[500],
|
|
103
|
+
},
|
|
104
|
+
preview: {
|
|
105
|
+
aspectRatio: 16 / 4,
|
|
106
|
+
width: "50%",
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
const UploadAreaPreview = ({ value }) => {
|
|
110
|
+
const containerRef = useRef(null);
|
|
111
|
+
useLayoutEffect(() => {
|
|
112
|
+
const element = containerRef.current;
|
|
113
|
+
if (element != null) {
|
|
114
|
+
while (element.firstChild) {
|
|
115
|
+
element.firstChild.remove();
|
|
116
|
+
}
|
|
117
|
+
const previewElement = value.cloneNode(true);
|
|
118
|
+
element.append(previewElement);
|
|
119
|
+
previewElement.style.position = "absolute";
|
|
120
|
+
previewElement.style.top = "0";
|
|
121
|
+
previewElement.style.left = "0";
|
|
122
|
+
previewElement.style.width = "100%";
|
|
123
|
+
previewElement.style.height = "100%";
|
|
124
|
+
previewElement.style.objectFit = "contain";
|
|
125
|
+
previewElement.style.objectPosition = "50% 50%";
|
|
126
|
+
}
|
|
127
|
+
}, [value]);
|
|
128
|
+
return _jsx(View, { ref: containerRef, style: styles.preview });
|
|
129
|
+
};
|
|
130
|
+
export const UploadArea = ({ icon, accept, value, documents = [], disabled = false, onRemoveFile, onDropAccepted, onDropRejected, layout = "vertical", description, error, maxSize, }) => {
|
|
131
|
+
const [isHovered, setIsHovered] = useBoolean(false);
|
|
132
|
+
const { getRootProps, getInputProps, isDragActive, fileRejections } = useDropzone({
|
|
133
|
+
accept: accept.reduce((acc, item) => ({ ...acc, [item]: [] }), {}),
|
|
134
|
+
onDropAccepted,
|
|
135
|
+
onDropRejected,
|
|
136
|
+
disabled,
|
|
137
|
+
maxSize,
|
|
138
|
+
});
|
|
139
|
+
return (_jsxs(View, { style: commonStyles.fill, children: [_jsx("div", { ...getRootProps(), onMouseEnter: setIsHovered.on, onMouseLeave: setIsHovered.off, children: _jsxs(View, { style: [
|
|
140
|
+
styles.container,
|
|
141
|
+
disabled && styles.disabled,
|
|
142
|
+
layout === "horizontal" && styles.horizontalContainer,
|
|
143
|
+
!disabled && isHovered && styles.hoveredContainer,
|
|
144
|
+
isDragActive && styles.activeContainer,
|
|
145
|
+
(error != null || fileRejections.length > 0) && styles.errorContainer,
|
|
146
|
+
], accessibilityErrorMessage: error != null ? error : fileRejections[0]?.errors.join(", "), children: [_jsx("input", { ...getInputProps() }), isNotNullish(value) ? (value instanceof Element ? (_jsx(UploadAreaPreview, { value: value })) : (_jsxs(_Fragment, { children: [_jsx(Icon, { name: getIconNameFromFilename(value.name), size: 48, color: disabled ? colors.gray[200] : colors.current[500] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level: 5, variant: "h5", align: layout === "horizontal" ? "left" : "center", children: t("uploadArea.droppedFile") }), _jsx(Space, { height: 4 }), _jsx(LakeText, { variant: "smallRegular", color: colors.gray[200], children: value.name })] })] }))) : (_jsxs(_Fragment, { children: [_jsxs(View, { style: styles.icon, children: [_jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500], style: [
|
|
147
|
+
styles.decorativeIconLeft,
|
|
148
|
+
(isDragActive || isHovered) && styles.decorativeIconLeftHovered,
|
|
149
|
+
] }), _jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500], style: [
|
|
150
|
+
styles.decorativeIconRight,
|
|
151
|
+
(isDragActive || isHovered) && styles.decorativeIconRightHovered,
|
|
152
|
+
] }), _jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500] })] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level: 5, variant: "h5", align: layout === "horizontal" ? "left" : "center", color: disabled ? colors.gray[200] : undefined, children: disabled
|
|
153
|
+
? t("uploadArea.noValue")
|
|
154
|
+
: formatNestedMessage("uploadArea.dropFile", {
|
|
155
|
+
browse: _jsx(Text, { style: styles.browse, children: t("uploadArea.browse") }),
|
|
156
|
+
}) }), isNotNullish(error) ? (_jsxs(_Fragment, { children: [_jsx(Space, { height: 4 }), _jsx(LakeText, { color: colors.negative[400], align: layout === "horizontal" ? "left" : "center", children: error })] })) : (!disabled &&
|
|
157
|
+
isNotNullish(description) && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 4 }), _jsx(LakeText, { align: layout === "horizontal" ? "left" : "center", children: description })] })))] })] }))] }) }), documents.map(({ finished = false, ...document }, index) => {
|
|
158
|
+
const progress = Math.max(document.progress ?? 0, 3);
|
|
159
|
+
return (_jsxs(Fragment, { children: [_jsx(Space, { height: index === 0 ? 8 : 4 }), finished ? (_jsx(FileTile, { name: document.name ?? t("uploadArea.unknownFileName"), url: document.fileUrl, onRemove: isNullish(onRemoveFile) ? undefined : () => onRemoveFile(document.id) })) : (_jsxs(Box, { direction: "row", alignItems: "center", style: styles.item, children: [_jsx(LakeText, { numberOfLines: 1, color: colors.gray[700], children: t("uploadArea.uploading") }), _jsx(Space, { width: 20 }), _jsx(View, { accessibilityRole: "progressbar", style: styles.progressBar, children: _jsx(View, { style: [styles.progress, { width: `${progress}%` }] }) })] }))] }, document.id));
|
|
160
|
+
})] }));
|
|
161
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type BusinessActivity = "AdministrativeServices" | "Agriculture" | "Arts" | "BusinessAndRetail" | "Construction" | "Education" | "ElectricalDistributionAndWaterSupply" | "FinancialAndInsuranceOperations" | "Health" | "Housekeeping" | "InformationAndCommunication" | "LodgingAndFoodServices" | "ManufacturingAndMining" | "Other" | "PublicAdministration" | "RealEstate" | "ScientificActivities" | "Transportation";
|
|
2
|
+
type BusinessActivityEntry = {
|
|
3
|
+
text: string;
|
|
4
|
+
value: BusinessActivity;
|
|
5
|
+
};
|
|
6
|
+
export declare const businessActivities: BusinessActivityEntry[];
|
|
7
|
+
export type MonthlyPaymentVolume = "Between10000And50000" | "Between50000And100000" | "LessThan10000" | "MoreThan100000";
|
|
8
|
+
export declare const monthlyPaymentVolumes: {
|
|
9
|
+
text: string;
|
|
10
|
+
value: MonthlyPaymentVolume;
|
|
11
|
+
}[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { t } from "../utils/i18n";
|
|
2
|
+
const unsortedBusinessActivities = [
|
|
3
|
+
{ text: t("businessActivity.administrativeServices"), value: "AdministrativeServices" },
|
|
4
|
+
{ text: t("businessActivity.agriculture"), value: "Agriculture" },
|
|
5
|
+
{ text: t("businessActivity.arts"), value: "Arts" },
|
|
6
|
+
{ text: t("businessActivity.businessAndRetail"), value: "BusinessAndRetail" },
|
|
7
|
+
{ text: t("businessActivity.construction"), value: "Construction" },
|
|
8
|
+
{ text: t("businessActivity.education"), value: "Education" },
|
|
9
|
+
{
|
|
10
|
+
text: t("businessActivity.electricalDistributionAndWaterSupply"),
|
|
11
|
+
value: "ElectricalDistributionAndWaterSupply",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
text: t("businessActivity.financialAndInsuranceOperations"),
|
|
15
|
+
value: "FinancialAndInsuranceOperations",
|
|
16
|
+
},
|
|
17
|
+
{ text: t("businessActivity.health"), value: "Health" },
|
|
18
|
+
{ text: t("businessActivity.housekeeping"), value: "Housekeeping" },
|
|
19
|
+
{ text: t("businessActivity.informationAndCommunication"), value: "InformationAndCommunication" },
|
|
20
|
+
{ text: t("businessActivity.lodgingAndFoodServices"), value: "LodgingAndFoodServices" },
|
|
21
|
+
{ text: t("businessActivity.manufacturingAndMining"), value: "ManufacturingAndMining" },
|
|
22
|
+
{ text: t("businessActivity.publicAdministration"), value: "PublicAdministration" },
|
|
23
|
+
{ text: t("businessActivity.realEstate"), value: "RealEstate" },
|
|
24
|
+
{ text: t("businessActivity.scientificActivities"), value: "ScientificActivities" },
|
|
25
|
+
{ text: t("businessActivity.transportation"), value: "Transportation" },
|
|
26
|
+
];
|
|
27
|
+
export const businessActivities = [
|
|
28
|
+
...unsortedBusinessActivities.sort((a, b) => a.text.localeCompare(b.text)),
|
|
29
|
+
{ text: t("businessActivity.other"), value: "Other" },
|
|
30
|
+
];
|
|
31
|
+
export const monthlyPaymentVolumes = [
|
|
32
|
+
{ text: t("monthlyPaymentVolume.lessThan10000"), value: "LessThan10000" },
|
|
33
|
+
{ text: t("monthlyPaymentVolume.between10000And50000"), value: "Between10000And50000" },
|
|
34
|
+
{ text: t("monthlyPaymentVolume.between50000And100000"), value: "Between50000And100000" },
|
|
35
|
+
{ text: t("monthlyPaymentVolume.moreThan100000"), value: "MoreThan100000" },
|
|
36
|
+
];
|