oolib 2.135.1 → 2.136.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.
@@ -1,6 +1,69 @@
1
- export const BannerContext: React.Context<any>;
2
- export function BannerProvider({ children }: {
3
- children: any;
4
- }): React.JSX.Element;
5
- export function useBannerContext(): any;
6
- import React from "react";
1
+ import React, { ReactNode, FunctionComponent } from "react";
2
+ export interface BannerEntry {
3
+ id: string;
4
+ msg: string;
5
+ color?: string;
6
+ timeOut?: number;
7
+ }
8
+ export interface BannerState {
9
+ alertState: BannerEntry[];
10
+ infoState: BannerEntry[];
11
+ }
12
+ export type BannerAction = {
13
+ type: "ADD_ALERT";
14
+ payload: Omit<BannerEntry, "id">;
15
+ } | {
16
+ type: "ADD_INFO";
17
+ payload: Omit<BannerEntry, "id">;
18
+ } | {
19
+ type: "REMOVE_ALERT";
20
+ id: string;
21
+ } | {
22
+ type: "REMOVE_INFO";
23
+ id: string;
24
+ } | {
25
+ type: "REMOVE_ALL_INFO";
26
+ } | {
27
+ type: "REMOVE_ALL_ALERT";
28
+ };
29
+ export interface BannerContextType {
30
+ BANNER_STATE: BannerState;
31
+ SET_INFO_BANNER: (options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string;
32
+ SET_ALERT_BANNER: (options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string;
33
+ REMOVE_ALERT_BANNER: (e: React.MouseEvent, id: string) => void;
34
+ REMOVE_INFO_BANNER: (e: React.MouseEvent, id: string) => void;
35
+ REMOVE_ALL_INFO_BANNERS: (e: React.MouseEvent) => void;
36
+ REMOVE_ALL_ALERT_BANNERS: (e: React.MouseEvent) => void;
37
+ }
38
+ export declare const BannerContext: React.Context<BannerContextType>;
39
+ export interface BannerProviderProps {
40
+ children: ReactNode;
41
+ }
42
+ /**
43
+ * @component Renders a context provider component for the banner component.
44
+ *
45
+ * - The context value object containing the following properties:
46
+ * @property {BannerState} BANNER_STATE: The state of the banner.
47
+ * @property {(options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string} SET_INFO_BANNER: A callback function to be called when adding an info banner. The function takes the text to be displayed in the banner, the color of the banner, and the time in milliseconds to wait before removing the banner as arguments.
48
+ * @property {(options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string} SET_ALERT_BANNER: A callback function to be called when adding an alert banner. The function takes the text to be displayed in the banner, the color of the banner, and the time in milliseconds to wait before removing the banner as arguments.
49
+ * @property {(e: React.MouseEvent | null, id: string) => void} REMOVE_ALERT_BANNER: A callback function to be called when removing an alert banner. The function takes the mouse event and the id of the banner as arguments.
50
+ * @property {(e: React.MouseEvent | null, id: string) => void} REMOVE_INFO_BANNER: A callback function to be called when removing an info banner. The function takes the mouse event and the id of the banner as arguments.
51
+ * @property {(e: React.MouseEvent) => void} REMOVE_ALL_INFO_BANNERS: A callback function to be called when removing all info banners. The function takes the mouse event as an argument.
52
+ * @property {(e: React.MouseEvent) => void} REMOVE_ALL_ALERT_BANNERS: A callback function to be called when removing all alert banners. The function takes the mouse event as an argument.
53
+ * @return {ReactElement} The rendered context provider component.
54
+ */
55
+ export declare const BannerProvider: FunctionComponent<BannerProviderProps>;
56
+ /**
57
+ * @hook useBannerContext
58
+ *
59
+ * - The props object containing the following properties:
60
+ * @property {BannerState} BANNER_STATE: The state of the banner.
61
+ * @property {(options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string} SET_INFO_BANNER: A callback function to be called when adding an info banner. The function takes the text to be displayed in the banner, the color of the banner, and the time in milliseconds to wait before removing the banner as arguments.
62
+ * @property {(options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string} SET_ALERT_BANNER: A callback function to be called when adding an alert banner. The function takes the text to be displayed in the banner, the color of the banner, and the time in milliseconds to wait before removing the banner as arguments.
63
+ * @property {(e: React.MouseEvent | null, id: string) => void} REMOVE_ALERT_BANNER: A callback function to be called when removing an alert banner. The function takes the mouse event and the id of the banner as arguments.
64
+ * @property {(e: React.MouseEvent | null, id: string) => void} REMOVE_INFO_BANNER: A callback function to be called when removing an info banner. The function takes the mouse event and the id of the banner as arguments.
65
+ * @property {(e: React.MouseEvent) => void} REMOVE_ALL_INFO_BANNERS: A callback function to be called when removing all info banners. The function takes the mouse event as an argument.
66
+ * @property {(e: React.MouseEvent) => void} REMOVE_ALL_ALERT_BANNERS: A callback function to be called when removing all alert banners. The function takes the mouse event as an argument.
67
+ * @return {BannerContextType} The context value.
68
+ */
69
+ export declare const useBannerContext: () => BannerContextType;
@@ -45,7 +45,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.useBannerContext = exports.BannerProvider = exports.BannerContext = void 0;
47
47
  var react_1 = __importStar(require("react"));
48
- exports.BannerContext = (0, react_1.createContext)();
48
+ exports.BannerContext = (0, react_1.createContext)(undefined);
49
49
  var counter = 0;
50
50
  // FEEDBACK:
51
51
  // needs to be outside the BannerProvider, else it gets called twice.
@@ -59,7 +59,7 @@ var bannerReducer = function (state, action) {
59
59
  var alertState = state.alertState;
60
60
  counter = counter + 1;
61
61
  newEntry = __assign({ id: "ALERT-".concat(counter) }, action.payload
62
- // if an id is passed in the payload itelf, it will override the counter based id
62
+ // if an id is passed in the payload itelf, it will override the counter based id
63
63
  );
64
64
  // if a alert banner exists with the same id, as the new one coming in,
65
65
  // we remove that first.
@@ -72,9 +72,7 @@ var bannerReducer = function (state, action) {
72
72
  else {
73
73
  newAlertState = __spreadArray([newEntry], alertState, true);
74
74
  }
75
- return __assign(__assign({}, state), { alertState: __spreadArray([
76
- newEntry
77
- ], alertState, true) });
75
+ return __assign(__assign({}, state), { alertState: newAlertState });
78
76
  case "ADD_INFO":
79
77
  var infoState = state.infoState;
80
78
  counter = counter + 1;
@@ -99,15 +97,26 @@ var bannerReducer = function (state, action) {
99
97
  newInfoState = state.infoState.filter(function (a) { return a.id !== action.id; });
100
98
  return __assign(__assign({}, state), { infoState: newInfoState });
101
99
  case "REMOVE_ALL_INFO":
102
- newInfoState = [];
103
- return __assign(__assign({}, state), { infoState: newInfoState });
100
+ return __assign(__assign({}, state), { infoState: [] });
104
101
  case "REMOVE_ALL_ALERT":
105
- newAlertState = [];
106
- return __assign(__assign({}, state), { alertState: newAlertState });
102
+ return __assign(__assign({}, state), { alertState: [] });
107
103
  default:
108
104
  return state;
109
105
  }
110
106
  };
107
+ /**
108
+ * @component Renders a context provider component for the banner component.
109
+ *
110
+ * - The context value object containing the following properties:
111
+ * @property {BannerState} BANNER_STATE: The state of the banner.
112
+ * @property {(options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string} SET_INFO_BANNER: A callback function to be called when adding an info banner. The function takes the text to be displayed in the banner, the color of the banner, and the time in milliseconds to wait before removing the banner as arguments.
113
+ * @property {(options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string} SET_ALERT_BANNER: A callback function to be called when adding an alert banner. The function takes the text to be displayed in the banner, the color of the banner, and the time in milliseconds to wait before removing the banner as arguments.
114
+ * @property {(e: React.MouseEvent | null, id: string) => void} REMOVE_ALERT_BANNER: A callback function to be called when removing an alert banner. The function takes the mouse event and the id of the banner as arguments.
115
+ * @property {(e: React.MouseEvent | null, id: string) => void} REMOVE_INFO_BANNER: A callback function to be called when removing an info banner. The function takes the mouse event and the id of the banner as arguments.
116
+ * @property {(e: React.MouseEvent) => void} REMOVE_ALL_INFO_BANNERS: A callback function to be called when removing all info banners. The function takes the mouse event as an argument.
117
+ * @property {(e: React.MouseEvent) => void} REMOVE_ALL_ALERT_BANNERS: A callback function to be called when removing all alert banners. The function takes the mouse event as an argument.
118
+ * @return {ReactElement} The rendered context provider component.
119
+ */
111
120
  var BannerProvider = function (_a) {
112
121
  var children = _a.children;
113
122
  var initialState = { alertState: [], infoState: [] };
@@ -118,19 +127,21 @@ var BannerProvider = function (_a) {
118
127
  var REMOVE_INFO_BANNER = function (e, id) {
119
128
  BANNER_DISPATCH({ type: "REMOVE_INFO", id: id });
120
129
  };
121
- var REMOVE_ALL_INFO_BANNERS = function (e, id) {
122
- BANNER_DISPATCH({ type: "REMOVE_ALL_INFO", id: id });
130
+ var REMOVE_ALL_INFO_BANNERS = function (e) {
131
+ BANNER_DISPATCH({ type: "REMOVE_ALL_INFO" });
123
132
  };
124
- var REMOVE_ALL_ALERT_BANNERS = function (e, id) {
125
- BANNER_DISPATCH({ type: "REMOVE_ALL_ALERT", id: id });
133
+ var REMOVE_ALL_ALERT_BANNERS = function (e) {
134
+ BANNER_DISPATCH({ type: "REMOVE_ALL_ALERT" });
126
135
  };
127
136
  // the config of bannner can either be passed as a object, or plain arguments.
128
137
  var SET_INFO_BANNER = function (options_msg, color, timeOut) {
129
- var options = {};
138
+ var options;
130
139
  if (typeof options_msg === 'string') { //means it is the 'msg' config
131
- options.msg = options_msg;
132
- options.color = color || 'green'; //defaults to green
133
- options.timeOut = timeOut;
140
+ options = {
141
+ msg: options_msg,
142
+ color: color || 'green', //defaults to green
143
+ timeOut: timeOut
144
+ };
134
145
  }
135
146
  else {
136
147
  options = options_msg;
@@ -139,11 +150,13 @@ var BannerProvider = function (_a) {
139
150
  return "INFO-".concat(counter); //bannerId
140
151
  };
141
152
  var SET_ALERT_BANNER = function (options_msg, color, timeOut) {
142
- var options = {};
153
+ var options;
143
154
  if (typeof options_msg === 'string') { //means it is the 'msg' config
144
- options.msg = options_msg;
145
- options.color = color || 'green'; //defaults to green
146
- options.timeOut = timeOut;
155
+ options = {
156
+ msg: options_msg,
157
+ color: color || 'green', //defaults to green
158
+ timeOut: timeOut
159
+ };
147
160
  }
148
161
  else {
149
162
  options = options_msg;
@@ -151,18 +164,36 @@ var BannerProvider = function (_a) {
151
164
  BANNER_DISPATCH({ type: "ADD_ALERT", payload: options });
152
165
  return "ALERT-".concat(counter); //bannerId
153
166
  };
154
- return (react_1.default.createElement(exports.BannerContext.Provider, { value: {
155
- BANNER_STATE: BANNER_STATE,
156
- SET_INFO_BANNER: SET_INFO_BANNER,
157
- SET_ALERT_BANNER: SET_ALERT_BANNER,
158
- REMOVE_ALERT_BANNER: REMOVE_ALERT_BANNER,
159
- REMOVE_INFO_BANNER: REMOVE_INFO_BANNER,
160
- REMOVE_ALL_INFO_BANNERS: REMOVE_ALL_INFO_BANNERS,
161
- REMOVE_ALL_ALERT_BANNERS: REMOVE_ALL_ALERT_BANNERS
162
- } }, children));
167
+ var contextValue = {
168
+ BANNER_STATE: BANNER_STATE,
169
+ SET_INFO_BANNER: SET_INFO_BANNER,
170
+ SET_ALERT_BANNER: SET_ALERT_BANNER,
171
+ REMOVE_ALERT_BANNER: REMOVE_ALERT_BANNER,
172
+ REMOVE_INFO_BANNER: REMOVE_INFO_BANNER,
173
+ REMOVE_ALL_INFO_BANNERS: REMOVE_ALL_INFO_BANNERS,
174
+ REMOVE_ALL_ALERT_BANNERS: REMOVE_ALL_ALERT_BANNERS
175
+ };
176
+ return react_1.default.createElement(exports.BannerContext.Provider, { value: contextValue }, children);
163
177
  };
164
178
  exports.BannerProvider = BannerProvider;
179
+ /**
180
+ * @hook useBannerContext
181
+ *
182
+ * - The props object containing the following properties:
183
+ * @property {BannerState} BANNER_STATE: The state of the banner.
184
+ * @property {(options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string} SET_INFO_BANNER: A callback function to be called when adding an info banner. The function takes the text to be displayed in the banner, the color of the banner, and the time in milliseconds to wait before removing the banner as arguments.
185
+ * @property {(options_msg: string | Omit<BannerEntry, "id">, color?: string, timeOut?: number) => string} SET_ALERT_BANNER: A callback function to be called when adding an alert banner. The function takes the text to be displayed in the banner, the color of the banner, and the time in milliseconds to wait before removing the banner as arguments.
186
+ * @property {(e: React.MouseEvent | null, id: string) => void} REMOVE_ALERT_BANNER: A callback function to be called when removing an alert banner. The function takes the mouse event and the id of the banner as arguments.
187
+ * @property {(e: React.MouseEvent | null, id: string) => void} REMOVE_INFO_BANNER: A callback function to be called when removing an info banner. The function takes the mouse event and the id of the banner as arguments.
188
+ * @property {(e: React.MouseEvent) => void} REMOVE_ALL_INFO_BANNERS: A callback function to be called when removing all info banners. The function takes the mouse event as an argument.
189
+ * @property {(e: React.MouseEvent) => void} REMOVE_ALL_ALERT_BANNERS: A callback function to be called when removing all alert banners. The function takes the mouse event as an argument.
190
+ * @return {BannerContextType} The context value.
191
+ */
165
192
  var useBannerContext = function () {
166
- return (0, react_1.useContext)(exports.BannerContext);
193
+ var context = (0, react_1.useContext)(exports.BannerContext);
194
+ if (context === undefined) {
195
+ throw new Error('useBannerContext must be used within a BannerProvider');
196
+ }
197
+ return context;
167
198
  };
168
199
  exports.useBannerContext = useBannerContext;
@@ -1,9 +1,78 @@
1
- export function BannerAlert({ BANNER_STATE, REMOVE_ALERT_BANNER }: {
2
- BANNER_STATE: any;
3
- REMOVE_ALERT_BANNER: any;
4
- }): React.JSX.Element;
5
- export function BannerInfo({ BANNER_STATE, REMOVE_INFO_BANNER }: {
6
- BANNER_STATE: any;
7
- REMOVE_INFO_BANNER: any;
8
- }): React.JSX.Element;
9
1
  import React from "react";
2
+ export type IconColor = 'red' | 'green' | 'yellow' | 'dark' | 'grey';
3
+ export interface DisplayIconProps {
4
+ color: IconColor;
5
+ }
6
+ export interface BannerCTA {
7
+ to?: string;
8
+ action?: () => void;
9
+ text: string;
10
+ }
11
+ export interface BannerProps {
12
+ color: IconColor;
13
+ cta?: BannerCTA;
14
+ msg: string;
15
+ handleRemove: (e: React.MouseEvent | null, id: string) => void;
16
+ id: string;
17
+ timeOut?: number;
18
+ showIcon?: boolean;
19
+ bottomStroke?: boolean;
20
+ hideCloseButton?: boolean;
21
+ }
22
+ export interface BannerState {
23
+ id: string;
24
+ color: IconColor;
25
+ msg: string;
26
+ cta?: BannerCTA;
27
+ timeOut?: number;
28
+ showIcon?: boolean;
29
+ hideCloseButton?: boolean;
30
+ }
31
+ export interface BannerAlertProps {
32
+ BANNER_STATE: {
33
+ alertState: BannerState[];
34
+ };
35
+ REMOVE_ALERT_BANNER: (e: React.MouseEvent | null, id: string) => void;
36
+ }
37
+ /**
38
+ * @component Renders a list of alert banners with customizable text, color and styling.
39
+ *
40
+ * - The props object containing the following properties
41
+ * @prop {BannerState[]} alertState: An array of BannerState objects, each containing the properties of a banner component.
42
+ * @prop {(e: React.MouseEvent | null, id: string) => void} REMOVE_ALERT_BANNER: 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.
43
+ * @return {ReactElement} The rendered list of alert banners component.
44
+ *
45
+ * @typedef {Object} BannerState
46
+ * @prop {string} id: The id of the banner.
47
+ * @prop {IconColor} color: The color of the banner.
48
+ * @prop {string} msg: The text to be displayed in the banner.
49
+ * @prop {BannerCTA} cta: An object containing the info about the cta button.
50
+ * @prop {number} timeOut: The time in milliseconds to wait before removing the banner. Defaults to 3000.
51
+ * @prop {boolean} showIcon: A boolean indicating whether to show the icon in the banner. Defaults to true.
52
+ * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
53
+ */
54
+ export declare const BannerAlert: React.FunctionComponent<BannerAlertProps>;
55
+ export interface BannerInfoProps {
56
+ BANNER_STATE: {
57
+ infoState: BannerState[];
58
+ };
59
+ REMOVE_INFO_BANNER: (e: React.MouseEvent | null, id: string) => void;
60
+ }
61
+ /**
62
+ * @component Renders a list of info banners with customizable text, color and styling.
63
+ *
64
+ * - The props object containing the following properties
65
+ * @prop {BannerState[]} infoState: An array of BannerState objects, each containing the properties of a banner component.
66
+ * @prop {(e: React.MouseEvent | null, id: string) => void} REMOVE_INFO_BANNER: 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.
67
+ * @return {ReactElement} The rendered list of info banners component.
68
+ *
69
+ * @typedef {Object} BannerState
70
+ * @prop {string} id: The id of the banner.
71
+ * @prop {IconColor} color: The color of the banner.
72
+ * @prop {string} msg: The text to be displayed in the banner.
73
+ * @prop {BannerCTA} cta: An object containing the info about the cta button.
74
+ * @prop {number} timeOut: The time in milliseconds to wait before removing the banner. Defaults to 3000.
75
+ * @prop {boolean} showIcon: A boolean indicating whether to show the icon in the banner. Defaults to true.
76
+ * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
77
+ */
78
+ export declare const BannerInfo: React.FunctionComponent<BannerInfoProps>;
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.BannerInfo = exports.BannerAlert = void 0;
27
27
  var react_1 = __importStar(require("react"));
28
- var index_styled_1 = require("./index.styled");
28
+ var styled_1 = require("./styled");
29
29
  var react_router_dom_1 = require("react-router-dom");
30
30
  var Buttons_1 = require("../Buttons");
31
31
  var icons_1 = require("../../icons");
@@ -42,20 +42,41 @@ var DisplayIcon = function (_a) {
42
42
  var IconComp = icons_1.icons[ICONS[color]];
43
43
  return react_1.default.createElement(react_1.default.Fragment, null, IconComp && react_1.default.createElement(IconComp, { size: 20, weight: "bold" }));
44
44
  };
45
+ /**
46
+ * @component Renders a banner component with customizable text, color and styling.
47
+ *
48
+ * - The object containing the following properties:
49
+ * @prop {IconColor} color: The color of the banner.
50
+ * @prop {BannerCTA} cta: The object containing the info about the cta button.
51
+ * @prop {string} msg: The text to be displayed in the banner.
52
+ * @prop {(e: React.MouseEvent | null, id: string) => void} handleRemove: The callback function to be called when the banner is removed.
53
+ * @prop {string} id: The id of the banner.
54
+ * @prop {number} timeOut: The time in milliseconds to wait before removing the banner. Defaults to 3000.
55
+ * @prop {boolean} showIcon: A boolean indicating whether to show the icon in the banner. Defaults to true.
56
+ * @prop {boolean} bottomStroke: A boolean indicating whether to show the bottom stroke in the banner. Defaults to true.
57
+ * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
58
+ * @return {ReactElement} The rendered banner component.
59
+ */
45
60
  var Banner = function (_a) {
46
61
  var color = _a.color, cta = _a.cta, msg = _a.msg, handleRemove = _a.handleRemove, id = _a.id, timeOut = _a.timeOut, showIcon = _a.showIcon, _b = _a.bottomStroke, bottomStroke = _b === void 0 ? true : _b, _c = _a.hideCloseButton, hideCloseButton = _c === void 0 ? false : _c;
47
62
  var _d = (0, react_1.useState)(0), height = _d[0], setHeight = _d[1];
48
- var ContainerRef = (0, react_1.useRef)();
63
+ var ContainerRef = (0, react_1.useRef)(null);
49
64
  (0, react_1.useEffect)(function () {
50
65
  var timer;
51
- setHeight(ContainerRef.current.scrollHeight);
52
- if (timeOut)
66
+ if (ContainerRef.current) {
67
+ setHeight(ContainerRef.current.scrollHeight);
68
+ }
69
+ if (timeOut) {
53
70
  timer = setTimeout(function () {
54
71
  setHeight(0);
55
72
  remove(null, id);
56
73
  }, timeOut);
57
- return function () { return (timeOut ? clearTimeout(timer) : null); };
58
- }, [cta, id, msg]);
74
+ }
75
+ return function () {
76
+ if (timer)
77
+ clearTimeout(timer);
78
+ };
79
+ }, [cta, id, msg, timeOut]);
59
80
  var remove = function (e, id) {
60
81
  setHeight(0);
61
82
  setTimeout(function () {
@@ -63,18 +84,35 @@ var Banner = function (_a) {
63
84
  }, 300);
64
85
  };
65
86
  var genCTA = function (cta) {
66
- var LinkWrapper = cta.to ? react_router_dom_1.Link : react_1.Fragment; //sometimes we wanna pass the cta as a 'to' string rather than a action function so that it is serializable
87
+ var LinkWrapper = cta.to ? react_router_dom_1.Link : react_1.Fragment;
67
88
  return (react_1.default.createElement(LinkWrapper, { to: cta.to },
68
- react_1.default.createElement(Buttons_1.ButtonSecondary, { style: { marginTop: "0.5rem", marginBottom: "0.5rem" }, S: true, onClick: !cta.to && cta.action, invert: color === "dark" ? true : false }, cta === null || cta === void 0 ? void 0 : cta.text)));
89
+ react_1.default.createElement(Buttons_1.ButtonSecondary, { style: { marginTop: "0.5rem", marginBottom: "0.5rem" }, S: true, onClick: !cta.to && cta.action, invert: color === "dark" }, cta === null || cta === void 0 ? void 0 : cta.text)));
69
90
  };
70
- return (react_1.default.createElement(index_styled_1.BannerAnimateStyled, { key: id, ref: ContainerRef, height: height },
71
- react_1.default.createElement(index_styled_1.BannerWrapperStyled, { bottomStroke: bottomStroke, color: color },
72
- react_1.default.createElement(index_styled_1.BannerStyled, null,
91
+ return (react_1.default.createElement(styled_1.BannerAnimateStyled, { key: id, ref: ContainerRef, height: height },
92
+ react_1.default.createElement(styled_1.BannerWrapperStyled, { bottomStroke: bottomStroke, color: color },
93
+ react_1.default.createElement(styled_1.BannerStyled, null,
73
94
  showIcon && react_1.default.createElement(DisplayIcon, { color: color }),
74
95
  react_1.default.createElement(Typo_1.SANS_2, null, msg),
75
96
  cta && genCTA(cta)),
76
- hideCloseButton !== true && react_1.default.createElement(Buttons_1.ButtonGhost, { S: true, icon: "X", invert: color === "dark" ? true : false, onClick: function (e) { return remove(e, id); } }))));
97
+ hideCloseButton !== true && react_1.default.createElement(Buttons_1.ButtonGhost, { S: true, icon: "X", invert: color === "dark", onClick: function (e) { return remove(e, id); } }))));
77
98
  };
99
+ /**
100
+ * @component Renders a list of alert banners with customizable text, color and styling.
101
+ *
102
+ * - The props object containing the following properties
103
+ * @prop {BannerState[]} alertState: An array of BannerState objects, each containing the properties of a banner component.
104
+ * @prop {(e: React.MouseEvent | null, id: string) => void} REMOVE_ALERT_BANNER: 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.
105
+ * @return {ReactElement} The rendered list of alert banners component.
106
+ *
107
+ * @typedef {Object} BannerState
108
+ * @prop {string} id: The id of the banner.
109
+ * @prop {IconColor} color: The color of the banner.
110
+ * @prop {string} msg: The text to be displayed in the banner.
111
+ * @prop {BannerCTA} cta: An object containing the info about the cta button.
112
+ * @prop {number} timeOut: The time in milliseconds to wait before removing the banner. Defaults to 3000.
113
+ * @prop {boolean} showIcon: A boolean indicating whether to show the icon in the banner. Defaults to true.
114
+ * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
115
+ */
78
116
  var BannerAlert = function (_a) {
79
117
  var _b;
80
118
  var BANNER_STATE = _a.BANNER_STATE, REMOVE_ALERT_BANNER = _a.REMOVE_ALERT_BANNER;
@@ -82,15 +120,34 @@ var BannerAlert = function (_a) {
82
120
  (0, react_1.useEffect)(function () {
83
121
  setTimeout(function () {
84
122
  var ele = document.getElementById("bannerInfo");
85
- setTop(ele.offsetHeight);
123
+ if (ele) {
124
+ setTop(ele.offsetHeight);
125
+ }
86
126
  }, 100);
87
- });
88
- return (react_1.default.createElement(index_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, showIcon: e.showIcon, hideCloseButton: e.hideCloseButton })); })));
127
+ }, []);
128
+ 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, showIcon: e.showIcon, hideCloseButton: e.hideCloseButton })); })));
89
129
  };
