@mailstep/design-system 0.6.41 → 0.6.43
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/ExtraControlButtons/ExtraControlButtons.js +5 -2
- 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/hooks/useFloatingButton.d.ts +1 -1
- package/ui/Blocks/CommonGrid/hooks/useFloatingButton.js +2 -3
- package/ui/Blocks/CommonGrid/types.d.ts +4 -5
- package/ui/index.es.js +2228 -2235
- 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;
|
|
@@ -20,14 +20,17 @@ import DropdownSelect from '../../../../Elements/DropdownSelect';
|
|
|
20
20
|
export var Row = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n & > * {\n margin-right: 12px;\n }\n z-index: 2;\n"], ["\n display: flex;\n & > * {\n margin-right: 12px;\n }\n z-index: 2;\n"])));
|
|
21
21
|
var StyledButton = styled(Button)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: none;\n\n @media (min-width: 1024px) {\n display: block;\n }\n"], ["\n display: none;\n\n @media (min-width: 1024px) {\n display: block;\n }\n"])));
|
|
22
22
|
var ControlButton = function (_a) {
|
|
23
|
-
var node = _a.node, label = _a.label, appearance = _a.appearance, variant = _a.variant, disabled = _a.disabled, onClick = _a.onClick, onSelect = _a.onSelect, options = _a.options, hideChevron = _a.hideChevron;
|
|
23
|
+
var hide = _a.hide, node = _a.node, label = _a.label, appearance = _a.appearance, variant = _a.variant, disabled = _a.disabled, onClick = _a.onClick, onSelect = _a.onSelect, options = _a.options, hideChevron = _a.hideChevron, iconLeft = _a.iconLeft;
|
|
24
|
+
if (hide) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
24
27
|
if (node)
|
|
25
28
|
return _jsx(_Fragment, { children: node });
|
|
26
29
|
if (options) {
|
|
27
30
|
return (_jsx(DropdownSelect, { label: label || '', appearance: appearance || 'secondary', variant: variant || 'default', options: options, showChevron: !hideChevron, onSelect: onSelect, disabled: disabled }));
|
|
28
31
|
}
|
|
29
32
|
else {
|
|
30
|
-
return (_jsx(StyledButton, { type: "button", onClick: onClick, disabled: disabled, variant: variant || 'default', appearance: appearance || '
|
|
33
|
+
return (_jsx(StyledButton, { type: "button", onClick: onClick, disabled: disabled, variant: variant || 'default', appearance: appearance || 'primary', iconLeft: iconLeft, children: label }));
|
|
31
34
|
}
|
|
32
35
|
};
|
|
33
36
|
var ExtraControlButtons = function (_a) {
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -287,6 +287,7 @@ export type ExtraControlButton = {
|
|
|
287
287
|
hide?: boolean;
|
|
288
288
|
hideChevron?: boolean;
|
|
289
289
|
disabled?: boolean;
|
|
290
|
+
iconLeft?: string | JSX.Element;
|
|
290
291
|
};
|
|
291
292
|
export type Group = {
|
|
292
293
|
name?: string;
|
|
@@ -304,13 +305,11 @@ export type GridProps = Omit<CommonGridProps, 'filters'> & {
|
|
|
304
305
|
};
|
|
305
306
|
export type PageGridProps = Omit<GridProps, 'rowsData' | 'totalRowsCount' | 'columnsDefinitions' | 'actionColumnDefinition' | 'minColumnWidth' | 'columnLayout'>;
|
|
306
307
|
export type Item = {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
name: string;
|
|
308
|
+
title: string | JSX.Element;
|
|
309
|
+
onClick: () => void;
|
|
310
310
|
};
|
|
311
311
|
export type FloatingButtonProps = {
|
|
312
312
|
options?: Item[];
|
|
313
|
-
|
|
314
|
-
onClick?: () => void;
|
|
313
|
+
onClick?: (value?: string) => void;
|
|
315
314
|
};
|
|
316
315
|
export {};
|