@mailstep/design-system 0.7.50-beta.4 → 0.7.50-beta.5

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.7.50-beta.4",
3
+ "version": "0.7.50-beta.5",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -9,7 +9,7 @@ import { Trans } from '@lingui/react';
9
9
  import { x } from '@xstyled/styled-components';
10
10
  import { Wrapper, MailTo, LanguageBox, LogoWrapper, MainLogo, Version, CardBodyWithLanguage } from './styles';
11
11
  var Login = function (_a) {
12
- var onSubmit = _a.onSubmit, activeLanguage = _a.activeLanguage, onLanguageChange = _a.onLanguageChange, children = _a.children, brand = _a.brand, brandVariant = _a.brandVariant, isSubmitting = _a.isSubmitting, isSubmitDisabled = _a.isSubmitDisabled, withDistributionCenterSelect = _a.withDistributionCenterSelect, distributionCenterOptions = _a.distributionCenterOptions, selectedDistributionCenter = _a.selectedDistributionCenter, onChangeDistributionCenter = _a.onChangeDistributionCenter, languageItems = _a.languageItems, version = _a.version, backgroundImage = _a.backgroundImage, backgroundColor = _a.backgroundColor, admin = _a.admin, _b = _a.hasSupport, hasSupport = _b === void 0 ? true : _b, _c = _a.hasSocialLinks, hasSocialLinks = _c === void 0 ? true : _c, _d = _a.withPassword, withPassword = _d === void 0 ? true : _d, loginLabel = _a.loginLabel;
13
- return (_jsxs(Wrapper, { backgroundImage: backgroundImage, backgroundColor: backgroundColor, children: [_jsxs(CardBodyWithLanguage, { children: [_jsxs(LogoWrapper, { children: [_jsx(MainLogo, { brand: brand, variant: brandVariant }), admin && _jsx(Admin, {})] }), _jsxs(LanguageBox, { children: [hasSupport && (_jsxs(x.div, { mr: 4, children: [_jsx(H6, { color: "gray1", variant: "bold", mt: "8px", mb: "8px", as: "h6", children: _jsx(Trans, { id: "form.heading.support", message: "Support:" }) }), _jsx(MailTo, { href: "mailto:mailstep@mailstep.cz", children: EMAIL_ADDRESS })] })), _jsx(LanguageSwitch, { activeLanguage: activeLanguage, onLanguageChange: onLanguageChange, languageItems: languageItems })] }), _jsx(LoginForm, { onSubmit: onSubmit, isSubmitDisabled: isSubmitDisabled, isSubmitting: isSubmitting, onChangeDistributionCenter: onChangeDistributionCenter, withDistributionCenterSelect: withDistributionCenterSelect, distributionCenterOptions: distributionCenterOptions, selectedDistributionCenter: selectedDistributionCenter, withPassword: withPassword, loginLabel: loginLabel })] }), children, version && _jsx(Version, { children: version }), hasSocialLinks && _jsx(SocialLinks, {})] }));
12
+ var onSubmit = _a.onSubmit, activeLanguage = _a.activeLanguage, onLanguageChange = _a.onLanguageChange, children = _a.children, brand = _a.brand, brandVariant = _a.brandVariant, isSubmitting = _a.isSubmitting, isSubmitDisabled = _a.isSubmitDisabled, withDistributionCenterSelect = _a.withDistributionCenterSelect, distributionCenterOptions = _a.distributionCenterOptions, selectedDistributionCenter = _a.selectedDistributionCenter, onChangeDistributionCenter = _a.onChangeDistributionCenter, languageItems = _a.languageItems, version = _a.version, backgroundImage = _a.backgroundImage, admin = _a.admin, _b = _a.hasSupport, hasSupport = _b === void 0 ? true : _b, _c = _a.hasSocialLinks, hasSocialLinks = _c === void 0 ? true : _c, _d = _a.withPassword, withPassword = _d === void 0 ? true : _d, _e = _a.withLogin, withLogin = _e === void 0 ? true : _e, loginLabel = _a.loginLabel;
13
+ return (_jsxs(Wrapper, { backgroundImage: backgroundImage, children: [_jsxs(CardBodyWithLanguage, { children: [_jsxs(LogoWrapper, { children: [_jsx(MainLogo, { brand: brand, variant: brandVariant }), admin && _jsx(Admin, {})] }), _jsxs(LanguageBox, { children: [hasSupport && (_jsxs(x.div, { mr: 4, children: [_jsx(H6, { color: "gray1", variant: "bold", mt: "8px", mb: "8px", as: "h6", children: _jsx(Trans, { id: "form.heading.support", message: "Support:" }) }), _jsx(MailTo, { href: "mailto:mailstep@mailstep.cz", children: EMAIL_ADDRESS })] })), _jsx(LanguageSwitch, { activeLanguage: activeLanguage, onLanguageChange: onLanguageChange, languageItems: languageItems })] }), _jsx(LoginForm, { onSubmit: onSubmit, isSubmitDisabled: isSubmitDisabled, isSubmitting: isSubmitting, onChangeDistributionCenter: onChangeDistributionCenter, withDistributionCenterSelect: withDistributionCenterSelect, distributionCenterOptions: distributionCenterOptions, selectedDistributionCenter: selectedDistributionCenter, withPassword: withPassword, withLogin: withLogin, loginLabel: loginLabel })] }), children, version && _jsx(Version, { children: version }), hasSocialLinks && _jsx(SocialLinks, {})] }));
14
14
  };
