oolib 2.115.0 → 2.117.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/dist/components/ActionMenu/index.d.ts +45 -12
- package/dist/components/ActionMenu/index.js +26 -12
- package/dist/components/ActionMenu/styled.d.ts +25 -5
- package/dist/components/ActionMenu/styled.js +6 -15
- package/dist/components/Buttons/index.d.ts +2 -2
- package/dist/components/Modals/Modal/index.d.ts +39 -12
- package/dist/components/Modals/Modal/index.js +27 -11
- package/dist/components/Modals/Modal/styled.d.ts +27 -9
- package/dist/components/Modals/Modal/styled.js +5 -5
- package/dist/components/Modals/ModalConfirm/index.d.ts +27 -8
- package/dist/components/Modals/ModalConfirm/index.js +19 -7
- package/dist/components/Modals/ModalConfirm/styled.d.ts +11 -6
- package/dist/components/Modals/ModalConfirm/styled.js +4 -4
- package/dist/components/Modals/derivedComps/ModalConfirmAction/index.d.ts +20 -7
- package/dist/components/Modals/derivedComps/ModalConfirmAction/index.js +18 -16
- package/dist/components/Modals/derivedComps/ModalForms/index.d.ts +21 -8
- package/dist/components/Modals/derivedComps/ModalForms/index.js +13 -3
- package/dist/components/Modals/derivedComps/ModalSmall/index.d.ts +30 -10
- package/dist/components/Modals/derivedComps/ModalSmall/index.js +18 -0
- package/dist/components/PercentBarChart/index.d.ts +2 -2
- package/dist/components/PercentBarChart/index.js +39 -37
- package/dist/stories/ModalConfirmAction.stories.js +0 -1
- package/dist/stories/PercentBarChart.stories.js +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { FunctionComponent, ReactNode } from "react";
|
|
2
|
+
import * as ButtonComps from "../Buttons";
|
|
3
|
+
export interface ActionItem {
|
|
4
|
+
display: string;
|
|
2
5
|
icon?: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
7
|
+
confirmAction?: {
|
|
8
|
+
title?: string;
|
|
9
|
+
message?: string;
|
|
10
|
+
onConfirm?: () => void;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface CustomSelectCompProps {
|
|
14
|
+
active: boolean;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
}
|
|
17
|
+
export interface ActionMenuProps {
|
|
18
|
+
icon?: string;
|
|
19
|
+
invert?: boolean;
|
|
20
|
+
actions: ActionItem[];
|
|
21
|
+
align?: "left" | "right" | "center";
|
|
22
|
+
iconSize?: "S" | "M";
|
|
23
|
+
M?: boolean;
|
|
24
|
+
ButtonComp?: keyof typeof ButtonComps;
|
|
25
|
+
setShowActions?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
10
26
|
popOutOfOverflowHiddenParent?: boolean;
|
|
11
|
-
CustomSelectComp
|
|
12
|
-
storybookPreview
|
|
13
|
-
}
|
|
14
|
-
|
|
27
|
+
CustomSelectComp?: ReactNode | FunctionComponent<CustomSelectCompProps>;
|
|
28
|
+
storybookPreview?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @component Renders an action menu component with customizable text and styling.
|
|
32
|
+
*
|
|
33
|
+
* - The props object containing the following properties:
|
|
34
|
+
* @prop {string} icon: The name of the icon to be displayed. Defaults to "DotsThree".
|
|
35
|
+
* @prop {boolean} invert: A boolean indicating whether to invert the action menu colors. Defaults to false.
|
|
36
|
+
* @prop {ActionItem[]} actions: An array of action items to be displayed in the action menu.
|
|
37
|
+
* @prop {"left" | "right" | "center"} align: The alignment of the action menu relative to its parent element. Defaults to "right".
|
|
38
|
+
* @prop {"S" | "M"} iconSize: The size of the icon. Defaults to "S".
|
|
39
|
+
* @prop {boolean} M: A boolean indicating whether to use the medium sized buttons. Defaults to false.
|
|
40
|
+
* @prop {keyof typeof ButtonComps} ButtonComp: The name of the button component to use for each action item. Defaults to "ButtonGhost".
|
|
41
|
+
* @prop {React.Dispatch<React.SetStateAction<boolean>>} setShowActions: A callback function to set the expanded state of the action menu.
|
|
42
|
+
* @prop {boolean} popOutOfOverflowHiddenParent: A boolean indicating whether the action menu should pop out of an overflow:hidden parent element. Defaults to false.
|
|
43
|
+
* @prop {React.ReactNode | React.FunctionComponent<CustomSelectCompProps>} CustomSelectComp: A custom select component to use instead of the default select component.
|
|
44
|
+
* @prop {boolean} storybookPreview: A boolean indicating whether the component is being rendered in storybook. Defaults to false.
|
|
45
|
+
* @return {ReactElement} The rendered action menu component.
|
|
46
|
+
*/
|
|
47
|
+
export declare const ActionMenu: FunctionComponent<ActionMenuProps>;
|
|
@@ -44,22 +44,35 @@ var usePopOutOfOverflowHiddenParent_1 = require("../../utils/usePopOutOfOverflow
|
|
|
44
44
|
var styled_1 = require("./styled");
|
|
45
45
|
var ModalConfirmAction_1 = require("../Modals/derivedComps/ModalConfirmAction");
|
|
46
46
|
var react_dom_1 = require("react-dom");
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @component Renders an action menu component with customizable text and styling.
|
|
49
|
+
*
|
|
50
|
+
* - The props object containing the following properties:
|
|
51
|
+
* @prop {string} icon: The name of the icon to be displayed. Defaults to "DotsThree".
|
|
52
|
+
* @prop {boolean} invert: A boolean indicating whether to invert the action menu colors. Defaults to false.
|
|
53
|
+
* @prop {ActionItem[]} actions: An array of action items to be displayed in the action menu.
|
|
54
|
+
* @prop {"left" | "right" | "center"} align: The alignment of the action menu relative to its parent element. Defaults to "right".
|
|
55
|
+
* @prop {"S" | "M"} iconSize: The size of the icon. Defaults to "S".
|
|
56
|
+
* @prop {boolean} M: A boolean indicating whether to use the medium sized buttons. Defaults to false.
|
|
57
|
+
* @prop {keyof typeof ButtonComps} ButtonComp: The name of the button component to use for each action item. Defaults to "ButtonGhost".
|
|
58
|
+
* @prop {React.Dispatch<React.SetStateAction<boolean>>} setShowActions: A callback function to set the expanded state of the action menu.
|
|
59
|
+
* @prop {boolean} popOutOfOverflowHiddenParent: A boolean indicating whether the action menu should pop out of an overflow:hidden parent element. Defaults to false.
|
|
60
|
+
* @prop {React.ReactNode | React.FunctionComponent<CustomSelectCompProps>} CustomSelectComp: A custom select component to use instead of the default select component.
|
|
61
|
+
* @prop {boolean} storybookPreview: A boolean indicating whether the component is being rendered in storybook. Defaults to false.
|
|
62
|
+
* @return {ReactElement} The rendered action menu component.
|
|
63
|
+
*/
|
|
48
64
|
var ActionMenu = function (_a) {
|
|
49
|
-
var _b = _a.icon, icon = _b === void 0 ? "DotsThree" : _b,
|
|
50
|
-
invert = _a.invert, actions = _a.actions, _c = _a.align, align = _c === void 0 ? "right" : _c, _d = _a.iconSize, iconSize = _d === void 0 ? "S" : _d, M = _a.M, _e = _a.ButtonComp, _ButtonComp = _e === void 0 ? "ButtonGhost" : _e, setShowActionsInParent = _a.setShowActions, _f = _a.popOutOfOverflowHiddenParent, popOutOfOverflowHiddenParent = _f === void 0 ? false : _f, CustomSelectComp = _a.CustomSelectComp, storybookPreview = _a.storybookPreview;
|
|
65
|
+
var _b = _a.icon, icon = _b === void 0 ? "DotsThree" : _b, invert = _a.invert, actions = _a.actions, _c = _a.align, align = _c === void 0 ? "right" : _c, _d = _a.iconSize, iconSize = _d === void 0 ? "S" : _d, M = _a.M, _e = _a.ButtonComp, _ButtonComp = _e === void 0 ? "ButtonGhost" : _e, setShowActionsInParent = _a.setShowActions, _f = _a.popOutOfOverflowHiddenParent, popOutOfOverflowHiddenParent = _f === void 0 ? false : _f, CustomSelectComp = _a.CustomSelectComp, storybookPreview = _a.storybookPreview;
|
|
51
66
|
var actionMenuRef = (0, react_1.useRef)(null);
|
|
52
67
|
var optionsWrapperRef = (0, react_1.useRef)(null);
|
|
53
68
|
var _g = (0, react_1.useState)(false), showActions = _g[0], setShowActions = _g[1];
|
|
54
69
|
(0, useHandleClickOutside_1.useHandleClickOutside)(popOutOfOverflowHiddenParent
|
|
55
|
-
? [actionMenuRef, optionsWrapperRef]
|
|
70
|
+
? [actionMenuRef, optionsWrapperRef]
|
|
56
71
|
: actionMenuRef, setShowActions);
|
|
57
72
|
if (!actions || actions.length === 0)
|
|
58
73
|
return null;
|
|
59
74
|
var getOpsRect = function () { var _a; return (_a = optionsWrapperRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(); };
|
|
60
75
|
var ButtonComp = ButtonComps[_ButtonComp];
|
|
61
|
-
//basically action menu defaults to 'S' button size (cuz its an icon only button)
|
|
62
|
-
//so passing 'M' will override this default and make it a Medium sized button
|
|
63
76
|
var buttonSize = M ? { M: true } : {};
|
|
64
77
|
var genOptionIcon = function (iconName) {
|
|
65
78
|
var IconComp = icons_1.icons[iconName];
|
|
@@ -74,21 +87,22 @@ var ActionMenu = function (_a) {
|
|
|
74
87
|
removeFixedPos();
|
|
75
88
|
}
|
|
76
89
|
}, [showActions]);
|
|
77
|
-
//on unmount, setShowActionsInParent to false, obviously.
|
|
78
90
|
(0, react_1.useEffect)(function () {
|
|
79
|
-
return function () {
|
|
91
|
+
return function () {
|
|
92
|
+
return setShowActionsInParent && setShowActionsInParent(false);
|
|
93
|
+
};
|
|
80
94
|
}, []);
|
|
81
95
|
var _h = (0, usePopOutOfOverflowHiddenParent_1.usePopOutOfOverflowHiddenParent)(popOutOfOverflowHiddenParent), fixPos = _h.fixPos, applyFixedPos = _h.applyFixedPos, removeFixedPos = _h.removeFixedPos, trackerRef = _h.trackerRef;
|
|
82
96
|
var genLighbox = function () {
|
|
83
97
|
var _a, _b;
|
|
84
|
-
return (react_1.default.createElement(styled_1.StyledActionsDropMenu, { id: "dropmenu", align: align, invert: invert, optionsHeight: (_a = getOpsRect()) === null || _a === void 0 ? void 0 : _a.height,
|
|
85
|
-
optionsWidth: (_b = getOpsRect()) === null || _b === void 0 ? void 0 : _b.width, showActions: showActions, fixPos: fixPos },
|
|
98
|
+
return (react_1.default.createElement(styled_1.StyledActionsDropMenu, { id: "dropmenu", align: align, invert: invert, optionsHeight: (_a = getOpsRect()) === null || _a === void 0 ? void 0 : _a.height, optionsWidth: (_b = getOpsRect()) === null || _b === void 0 ? void 0 : _b.width, showActions: showActions, fixPos: fixPos },
|
|
86
99
|
react_1.default.createElement(styled_1.StyledActionMenuOpsWrapper, { invert: invert, align: align, ref: optionsWrapperRef }, actions.map(function (action) {
|
|
87
100
|
return (react_1.default.createElement(ModalConfirmAction_1.ModalConfirmAction, __assign({}, action.confirmAction),
|
|
88
101
|
react_1.default.createElement(styled_1.StyledOption, __assign({}, action, { onClick: function (e) {
|
|
102
|
+
var _a;
|
|
89
103
|
e.preventDefault();
|
|
90
104
|
e.stopPropagation();
|
|
91
|
-
action.onClick
|
|
105
|
+
(_a = action.onClick) === null || _a === void 0 ? void 0 : _a.call(action, e);
|
|
92
106
|
setShowActions(false);
|
|
93
107
|
}, key: action.display, invert: invert }),
|
|
94
108
|
action.icon && genOptionIcon(action.icon),
|
|
@@ -96,7 +110,7 @@ var ActionMenu = function (_a) {
|
|
|
96
110
|
}))));
|
|
97
111
|
};
|
|
98
112
|
return (react_1.default.createElement(styled_1.StyledActionMenu, { ref: actionMenuRef },
|
|
99
|
-
CustomSelectComp ? (react_1.default.createElement(CustomSelectComp, { active: showActions, onClick: function (
|
|
113
|
+
typeof CustomSelectComp === 'function' ? (react_1.default.createElement(CustomSelectComp, { active: showActions, onClick: function () {
|
|
100
114
|
setShowActions(!showActions);
|
|
101
115
|
} })) : (react_1.default.createElement(ButtonComp, __assign({}, buttonSize, { icon: icon, iconSize: iconSize, invert: invert, stopPropagation: true, preventDefault: true, onClick: function (e) {
|
|
102
116
|
setShowActions(!showActions);
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
export const StyledActionMenu: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export const StyledActionMenuTracker: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export declare const StyledActionMenu: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const StyledActionMenuTracker: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
align: "left" | "right" | "center";
|
|
4
|
+
storybookPreview?: boolean;
|
|
5
|
+
}, never>;
|
|
6
|
+
type alignType = "left" | "right" | "center";
|
|
7
|
+
export declare const StyledActionsDropMenu: import("styled-components").StyledComponent<"div", any, {
|
|
8
|
+
align: alignType;
|
|
9
|
+
invert?: boolean;
|
|
10
|
+
optionsHeight?: number;
|
|
11
|
+
optionsWidth?: number;
|
|
12
|
+
showActions: boolean;
|
|
13
|
+
fixPos?: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
};
|
|
17
|
+
}, never>;
|
|
18
|
+
export declare const StyledActionMenuOpsWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
19
|
+
align: "left" | "right" | "center";
|
|
20
|
+
invert?: boolean;
|
|
21
|
+
}, never>;
|
|
22
|
+
export declare const StyledOption: import("styled-components").StyledComponent<"button", any, {
|
|
23
|
+
invert?: boolean;
|
|
24
|
+
}, never>;
|
|
25
|
+
export {};
|
|
@@ -34,17 +34,10 @@ var mixins_1 = require("../../themes/mixins");
|
|
|
34
34
|
var globalVariables_1 = require("../../globalStyles/globalVariables");
|
|
35
35
|
var greyColor5 = themes_1.colors.greyColor5, white = themes_1.colors.white, greyColor10 = themes_1.colors.greyColor10, greyColor70 = themes_1.colors.greyColor70, greyColor100 = themes_1.colors.greyColor100, greyColor80 = themes_1.colors.greyColor80;
|
|
36
36
|
var pointerHeight = 10;
|
|
37
|
-
/**
|
|
38
|
-
* we add bottom, left and right margin on the StyledActionMenuOpsWrapper
|
|
39
|
-
* & increase the width by 20 and height by 10 of StyledActionsDropMenu
|
|
40
|
-
* so that the dropshadow shows (since StyledActionsDropMenu has overflow hidden)
|
|
41
|
-
*
|
|
42
|
-
* this offset needs to be cancelled by the absolute positioning of StyledActionsDropMenu
|
|
43
|
-
*/
|
|
44
37
|
var offset = 10;
|
|
45
38
|
exports.StyledActionMenu = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n width: max-content;\n"], ["\n position: relative;\n width: max-content;\n"])));
|
|
46
39
|
var trackerSize = 5;
|
|
47
|
-
exports.StyledActionMenuTracker = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: ", "px;\n height: ", "px;\n position: absolute;\n ", "\n bottom: 0;\n transform: translateY(100%);\n ", "
|
|
40
|
+
exports.StyledActionMenuTracker = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: ", "px;\n height: ", "px;\n position: absolute;\n ", "\n bottom: 0;\n transform: translateY(100%);\n ", "\n"], ["\n width: ", "px;\n height: ", "px;\n position: absolute;\n ", "\n bottom: 0;\n transform: translateY(100%);\n ", "\n"])), trackerSize, trackerSize, function (_a) {
|
|
48
41
|
var align = _a.align;
|
|
49
42
|
switch (align) {
|
|
50
43
|
case "left":
|
|
@@ -52,14 +45,14 @@ exports.StyledActionMenuTracker = styled_components_1.default.div(templateObject
|
|
|
52
45
|
case "right":
|
|
53
46
|
return (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n right: -", "px;\n "], ["\n right: -", "px;\n "])), offset + trackerSize);
|
|
54
47
|
case "center":
|
|
55
|
-
return (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n left: 1.5rem
|
|
48
|
+
return (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n left: 1.5rem;\n "], ["\n left: 1.5rem;\n "])));
|
|
56
49
|
}
|
|
57
50
|
}, function (_a) {
|
|
58
51
|
var storybookPreview = _a.storybookPreview;
|
|
59
|
-
return storybookPreview && (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["
|
|
52
|
+
return storybookPreview && (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background-color: ", ";\n "], ["\n background-color: ", ";\n "])), themes_1.colors.red);
|
|
60
53
|
});
|
|
61
54
|
exports.StyledActionsDropMenu = styled_components_1.default.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n ", "\n\n z-index: 1001;\n\n ", ";\n overflow: hidden;\n width: ", ";\n height: ", ";\n"], ["\n ", "\n\n z-index: 1001;\n\n ", ";\n overflow: hidden;\n width: ", ";\n height: ", ";\n"])), function (_a) {
|
|
62
|
-
var fixPos = _a.fixPos;
|
|
55
|
+
var fixPos = _a.fixPos, align = _a.align;
|
|
63
56
|
return fixPos
|
|
64
57
|
? (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n position: fixed;\n top: ", "px;\n left: ", "px;\n z-index: 1000;\n ", "\n "], ["\n position: fixed;\n top: ", "px;\n left: ", "px;\n z-index: 1000;\n ", "\n "])), fixPos.y, fixPos.x, function (_a) {
|
|
65
58
|
var align = _a.align;
|
|
@@ -76,12 +69,10 @@ exports.StyledActionsDropMenu = styled_components_1.default.div(templateObject_1
|
|
|
76
69
|
});
|
|
77
70
|
}, (0, mixins_1.transition)("height"), function (_a) {
|
|
78
71
|
var optionsWidth = _a.optionsWidth;
|
|
79
|
-
return optionsWidth + offset * 2
|
|
72
|
+
return (optionsWidth ? "".concat(optionsWidth + offset * 2, "px") : "auto");
|
|
80
73
|
}, function (_a) {
|
|
81
74
|
var showActions = _a.showActions, optionsHeight = _a.optionsHeight;
|
|
82
|
-
return showActions
|
|
83
|
-
? optionsHeight + pointerHeight + offset + "px" || "auto"
|
|
84
|
-
: 0;
|
|
75
|
+
return showActions ? "".concat(optionsHeight ? optionsHeight + pointerHeight + offset : "auto", "px") : "0";
|
|
85
76
|
});
|
|
86
77
|
exports.StyledActionMenuOpsWrapper = styled_components_1.default.div(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n position: absolute;\n bottom: 10px;\n padding: 0.6rem 0;\n ", "\n margin: 0 ", "px;\n\n //pointer outline\n &::after {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n\n ", "\n\n border: 1rem solid transparent;\n border-bottom: 1rem solid\n ", ";\n }\n\n //pointer fill\n &::before {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n ", "\n border: 0.85rem solid transparent;\n border-bottom: 0.85rem solid\n ", ";\n z-index: 1;\n }\n"], ["\n position: absolute;\n bottom: 10px;\n padding: 0.6rem 0;\n ", "\n margin: 0 ", "px;\n\n //pointer outline\n &::after {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n\n ", "\n\n border: 1rem solid transparent;\n border-bottom: 1rem solid\n ", ";\n }\n\n //pointer fill\n &::before {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n ", "\n border: 0.85rem solid transparent;\n border-bottom: 0.85rem solid\n ", ";\n z-index: 1;\n }\n"])), globalVariables_1.globalLightboxStyle, offset, function (_a) {
|
|
87
78
|
var align = _a.align;
|
|
@@ -30,7 +30,7 @@ export interface ButtonProps {
|
|
|
30
30
|
className?: string;
|
|
31
31
|
S?: boolean;
|
|
32
32
|
M?: boolean;
|
|
33
|
-
iconSize?: number;
|
|
33
|
+
iconSize?: number | "S" | "M";
|
|
34
34
|
iconColor?: string;
|
|
35
35
|
iconWeight?: string;
|
|
36
36
|
stopPropagation?: boolean;
|
|
@@ -47,7 +47,7 @@ export declare const ButtonCustom: React.FunctionComponent<ButtonProps>;
|
|
|
47
47
|
export declare const ButtonGhost: React.FunctionComponent<ButtonProps>;
|
|
48
48
|
interface UploadButtonProps {
|
|
49
49
|
mutilple?: boolean;
|
|
50
|
-
onChange
|
|
50
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
51
51
|
variant?: string;
|
|
52
52
|
id?: string;
|
|
53
53
|
accept?: string;
|
|
@@ -1,20 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type alignActionsType = "left" | "right" | "center";
|
|
3
|
+
export interface ModalProps {
|
|
4
|
+
title: string;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
linkTo?: string;
|
|
6
8
|
desktopWidth?: string;
|
|
7
|
-
headerStyle?:
|
|
8
|
-
subtitle
|
|
9
|
+
headerStyle?: "style1" | "style2";
|
|
10
|
+
subtitle?: string;
|
|
9
11
|
fitToContentHeight?: boolean;
|
|
10
|
-
invert
|
|
11
|
-
overflowVisible
|
|
12
|
+
invert?: boolean;
|
|
13
|
+
overflowVisible?: boolean;
|
|
12
14
|
showActionPanel?: boolean;
|
|
13
15
|
onCloseText?: string;
|
|
14
|
-
onConfirm
|
|
16
|
+
onConfirm?: React.MouseEventHandler<HTMLButtonElement> | React.ReactNode;
|
|
15
17
|
showCloseBtn?: boolean;
|
|
16
18
|
onConfirmText?: string;
|
|
17
19
|
showConfirmBtn?: boolean;
|
|
18
|
-
alignActions?:
|
|
20
|
+
alignActions?: alignActionsType;
|
|
19
21
|
disableHeader?: boolean;
|
|
20
|
-
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @component Renders a modal component with customizable title, content, and actions.
|
|
25
|
+
*
|
|
26
|
+
* - The props object containing the following properties:
|
|
27
|
+
* @prop {string} title: The title of the modal.
|
|
28
|
+
* @prop {() => void} onClose: A callback function to be called when the close button is clicked.
|
|
29
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the modal body.
|
|
30
|
+
* @prop {string} [linkTo]: An optional link for the modal.
|
|
31
|
+
* @prop {string} [desktopWidth]: The width of the modal on desktop screens. Defaults to "80%".
|
|
32
|
+
* @prop {('style1' | 'style2')} [headerStyle]: The style of the modal header. Defaults to "style1".
|
|
33
|
+
* @prop {string} [subtitle]: The subtitle of the modal.
|
|
34
|
+
* @prop {boolean} [fitToContentHeight]: A boolean indicating whether the modal height should be adjusted based on its content. Defaults to false.
|
|
35
|
+
* @prop {boolean} [invert]: A boolean indicating whether to invert the background color of the modal. Defaults to false.
|
|
36
|
+
* @prop {boolean} [overflowVisible]: A boolean indicating whether the modal should render its overflow as visible. Defaults to false.
|
|
37
|
+
* @prop {boolean} [showActionPanel]: A boolean indicating whether to render the action panel. Defaults to false.
|
|
38
|
+
* @prop {string} [onCloseText]: The text to be displayed in the close button. Defaults to "Close".
|
|
39
|
+
* @prop {React.MouseEventHandler<HTMLButtonElement> | React.ReactNode} [onConfirm]: A callback function or node to be rendered instead of the confirm button.
|
|
40
|
+
* @prop {boolean} [showCloseBtn]: A boolean indicating whether to render the close button. Defaults to true.
|
|
41
|
+
* @prop {string} [onConfirmText]: The text to be displayed in the confirm button. Defaults to "Confirm".
|
|
42
|
+
* @prop {boolean} [showConfirmBtn]: A boolean indicating whether to render the confirm button. Defaults to false.
|
|
43
|
+
* @prop {('left' | 'right' | 'center')} [alignActions]: The alignment of the action buttons. Defaults to "right".
|
|
44
|
+
* @prop {boolean} [disableHeader]: A boolean indicating whether to render the header. Defaults to false.
|
|
45
|
+
* @return {ReactElement} The rendered modal component.
|
|
46
|
+
*/
|
|
47
|
+
export declare const Modal: React.FunctionComponent<ModalProps>;
|
|
@@ -45,10 +45,32 @@ var ModalHeaderStyle2_1 = require("./comps/ModalHeaderStyle2");
|
|
|
45
45
|
var styled_1 = require("./styled");
|
|
46
46
|
var Buttons_1 = require("../../Buttons");
|
|
47
47
|
var Divider_1 = require("../../Divider");
|
|
48
|
+
/**
|
|
49
|
+
* @component Renders a modal component with customizable title, content, and actions.
|
|
50
|
+
*
|
|
51
|
+
* - The props object containing the following properties:
|
|
52
|
+
* @prop {string} title: The title of the modal.
|
|
53
|
+
* @prop {() => void} onClose: A callback function to be called when the close button is clicked.
|
|
54
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the modal body.
|
|
55
|
+
* @prop {string} [linkTo]: An optional link for the modal.
|
|
56
|
+
* @prop {string} [desktopWidth]: The width of the modal on desktop screens. Defaults to "80%".
|
|
57
|
+
* @prop {('style1' | 'style2')} [headerStyle]: The style of the modal header. Defaults to "style1".
|
|
58
|
+
* @prop {string} [subtitle]: The subtitle of the modal.
|
|
59
|
+
* @prop {boolean} [fitToContentHeight]: A boolean indicating whether the modal height should be adjusted based on its content. Defaults to false.
|
|
60
|
+
* @prop {boolean} [invert]: A boolean indicating whether to invert the background color of the modal. Defaults to false.
|
|
61
|
+
* @prop {boolean} [overflowVisible]: A boolean indicating whether the modal should render its overflow as visible. Defaults to false.
|
|
62
|
+
* @prop {boolean} [showActionPanel]: A boolean indicating whether to render the action panel. Defaults to false.
|
|
63
|
+
* @prop {string} [onCloseText]: The text to be displayed in the close button. Defaults to "Close".
|
|
64
|
+
* @prop {React.MouseEventHandler<HTMLButtonElement> | React.ReactNode} [onConfirm]: A callback function or node to be rendered instead of the confirm button.
|
|
65
|
+
* @prop {boolean} [showCloseBtn]: A boolean indicating whether to render the close button. Defaults to true.
|
|
66
|
+
* @prop {string} [onConfirmText]: The text to be displayed in the confirm button. Defaults to "Confirm".
|
|
67
|
+
* @prop {boolean} [showConfirmBtn]: A boolean indicating whether to render the confirm button. Defaults to false.
|
|
68
|
+
* @prop {('left' | 'right' | 'center')} [alignActions]: The alignment of the action buttons. Defaults to "right".
|
|
69
|
+
* @prop {boolean} [disableHeader]: A boolean indicating whether to render the header. Defaults to false.
|
|
70
|
+
* @return {ReactElement} The rendered modal component.
|
|
71
|
+
*/
|
|
48
72
|
var Modal = function (_a) {
|
|
49
|
-
var title = _a.title, onClose = _a.onClose, children = _a.children, linkTo = _a.linkTo, _b = _a.desktopWidth, desktopWidth = _b === void 0 ? "80%" : _b, _c = _a.headerStyle, headerStyle = _c === void 0 ? "style1" : _c, subtitle = _a.subtitle,
|
|
50
|
-
_d = _a.fitToContentHeight, // used only in header style 2
|
|
51
|
-
fitToContentHeight = _d === void 0 ? false : _d, invert = _a.invert, overflowVisible = _a.overflowVisible, _e = _a.showActionPanel, showActionPanel = _e === void 0 ? false : _e, _f = _a.onCloseText, onCloseText = _f === void 0 ? "Close" : _f, onConfirm = _a.onConfirm, _g = _a.showCloseBtn, showCloseBtn = _g === void 0 ? true : _g, _h = _a.onConfirmText, onConfirmText = _h === void 0 ? "Confirm" : _h, _j = _a.showConfirmBtn, showConfirmBtn = _j === void 0 ? true : _j, _k = _a.alignActions, alignActions = _k === void 0 ? "right" : _k, _l = _a.disableHeader, disableHeader = _l === void 0 ? false : _l;
|
|
73
|
+
var title = _a.title, onClose = _a.onClose, children = _a.children, linkTo = _a.linkTo, _b = _a.desktopWidth, desktopWidth = _b === void 0 ? "80%" : _b, _c = _a.headerStyle, headerStyle = _c === void 0 ? "style1" : _c, subtitle = _a.subtitle, _d = _a.fitToContentHeight, fitToContentHeight = _d === void 0 ? false : _d, invert = _a.invert, overflowVisible = _a.overflowVisible, _e = _a.showActionPanel, showActionPanel = _e === void 0 ? false : _e, _f = _a.onCloseText, onCloseText = _f === void 0 ? "Close" : _f, onConfirm = _a.onConfirm, _g = _a.showCloseBtn, showCloseBtn = _g === void 0 ? true : _g, _h = _a.onConfirmText, onConfirmText = _h === void 0 ? "Confirm" : _h, _j = _a.showConfirmBtn, showConfirmBtn = _j === void 0 ? true : _j, _k = _a.alignActions, alignActions = _k === void 0 ? "right" : _k, _l = _a.disableHeader, disableHeader = _l === void 0 ? false : _l;
|
|
52
74
|
var screenWidth = (0, useScreenWidth_1.useScreenWidth)();
|
|
53
75
|
var handleClose = function () { return onClose(); };
|
|
54
76
|
var initAnimPos = { marginTop: "100vh", opacity: 0 };
|
|
@@ -56,7 +78,7 @@ var Modal = function (_a) {
|
|
|
56
78
|
var _m = (0, react_1.useState)(endAnimPos), animPos = _m[0], setAnimPos = _m[1];
|
|
57
79
|
(0, react_1.useEffect)(function () {
|
|
58
80
|
document.body.style.overflow = "hidden";
|
|
59
|
-
return function () {
|
|
81
|
+
return function () { document.body.style.overflow = "unset"; };
|
|
60
82
|
}, []);
|
|
61
83
|
var genHeader = function () {
|
|
62
84
|
var headerStyles = {
|
|
@@ -66,12 +88,6 @@ var Modal = function (_a) {
|
|
|
66
88
|
var Comp = headerStyles[headerStyle];
|
|
67
89
|
return (react_1.default.createElement(Comp, { title: title, subtitle: subtitle, setAnimPos: setAnimPos, linkTo: linkTo, onClose: onClose, initAnimPos: initAnimPos, invert: invert }));
|
|
68
90
|
};
|
|
69
|
-
/**
|
|
70
|
-
* 'takeFullScreenOnScroll' messy as it is, it is needed,
|
|
71
|
-
* because header style 1 scrolls up and fixes to the top of screen
|
|
72
|
-
* but header style 2 (hints) stays fixed, 4rem from top of screen
|
|
73
|
-
* this is by design
|
|
74
|
-
*/
|
|
75
91
|
var takeFullScreenOnScroll = ["style1"].indexOf(headerStyle) !== -1
|
|
76
92
|
? true
|
|
77
93
|
: ["style2"].indexOf(headerStyle) !== -1 && false;
|
|
@@ -85,7 +101,7 @@ var Modal = function (_a) {
|
|
|
85
101
|
react_1.default.createElement(styled_1.StyledActionButtonsWrapper, { alignActions: alignActions },
|
|
86
102
|
showConfirmBtn &&
|
|
87
103
|
typeof onConfirm === 'function'
|
|
88
|
-
? react_1.default.createElement(Buttons_1.ButtonPrimary, { onClick: onConfirm }, onConfirmText)
|
|
104
|
+
? react_1.default.createElement(Buttons_1.ButtonPrimary, { onClick: onConfirm }, onConfirmText)
|
|
89
105
|
: onConfirm,
|
|
90
106
|
showCloseBtn && react_1.default.createElement(Buttons_1.ButtonGhost, { onClick: onClose }, onCloseText)))))); };
|
|
91
107
|
return ((0, react_dom_1.createPortal)(react_1.default.createElement(styled_1.StyledModalLargeBg, null,
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { alignActionsType } from ".";
|
|
2
|
+
interface StyledModalLargeContentWrapperProps {
|
|
3
|
+
takeFullScreenOnScroll: boolean;
|
|
4
|
+
desktopWidth?: string;
|
|
5
|
+
}
|
|
6
|
+
interface StyledModalBodyWrapperProps {
|
|
7
|
+
takeFullScreenOnScroll: boolean;
|
|
8
|
+
overflowVisible?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface StyledModalLargeBodyProps {
|
|
11
|
+
takeFullScreenOnScroll: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface StyledActionButtonsWrapperProps {
|
|
14
|
+
alignActions: alignActionsType;
|
|
15
|
+
}
|
|
16
|
+
export declare const StyledModalLargeBg: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {}, never>;
|
|
17
|
+
export declare const StyledModalLargeBgColor: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {}, never>;
|
|
18
|
+
export declare const StyledModalLargeContentWrapper: import("styled-components").StyledComponent<"div", any, StyledModalLargeContentWrapperProps, never>;
|
|
19
|
+
export declare const StyledModalLargeHeader: import("styled-components").StyledComponent<"header", any, {
|
|
20
|
+
invert?: boolean;
|
|
21
|
+
}, never>;
|
|
22
|
+
export declare const StyledModalBodyWrapper: import("styled-components").StyledComponent<"div", any, StyledModalBodyWrapperProps, never>;
|
|
23
|
+
export declare const StyledModalLargeBody: import("styled-components").StyledComponent<"div", any, StyledModalLargeBodyProps, never>;
|
|
24
|
+
export declare const StyledActionButtonsWrapper: import("styled-components").StyledComponent<"div", any, StyledActionButtonsWrapperProps, never>;
|
|
25
|
+
export declare const StyledModalHeaderStyle2Container: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
26
|
+
export declare const StyledModalHeaderStyle2Title: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
27
|
+
export {};
|
|
@@ -35,7 +35,7 @@ var styled_components_1 = __importStar(require("styled-components"));
|
|
|
35
35
|
var black_opacity80 = themes_1.colors.black_opacity80, white = themes_1.colors.white, greyColor5 = themes_1.colors.greyColor5, greyColor15 = themes_1.colors.greyColor15;
|
|
36
36
|
exports.StyledModalLargeBg = (0, styled_components_1.default)(framer_motion_1.motion.div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100vw;\n height: 100%;\n position: fixed;\n left: 0;\n bottom: 0;\n z-index: 999999999;\n overflow-y: auto;\n overflow-x: hidden;\n ", " {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n"], ["\n width: 100vw;\n height: 100%;\n position: fixed;\n left: 0;\n bottom: 0;\n z-index: 999999999;\n overflow-y: auto;\n overflow-x: hidden;\n ", " {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n"])), (0, mixins_1.mediaQuery)("sm"));
|
|
37
37
|
exports.StyledModalLargeBgColor = (0, styled_components_1.default)(framer_motion_1.motion.div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: ", ";\n position: absolute;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n"], ["\n background: ", ";\n position: absolute;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n"])), black_opacity80);
|
|
38
|
-
exports.StyledModalLargeContentWrapper = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 100%;\n margin-top: 4rem;\n background-color: ", ";\n ", "\n
|
|
38
|
+
exports.StyledModalLargeContentWrapper = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 100%;\n margin-top: 4rem;\n background-color: ", ";\n ", "\n ", " {\n margin-top: 0;\n border: 2px solid ", ";\n width: ", ";\n /* min-height: 50vh; */\n max-height: 90vh;\n position: relative;\n display: flex;\n flex-direction: column;\n border-radius: 0.2rem;\n margin: 0 auto;\n }\n"], ["\n width: 100%;\n margin-top: 4rem;\n background-color: ", ";\n ", "\n ", " {\n margin-top: 0;\n border: 2px solid ", ";\n width: ", ";\n /* min-height: 50vh; */\n max-height: 90vh;\n position: relative;\n display: flex;\n flex-direction: column;\n border-radius: 0.2rem;\n margin: 0 auto;\n }\n"])), white, function (_a) {
|
|
39
39
|
var takeFullScreenOnScroll = _a.takeFullScreenOnScroll;
|
|
40
40
|
return takeFullScreenOnScroll
|
|
41
41
|
? (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n /* min-height: calc(100vh - 4rem); */\n "], ["\n /* min-height: calc(100vh - 4rem); */\n "]))) : (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n height: calc(100vh - 4rem);\n display: flex;\n flex-direction: column;\n "], ["\n height: calc(100vh - 4rem);\n display: flex;\n flex-direction: column;\n "])));
|
|
@@ -45,19 +45,19 @@ exports.StyledModalLargeContentWrapper = styled_components_1.default.div(templat
|
|
|
45
45
|
});
|
|
46
46
|
exports.StyledModalLargeHeader = styled_components_1.default.header(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background-color: ", ";\n /* width: 100%; */\n height: 4rem;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0 2rem;\n position: sticky;\n top: 0;\n z-index: 100;\n"], ["\n background-color: ", ";\n /* width: 100%; */\n height: 4rem;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0 2rem;\n position: sticky;\n top: 0;\n z-index: 100;\n"])), function (_a) {
|
|
47
47
|
var invert = _a.invert;
|
|
48
|
-
return invert ? themes_1.colors.greyColor90 : greyColor5;
|
|
48
|
+
return (invert ? themes_1.colors.greyColor90 : greyColor5);
|
|
49
49
|
});
|
|
50
50
|
exports.StyledModalBodyWrapper = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: ", ";\n"], ["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: ", ";\n"])), function (_a) {
|
|
51
51
|
var takeFullScreenOnScroll = _a.takeFullScreenOnScroll, overflowVisible = _a.overflowVisible;
|
|
52
|
-
return overflowVisible ? "unset" : takeFullScreenOnScroll ? "auto" :
|
|
52
|
+
return overflowVisible ? "unset" : takeFullScreenOnScroll ? "auto" : "unset";
|
|
53
53
|
});
|
|
54
54
|
exports.StyledModalLargeBody = styled_components_1.default.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n position: relative;\n display: flex;\n flex-direction: column;\n ", "\n"], ["\n position: relative;\n display: flex;\n flex-direction: column;\n ", "\n"])), function (_a) {
|
|
55
55
|
var takeFullScreenOnScroll = _a.takeFullScreenOnScroll;
|
|
56
56
|
return !takeFullScreenOnScroll && (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n flex: 1;\n overflow: auto;\n "], ["\n flex: 1;\n overflow: auto;\n "])));
|
|
57
57
|
});
|
|
58
|
-
exports.StyledActionButtonsWrapper = styled_components_1.default.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n gap: 1rem;\n display: flex;\n justify-content: ", ";\n padding: 1rem 0;\n padding-left: 2rem;\n padding-right: 0.5rem
|
|
58
|
+
exports.StyledActionButtonsWrapper = styled_components_1.default.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n gap: 1rem;\n display: flex;\n justify-content: ", ";\n padding: 1rem 0;\n padding-left: 2rem;\n padding-right: 0.5rem;\n background-color: white;\n"], ["\n gap: 1rem;\n display: flex;\n justify-content: ", ";\n padding: 1rem 0;\n padding-left: 2rem;\n padding-right: 0.5rem;\n background-color: white;\n"])), function (_a) {
|
|
59
59
|
var alignActions = _a.alignActions;
|
|
60
|
-
return alignActions === "right" ?
|
|
60
|
+
return (alignActions === "right" ? "flex-end" : "");
|
|
61
61
|
});
|
|
62
62
|
exports.StyledModalHeaderStyle2Container = styled_components_1.default.div(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n display: flex;\n border-bottom: 1px solid ", ";\n padding: 1rem 2rem;\n position: relative;\n"], ["\n display: flex;\n border-bottom: 1px solid ", ";\n padding: 1rem 2rem;\n position: relative;\n"])), greyColor15);
|
|
63
63
|
exports.StyledModalHeaderStyle2Title = styled_components_1.default.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n padding-top: 1rem;\n display: flex;\n flex-grow: 1;\n gap: 1.5rem;\n justify-content: space-between;\n align-items: center;\n"], ["\n padding-top: 1rem;\n display: flex;\n flex-grow: 1;\n gap: 1.5rem;\n justify-content: space-between;\n align-items: center;\n"])));
|
|
@@ -1,12 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React, { FunctionComponent } from "react";
|
|
2
|
+
import { alignActionsType } from "../Modal";
|
|
3
|
+
export interface ModalConfirmProps {
|
|
4
|
+
title?: string;
|
|
5
|
+
subTitle?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
onClose: () => void;
|
|
6
8
|
onCloseText?: string;
|
|
7
9
|
showConfirmBtn?: boolean;
|
|
8
10
|
showCloseBtn?: boolean;
|
|
9
|
-
onConfirm:
|
|
11
|
+
onConfirm: React.MouseEventHandler<HTMLButtonElement>;
|
|
10
12
|
onConfirmText?: string;
|
|
11
|
-
alignActions?:
|
|
12
|
-
}
|
|
13
|
+
alignActions?: alignActionsType;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @component Renders a modal confirmation component with customizable text, buttons and styling.
|
|
17
|
+
*
|
|
18
|
+
* - The props object containing the following properties:
|
|
19
|
+
* @prop {string} title: The title to be displayed in the modal.
|
|
20
|
+
* @prop {string} subTitle: The subtitle to be displayed in the modal.
|
|
21
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the modal.
|
|
22
|
+
* @prop {() => void} onClose: A function to call when the close button is clicked.
|
|
23
|
+
* @prop {string} onCloseText: The text to be displayed on the close button.
|
|
24
|
+
* @prop {boolean} showConfirmBtn: A boolean indicating whether to show the confirm button.
|
|
25
|
+
* @prop {boolean} showCloseBtn: A boolean indicating whether to show the close button.
|
|
26
|
+
* @prop {React.MouseEventHandler<HTMLButtonElement>} onConfirm: A function to call when the confirm button is clicked.
|
|
27
|
+
* @prop {string} onConfirmText: The text to be displayed on the confirm button.
|
|
28
|
+
* @prop {alignActionsType} alignActions: The alignment of the action buttons.
|
|
29
|
+
* @return {ReactElement} The rendered modal confirm component.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ModalConfirm: FunctionComponent<ModalConfirmProps>;
|
|
@@ -31,6 +31,22 @@ var useScreenWidth_1 = require("../../../utils/customHooks/useScreenWidth");
|
|
|
31
31
|
var Buttons_1 = require("../../Buttons");
|
|
32
32
|
var Typo_1 = require("../../Typo");
|
|
33
33
|
var styled_1 = require("./styled");
|
|
34
|
+
/**
|
|
35
|
+
* @component Renders a modal confirmation component with customizable text, buttons and styling.
|
|
36
|
+
*
|
|
37
|
+
* - The props object containing the following properties:
|
|
38
|
+
* @prop {string} title: The title to be displayed in the modal.
|
|
39
|
+
* @prop {string} subTitle: The subtitle to be displayed in the modal.
|
|
40
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the modal.
|
|
41
|
+
* @prop {() => void} onClose: A function to call when the close button is clicked.
|
|
42
|
+
* @prop {string} onCloseText: The text to be displayed on the close button.
|
|
43
|
+
* @prop {boolean} showConfirmBtn: A boolean indicating whether to show the confirm button.
|
|
44
|
+
* @prop {boolean} showCloseBtn: A boolean indicating whether to show the close button.
|
|
45
|
+
* @prop {React.MouseEventHandler<HTMLButtonElement>} onConfirm: A function to call when the confirm button is clicked.
|
|
46
|
+
* @prop {string} onConfirmText: The text to be displayed on the confirm button.
|
|
47
|
+
* @prop {alignActionsType} alignActions: The alignment of the action buttons.
|
|
48
|
+
* @return {ReactElement} The rendered modal confirm component.
|
|
49
|
+
*/
|
|
34
50
|
var ModalConfirm = function (_a) {
|
|
35
51
|
var title = _a.title, subTitle = _a.subTitle, children = _a.children, onClose = _a.onClose, _b = _a.onCloseText, onCloseText = _b === void 0 ? "Cancel" : _b, _c = _a.showConfirmBtn, showConfirmBtn = _c === void 0 ? true : _c, _d = _a.showCloseBtn, showCloseBtn = _d === void 0 ? true : _d, onConfirm = _a.onConfirm, _e = _a.onConfirmText, onConfirmText = _e === void 0 ? "Delete" : _e, _f = _a.alignActions, alignActions = _f === void 0 ? "left" : _f;
|
|
36
52
|
var screenWidth = (0, useScreenWidth_1.useScreenWidth)();
|
|
@@ -39,7 +55,7 @@ var ModalConfirm = function (_a) {
|
|
|
39
55
|
var _g = (0, react_1.useState)(endAnimPos), animPos = _g[0], setAnimPos = _g[1];
|
|
40
56
|
(0, react_1.useEffect)(function () {
|
|
41
57
|
document.body.style.overflow = "hidden";
|
|
42
|
-
return function () {
|
|
58
|
+
return function () { document.body.style.overflow = "unset"; };
|
|
43
59
|
}, []);
|
|
44
60
|
var SubTitleText = screenWidth >= (0, mixins_1.getBreakPoint)('sm') ? Typo_1.SANS_4 : Typo_1.SANS_3;
|
|
45
61
|
var genModalContents = function () { return (react_1.default.createElement(react_1.Fragment, null,
|
|
@@ -54,17 +70,13 @@ var ModalConfirm = function (_a) {
|
|
|
54
70
|
react_1.default.createElement(styled_1.StyledFlexWrapper, { style: { marginTop: (children) && "2rem" }, alignActions: alignActions },
|
|
55
71
|
showConfirmBtn && react_1.default.createElement(Buttons_1.ButtonPrimary, { onClick: onConfirm }, onConfirmText),
|
|
56
72
|
showCloseBtn && react_1.default.createElement(Buttons_1.ButtonSecondary, { onClick: onClose }, onCloseText))))); };
|
|
57
|
-
return ((0, react_dom_1.createPortal)(react_1.default.createElement(styled_1.StyledModalConfirm, { initial: { opacity: initAnimPos.opacity }, animate: { opacity: animPos.opacity }, transition: { type: "tween", ease: "easeOut" }, onClick: function () { return onClose(); } }, screenWidth < (0, mixins_1.getBreakPoint)("sm") ? (react_1.default.createElement(styled_1.StyledModalConfirmContentWrapper, { initial: initAnimPos, animate: animPos, transition: {
|
|
73
|
+
return ((0, react_dom_1.createPortal)(react_1.default.createElement(styled_1.StyledModalConfirm, { initial: { opacity: initAnimPos.opacity }, animate: { opacity: animPos.opacity }, transition: { type: "tween", ease: "easeOut" }, onClick: function () { return onClose(); } }, screenWidth < (0, mixins_1.getBreakPoint)("sm") ? (react_1.default.createElement(styled_1.StyledModalConfirmContentWrapper, { initial: { marginTop: initAnimPos.marginTop, translateY: initAnimPos.translateY }, animate: { marginTop: animPos.marginTop, translateY: animPos.translateY }, transition: {
|
|
58
74
|
type: "tween",
|
|
59
75
|
ease: "easeOut",
|
|
60
76
|
}, onAnimationComplete: function () {
|
|
61
77
|
if (animPos.marginTop === initAnimPos.marginTop)
|
|
62
78
|
onClose();
|
|
63
|
-
}, onClick: function (e) { return e.stopPropagation(); } }, genModalContents())) : (react_1.default.createElement(styled_1.StyledModalConfirmContentWrapper
|
|
64
|
-
// style={{ width: "100%" }}
|
|
65
|
-
, {
|
|
66
|
-
// style={{ width: "100%" }}
|
|
67
|
-
initial: {
|
|
79
|
+
}, onClick: function (e) { return e.stopPropagation(); } }, genModalContents())) : (react_1.default.createElement(styled_1.StyledModalConfirmContentWrapper, { initial: {
|
|
68
80
|
opacity: initAnimPos.opacity,
|
|
69
81
|
marginTop: initAnimPos.marginTop,
|
|
70
82
|
}, animate: {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
1
|
+
import { alignActionsType } from "../Modal";
|
|
2
|
+
interface StyledFlexWrapperProps {
|
|
3
|
+
alignActions: alignActionsType;
|
|
4
|
+
}
|
|
5
|
+
export declare const StyledModalConfirm: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {}, never>;
|
|
6
|
+
export declare const StyledModalConfirmContentWrapper: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {}, never>;
|
|
7
|
+
export declare const StyledModalConfirmContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const StyledModalConfirmClose: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const StyledModalConfirmContentSubtitle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
+
export declare const StyledFlexWrapper: import("styled-components").StyledComponent<"div", any, StyledFlexWrapperProps, never>;
|
|
11
|
+
export {};
|
|
@@ -34,13 +34,13 @@ var framer_motion_1 = require("framer-motion");
|
|
|
34
34
|
var styled_components_1 = __importStar(require("styled-components"));
|
|
35
35
|
var white = themes_1.colors.white, greyColor100_opacity70 = themes_1.colors.greyColor100_opacity70;
|
|
36
36
|
var ModalStyles = (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n position: fixed;\n top: 0;\n left: 0;\n background: ", ";\n z-index: 999999999;\n"], ["\n width: 100%;\n height: 100%;\n position: fixed;\n top: 0;\n left: 0;\n background: ", ";\n z-index: 999999999;\n"])), greyColor100_opacity70);
|
|
37
|
-
exports.StyledModalConfirm = (0, styled_components_1.default)(framer_motion_1.motion.div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n
|
|
38
|
-
exports.StyledModalConfirmContentWrapper = (0, styled_components_1.default)(framer_motion_1.motion.div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 100%;\n position: absolute;\n bottom: 0;\n background-color: ", ";\n
|
|
39
|
-
exports.StyledModalConfirmContent = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n padding: 0 2rem 2rem 2rem;\n
|
|
37
|
+
exports.StyledModalConfirm = (0, styled_components_1.default)(framer_motion_1.motion.div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n ", " {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n"], ["\n ", "\n ", " {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n"])), ModalStyles, (0, mixins_1.mediaQuery)("sm"));
|
|
38
|
+
exports.StyledModalConfirmContentWrapper = (0, styled_components_1.default)(framer_motion_1.motion.div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 100%;\n position: absolute;\n bottom: 0;\n background-color: ", ";\n ", " {\n border: 2px solid ", ";\n width: 50vw;\n position: relative;\n border-radius: 0.2rem;\n }\n"], ["\n width: 100%;\n position: absolute;\n bottom: 0;\n background-color: ", ";\n ", " {\n border: 2px solid ", ";\n width: 50vw;\n position: relative;\n border-radius: 0.2rem;\n }\n"])), white, (0, mixins_1.mediaQuery)("sm"), white);
|
|
39
|
+
exports.StyledModalConfirmContent = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n padding: 0 2rem 2rem 2rem;\n ", " {\n position: relative;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n padding: 0 3rem 3rem 3rem;\n }\n"], ["\n position: relative;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n padding: 0 2rem 2rem 2rem;\n ", " {\n position: relative;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n padding: 0 3rem 3rem 3rem;\n }\n"])), (0, mixins_1.mediaQuery)("sm"));
|
|
40
40
|
exports.StyledModalConfirmClose = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 100%;\n display: flex;\n justify-content: flex-end;\n"], ["\n width: 100%;\n display: flex;\n justify-content: flex-end;\n"])));
|
|
41
41
|
exports.StyledModalConfirmContentSubtitle = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n margin-top: 0.5rem;\n"], ["\n margin-top: 0.5rem;\n"])));
|
|
42
42
|
exports.StyledFlexWrapper = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n justify-content: ", ";\n gap: 1rem;\n align-items: center;\n"], ["\n display: flex;\n justify-content: ", ";\n gap: 1rem;\n align-items: center;\n"])), function (_a) {
|
|
43
43
|
var alignActions = _a.alignActions;
|
|
44
|
-
return alignActions === "right" ?
|
|
44
|
+
return (alignActions === "right" ? "flex-end" : "");
|
|
45
45
|
});
|
|
46
46
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { FunctionComponent, ReactNode } from "react";
|
|
2
|
+
export interface ModalConfirmActionProps {
|
|
3
|
+
children: ReactNode;
|
|
3
4
|
enabled?: boolean;
|
|
4
5
|
title?: string;
|
|
5
|
-
subtitle
|
|
6
|
-
onConfirmText
|
|
7
|
-
onCloseText
|
|
8
|
-
}
|
|
9
|
-
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
onConfirmText?: string;
|
|
8
|
+
onCloseText?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @component Renders a modal confirmation action component with customizable text, buttons and styling.
|
|
12
|
+
*
|
|
13
|
+
* - The props object containing the following properties:
|
|
14
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the button.
|
|
15
|
+
* @prop {boolean} enabled: A boolean indicating whether the component is enabled or not. Defaults to false.
|
|
16
|
+
* @prop {string} title: The title to be displayed in the modal.
|
|
17
|
+
* @prop {string} subtitle: The subtitle to be displayed in the modal.
|
|
18
|
+
* @prop {string} onConfirmText: The text to be displayed in the confirm button. Defaults to "Confirm".
|
|
19
|
+
* @prop {string} onCloseText: The text to be displayed in the close button. Defaults to "Cancel".
|
|
20
|
+
* @return {ReactElement} The rendered modal confirm action component.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ModalConfirmAction: FunctionComponent<ModalConfirmActionProps>;
|
|
@@ -26,26 +26,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.ModalConfirmAction = void 0;
|
|
27
27
|
var react_1 = __importStar(require("react"));
|
|
28
28
|
var ModalConfirm_1 = require("../../ModalConfirm");
|
|
29
|
-
|
|
30
|
-
@
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
/**
|
|
30
|
+
* @component Renders a modal confirmation action component with customizable text, buttons and styling.
|
|
31
|
+
*
|
|
32
|
+
* - The props object containing the following properties:
|
|
33
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the button.
|
|
34
|
+
* @prop {boolean} enabled: A boolean indicating whether the component is enabled or not. Defaults to false.
|
|
35
|
+
* @prop {string} title: The title to be displayed in the modal.
|
|
36
|
+
* @prop {string} subtitle: The subtitle to be displayed in the modal.
|
|
37
|
+
* @prop {string} onConfirmText: The text to be displayed in the confirm button. Defaults to "Confirm".
|
|
38
|
+
* @prop {string} onCloseText: The text to be displayed in the close button. Defaults to "Cancel".
|
|
39
|
+
* @return {ReactElement} The rendered modal confirm action component.
|
|
40
|
+
*/
|
|
41
|
+
var ModalConfirmAction = function (_a) {
|
|
42
|
+
var children = _a.children, _b = _a.enabled, enabled = _b === void 0 ? false : _b, _c = _a.title, title = _c === void 0 ? "Are you sure you want to do this action?" : _c, subtitle = _a.subtitle, onConfirmText = _a.onConfirmText, onCloseText = _a.onCloseText;
|
|
41
43
|
var _d = (0, react_1.useState)(false), modal = _d[0], setModal = _d[1];
|
|
42
44
|
var callback;
|
|
43
45
|
var handleParentClick = function (e) {
|
|
44
46
|
// usecase: actionMenu in table
|
|
45
47
|
e.stopPropagation();
|
|
46
|
-
setModal(
|
|
48
|
+
setModal(true);
|
|
47
49
|
};
|
|
48
|
-
var handleConfirm = function (
|
|
50
|
+
var handleConfirm = function () {
|
|
49
51
|
callback(modal);
|
|
50
52
|
setModal(false);
|
|
51
53
|
};
|
|
@@ -59,7 +61,7 @@ function ModalConfirmAction(_a) {
|
|
|
59
61
|
if (react_1.default.isValidElement(child)) {
|
|
60
62
|
// Access props of the child component
|
|
61
63
|
callback = child.props.onClick;
|
|
62
|
-
return react_1.
|
|
64
|
+
return (0, react_1.cloneElement)(child, { onClick: handleParentClick });
|
|
63
65
|
}
|
|
64
66
|
// Return non-component children as they are
|
|
65
67
|
return child;
|
|
@@ -69,5 +71,5 @@ function ModalConfirmAction(_a) {
|
|
|
69
71
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
70
72
|
modal ? (react_1.default.createElement(ModalConfirm_1.ModalConfirm, { title: title, subTitle: subtitle, onClose: function () { return setModal(false); }, onConfirmText: onConfirmText, onConfirm: handleConfirm, onCloseText: onCloseText })) : null,
|
|
71
73
|
getChildren()));
|
|
72
|
-
}
|
|
74
|
+
};
|
|
73
75
|
exports.ModalConfirmAction = ModalConfirmAction;
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import React, { FunctionComponent } from "react";
|
|
2
|
+
import { alignActionsType } from "../../Modal";
|
|
3
|
+
export interface ModalFormsProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
SUBMIT_BUTTON: React.ReactNode;
|
|
6
|
+
title: string;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
alignActions?: alignActionsType;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @component Renders a form modal component with customizable submit button text and styling.
|
|
12
|
+
*
|
|
13
|
+
* - The props object containing the following properties:
|
|
14
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the form modal.
|
|
15
|
+
* @prop {React.ReactNode} SUBMIT_BUTTON: The text to be displayed in the submit button.
|
|
16
|
+
* @prop {string} title: The title of the form modal.
|
|
17
|
+
* @prop {() => void} onClose: A function to be called when the form modal is closed.
|
|
18
|
+
* @prop {'left' | 'right'} alignActions: The alignment of the actions buttons in the form modal. Defaults to "left".
|
|
19
|
+
* @return {ReactElement} The rendered form modal component.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ModalForms: FunctionComponent<ModalFormsProps>;
|
|
@@ -6,10 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ModalForms = void 0;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
8
|
var Modal_1 = require("../../Modal");
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @component Renders a form modal component with customizable submit button text and styling.
|
|
11
|
+
*
|
|
12
|
+
* - The props object containing the following properties:
|
|
13
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the form modal.
|
|
14
|
+
* @prop {React.ReactNode} SUBMIT_BUTTON: The text to be displayed in the submit button.
|
|
15
|
+
* @prop {string} title: The title of the form modal.
|
|
16
|
+
* @prop {() => void} onClose: A function to be called when the form modal is closed.
|
|
17
|
+
* @prop {'left' | 'right'} alignActions: The alignment of the actions buttons in the form modal. Defaults to "left".
|
|
18
|
+
* @return {ReactElement} The rendered form modal component.
|
|
19
|
+
*/
|
|
10
20
|
var ModalForms = function (_a) {
|
|
11
21
|
var children = _a.children, SUBMIT_BUTTON = _a.SUBMIT_BUTTON, title = _a.title, onClose = _a.onClose, alignActions = _a.alignActions;
|
|
12
|
-
console.log({ SUBMIT_BUTTON: SUBMIT_BUTTON });
|
|
13
|
-
return (react_1.default.createElement(Modal_1.Modal, { fitToContentHeight: true, title: title, showActionPanel: true, onClose: onClose, onCloseText: "Cancel", desktopWidth: "600px", onConfirm: SUBMIT_BUTTON, alignActions: alignActions ||
|
|
22
|
+
// console.log({ SUBMIT_BUTTON: SUBMIT_BUTTON });
|
|
23
|
+
return (react_1.default.createElement(Modal_1.Modal, { fitToContentHeight: true, title: title, showActionPanel: true, onClose: onClose, onCloseText: "Cancel", desktopWidth: "600px", onConfirm: SUBMIT_BUTTON, alignActions: alignActions || "left" }, children));
|
|
14
24
|
};
|
|
15
25
|
exports.ModalForms = ModalForms;
|
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React, { FunctionComponent, ReactNode } from "react";
|
|
2
|
+
import { alignActionsType } from "../../Modal";
|
|
3
|
+
export interface ModalSmallProps {
|
|
4
|
+
title: string;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
invert?: boolean;
|
|
7
|
+
showActionPanel?: boolean;
|
|
6
8
|
onCloseText?: string;
|
|
7
|
-
onConfirm
|
|
9
|
+
onConfirm?: React.ReactNode;
|
|
8
10
|
onConfirmText?: string;
|
|
9
11
|
overflowVisible?: boolean;
|
|
10
12
|
fitToContentHeight?: boolean;
|
|
11
|
-
alignActions?:
|
|
13
|
+
alignActions?: alignActionsType;
|
|
12
14
|
desktopWidth?: string;
|
|
13
|
-
children:
|
|
14
|
-
}
|
|
15
|
-
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @component Renders a small modal component with customizable content and actions.
|
|
19
|
+
*
|
|
20
|
+
* - The props object containing the following properties:
|
|
21
|
+
* @prop {string} title: The title of the modal.
|
|
22
|
+
* @prop {() => void} onClose: A function to be called when the modal is closed.
|
|
23
|
+
* @prop {boolean} invert: A boolean indicating whether to invert the modal colors. Defaults to false.
|
|
24
|
+
* @prop {boolean} showActionPanel: A boolean indicating whether to show the modal actions panel. Defaults to true.
|
|
25
|
+
* @prop {string} onCloseText: The text to be displayed in the close button. Defaults to "Close".
|
|
26
|
+
* @prop {React.ReactNode} onConfirm: A React node to be rendered as the confirm button. Defaults to none.
|
|
27
|
+
* @prop {string} onConfirmText: The text to be displayed in the confirm button. Defaults to "Confirm".
|
|
28
|
+
* @prop {boolean} overflowVisible: A boolean indicating whether to override the overflow: hidden styling on the modal. Defaults to true.
|
|
29
|
+
* @prop {boolean} fitToContentHeight: A boolean indicating whether to fit the modal to the content height. Defaults to true.
|
|
30
|
+
* @prop {alignActionsType} alignActions: A string indicating how the modal actions buttons should be aligned. Defaults to "right".
|
|
31
|
+
* @prop {string} desktopWidth: A string indicating the width of the modal on desktop views. Defaults to "50vw".
|
|
32
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the modal.
|
|
33
|
+
* @return {ReactElement} The rendered modal component.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ModalSmall: FunctionComponent<ModalSmallProps>;
|
|
@@ -6,6 +6,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ModalSmall = void 0;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
8
|
var Modal_1 = require("../../Modal");
|
|
9
|
+
/**
|
|
10
|
+
* @component Renders a small modal component with customizable content and actions.
|
|
11
|
+
*
|
|
12
|
+
* - The props object containing the following properties:
|
|
13
|
+
* @prop {string} title: The title of the modal.
|
|
14
|
+
* @prop {() => void} onClose: A function to be called when the modal is closed.
|
|
15
|
+
* @prop {boolean} invert: A boolean indicating whether to invert the modal colors. Defaults to false.
|
|
16
|
+
* @prop {boolean} showActionPanel: A boolean indicating whether to show the modal actions panel. Defaults to true.
|
|
17
|
+
* @prop {string} onCloseText: The text to be displayed in the close button. Defaults to "Close".
|
|
18
|
+
* @prop {React.ReactNode} onConfirm: A React node to be rendered as the confirm button. Defaults to none.
|
|
19
|
+
* @prop {string} onConfirmText: The text to be displayed in the confirm button. Defaults to "Confirm".
|
|
20
|
+
* @prop {boolean} overflowVisible: A boolean indicating whether to override the overflow: hidden styling on the modal. Defaults to true.
|
|
21
|
+
* @prop {boolean} fitToContentHeight: A boolean indicating whether to fit the modal to the content height. Defaults to true.
|
|
22
|
+
* @prop {alignActionsType} alignActions: A string indicating how the modal actions buttons should be aligned. Defaults to "right".
|
|
23
|
+
* @prop {string} desktopWidth: A string indicating the width of the modal on desktop views. Defaults to "50vw".
|
|
24
|
+
* @prop {React.ReactNode} children: The content to be rendered inside the modal.
|
|
25
|
+
* @return {ReactElement} The rendered modal component.
|
|
26
|
+
*/
|
|
9
27
|
var ModalSmall = function (_a) {
|
|
10
28
|
var title = _a.title, onClose = _a.onClose, invert = _a.invert, showActionPanel = _a.showActionPanel, _b = _a.onCloseText, onCloseText = _b === void 0 ? "Close" : _b, onConfirm = _a.onConfirm, _c = _a.onConfirmText, onConfirmText = _c === void 0 ? "Confirm" : _c, _d = _a.overflowVisible, overflowVisible = _d === void 0 ? true : _d, _e = _a.fitToContentHeight, fitToContentHeight = _e === void 0 ? true : _e, _f = _a.alignActions, alignActions = _f === void 0 ? "right" : _f, _g = _a.desktopWidth, desktopWidth = _g === void 0 ? "50vw" : _g, children = _a.children;
|
|
11
29
|
return (react_1.default.createElement(Modal_1.Modal, { title: title, onClose: onClose, onCloseText: onCloseText, onConfirm: onConfirm, onConfirmText: onConfirmText, desktopWidth: desktopWidth, overflowVisible: overflowVisible, fitToContentHeight: fitToContentHeight, invert: invert, showActionPanel: showActionPanel, alignActions: alignActions, children: react_1.default.createElement("div", { style: { padding: "2rem" } }, children) }));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const PercentBarChart: ({ data: _data, title, valuePath,
|
|
2
|
+
export declare const PercentBarChart: ({ data: _data, title, valuePath, display, onClick, colors }: {
|
|
3
3
|
data: any;
|
|
4
4
|
valuePath: string;
|
|
5
5
|
title?: string;
|
|
6
|
-
|
|
6
|
+
display: string;
|
|
7
7
|
onClick?: (name: string) => void;
|
|
8
8
|
colors?: string[];
|
|
9
9
|
}) => React.JSX.Element;
|
|
@@ -47,6 +47,7 @@ exports.PercentBarChart = void 0;
|
|
|
47
47
|
var react_1 = __importStar(require("react"));
|
|
48
48
|
var recharts_1 = require("recharts");
|
|
49
49
|
var Typo_1 = require("../Typo");
|
|
50
|
+
var colors_1 = require("../../themes/colors");
|
|
50
51
|
var chartColors = [
|
|
51
52
|
"#F53D65",
|
|
52
53
|
"#666666",
|
|
@@ -62,13 +63,13 @@ var chartColors = [
|
|
|
62
63
|
var renderCustomizedLabel = function (_a) {
|
|
63
64
|
var y = _a.y, value = _a.value, opacity = _a.opacity;
|
|
64
65
|
var offset = 12;
|
|
65
|
-
return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, x: 0, y: y - offset, fill: "black", textAnchor: "start", dominantBaseline: "middle" }, value));
|
|
66
|
+
return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, x: 0, y: y - offset, fill: "black", textAnchor: "start", dominantBaseline: "middle", className: 'SANS_2' }, value));
|
|
66
67
|
};
|
|
67
68
|
var renderCustomizedValue = function (_a) {
|
|
68
69
|
var y = _a.y, width = _a.width, height = _a.height, value = _a.value, suffix = _a.suffix, opacity = _a.opacity;
|
|
69
70
|
var xOffset = 6;
|
|
70
71
|
var yOffset = 2;
|
|
71
|
-
return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, fontWeight: "600", x: width + xOffset, y: y + height / 2 + yOffset, fill: "black", textAnchor: "start", dominantBaseline: "middle" }, "".concat(value).concat(suffix || "")));
|
|
72
|
+
return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, fontWeight: "600", x: width + xOffset, y: y + height / 2 + yOffset, fill: "black", textAnchor: "start", dominantBaseline: "middle", className: 'SANS_2' }, "".concat(value).concat(suffix || "")));
|
|
72
73
|
};
|
|
73
74
|
var _dataSample = [
|
|
74
75
|
{ name: "AAA/A1+", value: 72.3, Type: 0 },
|
|
@@ -77,51 +78,52 @@ var _dataSample = [
|
|
|
77
78
|
{ name: "AA+", value: 5.63, Type: 3 },
|
|
78
79
|
];
|
|
79
80
|
var PercentBarChart = function (_a) {
|
|
80
|
-
var _b = _a.data, _data = _b === void 0 ? _dataSample : _b, title = _a.title, _c = _a.valuePath, valuePath = _c === void 0 ? "value" : _c, _d = _a.
|
|
81
|
+
var _b = _a.data, _data = _b === void 0 ? _dataSample : _b, title = _a.title, _c = _a.valuePath, valuePath = _c === void 0 ? "value" : _c, _d = _a.display, display = _d === void 0 ? "name" : _d, onClick = _a.onClick, _e = _a.colors, colors = _e === void 0 ? chartColors : _e;
|
|
81
82
|
var data = (0, react_1.useMemo)(function () {
|
|
82
83
|
var finalData = __spreadArray([], _data, true);
|
|
83
|
-
finalData = finalData.map(function (d, i) { return (__assign(__assign({}, d), { value: d[valuePath], name: d[
|
|
84
|
+
finalData = finalData.map(function (d, i) { return (__assign(__assign({}, d), { value: d[valuePath], name: d[display], color: (colors)[i % (colors).length] })); });
|
|
84
85
|
finalData.sort(function (a, b) {
|
|
85
86
|
return Number(b.value || 0) - Number(a.value || 0);
|
|
86
87
|
});
|
|
87
88
|
return finalData;
|
|
88
|
-
}, [_data,
|
|
89
|
+
}, [_data, display, valuePath]);
|
|
89
90
|
var _f = (0, react_1.useState)(undefined), activeBar = _f[0], setActiveBar = _f[1];
|
|
90
91
|
var changeBarOpacityFn = function (name) {
|
|
91
92
|
return activeBar && activeBar !== name ? 0.4 : 1;
|
|
92
93
|
};
|
|
93
|
-
return (react_1.default.createElement("div", { style: {
|
|
94
|
-
title && react_1.default.createElement(Typo_1.SANS_4_5,
|
|
95
|
-
react_1.default.createElement(
|
|
96
|
-
react_1.default.createElement(recharts_1.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number" }),
|
|
103
|
-
react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category", width: 250, dataKey: id }),
|
|
104
|
-
react_1.default.createElement(recharts_1.Bar, { style: { cursor: "pointer" }, dataKey: "value", unit: "%", onMouseOver: function (args) { return setActiveBar(args[id]); }, onMouseOut: function () { return setActiveBar(undefined); }, onMouseDown: function (args) {
|
|
105
|
-
setActiveBar(args[id]);
|
|
106
|
-
onClick(args[id]);
|
|
94
|
+
return (react_1.default.createElement("div", { style: { border: "1px solid ".concat(colors_1.colors.greyColor15) } },
|
|
95
|
+
title && react_1.default.createElement(Typo_1.SANS_4_5, { style: { padding: "2rem", paddingBottom: "0" }, semibold: true }, title),
|
|
96
|
+
react_1.default.createElement("div", { style: { height: "".concat(80 * data.length, "px"), width: "100%", padding: "2rem", paddingTop: 0 } },
|
|
97
|
+
react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: "100%" },
|
|
98
|
+
react_1.default.createElement(recharts_1.BarChart, { width: 500, height: 500, barCategoryGap: 20, data: data, layout: "vertical", margin: {
|
|
99
|
+
top: 15,
|
|
100
|
+
right: 60,
|
|
101
|
+
left: 0,
|
|
102
|
+
bottom: 0,
|
|
107
103
|
} },
|
|
108
|
-
react_1.default.createElement(recharts_1.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
104
|
+
react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number" }),
|
|
105
|
+
react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category", width: 250, dataKey: display }),
|
|
106
|
+
react_1.default.createElement(recharts_1.Bar, { style: { cursor: "pointer" }, dataKey: "value", unit: "%", onMouseOver: function (args) { return setActiveBar(args[display]); }, onMouseOut: function () { return setActiveBar(undefined); }, onMouseDown: function (args) {
|
|
107
|
+
setActiveBar(args[display]);
|
|
108
|
+
onClick(args[display]);
|
|
109
|
+
} },
|
|
110
|
+
react_1.default.createElement(recharts_1.LabelList, { dataKey: display, position: "top", content: function (props) {
|
|
111
|
+
return renderCustomizedLabel({
|
|
112
|
+
y: props.y,
|
|
113
|
+
value: props.value,
|
|
114
|
+
opacity: changeBarOpacityFn(props[display]),
|
|
115
|
+
});
|
|
116
|
+
} }),
|
|
117
|
+
react_1.default.createElement(recharts_1.LabelList, { dataKey: "value", offset: 0, content: function (props) {
|
|
118
|
+
return renderCustomizedValue({
|
|
119
|
+
y: props.y,
|
|
120
|
+
width: props.width,
|
|
121
|
+
height: props.height,
|
|
122
|
+
value: props.value,
|
|
123
|
+
suffix: "%",
|
|
124
|
+
opacity: changeBarOpacityFn(props[display]),
|
|
125
|
+
});
|
|
126
|
+
} }),
|
|
127
|
+
data.map(function (entry, index) { return (react_1.default.createElement(recharts_1.Cell, { opacity: changeBarOpacityFn(entry[display]), key: "cell-".concat(index), height: 30, fill: entry.color })); })))))));
|
|
126
128
|
};
|
|
127
129
|
exports.PercentBarChart = PercentBarChart;
|
|
@@ -16,7 +16,6 @@ var Buttons_1 = require("../components/Buttons");
|
|
|
16
16
|
var ModalConfirmAction_1 = require("../components/Modals/derivedComps/ModalConfirmAction");
|
|
17
17
|
var Banners_1 = require("../components/Banners");
|
|
18
18
|
var react_1 = require("react");
|
|
19
|
-
var Typo_1 = require("../components/Typo");
|
|
20
19
|
exports.default = {
|
|
21
20
|
title: "ModalConfirmAction",
|
|
22
21
|
args: {
|
|
@@ -20,6 +20,6 @@ var PercentBarChart_ = function (args) {
|
|
|
20
20
|
console.log("Bar clicked: ".concat(name));
|
|
21
21
|
};
|
|
22
22
|
return (react_1.default.createElement("div", null,
|
|
23
|
-
react_1.default.createElement(PercentBarChart_1.PercentBarChart, { data: data,
|
|
23
|
+
react_1.default.createElement(PercentBarChart_1.PercentBarChart, { data: data, display: "name", valuePath: "value", title: "This is PercentBarChart representing the data", onClick: handleBarClick })));
|
|
24
24
|
};
|
|
25
25
|
exports.PercentBarChart_ = PercentBarChart_;
|