@swan-io/shared-business 12.2.9 → 12.2.11

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": "12.2.9",
3
+ "version": "12.2.11",
4
4
  "engines": {
5
5
  "node": "^22.12.0"
6
6
  },
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "license": "MIT",
27
27
  "peerDependencies": {
28
- "@swan-io/lake": "12.2.9"
28
+ "@swan-io/lake": "12.2.11"
29
29
  },
30
30
  "dependencies": {
31
31
  "@formatjs/intl": "^3.1.6",
@@ -51,6 +51,6 @@
51
51
  "@types/react-native": "^0.72.8",
52
52
  "jsdom": "^26.1.0",
53
53
  "vitest": "^3.2.0",
54
- "@swan-io/lake": "12.2.9"
54
+ "@swan-io/lake": "12.2.11"
55
55
  }
56
56
  }
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box } from "@swan-io/lake/src/components/Box";
3
3
  import { Separator } from "@swan-io/lake/src/components/Separator";
4
4
  import { Space } from "@swan-io/lake/src/components/Space";
@@ -110,7 +110,7 @@ const logoStyle = {
110
110
  export const AccountStatementV1 = ({ partnerLogoUrl, style, accountHolderType, accountHolderName, accountHolderAddress, iban, bic, openingDate, closingDate, openingBalance, transactions, feesDebit, feesCredit, totalsCredit, totalsDebit, closingBalance, }) => {
111
111
  return (_jsxs(Box, { style: [styles.container, style], direction: "column", justifyContent: "spaceBetween", children: [_jsxs(Box, { children: [_jsx(Box, { direction: "row", justifyContent: "spaceBetween", children: _jsxs(Box, { direction: "row", alignItems: "center", children: [isNotNullishOrEmpty(partnerLogoUrl) ? (_jsx("img", { src: partnerLogoUrl, style: logoStyle })) : (_jsx(SwanLogo, { style: styles.defaultLogo })), _jsx(Separator, { horizontal: true, space: 8 }), _jsx(Text, { style: styles.partnershipText, children: t("accountStatement.partnership") }), _jsx(Space, { width: 4 }), _jsx(SwanLogo, { color: colors.gray[900], style: styles.swanLogo })] }) }), _jsx(Space, { height: 24 }), _jsx(Text, { style: styles.pageTitle, children: t("accountStatement.titleDocument") }), _jsx(Space, { height: 8 }), _jsx(Text, { style: styles.text, children: accountHolderType === "Company"
112
112
  ? t("accountStatement.titleDocument.companyDescription")
113
- : t("accountStatement.titleDocument.individualDescription") }), _jsx(Space, { height: 24 }), _jsxs(Box, { direction: "row", justifyContent: "spaceBetween", children: [_jsxs(Box, { direction: "column", children: [_jsx(Text, { style: styles.sectionTitle, children: accountHolderName.toUpperCase() }), _jsx(Text, { style: styles.text, children: accountHolderAddress.street }), _jsx(Text, { style: styles.text, children: accountHolderAddress.city }), isNotNullish(accountHolderAddress.country) && (_jsx(Text, { style: styles.text, children: getCountryName(accountHolderAddress.country) }))] }), _jsxs(Box, { direction: "column", alignItems: "end", children: [_jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.contactSupport") }), _jsx(Text, { style: styles.text, children: "support@swan.io" })] })] }), _jsx(Space, { height: 24 }), _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.iban") }), _jsx(Text, { style: styles.text, children: iban }), _jsx(Space, { height: 12 }), _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.bic") }), _jsx(Text, { style: styles.text, children: bic }), _jsx(Space, { height: 48 }), _jsxs(Box, { direction: "row", justifyContent: "spaceBetween", children: [_jsx(Box, { direction: "column", children: _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.date", { openingDate, closingDate }) }) }), _jsxs(Box, { direction: "column", children: [_jsx(Text, { style: styles.openingBalanceText, children: t("accountStatement.openingBalance") }), _jsx(Text, { style: styles.totalAmount, children: formatCurrencyIso(Number(openingBalance.value), openingBalance.currency) })] })] }), _jsx(Space, { height: 24 }), _jsxs(_Fragment, { children: [_jsxs(Box, { direction: "row", style: { backgroundColor: colors.gray[50] }, children: [_jsx(Text, { style: [styles.titleColumn, { width: "15%" }], children: t("accountStatement.column.date") }), _jsx(Text, { style: [styles.titleColumn, { width: "22%" }], children: t("accountStatement.column.type") }), _jsx(Text, { style: [styles.titleColumn, { width: "33%" }], children: t("accountStatement.column.description") }), _jsx(Text, { style: [styles.titleColumn, { width: "15%", textAlign: "right" }], children: t("accountStatement.column.credit") }), _jsx(Text, { style: [styles.titleColumn, { width: "15%", textAlign: "right" }], children: t("accountStatement.column.debit") })] }), _jsx(Box, { direction: "column", children: transactions.map(transaction => (_jsxs(Box, { direction: "row", children: [_jsx(Text, { style: [styles.textColumn, { width: "15%" }], children: transaction.date }), _jsx(Text, { style: [styles.textColumn, { width: "22%" }], children: translateTransaction(transaction.type) }), _jsx(Text, { style: [styles.textColumn, { width: "33%" }], children: transaction.label }), _jsx(Text, { style: [styles.textColumn, { width: "15%", textAlign: "right" }], children: transaction.credit ? transaction.credit.value : "" }), _jsx(Text, { style: [styles.textColumn, { width: "15%", textAlign: "right" }], children: transaction.debit ? transaction.debit.value : "" })] }, transaction.id))) })] }), _jsxs(Box, { direction: "column", children: [_jsxs(Box, { direction: "row", justifyContent: "end", children: [_jsx(Text, { style: styles.row, children: t("accountStatement.column.fees") }), _jsx(Text, { style: styles.row, children: feesCredit.value }), _jsx(Text, { style: styles.row, children: feesDebit.value })] }), _jsxs(Box, { direction: "row", justifyContent: "end", children: [_jsx(Text, { style: styles.row, children: t("accountStatement.column.totals") }), _jsx(Text, { style: styles.row, children: totalsCredit.value }), _jsx(Text, { style: styles.row, children: totalsDebit.value })] })] }), _jsx(Box, { direction: "row", justifyContent: "end", children: _jsxs(Box, { direction: "row", alignItems: "center", style: styles.closingBalanceRow, justifyContent: "spaceBetween", children: [_jsx(Title, { text: t("accountStatement.closingBalance") }), _jsx(Title, { text: formatCurrencyIso(Number(closingBalance.value), closingBalance.currency), style: styles.totalAmount, align: "right" })] }) })] }), _jsxs(Box, { children: [_jsx(Separator, { space: 24 }), _jsx(Text, { style: styles.footer, children: t("transactionStatement.footer") })] })] }));
113
+ : t("accountStatement.titleDocument.individualDescription") }), _jsx(Space, { height: 24 }), _jsxs(Box, { direction: "row", justifyContent: "spaceBetween", children: [_jsxs(Box, { direction: "column", children: [_jsx(Text, { style: styles.sectionTitle, children: accountHolderName.toUpperCase() }), _jsx(Text, { style: styles.text, children: accountHolderAddress.street }), _jsx(Text, { style: styles.text, children: accountHolderAddress.city }), isNotNullish(accountHolderAddress.country) && (_jsx(Text, { style: styles.text, children: getCountryName(accountHolderAddress.country) }))] }), _jsxs(Box, { direction: "column", alignItems: "end", children: [_jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.contactSupport") }), _jsx(Text, { style: styles.text, children: "support@swan.io" })] })] }), _jsx(Space, { height: 24 }), _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.iban") }), _jsx(Text, { style: styles.text, children: iban }), _jsx(Space, { height: 12 }), _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.bic") }), _jsx(Text, { style: styles.text, children: bic }), _jsx(Space, { height: 48 }), _jsxs(Box, { direction: "row", justifyContent: "spaceBetween", children: [_jsx(Box, { direction: "column", children: _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.date", { openingDate, closingDate }) }) }), _jsxs(Box, { direction: "column", children: [_jsx(Text, { style: styles.openingBalanceText, children: t("accountStatement.openingBalance") }), _jsx(Text, { style: styles.totalAmount, children: formatCurrencyIso(Number(openingBalance.value), openingBalance.currency) })] })] }), _jsx(Space, { height: 24 }), _jsxs(Box, { direction: "row", style: { backgroundColor: colors.gray[50] }, children: [_jsx(Text, { style: [styles.titleColumn, { width: "15%" }], children: t("accountStatement.column.date") }), _jsx(Text, { style: [styles.titleColumn, { width: "22%" }], children: t("accountStatement.column.type") }), _jsx(Text, { style: [styles.titleColumn, { width: "33%" }], children: t("accountStatement.column.description") }), _jsx(Text, { style: [styles.titleColumn, { width: "15%", textAlign: "right" }], children: t("accountStatement.column.credit") }), _jsx(Text, { style: [styles.titleColumn, { width: "15%", textAlign: "right" }], children: t("accountStatement.column.debit") })] }), _jsx(Box, { direction: "column", children: transactions.map(transaction => (_jsxs(Box, { direction: "row", children: [_jsx(Text, { style: [styles.textColumn, { width: "15%" }], children: transaction.date }), _jsx(Text, { style: [styles.textColumn, { width: "22%" }], children: translateTransaction(transaction.type) }), _jsx(Text, { style: [styles.textColumn, { width: "33%" }], children: transaction.label }), _jsx(Text, { style: [styles.textColumn, { width: "15%", textAlign: "right" }], children: transaction.credit ? transaction.credit.value : "" }), _jsx(Text, { style: [styles.textColumn, { width: "15%", textAlign: "right" }], children: transaction.debit ? transaction.debit.value : "" })] }, transaction.id))) }), _jsxs(Box, { direction: "column", children: [_jsxs(Box, { direction: "row", justifyContent: "end", children: [_jsx(Text, { style: styles.row, children: t("accountStatement.column.fees") }), _jsx(Text, { style: styles.row, children: feesCredit.value }), _jsx(Text, { style: styles.row, children: feesDebit.value })] }), _jsxs(Box, { direction: "row", justifyContent: "end", children: [_jsx(Text, { style: styles.row, children: t("accountStatement.column.totals") }), _jsx(Text, { style: styles.row, children: totalsCredit.value }), _jsx(Text, { style: styles.row, children: totalsDebit.value })] })] }), _jsx(Box, { direction: "row", justifyContent: "end", children: _jsxs(Box, { direction: "row", alignItems: "center", style: styles.closingBalanceRow, justifyContent: "spaceBetween", children: [_jsx(Title, { text: t("accountStatement.closingBalance") }), _jsx(Title, { text: formatCurrencyIso(Number(closingBalance.value), closingBalance.currency), style: styles.totalAmount, align: "right" })] }) })] }), _jsxs(Box, { children: [_jsx(Separator, { space: 24 }), _jsx(Text, { style: styles.footer, children: t("transactionStatement.footer") })] })] }));
114
114
  };
