@mailstep/design-system 0.6.67 → 0.6.69-beta.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": "@mailstep/design-system",
3
- "version": "0.6.67",
3
+ "version": "0.6.69-beta.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -1,3 +1,3 @@
1
1
  import { type FC } from 'react';
2
- import { StepperProps } from './types';
2
+ import type { StepperProps } from './types';
3
3
  export declare const Stepper: FC<StepperProps>;
@@ -3,18 +3,18 @@ import { useEffect, useMemo } from 'react';
3
3
  import { StepItem } from './components/StepItem';
4
4
  import { Container, ItemsWrapper } from './styles';
5
5
  export var Stepper = function (_a) {
6
- var items = _a.items, activeStep = _a.activeStep, handleChangeStep = _a.handleChangeStep, handleGoToNextStep = _a.handleGoToNextStep, isLoading = _a.isLoading;
7
- if (!(items === null || items === void 0 ? void 0 : items.length))
8
- return null;
6
+ var items = _a.items, activeStep = _a.activeStep, hasStepNumbering = _a.hasStepNumbering, handleChangeStep = _a.handleChangeStep, handleGoToNextStep = _a.handleGoToNextStep, isLoading = _a.isLoading;
9
7
  var Component = useMemo(function () { return items[activeStep].component; }, [items, activeStep]);
10
8
  useEffect(function () {
11
9
  var _a;
12
10
  if (!!activeStep && !((_a = items[activeStep - 1]) === null || _a === void 0 ? void 0 : _a.completed)) {
13
- handleChangeStep(0)();
11
+ handleChangeStep === null || handleChangeStep === void 0 ? void 0 : handleChangeStep(0)();
14
12
  }
15
13
  }, [items]);
16
- return (_jsxs(Container, { children: [_jsx(ItemsWrapper, { children: items.map(function (_a, index) {
17
- var title = _a.title, disabled = _a.disabled, completed = _a.completed;
18
- return (_jsx(StepItem, { onClick: handleChangeStep(index), title: title, index: index, activeStep: activeStep, disabled: disabled, completed: completed }, title));
19
- }) }), _jsx(Component, { handleGoToNextStep: handleGoToNextStep, isLoading: isLoading })] }));
14
+ if (!(items === null || items === void 0 ? void 0 : items.length))
15
+ return null;
16
+ return (_jsxs(Container, { children: [_jsx(ItemsWrapper, { total: items.length, children: items.map(function (_a, index) {
17
+ var title = _a.title, disabled = _a.disabled, completed = _a.completed, icon = _a.icon;
18
+ return (_jsx(StepItem, { onClick: handleChangeStep === null || handleChangeStep === void 0 ? void 0 : handleChangeStep(index), title: title, index: index, total: items.length, activeStep: activeStep, disabled: disabled, completed: completed, hasStepNumbering: hasStepNumbering, icon: icon }, title));
19
+ }) }), Component && _jsx(Component, { handleGoToNextStep: handleGoToNextStep, isLoading: isLoading })] }));
20
20
  };
