@mailstep/design-system 0.7.58-beta.0 → 0.7.59-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.7.58-beta.0",
3
+ "version": "0.7.59-beta.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
2
  import { ColumnTitleComponentType } from '../../types';
3
- type Props = React.ComponentProps<ColumnTitleComponentType>;
4
- declare const ColumnTitle: ({ title, isSortable, onSetSort, sortValue }: Props) => JSX.Element | null;
3
+ declare const ColumnTitle: React.FC<ColumnTitleComponentType>;
5
4
  export default ColumnTitle;
@@ -4,8 +4,8 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
4
4
  };
5
5
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  import { useState, useCallback, useRef, useEffect } from 'react';
7
- import styled, { x, css } from '@xstyled/styled-components';
8
7
  import Icon from '../../../../Elements/Icon/Icon';
8
+ import styled, { x, css } from '@xstyled/styled-components';
9
9
  // ArrowWrap and WarningWrap need to have the same size to solve resizing issues
10
10
  var WRAPPER_WIDTH = 35;
11
11
  var Wrap = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n font-size: 0.8rem;\n"], ["\n width: 100%;\n font-size: 0.8rem;\n"])));
@@ -31,8 +31,8 @@ var ColumnTitle = function (_a) {
31
31
  var onSetAsc = useCallback(function () { return onSetSort === null || onSetSort === void 0 ? void 0 : onSetSort('asc'); }, [onSetSort]);
32
32
  var onSetDesc = useCallback(function () { return onSetSort === null || onSetSort === void 0 ? void 0 : onSetSort('desc'); }, [onSetSort]);
33
33
  var onSetNull = useCallback(function () { return onSetSort === null || onSetSort === void 0 ? void 0 : onSetSort(null); }, [onSetSort]);
34
- var isAsc = sortValue == 'asc';
35
- var isDesc = sortValue == 'desc';
34
+ var isAsc = sortValue === 'asc';
35
+ var isDesc = sortValue === 'desc';
36
36
  var wrapRef = useRef(null);
37
37
  var contentRef = useRef(null);
38
38
  useEffect(function () {
@@ -1,9 +1,4 @@
1
1
  import React from 'react';
2
- import { SortingValueType } from '../types';
3
- declare const _default: React.NamedExoticComponent<{
4
- title?: string | JSX.Element | undefined;
5
- isSortable: boolean;
6
- onSetSort?: ((value: SortingValueType) => void) | undefined;
7
- sortValue: SortingValueType;
8
- }>;
2
+ import type { ColumnTitleComponentType } from '../types';
3
+ declare const _default: React.NamedExoticComponent<ColumnTitleComponentType>;
9
4
  export default _default;
@@ -4,17 +4,26 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
4
4
  };
5
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  import React from 'react';
7
- import styled from '@xstyled/styled-components';
8
7
  import { SortingUp, SortingDown } from './icons/Sorting';
8
+ import styled from '@xstyled/styled-components';
9
9
  var Title = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n & + * {\n margin-left: 1em;\n }\n"], ["\n & + * {\n margin-left: 1em;\n }\n"])));
10
10
  var ColumnTitle = function (_a) {
11
11
  var title = _a.title, isSortable = _a.isSortable, onSetSort = _a.onSetSort, sortValue = _a.sortValue;
12
- var handleClick = React.useCallback(function () {
13
- var newValue = sortValue ? (sortValue == 'asc' ? 'desc' : null) : 'asc';
14
- if (onSetSort)
15
- onSetSort(newValue);
16
- }, [sortValue, onSetSort]);
17
- return (_jsxs("div", { onClick: isSortable ? handleClick : undefined, className: isSortable ? 'sortable' : '', children: [_jsx(Title, { children: title }), isSortable && sortValue === 'asc' && _jsx(SortingUp, { width: "16" }), isSortable && sortValue === 'desc' && _jsx(SortingDown, { width: "16" })] }));
12
+ var _b = React.useState(0), mouseDownTimestamp = _b[0], setMouseDownTimestamp = _b[1];
13
+ var handleMouseDown = React.useCallback(function () {
14
+ setMouseDownTimestamp(Date.now());
15
+ }, []);
16
+ var handleMouseUp = React.useCallback(function () {
17
+ var now = Date.now();
18
+ var duration = now - mouseDownTimestamp;
19
+ if (duration < 200) {
20
+ var newValue = sortValue ? (sortValue === 'asc' ? 'desc' : null) : 'asc';
21
+ if (onSetSort)
22
+ onSetSort(newValue);
23
+ }
24
+ setMouseDownTimestamp(0);
25
+ }, [mouseDownTimestamp, onSetSort, sortValue]);
26
+ return (_jsxs("div", { onMouseDown: isSortable ? handleMouseDown : undefined, onMouseUp: isSortable ? handleMouseUp : undefined, className: isSortable ? 'sortable' : '', children: [_jsx(Title, { children: title }), isSortable && sortValue === 'asc' && _jsx(SortingUp, { width: "16" }), isSortable && sortValue === 'desc' && _jsx(SortingDown, { width: "16" })] }));
18
27
  };
19
28
  export default React.memo(ColumnTitle);
20
29
  var templateObject_1;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ReduxGrid, createRandomData } from '../utils/utils';
2
+ import { LinguiContainer } from '../../../../utils/LinguiContainer';
3
3
  import { onRowEditClick, onRowReadClick, onRowAction } from '../utils/actions';
4
4
  import { columnDefinitions } from '../utils/columnDefinition';
5
+ import { ReduxGrid, createRandomData } from '../utils/utils';
5
6
  import withRedux from '../utils/withRedux';
6
- import { LinguiContainer } from '../../../../utils/LinguiContainer';
7
7
  export var ActionColumnCheckboxes = {
8
8
  flexBasis: 160,
9
9
  forceCheckboxes: true
@@ -43,19 +43,19 @@ export type FilterComponentProps<VT> = {
43
43
  value: VT | null;
44
44
  OverlayComponent?: React.FunctionComponent;
45
45
  } & Record<string, any>;
46
- export type ColumnTitleComponentType = React.ComponentType<{
46
+ export type ColumnTitleComponentType = {
47
47
  title?: string | JSX.Element;
48
48
  isSortable: boolean;
49
49
  onSetSort?: (value: SortingValueType) => void;
50
50
  sortValue: SortingValueType;
51
- }>;
51
+ };
52
52
  export type ComponentsProps = {
53
53
  Translator: React.ComponentType<any>;
54
54
  Checkbox: React.ComponentType<CheckboxPublicInterfaceProps>;
55
55
  Button: React.ComponentType<ButtonPublicInterfaceProps>;
56
56
  Switch: React.ComponentType<SwitchPublicInterfaceProps>;
57
57
  Paginator: React.ComponentType<PaginatorProps>;
58
- ColumnTitle?: ColumnTitleComponentType;
58
+ ColumnTitle?: React.ComponentType<ColumnTitleComponentType>;
59
59
  };
60
60
  export type CustomComparators = {
61
61
  [name: string]: Comparator[];
@@ -1,3 +1,3 @@
1
- import { TabContentProps } from './types';
2
- import { ReactElement } from 'react';
1
+ import type { ReactElement } from 'react';
2
+ import type { TabContentProps } from './types';
3
3
  export declare const TabContent: ({ activeTab, value, children }: TabContentProps) => ReactElement | null;
@@ -1,2 +1,2 @@
1
- import { TabsProps } from './types';
2
- export declare const Tabs: ({ tabsDefinition, activeTab, onTabSwitch, mb, mt }: TabsProps) => JSX.Element;
1
+ import type { TabsProps } from './types';
2
+ export declare const Tabs: ({ tabsDefinition, activeTab, onTabSwitch, mb, mt, minTabWidth }: TabsProps) => JSX.Element;
@@ -1,19 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
- import { RoundedWrap, StyledImageBox, Tab as StyledTab, StyledTabWrapper, TabPanel } from './styles';
4
- import { Text } from '../../Elements/Text';
5
3
  import { Icon } from '../../Elements/Icon';
4
+ import { Text } from '../../Elements/Text';
5
+ import { RoundedWrap, StyledImageBox, Tab as StyledTab, StyledTabWrapper, TabPanel } from './styles';
6
6
  var Tab = function (_a) {
7
- var tabDefinition = _a.tabDefinition, value = _a.value, isActive = _a.isActive, onTabSwitch = _a.onTabSwitch;
7
+ var tabDefinition = _a.tabDefinition, value = _a.value, isActive = _a.isActive, onTabSwitch = _a.onTabSwitch, minWidth = _a.minWidth;
8
8
  var icon = tabDefinition.icon, label = tabDefinition.label, badgeCount = tabDefinition.badgeCount, disabled = tabDefinition.disabled;
9
9
  var handleOnClick = useCallback(function () {
10
10
  onTabSwitch(value);
11
11
  }, [onTabSwitch, value]);
12
- return (_jsx(StyledTabWrapper, { children: _jsxs(StyledTab, { onClick: !disabled ? handleOnClick : undefined, active: isActive, disabled: disabled, children: [icon && (_jsx(StyledImageBox, { children: _jsx(Icon, { icon: icon }) })), _jsx(Text, { children: label }), badgeCount === 0 || (badgeCount && badgeCount > 0) && (_jsx(RoundedWrap, { children: _jsx(Text, { variant: "medium", children: badgeCount }) }))] }) }));
12
+ return (_jsx(StyledTabWrapper, { children: _jsxs(StyledTab, { onClick: !disabled ? handleOnClick : undefined, active: isActive, disabled: disabled, minWidth: minWidth, children: [icon && (_jsx(StyledImageBox, { children: _jsx(Icon, { icon: icon }) })), _jsx(Text, { children: label }), badgeCount === 0 ||
13
+ (badgeCount && badgeCount > 0 && (_jsx(RoundedWrap, { children: _jsx(Text, { variant: "medium", children: badgeCount }) })))] }) }));
13
14
  };
14
15
  export var Tabs = function (_a) {
15
- var tabsDefinition = _a.tabsDefinition, activeTab = _a.activeTab, onTabSwitch = _a.onTabSwitch, mb = _a.mb, mt = _a.mt;
16
+ var tabsDefinition = _a.tabsDefinition, activeTab = _a.activeTab, onTabSwitch = _a.onTabSwitch, mb = _a.mb, mt = _a.mt, minTabWidth = _a.minTabWidth;
16
17
  return (_jsx(TabPanel, { "$mb": mb, "$mt": mt, children: tabsDefinition.map(function (item, index) {
17
- return _jsx(Tab, { value: index, tabDefinition: item, isActive: index === activeTab, onTabSwitch: onTabSwitch }, index);
18
+ return (_jsx(Tab, { value: index, tabDefinition: item, isActive: index === activeTab, minWidth: minTabWidth, onTabSwitch: onTabSwitch }, index));
18
19
  }) }));
19
20
  };
@@ -2,7 +2,7 @@
2
2
  import { StoryObj } from '@storybook/react';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: ({ tabsDefinition, activeTab, onTabSwitch, mb, mt }: import("../types").TabsProps) => JSX.Element;
5
+ component: ({ tabsDefinition, activeTab, onTabSwitch, mb, mt, minTabWidth }: import("../types").TabsProps) => JSX.Element;
6
6
  tags: string[];
7
7
  argTypes: {};
8
8
  };
@@ -5,6 +5,7 @@ export declare const RoundedWrap: import("styled-components").StyledComponent<"d
5
5
  export declare const Tab: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
6
6
  active: boolean;
7
7
  disabled?: boolean | undefined;
8
+ minWidth?: string | string[] | undefined;
8
9
  }, never>;
9
10
  export declare const TabPanel: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
10
11
  $mb?: string | undefined;
@@ -7,10 +7,13 @@ export var StyledImageBox = styled(x.div)(templateObject_1 || (templateObject_1
7
7
  export var StyledTabWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n align-items: center;\n position: relative;\n"], ["\n display: flex;\n flex-direction: row;\n align-items: center;\n position: relative;\n"])));
8
8
  export var RoundedWrap = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex !important;\n justify-content: center;\n align-items: center;\n height: 23px;\n background-color: ", ";\n border-radius: 29px;\n padding: 3px 10px;\n margin-left: 8px;\n"], ["\n display: flex !important;\n justify-content: center;\n align-items: center;\n height: 23px;\n background-color: ", ";\n border-radius: 29px;\n padding: 3px 10px;\n margin-left: 8px;\n"])), th.color('lightGray7'));
9
9
  var activeTab = css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n color: ", ";\n\n &:after {\n content: '';\n position: absolute;\n bottom: 2;\n left: 0;\n right: 0;\n background-color: ", ";\n height: 4px;\n border-radius: 6px 6px 0px 0px;\n }\n & > div {\n display: inline;\n color: ", ";\n }\n"], ["\n color: ", ";\n\n &:after {\n content: '';\n position: absolute;\n bottom: 2;\n left: 0;\n right: 0;\n background-color: ", ";\n height: 4px;\n border-radius: 6px 6px 0px 0px;\n }\n & > div {\n display: inline;\n color: ", ";\n }\n"])), th.color('red1'), th.color('red1'), th.color('typoPrimary'));
10
- export var Tab = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: ", ";\n padding: 0 8px 12px;\n transition: 200ms;\n color: ", ";\n font-weight: bold;\n font-size: 14px;\n letter-spacing: 0.03em;\n min-width: 100px;\n\n & > div {\n display: none;\n }\n &:not(:last-child) {\n margin-right: 0.5rem;\n }\n\n :hover {\n color: ", ";\n }\n\n :active {\n ", ";\n }\n\n ", ";\n\n @media (min-width: 400px) {\n min-width: 120px;\n }\n"], ["\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: ", ";\n padding: 0 8px 12px;\n transition: 200ms;\n color: ", ";\n font-weight: bold;\n font-size: 14px;\n letter-spacing: 0.03em;\n min-width: 100px;\n\n & > div {\n display: none;\n }\n &:not(:last-child) {\n margin-right: 0.5rem;\n }\n\n :hover {\n color: ", ";\n }\n\n :active {\n ", ";\n }\n\n ", ";\n\n @media (min-width: 400px) {\n min-width: 120px;\n }\n"])), function (_a) {
10
+ export var Tab = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: ", ";\n padding: 0 12px 12px;\n transition: 200ms;\n color: ", ";\n font-weight: bold;\n font-size: 14px;\n letter-spacing: 0.03em;\n min-width: ", ";\n\n & > div {\n display: none;\n }\n &:not(:last-child) {\n margin-right: 0.5rem;\n }\n\n :hover {\n color: ", ";\n }\n\n :active {\n ", ";\n }\n\n ", ";\n\n @media (min-width: 400px) {\n min-width: ", ";\n }\n"], ["\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: ", ";\n padding: 0 12px 12px;\n transition: 200ms;\n color: ", ";\n font-weight: bold;\n font-size: 14px;\n letter-spacing: 0.03em;\n min-width: ", ";\n\n & > div {\n display: none;\n }\n &:not(:last-child) {\n margin-right: 0.5rem;\n }\n\n :hover {\n color: ", ";\n }\n\n :active {\n ", ";\n }\n\n ", ";\n\n @media (min-width: 400px) {\n min-width: ", ";\n }\n"])), function (_a) {
11
11
  var disabled = _a.disabled;
12
12
  return (disabled ? 'auto' : 'pointer');
13
13
  }, th.color('gray'), function (_a) {
14
+ var minWidth = _a.minWidth;
15
+ return minWidth ? (Array.isArray(minWidth) ? minWidth[0] : minWidth) : '100px';
16
+ }, function (_a) {
14
17
  var disabled = _a.disabled;
15
18
  return th.color(disabled ? 'gray' : 'typoPrimary');
16
19
  }, function (_a) {
@@ -19,6 +22,9 @@ export var Tab = styled.div(templateObject_5 || (templateObject_5 = __makeTempla
19
22
  }, function (_a) {
20
23
  var active = _a.active;
21
24
  return (active ? activeTab : '');
25
+ }, function (_a) {
26
+ var minWidth = _a.minWidth;
27
+ return minWidth ? (Array.isArray(minWidth) ? minWidth[1] : minWidth) : '120px';
22
28
  });
23
29
  export var TabPanel = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n overflow: auto;\n width: fit-content;\n position: relative;\n margin-bottom: ", ";\n margin-top: ", ";\n align-items: stretch;\n\n &:after {\n content: '';\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: ", ";\n height: 2px;\n }\n"], ["\n display: flex;\n align-items: center;\n overflow: auto;\n width: fit-content;\n position: relative;\n margin-bottom: ", ";\n margin-top: ", ";\n align-items: stretch;\n\n &:after {\n content: '';\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: ", ";\n height: 2px;\n }\n"])), function (_a) {
24
30
  var _b = _a.$mb, $mb = _b === void 0 ? 0 : _b;
@@ -12,12 +12,14 @@ export type TabsProps = {
12
12
  onTabSwitch: (tab: number) => void;
13
13
  mb?: string;
14
14
  mt?: string;
15
+ minTabWidth?: string | string[];
15
16
  };
16
17
  export type TabElementProps = {
17
18
  tabDefinition: TabDefinition;
18
19
  value: number;
19
20
  isActive: boolean;
20
21
  onTabSwitch: (tab: number) => void;
22
+ minWidth?: string | string[];
21
23
  };
22
24
  export type UseTabsHook = (tabDefinitions: TabDefinition[]) => {
23
25
  activeTab: number;
@@ -1,7 +1,2 @@
1
1
  import { type FC } from 'react';
2
- type CheckedCircleProps = {
3
- checked?: boolean;
4
- color?: string;
5
- };
6
- export declare const CheckedCircle: FC<CheckedCircleProps>;
7
- export {};
2
+ export declare const CheckedCircle: FC;
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Icon from '../Icon';
3
3
  import { CheckedCircleContainer } from './styles';
4
- export var CheckedCircle = function (_a) {
5
- var _b = _a.checked, checked = _b === void 0 ? true : _b, _c = _a.color, color = _c === void 0 ? 'red1' : _c;
6
- return _jsx(CheckedCircleContainer, { color: color, children: checked && _jsx(Icon, { icon: "check", size: "12px" }) });
4
+ export var CheckedCircle = function () {
5
+ return (_jsx(CheckedCircleContainer, { children: _jsx(Icon, { icon: "check", size: "12px" }) }));
7
6
  };
@@ -2,16 +2,10 @@
2
2
  import type { StoryObj } from '@storybook/react';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: import("react").FC<{
6
- checked?: boolean | undefined;
7
- color?: string | undefined;
8
- }>;
5
+ component: import("react").FC;
9
6
  tags: string[];
10
7
  argTypes: {};
11
8
  };
12
9
  export default meta;
13
10
  type Story = StoryObj<typeof meta>;
14
11
  export declare const Default: Story;
15
- export declare const Checked: Story;
16
- export declare const CheckedGreen: Story;
17
- export declare const Unchecked: Story;
@@ -9,19 +9,3 @@ export default meta;
9
9
  export var Default = {
10
10
  args: {}
11
11
  };
12
- export var Checked = {
13
- args: {
14
- checked: true
15
- }
16
- };
17
- export var CheckedGreen = {
18
- args: {
19
- checked: true,
20
- color: 'green60'
21
- }
22
- };
23
- export var Unchecked = {
24
- args: {
25
- checked: false
26
- }
27
- };
@@ -1,3 +1 @@
1
- export declare const CheckedCircleContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
2
- color: string;
3
- }, never>;
1
+ export declare const CheckedCircleContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
@@ -3,11 +3,5 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
3
3
  return cooked;
4
4
  };
5
5
  import styled, { th } from '@xstyled/styled-components';
6
- export var CheckedCircleContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: 50%;\n border: 8px solid ", ";\n color: ", ";\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: white;\n"], ["\n border-radius: 50%;\n border: 8px solid ", ";\n color: ", ";\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: white;\n"])), function (_a) {
7
- var color = _a.color;
8
- return th.color(color);
9
- }, function (_a) {
10
- var color = _a.color;
11
- return th.color(color);
12
- });
6
+ export var CheckedCircleContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: 50%;\n border: 8px solid ", ";\n color: ", ";\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: white;\n"], ["\n border-radius: 50%;\n border: 8px solid ", ";\n color: ", ";\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: white;\n"])), th.color('red1'), th.color('red1'));
13
7
  var templateObject_1;