115
115
  export const AccountStatement = (props) => match(props)
116
116
  .with({ version: "v1" }, props => _jsx(AccountStatementV1, { ...props }))
@@ -107,7 +107,7 @@ export const ChoicePicker = ({ tile = true, items, getId = identity, large = fal
107
107
  const containerRef = useRef(null);
108
108
  const { desktop } = useResponsive(breakpoints.medium);
109
109
  const [mobilePosition, setMobilePosition] = useState("start");
110
- // biome-ignore lint/correctness/useExhaustiveDependencies:
110
+ // biome-ignore lint/correctness/useExhaustiveDependencies: _
111
111
  useEffect(() => {
112
112
  if (desktop) {
113
113
  return;
@@ -14,7 +14,7 @@ const zendeskFieldMapping = {
14
14
  };
15
15
  const [zendeskApi, setZendeskApi] = Deferred.make();
16
16
  export const SupportChat = ({ children, accentColor, type, additionalInfo }) => {
17
- // biome-ignore lint/correctness/useExhaustiveDependencies(zE):
17
+ // biome-ignore lint/correctness/useExhaustiveDependencies(zE): _
18
18
  useEffect(() => {
19
19
  const script = document.createElement("script");
20
20
  script.id = "ze-snippet";
@@ -38,7 +38,7 @@ export const SupportChat = ({ children, accentColor, type, additionalInfo }) =>
38
38
  color: { theme: accentColor !== null && accentColor !== void 0 ? accentColor : "#26232f" },
39
39
  };
40
40
  }, [accentColor]);
41
- // biome-ignore lint/correctness/useExhaustiveDependencies(zE):
41
+ // biome-ignore lint/correctness/useExhaustiveDependencies(zE): _
42
42
  useEffect(() => {
43
43
  const { firstName, lastName, email, projectName, ...fieldInfos } = additionalInfo;
44
44
  const values = Dict.entries({ ...fieldInfos, email });
@@ -76,7 +76,7 @@ export const SupportChat = ({ children, accentColor, type, additionalInfo }) =>
76
76
  }
77
77
  });
78
78
  }, [accentColor, additionalInfo]);
79
- // biome-ignore lint/correctness/useExhaustiveDependencies(zE):
79
+ // biome-ignore lint/correctness/useExhaustiveDependencies(zE): _
80
80
  const onPressShow = useCallback(() => {
81
81
  try {
82
82
  zE("webWidget", "show");
@@ -52,7 +52,7 @@
52
52
  "common.filters.none": "Keine",
53
53
  "common.form.help.nbCharacters": "{nbCharacters} Zeichen",
54
54
  "common.form.help.nbDigits": "{nbDigits} Ziffern",
55
- "common.form.invalidTaxIdentificationNumber": "Diese Steueridentifikationsnummer ist ungültig",
55
+ "common.form.invalidTaxIdentificationNumber": "Dieses Feld ist ungültig",
56
56
  "common.form.taxIdentificationNumber.placeholder": "Steueridentifikationsnummer",
57
57
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (auch Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr oder Steuer-ID gemäß § 139b AO)",
58
58
  "common.form.taxIdentificationNumber.tooltip.ita": "Steuer-ID (Codice fiscale)",
@@ -52,7 +52,7 @@
52
52
  "common.filters.none": "None",
53
53
  "common.form.help.nbCharacters": "{nbCharacters} characters",
54
54
  "common.form.help.nbDigits": "{nbDigits} digits",
55
- "common.form.invalidTaxIdentificationNumber": "This tax identification number is invalid",
55
+ "common.form.invalidTaxIdentificationNumber": "This field is invalid",
56
56
  "common.form.taxIdentificationNumber.placeholder": "Tax ID",
57
57
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (also Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr or Steuer-ID, according to § 139b AO)",
58
58
  "common.form.taxIdentificationNumber.tooltip.ita": "Tax ID (Codice fiscale)",
@@ -52,7 +52,7 @@
52
52
  "common.filters.none": "Ninguno",
53
53
  "common.form.help.nbCharacters": "{nbCharacters} caracteres",
54
54
  "common.form.help.nbDigits": "{nbDigits} dígitos",
55
- "common.form.invalidTaxIdentificationNumber": "Este número de identificación fiscal no es válido",
55
+ "common.form.invalidTaxIdentificationNumber": "Este campo es inválido",
56
56
  "common.form.taxIdentificationNumber.placeholder": "Número de identificación fiscal",
57
57
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (también Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr o Steuer-ID, según § 139b AO)",
58
58
  "common.form.taxIdentificationNumber.tooltip.ita": "Número de identificación fiscal (Codice fiscale)",
@@ -52,7 +52,7 @@
52
52
  "common.filters.none": "Ei yhtään",
53
53
  "common.form.help.nbCharacters": "{nbCharacters} merkkiä",
54
54
  "common.form.help.nbDigits": "{nbDigits} numeroa",
55
- "common.form.invalidTaxIdentificationNumber": "Virheellinen verotunnistenumero",
55
+ "common.form.invalidTaxIdentificationNumber": "Tämä kenttä on virheellinen",
56
56
  "common.form.taxIdentificationNumber.placeholder": "verotunnus",
57
57
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (also Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr or Steuer-ID, according to § 139b AO)",
58
58
  "common.form.taxIdentificationNumber.tooltip.ita": "Verotunnus (Codice fiscale)",
@@ -52,7 +52,7 @@
52
52
  "common.filters.none": "Aucun",
53
53
  "common.form.help.nbCharacters": "{nbCharacters} caractères",
54
54
  "common.form.help.nbDigits": "{nbDigits} chiffres",
55
- "common.form.invalidTaxIdentificationNumber": "Ce numéro d'identification fiscale n'est pas valide",
55
+ "common.form.invalidTaxIdentificationNumber": "Ce champ est invalide",
56
56
  "common.form.taxIdentificationNumber.placeholder": "Numéro d'identification fiscale",
57
57
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (également Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr ou Steuer-ID, selon § 139b AO)",
58
58
  "common.form.taxIdentificationNumber.tooltip.ita": "Numéro d'identification fiscale (Codice fiscale)",
@@ -52,7 +52,7 @@
52
52
  "common.filters.none": "Nessuno",
53
53
  "common.form.help.nbCharacters": "{nbCharacters} caratteri",
54
54
  "common.form.help.nbDigits": "{nbDigits} cifre",
55
- "common.form.invalidTaxIdentificationNumber": "Codice fiscale non valido",
55
+ "common.form.invalidTaxIdentificationNumber": "Questo campo non è valido",
56
56
  "common.form.taxIdentificationNumber.placeholder": "Codice fiscale",
57
57
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (anche Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Steuer-IDNr., Steuer-ID o Steuer-ID, secondo § 139b AO)",
58
58
  "common.form.taxIdentificationNumber.tooltip.ita": "Codice fiscale (Tax ID)",
@@ -52,7 +52,7 @@
52
52
  "common.filters.none": "Geen",
53
53
  "common.form.help.nbCharacters": "{nbCharacters} tekens",
54
54
  "common.form.help.nbDigits": "{nbDigits} cijfers",
55
- "common.form.invalidTaxIdentificationNumber": "Dit fiscale identificatienummer is ongeldig",
55
+ "common.form.invalidTaxIdentificationNumber": "Dit veld is ongeldig",
56
56
  "common.form.taxIdentificationNumber.placeholder": "BTW-nummer",
57
57
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (ook Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IDnr., IDnr of Steuer-ID, volgens § 139b AO)",
58
58
  "common.form.taxIdentificationNumber.tooltip.ita": "Btw-nummer (Codice fiscale)",
@@ -52,7 +52,7 @@
52
52
  "common.filters.none": "Nenhum",
53
53
  "common.form.help.nbCharacters": "{nbCharacters} caracteres",
54
54
  "common.form.help.nbDigits": "{nbDigits} dígitos",
55
- "common.form.invalidTaxIdentificationNumber": "Este número de identificação fiscal é inválido",
55
+ "common.form.invalidTaxIdentificationNumber": "Este campo é inválido",
56
56
  "common.form.taxIdentificationNumber.placeholder": "Número de Identificação Fiscal",
57
57
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (também Steuerliche Identificationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr ou Steuer-ID, conforme § 139b AO)",
58
58
  "common.form.taxIdentificationNumber.tooltip.ita": "NIF (Número de Identificação Fiscal)",
@@ -2,7 +2,7 @@ import { intersection } from "@swan-io/lake/src/utils/array";
2
2
  import { isNotNullish, isNullish } from "@swan-io/lake/src/utils/nullish";
3
3
  export const LANGUAGE_FALLBACK = "en";
4
4
  const PREFERRED_LANGUAGE_KEY = "swan__PreferredLanguage";
5
- let supportedLanguages = undefined;
5
+ let supportedLanguages;
6
6
  export const getLanguagesHelpers = (languages) => {
7
7
  // Restrict shared-business supported languages to the current project ones
8
8
  supportedLanguages = isNullish(supportedLanguages)
@@ -1,14 +1,9 @@
1
- import { isNotNullish } from "@swan-io/lake/src/utils/nullish";
2
- import { countries, france } from "../constants/countries";
1
+ import { france, getCountryByCCA2, isCountryCCA2 } from "../constants/countries";
3
2
  export const getMostLikelyUserCountry = () => {
4
- const navigatorCountries = navigator.languages
5
- .map(language => language.split("-")[1])
6
- .filter(isNotNullish);
7
- for (let index = 0; index < navigatorCountries.length; index++) {
8
- const navigatorCountry = navigatorCountries[index];
9
- const country = countries.find(({ cca2 }) => cca2 === navigatorCountry);
10
- if (isNotNullish(country)) {
11
- return country;
3
+ const countries = navigator.languages.map(language => language.split("-")[1]);
4
+ for (const country of countries) {
5
+ if (isCountryCCA2(country)) {
6
+ return getCountryByCCA2(country);
12
7
  }
13
8
  }
14
9
  // fallback to france when no valid country found in navigator locales