@@ -0,0 +1,9 @@
1
+ import { type FC } from 'react';
2
+ type Props = {
3
+ icon?: string;
4
+ isCompleted?: boolean;
5
+ children?: React.ReactNode;
6
+ isActiveStep?: boolean;
7
+ };
8
+ export declare const StepCircle: FC<Props>;
9
+ export {};
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Icon from '../../../../Elements/Icon';
3
+ import { StepCircleContainer } from './styles';
4
+ export var StepCircle = function (_a) {
5
+ var icon = _a.icon, isCompleted = _a.isCompleted, children = _a.children, isActiveStep = _a.isActiveStep;
6
+ return (_jsx(StepCircleContainer, { isCompleted: isCompleted, isActiveStep: isActiveStep, children: icon ? _jsx(Icon, { icon: icon, size: "12px", fill: isCompleted || isActiveStep ? 'red1' : 'lightGray6' }) : children }));
7
+ };
@@ -0,0 +1,4 @@
1
+ export declare const StepCircleContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
2
+ isCompleted?: boolean | undefined;
3
+ isActiveStep?: boolean | undefined;
4
+ }, never>;
@@ -0,0 +1,19 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ import styled, { css, th } from '@xstyled/styled-components';
6
+ export var StepCircleContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n font-size: 16px;\n font-weight: 600;\n border-radius: 50%;\n color: ", ";\n border: ", ";\n border-color: ", ";\n background: white;\n height: 36px;\n width: 36px;\n display: flex;\n flex: 0 0 36px;\n justify-content: center;\n align-items: center;\n\n ", "\n"], ["\n font-size: 16px;\n font-weight: 600;\n border-radius: 50%;\n color: ", ";\n border: ", ";\n border-color: ", ";\n background: white;\n height: 36px;\n width: 36px;\n display: flex;\n flex: 0 0 36px;\n justify-content: center;\n align-items: center;\n\n ", "\n"])), function (_a) {
7
+ var isActiveStep = _a.isActiveStep;
8
+ return (isActiveStep ? th.color('red1') : th.color('lightGray6'));
9
+ }, function (_a) {
10
+ var isCompleted = _a.isCompleted;
11
+ return "".concat(isCompleted ? 8 : 2, "px solid");
12
+ }, function (_a) {
13
+ var isCompleted = _a.isCompleted, isActiveStep = _a.isActiveStep;
14
+ return th.color(isActiveStep || isCompleted ? 'red1' : 'lightGray6');
15
+ }, function (_a) {
16
+ var isActiveStep = _a.isActiveStep;
17
+ return isActiveStep && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-shadow: 0 0 0 4px ", ";\n "], ["\n box-shadow: 0 0 0 4px ", ";\n "])), th.color('red20'));
18
+ });
19
+ var templateObject_1, templateObject_2;
@@ -1,11 +1,14 @@
1
1
  import { type FC } from 'react';
2
2
  type StepItemProps = {
3
- onClick: () => void;
3
+ onClick?: () => void;
4
4
  title: string;
5
5
  index: number;
6
6
  activeStep: number;
7
7
  disabled?: boolean;
8
8
  completed?: boolean;
9
+ icon?: string;
10
+ hasStepNumbering?: boolean;
11
+ total: number;
9
12
  };
10
13
  export declare const StepItem: FC<StepItemProps>;
11
14
  export {};
@@ -1,13 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Paragraph2, H7 } from '../../../../Elements/Typography/Typography';
3
- import { CheckedCircle } from '../CheckedCircle';
3
+ import { StepCircle } from '../StepCircle';
4
4
  import { Trans } from '@lingui/react';
5
5
  import { x } from '@xstyled/styled-components';
6
6
  import isBoolean from 'lodash/isBoolean';
7
- import { Line, StepItemContainer, StepNumber, ContentWrapper } from './styles';
7
+ import { Line, StepItemContainer, ContentWrapper } from './styles';
8
8
  export var StepItem = function (_a) {
9
- var title = _a.title, index = _a.index, disabled = _a.disabled, activeStep = _a.activeStep, completed = _a.completed, onClick = _a.onClick;
9
+ var title = _a.title, index = _a.index, disabled = _a.disabled, activeStep = _a.activeStep, completed = _a.completed, icon = _a.icon, _b = _a.hasStepNumbering, hasStepNumbering = _b === void 0 ? true : _b, total = _a.total, onClick = _a.onClick;
10
10
  var isActiveStep = index === activeStep;
11
11
  var isCompletedStep = isBoolean(completed) ? completed : index < activeStep;
12
- return (_jsxs(StepItemContainer, { onClick: !disabled && isCompletedStep ? onClick : undefined, isActiveStep: isActiveStep, isDisabled: disabled, children: [_jsx(Line, { isActiveStep: isActiveStep, isCompletedStep: isCompletedStep }), _jsxs(ContentWrapper, { children: [isCompletedStep ? _jsx(CheckedCircle, {}) : _jsx(StepNumber, { isActiveStep: isActiveStep, children: index + 1 }), _jsxs("div", { children: [_jsx(x.span, { textTransform: "uppercase", children: _jsxs(H7, { color: "gray1", variant: "semiBold", mt: 0, mb: "4px", children: [_jsx(Trans, { id: "step", message: "Step" }), ": ", index + 1] }) }), _jsx(Paragraph2, { variant: "medium", children: title })] })] })] }));
12
+ return (_jsxs(StepItemContainer, { onClick: !disabled && isCompletedStep ? onClick : undefined, isActiveStep: isActiveStep, isDisabled: disabled, total: total, children: [_jsx(Line, { isActiveStep: isActiveStep, isCompletedStep: isCompletedStep }), _jsxs(ContentWrapper, { children: [_jsx(StepCircle, { icon: isCompletedStep ? 'check' : icon, isCompleted: isCompletedStep, isActiveStep: isActiveStep, children: index + 1 }), _jsxs("div", { children: [hasStepNumbering && (_jsx(x.span, { textTransform: "uppercase", children: _jsxs(H7, { color: "gray1", variant: "semiBold", mt: 0, mb: "4px", children: [_jsx(Trans, { id: "step", message: "Step" }), ": ", index + 1] }) })), _jsx(Paragraph2, { variant: "medium", children: title })] })] })] }));
13
13
  };