15
15
  export default Login;
@@ -11,6 +11,7 @@ type Props = {
11
11
  selectedDistributionCenter?: string;
12
12
  withPassword?: boolean;
13
13
  loginLabel?: string;
14
+ withLogin?: boolean;
14
15
  };
15
16
  export declare const LoginForm: FC<Props>;
16
17
  export {};
@@ -13,19 +13,20 @@ import styled, { x } from '@xstyled/styled-components';
13
13
  var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: block;\n width: 100%;\n box-sizing: border-box;\n margin-bottom: 10px;\n & > div > H4 {\n display: none;\n }\n @media (min-width: 1024px) {\n height: 300px;\n min-width: 300px;\n margin-bottom: 50px;\n & > div > H4 {\n display: block;\n }\n }\n"], ["\n display: block;\n width: 100%;\n box-sizing: border-box;\n margin-bottom: 10px;\n & > div > H4 {\n display: none;\n }\n @media (min-width: 1024px) {\n height: 300px;\n min-width: 300px;\n margin-bottom: 50px;\n & > div > H4 {\n display: block;\n }\n }\n"])));
14
14
  var ButtonsContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n margin-top: 15px;\n width: 100%;\n @media (min-width: 1024px) {\n display: inline-block;\n margin-top: 40px;\n }\n"], ["\n display: flex;\n margin-top: 15px;\n width: 100%;\n @media (min-width: 1024px) {\n display: inline-block;\n margin-top: 40px;\n }\n"])));