90
130
  exports.BannerAlert = BannerAlert;
131
+ /**
132
+ * @component Renders a list of info banners with customizable text, color and styling.
133
+ *
134
+ * - The props object containing the following properties
135
+ * @prop {BannerState[]} infoState: An array of BannerState objects, each containing the properties of a banner component.
136
+ * @prop {(e: React.MouseEvent | null, id: string) => void} REMOVE_INFO_BANNER: 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.
137
+ * @return {ReactElement} The rendered list of info banners component.
138
+ *
139
+ * @typedef {Object} BannerState
140
+ * @prop {string} id: The id of the banner.
141
+ * @prop {IconColor} color: The color of the banner.
142
+ * @prop {string} msg: The text to be displayed in the banner.
143
+ * @prop {BannerCTA} cta: An object containing the info about the cta button.
144
+ * @prop {number} timeOut: The time in milliseconds to wait before removing the banner. Defaults to 3000.
145
+ * @prop {boolean} showIcon: A boolean indicating whether to show the icon in the banner. Defaults to true.
146
+ * @prop {boolean} hideCloseButton: A boolean indicating whether to hide the close button in the banner. Defaults to false.
147
+ */
91
148
  var BannerInfo = function (_a) {
92
149
  var _b;
93
150
  var BANNER_STATE = _a.BANNER_STATE, REMOVE_INFO_BANNER = _a.REMOVE_INFO_BANNER;
94
- return (react_1.default.createElement(index_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, showIcon: e.showIcon, bottomStroke: false, hideCloseButton: e.hideCloseButton })); })));
151
+ 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, showIcon: e.showIcon, bottomStroke: false, hideCloseButton: e.hideCloseButton })); })));
95
152
  };
