oolib 2.216.0 → 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.
|
@@ -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
|
};
|
|
@@ -13,6 +13,7 @@ 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",
|
|
@@ -158,3 +159,17 @@ var Toast = function (args) {
|
|
|
158
159
|
React.createElement("i", null, "Note: change props and click on add more button"))));
|
|
159
160
|
};
|
|
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
|
+
// };
|