@@ -1,12 +1,11 @@
1
1
  export declare const StepItemContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
2
2
  isActiveStep: boolean;
3
3
  isDisabled?: boolean | undefined;
4
+ total: number;
5
+ onClick?: (() => void) | undefined;
4
6
  }, never>;
5
7
  export declare const Line: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
6
8
  isActiveStep: boolean;
7
9
  isCompletedStep: boolean;
8
10
  }, never>;
9
- export declare const StepNumber: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
10
- isActiveStep: boolean;
11
- }, never>;
12
11
  export declare const ContentWrapper: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
@@ -2,15 +2,26 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
2
2
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
3
  return cooked;
4
4
  };
5
+ import { StepCircleContainer } from '../StepCircle/styles';
5
6
  import styled, { css, th } from '@xstyled/styled-components';
6
- export var StepItemContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: 10px;\n width: 240px;\n padding: 24px;\n background-color: ", ";\n cursor: ", ";\n"], ["\n border-radius: 10px;\n width: 240px;\n padding: 24px;\n background-color: ", ";\n cursor: ", ";\n"])), function (_a) {
7
+ var responsiveCss = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n\n h6 {\n font-size: 10px;\n }\n\n p {\n font-size: 12px;\n }\n\n ", " {\n display: flex;\n }\n\n @media (min-width: ", "px) {\n width: 150px;\n\n ", " {\n display: none;\n }\n }\n\n @media (min-width: ", "px) {\n width: 200px;\n\n ", " {\n display: flex;\n }\n }\n\n @media (min-width: ", "px) {\n width: 240px;\n\n p {\n font-size: 16px;\n }\n h6 {\n font-size: 12px;\n }\n\n ", " {\n display: flex;\n }\n }\n"], ["\n width: 100%;\n\n h6 {\n font-size: 10px;\n }\n\n p {\n font-size: 12px;\n }\n\n ", " {\n display: flex;\n }\n\n @media (min-width: ", "px) {\n width: 150px;\n\n ", " {\n display: none;\n }\n }\n\n @media (min-width: ", "px) {\n width: 200px;\n\n ", " {\n display: flex;\n }\n }\n\n @media (min-width: ", "px) {\n width: 240px;\n\n p {\n font-size: 16px;\n }\n h6 {\n font-size: 12px;\n }\n\n ", " {\n display: flex;\n }\n }\n"])), StepCircleContainer, function (_a) {
8
+ var total = _a.total;
9
+ return total * 150;
10
+ }, StepCircleContainer, function (_a) {
11
+ var total = _a.total;
12
+ return total * 200;
13
+ }, StepCircleContainer, function (_a) {
14
+ var total = _a.total;
15
+ return total * 240;
16
+ }, StepCircleContainer);
17
+ export var StepItemContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-radius: 10px;\n width: 240px;\n padding: 24px;\n background-color: ", ";\n cursor: ", ";\n ", "\n"], ["\n border-radius: 10px;\n width: 240px;\n padding: 24px;\n background-color: ", ";\n cursor: ", ";\n ", "\n"])), function (_a) {
7
18
  var isActiveStep = _a.isActiveStep;
8
19
  return (isActiveStep ? th.color('bgLightGray1') : 'transparent');
9
20
  }, function (_a) {
10
- var isDisabled = _a.isDisabled;
11
- return (isDisabled ? 'not-allowed' : 'pointer');
12
- });
13
- export var Line = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 4px;\n border-radius: 8px;\n width: 100%;\n background-color: ", ";\n margin-bottom: 16px;\n"], ["\n height: 4px;\n border-radius: 8px;\n width: 100%;\n background-color: ", ";\n margin-bottom: 16px;\n"])), function (_a) {
21
+ var isDisabled = _a.isDisabled, onClick = _a.onClick;
22
+ return (isDisabled ? 'not-allowed' : onClick ? 'pointer' : 'auto');
23
+ }, responsiveCss);
24
+ export var Line = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: 4px;\n border-radius: 8px;\n width: 100%;\n background-color: ", ";\n margin-bottom: 16px;\n"], ["\n height: 4px;\n border-radius: 8px;\n width: 100%;\n background-color: ", ";\n margin-bottom: 16px;\n"])), function (_a) {
14
25
  var isActiveStep = _a.isActiveStep, isCompletedStep = _a.isCompletedStep;