96
153
  exports.BannerInfo = BannerInfo;
@@ -0,0 +1,23 @@
1
+ export interface ColorConfig {
2
+ [key: string]: {
3
+ bgColor: string;
4
+ color?: string;
5
+ };
6
+ }
7
+ declare const colorConfig: ColorConfig;
8
+ interface BannerAnimateStyledProps {
9
+ height: number;
10
+ }
11
+ export declare const BannerAnimateStyled: import("styled-components").StyledComponent<"div", any, BannerAnimateStyledProps, never>;
12
+ interface BannerWrapperStyledProps {
13
+ color: keyof typeof colorConfig;
14
+ bottomStroke?: boolean;
15
+ }
16
+ export declare const BannerWrapperStyled: import("styled-components").StyledComponent<"div", any, BannerWrapperStyledProps, never>;
17
+ export declare const BannerStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
18
+ interface BannerAlertStyledProps {
19
+ top: number;
20
+ }
21
+ export declare const BannerAlertStyled: import("styled-components").StyledComponent<"div", any, BannerAlertStyledProps, never>;
22
+ export declare const BannerInfoStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
23
+ export {};
@@ -43,28 +43,22 @@ exports.BannerAnimateStyled = styled_components_1.default.div(templateObject_1 |
43
43
  var height = _a.height;
44
44
  return height;
45
45
  });
