@swan-io/shared-business 2.3.0 → 2.4.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": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { CountryCCA3 } from "../constants/countries";
3
3
  type BeneficiaryType = "HasCapital" | "LegalRepresentative" | "Other";
4
- type AccountCountry = "DEU" | "ESP" | "FRA";
4
+ type AccountCountry = "DEU" | "ESP" | "FRA" | "NLD";
5
5
  export type BeneficiaryFormStep = "common" | "address";
6
6
  export type EditorState = {
7
7
  reference: string;
@@ -17,7 +17,7 @@ import { combineValidators, hasDefinedKeys, useForm } from "react-ux-form";
17
17
  import { Rifm } from "rifm";
18
18
  import { match } from "ts-pattern";
19
19
  import { v4 as uuid } from "uuid";
20
- import { allCountries, individualCountries, isCountryCCA3, } from "../constants/countries";
20
+ import { allCountries, isCountryCCA3 } from "../constants/countries";
21
21
  import { decodeBirthDate, encodeBirthDate } from "../utils/date";
22
22
  import { locale, rifmDateProps, t } from "../utils/i18n";
23
23
  import { validateBooleanRequired, validateIndividualTaxNumber, validateNullableRequired, validateRequired, } from "../utils/validation";
@@ -31,11 +31,11 @@ const styles = StyleSheet.create({
31
31
  },
32
32
  });
33
33
  const beneficiaryTypes = [
34
+ { value: "HasCapital", name: t("beneficiaryForm.beneficiary.ownershipOfCapital") },
34
35
  {
35
36
  value: "LegalRepresentative",
36
37
  name: t("beneficiaryForm.beneficiary.legalRepresentative"),
37
38
  },
38
- { value: "HasCapital", name: t("beneficiaryForm.beneficiary.ownershipOfCapital") },
39
39
  { value: "Other", name: t("beneficiaryForm.beneficiary.other") },
40
40
  ];
41
41
  const validateCca3CountryCode = value => {
@@ -194,7 +194,7 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
194
194
  sanitize: value => value?.trim(),
195
195
  },
196
196
  type: {
197
- initialValue: initialState?.type ?? "LegalRepresentative",
197
+ initialValue: initialState?.type ?? "HasCapital",
198
198
  validate: validateRequired,
199
199
  },
200
200
  capitalType: {
@@ -329,7 +329,7 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
329
329
  }, onLoadError: onCityLoadError })) })) }), _jsx(Space, { width: 12 }), _jsx(Field, { name: "birthCityPostalCode", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.birthPostalCode"), optionalLabel: isBirthInfoRequired ? undefined : t("common.optional"), style: styles.inputContainer, render: id => (_jsx(LakeTextInput, { error: error, placeholder: birthCountryCode.value == null
330
330
  ? t("beneficiaryForm.beneficiary.fillBirthCountry")
331
331
  : t("beneficiaryForm.beneficiary.birthPostalCodePlaceholder"), id: id, disabled: birthCountryCode.value === undefined, value: value, onChangeText: onChange })) })) })] })) }) }), _jsx(Field, { name: "type", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.type"), type: "radioGroup", render: () => (_jsx(RadioGroup, { direction: "row", value: value, onValueChange: onChange, items: beneficiaryTypes })) })) }), _jsx(FieldsListener, { names: ["type"], children: ({ type }) => type.value === "HasCapital" ? (_jsxs(_Fragment, { children: [_jsx(Field, { name: "totalCapitalPercentage", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.totalCapitalPercentage"), render: id => (_jsx(LakeTextInput, { error: error, unit: "%", inputMode: "decimal", "aria-valuemin": 0, "aria-valuemax": 100, id: id, value: value, onChangeText: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(Field, { name: "capitalType", children: ({ value, error, onChange }) => (_jsx(CapitalTypeCheckboxes, { value: value ?? "none", error: error, onChange: onChange })) })] })) : null })] })))
332
- .with("address", () => (_jsxs(View, { role: "form", children: [_jsx(Field, { name: "country", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.country"), render: id => (_jsx(CountryPicker, { id: id, value: value, countries: individualCountries, onValueChange: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(FieldsListener, { names: ["country"], children: ({ country }) => (_jsxs(_Fragment, { children: [_jsx(AddressFormPart, { apiKey: googleMapApiKey, initialAddress: initialAddress.current.residencyAddressLine1 ?? "", initialCity: initialAddress.current.residencyAddressCity ?? "", initialPostalCode: initialAddress.current.residencyAddressPostalCode ?? "", country: country?.value ?? accountCountry, label: t("beneficiaryForm.beneficiary.address"), Field: Field, setFieldValue: setFieldValue, listenFields: listenFields, isLarge: large }), ((accountCountry === "DEU" && country?.value === "DEU") ||
332
+ .with("address", () => (_jsxs(View, { role: "form", children: [_jsx(Field, { name: "country", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.country"), render: id => (_jsx(CountryPicker, { id: id, value: value, countries: allCountries, onValueChange: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(FieldsListener, { names: ["country"], children: ({ country }) => (_jsxs(_Fragment, { children: [_jsx(AddressFormPart, { apiKey: googleMapApiKey, initialAddress: initialAddress.current.residencyAddressLine1 ?? "", initialCity: initialAddress.current.residencyAddressCity ?? "", initialPostalCode: initialAddress.current.residencyAddressPostalCode ?? "", country: country?.value ?? accountCountry, label: t("beneficiaryForm.beneficiary.address"), Field: Field, setFieldValue: setFieldValue, listenFields: listenFields, isLarge: large }), ((accountCountry === "DEU" && country?.value === "DEU") ||
333
333
  accountCountry === "ESP") && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(Field, { name: "taxIdentificationNumber", children: ({ value, error, valid, onChange }) => (_jsx(TaxIdentificationNumberInput, { value: value ?? "", error: error, valid: valid, onChange: onChange, accountCountry: accountCountry, isCompany: false,
334
334
  // is mandatory for German accounts and UBO living in Germany
335
335
  required: accountCountry === "DEU" && country?.value === "DEU" })) })] }))] })) })] })))
