@swan-io/shared-business 2.0.0 → 2.0.2

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.0.0",
3
+ "version": "2.0.2",
4
4
  "engines": {
5
5
  "node": ">=14.0.0",
6
6
  "yarn": "^1.20.0"
@@ -29,9 +29,9 @@
29
29
  "@swan-io/lake": "*"
30
30
  },
31
31
  "dependencies": {
32
- "@formatjs/intl": "^2.7.1",
32
+ "@formatjs/intl": "^2.7.2",
33
33
  "@googlemaps/js-api-loader": "^1.15.1",
34
- "@swan-io/boxed": "^1.0.1",
34
+ "@swan-io/boxed": "^1.0.2",
35
35
  "dayjs": "^1.11.7",
36
36
  "react": "^18.2.0",
37
37
  "react-atomic-state": "^1.2.7",
@@ -40,19 +40,19 @@
40
40
  "react-native-web": "^0.19.4",
41
41
  "react-ux-form": "^1.3.0",
42
42
  "rifm": "^0.12.1",
43
- "ts-pattern": "^4.2.2",
43
+ "ts-pattern": "^4.3.0",
44
44
  "uuid": "^9.0.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@swan-io/lake": "*",
48
48
  "@testing-library/react": "^14.0.0",
49
49
  "@testing-library/user-event": "^14.4.3",
50
- "@types/google.maps": "^3.52.6",
51
- "@types/react": "^18.0.37",
52
- "@types/react-dom": "^18.0.11",
50
+ "@types/google.maps": "^3.53.1",
51
+ "@types/react": "^18.2.6",
52
+ "@types/react-dom": "^18.2.4",
53
53
  "@types/react-native": "^0.71.6",
54
54
  "@types/uuid": "^9.0.1",
55
- "jsdom": "^21.1.1",
56
- "vitest": "^0.30.1"
55
+ "jsdom": "^22.0.0",
56
+ "vitest": "^0.31.0"
57
57
  }
58
58
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Form } from "react-ux-form";
3
2
  import { CountryCCA3 } from "../constants/countries";
4
3
  type AddressField = {
@@ -18,5 +17,5 @@ type Props = {
18
17
  isLarge: boolean;
19
18
  apiKey: string;
20
19
  } & FormProps;
21
- export declare const AddressFormPart: ({ initialAddress, initialCity, initialPostalCode, country, label, optionalLabel, placeholder, Field, setFieldValue, listenFields, isLarge, apiKey, }: Props) => JSX.Element;
20
+ export declare const AddressFormPart: ({ initialAddress, initialCity, initialPostalCode, country, label, optionalLabel, placeholder, Field, setFieldValue, listenFields, isLarge, apiKey, }: Props) => import("react/jsx-runtime").JSX.Element;
22
21
  export {};
@@ -240,6 +240,12 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
240
240
  },
241
241
  });
242
242
  const hasBeenSubmittedOnce = useRef(false);
