krl-alfred 2.17.30 → 2.17.31
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/Toast/Toast.d.ts +1 -1
- package/dist/components/Toast/Toast.js +13 -5
- package/dist/components/Toast/Toast.styled.js +1 -1
- package/dist/components/Toast/core/state.d.ts +5 -5
- package/dist/components/Toast/props.d.ts +3 -1
- package/dist/components/Toast/props.js +2 -0
- package/dist/components/Toast/stories/Toast.stories.d.ts +1 -0
- package/dist/components/Toast/stories/Toast.stories.js +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ToastProps } from "./props";
|
|
3
3
|
import { toast } from "./core/state";
|
|
4
|
-
declare const Toaster: ({ size, show, children, onSecondaryAction, hasLoading, }: ToastProps) => React.ReactPortal;
|
|
4
|
+
declare const Toaster: ({ size, show, children, onSecondaryAction, hasLoading, showCloseIcon, onClose, }: ToastProps) => React.ReactPortal;
|
|
5
5
|
export { toast, Toaster };
|
|
@@ -26,10 +26,10 @@ var state_1 = require("./core/state");
|
|
|
26
26
|
Object.defineProperty(exports, "toast", { enumerable: true, get: function () { return state_1.toast; } });
|
|
27
27
|
var Loader_1 = __importDefault(require("../Loader"));
|
|
28
28
|
var Toaster = function (_a) {
|
|
29
|
-
var _b = _a.size, size = _b === void 0 ? props_1.ToastDefault.size : _b, _c = _a.show, show = _c === void 0 ? props_1.ToastDefault.show : _c, _d = _a.children, children = _d === void 0 ? props_1.ToastDefault.children : _d, _e = _a.onSecondaryAction, onSecondaryAction = _e === void 0 ? props_1.ToastDefault.onSecondaryAction : _e, _f = _a.hasLoading, hasLoading = _f === void 0 ? props_1.ToastDefault.hasLoading : _f;
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
29
|
+
var _b = _a.size, size = _b === void 0 ? props_1.ToastDefault.size : _b, _c = _a.show, show = _c === void 0 ? props_1.ToastDefault.show : _c, _d = _a.children, children = _d === void 0 ? props_1.ToastDefault.children : _d, _e = _a.onSecondaryAction, onSecondaryAction = _e === void 0 ? props_1.ToastDefault.onSecondaryAction : _e, _f = _a.hasLoading, hasLoading = _f === void 0 ? props_1.ToastDefault.hasLoading : _f, _g = _a.showCloseIcon, showCloseIcon = _g === void 0 ? props_1.ToastDefault.showCloseIcon : _g, _h = _a.onClose, onClose = _h === void 0 ? props_1.ToastDefault.onClose : _h;
|
|
30
|
+
var _j = (0, react_1.useState)(show), isShowToast = _j[0], setIsShowToast = _j[1];
|
|
31
|
+
var _k = (0, react_1.useState)({}), toastProps = _k[0], setToastProps = _k[1];
|
|
32
|
+
var _l = (0, react_1.useState)("24px"), iconSize = _l[0], setIconSize = _l[1];
|
|
33
33
|
(0, react_1.useEffect)(function () {
|
|
34
34
|
return state_1.ToastState.subscribe(function (toast) {
|
|
35
35
|
setToastProps(__assign(__assign({}, props_1.ToastDefault), toast));
|
|
@@ -73,8 +73,16 @@ var Toaster = function (_a) {
|
|
|
73
73
|
setIconSize("24px");
|
|
74
74
|
}
|
|
75
75
|
}, [toastProps, size]);
|
|
76
|
+
var handleClose = function () {
|
|
77
|
+
if (toastProps.onClose) {
|
|
78
|
+
toastProps.onClose();
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
setIsShowToast(false);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
76
84
|
return (isShowToast &&
|
|
77
|
-
react_dom_1.default.createPortal((0, jsx_runtime_1.jsx)(Toast_styled_1.OverlayStyled, { children: (0, jsx_runtime_1.jsx)(Toast_styled_1.ToastStyled, __assign({ "$size": toastProps.size, "$alignment": toastProps.alignment, "$variant": toastProps.variant }, { children: toastProps.hasLoading ? ((0, jsx_runtime_1.jsxs)("div", { children: [(toastProps.icon) && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "icon" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: toastProps.icon, width: iconSize, height: iconSize }) }))), (0, jsx_runtime_1.jsx)("div", __assign({ className: "loaderWrapper" }, { children: (0, jsx_runtime_1.jsx)(Loader_1.default, { variant: "primary", width: "1.5rem", height: "1.5rem" }) }))] })) : ((0, jsx_runtime_1.jsxs)("div", { children: [(toastProps.icon) && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "icon" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: toastProps.icon, width: iconSize, height: iconSize }) }))), (toastProps.title) && ((0, jsx_runtime_1.jsx)("h5", { className: "title", dangerouslySetInnerHTML: { __html: toastProps.title } })), (0, jsx_runtime_1.jsx)("div", __assign({ className: "content" }, { children: toastProps.children || children })), (toastProps.showPrimaryButton || toastProps.showSecondaryButton) && ((0, jsx_runtime_1.jsxs)("div", __assign({ className: "bottom" }, { children: [(toastProps.showSecondaryButton) && ((0, jsx_runtime_1.jsx)(Button_1.default, __assign({ onClick: function (e) {
|
|
85
|
+
react_dom_1.default.createPortal((0, jsx_runtime_1.jsx)(Toast_styled_1.OverlayStyled, { children: (0, jsx_runtime_1.jsx)(Toast_styled_1.ToastStyled, __assign({ "$size": toastProps.size, "$alignment": toastProps.alignment, "$variant": toastProps.variant }, { children: toastProps.hasLoading ? ((0, jsx_runtime_1.jsxs)("div", { children: [(toastProps.icon) && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "icon" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: toastProps.icon, width: iconSize, height: iconSize }) }))), (0, jsx_runtime_1.jsx)("div", __assign({ className: "loaderWrapper" }, { children: (0, jsx_runtime_1.jsx)(Loader_1.default, { variant: "primary", width: "1.5rem", height: "1.5rem" }) }))] })) : ((0, jsx_runtime_1.jsxs)("div", { children: [toastProps.showCloseIcon && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "toastrHeader" }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ onClick: handleClose, className: "closeIcon" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: "Closebig" }) })) }))), (toastProps.icon) && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "icon" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: toastProps.icon, width: iconSize, height: iconSize }) }))), (toastProps.title) && ((0, jsx_runtime_1.jsx)("h5", { className: "title", dangerouslySetInnerHTML: { __html: toastProps.title } })), (0, jsx_runtime_1.jsx)("div", __assign({ className: "content" }, { children: toastProps.children || children })), (toastProps.showPrimaryButton || toastProps.showSecondaryButton) && ((0, jsx_runtime_1.jsxs)("div", __assign({ className: "bottom" }, { children: [(toastProps.showSecondaryButton) && ((0, jsx_runtime_1.jsx)(Button_1.default, __assign({ onClick: function (e) {
|
|
78
86
|
toastProps.onSecondaryAction(e);
|
|
79
87
|
onSecondaryAction(e);
|
|
80
88
|
setIsShowToast(false);
|
|
@@ -9,7 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.OverlayStyled = exports.ToastStyled = void 0;
|
|
11
11
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
-
exports.ToastStyled = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: white;\n border-radius: 0.5rem;\n box-sizing: border-box;\n max-width: calc(100vw - 2rem);\n padding: 2rem;\n display: flex;\n align-items: center;\n ", ";\n width: ", ";\n min-height: ", ";\n > div{\n width: 100%;\n }\n \n .icon{\n width: ", ";\n\n height: ", ";\n border-radius: 50%;\n background-color: ", ";\n text-align: center;\n align-items: center;\n justify-content: center;\n display: flex;\n margin:\n ", ";\n svg{\n\n width: ", ";\n\n height: ", ";\n color: #fff;\n }\n }\n .loaderWrapper{\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .title {\n margin: 2rem 0 0 0;\n padding: 0;\n font:var(--title-extra-bold-16-19);\n }\n \n .content {\n margin: 1rem 0 0 0;\n font:var(--body-regular-14-17);\n &:is(:empty){\n display: none;\n }\n }\n .bottom{\n margin: 2rem 0 0 0;\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n column-gap: 1rem;\n button{\n white-space: nowrap;\n }\n }\n"], ["\n background: white;\n border-radius: 0.5rem;\n box-sizing: border-box;\n max-width: calc(100vw - 2rem);\n padding: 2rem;\n display: flex;\n align-items: center;\n ", ";\n width: ", ";\n min-height: ", ";\n > div{\n width: 100%;\n }\n \n .icon{\n width: ", ";\n\n height: ", ";\n border-radius: 50%;\n background-color: ", ";\n text-align: center;\n align-items: center;\n justify-content: center;\n display: flex;\n margin:\n ", ";\n svg{\n\n width: ", ";\n\n height: ", ";\n color: #fff;\n }\n }\n .loaderWrapper{\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .title {\n margin: 2rem 0 0 0;\n padding: 0;\n font:var(--title-extra-bold-16-19);\n }\n \n .content {\n margin: 1rem 0 0 0;\n font:var(--body-regular-14-17);\n &:is(:empty){\n display: none;\n }\n }\n .bottom{\n margin: 2rem 0 0 0;\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n column-gap: 1rem;\n button{\n white-space: nowrap;\n }\n }\n"])), function (props) {
|
|
12
|
+
exports.ToastStyled = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: white;\n border-radius: 0.5rem;\n box-sizing: border-box;\n max-width: calc(100vw - 2rem);\n padding: 2rem;\n display: flex;\n align-items: center;\n position: relative;\n ", ";\n width: ", ";\n min-height: ", ";\n > div{\n width: 100%;\n }\n \n .icon{\n width: ", ";\n\n height: ", ";\n border-radius: 50%;\n background-color: ", ";\n text-align: center;\n align-items: center;\n justify-content: center;\n display: flex;\n margin:\n ", ";\n svg{\n\n width: ", ";\n\n height: ", ";\n color: #fff;\n }\n }\n .loaderWrapper{\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .title {\n margin: 2rem 0 0 0;\n padding: 0;\n font:var(--title-extra-bold-16-19);\n }\n \n .content {\n margin: 1rem 0 0 0;\n font:var(--body-regular-14-17);\n &:is(:empty){\n display: none;\n }\n }\n .bottom{\n margin: 2rem 0 0 0;\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n column-gap: 1rem;\n button{\n white-space: nowrap;\n }\n }\n\n .toastrHeader{\n align-items: center;\n justify-content: flex-end;\n width: 100%;\n padding: 0 0 24px 0;\n display: flex;\n \n .closeIcon {\n width: 32px;\n height: 32px;\n border-radius: 0.5rem;\n cursor: pointer;\n background: white;\n transition: all .2s;\n color: var(--dark);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n &:hover {\n box-shadow: 0 6px 30px var(--box-shadow-color);\n }\n }\n }\n"], ["\n background: white;\n border-radius: 0.5rem;\n box-sizing: border-box;\n max-width: calc(100vw - 2rem);\n padding: 2rem;\n display: flex;\n align-items: center;\n position: relative;\n ", ";\n width: ", ";\n min-height: ", ";\n > div{\n width: 100%;\n }\n \n .icon{\n width: ", ";\n\n height: ", ";\n border-radius: 50%;\n background-color: ", ";\n text-align: center;\n align-items: center;\n justify-content: center;\n display: flex;\n margin:\n ", ";\n svg{\n\n width: ", ";\n\n height: ", ";\n color: #fff;\n }\n }\n .loaderWrapper{\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .title {\n margin: 2rem 0 0 0;\n padding: 0;\n font:var(--title-extra-bold-16-19);\n }\n \n .content {\n margin: 1rem 0 0 0;\n font:var(--body-regular-14-17);\n &:is(:empty){\n display: none;\n }\n }\n .bottom{\n margin: 2rem 0 0 0;\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n column-gap: 1rem;\n button{\n white-space: nowrap;\n }\n }\n\n .toastrHeader{\n align-items: center;\n justify-content: flex-end;\n width: 100%;\n padding: 0 0 24px 0;\n display: flex;\n \n .closeIcon {\n width: 32px;\n height: 32px;\n border-radius: 0.5rem;\n cursor: pointer;\n background: white;\n transition: all .2s;\n color: var(--dark);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n &:hover {\n box-shadow: 0 6px 30px var(--box-shadow-color);\n }\n }\n }\n"])), function (props) {
|
|
13
13
|
switch (props.$alignment) {
|
|
14
14
|
case 'left':
|
|
15
15
|
return "\n justify-content: flex-start;\n text-align: start;\n ";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Toast } from "../props";
|
|
2
2
|
declare class Observer {
|
|
3
|
-
subscribers: Array<(toast:
|
|
3
|
+
subscribers: Array<(toast: Toast) => void>;
|
|
4
4
|
constructor();
|
|
5
|
-
subscribe: (subscriber: (toast:
|
|
6
|
-
publish: (data:
|
|
7
|
-
addToast: (data:
|
|
5
|
+
subscribe: (subscriber: (toast: Toast) => void) => () => void;
|
|
6
|
+
publish: (data: Toast) => void;
|
|
7
|
+
addToast: (data: Toast) => void;
|
|
8
8
|
}
|
|
9
9
|
export declare const ToastState: Observer;
|
|
10
10
|
export declare const toast: any;
|
|
@@ -7,12 +7,14 @@ export declare const variant: string[];
|
|
|
7
7
|
type VARIANT = typeof variant[number];
|
|
8
8
|
export declare const iconNames: string[];
|
|
9
9
|
type ICON = typeof iconNames[any];
|
|
10
|
-
interface Toast {
|
|
10
|
+
export interface Toast {
|
|
11
11
|
size?: SIZES;
|
|
12
12
|
alignment?: ALIGNMENT;
|
|
13
13
|
variant?: VARIANT;
|
|
14
14
|
show?: boolean;
|
|
15
15
|
hasClosing?: boolean;
|
|
16
|
+
showCloseIcon?: boolean;
|
|
17
|
+
onClose?(): void;
|
|
16
18
|
title?: string;
|
|
17
19
|
children?: React.ReactNode;
|
|
18
20
|
setShow?(b: boolean): void;
|
|
@@ -23,6 +23,7 @@ var Button_1 = __importDefault(require("../../Button"));
|
|
|
23
23
|
exports.default = {
|
|
24
24
|
title: 'Components/Toast',
|
|
25
25
|
component: function (props) {
|
|
26
|
+
console.log(props);
|
|
26
27
|
var handleShowToast = function () { return (0, Toast_1.toast)(props); };
|
|
27
28
|
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(Toast_1.Toaster, {}), (0, jsx_runtime_1.jsx)(Button_1.default, __assign({ size: "big", variant: "primary", onClick: handleShowToast }, { children: "Show Toast" }))] }));
|
|
28
29
|
},
|
|
@@ -50,5 +51,6 @@ exports.Default = {
|
|
|
50
51
|
showSecondaryButton: false,
|
|
51
52
|
secondaryButtonText: 'Secondary',
|
|
52
53
|
hasLoading: false,
|
|
54
|
+
showCloseIcon: true,
|
|
53
55
|
},
|
|
54
56
|
};
|