46
- exports.BannerWrapperStyled = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n padding: 0.5rem 2rem;\n position: relative;\n\n gap: 1rem;\n border-bottom: 1px solid ", ";\n background-color: ", ";\n\n ", "\n\n /* box-shadow: ", "; */\n\n color: ", ";\n\n ", " {\n align-items: center;\n }\n"], ["\n display: flex;\n padding: 0.5rem 2rem;\n position: relative;\n\n gap: 1rem;\n border-bottom: 1px solid ", ";\n background-color: ", ";\n\n ", "\n\n /* box-shadow: ", "; */\n\n color: ", ";\n\n ", " {\n align-items: center;\n }\n"])), greyColor15, function (_a) {
46
+ exports.BannerWrapperStyled = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n padding: 0.5rem 2rem;\n position: relative;\n gap: 1rem;\n border-bottom: 1px solid ", ";\n background-color: ", ";\n\n ", "\n\n color: ", ";\n\n ", " {\n align-items: center;\n }\n"], ["\n display: flex;\n padding: 0.5rem 2rem;\n position: relative;\n gap: 1rem;\n border-bottom: 1px solid ", ";\n background-color: ", ";\n\n ", "\n\n color: ", ";\n\n ", " {\n align-items: center;\n }\n"])), greyColor15, function (_a) {
47
47
  var _b;
