oolib 2.135.1 → 2.136.1
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/Banners/bannerContext.d.ts +69 -6
- package/dist/components/Banners/bannerContext.js +62 -31
- package/dist/components/Banners/index.d.ts +77 -8
- package/dist/components/Banners/index.js +73 -16
- package/dist/components/Banners/styled.d.ts +23 -0
- package/dist/components/Banners/{index.styled.js → styled.js} +6 -12
- package/dist/components/PercentBarChart/comps/CustomizedLabel/index.d.ts +2 -3
- package/dist/components/PercentBarChart/comps/CustomizedLabel/index.js +9 -3
- package/dist/components/PercentBarChart/index.d.ts +3 -1
- package/dist/components/PercentBarChart/index.js +7 -13
- package/dist/components/VideoInput/index.d.ts +1 -1
- package/dist/components/VideoInput/index.js +14 -1
- package/dist/stories/Oolib/components/PercentBarChart.stories.js +4 -4
- package/package.json +1 -1
- package/dist/components/Banners/index.styled.d.ts +0 -5
|
@@ -1,6 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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:
|
|
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
|
-
|
|
103
|
-
return __assign(__assign({}, state), { infoState: newInfoState });
|
|
100
|
+
return __assign(__assign({}, state), { infoState: [] });
|
|
104
101
|
case "REMOVE_ALL_ALERT":
|
|
105
|
-
|
|
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
|
|
122
|
-
BANNER_DISPATCH({ type: "REMOVE_ALL_INFO"
|
|
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
|
|
125
|
-
BANNER_DISPATCH({ type: "REMOVE_ALL_ALERT"
|
|
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
|
|
132
|
-
|
|
133
|
-
|
|
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
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
52
|
-
|
|
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
|
-
|
|
58
|
-
|
|
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;
|
|
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"
|
|
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(
|
|
71
|
-
react_1.default.createElement(
|
|
72
|
-
react_1.default.createElement(
|
|
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"
|
|
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
|
-
|
|
123
|
+
if (ele) {
|
|
124
|
+
setTop(ele.offsetHeight);
|
|
125
|
+
}
|
|
86
126
|
}, 100);
|
|
87
|
-
});
|
|
88
|
-
return (react_1.default.createElement(
|
|
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(
|
|
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
|
|
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
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
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
|
|
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;
|
|
@@ -5,14 +5,13 @@ type TCustomizedLabeValue = {
|
|
|
5
5
|
count: number;
|
|
6
6
|
name: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const CustomizedLabel: ({ y, width, height, value,
|
|
8
|
+
export declare const CustomizedLabel: ({ y, width, height, value, plotDataPoint, opacity, _base_configs, onMouseOver, onMouseOut, onMouseDown, }: {
|
|
9
9
|
y?: number | string;
|
|
10
10
|
width?: number | string;
|
|
11
11
|
height?: number | string;
|
|
12
12
|
value?: TCustomizedLabeValue;
|
|
13
13
|
opacity: number;
|
|
14
|
-
|
|
15
|
-
showCount?: boolean;
|
|
14
|
+
plotDataPoint?: "percentage" | "count";
|
|
16
15
|
_base_configs: TBaseConfigs;
|
|
17
16
|
onMouseOver?: (e: React.MouseEvent<SVGRectElement, MouseEvent>, v: TCustomizedLabeValue) => void;
|
|
18
17
|
onMouseOut?: (e: React.MouseEvent<SVGRectElement, MouseEvent>, v: TCustomizedLabeValue) => void;
|
|
@@ -8,7 +8,7 @@ var react_1 = __importDefault(require("react"));
|
|
|
8
8
|
var themes_1 = require("../../../../themes");
|
|
9
9
|
var CustomizedLabel = function (_a) {
|
|
10
10
|
var y = _a.y, width = _a.width, //i think this is the width and the height of the bar. dont need it just yet..
|
|
11
|
-
height = _a.height, value = _a.value,
|
|
11
|
+
height = _a.height, value = _a.value, plotDataPoint = _a.plotDataPoint, opacity = _a.opacity, _base_configs = _a._base_configs, onMouseOver = _a.onMouseOver, onMouseOut = _a.onMouseOut, onMouseDown = _a.onMouseDown;
|
|
12
12
|
var yOffset = -(_base_configs.labelToBarGap + _base_configs.barHeight);
|
|
13
13
|
var percent = value.percentage;
|
|
14
14
|
var count = value.count;
|
|
@@ -16,8 +16,14 @@ var CustomizedLabel = function (_a) {
|
|
|
16
16
|
var percentXOffset = 0;
|
|
17
17
|
var xOffsetRelative = 10;
|
|
18
18
|
return (react_1.default.createElement("g", null,
|
|
19
|
-
react_1.default.createElement("text", { opacity: opacity, x: percentXOffset, y: y + yOffset, fill: themes_1.colors.greyColor100, textAnchor: "start", dominantBaseline: "middle", className: "UI_BODY_BOLD_SM" },
|
|
20
|
-
|
|
19
|
+
react_1.default.createElement("text", { opacity: opacity, x: percentXOffset, y: y + yOffset, fill: themes_1.colors.greyColor100, textAnchor: "start", dominantBaseline: "middle", className: "UI_BODY_BOLD_SM" },
|
|
20
|
+
plotDataPoint === "percentage"
|
|
21
|
+
? percent + "%"
|
|
22
|
+
: plotDataPoint === "count"
|
|
23
|
+
? count
|
|
24
|
+
: "",
|
|
25
|
+
plotDataPoint === "percentage" && ( // basically no need to show this only if plotDataPoint is count, since in that case, count is already shown above
|
|
26
|
+
react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, y: y + yOffset, fill: themes_1.colors.greyColor80 }, count)),
|
|
21
27
|
react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, y: y + yOffset, fill: themes_1.colors.greyColor80 }, name)),
|
|
22
28
|
react_1.default.createElement("rect", { onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, value); }, onMouseOver: function (e) { return onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, value); }, onMouseOut: function (e) { return onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, value); }, x: percentXOffset, y: y + _base_configs.mouseEventDetectorYOffset, width: width, height: _base_configs.mouseEventDetectorHeight, fill: "red", "fill-opacity": _base_configs.mouseEventDetectorOpacity })));
|
|
23
29
|
};
|
|
@@ -7,7 +7,7 @@ export type TBaseConfigs = {
|
|
|
7
7
|
mouseEventDetectorHeight: number;
|
|
8
8
|
mouseEventDetectorOpacity: number;
|
|
9
9
|
};
|
|
10
|
-
export declare const PercentBarChart: ({ data: _data, title, valuePath, labelPath, onClick, colors, colorIdx,
|
|
10
|
+
export declare const PercentBarChart: ({ data: _data, title, valuePath, labelPath, onClick, colors, colorIdx, plotDataPoint, }: {
|
|
11
11
|
data: any;
|
|
12
12
|
valuePath: string;
|
|
13
13
|
labelPath: string;
|
|
@@ -16,5 +16,7 @@ export declare const PercentBarChart: ({ data: _data, title, valuePath, labelPat
|
|
|
16
16
|
colors?: string[];
|
|
17
17
|
colorIdx?: number;
|
|
18
18
|
valueSuffix?: string;
|
|
19
|
+
plotDataPoint?: 'percentage' | 'count';
|
|
19
20
|
showCount?: boolean;
|
|
21
|
+
showPercent?: boolean;
|
|
20
22
|
}) => React.JSX.Element;
|
|
@@ -83,28 +83,23 @@ var PercentBarChart = function (_a) {
|
|
|
83
83
|
_c = _a.labelPath, // is relevant only for the initial data setting in useMemo. after that, the actual percentage is always stored against the 'percentage' key, and the count against the 'count' key
|
|
84
84
|
labelPath = _c === void 0 ? "name" : _c, // same as above for label path
|
|
85
85
|
onClick = _a.onClick, _d = _a.colors, colors = _d === void 0 ? chartColors : _d, _e = _a.colorIdx, colorIdx = _e === void 0 ? 0 : _e, //if you are rendering a grid of such charts, then maybe you want each of their colors to be different. in that case, increment this idx from the parent component
|
|
86
|
-
_f = _a.
|
|
87
|
-
|
|
86
|
+
_f = _a.plotDataPoint, //if you are rendering a grid of such charts, then maybe you want each of their colors to be different. in that case, increment this idx from the parent component
|
|
87
|
+
plotDataPoint = _f === void 0 ? 'percentage' : _f;
|
|
88
88
|
var totalCount = (0, getTotalCount_1.getTotalCount)({ data: _data, countPath: valuePath });
|
|
89
89
|
var data = (0, react_1.useMemo)(function () {
|
|
90
90
|
var finalData = __spreadArray([], _data, true);
|
|
91
91
|
finalData = finalData.map(function (d, i) {
|
|
92
|
-
var percentage = (0, _EXPORTS_1.getPercentage)((0, _EXPORTS_1.getVal)(d, valuePath), totalCount);
|
|
93
92
|
var count = (0, _EXPORTS_1.getVal)(d, valuePath);
|
|
94
93
|
return ({
|
|
95
|
-
labels: {
|
|
96
|
-
percentage: percentage,
|
|
97
|
-
count: count,
|
|
98
|
-
name: (0, _EXPORTS_1.getVal)(d, labelPath),
|
|
99
|
-
},
|
|
94
|
+
labels: __assign(__assign({}, (plotDataPoint === 'percentage' ? { percentage: (0, _EXPORTS_1.getPercentage)((0, _EXPORTS_1.getVal)(d, valuePath), totalCount) } : {})), { count: count, name: (0, _EXPORTS_1.getVal)(d, labelPath) }),
|
|
100
95
|
});
|
|
101
96
|
});
|
|
102
97
|
finalData.sort(function (a, b) {
|
|
103
|
-
return Number(b.
|
|
98
|
+
return Number((0, _EXPORTS_1.getVal)(b, "labels.".concat(plotDataPoint)) || 0) - Number((0, _EXPORTS_1.getVal)(a, "labels.".concat(plotDataPoint)) || 0);
|
|
104
99
|
});
|
|
105
100
|
return finalData;
|
|
106
101
|
}, [_data, labelPath, valuePath]);
|
|
107
|
-
var
|
|
102
|
+
var _g = (0, react_1.useState)(undefined), activeBar = _g[0], setActiveBar = _g[1];
|
|
108
103
|
var changeBarOpacityFn = function (name) {
|
|
109
104
|
return activeBar && activeBar !== name ? 0.4 : 1;
|
|
110
105
|
};
|
|
@@ -137,13 +132,12 @@ var PercentBarChart = function (_a) {
|
|
|
137
132
|
} },
|
|
138
133
|
react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number" }),
|
|
139
134
|
react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category" }),
|
|
140
|
-
react_1.default.createElement(recharts_1.Bar, { radius: _base_configs.barRadius, style: onClick ? { cursor: "pointer" } : {}, dataKey: "labels.
|
|
135
|
+
react_1.default.createElement(recharts_1.Bar, { radius: _base_configs.barRadius, style: onClick ? { cursor: "pointer" } : {}, dataKey: "labels.".concat(plotDataPoint) },
|
|
141
136
|
react_1.default.createElement(recharts_1.LabelList, { dataKey: "labels", offset: 0, content: function (props) { return react_1.default.createElement(CustomizedLabel_1.CustomizedLabel, __assign({ y: props.y,
|
|
142
137
|
width: props.width,
|
|
143
138
|
height: props.height,
|
|
144
139
|
value: props.value, //here value is the percentage
|
|
145
|
-
|
|
146
|
-
opacity: changeBarOpacityFn(props.value.name), _base_configs: _base_configs }, (onClick
|
|
140
|
+
plotDataPoint: plotDataPoint, opacity: changeBarOpacityFn(props.value.name), _base_configs: _base_configs }, (onClick
|
|
147
141
|
? {
|
|
148
142
|
onMouseOver: function (e, value) { return setActiveBar(value.name); },
|
|
149
143
|
onMouseOut: function () { return setActiveBar(undefined); },
|
|
@@ -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, {
|
|
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 },
|
|
@@ -10,10 +10,10 @@ exports.default = {
|
|
|
10
10
|
title: "Components/PercentBarChart",
|
|
11
11
|
};
|
|
12
12
|
var data = [
|
|
13
|
-
{ display:
|
|
14
|
-
{ display:
|
|
15
|
-
{ display:
|
|
16
|
-
{ display:
|
|
13
|
+
{ display: 'Logged In Once', value: 60 },
|
|
14
|
+
{ display: 'Registered Users', value: 100 },
|
|
15
|
+
{ display: 'Created Profile', value: 20 },
|
|
16
|
+
{ display: 'Wrote at least 1 story', value: 8 }
|
|
17
17
|
];
|
|
18
18
|
var PercentBarChart_ = function (args) {
|
|
19
19
|
var handleBarClick = function (name) {
|
package/package.json
CHANGED
|
@@ -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>;
|