15
15
  export var LoginForm = function (_a) {
16
- var onSubmit = _a.onSubmit, isSubmitting = _a.isSubmitting, isSubmitDisabled = _a.isSubmitDisabled, distributionCenterOptions = _a.distributionCenterOptions, withDistributionCenterSelect = _a.withDistributionCenterSelect, onChangeDistributionCenter = _a.onChangeDistributionCenter, selectedDistributionCenter = _a.selectedDistributionCenter, withPassword = _a.withPassword, loginLabel = _a.loginLabel;
16
+ var onSubmit = _a.onSubmit, isSubmitting = _a.isSubmitting, isSubmitDisabled = _a.isSubmitDisabled, distributionCenterOptions = _a.distributionCenterOptions, withDistributionCenterSelect = _a.withDistributionCenterSelect, onChangeDistributionCenter = _a.onChangeDistributionCenter, selectedDistributionCenter = _a.selectedDistributionCenter, withPassword = _a.withPassword, withLogin = _a.withLogin, loginLabel = _a.loginLabel;
17
17
  var _b = useState(''), login = _b[0], setLogin = _b[1];
18
18
  var _c = useState(''), password = _c[0], setPassword = _c[1];
19
- var _d = useState(''), loginError = _d[0], setLoginError = _d[1];
20
- var _e = useState(''), passwordError = _e[0], setPasswordError = _e[1];
21
- var _f = useState(''), dcCenterError = _f[0], setDCCenterError = _f[1];
19
+ var _d = useState(''), submitError = _d[0], setSubmitError = _d[1];
20
+ var _e = useState(''), loginError = _e[0], setLoginError = _e[1];
21
+ var _f = useState(''), passwordError = _f[0], setPasswordError = _f[1];
22
+ var _g = useState(''), dcCenterError = _g[0], setDCCenterError = _g[1];
22
23
  var handleChangeLogin = useCallback(function (e) {
23
24
  setLogin(e.target.value);
24
25
  }, []);
25
26
  var handleChangePassword = useCallback(function (e) {
26
27
  setPassword(e.target.value);
27
28
  }, []);
28
- var handleSubmit = function () {
29
+ var handleSubmit = useCallback(function () {
29
30
  setLoginError('');
30
31
  setPasswordError('');
31
32
  setDCCenterError('');
@@ -41,18 +42,21 @@ export var LoginForm = function (_a) {
41
42
  setDCCenterError(i18n._({ id: 'requiredField', message: 'Required field' }));
42
43
  return;
43
44
  }
44
- onSubmit({
45
- login: login,
46
- password: password
47
- }).catch(console.error);
48
- };
45
+ onSubmit({ login: login, password: password })
46
+ .catch(function (error) {
47
+ error && setSubmitError(String(error));
48
+ })
49
+ .finally(function () {
50
+ setPassword('');
51
+ });
52
+ }, [login, password, selectedDistributionCenter, withDistributionCenterSelect, withPassword, onSubmit]);
49
53
  var handleChangeDistributionCenter = useCallback(function (e) {
50
54
  onChangeDistributionCenter === null || onChangeDistributionCenter === void 0 ? void 0 : onChangeDistributionCenter(e.target.value);
51
55
  }, [onChangeDistributionCenter]);
52
- return (_jsxs(Container, { children: [_jsx(x.div, { mt: "24px", children: _jsx(Input, { label: loginLabel || i18n._({ id: 'form.login.label', message: 'Login' }), placeholder: i18n._({ id: 'form.login.label', message: 'Login' }), type: "text", name: "login", autoFocus: true, error: loginError, value: login, onChange: handleChangeLogin, onEnter: handleSubmit }) }), withPassword && (_jsx(x.div, { mt: "12px", children: _jsx(Input, { label: i18n._({ id: 'form.password.label', message: 'Password' }), placeholder: i18n._({ id: 'form.password.label', message: 'Password' }), name: "password", type: "password", value: password, onChange: handleChangePassword, error: passwordError, onEnter: handleSubmit }) })), withDistributionCenterSelect && (_jsx(x.div, { mt: "12px", children: _jsx(SingleSelect
56
+ return (_jsxs(Container, { children: [withLogin && (_jsx(x.div, { mt: "24px", children: _jsx(Input, { label: loginLabel || i18n._({ id: 'form.login.label', message: 'Login' }), placeholder: i18n._({ id: 'form.login.label', message: 'Login' }), type: "text", name: "login", autoFocus: true, error: loginError, value: login, onChange: handleChangeLogin, onEnter: handleSubmit }) })), withPassword && (_jsx(x.div, { mt: "12px", children: _jsx(Input, { label: i18n._({ id: 'form.password.label', message: 'Password' }), placeholder: i18n._({ id: 'form.password.label', message: 'Password' }), name: "password", type: "password", value: password, onChange: handleChangePassword, error: passwordError, onEnter: handleSubmit }) })), withDistributionCenterSelect && (_jsx(x.div, { mt: "12px", children: _jsx(SingleSelect
53
57
  // @ts-ignore
54
58
  , {
55
59
  // @ts-ignore
56
- onChange: handleChangeDistributionCenter, options: distributionCenterOptions, value: selectedDistributionCenter, placeholder: i18n._({ id: 'form.distributionCenter.label', message: 'Distribution center' }), label: i18n._({ id: 'form.distributionCenter.label', message: 'Distribution center' }), error: dcCenterError }) })), _jsx(ButtonsContainer, { children: _jsx(Button, { onClick: handleSubmit, iconLeft: "login", isLoading: isSubmitting, disabled: isSubmitDisabled, fullWidth: true, children: _jsx(Trans, { id: "form.buttonSignIn", message: "Sign in" }) }) })] }));
60
+ onChange: handleChangeDistributionCenter, options: distributionCenterOptions, value: selectedDistributionCenter, placeholder: i18n._({ id: 'form.distributionCenter.label', message: 'Distribution center' }), label: i18n._({ id: 'form.distributionCenter.label', message: 'Distribution center' }), error: dcCenterError }) })), submitError && (_jsx(x.div, { mt: "12px", color: "red1", children: submitError })), _jsx(ButtonsContainer, { children: _jsx(Button, { onClick: handleSubmit, iconLeft: "login", isLoading: isSubmitting, disabled: isSubmitDisabled, fullWidth: true, children: _jsx(Trans, { id: "form.buttonSignIn", message: "Sign in" }) }) })] }));
57
61
  };