48
48
  var color = _a.color;
49
49
  return (_b = colorConfig[color]) === null || _b === void 0 ? void 0 : _b.bgColor;
50
50
  }, function (_a) {
51
- var bottomStroke = _a.bottomStroke;
52
- return bottomStroke && (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: inset 00px -2px 0px ", ";\n "], ["\n box-shadow: inset 00px -2px 0px ", ";\n "])), function (_a) {
53
- var _b;
54
- var color = _a.color;
55
- return (_b = colorConfig[color]) === null || _b === void 0 ? void 0 : _b.color;
56
- });
57
- }, function (_a) {
58
- var bottomStroke = _a.bottomStroke;
59
- return bottomStroke && "";
51
+ var _b;
52
+ var bottomStroke = _a.bottomStroke, color = _a.color;
53
+ return bottomStroke && (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: inset 0px -2px 0px ", ";\n "], ["\n box-shadow: inset 0px -2px 0px ", ";\n "])), (_b = colorConfig[color]) === null || _b === void 0 ? void 0 : _b.color);
60
54
  }, function (_a) {
61
55
  var color = _a.color;
62
56
  return (color === "dark" ? white : "");
63
57
  }, (0, mixins_1.mediaQuery)("sm"));
64
58
  exports.BannerStyled = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 1rem;\n width: 100%;\n"], ["\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 1rem;\n width: 100%;\n"])));
