@mailstep/design-system 0.10.5 → 0.10.7

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": "@mailstep/design-system",
3
- "version": "0.10.5",
3
+ "version": "0.10.7",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -3,16 +3,22 @@ import { Container, HiddenInput } from "./styles.js";
3
3
  import { useCallback } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region packages/ui/Blocks/ImageList/components/AddPhoto/index.tsx
6
+ const IMAGE_MIME_PREFIX = "image/";
6
7
  const AddPhoto = ({ onImageUpload, isDisabled, hasRemove }) => {
7
8
  const handleImageUpload = useCallback((event) => {
8
- if (!event.target?.files?.[0]) return;
9
+ const input = event.target;
10
+ const file = input?.files?.[0];
11
+ if (!file?.type.startsWith(IMAGE_MIME_PREFIX)) {
12
+ input.value = "";
13
+ return;
14
+ }
9
15
  const reader = new FileReader();
10
- reader.readAsDataURL(event.target.files[0]);
16
+ reader.readAsDataURL(file);
11
17
  reader.onload = async () => {
12
18
  await onImageUpload?.({
13
19
  base64image: reader.result?.split(",").pop(),
14
20
  base64WithDataDeclaration: reader.result,
15
- file: event.target.files?.[0]
21
+ file
16
22
  });
17
23
  };
18
24
  }, [onImageUpload]);
@@ -9,7 +9,7 @@ import { x } from "@xstyled/styled-components";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
10
  import { Trans } from "@lingui/react";
11
11
  //#region packages/ui/Blocks/LoginPage/LoginPage.tsx
12
- const Login = ({ onSubmit, activeLanguage, onLanguageChange, children, brand, brandVariant, isSubmitting, isSubmitDisabled, withDistributionCenterSelect, distributionCenterOptions, selectedDistributionCenter, onChangeDistributionCenter, languageItems, version, backgroundImage, admin, hasSupport = true, hasSocialLinks = true, withPassword = true, withLogin = true, loginLabel, passwordLabel }) => {
12
+ const Login = ({ onSubmit, activeLanguage, onLanguageChange, children, brand, brandVariant, isSubmitting, isSubmitDisabled, withDistributionCenterSelect, distributionCenterOptions, selectedDistributionCenter, onChangeDistributionCenter, languageItems, version, backgroundImage, admin, hasSupport = true, hasSocialLinks = true, withPassword = true, withLogin = true, loginLabel, passwordLabel, formHeader }) => {
13
13
  return /* @__PURE__ */ jsxs(Wrapper, {
14
14
  backgroundImage,
15
15
  children: [
@@ -50,7 +50,8 @@ const Login = ({ onSubmit, activeLanguage, onLanguageChange, children, brand, br
50
50
  withPassword,
51
51
  withLogin,
52
52
  loginLabel,
53
- passwordLabel
53
+ passwordLabel,
54
+ formHeader
54
55
  })
55
56
  ] }),
56
57
  children,
@@ -1,6 +1,6 @@
1
- import { FC } from 'react';
2
- import { Option } from '../../../Elements/Select/types';
3
- import { LoginData } from '../types';
1
+ import { type FC, type ReactNode } from 'react';
2
+ import { type Option } from '../../../Elements/Select/types';
3
+ import { type LoginData } from '../types';
4
4
  type Props = {
5
5
  onSubmit: (loginData: LoginData) => Promise<void>;
6
6
  isSubmitting?: boolean;
@@ -13,6 +13,7 @@ type Props = {
13
13
  loginLabel?: string;
14
14
  passwordLabel?: string;
15
15
  withLogin?: boolean;
16
+ formHeader?: ReactNode;
16
17
  };
17
18
  export declare const LoginForm: FC<Props>;
18
19
  export {};
@@ -16,7 +16,7 @@ const Container = styled$1.div`
16
16
  display: none;
17
17
  }
18
18
  @media (min-width: 1024px) {
19
- height: 300px;
19
+ min-height: 300px;
20
20
  min-width: 300px;
21
21
  margin-bottom: 50px;
22
22
  & > div > H4 {
@@ -33,7 +33,7 @@ const ButtonsContainer = styled$1.div`
33
33
  margin-top: 40px;
34
34
  }
35
35
  `;
36
- const LoginForm = ({ onSubmit, isSubmitting, isSubmitDisabled, distributionCenterOptions, withDistributionCenterSelect, onChangeDistributionCenter, selectedDistributionCenter, withPassword, withLogin, loginLabel, passwordLabel }) => {
36
+ const LoginForm = ({ onSubmit, isSubmitting, isSubmitDisabled, distributionCenterOptions, withDistributionCenterSelect, onChangeDistributionCenter, selectedDistributionCenter, withPassword, withLogin, loginLabel, passwordLabel, formHeader }) => {
37
37
  const [login, setLogin] = useState("");
38
38
  const [password, setPassword] = useState("");
39
39
  const [submitError, setSubmitError] = useState("");
@@ -76,7 +76,7 @@ const LoginForm = ({ onSubmit, isSubmitting, isSubmitDisabled, distributionCente
76
76
  login,
77
77
  password
78
78
  }).catch((error) => {
79
- error && setSubmitError(String(error));
79
+ error && setSubmitError(error instanceof Error ? error.message : String(error));
80
80
  }).finally(() => {
81
81
  setPassword("");
82
82
  });
@@ -92,6 +92,10 @@ const LoginForm = ({ onSubmit, isSubmitting, isSubmitDisabled, distributionCente
92
92
  onChangeDistributionCenter?.(e.target.value);
93
93
  }, [onChangeDistributionCenter]);
94
94
  return /* @__PURE__ */ jsxs(Container, { children: [
95
+ formHeader && /* @__PURE__ */ jsx(x.div, {
96
+ mt: "24px",
97
+ children: formHeader
98
+ }),
95
99
  withLogin && /* @__PURE__ */ jsx(x.div, {
96
100
  mt: "24px",
97
101
  children: /* @__PURE__ */ jsx(Input, {
@@ -31,4 +31,5 @@ export type LoginPageProps = {
31
31
  loginLabel?: string;
32
32
  passwordLabel?: string;
33
33
  admin?: boolean;
34
+ formHeader?: ReactNode;
34
35
  };