oolib 2.215.4 → 2.217.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.
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { BannerCTA, BannerProps } from "../types";
3
+ export declare const CTA: ({ cta }: {
4
+ cta: BannerCTA;
5
+ }) => React.JSX.Element;
6
+ /**
7
+ * @component Renders a banner component with customizable text, color and styling.
8
+ *
9
+ * - The object containing the following properties:
10
+ * @prop {IconColor} color: The color of the banner.
11
+ * @prop {BannerCTA} cta: The object containing the info about the cta button.
12
+ * @prop {string} msg: The text to be displayed in the banner.
13
+ * @prop {(e: React.MouseEvent | null, id: string) => void} handleRemove: The callback function to be called when the banner is removed.
14
+ * @prop {string} id: The id of the banner.
15
+ * @prop {number} timeOut: The time in milliseconds to wait before removing the banner. Defaults to 3000.
16
+ * @prop {boolean} showIcon: A boolean indicating whether to show the icon in the banner. Defaults to true.
17
+ * @prop {boolean} bottomStroke: A boolean indicating whether to show the bottom stroke in the banner. Defaults to true.
18
+ * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
19
+ * @return {ReactElement} The rendered banner component.
20
+ */
21
+ export declare const Banner: React.FunctionComponent<BannerProps>;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.Banner = exports.CTA = void 0;
48
+ var react_1 = __importStar(require("react"));
49
+ var styled_1 = require("../styled");
50
+ var react_router_dom_1 = require("react-router-dom");
51
+ var Buttons_1 = require("../../../v2/components/Buttons");
52
+ var Typo2_1 = require("../../../v2/components/Typo2");
53
+ var __1 = require("..");
54
+ var CTA = function (_a) {
55
+ var cta = _a.cta;
56
+ var LinkWrapper = cta.to ? react_router_dom_1.Link : react_1.Fragment;
57
+ return (react_1.default.createElement(LinkWrapper, __assign({}, (cta.to ? { to: cta.to } : {})),
58
+ react_1.default.createElement(Buttons_1.ButtonSecondaryCompact, { style: { marginTop: "0.5rem", marginBottom: "0.5rem" }, S: true, onClick: !cta.to && cta.action }, cta === null || cta === void 0 ? void 0 : cta.text)));
59
+ };
60
+ exports.CTA = CTA;
61
+ /**
62
+ * @component Renders a banner component with customizable text, color and styling.
63
+ *
64
+ * - The object containing the following properties:
65
+ * @prop {IconColor} color: The color of the banner.
66
+ * @prop {BannerCTA} cta: The object containing the info about the cta button.
67
+ * @prop {string} msg: The text to be displayed in the banner.
68
+ * @prop {(e: React.MouseEvent | null, id: string) => void} handleRemove: The callback function to be called when the banner is removed.
69
+ * @prop {string} id: The id of the banner.
70
+ * @prop {number} timeOut: The time in milliseconds to wait before removing the banner. Defaults to 3000.
71
+ * @prop {boolean} showIcon: A boolean indicating whether to show the icon in the banner. Defaults to true.
72
+ * @prop {boolean} bottomStroke: A boolean indicating whether to show the bottom stroke in the banner. Defaults to true.
73
+ * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
74
+ * @return {ReactElement} The rendered banner component.
75
+ */
76
+ var Banner = function (_a) {
77
+ var color = _a.color, cta = _a.cta, msg = _a.msg, handleRemove = _a.handleRemove, id = _a.id, timeOut = _a.timeOut, _b = _a.showIcon, showIcon = _b === void 0 ? true : _b, _c = _a.bottomStroke, bottomStroke = _c === void 0 ? true : _c, _d = _a.hideCloseButton, hideCloseButton = _d === void 0 ? false : _d;
78
+ var _e = (0, react_1.useState)(0), height = _e[0], setHeight = _e[1];
79
+ var ContainerRef = (0, react_1.useRef)(null);
80
+ (0, react_1.useEffect)(function () {
81
+ var timer;
82
+ if (ContainerRef.current) {
83
+ setHeight(ContainerRef.current.scrollHeight);
84
+ }
85
+ if (timeOut) {
86
+ timer = setTimeout(function () {
87
+ setHeight(0);
88
+ remove(null, id);
89
+ }, timeOut);
90
+ }
91
+ return function () {
92
+ if (timer)
93
+ clearTimeout(timer);
94
+ };
95
+ }, [cta, id, msg, timeOut]);
96
+ var remove = function (e, id) {
97
+ setHeight(0);
98
+ setTimeout(function () {
99
+ handleRemove(e, id);
100
+ }, 300);
101
+ };
102
+ return (react_1.default.createElement(styled_1.BannerAnimateStyled, { key: id, ref: ContainerRef, height: height },
103
+ react_1.default.createElement(styled_1.BannerWrapperStyled, { bottomStroke: bottomStroke, color: color },
104
+ react_1.default.createElement(styled_1.BannerStyled, null,
105
+ showIcon && react_1.default.createElement(__1.DisplayIcon, { color: color }),
106
+ react_1.default.createElement(Typo2_1.UI_BODY_SEMIBOLD_SM_DF, null, msg),
107
+ cta && react_1.default.createElement(exports.CTA, { cta: cta })),
108
+ hideCloseButton !== true &&
109
+ react_1.default.createElement(Buttons_1.ButtonGhost, { S: true, icon: "X", onClick: function (e) { return remove(e, id); } }))));
110
+ };
111
+ exports.Banner = Banner;
@@ -0,0 +1,19 @@
1
+ import { FunctionComponent } from "react";
2
+ import { BannerProps } from "../types";
3
+ export declare const StyledToastWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ /**
5
+ * A toast component that displays a message and an optional close button and/or CTA button.
6
+ *
7
+ * @param {BannerProps} props - The props object containing the following properties
8
+ * @param {IconColor} color - The color of the banner.
9
+ * @param {BannerCTA} cta - An object containing the info about the cta button.
10
+ * @param {string} msg - The text to be displayed in the banner.
11
+ * @param {(e: React.MouseEvent | null, id: string) => void} handleRemove - A callback function to be called when a banner is removed. The function takes the mouse event and the id of the banner as arguments.
12
+ * @param {string} id - The id of the banner.
13
+ * @param {boolean} showIcon - A boolean indicating whether to show the icon in the banner. Defaults to true.
14
+ * @param {boolean} hideCloseButton - A boolean indicating whether to hide the close button in the banner. Defaults to false.
15
+ * @param {string} actionText - The text to be displayed on the close button in the banner.
16
+ * @param {boolean} bottomStroke - A boolean indicating whether to add a bottom stroke to the banner. Defaults to true.
17
+ * @param {number} timeOut - The time in milliseconds to wait before removing the banner. Defaults to 3000.
18
+ */
19
+ export declare const Toast: FunctionComponent<BannerProps>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Toast = exports.StyledToastWrapper = void 0;
11
+ var react_1 = __importDefault(require("react"));
12
+ var styled_components_1 = __importDefault(require("styled-components"));
13
+ var framer_motion_1 = require("framer-motion");
14
+ var mixins_1 = require("../../../themes/mixins");
15
+ var Typo2_1 = require("../../../v2/components/Typo2");
16
+ var Buttons_1 = require("../../../v2/components/Buttons");
17
+ var __1 = require("..");
18
+ var Banner_1 = require("../Banner");
19
+ var StyledToast = (0, styled_components_1.default)(framer_motion_1.motion.div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0.8rem 1.2rem;\n border-radius: 1.2rem;\n background: white;\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 40rem;\n min-height: 5rem;\n\n ", " {\n width: 45rem;\n };\n\n box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.15);\n\n"], ["\n padding: 0.8rem 1.2rem;\n border-radius: 1.2rem;\n background: white;\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 40rem;\n min-height: 5rem;\n\n ", " {\n width: 45rem;\n };\n\n box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.15);\n\n"])), (0, mixins_1.mediaQuery)("md"));
20
+ exports.StyledToastWrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: fixed;\n bottom: 2.5rem;\n right: 2.5rem;\n width: max-content;\n z-index: 1000000000;\n overflow: hidden;\n padding: 2rem;\n background: transparent;\n"], ["\n position: fixed;\n bottom: 2.5rem;\n right: 2.5rem;\n width: max-content;\n z-index: 1000000000;\n overflow: hidden;\n padding: 2rem;\n background: transparent;\n"
21
+ /**
22
+ * A toast component that displays a message and an optional close button and/or CTA button.
23
+ *
24
+ * @param {BannerProps} props - The props object containing the following properties
25
+ * @param {IconColor} color - The color of the banner.
26
+ * @param {BannerCTA} cta - An object containing the info about the cta button.
27
+ * @param {string} msg - The text to be displayed in the banner.
28
+ * @param {(e: React.MouseEvent | null, id: string) => void} handleRemove - A callback function to be called when a banner is removed. The function takes the mouse event and the id of the banner as arguments.
29
+ * @param {string} id - The id of the banner.
30
+ * @param {boolean} showIcon - A boolean indicating whether to show the icon in the banner. Defaults to true.
31
+ * @param {boolean} hideCloseButton - A boolean indicating whether to hide the close button in the banner. Defaults to false.
32
+ * @param {string} actionText - The text to be displayed on the close button in the banner.
33
+ * @param {boolean} bottomStroke - A boolean indicating whether to add a bottom stroke to the banner. Defaults to true.
34
+ * @param {number} timeOut - The time in milliseconds to wait before removing the banner. Defaults to 3000.
35
+ */
36
+ ])));
37
+ /**
38
+ * A toast component that displays a message and an optional close button and/or CTA button.
39
+ *
40
+ * @param {BannerProps} props - The props object containing the following properties
41
+ * @param {IconColor} color - The color of the banner.
42
+ * @param {BannerCTA} cta - An object containing the info about the cta button.
43
+ * @param {string} msg - The text to be displayed in the banner.
44
+ * @param {(e: React.MouseEvent | null, id: string) => void} handleRemove - A callback function to be called when a banner is removed. The function takes the mouse event and the id of the banner as arguments.
45
+ * @param {string} id - The id of the banner.
46
+ * @param {boolean} showIcon - A boolean indicating whether to show the icon in the banner. Defaults to true.
47
+ * @param {boolean} hideCloseButton - A boolean indicating whether to hide the close button in the banner. Defaults to false.
48
+ * @param {string} actionText - The text to be displayed on the close button in the banner.
49
+ * @param {boolean} bottomStroke - A boolean indicating whether to add a bottom stroke to the banner. Defaults to true.
50
+ * @param {number} timeOut - The time in milliseconds to wait before removing the banner. Defaults to 3000.
51
+ */
52
+ var Toast = function (_a) {
53
+ var color = _a.color, cta = _a.cta, msg = _a.msg, handleRemove = _a.handleRemove, id = _a.id, _b = _a.showIcon, showIcon = _b === void 0 ? true : _b, _c = _a.hideCloseButton, hideCloseButton = _c === void 0 ? false : _c, actionText = _a.actionText, actionIcon = _a.actionIcon, _d = _a.bottomStroke, bottomStroke = _d === void 0 ? true : _d, timeOut = _a.timeOut;
54
+ return (react_1.default.createElement(StyledToast, { initial: { x: "100%", opacity: 0 }, animate: { x: 0, opacity: 1 }, exit: { x: "100%", opacity: 0 }, transition: { type: "spring", damping: 25, stiffness: 300 } },
55
+ react_1.default.createElement("div", { style: { display: "flex" } },
56
+ showIcon && react_1.default.createElement(__1.DisplayIcon, { color: color }),
57
+ react_1.default.createElement(Typo2_1.UI_BODY_SEMIBOLD_SM_DF, null, msg),
58
+ cta && react_1.default.createElement(Banner_1.CTA, { cta: cta })),
59
+ hideCloseButton !== true &&
60
+ react_1.default.createElement(Buttons_1.ButtonSecondary, { S: true, style: { maxWidth: "10rem" }, icon: actionIcon, onClick: function (e) { return handleRemove(e, id); }, children: actionText })));
61
+ };
62
+ exports.Toast = Toast;
63
+ var templateObject_1, templateObject_2;
@@ -5,9 +5,11 @@ export interface BannerEntry {
5
5
  color?: string;
6
6
  timeOut?: number;
7
7
  }