65
- exports.BannerAlertStyled = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: sticky;\n z-index: 1000000000; //whatever this is, it should be more than modal\n width: 100%;\n ", ";\n\n ", "\n"], ["\n position: sticky;\n z-index: 1000000000; //whatever this is, it should be more than modal\n width: 100%;\n ", ";\n\n ", "\n"])), function (_a) {
59
+ exports.BannerAlertStyled = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: sticky;\n z-index: 1000000000;\n width: 100%;\n ", ";\n\n ", "\n"], ["\n position: sticky;\n z-index: 1000000000;\n width: 100%;\n ", ";\n\n ", "\n"])), function (_a) {
66
60
  var top = _a.top;
67
- return (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n top: ", "px;\n "], ["\n top: ", "px;\n "])), top);
61
+ return (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n top: ", "px;\n "], ["\n top: ", "px;\n "])), top);
68
62
  }, (0, mixins_1.transition)("top"));
69
63
  exports.BannerInfoStyled = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: sticky;\n z-index: 1000000000;\n top: 0;\n width: 100%;\n"], ["\n position: sticky;\n z-index: 1000000000;\n top: 0;\n width: 100%;\n"])));
70
64
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
@@ -14,5 +14,5 @@ declare function VideoInput({ id, label, sublabel, isRequired, value: _value, on
14
14
  files: any;
15
15
  width: any;
16
16
  height: any;
17
- }): React.JSX.Element;
17
+ }, ...args: any[]): React.JSX.Element;
18
18
  import React from 'react';
