@mailstep/design-system 0.7.57 → 0.7.58

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.57",
3
+ "version": "0.7.58",
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[];