@mailstep/design-system 0.6.40 → 0.6.42
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 +1 -1
- package/ui/Blocks/CommonGrid/components/DropdownButton/DropdownButton.d.ts +10 -0
- package/ui/Blocks/CommonGrid/components/DropdownButton/DropdownButton.js +32 -0
- package/ui/Blocks/CommonGrid/components/DropdownButton/index.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/DropdownButton/index.js +2 -0
- package/ui/Blocks/CommonGrid/components/FloatingButton/FloatingButton.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/FloatingButton/FloatingButton.js +3 -15
- package/ui/Blocks/CommonGrid/components/gridCells/EnumInCell.js +1 -1
- package/ui/Blocks/CommonGrid/hooks/useFloatingButton.d.ts +1 -1
- package/ui/Blocks/CommonGrid/hooks/useFloatingButton.js +2 -3
- package/ui/Blocks/CommonGrid/types.d.ts +3 -5
- package/ui/index.es.js +2218 -2227
- package/ui/index.umd.js +3 -3
package/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Item } from '../../types';
|
|
3
|
+
import { AppearanceValue } from '../../../../Elements/Button/types';
|
|
4
|
+
type Props = {
|
|
5
|
+
label: string | JSX.Element;
|
|
6
|
+
items: Item[];
|
|
7
|
+
appearance?: AppearanceValue;
|
|
8
|
+
};
|
|
9
|
+
declare const DropdownButton: ({ label, items, appearance }: Props) => JSX.Element;
|
|
10
|
+
export default DropdownButton;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 styled from '@xstyled/styled-components';
|
|
7
|
+
import React, { useCallback, useState } from 'react';
|
|
8
|
+
import Button from '../../../../Elements/Button/Button';
|
|
9
|
+
import { useClickOutside } from '../../../Modal/hooks/useClickOutside';
|
|
10
|
+
import DropdownMenu from '../../../../Elements/DropdownMenu';
|
|
11
|
+
import { ArrowDown, ArrowUp } from '../../../../Elements/Icon';
|
|
12
|
+
import { th } from '@xstyled/system';
|
|
13
|
+
var ButtonWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n width: fit-content;\n"], ["\n position: relative;\n width: fit-content;\n"])));
|
|
14
|
+
var StyledDropdownMenu = styled(DropdownMenu)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: calc(100% + 4px);\n right: 0;\n width: max-content;\n z-index: 2;\n"], ["\n position: absolute;\n top: calc(100% + 4px);\n right: 0;\n width: max-content;\n z-index: 2;\n"])));
|
|
15
|
+
var StyledButton = styled(Button)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-right: 0;\n"], ["\n padding-right: 0;\n"])));
|
|
16
|
+
var StyledIcon = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 20px;\n height: 20px;\n margin: 9px;\n & > svg {\n stroke: ", ";\n }\n"], ["\n width: 20px;\n height: 20px;\n margin: 9px;\n & > svg {\n stroke: ", ";\n }\n"])), function (_a) {
|
|
17
|
+
var appearance = _a.appearance;
|
|
18
|
+
return appearance === 'secondary' ? th.color('blue2') : appearance === 'tertiary' ? th.color('red1') : 'white';
|
|
19
|
+
});
|
|
20
|
+
var Separator = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n height: 38px;\n width: 1px;\n background-color: white;\n margin-left: 18px;\n"], ["\n height: 38px;\n width: 1px;\n background-color: white;\n margin-left: 18px;\n"])));
|
|
21
|
+
var DropdownButton = function (_a) {
|
|
22
|
+
var label = _a.label, items = _a.items, appearance = _a.appearance;
|
|
23
|
+
var _b = useState(false), showDropdownMenu = _b[0], setShowDropdownMenu = _b[1];
|
|
24
|
+
var onClose = useCallback(function () { return setShowDropdownMenu(false); }, []);
|
|
25
|
+
var handleClick = React.useCallback(function () {
|
|
26
|
+
setShowDropdownMenu(function (prev) { return !prev; });
|
|
27
|
+
}, []);
|
|
28
|
+
var ref = useClickOutside({ onClose: onClose });
|
|
29
|
+
return (_jsxs(ButtonWrapper, { ref: ref, children: [_jsxs(StyledButton, { onClick: handleClick, appearance: appearance, children: [label, _jsx(Separator, {}), _jsx(StyledIcon, { appearance: appearance, children: showDropdownMenu ? _jsx(ArrowUp, {}) : _jsx(ArrowDown, {}) })] }), _jsx(StyledDropdownMenu, { showMenu: showDropdownMenu, items: items })] }));
|
|
30
|
+
};
|
|
31
|
+
export default DropdownButton;
|
|
32
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -3,5 +3,5 @@ export declare const StyledButton: import("styled-components").StyledComponent<"
|
|
|
3
3
|
export declare const StyledCross: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
}, never>;
|
|
6
|
-
declare const FloatingButton: ({ options,
|
|
6
|
+
declare const FloatingButton: ({ options, onClick }: FloatingButtonProps) => JSX.Element | null;
|
|
7
7
|
export default FloatingButton;
|
|
@@ -3,7 +3,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
5
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { useCallback,
|
|
6
|
+
import { useCallback, useRef, useState } from 'react';
|
|
7
7
|
import styled from '@xstyled/styled-components';
|
|
8
8
|
import DropdownMenu from '../../../../Elements/DropdownMenu';
|
|
9
9
|
import Popover from '../../../Popover';
|
|
@@ -18,7 +18,7 @@ export var StyledCross = styled.div(templateObject_4 || (templateObject_4 = __ma
|
|
|
18
18
|
return (isOpen ? 'rotate(45deg) translate(-1px, -1px)' : 'rotate(90deg) translate(-2px, 0)');
|
|
19
19
|
});
|
|
20
20
|
var FloatingButton = function (_a) {
|
|
21
|
-
var options = _a.options,
|
|
21
|
+
var options = _a.options, onClick = _a.onClick;
|
|
22
22
|
var _b = useState(false), showDropdownMenu = _b[0], setShowDropdownMenu = _b[1];
|
|
23
23
|
var ref = useRef(null);
|
|
24
24
|
var onClose = useCallback(function () { return setShowDropdownMenu(false); }, []);
|
|
@@ -28,19 +28,7 @@ var FloatingButton = function (_a) {
|
|
|
28
28
|
}
|
|
29
29
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
30
30
|
}, [onClick, options]);
|
|
31
|
-
|
|
32
|
-
setShowDropdownMenu(false);
|
|
33
|
-
onSelect === null || onSelect === void 0 ? void 0 : onSelect(item.value);
|
|
34
|
-
}, [onSelect]);
|
|
35
|
-
var items = useMemo(function () {
|
|
36
|
-
return options === null || options === void 0 ? void 0 : options.map(function (item) { return ({
|
|
37
|
-
title: item.label,
|
|
38
|
-
onClick: function () { return handleSelectItem(item); },
|
|
39
|
-
link: '#',
|
|
40
|
-
name: item.name,
|
|
41
|
-
}); });
|
|
42
|
-
}, [handleSelectItem, options]);
|
|
43
|
-
return (_jsx(FloatingWrapper, { children: _jsxs(StyledButton, { ref: ref, onClick: handleOnClick, children: [_jsxs(StyledCross, { isOpen: showDropdownMenu, children: [_jsx("span", { className: "line" }), _jsx("span", { className: "line" })] }), showDropdownMenu && (_jsx(Popover, { parentRef: ref, onClose: onClose, placement: "top-end", children: _jsx(StyledDropdownMenu, { showMenu: true, items: items }) }))] }) }));
|
|
31
|
+
return (_jsx(FloatingWrapper, { children: _jsxs(StyledButton, { ref: ref, onClick: handleOnClick, children: [_jsxs(StyledCross, { isOpen: showDropdownMenu, children: [_jsx("span", { className: "line" }), _jsx("span", { className: "line" })] }), showDropdownMenu && (_jsx(Popover, { parentRef: ref, onClose: onClose, placement: "top-end", children: _jsx(StyledDropdownMenu, { showMenu: true, items: options }) }))] }) }));
|
|
44
32
|
};
|
|
45
33
|
export default FloatingButton;
|
|
46
34
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -17,7 +17,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
17
|
import { useMemo } from 'react';
|
|
18
18
|
import styled from '@xstyled/styled-components';
|
|
19
19
|
import HighlightBox from '../../../../Elements/HighlightBox';
|
|
20
|
-
var Center = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-start;\n width:
|
|
20
|
+
var Center = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-start;\n width: 100%;\n"], ["\n display: flex;\n justify-content: flex-start;\n width: 100%;\n"])));
|
|
21
21
|
export var EnumInCell = function (_a) {
|
|
22
22
|
var value = _a.value, enumObj = _a.enumObj, appearanceMap = _a.appearanceMap, size = _a.size;
|
|
23
23
|
var finalLabel = useMemo(function () {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FloatingButtonProps, Item } from '../types';
|
|
2
|
-
declare const useFloatingButton: (hasPermission: any, onClick?: () => void, options?: Item[]
|
|
2
|
+
declare const useFloatingButton: (hasPermission: any, onClick?: () => void, options?: Item[]) => FloatingButtonProps | undefined;
|
|
3
3
|
export default useFloatingButton;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
var useFloatingButton = function (hasPermission, onClick, options
|
|
2
|
+
var useFloatingButton = function (hasPermission, onClick, options) {
|
|
3
3
|
return useMemo(function () {
|
|
4
4
|
if (!hasPermission)
|
|
5
5
|
return;
|
|
6
6
|
return {
|
|
7
7
|
onClick: onClick,
|
|
8
8
|
options: options,
|
|
9
|
-
onSelect: onSelect,
|
|
10
9
|
};
|
|
11
|
-
}, [hasPermission, onClick, options
|
|
10
|
+
}, [hasPermission, onClick, options]);
|
|
12
11
|
};
|
|
13
12
|
export default useFloatingButton;
|
|
@@ -304,13 +304,11 @@ export type GridProps = Omit<CommonGridProps, 'filters'> & {
|
|
|
304
304
|
};
|
|
305
305
|
export type PageGridProps = Omit<GridProps, 'rowsData' | 'totalRowsCount' | 'columnsDefinitions' | 'actionColumnDefinition' | 'minColumnWidth' | 'columnLayout'>;
|
|
306
306
|
export type Item = {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
name: string;
|
|
307
|
+
title: string | JSX.Element;
|
|
308
|
+
onClick: () => void;
|
|
310
309
|
};
|
|
311
310
|
export type FloatingButtonProps = {
|
|
312
311
|
options?: Item[];
|
|
313
|
-
|
|
314
|
-
onClick?: () => void;
|
|
312
|
+
onClick?: (value?: string) => void;
|
|
315
313
|
};
|
|
316
314
|
export {};
|