@@ -1,4 +1,15 @@
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
+ };
2
13
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
14
  if (k2 === undefined) k2 = k;
4
15
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -39,9 +50,11 @@ var useFakeUploadImpression_1 = require("../../utilsOolib/useFakeUploadImpressio
39
50
  var bannerContext_1 = require("../Banners/bannerContext");
40
51
  var VideoActionMenu_1 = require("./comps/VideoActionMenu");
41
52
  var FileUploadWrapper_1 = require("../FileUploadWrapper");
53
+ var getBlockLabelProps_1 = require("../../utils/getBlockLabelProps");
42
54
  function VideoInput(_a) {
43
55
  var id = _a.id, label = _a.label, sublabel = _a.sublabel, isRequired = _a.isRequired, _value = _a.value, onChange = _a.onChange, readOnly = _a.readOnly, lightPlayer = _a.light, _b = _a.enableVideoUpload, enableVideoUpload = _b === void 0 ? false : _b, isInRTE = _a.isInRTE, invert = _a.invert, files = _a.files, // //used by RTEVideoInput
44
56
  width = _a.width, height = _a.height;
57
+ var props = arguments[0];
45
58
  //backwards compatibility
46
59
  var value = typeof _value === 'string'
47
60
  ? [{ publicUrl: _value }]
@@ -111,7 +124,7 @@ function VideoInput(_a) {
111
124
  }
112
125
  };
113
126
  return (react_1.default.createElement(react_1.Fragment, null,
114
- react_1.default.createElement(BlockLabel_1.BlockLabel, { label: label, sublabel: sublabel, isRequired: isRequired, readOnly: readOnly, invert: invert }),
127
+ react_1.default.createElement(BlockLabel_1.BlockLabel, __assign({}, (0, getBlockLabelProps_1.getBlockLabelProps)(props))),
115
128
  readOnly ? (createVideoPreview({ value: value })) :
116
129
  (value === null || value === void 0 ? void 0 : value.length) > 0 ? (createVideoPreview({ value: value, actionMenuButton: true })) :
117
130
  react_1.default.createElement(FileUploadWrapper_1.FileUploadWrapper, { height: '18rem', isLoading: isLoading, uploadProgress: uploadProgress, enableClickUpload: false, mediaType: 'video', handleUpload: handleUpload },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.135.1",
3
+ "version": "2.136.0",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,5 +0,0 @@
1
- export const BannerAnimateStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export const BannerWrapperStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export const BannerStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- export const BannerAlertStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- export const BannerInfoStyled: import("styled-components").StyledComponent<"div", any, {}, never>;