@mailstep/design-system 0.4.21 → 0.5.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.
Files changed (109) hide show
  1. package/package.json +17 -4
  2. package/ui/Blocks/CommonGrid/CommonGrid.d.ts +3 -0
  3. package/ui/Blocks/CommonGrid/CommonGrid.js +115 -0
  4. package/ui/Blocks/CommonGrid/CommonGridContext.d.ts +12 -0
  5. package/ui/Blocks/CommonGrid/CommonGridContext.js +45 -0
  6. package/ui/Blocks/CommonGrid/HoC/withReduxActions.d.ts +2 -0
  7. package/ui/Blocks/CommonGrid/HoC/withReduxActions.js +36 -0
  8. package/ui/Blocks/CommonGrid/components/ActionColumnHead.d.ts +4 -0
  9. package/ui/Blocks/CommonGrid/components/ActionColumnHead.js +16 -0
  10. package/ui/Blocks/CommonGrid/components/ButtonStrip.d.ts +7 -0
  11. package/ui/Blocks/CommonGrid/components/ButtonStrip.js +35 -0
  12. package/ui/Blocks/CommonGrid/components/ColumnFilterCell.d.ts +11 -0
  13. package/ui/Blocks/CommonGrid/components/ColumnFilterCell.js +41 -0
  14. package/ui/Blocks/CommonGrid/components/ColumnTitle.d.ts +9 -0
  15. package/ui/Blocks/CommonGrid/components/ColumnTitle.js +20 -0
  16. package/ui/Blocks/CommonGrid/components/ConfigForm.d.ts +9 -0
  17. package/ui/Blocks/CommonGrid/components/ConfigForm.js +58 -0
  18. package/ui/Blocks/CommonGrid/components/DataCell.d.ts +11 -0
  19. package/ui/Blocks/CommonGrid/components/DataCell.js +52 -0
  20. package/ui/Blocks/CommonGrid/components/DataRow.d.ts +21 -0
  21. package/ui/Blocks/CommonGrid/components/DataRow.js +110 -0
  22. package/ui/Blocks/CommonGrid/components/DefaultPaginator.d.ts +3 -0
  23. package/ui/Blocks/CommonGrid/components/DefaultPaginator.js +11 -0
  24. package/ui/Blocks/CommonGrid/components/Dialog.d.ts +11 -0
  25. package/ui/Blocks/CommonGrid/components/Dialog.js +19 -0
  26. package/ui/Blocks/CommonGrid/components/DropdownMenu.d.ts +21 -0
  27. package/ui/Blocks/CommonGrid/components/DropdownMenu.js +59 -0
  28. package/ui/Blocks/CommonGrid/components/DropdownSelect.d.ts +15 -0
  29. package/ui/Blocks/CommonGrid/components/DropdownSelect.js +35 -0
  30. package/ui/Blocks/CommonGrid/components/FilterDropdown.d.ts +3 -0
  31. package/ui/Blocks/CommonGrid/components/FilterDropdown.js +36 -0
  32. package/ui/Blocks/CommonGrid/components/FilterRow.d.ts +15 -0
  33. package/ui/Blocks/CommonGrid/components/FilterRow.js +35 -0
  34. package/ui/Blocks/CommonGrid/components/FloatingButton.d.ts +6 -0
  35. package/ui/Blocks/CommonGrid/components/FloatingButton.js +13 -0
  36. package/ui/Blocks/CommonGrid/components/GroupRow.d.ts +9 -0
  37. package/ui/Blocks/CommonGrid/components/GroupRow.js +27 -0
  38. package/ui/Blocks/CommonGrid/components/HeadCell.d.ts +27 -0
  39. package/ui/Blocks/CommonGrid/components/HeadCell.js +43 -0
  40. package/ui/Blocks/CommonGrid/components/HeadRow.d.ts +15 -0
  41. package/ui/Blocks/CommonGrid/components/HeadRow.js +69 -0
  42. package/ui/Blocks/CommonGrid/components/OversizedScroll.d.ts +11 -0
  43. package/ui/Blocks/CommonGrid/components/OversizedScroll.js +24 -0
  44. package/ui/Blocks/CommonGrid/components/Resize.d.ts +7 -0
  45. package/ui/Blocks/CommonGrid/components/Resize.js +33 -0
  46. package/ui/Blocks/CommonGrid/components/Table.d.ts +16 -0
  47. package/ui/Blocks/CommonGrid/components/Table.js +30 -0
  48. package/ui/Blocks/CommonGrid/components/icons/ArrowSimple.d.ts +2 -0
  49. package/ui/Blocks/CommonGrid/components/icons/ArrowSimple.js +14 -0
  50. package/ui/Blocks/CommonGrid/components/icons/Edit.d.ts +2 -0
  51. package/ui/Blocks/CommonGrid/components/icons/Edit.js +14 -0
  52. package/ui/Blocks/CommonGrid/components/icons/EyeOpen.d.ts +2 -0
  53. package/ui/Blocks/CommonGrid/components/icons/EyeOpen.js +14 -0
  54. package/ui/Blocks/CommonGrid/components/icons/Sorting.d.ts +2 -0
  55. package/ui/Blocks/CommonGrid/components/icons/Sorting.js +14 -0
  56. package/ui/Blocks/CommonGrid/components/utils.d.ts +8 -0
  57. package/ui/Blocks/CommonGrid/components/utils.js +22 -0
  58. package/ui/Blocks/CommonGrid/hooks/useColumnSizes.d.ts +12 -0
  59. package/ui/Blocks/CommonGrid/hooks/useColumnSizes.js +83 -0
  60. package/ui/Blocks/CommonGrid/hooks/useControlButtons.d.ts +10 -0
  61. package/ui/Blocks/CommonGrid/hooks/useControlButtons.js +64 -0
  62. package/ui/Blocks/CommonGrid/hooks/useRowsKeyControls.d.ts +4 -0
  63. package/ui/Blocks/CommonGrid/hooks/useRowsKeyControls.js +21 -0
  64. package/ui/Blocks/CommonGrid/hooks/useUxReset.d.ts +3 -0
  65. package/ui/Blocks/CommonGrid/hooks/useUxReset.js +15 -0
  66. package/ui/Blocks/CommonGrid/index.d.ts +7 -0
  67. package/ui/Blocks/CommonGrid/index.js +7 -0
  68. package/ui/Blocks/CommonGrid/store/index.d.ts +58 -0
  69. package/ui/Blocks/CommonGrid/store/index.js +230 -0
  70. package/ui/Blocks/CommonGrid/store/migrateState.d.ts +3 -0
  71. package/ui/Blocks/CommonGrid/store/migrateState.js +14 -0
  72. package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.d.ts +11 -0
  73. package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +31 -0
  74. package/ui/Blocks/CommonGrid/storybook/stories/customControllButtons.stories.d.ts +13 -0
  75. package/ui/Blocks/CommonGrid/storybook/stories/customControllButtons.stories.js +49 -0
  76. package/ui/Blocks/CommonGrid/storybook/stories/default.stories.d.ts +6 -0
  77. package/ui/Blocks/CommonGrid/storybook/stories/default.stories.js +14 -0
  78. package/ui/Blocks/CommonGrid/storybook/stories/loading.stories.d.ts +10 -0
  79. package/ui/Blocks/CommonGrid/storybook/stories/loading.stories.js +11 -0
  80. package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNoScrollLayout.stories.d.ts +10 -0
  81. package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNoScrollLayout.stories.js +12 -0
  82. package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNormalLayout.stories.d.ts +10 -0
  83. package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNormalLayout.stories.js +12 -0
  84. package/ui/Blocks/CommonGrid/storybook/stories/styledCommonGrid.stories.d.ts +6 -0
  85. package/ui/Blocks/CommonGrid/storybook/stories/styledCommonGrid.stories.js +15 -0
  86. package/ui/Blocks/CommonGrid/storybook/stories/withCustomGridActions.stories.d.ts +10 -0
  87. package/ui/Blocks/CommonGrid/storybook/stories/withCustomGridActions.stories.js +15 -0
  88. package/ui/Blocks/CommonGrid/storybook/stories/withForcedCheckboxes.stories.d.ts +14 -0
  89. package/ui/Blocks/CommonGrid/storybook/stories/withForcedCheckboxes.stories.js +24 -0
  90. package/ui/Blocks/CommonGrid/storybook/utils/actions.d.ts +4 -0
  91. package/ui/Blocks/CommonGrid/storybook/utils/actions.js +6 -0
  92. package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.d.ts +10 -0
  93. package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +97 -0
  94. package/ui/Blocks/CommonGrid/storybook/utils/filters.d.ts +2 -0
  95. package/ui/Blocks/CommonGrid/storybook/utils/filters.js +23 -0
  96. package/ui/Blocks/CommonGrid/storybook/utils/utils.d.ts +17 -0
  97. package/ui/Blocks/CommonGrid/storybook/utils/utils.js +66 -0
  98. package/ui/Blocks/CommonGrid/storybook/utils/withRedux.d.ts +2 -0
  99. package/ui/Blocks/CommonGrid/storybook/utils/withRedux.js +12 -0
  100. package/ui/Blocks/CommonGrid/storybook/utils/withRouter.d.ts +2 -0
  101. package/ui/Blocks/CommonGrid/storybook/utils/withRouter.js +4 -0
  102. package/ui/Blocks/CommonGrid/storybook/utils/withTheme.d.ts +2 -0
  103. package/ui/Blocks/CommonGrid/storybook/utils/withTheme.js +18 -0
  104. package/ui/Blocks/CommonGrid/types.d.ts +299 -0
  105. package/ui/Blocks/CommonGrid/types.js +8 -0
  106. package/ui/Blocks/CommonGrid/utils/index.d.ts +17 -0
  107. package/ui/Blocks/CommonGrid/utils/index.js +60 -0
  108. package/ui/Blocks/CommonGrid/utils/public.d.ts +16 -0
  109. package/ui/Blocks/CommonGrid/utils/public.js +52 -0
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { CommonGridProps } from '../types';
3
+ type OversizedScrollProps = {
4
+ columnLayout: Required<CommonGridProps>['columnLayout'];
5
+ isLoading?: boolean;
6
+ children: React.ReactNode;
7
+ floatingChildren?: React.ReactNode;
8
+ totalColumnsWidth: number;
9
+ };
10
+ declare const forwardedWrapper: React.ForwardRefExoticComponent<OversizedScrollProps & React.RefAttributes<any>>;
11
+ export default forwardedWrapper;
@@ -0,0 +1,24 @@
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ import React from 'react';
7
+ import styled, { css } from '@xstyled/styled-components';
8
+ var ScrollWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", ";\n\n min-height: ", ";\n"], ["\n ", ";\n\n min-height: ", ";\n"])), function (props) {
9
+ return props.columnLayout != 'no-scroll' && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n overflow-x: ", ";\n position: relative;\n @media (min-width: 1024px) {\n overflow-x: auto;\n }\n "], ["\n overflow-x: ", ";\n position: relative;\n @media (min-width: 1024px) {\n overflow-x: auto;\n }\n "])), props.columnLayout == 'sticky' ? 'inherit' : 'auto');
10
+ }, function (props) { return (props.columnLayout == 'normal' ? '360px' : '0'); });
11
+ var ScrollSizer = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), function (props) {
12
+ return props.columnLayout != 'no-scroll' && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: ", "px;\n "], ["\n width: ", "px;\n "])), props.totalColumnsWidth);
13
+ });
14
+ var FloatPosition = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n position: sticky;\n left: 0;\n"], ["\n position: sticky;\n left: 0;\n"])));
15
+ var OversizedScroll = function (_a, ref) {
16
+ var columnLayout = _a.columnLayout, isLoading = _a.isLoading, children = _a.children, floatingChildren = _a.floatingChildren, totalColumnsWidth = _a.totalColumnsWidth;
17
+ return (
18
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19
+ // @ts-ignore
20
+ _jsxs(ScrollWrapper, { columnLayout: columnLayout, isLoading: isLoading, className: "gridWrapper", ref: ref, children: [_jsx(ScrollSizer, { columnLayout: columnLayout, totalColumnsWidth: totalColumnsWidth, children: children }), floatingChildren && _jsx(FloatPosition, { children: floatingChildren })] }));
21
+ };
22
+ var forwardedWrapper = React.forwardRef(OversizedScroll);
23
+ export default forwardedWrapper;
24
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -0,0 +1,7 @@
1
+ interface Resize {
2
+ onResize: (width: number) => void;
3
+ onResizeOver: () => void;
4
+ onResizeOut: () => void;
5
+ }
6
+ declare const Resize: ({ onResize, onResizeOver, onResizeOut }: Resize) => JSX.Element;
7
+ export default Resize;
@@ -0,0 +1,33 @@
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 { jsx as _jsx } from "react/jsx-runtime";
6
+ import { useCallback } from 'react';
7
+ import styled from '@xstyled/styled-components';
8
+ var Resizer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: 100%;\n width: 7px;\n cursor: col-resize;\n position: absolute;\n z-index: 2;\n right: 0px;\n top: 0px;\n border-left: 1px dotted;\n border-right: 1px dotted;\n border-left-color: primary;\n border-right-color: primary;\n opacity: 0;\n transition: opacity 0.6s;\n &:hover {\n opacity: 1;\n }\n"], ["\n height: 100%;\n width: 7px;\n cursor: col-resize;\n position: absolute;\n z-index: 2;\n right: 0px;\n top: 0px;\n border-left: 1px dotted;\n border-right: 1px dotted;\n border-left-color: primary;\n border-right-color: primary;\n opacity: 0;\n transition: opacity 0.6s;\n &:hover {\n opacity: 1;\n }\n"])));
9
+ var Resize = function (_a) {
10
+ var onResize = _a.onResize, onResizeOver = _a.onResizeOver, onResizeOut = _a.onResizeOut;
11
+ var handleMouseDown = useCallback(function (downEvent) {
12
+ if ((downEvent === null || downEvent === void 0 ? void 0 : downEvent.button) !== 0) {
13
+ return;
14
+ }
15
+ var initialPosX = downEvent === null || downEvent === void 0 ? void 0 : downEvent.pageX;
16
+ var handleMouseMove = function (moveEvent) {
17
+ onResize(moveEvent.pageX - initialPosX);
18
+ };
19
+ var handleMouseUp = function (upEvent) {
20
+ document.removeEventListener('mousemove', handleMouseMove);
21
+ document.removeEventListener('mouseup', handleMouseUp);
22
+ upEvent.stopPropagation();
23
+ upEvent.preventDefault();
24
+ };
25
+ document.addEventListener('mousemove', handleMouseMove);
26
+ document.addEventListener('mouseup', handleMouseUp);
27
+ downEvent.stopPropagation();
28
+ downEvent.preventDefault();
29
+ }, [onResize]);
30
+ return _jsx(Resizer, { className: "resizer", onMouseDown: handleMouseDown, onMouseOver: onResizeOver, onMouseOut: onResizeOut });
31
+ };
32
+ export default Resize;
33
+ var templateObject_1;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ type TableProps = {
3
+ children: React.ReactNode;
4
+ };
5
+ export declare const Body: ({ children }: TableProps) => JSX.Element;
6
+ export declare const StyledRow: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
7
+ hasRowClick: boolean;
8
+ }, never>;
9
+ export declare const Row: (props: any) => JSX.Element;
10
+ export declare const StyledDataRow: import("styled-components").StyledComponent<(props: any) => JSX.Element, import("@xstyled/system").Theme, {
11
+ isEven: boolean;
12
+ }, never>;
13
+ export declare const Cell: (props: any) => JSX.Element;
14
+ export declare const TextCell: import("styled-components").StyledComponent<(props: any) => JSX.Element, import("@xstyled/system").Theme, {}, never>;
15
+ export declare const MessageCell: import("styled-components").StyledComponent<(props: any) => JSX.Element, import("@xstyled/system").Theme, {}, never>;
16
+ export {};
@@ -0,0 +1,30 @@
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
+ var __assign = (this && this.__assign) || function () {
6
+ __assign = Object.assign || function(t) {
7
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
8
+ s = arguments[i];
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
+ t[p] = s[p];
11
+ }
12
+ return t;
13
+ };
14
+ return __assign.apply(this, arguments);
15
+ };
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ // @ts-ignore
18
+ import styled, { system, th } from '@xstyled/styled-components';
19
+ export var Body = function (_a) {
20
+ var children = _a.children;
21
+ return _jsx("div", { children: children });
22
+ };
23
+ export var StyledRow = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n display: flex;\n min-height: 32px;\n border-bottom: 1px solid rgb(228, 231, 235);\n cursor: ", ";\n"], ["\n ", ";\n display: flex;\n min-height: 32px;\n border-bottom: 1px solid rgb(228, 231, 235);\n cursor: ", ";\n"])), system, function (props) { return (props.hasRowClick ? 'pointer' : 'cursor'); });
24
+ export var Row = function (props) { return _jsx(StyledRow, __assign({ ref: props.innerRef }, props)); };
25
+ var StyledCell = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", ";\n display: flex;\n overflow: hidden;\n align-items: center;\n justify-content: ", ";\n"], ["\n ", ";\n display: flex;\n overflow: hidden;\n align-items: center;\n justify-content: ", ";\n"])), system, function (props) { return props.align; });
26
+ export var StyledDataRow = styled(Row)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n"], ["\n background-color: ", ";\n"])), function (props) { return (props.isEven ? th('colors.bgLightGray') : 'white'); });
27
+ export var Cell = function (props) { return _jsx(StyledCell, __assign({ ref: props.innerRef }, props)); };
28
+ export var TextCell = styled(Cell)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n text-overflow: ellipsis;\n white-space: nowrap;\n"], ["\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
29
+ export var MessageCell = styled(Cell)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 100%;\n"], ["\n width: 100%;\n"])));
30
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -0,0 +1,2 @@
1
+ declare const SvgArrowSimple: (props: any) => JSX.Element;
2
+ export default SvgArrowSimple;
@@ -0,0 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ var SvgArrowSimple = function (props) { return (_jsx("svg", __assign({ width: "1em", height: "1em", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", className: "arrow-simple_svg__menu-toggle-icon" }, props, { children: _jsx("path", { d: "M9 18l6-6-6-6", fill: "none" }) }))); };
14
+ export default SvgArrowSimple;
@@ -0,0 +1,2 @@
1
+ declare const Edit: (props: any) => JSX.Element;
2
+ export default Edit;
@@ -0,0 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ var Edit = function (props) { return (_jsx("svg", __assign({ "data-icon": "edit", viewBox: "0 0 16 16" }, props, { children: _jsx("path", { d: "M3.25 10.26l2.47 2.47 6.69-6.69-2.46-2.48-6.7 6.7zM.99 14.99l3.86-1.39-2.46-2.44-1.4 3.83zm12.25-14c-.48 0-.92.2-1.24.51l-1.44 1.44 2.47 2.47 1.44-1.44c.32-.32.51-.75.51-1.24.01-.95-.77-1.74-1.74-1.74z", fillRule: "evenodd" }) }))); };
14
+ export default Edit;
@@ -0,0 +1,2 @@
1
+ declare const EyeOpen: (props: any) => JSX.Element;
2
+ export default EyeOpen;
@@ -0,0 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ var EyeOpen = function (props) { return (_jsx("svg", __assign({ "data-icon": "eye-open", viewBox: "0 0 16 16" }, props, { children: _jsx("path", { d: "M8.002 7.003a1.003 1.003 0 000 2.005 1.003 1.003 0 000-2.005zm7.988.972v-.02-.01-.02-.02a.675.675 0 00-.17-.36c-.509-.673-1.118-1.264-1.737-1.806-1.328-1.173-2.846-2.155-4.523-2.546a6.702 6.702 0 00-2.925-.06c-.889.18-1.738.541-2.546.992C2.84 4.837 1.692 5.81.694 6.902c-.18.211-.36.411-.53.632a.742.742 0 000 .932c.51.672 1.119 1.264 1.738 1.805 1.328 1.173 2.846 2.156 4.523 2.547.968.23 1.947.24 2.925.04.889-.18 1.738-.542 2.546-.993 1.248-.712 2.397-1.684 3.395-2.777.18-.2.37-.411.54-.632.09-.1.149-.23.169-.36v-.02-.02-.01-.02-.03c0-.01-.01-.01-.01-.02zm-7.988 3.038a2.998 2.998 0 01-2.995-3.008 2.998 2.998 0 012.995-3.008 2.998 2.998 0 012.996 3.008 2.998 2.998 0 01-2.996 3.008z", fillRule: "evenodd" }) }))); };
14
+ export default EyeOpen;
@@ -0,0 +1,2 @@
1
+ export declare const SortingUp: (props: any) => JSX.Element;
2
+ export declare const SortingDown: (props: any) => JSX.Element;
@@ -0,0 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ export var SortingUp = function (props) { return (_jsx("svg", __assign({ viewBox: "0 0 16 16" }, props, { children: _jsx("path", { d: "M12.71 9.29l-4-4C8.53 5.11 8.28 5 8 5s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L8 7.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z", fillRule: "evenodd" }) }))); };
14
+ export var SortingDown = function (props) { return (_jsx("svg", __assign({ viewBox: "0 0 16 16" }, props, { children: _jsx("path", { d: "M12 5c-.28 0-.53.11-.71.29L8 8.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0012 5z", fillRule: "evenodd" }) }))); };
@@ -0,0 +1,8 @@
1
+ type Props = {
2
+ handleRowClick: (e: MouseEvent) => void;
3
+ };
4
+ export declare const useTimeMeasurement: ({ handleRowClick }: Props) => {
5
+ handleMouseDown: () => void;
6
+ handleMouseUp: (e: MouseEvent) => void;
7
+ };
8
+ export {};
@@ -0,0 +1,22 @@
1
+ import { useState } from 'react';
2
+ export var useTimeMeasurement = function (_a) {
3
+ var handleRowClick = _a.handleRowClick;
4
+ var _b = useState(0), startTime = _b[0], setStartTime = _b[1];
5
+ var handleMouseDown = function () {
6
+ // Set the start time when mouse is pressed
7
+ var start = Date.now();
8
+ setStartTime(start);
9
+ };
10
+ var handleMouseUp = function (e) {
11
+ if (startTime !== 0) {
12
+ // Calculate the time difference between mouse down and up
13
+ var endTime = Date.now();
14
+ var duration = endTime - startTime;
15
+ if (duration > 0 && duration < 200) {
16
+ handleRowClick(e);
17
+ }
18
+ setStartTime(0);
19
+ }
20
+ };
21
+ return { handleMouseDown: handleMouseDown, handleMouseUp: handleMouseUp };
22
+ };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { CommonGridProps, GridActionsType, GridSelectorsType } from '../types';
3
+ type ReturnProps = {
4
+ displayColumnsWidth: {
5
+ [anyColumn: string]: number;
6
+ };
7
+ totalColumnsWidth: number;
8
+ gridBoxRef: React.MutableRefObject<HTMLElement>;
9
+ handleResizeDrag: (column: string, width: number) => void;
10
+ };
11
+ declare const useColumnSizes: (displayColumnsDefinitions: CommonGridProps['columnsDefinitions'], storeColumnsWidth: Required<GridSelectorsType>['columnsWidth'], storeColumnsWidthVariant: GridSelectorsType['columnsWidthVariant'], setColumnWidth: Required<GridActionsType>['setColumnWidth'], columnLayout: Required<CommonGridProps>['columnLayout'], minColumnWidth?: number) => ReturnProps;
12
+ export default useColumnSizes;
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import sum from 'lodash/sum';
3
+ var useColumnSizes = function (displayColumnsDefinitions, storeColumnsWidth, storeColumnsWidthVariant, setColumnWidth, columnLayout, minColumnWidth) {
4
+ /**
5
+ * decorate grid resize with layout and reset grid widths if layout changes
6
+ */
7
+ if (minColumnWidth === void 0) { minColumnWidth = 50; }
8
+ var handleSetColumnWidth = React.useCallback(function (columnWidth) { return setColumnWidth(columnWidth, columnLayout); }, [columnLayout, setColumnWidth]);
9
+ React.useEffect(function () {
10
+ if (storeColumnsWidthVariant != columnLayout)
11
+ handleSetColumnWidth(null);
12
+ }, [columnLayout, storeColumnsWidthVariant, handleSetColumnWidth]);
13
+ /**
14
+ * base width of each displayed column and of all displayed columns put together
15
+ */
16
+ var displayColumnsWidth = React.useMemo(function () {
17
+ var displayColumnsWidth = {};
18
+ displayColumnsDefinitions.forEach(function (column) { return (displayColumnsWidth[column.name] = (storeColumnsWidth === null || storeColumnsWidth === void 0 ? void 0 : storeColumnsWidth[column.name]) || column.flexBasis); });
19
+ return displayColumnsWidth;
20
+ }, [displayColumnsDefinitions, storeColumnsWidth]);
21
+ var totalColumnsWidth = React.useMemo(function () {
22
+ return sum(Object.values(displayColumnsWidth));
23
+ }, [displayColumnsWidth]);
24
+ /**
25
+ * handling of remaining space
26
+ */
27
+ // TODO optimize better
28
+ var gridBoxRef = React.useRef(null);
29
+ var testAdjustLastColumn = React.useCallback(function () {
30
+ var _a;
31
+ var _b;
32
+ var gridWidth = ((_b = gridBoxRef === null || gridBoxRef === void 0 ? void 0 : gridBoxRef.current) === null || _b === void 0 ? void 0 : _b.clientWidth) || null;
33
+ if ((columnLayout == 'normal' || columnLayout == 'sticky') && gridWidth && totalColumnsWidth < gridWidth) {
34
+ var lastColumn = displayColumnsDefinitions[displayColumnsDefinitions.length - 1];
35
+ if (lastColumn) {
36
+ var change = (_a = {}, _a[lastColumn.name] = displayColumnsWidth[lastColumn.name] + gridWidth - totalColumnsWidth, _a);
37
+ handleSetColumnWidth(change);
38
+ }
39
+ }
40
+ }, [columnLayout, displayColumnsDefinitions, displayColumnsWidth, gridBoxRef, handleSetColumnWidth, totalColumnsWidth]);
41
+ React.useEffect(function () {
42
+ testAdjustLastColumn();
43
+ }, [testAdjustLastColumn]);
44
+ React.useLayoutEffect(function () {
45
+ window.addEventListener('resize', testAdjustLastColumn);
46
+ return function () { return window.removeEventListener('resize', testAdjustLastColumn); };
47
+ }, [testAdjustLastColumn]);
48
+ /**
49
+ * resizing of columns
50
+ */
51
+ var handleResizeDrag = React.useCallback(function (columnName, width) {
52
+ var _a, _b;
53
+ var _c;
54
+ var i = displayColumnsDefinitions.findIndex(function (_a) {
55
+ var name = _a.name;
56
+ return name == columnName;
57
+ });
58
+ var nextColumn = displayColumnsDefinitions[i + 1];
59
+ if (columnLayout == 'normal' || columnLayout == 'sticky') {
60
+ var gridWidth = ((_c = gridBoxRef === null || gridBoxRef === void 0 ? void 0 : gridBoxRef.current) === null || _c === void 0 ? void 0 : _c.clientWidth) || null;
61
+ var lastColumnWidth = displayColumnsWidth[displayColumnsDefinitions[displayColumnsDefinitions.length - 1].name];
62
+ var lastColumnMinWidth = (gridWidth && gridWidth - (totalColumnsWidth - lastColumnWidth)) || 0;
63
+ var minWidth = !nextColumn ? Math.max(lastColumnMinWidth, minColumnWidth) : minColumnWidth;
64
+ var origin_1 = displayColumnsWidth[columnName];
65
+ var newWidth = origin_1 + width < minWidth ? minWidth : origin_1 + width;
66
+ handleSetColumnWidth((_a = {}, _a[columnName] = newWidth, _a));
67
+ }
68
+ else if (columnLayout == 'no-scroll') {
69
+ var nextColumnWidth = displayColumnsWidth[nextColumn.name];
70
+ var origin_2 = displayColumnsWidth[columnName];
71
+ var addedColumnWidth = origin_2 + width < minColumnWidth ? minColumnWidth - origin_2 : width;
72
+ var addedNextColumnWidth = nextColumnWidth - addedColumnWidth < minColumnWidth ? nextColumnWidth - minColumnWidth : addedColumnWidth;
73
+ var addedWidth = Math.min(addedColumnWidth, addedNextColumnWidth);
74
+ var columnsWidth = (_b = {}, _b[columnName] = origin_2 + addedWidth, _b);
75
+ if (nextColumn) {
76
+ columnsWidth[nextColumn.name] = nextColumnWidth - addedWidth;
77
+ }
78
+ handleSetColumnWidth(columnsWidth);
79
+ }
80
+ }, [displayColumnsDefinitions, columnLayout, displayColumnsWidth, totalColumnsWidth, minColumnWidth, handleSetColumnWidth]);
81
+ return { totalColumnsWidth: totalColumnsWidth, gridBoxRef: gridBoxRef, displayColumnsWidth: displayColumnsWidth, handleResizeDrag: handleResizeDrag };
82
+ };
83
+ export default useColumnSizes;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { CommonGridProps, GridActionsType, ExtraControlButton } from '../types';
3
+ type ReturnProps = {
4
+ topLeftButtons: ExtraControlButton[];
5
+ topRightButtons: ExtraControlButton[];
6
+ bottomLeftButtons: ExtraControlButton[];
7
+ bottomRightButtons: ExtraControlButton[];
8
+ };
9
+ declare const useControlButtons: (hideColumnConfig: CommonGridProps['hideColumnConfig'], openConfigForm: Required<GridActionsType>['openConfigForm'], resetGrid: Required<GridActionsType>['resetGrid'], columnsDefinitions: CommonGridProps['columnsDefinitions'], resetFilters: Required<GridActionsType>['resetFilters'], setRowsPerPage: Required<GridActionsType>['setRowsPerPage'], rowsSeenTxt: string, extraControlButtons: CommonGridProps['extraControlButtons'], Translator: React.ComponentType<any>, confirmOnReset: (() => boolean) | undefined, perPageOptions: number[]) => ReturnProps;
10
+ export default useControlButtons;
@@ -0,0 +1,64 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import React from 'react';
12
+ import { ExtraControlButtonPosition } from '../types';
13
+ var getButtonsByPosition = function (location, extraControlButtons) {
14
+ return (extraControlButtons || []).filter(function (_a) {
15
+ var position = _a.position;
16
+ return position == location || (!position && location == 'top-left');
17
+ });
18
+ };
19
+ var useControlButtons = function (hideColumnConfig, openConfigForm, resetGrid, columnsDefinitions, resetFilters, setRowsPerPage, rowsSeenTxt, extraControlButtons, Translator, confirmOnReset, perPageOptions) {
20
+ var resetGridWithConfirm = React.useCallback(function () { return confirmOnReset ? confirmOnReset() && resetGrid() : resetGrid(); }, [confirmOnReset, resetGrid]);
21
+ var topLeftButtons = React.useMemo(function () {
22
+ return __spreadArray([
23
+ {
24
+ label: rowsSeenTxt,
25
+ options: perPageOptions.map(function (value) { return ({ label: String(value), onClick: function () { return setRowsPerPage(value); } }); }),
26
+ hideChevron: true,
27
+ },
28
+ {
29
+ label: _jsx(Translator, { id: "dataGrid.buttonClearSettings", defaults: "Reset filters" }),
30
+ onClick: resetFilters,
31
+ hide: !columnsDefinitions.find(function (col) { return col.filtering; }), // does grid have any filters
32
+ },
33
+ {
34
+ label: _jsx(Translator, { id: "dataGrid.buttonClearConfig", defaults: "Reset config" }),
35
+ onClick: resetGridWithConfirm,
36
+ },
37
+ {
38
+ label: _jsx(Translator, { id: "dataGrid.buttonGridConfig", defaults: "Configure columns" }),
39
+ onClick: openConfigForm,
40
+ hide: hideColumnConfig,
41
+ }
42
+ ], getButtonsByPosition(ExtraControlButtonPosition.TopLeft, extraControlButtons), true);
43
+ }, [
44
+ hideColumnConfig,
45
+ columnsDefinitions,
46
+ extraControlButtons,
47
+ openConfigForm,
48
+ resetFilters,
49
+ resetGrid,
50
+ rowsSeenTxt,
51
+ setRowsPerPage,
52
+ ]);
53
+ var topRightButtons = React.useMemo(function () {
54
+ return getButtonsByPosition(ExtraControlButtonPosition.TopRight, extraControlButtons);
55
+ }, [extraControlButtons]);
56
+ var bottomLeftButtons = React.useMemo(function () {
57
+ return getButtonsByPosition(ExtraControlButtonPosition.BottomLeft, extraControlButtons);
58
+ }, [extraControlButtons]);
59
+ var bottomRightButtons = React.useMemo(function () {
60
+ return getButtonsByPosition(ExtraControlButtonPosition.BottomRight, extraControlButtons);
61
+ }, [extraControlButtons]);
62
+ return { topLeftButtons: topLeftButtons, topRightButtons: topRightButtons, bottomLeftButtons: bottomLeftButtons, bottomRightButtons: bottomRightButtons };
63
+ };
64
+ export default useControlButtons;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { RowProps, UxState } from '../types';
3
+ declare const useRowsKeyControls: (rowsData: RowProps[], uxState: UxState, onUxChange?: ((uxKey: keyof UxState, uxValue: any) => void) | undefined) => (e: React.KeyboardEvent<HTMLDivElement>) => void;
4
+ export default useRowsKeyControls;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ var useRowsKeyControls = function (rowsData, uxState, onUxChange) {
3
+ return React.useCallback(function (e) {
4
+ var _a, _b;
5
+ var selectedRowId = uxState.selectedRow;
6
+ if (!selectedRowId)
7
+ return;
8
+ var selectedRowIdx = rowsData.findIndex(function (row) { return row.id === selectedRowId; });
9
+ var previousRowId = (_a = rowsData[selectedRowIdx - 1]) === null || _a === void 0 ? void 0 : _a.id;
10
+ var nextRowId = (_b = rowsData[selectedRowIdx + 1]) === null || _b === void 0 ? void 0 : _b.id;
11
+ var isFirst = selectedRowIdx === 0;
12
+ var isLast = selectedRowIdx === rowsData.length - 1;
13
+ if (e.key === 'ArrowUp' && !isFirst)
14
+ onUxChange === null || onUxChange === void 0 ? void 0 : onUxChange('selectedRow', previousRowId);
15
+ if (e.key === 'ArrowDown' && !isLast)
16
+ onUxChange === null || onUxChange === void 0 ? void 0 : onUxChange('selectedRow', nextRowId);
17
+ if (e.key === 'Escape')
18
+ onUxChange === null || onUxChange === void 0 ? void 0 : onUxChange('selectedRow', null);
19
+ }, [uxState, rowsData, onUxChange]);
20
+ };
21
+ export default useRowsKeyControls;
@@ -0,0 +1,3 @@
1
+ import { RowProps, GridActionsType, UxState } from '../types';
2
+ declare const useUxReset: (rowsData: RowProps[], uxState: UxState, clearUxState: GridActionsType['clearUxState']) => any;
3
+ export default useUxReset;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ var useUxReset = function (rowsData, uxState, clearUxState) {
3
+ var _a = React.useState('|'), previous = _a[0], setPrevious = _a[1];
4
+ React.useEffect(function () {
5
+ var ids = (rowsData || []).map(function (row) { return row.id; }).join('|');
6
+ // clear uxState if listed rows change and uxState is not clear already
7
+ if (ids !== previous) {
8
+ if (clearUxState && ((uxState.checkedRows && Object.keys(uxState.checkedRows).length) || uxState.selectedRow)) {
9
+ clearUxState();
10
+ }
11
+ }
12
+ setPrevious(ids);
13
+ }, [rowsData]); // eslint-disable-line react-hooks/exhaustive-deps
14
+ };
15
+ export default useUxReset;
@@ -0,0 +1,7 @@
1
+ import CommonGrid from './CommonGrid';
2
+ import withReduxActions from './HoC/withReduxActions';
3
+ import reducer, { actionPrefix, createActions, createSelectors, createFullSelector, actionTypes } from './store';
4
+ import * as Types from './types';
5
+ import * as utils from './utils/public';
6
+ export default CommonGrid;
7
+ export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, utils };
@@ -0,0 +1,7 @@
1
+ import CommonGrid from './CommonGrid';
2
+ import withReduxActions from './HoC/withReduxActions';
3
+ import reducer, { actionPrefix, createActions, createSelectors, createFullSelector, actionTypes } from './store';
4
+ import * as Types from './types';
5
+ import * as utils from './utils/public';
6
+ export default CommonGrid;
7
+ export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, utils };
@@ -0,0 +1,58 @@
1
+ import { FilterProps, SortingValueType, InitProps, GridState, GridSelectorsType, ColumnConfig } from '../types';
2
+ type DefaultRootState = {};
3
+ export type MultiState = {
4
+ [key: string]: GridState;
5
+ };
6
+ export declare const initialState: GridState;
7
+ export declare const actionPrefix = "@store/CommonGrid";
8
+ export declare const actionTypes: {
9
+ init: string;
10
+ clearUxState: string;
11
+ handleUxChange: string;
12
+ openConfigForm: string;
13
+ closeConfigForm: string;
14
+ setColumnConfig: string;
15
+ setPage: string;
16
+ setRowsPerPage: string;
17
+ resetFilters: string;
18
+ addFilter: string;
19
+ addSorting: string;
20
+ clearSettings: string;
21
+ resetGrid: string;
22
+ setColumnWidth: string;
23
+ setColumnsOrder: string;
24
+ };
25
+ declare const _default: (state: MultiState | undefined, action: Action) => MultiState;
26
+ export default _default;
27
+ export declare const createActions: (gridName: string) => {
28
+ init: (initProps: InitProps) => Action;
29
+ clearUxState: () => Action;
30
+ handleUxChange: (uxKey: keyof GridState['uxState'], uxValue: any) => Action;
31
+ openConfigForm: () => Action;
32
+ closeConfigForm: () => Action;
33
+ setColumnConfig: (columnConfig: ColumnConfig) => Action;
34
+ setPage: (page: number) => Action;
35
+ setColumnWidth: (columnsWidth: {
36
+ [anyKey: string]: number;
37
+ } | null, columnLayout: 'normal' | 'no-scroll' | 'sticky') => Action;
38
+ resetGrid: () => Action;
39
+ setColumnsOrder: (columnsOrder: string[]) => Action;
40
+ setRowsPerPage: (rowsPerPage: number) => Action;
41
+ resetFilters: () => Action;
42
+ addFilter: (column: string, value: any, filterProps: FilterProps) => Action;
43
+ addSorting: (column: string, direction: SortingValueType) => Action;
44
+ clearSettings: () => Action;
45
+ };
46
+ export declare const createSelectors: (gridName: string) => {
47
+ getUxState: (state: DefaultRootState) => GridState['uxState'];
48
+ isConfigFormOpen: (state: DefaultRootState) => GridState['isConfigFormOpen'];
49
+ getColumnConfig: (state: DefaultRootState) => GridState['columnConfig'];
50
+ getPage: (state: DefaultRootState) => GridState['page'];
51
+ getRowsPerPage: (state: DefaultRootState) => GridState['rowsPerPage'];
52
+ getFilter: (state: DefaultRootState) => GridState['filter'];
53
+ getSorting: (state: DefaultRootState) => GridState['sorting'];
54
+ getColumnsWidth: (state: DefaultRootState) => GridState['columnsWidth'];
55
+ getColumnsWidthVariant: (state: DefaultRootState) => GridState['columnsWidthVariant'];
56
+ getColumnsOrder: (state: DefaultRootState) => GridState['columnsOrder'];
57
+ };
58
+ export declare const createFullSelector: (gridName: string) => (state: DefaultRootState) => GridSelectorsType;