58
62
  var templateObject_1, templateObject_2;
@@ -1,7 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export declare const Wrapper: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
3
3
  backgroundImage?: "mailship" | undefined;
4
- backgroundColor?: string | undefined;
5
4
  }, never>;
6
5
  export declare const LanguageBox: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
7
6
  export declare const CardBodyWithLanguage: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
@@ -8,12 +8,9 @@ import styled, { th } from '@xstyled/styled-components';
8
8
  var backgroundImageMap = {
9
9
  mailship: mailship
10
10
  };
11
- export var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100vh;\n font-family: ", ";\n flex-grow: 1;\n background: ", ";\n opacity: 1;\n z-index: 1;\n display: flex;\n justify-content: space-between;\n @media (min-width: 1024px) {\n background: ", "\n background-size: cover;\n }\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100vh;\n font-family: ", ";\n flex-grow: 1;\n background: ", ";\n opacity: 1;\n z-index: 1;\n display: flex;\n justify-content: space-between;\n @media (min-width: 1024px) {\n background: ", "\n background-size: cover;\n }\n"])), th('fonts.primary'), function (_a) {
12
- var backgroundColor = _a.backgroundColor;
13
- return backgroundColor || th('colors.bgLightGray');
14
- }, function (_a) {
15
- var backgroundImage = _a.backgroundImage, backgroundColor = _a.backgroundColor;
16
- return "".concat(backgroundColor ? backgroundColor : 'transparent', " ").concat(backgroundImage ? "url(".concat(backgroundImageMap[backgroundImage], ")") : '', " 50% 0% no-repeat padding-box;");
11
+ export var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100vh;\n font-family: ", ";\n flex-grow: 1;\n background: ", ";\n opacity: 1;\n z-index: 1;\n display: flex;\n justify-content: space-between;\n @media (min-width: 1024px) {\n background: ", "\n background-size: cover;\n }\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100vh;\n font-family: ", ";\n flex-grow: 1;\n background: ", ";\n opacity: 1;\n z-index: 1;\n display: flex;\n justify-content: space-between;\n @media (min-width: 1024px) {\n background: ", "\n background-size: cover;\n }\n"])), th('fonts.primary'), th('colors.bgLightGray'), function (_a) {
12
+ var backgroundImage = _a.backgroundImage;
13
+ return "transparent ".concat(backgroundImage ? "url(".concat(backgroundImageMap[backgroundImage], ")") : '', " 50% 0% no-repeat padding-box;");
17
14
  });
18
15
  export var LanguageBox = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n margin: 15px 0;\n align-items: flex-end;\n justify-content: space-between;\n @media (min-width: 1024px) {\n justify-content: flex-end;\n margin: 40px 0;\n }\n"], ["\n display: flex;\n margin: 15px 0;\n align-items: flex-end;\n justify-content: space-between;\n @media (min-width: 1024px) {\n justify-content: flex-end;\n margin: 40px 0;\n }\n"])));
19
16
  export var CardBodyWithLanguage = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n justify-content: start;\n flex-direction: column;\n padding: 0 32px 10px 32px;\n flex-grow: 1;\n margin: auto;\n width: 500px;\n @media (min-width: 1024px) {\n display: block;\n flex-grow: 0;\n }\n"], ["\n display: flex;\n justify-content: start;\n flex-direction: column;\n padding: 0 32px 10px 32px;\n flex-grow: 1;\n margin: auto;\n width: 500px;\n @media (min-width: 1024px) {\n display: block;\n flex-grow: 0;\n }\n"])));
@@ -23,11 +23,11 @@ export type LoginPageProps = {
23
23
  languageItems?: LanguageItem[];
24
24
  version?: string;
25
25
  backgroundImage?: BackgroundImages;
26
- backgroundColor?: string;
27
26
  icon?: string;
28
27
  hasSupport?: boolean;
29
28
  hasSocialLinks?: boolean;
30
29
  withPassword?: boolean;
30
+ withLogin?: boolean;
31
31
  loginLabel?: string;
32
32
  admin?: boolean;
33
33
  };