15
26
  if (isActiveStep)
16
27
  return th.color('red1');
@@ -18,15 +29,5 @@ export var Line = styled.div(templateObject_2 || (templateObject_2 = __makeTempl
18
29
  return th.color('red20');
19
30
  return th.color('lightGray7');
20
31
  });
21
- export var StepNumber = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: 16px;\n font-weight: 600;\n margin-bottom: 16px;\n color: ", ";\n border: 2px solid ", ";\n border-radius: 50%;\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n\n ", "\n"], ["\n font-size: 16px;\n font-weight: 600;\n margin-bottom: 16px;\n color: ", ";\n border: 2px solid ", ";\n border-radius: 50%;\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n\n ", "\n"])), function (_a) {
22
- var isActiveStep = _a.isActiveStep;
23
- return (isActiveStep ? th.color('red1') : th.color('lightGray6'));
24
- }, function (_a) {
25
- var isActiveStep = _a.isActiveStep;
26
- return (isActiveStep ? th.color('red1') : th.color('lightGray6'));
27
- }, function (_a) {
28
- var isActiveStep = _a.isActiveStep;
29
- return isActiveStep && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n box-shadow: 0 0 0 4px ", ";\n "], ["\n box-shadow: 0 0 0 4px ", ";\n "])), th.color('red20'));
30
- });
31
- export var ContentWrapper = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n column-gap: 16px;\n"], ["\n display: flex;\n column-gap: 16px;\n"])));
32
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
32
+ export var ContentWrapper = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n column-gap: 16px;\n align-items: center;\n"], ["\n display: flex;\n column-gap: 16px;\n align-items: center;\n"])));
33
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -1,4 +1,4 @@
1
1
  export { Stepper as default } from './Stepper';
2
2
  export { useStepper } from './hooks/useStepper';
3
- export { CheckedCircle } from './components/CheckedCircle';
3
+ export { StepCircle } from './components/StepCircle';
4
4
  export type { StepperItem, StepperPassedDownProps } from './types';
@@ -1,3 +1,3 @@
1
1
  export { Stepper as default } from './Stepper';
2
2
  export { useStepper } from './hooks/useStepper';
3
- export { CheckedCircle } from './components/CheckedCircle';
3
+ export { StepCircle } from './components/StepCircle';
@@ -1,7 +1,9 @@
1
+ import { type FC } from 'react';
1
2
  declare const meta: {
2
3
  title: string;
3
4
  tags: string[];
4
5
  };
5
6
  export default meta;
6
- export declare const Default: () => import("react/jsx-runtime").JSX.Element;
7
- export declare const AllStepsCompleted: () => import("react/jsx-runtime").JSX.Element;
7
+ export declare const Default: FC;
8
+ export declare const WithIcons: FC;
9
+ export declare const AllStepsCompleted: FC;
@@ -44,6 +44,29 @@ var items = [
44
44
  }
45
45
  }
46
46
  ];
47
+ var iconItems = [
48
+ {
49
+ title: 'Order created',
50
+ icon: 'peopleCarry',
51
+ completed: true
52
+ },
53
+ {
54
+ title: 'Processed in stock',
55
+ icon: 'boxRamp'
56
+ },
57
+ {
58
+ title: 'Log Processed in stock',
59
+ icon: 'flatBox'
60
+ },
61
+ {
62
+ title: 'PPL parcelshop',
63
+ icon: 'truck'
64
+ },
65
+ {
66
+ title: 'Delivered',
67
+ icon: 'circleCheck'
68
+ }
69
+ ];
47
70
  var completedItems = items.map(function (item) { return (__assign(__assign({}, item), { completed: true })); });