@@ -1,5 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AutoWidthImage } from "@swan-io/lake/src/components/AutoWidthImage";
3
2
  import { Box } from "@swan-io/lake/src/components/Box";
4
3
  import { Fill } from "@swan-io/lake/src/components/Fill";
5
4
  import { LakeHeading } from "@swan-io/lake/src/components/LakeHeading";
@@ -14,6 +13,10 @@ import { match } from "ts-pattern";
14
13
  import { t } from "../utils/i18n";
15
14
  const LOGO_MAX_HEIGHT = 26;
16
15
  const LOGO_MAX_WIDTH = 200;
16
+ const imageStyle = {
17
+ objectFit: "contain",
18
+ objectPosition: "left",
19
+ };
17
20
  const styles = StyleSheet.create({
18
21
  container: {
19
22
  width: 470,
@@ -66,7 +69,7 @@ export const RIB = (props) => match(props)
66
69
  .with({ version: "v1" }, props => _jsx(RIBv1, { ...props }))
67
70
  .exhaustive();
68
71
  const RIBv1 = ({ partnerColor, partnerLogoUrl, iban, bic, bank, agency, bankNumber, bankKey, bankAddress, accountHolderAddress, }) => {
69
- return (_jsx(WithPartnerAccentColor, { color: partnerColor, children: _jsxs(View, { style: styles.container, children: [_jsxs(View, { style: styles.part, children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [isNotNullishOrEmpty(partnerLogoUrl) ? (_jsx(AutoWidthImage, { sourceUri: partnerLogoUrl, height: LOGO_MAX_HEIGHT, maxWidth: LOGO_MAX_WIDTH, resizeMode: "contain" })) : (_jsx(SwanLogo, { style: styles.defaultLogo })), _jsx(Fill, { minWidth: 24 }), _jsx(LakeHeading, { level: 2, variant: "h3", color: colors.gray[900], children: t("rib.bankDetails") })] }), _jsx(Space, { height: 24 }), _jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(RibValue, { type: "mainInfo", color: "partner", label: t("rib.iban"), value: iban }), _jsx(Space, { width: 24 }), _jsx(RibValue, { type: "mainInfo", color: "partner", label: t("rib.bic"), value: bic })] }), _jsx(Space, { height: 8 }), _jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(RibValue, { type: "smallInfo", color: "gray", label: t("rib.bank"), value: bank }), _jsx(Space, { width: 24 }), _jsx(RibValue, { type: "smallInfo", color: "gray", label: t("rib.agency"), value: agency }), _jsx(Space, { width: 24 }), _jsx(RibValue, { type: "smallInfo", color: "gray", label: t("rib.number"), value: bankNumber }), _jsx(Space, { width: 24 }), _jsx(RibValue, { type: "smallInfo", color: "gray", label: t("rib.key"), value: bankKey })] })] }), _jsx(Separator, {}), _jsxs(View, { style: styles.part, children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(RibValue, { type: "addressInfo", color: "partner", label: t("rib.address"), value: [
72
+ return (_jsx(WithPartnerAccentColor, { color: partnerColor, children: _jsxs(View, { style: styles.container, children: [_jsxs(View, { style: styles.part, children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [isNotNullishOrEmpty(partnerLogoUrl) ? (_jsx("img", { src: partnerLogoUrl, width: LOGO_MAX_WIDTH, height: LOGO_MAX_HEIGHT, style: imageStyle })) : (_jsx(SwanLogo, { style: styles.defaultLogo })), _jsx(Fill, { minWidth: 24 }), _jsx(LakeHeading, { level: 2, variant: "h3", color: colors.gray[900], children: t("rib.bankDetails") })] }), _jsx(Space, { height: 24 }), _jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(RibValue, { type: "mainInfo", color: "partner", label: t("rib.iban"), value: iban }), _jsx(Space, { width: 24 }), _jsx(RibValue, { type: "mainInfo", color: "partner", label: t("rib.bic"), value: bic })] }), _jsx(Space, { height: 8 }), _jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(RibValue, { type: "smallInfo", color: "gray", label: t("rib.bank"), value: bank }), _jsx(Space, { width: 24 }), _jsx(RibValue, { type: "smallInfo", color: "gray", label: t("rib.agency"), value: agency }), _jsx(Space, { width: 24 }), _jsx(RibValue, { type: "smallInfo", color: "gray", label: t("rib.number"), value: bankNumber }), _jsx(Space, { width: 24 }), _jsx(RibValue, { type: "smallInfo", color: "gray", label: t("rib.key"), value: bankKey })] })] }), _jsx(Separator, {}), _jsxs(View, { style: styles.part, children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(RibValue, { type: "addressInfo", color: "partner", label: t("rib.address"), value: [
70
73
  bankAddress.name,
71
74
  bankAddress.address,
72
75
  `${bankAddress.zipCode} ${bankAddress.city}`,
@@ -1,4 +1,4 @@
1
- export type AccountCountry = "DEU" | "ESP" | "FRA";
1
+ export type AccountCountry = "DEU" | "ESP" | "FRA" | "NLD";
2
2
  export declare const getIndividualTaxNumberPlaceholder: (accountCountry: AccountCountry) => string;
3
3
  export declare const getCompanyTaxNumberPlaceholder: (accountCountry: AccountCountry) => string;
4
4
  export declare const getTaxNumberTooltip: (accountCountry: AccountCountry) => string;