8
+ export type Variant = "toast" | "default";
8
9
  export interface BannerState {
9
10
  alertState: BannerEntry[];
10
11
  infoState: BannerEntry[];
12
+ variant?: Variant;
11
13
  }
12
14
  export type BannerAction = {
13
15
  type: "ADD_ALERT";
@@ -25,6 +27,9 @@ export type BannerAction = {
25
27
  type: "REMOVE_ALL_INFO";
26
28
  } | {
27
29
  type: "REMOVE_ALL_ALERT";
30
+ } | {
31
+ type: "SET_VARIANT";
32
+ variant: Variant;
28
33
  };
29
34
  export interface BannerContextType {
30
35
  BANNER_STATE: BannerState;
@@ -34,6 +39,7 @@ export interface BannerContextType {
34
39
  REMOVE_INFO_BANNER: (e: React.MouseEvent, id: string) => void;
35
40
  REMOVE_ALL_INFO_BANNERS: (e: React.MouseEvent) => void;
36
41
  REMOVE_ALL_ALERT_BANNERS: (e: React.MouseEvent) => void;
42
+ SET_VARIANT: (variant: Variant) => void;
37
43
  }
38
44
  export declare const BannerContext: React.Context<BannerContextType>;
39
45
  export interface BannerProviderProps {
@@ -110,6 +110,8 @@ var bannerReducer = function (state, action) {
110
110
  return __assign(__assign({}, state), { infoState: [] });
111
111
  case "REMOVE_ALL_ALERT":
112
112
  return __assign(__assign({}, state), { alertState: [] });
113
+ case "SET_VARIANT":
114
+ return __assign(__assign({}, state), { variant: action.variant });
113
115
  default:
114
116
  return state;
115
117
  }
@@ -129,7 +131,7 @@ var bannerReducer = function (state, action) {
129
131
  */
130
132
  var BannerProvider = function (_a) {
131
133
  var children = _a.children;
132
- var initialState = { alertState: [], infoState: [] };
134
+ var initialState = { alertState: [], infoState: [], variant: "default" };
133
135
  var _b = (0, react_1.useReducer)(bannerReducer, initialState), BANNER_STATE = _b[0], BANNER_DISPATCH = _b[1];
134
136
  var REMOVE_ALERT_BANNER = function (e, id) {
135
137
  BANNER_DISPATCH({ type: "REMOVE_ALERT", id: id });
@@ -143,6 +145,9 @@ var BannerProvider = function (_a) {
143
145
  var REMOVE_ALL_ALERT_BANNERS = function (e) {
144
146
  BANNER_DISPATCH({ type: "REMOVE_ALL_ALERT" });
145
147
  };
148
+ var SET_VARIANT = function (variant) {
149
+ BANNER_DISPATCH({ type: "SET_VARIANT", variant: variant });
150
+ };
146
151
  // the config of bannner can either be passed as a object, or plain arguments.
147
152
  var SET_INFO_BANNER = function (options_msg, color, timeOut) {
148
153
  var options;
@@ -181,7 +186,8 @@ var BannerProvider = function (_a) {
181
186
  REMOVE_ALERT_BANNER: REMOVE_ALERT_BANNER,
182
187
  REMOVE_INFO_BANNER: REMOVE_INFO_BANNER,
183
188
  REMOVE_ALL_INFO_BANNERS: REMOVE_ALL_INFO_BANNERS,
184
- REMOVE_ALL_ALERT_BANNERS: REMOVE_ALL_ALERT_BANNERS
189
+ REMOVE_ALL_ALERT_BANNERS: REMOVE_ALL_ALERT_BANNERS,
190
+ SET_VARIANT: SET_VARIANT
185
191
  };
186
192
  return react_1.default.createElement(exports.BannerContext.Provider, { value: contextValue }, children);
187
193
  };
@@ -1,40 +1,6 @@
1
1
  import React from "react";
2
- import { To } from 'react-router-dom';
3
- export type IconColor = 'red' | 'green' | 'yellow' | 'dark' | 'grey';
4
- export interface DisplayIconProps {
5
- color: IconColor;
6
- }
7
- export interface BannerCTA {
8
- to?: To;
9
- action?: () => void;
10
- text: string;
11
- }
12
- export interface BannerProps {
13
- color: IconColor;
14
- cta?: BannerCTA;
15
- msg: string;
16
- handleRemove: (e: React.MouseEvent | null, id: string) => void;
17
- id: string;
18
- timeOut?: number;
19
- showIcon?: boolean;
20
- bottomStroke?: boolean;
21
- hideCloseButton?: boolean;
22
- }
23
- export interface BannerState {
24
- id: string;
25
- color: IconColor;
26
- msg: string;
27
- cta?: BannerCTA;
28
- timeOut?: number;
29
- showIcon?: boolean;
30
- hideCloseButton?: boolean;
31
- }
32
- export interface BannerAlertProps {
33
- BANNER_STATE: {
34
- alertState: BannerState[];
35
- };
36
- REMOVE_ALERT_BANNER: (e: React.MouseEvent | null, id: string) => void;
37
- }
2
+ import { BannerAlertProps, BannerInfoProps, DisplayIconProps } from "./types";
3
+ export declare const DisplayIcon: React.FunctionComponent<DisplayIconProps>;
38
4
  /**
39
5
  * @component Renders a list of alert banners with customizable text, color and styling.
40
6
  *
@@ -53,12 +19,6 @@ export interface BannerAlertProps {
53
19
  * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
54
20
  */
55
21
  export declare const BannerAlert: React.FunctionComponent<BannerAlertProps>;
56
- export interface BannerInfoProps {
57
- BANNER_STATE: {
58
- infoState: BannerState[];
59
- };
60
- REMOVE_INFO_BANNER: (e: React.MouseEvent | null, id: string) => void;
61
- }
62
22
  /**
63
23
  * @component Renders a list of info banners with customizable text, color and styling.
64
24
  *
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -44,79 +33,19 @@ var __importStar = (this && this.__importStar) || (function () {
44
33
  };
45
34
  })();
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
- exports.BannerInfo = exports.BannerAlert = void 0;
36
+ exports.BannerInfo = exports.BannerAlert = exports.DisplayIcon = void 0;
48
37
  var react_1 = __importStar(require("react"));
49
38
  var styled_1 = require("./styled");
50
- var react_router_dom_1 = require("react-router-dom");
51
39
  var icons_1 = require("../../icons");
52
- var Buttons_1 = require("../../v2/components/Buttons");
53
- var Typo2_1 = require("../../v2/components/Typo2");
54
- var ICONS = {
55
- red: "XCircle",
56
- green: "CheckCircle",
57
- yellow: "WarningCircle",
58
- dark: "WarningCircle",
59
- grey: "WarningCircle",
60
- };
40
+ var Toast_1 = require("./Toast");
41
+ var types_1 = require("./types");
42
+ var Banner_1 = require("./Banner");
61
43
  var DisplayIcon = function (_a) {
62
44
  var color = _a.color;
63
- var IconComp = icons_1.icons[ICONS[color]];
45
+ var IconComp = icons_1.icons[types_1.ICONS[color]];
64
46
  return react_1.default.createElement(react_1.default.Fragment, null, IconComp && react_1.default.createElement(IconComp, { size: 20, weight: "bold" }));
65
47
  };
66
- /**
67
- * @component Renders a banner component with customizable text, color and styling.
68
- *
69
- * - The object containing the following properties:
70
- * @prop {IconColor} color: The color of the banner.
71
- * @prop {BannerCTA} cta: The object containing the info about the cta button.
72
- * @prop {string} msg: The text to be displayed in the banner.
73
- * @prop {(e: React.MouseEvent | null, id: string) => void} handleRemove: The callback function to be called when the banner is removed.
74
- * @prop {string} id: The id of the banner.
75
- * @prop {number} timeOut: The time in milliseconds to wait before removing the banner. Defaults to 3000.
76
- * @prop {boolean} showIcon: A boolean indicating whether to show the icon in the banner. Defaults to true.
77
- * @prop {boolean} bottomStroke: A boolean indicating whether to show the bottom stroke in the banner. Defaults to true.
78
- * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
79
- * @return {ReactElement} The rendered banner component.
80
- */
81
- var Banner = function (_a) {
82
- var color = _a.color, cta = _a.cta, msg = _a.msg, handleRemove = _a.handleRemove, id = _a.id, timeOut = _a.timeOut, _b = _a.showIcon, showIcon = _b === void 0 ? true : _b, _c = _a.bottomStroke, bottomStroke = _c === void 0 ? true : _c, _d = _a.hideCloseButton, hideCloseButton = _d === void 0 ? false : _d;
83
- var _e = (0, react_1.useState)(0), height = _e[0], setHeight = _e[1];
84
- var ContainerRef = (0, react_1.useRef)(null);
85
- (0, react_1.useEffect)(function () {
86
- var timer;
87
- if (ContainerRef.current) {
88
- setHeight(ContainerRef.current.scrollHeight);
89
- }
90
- if (timeOut) {
91
- timer = setTimeout(function () {
92
- setHeight(0);
93
- remove(null, id);
94
- }, timeOut);
95
- }
96
- return function () {
97
- if (timer)
98
- clearTimeout(timer);
99
- };
100
- }, [cta, id, msg, timeOut]);
101
- var remove = function (e, id) {
102
- setHeight(0);
103
- setTimeout(function () {
104
- handleRemove(e, id);
105
- }, 300);
106
- };
107
- var genCTA = function (cta) {
108
- var LinkWrapper = cta.to ? react_router_dom_1.Link : react_1.Fragment;
109
- return (react_1.default.createElement(LinkWrapper, __assign({}, (cta.to ? { to: cta.to } : {})),
110
- react_1.default.createElement(Buttons_1.ButtonSecondaryCompact, { style: { marginTop: "0.5rem", marginBottom: "0.5rem" }, S: true, onClick: !cta.to && cta.action }, cta === null || cta === void 0 ? void 0 : cta.text)));
111
- };
112
- return (react_1.default.createElement(styled_1.BannerAnimateStyled, { key: id, ref: ContainerRef, height: height },
113
- react_1.default.createElement(styled_1.BannerWrapperStyled, { bottomStroke: bottomStroke, color: color },
114
- react_1.default.createElement(styled_1.BannerStyled, null,
115
- showIcon && react_1.default.createElement(DisplayIcon, { color: color }),
116
- react_1.default.createElement(Typo2_1.UI_BODY_SEMIBOLD_SM_DF, null, msg),
117
- cta && genCTA(cta)),
118
- hideCloseButton !== true && react_1.default.createElement(Buttons_1.ButtonGhost, { S: true, icon: "X", onClick: function (e) { return remove(e, id); } }))));
119
- };
48
+ exports.DisplayIcon = DisplayIcon;
120
49
  /**
121
50
  * @component Renders a list of alert banners with customizable text, color and styling.
122
51
  *
@@ -135,9 +64,9 @@ var Banner = function (_a) {
135
64
  * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
136
65
  */
137
66
  var BannerAlert = function (_a) {
138
- var _b;
139
- var BANNER_STATE = _a.BANNER_STATE, REMOVE_ALERT_BANNER = _a.REMOVE_ALERT_BANNER;
140
- var _c = (0, react_1.useState)(0), top = _c[0], setTop = _c[1];
67
+ var _b, _c;
68
+ var BANNER_STATE = _a.BANNER_STATE, REMOVE_ALERT_BANNER = _a.REMOVE_ALERT_BANNER, variant = _a.variant;
69
+ var _d = (0, react_1.useState)(0), top = _d[0], setTop = _d[1];
141
70
  (0, react_1.useEffect)(function () {
142
71
  var timerId = setTimeout(function () {
143
72
  var ele = document.getElementById("bannerInfo");
@@ -149,7 +78,11 @@ var BannerAlert = function (_a) {
149
78
  clearTimeout(timerId);
150
79
  };
151
80
  }, []);
152
- return (react_1.default.createElement(styled_1.BannerAlertStyled, { top: top }, (_b = BANNER_STATE === null || BANNER_STATE === void 0 ? void 0 : BANNER_STATE.alertState) === null || _b === void 0 ? void 0 : _b.map(function (e) { return (react_1.default.createElement(Banner, { key: e.id, id: e.id, color: e.color, msg: e.msg, cta: e.cta, handleRemove: REMOVE_ALERT_BANNER, timeOut: e.timeOut, hideCloseButton: e.hideCloseButton })); })));
81
+ return variant === "toast"
82
+ ?
83
+ react_1.default.createElement(Toast_1.StyledToastWrapper, null, (_b = BANNER_STATE === null || BANNER_STATE === void 0 ? void 0 : BANNER_STATE.alertState) === null || _b === void 0 ? void 0 : _b.map(function (e) { return (react_1.default.createElement(Toast_1.Toast, { key: e.id, id: e.id, color: e.color, msg: e.msg, cta: e.cta, handleRemove: REMOVE_ALERT_BANNER, timeOut: e.timeOut, hideCloseButton: e.hideCloseButton, actionText: e.actionText, actionIcon: e.actionIcon })); }))
84
+ :
85
+ react_1.default.createElement(styled_1.BannerAlertStyled, { top: top }, (_c = BANNER_STATE === null || BANNER_STATE === void 0 ? void 0 : BANNER_STATE.alertState) === null || _c === void 0 ? void 0 : _c.map(function (e) { return (react_1.default.createElement(Banner_1.Banner, { key: e.id, id: e.id, color: e.color, msg: e.msg, cta: e.cta, handleRemove: REMOVE_ALERT_BANNER, timeOut: e.timeOut, hideCloseButton: e.hideCloseButton })); }));
153
86
  };
154
87
  exports.BannerAlert = BannerAlert;
155
88
  /**
@@ -170,8 +103,12 @@ exports.BannerAlert = BannerAlert;
170
103
  * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
171
104
  */
172
105
  var BannerInfo = function (_a) {
173
- var _b;
174
- var BANNER_STATE = _a.BANNER_STATE, REMOVE_INFO_BANNER = _a.REMOVE_INFO_BANNER;
175
- return (react_1.default.createElement(styled_1.BannerInfoStyled, { id: "bannerInfo" }, (_b = BANNER_STATE === null || BANNER_STATE === void 0 ? void 0 : BANNER_STATE.infoState) === null || _b === void 0 ? void 0 : _b.map(function (e) { return (react_1.default.createElement(Banner, { key: e.id, id: e.id, color: e.color, msg: e.msg, cta: e.cta, handleRemove: REMOVE_INFO_BANNER, timeOut: e.timeOut, bottomStroke: false, hideCloseButton: e.hideCloseButton })); })));
106
+ var _b, _c;
107
+ var BANNER_STATE = _a.BANNER_STATE, REMOVE_INFO_BANNER = _a.REMOVE_INFO_BANNER, variant = _a.variant;
108
+ return variant === "toast"
109
+ ?
110
+ react_1.default.createElement(Toast_1.StyledToastWrapper, null, (_b = BANNER_STATE === null || BANNER_STATE === void 0 ? void 0 : BANNER_STATE.infoState) === null || _b === void 0 ? void 0 : _b.map(function (e) { return (react_1.default.createElement(Toast_1.Toast, { key: e.id, id: e.id, color: e.color, msg: e.msg, cta: e.cta, handleRemove: REMOVE_INFO_BANNER, timeOut: e.timeOut, hideCloseButton: e.hideCloseButton, actionText: e.actionText, actionIcon: e.actionIcon })); }))
111
+ :
112
+ react_1.default.createElement(styled_1.BannerInfoStyled, { id: "bannerInfo" }, (_c = BANNER_STATE === null || BANNER_STATE === void 0 ? void 0 : BANNER_STATE.infoState) === null || _c === void 0 ? void 0 : _c.map(function (e) { return (react_1.default.createElement(Banner_1.Banner, { key: e.id, id: e.id, color: e.color, msg: e.msg, cta: e.cta, handleRemove: REMOVE_INFO_BANNER, timeOut: e.timeOut, bottomStroke: false, hideCloseButton: e.hideCloseButton, variant: variant })); }));
176
113
  };
177
114
  exports.BannerInfo = BannerInfo;
@@ -0,0 +1,50 @@
1
+ import { To } from "react-router-dom";
2
+ export type IconColor = 'red' | 'green' | 'yellow' | 'dark' | 'grey';
3
+ export declare const ICONS: Record<IconColor, string>;
4
+ export interface BannerProps {
5
+ color: IconColor;
6
+ cta?: BannerCTA;
7
+ msg: string;
8
+ handleRemove: (e: React.MouseEvent | null, id: string) => void;
9
+ id: string;
10
+ timeOut?: number;
11
+ showIcon?: boolean;
12
+ bottomStroke?: boolean;
13
+ hideCloseButton?: boolean;
14
+ variant?: "toast" | "default";
15
+ actionText?: string;
16
+ actionIcon?: string;
17
+ }
18
+ export interface DisplayIconProps {
19
+ color: IconColor;
20
+ }
21
+ export interface BannerCTA {
22
+ to?: To;
23
+ action?: () => void;
24
+ text: string;
25
+ }
26
+ export interface BannerState {
27
+ id: string;
28
+ color: IconColor;
29
+ msg: string;
30
+ cta?: BannerCTA;
31
+ timeOut?: number;
32
+ showIcon?: boolean;
33
+ hideCloseButton?: boolean;
34
+ actionText?: string;
35
+ actionIcon?: string;
36
+ }
37
+ export interface BannerAlertProps {
38
+ BANNER_STATE: {
39
+ alertState: BannerState[];
40
+ };
41
+ REMOVE_ALERT_BANNER: (e: React.MouseEvent | null, id: string) => void;
42
+ variant?: "toast" | "default";
43
+ }
44
+ export interface BannerInfoProps {
45
+ BANNER_STATE: {
46
+ infoState: BannerState[];
47
+ };
48
+ REMOVE_INFO_BANNER: (e: React.MouseEvent | null, id: string) => void;
49
+ variant?: "toast" | "default";
50
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ICONS = void 0;
4
+ exports.ICONS = {
5
+ red: "XCircle",
6
+ green: "CheckCircle",
7
+ yellow: "WarningCircle",
8
+ dark: "WarningCircle",
9
+ grey: "WarningCircle",
10
+ };
@@ -25,6 +25,22 @@ declare namespace _default {
25
25
  let name_4: string;
26
26
  export { name_4 as name };
27
27
  }
28
+ namespace variant {
29
+ let name_5: string;
30
+ export { name_5 as name };
31
+ export let options: string[];
32
+ export namespace mapping {
33
+ let Default: string;
34
+ let Toast: string;
35
+ }
36
+ export namespace control_1 {
37
+ let type_1: string;
38
+ export { type_1 as type };
39
+ }
40
+ export { control_1 as control };
41
+ let defaultValue_1: string;
42
+ export { defaultValue_1 as defaultValue };
43
+ }
28
44
  }
29
45
  namespace args {
30
46
  export let color: string;
@@ -38,6 +54,9 @@ declare namespace _default {
38
54
  export { autoHide_1 as autoHide };
39
55
  let timeOut_1: number;
40
56
  export { timeOut_1 as timeOut };
57
+ let variant_1: string;
58
+ export { variant_1 as variant };
59
+ export let actionText: string;
41
60
  }
42
61
  }
43
62
  export default _default;
@@ -45,26 +64,28 @@ export function Banner_Alert(args: any): import("react").JSX.Element;
45
64
  export namespace Banner_Alert {
46
65
  export namespace argTypes_1 {
47
66
  export namespace color_1 {
48
- let name_5: string;
49
- export { name_5 as name };
50
- export let options: string[];
51
- export namespace mapping {
67
+ let name_6: string;
68
+ export { name_6 as name };
69
+ let options_1: string[];
70
+ export { options_1 as options };
71
+ export namespace mapping_1 {
52
72
  let Success: string;
53
73
  let Alert: string;
54
74
  let Wanring: string;
55
75
  }
56
- export namespace control_1 {
57
- let type_1: string;
58
- export { type_1 as type };
76
+ export { mapping_1 as mapping };
77
+ export namespace control_2 {
78
+ let type_2: string;
79
+ export { type_2 as type };
59
80
  }
60
- export { control_1 as control };
61
- let defaultValue_1: string;
62
- export { defaultValue_1 as defaultValue };
81
+ export { control_2 as control };
82
+ let defaultValue_2: string;
83
+ export { defaultValue_2 as defaultValue };
63
84
  }
64
85
  export { color_1 as color };
65
86
  export namespace buttonText {
66
- let name_6: string;
67
- export { name_6 as name };
87
+ let name_7: string;
88
+ export { name_7 as name };
68
89
  }
69
90
  }
70
91
  export { argTypes_1 as argTypes };
@@ -78,20 +99,21 @@ export function Banner_Info(args: any): import("react").JSX.Element;
78
99
  export namespace Banner_Info {
79
100
  export namespace argTypes_2 {
80
101
  export namespace color_2 {
81
- let name_7: string;
82
- export { name_7 as name };
83
- let options_1: string[];
84
- export { options_1 as options };
85
- export namespace control_2 {
86
- let type_2: string;
87
- export { type_2 as type };
102
+ let name_8: string;
103
+ export { name_8 as name };
104
+ let options_2: string[];
105
+ export { options_2 as options };
106
+ export namespace control_3 {
107
+ let type_3: string;
108
+ export { type_3 as type };
88
109
  }
89
- export { control_2 as control };
90
- let defaultValue_2: string;
91
- export { defaultValue_2 as defaultValue };
110
+ export { control_3 as control };
111
+ let defaultValue_3: string;
112
+ export { defaultValue_3 as defaultValue };
92
113
  }
93
114
  export { color_2 as color };
94
115
  }
95
116
  export { argTypes_2 as argTypes };
96
117
  }
118
+ export function Toast(args: any): import("react").JSX.Element;
97
119
  declare const availableIcons: string[];
@@ -9,10 +9,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9
9
  return to.concat(ar || Array.prototype.slice.call(from));
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Banner_Info = exports.Banner_Alert = void 0;
12
+ exports.Toast = exports.Banner_Info = exports.Banner_Alert = void 0;
13
13
  var react_1 = require("react");
14
14
  var Banners_1 = require("../../../components/Banners");
15
15
  var icons_1 = require("../../../icons");
16
+ var bannerContext_1 = require("../../../components/Banners/bannerContext");
16
17
  var availableIcons = Object.keys(icons_1.icons).sort();
17
18
  exports.default = {
18
19
  title: "Components/Banners",
@@ -35,6 +36,16 @@ exports.default = {
35
36
  timeOut: {
36
37
  name: "Time Out",
37
38
  },
39
+ variant: {
40
+ name: "Variant",
41
+ options: ["Default", "Toast"],
42
+ mapping: {
43
+ Default: "default",
44
+ Toast: "toast",
45
+ },
46
+ control: { type: "select" },
47
+ defaultValue: "Default",
48
+ },
38
49
  },
39
50
  args: {
40
51
  color: "Success",
@@ -42,7 +53,9 @@ exports.default = {
42
53
  showIcon: "X",
43
54
  hideCloseButton: false,
44
55
  autoHide: false,
45
- timeOut: 5000,
56
+ timeOut: 50000000,
57
+ variant: "default",
58
+ actionText: ""
46
59
  },
47
60
  };
48
61
  var uid = 0;
@@ -72,7 +85,7 @@ var Banner_Alert = function (args) {
72
85
  alignItems: "center",
73
86
  gap: "1rem",
74
87
  } },
75
- React.createElement(Banners_1.BannerAlert, { BANNER_STATE: { alertState: state }, REMOVE_ALERT_BANNER: function (e, id) { return handleRemoveBanner({ id: id, setState: setState }); } }),
88
+ React.createElement(Banners_1.BannerAlert, { BANNER_STATE: { alertState: state }, REMOVE_ALERT_BANNER: function (e, id) { return handleRemoveBanner({ id: id, setState: setState }); }, variant: args.variant }),
76
89
  React.createElement("button", { onClick: function () { return handleAddMore({ args: args, state: state, setState: setState }); }, style: { padding: ".5rem", width: "fit-content" } }, "Add more"),
77
90
  React.createElement("h3", null,
78
91
  React.createElement("i", null, "Note: change props and click on add more button"))));
@@ -109,8 +122,10 @@ var Banner_Info = function (args) {
109
122
  flexDirection: "column",
110
123
  alignItems: "center",
111
124
  gap: "1rem",
125
+ // background:"skyblue",
126
+ height: "100svh"
112
127
  } },
113
- React.createElement(Banners_1.BannerInfo, { BANNER_STATE: { infoState: state }, REMOVE_INFO_BANNER: function (e, id) { return handleRemoveBanner({ id: id, setState: setState }); } }),
128
+ React.createElement(Banners_1.BannerInfo, { BANNER_STATE: { infoState: state }, variant: args.variant, REMOVE_INFO_BANNER: function (e, id) { return handleRemoveBanner({ id: id, setState: setState }); } }),
114
129
  React.createElement("button", { onClick: function () { return handleAddMore({ args: args, state: state, setState: setState }); }, style: { padding: ".5rem", width: "fit-content" } }, "Add More"),
115
130
  React.createElement("h3", null,
116
131
  React.createElement("i", null, "Note: change props and click on add more button"))));
@@ -124,3 +139,37 @@ exports.Banner_Info.argTypes = {
124
139
  defaultValue: "grey",
125
140
  },
126
141
  };
142
+ var Toast = function (args) {
143
+ var _a = (0, react_1.useState)([]), state = _a[0], setState = _a[1];
144
+ args.id = uid;
145
+ if (!args.autoHide) {
146
+ delete args.timeOut;
147
+ }
148
+ return (React.createElement("div", { style: {
149
+ display: "flex",
150
+ flexDirection: "column",
151
+ alignItems: "center",
152
+ gap: "1rem",
153
+ // background:"skyblue",
154
+ height: "100svh"
155
+ } },
156
+ React.createElement(Banners_1.BannerInfo, { BANNER_STATE: { infoState: state }, variant: "toast", REMOVE_INFO_BANNER: function (e, id) { return handleRemoveBanner({ id: id, setState: setState }); } }),
157
+ React.createElement("button", { onClick: function () { return handleAddMore({ args: args, state: state, setState: setState }); }, style: { padding: ".5rem", width: "fit-content" } }, "Add More"),
158
+ React.createElement("h3", null,
159
+ React.createElement("i", null, "Note: change props and click on add more button"))));
160
+ };
161
+ exports.Toast = Toast;
162
+ // const TestBannerVariant = () => {
163
+ // const { SET_VARIANT, BANNER_STATE } = useBannerContext();
164
+ // return (
165
+ // <div>
166
+ // <p>Current variant: {BANNER_STATE.variant}</p>
167
+ // <button onClick={() => SET_VARIANT("toast")}>
168
+ // Set Toast
169
+ // </button>
170
+ // <button onClick={() => SET_VARIANT("default")}>
171
+ // Set Default
172
+ // </button>
173
+ // </div>
174
+ // );
175
+ // };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.215.4",
3
+ "version": "2.217.0",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",