48
71
  var meta = {
49
72
  title: 'Blocks/Stepper',
@@ -54,6 +77,9 @@ export var Default = function () {
54
77
  var _a = useStepper({ totalSteps: items.length }), activeStep = _a.activeStep, handleChangeStep = _a.handleChangeStep, handleGoToNextStep = _a.handleGoToNextStep;
55
78
  return (_jsx(LinguiContainer, { children: _jsx(Stepper, { items: items, activeStep: activeStep, handleChangeStep: handleChangeStep, handleGoToNextStep: handleGoToNextStep }) }));
56
79
  };
80
+ export var WithIcons = function () {
81
+ return (_jsx(LinguiContainer, { children: _jsx(Stepper, { items: iconItems, activeStep: 1, hasStepNumbering: false }) }));
82
+ };
57
83
  export var AllStepsCompleted = function () {
58
84
  var _a = useStepper({ totalSteps: completedItems.length }), activeStep = _a.activeStep, handleChangeStep = _a.handleChangeStep, handleGoToNextStep = _a.handleGoToNextStep;
59
85
  return (_jsx(LinguiContainer, { children: _jsx(Stepper, { items: completedItems, activeStep: activeStep, handleChangeStep: handleChangeStep, handleGoToNextStep: handleGoToNextStep }) }));
@@ -1,2 +1,4 @@
1
1
  export declare const Container: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
2
- export declare const ItemsWrapper: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
2
+ export declare const ItemsWrapper: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
3
+ total: number;
4
+ }, never>;
@@ -3,6 +3,9 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
3
3
  return cooked;
4
4
  };
5
5
  import styled from '@xstyled/styled-components';
6
- export var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n height: fit-content;\n justify-content: center;\n align-items: center;\n width: 100%;\n"], ["\n display: flex;\n flex-direction: column;\n height: fit-content;\n justify-content: center;\n align-items: center;\n width: 100%;\n"])));
7
- export var ItemsWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n margin-bottom: 36px;\n"], ["\n display: flex;\n margin-bottom: 36px;\n"])));
6
+ export var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n height: fit-content;\n justify-content: center;\n align-items: center;\n width: 100%;\n flex-direction: column;\n"], ["\n display: flex;\n flex-direction: column;\n height: fit-content;\n justify-content: center;\n align-items: center;\n width: 100%;\n flex-direction: column;\n"])));
7
+ export var ItemsWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n margin-bottom: 36px;\n flex-direction: column;\n width: 100%;\n\n @media (min-width: ", "px) {\n flex-direction: row;\n width: auto;\n }\n"], ["\n display: flex;\n margin-bottom: 36px;\n flex-direction: column;\n width: 100%;\n\n @media (min-width: ", "px) {\n flex-direction: row;\n width: auto;\n }\n"])), function (_a) {
8
+ var total = _a.total;
9
+ return total * 150;
10
+ });
8
11
  var templateObject_1, templateObject_2;
@@ -1,18 +1,20 @@
1
- import { FC } from 'react';
1
+ import type { FC } from 'react';
2
2
  export type StepperProps = {
3
3
  items: StepperItem[];
4
4
  activeStep: number;
5
- handleChangeStep: (step: number) => () => void;
6
- handleGoToNextStep: () => void;
5
+ handleChangeStep?: (step: number) => () => void;
6
+ handleGoToNextStep?: () => void;
7
7
  isLoading?: boolean;
8
+ hasStepNumbering?: boolean;
8
9
  };
9
10
  export type StepperPassedDownProps = {
10
- handleGoToNextStep: () => void;
11
+ handleGoToNextStep?: () => void;
11
12
  isLoading?: boolean;
12
13
  };
13
14
  export type StepperItem = {
14
15
  title: string;
16
+ icon?: string;
15
17
  completed?: boolean;
16
18
  disabled?: boolean;
17
- component: FC<StepperPassedDownProps>;
19
+ component?: FC<StepperPassedDownProps>;
18
20
  };
@@ -4,19 +4,9 @@ export var Portal = function (_a) {
4
4
  var children = _a.children;
5
5
  var container = useState(function () { return document.createElement('div'); })[0];
6
6
  useEffect(function () {
7
- try {
8
- document.body.appendChild(container);
9
- }
10
- catch (e) {
11
- console.log(e);
12
- }
7
+ document.body.appendChild(container);
13
8
  return function () {
14
- try {
15
- document.body.removeChild(container);
16
- }
17
- catch (e) {
18
- console.log(e);
19
- }
9
+ document.body.removeChild(container);
20
10
  };
21
11
  }, []);
22
12
  return ReactDom.createPortal(children, container);