243
+ useEffect(() => {
244
+ if (initialState != null) {
245
+ // submit form to validate all fields
246
+ submitForm(noop);
247
+ }
248
+ }, [initialState, submitForm]);
243
249
  useEffect(() => {
244
250
  return listenFields(["type"], () => {
245
251
  if (hasBeenSubmittedOnce.current) {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CountryCCA2, CountryCCA3 } from "../constants/countries";
3
2
  export type CountryItem<T extends CountryCCA3> = {
4
3
  cca3: T;
@@ -16,5 +15,5 @@ type Props<T extends CountryCCA3> = {
16
15
  disabled?: boolean;
17
16
  hideErrors?: boolean;
18
17
  };
19
- export declare function CountryPicker<T extends CountryCCA3>({ onValueChange, value, items, readOnly, id, error, placeholder, disabled, hideErrors, }: Props<T>): JSX.Element;
18
+ export declare function CountryPicker<T extends CountryCCA3>({ onValueChange, value, items, readOnly, id, error, placeholder, disabled, hideErrors, }: Props<T>): import("react/jsx-runtime").JSX.Element;
20
19
  export {};
@@ -18,5 +18,5 @@ type Props = {
18
18
  emptyResultText: string;
19
19
  apiKey: string;
20
20
  };
21
- export declare const GMapAddressSearchInput: ({ inputRef, id, country, disabled, error, value, onValueChange, onSuggestion, language, placeholder, shouldDisplaySuggestions, emptyResultText, apiKey, }: Props) => JSX.Element;
21
+ export declare const GMapAddressSearchInput: ({ inputRef, id, country, disabled, error, value, onValueChange, onSuggestion, language, placeholder, shouldDisplaySuggestions, emptyResultText, apiKey, }: Props) => import("react/jsx-runtime").JSX.Element;
22
22
  export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CountryCCA3 } from "../constants/countries";
3
2
  import { PlaceDetail } from "../hooks/useGoogleMapSDK";
4
3
  type Props = {
@@ -13,5 +12,5 @@ type Props = {
13
12
  onLoadError: (error: unknown) => void;
14
13
  apiKey: string;
15
14
  };
16
- export declare const GMapCityInput: ({ value, onValueChange, country, disabled, placeholder, id, error, onSuggestion, onLoadError, apiKey, }: Props) => JSX.Element;
15
+ export declare const GMapCityInput: ({ value, onValueChange, country, disabled, placeholder, id, error, onSuggestion, onLoadError, apiKey, }: Props) => import("react/jsx-runtime").JSX.Element;
17
16
  export {};
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  export declare const CONTENT_ID = "content";
3
- export declare const SkipToContent: () => JSX.Element | null;
2
+ export declare const SkipToContent: () => import("react/jsx-runtime").JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { AccountCountry } from "../utils/templateTranslations";
3
2
  type Props = {
4
3
  value: string;
@@ -11,5 +10,5 @@ type Props = {
11
10
  isCompany: boolean;
12
11
  required?: boolean;
13
12
  };
14
- export declare const TaxIdentificationNumberInput: ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, }: Props) => JSX.Element;
13
+ export declare const TaxIdentificationNumberInput: ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, }: Props) => import("react/jsx-runtime").JSX.Element;
15
14
  export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IconName } from "@swan-io/lake/src/components/Icon";
3
2
  import { DropzoneOptions } from "react-dropzone";
4
3
  export type UploadFileStatus = ({
@@ -28,5 +27,5 @@ type Props = {
28
27
  error?: string;
29
28
  maxSize?: number;
30
29
  };
31
- export declare const UploadArea: ({ icon, accept, value, documents, disabled, onRemoveFile, onDropAccepted, onDropRejected, layout, description, error, maxSize, }: Props) => JSX.Element;
30
+ export declare const UploadArea: ({ icon, accept, value, documents, disabled, onRemoveFile, onDropAccepted, onDropRejected, layout, description, error, maxSize, }: Props) => import("react/jsx-runtime").JSX.Element;
32
31
  export {};
@@ -22,7 +22,9 @@ export const getLanguagesHelpers = (languages) => {
22
22
  setPreferredLanguage: (language) => {
23
23
  try {
24
24
  localStorage.setItem(PREFERRED_LANGUAGE_KEY, language);
25
- window.location.reload();
25
+ const url = new URL(window.location.href);
26
+ url.searchParams.delete("lang");
27
+ window.location.replace(url.toString());
26
28
  }
27
29
  catch {
28
30
  return;
@@ -1,22 +1,22 @@
1
1
  import { match } from "ts-pattern";
2
2
  import { t } from "./i18n";
3
3
  export const getIndividualTaxNumberPlaceholder = (accountCountry) => match(accountCountry)
4
- .with("DEU", () => `${t('common.form.taxIdentificationNumber.placeholder')} (Steueridentifikationsnummer)`)
5
- .with("ESP", () => `${t('common.form.taxIdentificationNumber.placeholder')} (Número de Identificación Fiscal)`)
6
- .otherwise(() => t('common.form.taxIdentificationNumber.placeholder'));
4
+ .with("DEU", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Steueridentifikationsnummer)`)
5
+ .with("ESP", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Número de Identificación Fiscal)`)
6
+ .otherwise(() => t("common.form.taxIdentificationNumber.placeholder"));
7
7
  export const getCompanyTaxNumberPlaceholder = (accountCountry) => match(accountCountry)
8
- .with("DEU", () => `${t('common.form.taxIdentificationNumber.placeholder')} (Steuer-Nummer)`)
9
- .with("ESP", () => `${t('common.form.taxIdentificationNumber.placeholder')} (Número de Identificación Fiscal)`)
10
- .otherwise(() => t('common.form.taxIdentificationNumber.placeholder'));
8
+ .with("DEU", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Steuer-Nummer)`)
9
+ .with("ESP", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Número de Identificación Fiscal)`)
10
+ .otherwise(() => t("common.form.taxIdentificationNumber.placeholder"));
11
11
  export const getTaxNumberTooltip = (accountCountry) => match(accountCountry)
12
12
  .with("DEU", () => t("common.form.taxIdentificationNumber.tooltip.deu"))
13
13
  .with("ESP", () => "Número de Identificación Fiscal") // no need to translate
14
- .otherwise(() => '');
14
+ .otherwise(() => "");
15
15
  export const getCompanyTaxNumberHelp = (accountCountry) => match(accountCountry)
16
- .with("DEU", () => t("common.form.help.nbDigits", { nbDigits: '10-11' }))
17
- .with("ESP", () => t("common.form.help.nbCharacters", { nbCharacters: '9' }))
18
- .otherwise(() => '');
16
+ .with("DEU", () => t("common.form.help.nbDigits", { nbDigits: "10-11" }))
17
+ .with("ESP", () => t("common.form.help.nbCharacters", { nbCharacters: "9" }))
18
+ .otherwise(() => "");
19
19
  export const getIndividualTaxNumberHelp = (accountCountry) => match(accountCountry)
20
- .with("DEU", () => t("common.form.help.nbDigits", { nbDigits: '11' }))
21
- .with("ESP", () => t("common.form.help.nbCharacters", { nbCharacters: '9' }))
22
- .otherwise(() => '');
20
+ .with("DEU", () => t("common.form.help.nbDigits", { nbDigits: "11" }))
21
+ .with("ESP", () => t("common.form.help.nbCharacters", { nbCharacters: "9" }))
22
+ .otherwise(() => "");