empower-container 0.1.11 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- package/{src/main → dist}/assets/Asset.d.ts +0 -0
- package/{src/main → dist}/assets/Asset.js +0 -0
- package/{src/main → dist}/assets/Asset.tsx +0 -0
- package/{src/main → dist}/assets/icons/icon-check-white-sm.svg +0 -0
- package/{src/main → dist}/assets/images/icon-arrowdown-graydark.svg +0 -0
- package/{src/main → dist}/assets/images/icon-arrowleft-graydark.svg +0 -0
- package/{src/main → dist}/assets/images/icon-arrowright-graydark.svg +0 -0
- package/{src/main → dist}/assets/images/icon-arrowup-graydark.svg +0 -0
- package/{src/main → dist}/assets/images/icon-check-graydark.svg +0 -0
- package/{src/main → dist/cjs}/DatetimeFormatter.d.ts +0 -0
- package/{src/main → dist/cjs}/DatetimeFormatter.js +0 -0
- package/{src/main → dist/cjs}/Information.d.ts +0 -0
- package/dist/cjs/Information.js +63 -0
- package/{src/main → dist/cjs}/MenuBar.d.ts +0 -0
- package/dist/cjs/MenuBar.js +537 -0
- package/{src/main → dist/cjs}/Modal.d.ts +0 -0
- package/dist/cjs/Modal.js +32 -0
- package/dist/cjs/assets/Asset.d.ts +16 -0
- package/dist/cjs/assets/Asset.js +30 -0
- package/{src/main → dist/cjs}/constants/Constant.d.ts +0 -0
- package/dist/cjs/constants/Constant.js +35 -0
- package/{src/main → dist/cjs}/index.d.ts +0 -0
- package/{src/main → dist/cjs}/index.js +0 -0
- package/{src/main → dist/cjs}/inputs/Input.d.ts +0 -0
- package/{src/main → dist/cjs}/inputs/Input.js +7 -36
- package/{src/main → dist/cjs}/inputs/InputSelectionHandler.d.ts +0 -0
- package/{src/main → dist/cjs}/inputs/InputSelectionHandler.js +3 -3
- package/{src/main → dist/cjs}/inputs/Select.d.ts +0 -0
- package/{src/main → dist/cjs}/inputs/Select.js +11 -64
- package/dist/esm/DatetimeFormatter.d.ts +3 -0
- package/{src/main/DatetimeFormatter.tsx → dist/esm/DatetimeFormatter.js} +132 -139
- package/dist/esm/Information.d.ts +10 -0
- package/dist/esm/Information.js +38 -0
- package/dist/esm/MenuBar.d.ts +24 -0
- package/dist/esm/MenuBar.js +532 -0
- package/dist/esm/Modal.d.ts +33 -0
- package/dist/esm/Modal.js +27 -0
- package/dist/esm/assets/Asset.d.ts +16 -0
- package/dist/esm/assets/Asset.js +27 -0
- package/dist/esm/constants/Constant.d.ts +15 -0
- package/{src/main → dist/esm}/constants/Constant.js +9 -21
- package/{src/main/index.tsx → dist/esm/index.d.ts} +1 -3
- package/dist/esm/index.js +3 -0
- package/dist/esm/inputs/Input.d.ts +25 -0
- package/dist/esm/inputs/Input.js +104 -0
- package/dist/esm/inputs/InputSelectionHandler.d.ts +3 -0
- package/dist/esm/inputs/InputSelectionHandler.js +31 -0
- package/dist/esm/inputs/Select.d.ts +28 -0
- package/dist/esm/inputs/Select.js +399 -0
- package/{src → dist}/scss/components/_modal.scss +0 -0
- package/{src → dist}/scss/elements/_button.scss +0 -0
- package/{src → dist}/scss/elements/_index.scss +0 -0
- package/{src → dist}/scss/elements/_popover.scss +0 -0
- package/{src → dist}/scss/foundation/_colors.scss +0 -0
- package/{src → dist}/scss/foundation/_mixins.scss +0 -0
- package/{src → dist}/scss/foundation/_normalize.scss +0 -0
- package/{src → dist}/scss/foundation/_settings.scss +0 -0
- package/{src → dist}/scss/foundation/_typography.scss +0 -0
- package/{src → dist}/scss/library/_information.scss +0 -0
- package/{src → dist}/scss/library/_input.scss +0 -0
- package/{src → dist}/scss/library/_menubar.scss +0 -0
- package/{src → dist}/scss/library/_select.scss +0 -0
- package/{src → dist}/scss/style.scss +0 -0
- package/package.json +1 -1
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/src/index.tsx +0 -15
- package/src/main/Information.js +0 -65
- package/src/main/Information.tsx +0 -112
- package/src/main/MenuBar.js +0 -651
- package/src/main/MenuBar.tsx +0 -1074
- package/src/main/Modal.js +0 -24
- package/src/main/Modal.tsx +0 -83
- package/src/main/inputs/Input.tsx +0 -193
- package/src/main/inputs/InputSelectionHandler.tsx +0 -21
- package/src/main/inputs/Select.tsx +0 -654
- package/src/main/tsconfig.common.json +0 -34
- package/src/main/tsconfig.json +0 -35
- package/src/sample/App.css +0 -38
- package/src/sample/App.d.ts +0 -3
- package/src/sample/App.js +0 -13
- package/src/sample/App.test.d.ts +0 -1
- package/src/sample/App.test.js +0 -13
- package/src/sample/App.test.tsx +0 -9
- package/src/sample/App.tsx +0 -15
- package/src/sample/TestMenuBar.d.ts +0 -3
- package/src/sample/TestMenuBar.js +0 -527
- package/src/sample/TestMenuBar.tsx +0 -377
- package/src/sample/react-app-env.d.ts +0 -1
- package/src/sample/reportWebVitals.d.ts +0 -3
- package/src/sample/reportWebVitals.js +0 -38
- package/src/sample/reportWebVitals.ts +0 -15
- package/src/sample/setupTests.d.ts +0 -1
- package/src/sample/setupTests.js +0 -7
- package/src/sample/setupTests.ts +0 -5
- package/src/sample/tsconfig.json +0 -36
package/src/main/MenuBar.tsx
DELETED
@@ -1,1074 +0,0 @@
|
|
1
|
-
/* eslint-disable no-useless-concat */
|
2
|
-
/* eslint-disable jsx-a11y/anchor-is-valid */
|
3
|
-
import React, { useState, Fragment, useEffect } from "react";
|
4
|
-
import '../scss/style.scss';
|
5
|
-
|
6
|
-
// Imports
|
7
|
-
import { SVG_BACK, SVG_CLOSE_GRAY, SVG_ARROWLEFT, SVG_ARROWRIGHT, SVG_CHECK, SVG_ARROWDOWN, SVG_INFORMATION } from './assets/Asset';
|
8
|
-
import { CHECKBOX, MONTH_LIST, INFO_LOADER, PAGE_OPTION } from "./constants/Constant";
|
9
|
-
import Information from './Information';
|
10
|
-
import Input from './inputs/InputSelectionHandler';
|
11
|
-
import datetimeFormatter from './DatetimeFormatter';
|
12
|
-
import { Popover } from './inputs/Select';
|
13
|
-
|
14
|
-
// Package
|
15
|
-
import { Calendar } from 'react-date-range';
|
16
|
-
|
17
|
-
interface IMenuBarProps {
|
18
|
-
|
19
|
-
config?: any,
|
20
|
-
info?: any,
|
21
|
-
button?: {
|
22
|
-
show: boolean
|
23
|
-
actions?: Array<object>
|
24
|
-
},
|
25
|
-
|
26
|
-
dropdown?: any,
|
27
|
-
search?: any,
|
28
|
-
pagination?: any,
|
29
|
-
pivot?: any,
|
30
|
-
check?: any,
|
31
|
-
toggle?: any,
|
32
|
-
mainButton?: any,
|
33
|
-
buttonFooter?: any,
|
34
|
-
undoButton?:any,
|
35
|
-
customClass?: string,
|
36
|
-
children: any,
|
37
|
-
getActions: any
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
const MenuBar: React.FunctionComponent<IMenuBarProps> = ({ config, info, button, getActions, dropdown, search, pagination, pivot, check, toggle, mainButton, buttonFooter, undoButton, customClass, children }) => {
|
43
|
-
|
44
|
-
// React Hooks Popover
|
45
|
-
let [infoPopover, setInfoPopover] = useState(null);
|
46
|
-
let [mainButtonPopover, setMainButtonPopover] = useState<any>(null);
|
47
|
-
let [dropdownPopover, setDropdownPopover] = useState<any>(null);
|
48
|
-
let [paginationSummaryPopover, setPaginationSummaryPopover] = useState<any>(null);
|
49
|
-
let [pivotPopover, setPivotPopover] = useState<any>(null);
|
50
|
-
let [filterPopover, setFilterPopover] = useState<any>(null);
|
51
|
-
let [calendarYear, setCalendarYear] = useState<any>("");
|
52
|
-
let [minMonthIdx, setMinMonthIdx] = useState<any>(null);
|
53
|
-
let [maxMonthIdx, setMaxMonthIdx] = useState<any>(null);
|
54
|
-
|
55
|
-
// React Hooks Variables
|
56
|
-
let [searchTemporaryValue, setSearchTemporaryValue] = useState<string>('');
|
57
|
-
let [goToPage, setGoToPage] = useState<any>(1);
|
58
|
-
let [perPageTemporaryValue, setPerPageTemporaryValue] = useState<string>("");
|
59
|
-
let [paginationSummaryFormError, setPaginationSummaryFormError] = useState<Array<string>>([]);
|
60
|
-
let [loaded, setLoaded] = useState(false);
|
61
|
-
let [seconds, setSeconds] = useState(0);
|
62
|
-
let [undoShow, setUndoShow] = useState(undoButton && undoButton.show ? true : false);
|
63
|
-
let [doneTimer, setDoneTimer] = useState<boolean>(false);
|
64
|
-
|
65
|
-
useEffect(() => {
|
66
|
-
let filteredMonthList = []
|
67
|
-
if (dropdown && dropdown.minMonth) {
|
68
|
-
filteredMonthList = [...MONTH_LIST].filter(item => (item.value.toLowerCase() === dropdown.minMonth.toLowerCase()));
|
69
|
-
if (filteredMonthList.length > 0) {
|
70
|
-
minMonthIdx = MONTH_LIST.indexOf(filteredMonthList[0]);
|
71
|
-
setMinMonthIdx(minMonthIdx);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
if (dropdown && dropdown.maxMonth) {
|
75
|
-
filteredMonthList = [...MONTH_LIST].filter(item => (item.value.toLowerCase() === dropdown.maxMonth.toLowerCase()));
|
76
|
-
if (filteredMonthList.length > 0) {
|
77
|
-
maxMonthIdx = MONTH_LIST.indexOf(filteredMonthList[0]);
|
78
|
-
setMaxMonthIdx(maxMonthIdx);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
if (search && search.value && loaded === false) {
|
83
|
-
setSearchTemporaryValue(search.value);
|
84
|
-
setLoaded(true);
|
85
|
-
}
|
86
|
-
|
87
|
-
if (undoButton && undoButton.show) {
|
88
|
-
let buttonWithTimer = undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (
|
89
|
-
undoButton.actions.filter((item: any) => (item.hasOwnProperty('timer') && item.timer !== undefined && item.timer.constructor === Number))
|
90
|
-
) : [];
|
91
|
-
|
92
|
-
if (buttonWithTimer.length > 0) {
|
93
|
-
if (undoShow !== undoButton.show) {
|
94
|
-
if (buttonWithTimer[0] && buttonWithTimer[0].hasOwnProperty('timer')) {
|
95
|
-
|
96
|
-
buttonWithTimer[0].timer && setSeconds(buttonWithTimer[0].timer);
|
97
|
-
}
|
98
|
-
|
99
|
-
setDoneTimer(false);
|
100
|
-
setUndoShow(undoButton.show ? true : false);
|
101
|
-
}
|
102
|
-
let myInterval = setInterval(() => {
|
103
|
-
if (seconds > 0) {
|
104
|
-
setSeconds(seconds - 1);
|
105
|
-
} else {
|
106
|
-
if (!doneTimer) {
|
107
|
-
clearInterval(myInterval);
|
108
|
-
setDoneTimer(true)
|
109
|
-
returnValues('button', buttonWithTimer[0].action, null);
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}, 1000)
|
113
|
-
return () => {
|
114
|
-
clearInterval(myInterval);
|
115
|
-
};
|
116
|
-
}
|
117
|
-
} else {
|
118
|
-
setUndoShow(false);
|
119
|
-
}
|
120
|
-
|
121
|
-
});
|
122
|
-
|
123
|
-
|
124
|
-
// Belt Configuration Variables
|
125
|
-
info = info ? (
|
126
|
-
info.constructor === Object && info.infoDetails ? (
|
127
|
-
info
|
128
|
-
) : info.constructor === String ? (
|
129
|
-
info
|
130
|
-
) : INFO_LOADER
|
131
|
-
) : INFO_LOADER;
|
132
|
-
let dropdownTitle = dropdown && (dropdown.type === 'list' || dropdown.type === 'button') ? (
|
133
|
-
dropdown.title ? dropdown.title : ""
|
134
|
-
) : dropdown && dropdown.type === 'date-picker-weekly' ? (
|
135
|
-
dropdown.selection && dropdown.selection.startDate && dropdown.selection.endDate ? (
|
136
|
-
dropdown.selection.startDate + ' to ' + dropdown.selection.endDate
|
137
|
-
) : ""
|
138
|
-
) : dropdown && dropdown.type === 'date-picker-monthly' ? dropdown.selection.startDate : "";
|
139
|
-
|
140
|
-
/**
|
141
|
-
* popoverRequestHandler
|
142
|
-
* hide and show the popover of specific action
|
143
|
-
* @param {*} e - event of the click item
|
144
|
-
* @param {*} popover - popover type
|
145
|
-
*/
|
146
|
-
let popoverRequestHandler = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | any, popover: string, hide: boolean = false) => {
|
147
|
-
|
148
|
-
switch (popover) {
|
149
|
-
case 'info':
|
150
|
-
const { currentTarget } = e;
|
151
|
-
|
152
|
-
if (hide === false && info.constructor === String && info === INFO_LOADER) {
|
153
|
-
actionRequestHandler(e, 'icon', 'info')
|
154
|
-
setInfoPopover(e.currentTarget);
|
155
|
-
setTimeout(() => {
|
156
|
-
setInfoPopover(null);
|
157
|
-
setInfoPopover(currentTarget);
|
158
|
-
|
159
|
-
}, 2000);
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
} else {
|
165
|
-
infoPopover ? setInfoPopover(null) : setInfoPopover(e.currentTarget);
|
166
|
-
}
|
167
|
-
|
168
|
-
|
169
|
-
break;
|
170
|
-
case 'dropdown':
|
171
|
-
if (dropdown.type === 'date-picker-monthly' && !dropdownPopover) {
|
172
|
-
dropdown.selection && dropdown.selection.startDate ? setCalendarYear(datetimeFormatter(dropdown.selection.startDate, 'full-year')) : setCalendarYear(new Date())
|
173
|
-
} else if (dropdown.type === 'date-picker-cutoff' && !dropdownPopover) {
|
174
|
-
setCalendarYear(dropdown.currentYear); //need to improve on this one
|
175
|
-
}
|
176
|
-
dropdownPopover ? setDropdownPopover(null) : setDropdownPopover(e.currentTarget);
|
177
|
-
break;
|
178
|
-
case 'pagination-summary':
|
179
|
-
if (!Boolean(paginationSummaryPopover)) {
|
180
|
-
pagination && pagination.page ? setGoToPage(pagination.page) : setGoToPage(1);
|
181
|
-
setPerPageTemporaryValue(pagination.perPage ? pagination.perPage.toString() : '')
|
182
|
-
}
|
183
|
-
paginationSummaryPopover ? setPaginationSummaryPopover(null) : setPaginationSummaryPopover(e.currentTarget);
|
184
|
-
break;
|
185
|
-
case 'pivot':
|
186
|
-
pivotPopover ? setPivotPopover(null) : setPivotPopover(e.currentTarget);
|
187
|
-
break;
|
188
|
-
case 'filter':
|
189
|
-
filterPopover ? setFilterPopover(null) : setFilterPopover(e.currentTarget);
|
190
|
-
break;
|
191
|
-
case 'main-button':
|
192
|
-
if (hide) {
|
193
|
-
setMainButtonPopover(null);
|
194
|
-
} else {
|
195
|
-
mainButtonPopover ? setMainButtonPopover(null) : setMainButtonPopover(e.currentTarget);
|
196
|
-
}
|
197
|
-
break;
|
198
|
-
default:
|
199
|
-
break;
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|
203
|
-
/**
|
204
|
-
* actionRequestHandler
|
205
|
-
* manipulate the action and data of each action
|
206
|
-
* @param {*} e - event
|
207
|
-
* @param {*} type - action type / can be the action itself
|
208
|
-
* @param {*} action - it can be action type / data depends on the used actions
|
209
|
-
*/
|
210
|
-
let actionRequestHandler = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> |
|
211
|
-
React.MouseEvent<HTMLDivElement, MouseEvent> |
|
212
|
-
React.MouseEvent<HTMLButtonElement, MouseEvent>,
|
213
|
-
type: string,
|
214
|
-
action: string | object,
|
215
|
-
hidePopover: boolean = true) => {
|
216
|
-
|
217
|
-
if (e.preventDefault) {
|
218
|
-
e.preventDefault();
|
219
|
-
}
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
let data: any = null;
|
224
|
-
let addedParam: any = null;
|
225
|
-
if (type === 'search') {
|
226
|
-
data = searchTemporaryValue;
|
227
|
-
} else if (type === 'pagination' || type === 'pagination-summary') {
|
228
|
-
data = pagination;
|
229
|
-
} else if (type === 'dropdown' || type === 'pivot' || type === 'main-button' || type === 'button' || type === 'icon' || type === 'check' || type === 'tab' || type === 'toggle') {
|
230
|
-
data = action;
|
231
|
-
action = type;
|
232
|
-
if (dropdown && dropdown.type === 'date-picker-cutoff') {
|
233
|
-
addedParam = calendarYear;
|
234
|
-
}
|
235
|
-
} else if (type === 'undo-button') {
|
236
|
-
data = action;
|
237
|
-
action = type;
|
238
|
-
}
|
239
|
-
|
240
|
-
if (hidePopover) {
|
241
|
-
popoverRequestHandler(e, type, true);
|
242
|
-
}
|
243
|
-
|
244
|
-
setTimeout(function () {
|
245
|
-
returnValues(action, data, addedParam);
|
246
|
-
}, 200);
|
247
|
-
}
|
248
|
-
|
249
|
-
/**
|
250
|
-
* handleChangeFormValue
|
251
|
-
* manipulate the inputs temporary values
|
252
|
-
* @param {*} e - event
|
253
|
-
* @param {*} type - type of the input that has been changed
|
254
|
-
*/
|
255
|
-
let handleChangeFormValue = (e: any, type: string) => {
|
256
|
-
switch (type) {
|
257
|
-
case 'search':
|
258
|
-
|
259
|
-
e.target.value ? setSearchTemporaryValue(e.target.value) : setSearchTemporaryValue("");
|
260
|
-
break;
|
261
|
-
case 'show-per-page':
|
262
|
-
setPerPageTemporaryValue(e.target.value.toString());
|
263
|
-
setGoToPage(1);
|
264
|
-
if (paginationSummaryFormError.indexOf('perPageTemporaryValue') >= 0 && (e !== "")) {
|
265
|
-
paginationSummaryFormError = paginationSummaryFormError.filter(item => item !== 'perPageTemporaryValue');
|
266
|
-
setPaginationSummaryFormError(paginationSummaryFormError);
|
267
|
-
}
|
268
|
-
break;
|
269
|
-
case 'go-to-page':
|
270
|
-
setGoToPage(e.target.value);
|
271
|
-
if (paginationSummaryFormError.indexOf('goToPage') >= 0 && (e.currentTarget.value !== "" || e.currentTarget.value > 1)) {
|
272
|
-
paginationSummaryFormError = paginationSummaryFormError.filter((item: any) => item !== 'goToPage');
|
273
|
-
setPaginationSummaryFormError(paginationSummaryFormError);
|
274
|
-
}
|
275
|
-
break;
|
276
|
-
case 'advanced-filter':
|
277
|
-
returnValues(type, e);
|
278
|
-
break;
|
279
|
-
default:
|
280
|
-
break;
|
281
|
-
}
|
282
|
-
}
|
283
|
-
|
284
|
-
/**
|
285
|
-
* paginationRequestHandler
|
286
|
-
* manipulate the paginations value depend on the action
|
287
|
-
* @param {*} e - event
|
288
|
-
* @param {*} action - action that the user do
|
289
|
-
*/
|
290
|
-
let paginationRequestHandler = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>, action: string) => {
|
291
|
-
e.preventDefault();
|
292
|
-
let paginationCopy = { ...pagination };
|
293
|
-
switch (action) {
|
294
|
-
case 'check-pagination-required':
|
295
|
-
let formError = [];
|
296
|
-
if (goToPage === "" || goToPage < 1) {
|
297
|
-
formError.push('goToPage');
|
298
|
-
}
|
299
|
-
if (perPageTemporaryValue === "") {
|
300
|
-
formError.push('perPageTemporaryValue');
|
301
|
-
}
|
302
|
-
return formError;
|
303
|
-
case 'submit':
|
304
|
-
let errorFields: any = paginationRequestHandler(e, 'check-pagination-required');
|
305
|
-
if (errorFields.length > 0) {
|
306
|
-
setPaginationSummaryFormError(errorFields);
|
307
|
-
} else {
|
308
|
-
pagination.perPage = perPageTemporaryValue ? parseInt(perPageTemporaryValue) : pagination.perPage;
|
309
|
-
pagination.page = goToPage ? (
|
310
|
-
(pagination.perPage * goToPage) > pagination.total ? (
|
311
|
-
Math.floor(pagination.total / pagination.perPage) + 1
|
312
|
-
) : parseInt(goToPage)
|
313
|
-
) : 1;
|
314
|
-
pagination.counter = (pagination.page * pagination.perPage) > pagination.total ? pagination.total : (pagination.page * pagination.perPage);
|
315
|
-
// if (paginationCopy.perPage !== pagination.perPage || paginationCopy.page !== pagination.page || paginationCopy.counter !== pagination.counter) {
|
316
|
-
actionRequestHandler(e, 'pagination-summary', 'pagination');
|
317
|
-
// }
|
318
|
-
}
|
319
|
-
break;
|
320
|
-
case 'next':
|
321
|
-
pagination.page = ((pagination.page++) * pagination.perPage) > pagination.total ? (
|
322
|
-
Math.floor(pagination.total / pagination.perPage) + 1
|
323
|
-
) : pagination.page++;
|
324
|
-
pagination.counter = (pagination.page * pagination.perPage) > pagination.total ? pagination.total : (pagination.page * pagination.perPage);
|
325
|
-
if (paginationCopy.page !== pagination.page || paginationCopy.counter !== pagination.counter) {
|
326
|
-
actionRequestHandler(e, 'pagination', 'pagination');
|
327
|
-
}
|
328
|
-
break;
|
329
|
-
case 'prev':
|
330
|
-
pagination.page = pagination.page > 1 ? pagination.page -= 1 : pagination.page;
|
331
|
-
pagination.counter = pagination.page * pagination.perPage;
|
332
|
-
if (paginationCopy.page !== pagination.page || paginationCopy.counter !== pagination.counter) {
|
333
|
-
actionRequestHandler(e, 'pagination', 'pagination');
|
334
|
-
}
|
335
|
-
break;
|
336
|
-
default:
|
337
|
-
break;
|
338
|
-
}
|
339
|
-
}
|
340
|
-
|
341
|
-
/**
|
342
|
-
* checkboxRequestHandler
|
343
|
-
* select all / unselect all items
|
344
|
-
* @param {*} e - event
|
345
|
-
* @param {*} action - action of the checkbox
|
346
|
-
*/
|
347
|
-
let checkboxRequestHandler = (e: React.MouseEvent<HTMLDivElement, MouseEvent>, action: string) => {
|
348
|
-
// e.preventDefault();
|
349
|
-
if (check.disabled !== true) {
|
350
|
-
if (action === 'all') {
|
351
|
-
actionRequestHandler(e, 'check', 'all');
|
352
|
-
} else {
|
353
|
-
actionRequestHandler(e, 'check', 'none');
|
354
|
-
}
|
355
|
-
}
|
356
|
-
|
357
|
-
}
|
358
|
-
|
359
|
-
/**
|
360
|
-
* onDatePickerChange
|
361
|
-
* change the datepicker value
|
362
|
-
* @param {*} e - event
|
363
|
-
* @param {*} type - action type
|
364
|
-
*/
|
365
|
-
let onDatePickerChange = (e: Date|any, type: string) => {
|
366
|
-
if (dropdown.type === 'date-picker-weekly') {
|
367
|
-
dropdown.selection.startDate = datetimeFormatter(e, 'start-of-Week');
|
368
|
-
dropdown.selection.endDate = datetimeFormatter(e, 'end-of-Week');
|
369
|
-
}
|
370
|
-
actionRequestHandler(e, type, dropdown.selection);
|
371
|
-
}
|
372
|
-
|
373
|
-
/**
|
374
|
-
* dateMonthlyPickerHandler
|
375
|
-
* selection of month on a calendar and changing of year
|
376
|
-
* @param {*} e - event
|
377
|
-
* @param {*} action - action type
|
378
|
-
*/
|
379
|
-
let dateMonthlyPickerHandler = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | React.MouseEvent<HTMLButtonElement, MouseEvent>, action: string, data: string = '') => {
|
380
|
-
type opt = { maxYear: string; minYear: string; }
|
381
|
-
let { maxYear, minYear }: opt = { ...dropdown }
|
382
|
-
let newDateValue = null;
|
383
|
-
let standardDate = null;
|
384
|
-
let selectedMonthDate=null;
|
385
|
-
let monthIdx = null;
|
386
|
-
let fullYear = null;
|
387
|
-
if (action === 'next') {
|
388
|
-
if (!maxYear || (maxYear && parseInt(maxYear) >= calendarYear + 1)) {
|
389
|
-
calendarYear += 1;
|
390
|
-
setCalendarYear(calendarYear)
|
391
|
-
}
|
392
|
-
} else if (action === 'prev') {
|
393
|
-
if (!minYear || (minYear && parseInt(minYear) <= calendarYear - 1)) {
|
394
|
-
calendarYear -= 1;
|
395
|
-
setCalendarYear(calendarYear)
|
396
|
-
}
|
397
|
-
} else if (action === 'month-selection') {
|
398
|
-
newDateValue = datetimeFormatter(data + ' ' + calendarYear, 'month-year');
|
399
|
-
actionRequestHandler(e, 'dropdown', newDateValue);
|
400
|
-
} else if (action === 'next-month') {
|
401
|
-
standardDate = datetimeFormatter(dropdown.selection.startDate, 'date-standard');
|
402
|
-
selectedMonthDate = new Date(new Date(standardDate).toLocaleString('en-US', { timeZone: 'Asia/Manila' })); //making the date picked as the default gmt so that the new date wont adjust by timezone;
|
403
|
-
monthIdx = selectedMonthDate.getMonth();
|
404
|
-
fullYear = selectedMonthDate.getFullYear();
|
405
|
-
if (monthIdx + 1 < 12) {
|
406
|
-
monthIdx = monthIdx + 1;
|
407
|
-
} else {
|
408
|
-
monthIdx = 0;
|
409
|
-
fullYear = fullYear + 1;
|
410
|
-
}
|
411
|
-
if ((!maxYear && !maxMonthIdx) || fullYear < parseInt(maxYear) || (fullYear === parseInt(maxYear) && monthIdx <= parseInt(maxMonthIdx))) {
|
412
|
-
newDateValue = datetimeFormatter(MONTH_LIST[monthIdx].value + ' ' + fullYear, 'month-year');
|
413
|
-
actionRequestHandler(e, 'dropdown', newDateValue, false);
|
414
|
-
}
|
415
|
-
} else if (action === 'prev-month') {
|
416
|
-
standardDate = datetimeFormatter(dropdown.selection.startDate, 'date-standard');
|
417
|
-
selectedMonthDate = new Date(new Date(standardDate).toLocaleString('en-US', { timeZone: 'Asia/Manila' })); //making the date picked as the default gmt so that the new date wont adjust by timezone;
|
418
|
-
|
419
|
-
monthIdx = selectedMonthDate.getMonth();
|
420
|
-
fullYear = selectedMonthDate.getFullYear();
|
421
|
-
if (monthIdx - 1 >= 0) {
|
422
|
-
monthIdx = monthIdx - 1;
|
423
|
-
} else {
|
424
|
-
monthIdx = 11;
|
425
|
-
fullYear = fullYear - 1;
|
426
|
-
}
|
427
|
-
if ((!minYear && !minMonthIdx) || fullYear > parseInt(minYear) || (fullYear === parseInt(minYear) && monthIdx >= parseInt(minMonthIdx))) {
|
428
|
-
let newDateValue = datetimeFormatter(MONTH_LIST[monthIdx].value + ' ' + fullYear, 'month-year');
|
429
|
-
actionRequestHandler(e, 'dropdown', newDateValue, false);
|
430
|
-
}
|
431
|
-
}
|
432
|
-
}
|
433
|
-
|
434
|
-
let dateCutoffPickerHandler = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>, label: string, value: string) => {
|
435
|
-
let cutOffVal = {
|
436
|
-
"label": label,
|
437
|
-
"value": value,
|
438
|
-
}
|
439
|
-
actionRequestHandler(e, 'dropdown', cutOffVal);
|
440
|
-
}
|
441
|
-
|
442
|
-
/**
|
443
|
-
* returnValues
|
444
|
-
* return manipulated value from beltConfig to the parent component
|
445
|
-
* @param {*} action - done action on beltConfig
|
446
|
-
* @param {*} data - manipulated data from the action
|
447
|
-
*/
|
448
|
-
let returnValues = (action: any, data: string, addedParam = null) => {
|
449
|
-
return getActions ? getActions(action, data, addedParam) : false;
|
450
|
-
}
|
451
|
-
|
452
|
-
/**
|
453
|
-
* dateMonthlyPickerIsSelected
|
454
|
-
* determine if month is selected
|
455
|
-
* @param {*} month - month value
|
456
|
-
*/
|
457
|
-
let dateMonthlyPickerIsSelected = (month: string) => {
|
458
|
-
let isSelected = false;
|
459
|
-
if (dropdown && dropdown.selection && dropdown.selection.startDate && calendarYear) {
|
460
|
-
let monthYear = month + ' ' + calendarYear;
|
461
|
-
isSelected = datetimeFormatter(dropdown.selection.startDate.toString(), 'month-year') === datetimeFormatter(monthYear, 'month-year') ? true : false
|
462
|
-
}
|
463
|
-
return isSelected;
|
464
|
-
}
|
465
|
-
|
466
|
-
let isDisabledDropdownPagination = (action: string) => {
|
467
|
-
type opt = { maxYear?: string; minYear: string; selection: any }
|
468
|
-
let { maxYear, minYear, selection }: opt = { ...dropdown }
|
469
|
-
let selectedMonthDate = new Date(selection.startDate);
|
470
|
-
let monthIdx = selectedMonthDate.getMonth();
|
471
|
-
let fullYear = selectedMonthDate.getFullYear();
|
472
|
-
if (action === 'prev') {
|
473
|
-
if (minYear && minMonthIdx && fullYear === parseInt(minYear) && monthIdx === parseInt(minMonthIdx)) {
|
474
|
-
return ' is-disabled';
|
475
|
-
} else {
|
476
|
-
return '';
|
477
|
-
}
|
478
|
-
} else if (action === 'next') {
|
479
|
-
if (maxYear && maxMonthIdx && fullYear === parseInt(maxYear) && monthIdx === parseInt(maxMonthIdx)) {
|
480
|
-
return ' is-disabled';
|
481
|
-
} else {
|
482
|
-
return '';
|
483
|
-
}
|
484
|
-
}
|
485
|
-
}
|
486
|
-
|
487
|
-
let toggleSelectionHandler = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>, value: string) => {
|
488
|
-
event.preventDefault();
|
489
|
-
actionRequestHandler(event, 'toggle', value, false);
|
490
|
-
}
|
491
|
-
|
492
|
-
return (
|
493
|
-
<div className={customClass && customClass.constructor === String ? customClass : 'custom-card'}>
|
494
|
-
{/* Menubar Division */}
|
495
|
-
<div className="em-card-belt">
|
496
|
-
{/* Menubar Left */}
|
497
|
-
<div className="em-belt-left">
|
498
|
-
<div className="em-beltleft-container">
|
499
|
-
{
|
500
|
-
// Back Icon Configuration
|
501
|
-
config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("back") >= 0) || (config.iconType === 'back')) ? (
|
502
|
-
<a className="belt-icon icon-back"
|
503
|
-
href="#"
|
504
|
-
onClick={event => actionRequestHandler(event, 'icon', 'back')}
|
505
|
-
data-testid="menubar-back"
|
506
|
-
>
|
507
|
-
{SVG_BACK}
|
508
|
-
</a>
|
509
|
-
) : null
|
510
|
-
}
|
511
|
-
|
512
|
-
{
|
513
|
-
// Check Icon Configuration
|
514
|
-
config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("check") >= 0) || (config.iconType === 'check')) ? (
|
515
|
-
<div className="belt-icon-check" data-testid="menubar-checkbox">
|
516
|
-
{
|
517
|
-
check ? (
|
518
|
-
check.selected === 0 ? (
|
519
|
-
<div onClick={(event) => checkboxRequestHandler(event, 'all')}>
|
520
|
-
{CHECKBOX.NONE}
|
521
|
-
</div>
|
522
|
-
) : check.selected > 0 && check.selected < check.total ? (
|
523
|
-
<div onClick={(event) => checkboxRequestHandler(event, 'all')}>
|
524
|
-
{CHECKBOX.FEW}
|
525
|
-
</div>
|
526
|
-
) : check.selected === check.total ? (
|
527
|
-
<div onClick={(event) => checkboxRequestHandler(event, 'none')}>
|
528
|
-
{CHECKBOX.ALL}
|
529
|
-
</div>
|
530
|
-
) : <div>
|
531
|
-
{CHECKBOX.NONE}
|
532
|
-
</div>
|
533
|
-
) : <div>
|
534
|
-
{CHECKBOX.NONE}
|
535
|
-
</div>
|
536
|
-
}
|
537
|
-
</div>
|
538
|
-
) : null
|
539
|
-
}
|
540
|
-
|
541
|
-
{
|
542
|
-
// Standard Icon Configuration
|
543
|
-
config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("standard") >= 0) || (config.iconType === 'standard')) ? (
|
544
|
-
<div className="belt-icon" data-testid="menubar-standard-icon">{config.icon}</div>
|
545
|
-
) : null
|
546
|
-
}
|
547
|
-
|
548
|
-
<div className="belt-title">
|
549
|
-
{
|
550
|
-
// Title Configuration
|
551
|
-
check && check.selected && check.selected > 0 && check.selected < check.total ? (
|
552
|
-
<h6>{`${check.selected} ${check.selected === 1 ? 'item selected' : 'items selected'}`}</h6>
|
553
|
-
) : check && check.selected && check.selected === check.total ? (
|
554
|
-
<h6>All item(s) selected</h6>
|
555
|
-
) : config && config.title && (config.title.constructor === String || config.title.constructor === Object) ? (
|
556
|
-
<h6 className="config-title" data-testid="menubar-title">{config.title}</h6>
|
557
|
-
) : null
|
558
|
-
}
|
559
|
-
|
560
|
-
{
|
561
|
-
// Title Information Configuration
|
562
|
-
config && config.titleDescription ? (
|
563
|
-
<p>{config.titleDescription}</p>
|
564
|
-
) : null
|
565
|
-
}
|
566
|
-
</div>
|
567
|
-
|
568
|
-
{
|
569
|
-
// Information Configuration
|
570
|
-
config && config.showInfo.constructor === Boolean && config.showInfo===true ? (
|
571
|
-
<Fragment>
|
572
|
-
<div className="em-belt-info">
|
573
|
-
<a href="#" onClick={event => popoverRequestHandler(event, 'info')}
|
574
|
-
data-testid="menubar-information">
|
575
|
-
<div className="em-info-icon">{SVG_INFORMATION}</div>
|
576
|
-
</a>
|
577
|
-
<Popover
|
578
|
-
id="InfoPopOver"
|
579
|
-
open={Boolean(infoPopover)}
|
580
|
-
className={Boolean(dropdownPopover) ? 'open-popover' : ''}
|
581
|
-
onClick={event => popoverRequestHandler(event, 'info')}
|
582
|
-
>
|
583
|
-
|
584
|
-
<Information
|
585
|
-
items={info && info.infoDetails ? info.infoDetails : info}
|
586
|
-
listRow={info && info.listRow ? info.listRow : []}
|
587
|
-
desc={info && info.listRow && info.listRow.length > 0 ? false : true}
|
588
|
-
title={config && config.title ? config.title.toUpperCase() : null}
|
589
|
-
hide={event => popoverRequestHandler(event, 'info', true)}
|
590
|
-
/>
|
591
|
-
|
592
|
-
</Popover>
|
593
|
-
</div>
|
594
|
-
</Fragment>
|
595
|
-
) : null
|
596
|
-
}
|
597
|
-
{
|
598
|
-
// Additional title on the modal
|
599
|
-
config && config.addedTitle ? (
|
600
|
-
<p>{config.addedTitle}</p>
|
601
|
-
) : null
|
602
|
-
}
|
603
|
-
</div>
|
604
|
-
<div className="em-beltleft-cta">
|
605
|
-
{
|
606
|
-
mainButton && mainButton.show ? (
|
607
|
-
mainButton.actions && mainButton.actions.constructor === Array && mainButton.actions.length > 1 ? (
|
608
|
-
<Fragment>
|
609
|
-
<div className="em-dropdown">
|
610
|
-
<a className="em-button belt-action-main" id="main-button" href="#" onClick={event => popoverRequestHandler(event, 'main-button')}>
|
611
|
-
<div className="belt-icon">{mainButton.icon ? mainButton.icon : ''}</div>
|
612
|
-
<span>{mainButton.label ? mainButton.label : 'File a Request'}</span>
|
613
|
-
</a>
|
614
|
-
<Popover
|
615
|
-
id="mainButtonPopover"
|
616
|
-
open={Boolean(mainButtonPopover)}
|
617
|
-
onClick={event => popoverRequestHandler(event, 'main-button')}
|
618
|
-
className={Boolean(dropdownPopover) ? 'open-popover' : ''}
|
619
|
-
>
|
620
|
-
<div className="popover em-popover-list">
|
621
|
-
{mainButton.actions.map((btn: any, idx: number) =>
|
622
|
-
<a href="#" key={idx} onClick={event => actionRequestHandler(event, 'main-button', btn.action)}>{btn.label}</a>
|
623
|
-
)}
|
624
|
-
</div>
|
625
|
-
</Popover>
|
626
|
-
</div>
|
627
|
-
</Fragment>
|
628
|
-
) : mainButton.actions && mainButton.actions.constructor === Array && mainButton.actions.length === 1 ? (
|
629
|
-
mainButton.actions.map((btn: any, idx: number) => {
|
630
|
-
return (
|
631
|
-
<a className={btn.class ? 'belt-action ' + btn.class : 'belt-action'} href="#" key={idx} onClick={event => actionRequestHandler(event, 'main-button', btn.action)}>
|
632
|
-
<div className="belt-icon ">{btn.icon ? btn.icon : ''}</div>
|
633
|
-
<span>{btn.label ? btn.label : ''}</span>
|
634
|
-
</a>
|
635
|
-
)
|
636
|
-
})
|
637
|
-
) : null
|
638
|
-
) : null
|
639
|
-
}
|
640
|
-
|
641
|
-
{
|
642
|
-
// Button Actions Configuration
|
643
|
-
button && button.show && button.show.constructor === Boolean &&
|
644
|
-
button.actions && button.actions.constructor === Array && button.actions.length > 0 ? (
|
645
|
-
button.actions.map((btn: any, idx: number) => {
|
646
|
-
return (
|
647
|
-
<a className={btn.class ? btn.class : ' belt-action' + ' ' + (idx === 0 ? 'is-primary' : '')} href="#" key={idx} onClick={event => actionRequestHandler(event, 'button', btn.action)} data-testid="menubar-button">
|
648
|
-
<div className="belt-icon belt-buttons">{btn.icon ? btn.icon : ''}</div>
|
649
|
-
<span data-testid={'button-action-' + btn.action}>{btn.label ? btn.label : ''}</span>
|
650
|
-
</a>
|
651
|
-
)
|
652
|
-
})
|
653
|
-
) : null
|
654
|
-
}
|
655
|
-
|
656
|
-
{
|
657
|
-
// UndoButton Actions Configuration
|
658
|
-
undoButton && undoButton.show && !undoButton.isFooter &&
|
659
|
-
undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (
|
660
|
-
undoButton.actions.map((btn: any, idx: number) => {
|
661
|
-
return seconds > 0 || (btn.timer !== undefined) ? (
|
662
|
-
<a
|
663
|
-
className={btn.class ? btn.class : 'belt-action' + ' ' + (idx === 0 ? 'is-primary' : '') + (btn.disabled === true ? ' is-disabled' : ' em-button outline button-undo')}
|
664
|
-
href="#"
|
665
|
-
data-testid={`undo-button-${btn.action}`}
|
666
|
-
key={idx}
|
667
|
-
{...(btn.disabled === true ? { onClick: event => { event.preventDefault() } } : { onClick: event => actionRequestHandler(event, 'undo-button', btn.action) })}>
|
668
|
-
<div className="belt-icon">{btn.icon ? btn.icon : ''}</div>
|
669
|
-
<span data-testid="undo-button-text">{btn.label ? (
|
670
|
-
`${btn.label} ${btn.timer !== undefined && btn.timer.constructor === Number && seconds > 0 ? (
|
671
|
-
`in ${seconds}s`
|
672
|
-
) : ''}`
|
673
|
-
) : ''}</span>
|
674
|
-
</a>
|
675
|
-
) : null
|
676
|
-
})
|
677
|
-
) : null
|
678
|
-
}
|
679
|
-
</div>
|
680
|
-
</div>
|
681
|
-
|
682
|
-
{/* Menubar Right */}
|
683
|
-
<div className="em-belt-right">
|
684
|
-
{
|
685
|
-
// Dropdown Actions Configuration
|
686
|
-
dropdown && dropdown.show && dropdown.show.constructor === Boolean ? (
|
687
|
-
<Fragment>
|
688
|
-
<div className="em-dropdown">
|
689
|
-
{
|
690
|
-
dropdown.type === 'list' ? (
|
691
|
-
<a className="belt-dropdown" id="add" href="#" onClick={event => popoverRequestHandler(event, 'dropdown')}>
|
692
|
-
<div className="icon-add">{dropdown.icon ? dropdown.icon : ''}</div>
|
693
|
-
<span>{dropdownTitle}</span>
|
694
|
-
</a>
|
695
|
-
) : dropdown.type === 'date-picker-weekly' ? (
|
696
|
-
<a id="months"
|
697
|
-
className={`belt-dropdown ${Boolean(dropdownPopover) ? 'is-active' : ''}`}
|
698
|
-
href="#"
|
699
|
-
onClick={event => popoverRequestHandler(event, 'dropdown')}
|
700
|
-
>
|
701
|
-
<span>{dropdownTitle}</span>
|
702
|
-
<div className="icon-arrowdown">
|
703
|
-
{SVG_ARROWDOWN}
|
704
|
-
</div>
|
705
|
-
</a>
|
706
|
-
) : dropdown.type === 'date-picker-monthly' ? (
|
707
|
-
<Fragment>
|
708
|
-
<a id="months"
|
709
|
-
className={`belt-dropdown ${Boolean(dropdownPopover) ? 'is-active' : ''}`}
|
710
|
-
href="#"
|
711
|
-
onClick={event => popoverRequestHandler(event, 'dropdown')}
|
712
|
-
>
|
713
|
-
<span>{dropdownTitle}</span>
|
714
|
-
<div className="icon-arrowdown">
|
715
|
-
{SVG_ARROWDOWN}
|
716
|
-
</div>
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
</a>
|
721
|
-
{
|
722
|
-
dropdown.showPagination ? (
|
723
|
-
<Fragment>
|
724
|
-
<a
|
725
|
-
className={'belt-prev' + isDisabledDropdownPagination('prev')}
|
726
|
-
href="#"
|
727
|
-
onClick={event => dateMonthlyPickerHandler(event, 'prev-month')}
|
728
|
-
>
|
729
|
-
<div className="belt-icon">{SVG_ARROWLEFT}</div>
|
730
|
-
</a>
|
731
|
-
<a
|
732
|
-
className={'belt-next' + isDisabledDropdownPagination('next')}
|
733
|
-
href="#"
|
734
|
-
onClick={event => dateMonthlyPickerHandler(event, 'next-month')}
|
735
|
-
>
|
736
|
-
<div className="belt-icon">{SVG_ARROWRIGHT}</div>
|
737
|
-
</a>
|
738
|
-
</Fragment>
|
739
|
-
) : null
|
740
|
-
}
|
741
|
-
</Fragment>
|
742
|
-
) : dropdown.type === 'date-picker-cutoff' ? (
|
743
|
-
(
|
744
|
-
<a className="belt-dropdown" id="add" href="#" onClick={event => popoverRequestHandler(event, 'dropdown')}>
|
745
|
-
<span>{dropdown.cutoffValue && dropdown.cutoffValue.label ? dropdown.cutoffValue.label : ''}</span>
|
746
|
-
</a>
|
747
|
-
)
|
748
|
-
) : dropdown.type === 'button' ? (
|
749
|
-
<a className="belt-dropdown" id="add" href="#" onClick={event => actionRequestHandler(event, 'button', dropdown.action)}>
|
750
|
-
<div className="belt-icon">{dropdown.icon ? dropdown.icon : ''}</div>
|
751
|
-
<span>{dropdownTitle}</span>
|
752
|
-
</a>
|
753
|
-
) : (
|
754
|
-
<a className="belt-dropdown" id="add" href="#" onClick={event => popoverRequestHandler(event, 'dropdown')}>
|
755
|
-
<span>{dropdownTitle}</span>
|
756
|
-
</a>
|
757
|
-
)
|
758
|
-
}
|
759
|
-
<Popover
|
760
|
-
id="dropdownPopover"
|
761
|
-
className={Boolean(dropdownPopover) ? 'open-popover' : ''}
|
762
|
-
open={Boolean(dropdownPopover)}
|
763
|
-
onClick={event => popoverRequestHandler(event, 'dropdown')}
|
764
|
-
|
765
|
-
>
|
766
|
-
|
767
|
-
{
|
768
|
-
dropdown.type === 'list' ? (
|
769
|
-
dropdown.actions && dropdown.actions.constructor === Array && dropdown.actions.length > 0 ? (
|
770
|
-
<div className="popover em-popover-list">
|
771
|
-
{dropdown.actions.map((drpdwn: any, idx: number) =>
|
772
|
-
<a href="#" key={idx} onClick={event => actionRequestHandler(event, 'dropdown', drpdwn.value)}>{drpdwn.label}</a>
|
773
|
-
)}
|
774
|
-
</div>
|
775
|
-
) : null
|
776
|
-
) : dropdown.type === 'date-picker-weekly' ? (
|
777
|
-
<div className="popover">
|
778
|
-
<Calendar
|
779
|
-
className="dateRangePickerInput"
|
780
|
-
onChange={event => onDatePickerChange(event, 'dropdown')}
|
781
|
-
/>
|
782
|
-
</div>
|
783
|
-
) : dropdown.type === 'date-picker-monthly' ? (
|
784
|
-
<div className="popover em-popover-months">
|
785
|
-
<div className="list-years">
|
786
|
-
<button onClick={event => dateMonthlyPickerHandler(event, 'prev')} >{SVG_ARROWLEFT}</button>
|
787
|
-
<div>{calendarYear}</div>
|
788
|
-
<button onClick={event => dateMonthlyPickerHandler(event, 'next')} >{SVG_ARROWRIGHT}</button>
|
789
|
-
</div>
|
790
|
-
<div className="list-months">
|
791
|
-
{MONTH_LIST.map((action: any, idx: number) =>
|
792
|
-
dropdown.minYear && dropdown.minYear.toString() === calendarYear.toString() && minMonthIdx && minMonthIdx > idx ? (
|
793
|
-
<a href="#" key={idx} className='is-disabled' onClick={event => { event.preventDefault() }}>{action.label}</a>
|
794
|
-
) : dropdown.maxYear && dropdown.maxYear.toString() === calendarYear.toString() && maxMonthIdx && maxMonthIdx < idx ? (
|
795
|
-
<a href="#" key={idx} className='is-disabled' onClick={event => { event.preventDefault() }}>{action.label}</a>
|
796
|
-
) : (
|
797
|
-
<a
|
798
|
-
className={dateMonthlyPickerIsSelected(action.label) ? 'is-selected' : ''}
|
799
|
-
href="#"
|
800
|
-
key={idx}
|
801
|
-
onClick={event => dateMonthlyPickerHandler(event, 'month-selection', action.value)}>{action.label}</a>
|
802
|
-
)
|
803
|
-
)}
|
804
|
-
</div>
|
805
|
-
</div>
|
806
|
-
) : dropdown.type === 'date-picker-cutoff' ? (
|
807
|
-
<div className="popover em-popover-months">
|
808
|
-
<div className="list-years">
|
809
|
-
<button onClick={event => dateMonthlyPickerHandler(event, 'prev')} ><img src="/images/icons/icon-arrowleft-white.svg" alt="" /></button>
|
810
|
-
<div>{calendarYear}</div>
|
811
|
-
<button onClick={event => dateMonthlyPickerHandler(event, 'next')} ><img src="/images/icons/icon-arrowright-white.svg" alt="" /></button>
|
812
|
-
</div>
|
813
|
-
<div className="list-months">
|
814
|
-
{
|
815
|
-
dropdown.cutoffDates !== null && dropdown.cutoffDates.length > 0 ? (
|
816
|
-
dropdown.cutoffDates.map((action: any, idx: number) => {
|
817
|
-
let classSelect;
|
818
|
-
if (JSON.stringify(action.label) === JSON.stringify(dropdown.cutoffValue.label)) {
|
819
|
-
if (dropdown.currentYear === calendarYear) {
|
820
|
-
classSelect = 'is-selected';
|
821
|
-
} else {
|
822
|
-
classSelect = '';
|
823
|
-
}
|
824
|
-
// classSelect = 'is-selected';
|
825
|
-
} else {
|
826
|
-
classSelect = '';
|
827
|
-
}
|
828
|
-
return <a
|
829
|
-
className={classSelect}
|
830
|
-
href="#"
|
831
|
-
key={idx}
|
832
|
-
onClick={event => dateCutoffPickerHandler(event, action.label, action.value)}>{action.label}</a>
|
833
|
-
}
|
834
|
-
)
|
835
|
-
) : null
|
836
|
-
}
|
837
|
-
</div>
|
838
|
-
</div>
|
839
|
-
) : null
|
840
|
-
}
|
841
|
-
</Popover>
|
842
|
-
</div>
|
843
|
-
</Fragment>
|
844
|
-
) : null
|
845
|
-
}
|
846
|
-
{
|
847
|
-
pagination && pagination.show && pagination.show.constructor === Boolean ? (
|
848
|
-
<Fragment>
|
849
|
-
{
|
850
|
-
!pagination.hideSummary || pagination.hideSummary === false ? (
|
851
|
-
<Fragment>
|
852
|
-
<div className="em-dropdown">
|
853
|
-
<a className="pagination-summary" href="#" id="pagination" onClick={event => popoverRequestHandler(event, 'pagination-summary')} data-testid="menubar-pagination">
|
854
|
-
{
|
855
|
-
(pagination.counter > 0 ? (((pagination.page - 1) * pagination.perPage) + 1) : 0)
|
856
|
-
+ ' - ' +
|
857
|
-
(
|
858
|
-
pagination.page * pagination.perPage > pagination.total ?
|
859
|
-
(pagination.total ? pagination.total : pagination.counter) :
|
860
|
-
pagination.page * pagination.perPage
|
861
|
-
)
|
862
|
-
} of {pagination.total ? pagination.total : 0}
|
863
|
-
</a>
|
864
|
-
<Popover
|
865
|
-
id="paginationSummaryPopover"
|
866
|
-
className={Boolean(dropdownPopover) ? 'open-popover' : ''}
|
867
|
-
open={Boolean(paginationSummaryPopover)}
|
868
|
-
onClick={event => popoverRequestHandler(event, 'pagination-summary')}
|
869
|
-
|
870
|
-
>
|
871
|
-
{
|
872
|
-
<div className="popover em-popover-input">
|
873
|
-
<div className={'e-field field field-input' + (paginationSummaryFormError.indexOf('perPageTemporaryValue') >= 0 ? ' is-invalid' : '')}>
|
874
|
-
<label className='e-input-label'>SHOW</label>
|
875
|
-
<Input
|
876
|
-
config={{
|
877
|
-
id: 'paginationPerPage',
|
878
|
-
type: 'select',
|
879
|
-
placeholder: '-',
|
880
|
-
value: perPageTemporaryValue,
|
881
|
-
options: PAGE_OPTION
|
882
|
-
}}
|
883
|
-
onChanged={(event:any) => handleChangeFormValue(event, 'show-per-page')}
|
884
|
-
/>
|
885
|
-
</div>
|
886
|
-
<div className={'e-field field field-input' + (paginationSummaryFormError.indexOf('goToPage') >= 0 ? ' is-invalid' : '')}>
|
887
|
-
<label className='e-input-label'>GO TO PAGE</label>
|
888
|
-
<div className="e-input">
|
889
|
-
<Input
|
890
|
-
config={{
|
891
|
-
id: 'goToPage',
|
892
|
-
type: 'number',
|
893
|
-
value: goToPage,
|
894
|
-
placeholder: '-',
|
895
|
-
maxLength: 5,
|
896
|
-
min: '1',
|
897
|
-
}}
|
898
|
-
onChanged={(event:any) => handleChangeFormValue(event, 'go-to-page')}
|
899
|
-
/>
|
900
|
-
</div>
|
901
|
-
</div>
|
902
|
-
<button className="button-check" onClick={(event) => paginationRequestHandler(event, 'submit')}>
|
903
|
-
{SVG_CHECK}
|
904
|
-
</button>
|
905
|
-
</div>
|
906
|
-
}
|
907
|
-
</Popover>
|
908
|
-
</div>
|
909
|
-
</Fragment>
|
910
|
-
) : null
|
911
|
-
}
|
912
|
-
<a
|
913
|
-
className={(pagination.page * pagination.perPage) > pagination.perPage ? 'belt-prev' : 'belt-prev is-disabled'}
|
914
|
-
href="#"
|
915
|
-
{...(((pagination.page * pagination.perPage) > pagination.perPage) ? { onClick: (event:any) => paginationRequestHandler(event, 'prev') } : { onClick: event => { event.preventDefault() } })}
|
916
|
-
>
|
917
|
-
<div className="belt-icon">{SVG_ARROWLEFT}</div>
|
918
|
-
</a>
|
919
|
-
<a
|
920
|
-
className={pagination.total <= (pagination.page * pagination.perPage) ? 'belt-next is-disabled' : 'belt-next'}
|
921
|
-
href="#"
|
922
|
-
{...((pagination.total <= (pagination.page * pagination.perPage)) ? { onClick: event => { event.preventDefault() } } : { onClick: (event:any) => paginationRequestHandler(event, 'next') })}
|
923
|
-
>
|
924
|
-
<div className="belt-icon">{SVG_ARROWRIGHT}</div>
|
925
|
-
</a>
|
926
|
-
</Fragment>
|
927
|
-
) : null
|
928
|
-
}
|
929
|
-
{
|
930
|
-
// Pivot Configuration
|
931
|
-
pivot && pivot.show ? (
|
932
|
-
<Fragment>
|
933
|
-
<div className="em-dropdown">
|
934
|
-
<a id="months" className="belt-dropdown " href="#" onClick={event => popoverRequestHandler(event, 'pivot')} data-testid="menubar-pivot">
|
935
|
-
<span>
|
936
|
-
{
|
937
|
-
pivot.selected && pivot.actions &&
|
938
|
-
pivot.actions.constructor === Array && pivot.actions.length > 0 ? (
|
939
|
-
pivot.actions.filter((item: any) => (item.value === pivot.selected)).length > 0 ? (
|
940
|
-
pivot.actions.filter((item: any) => (item.value === pivot.selected))[0].label
|
941
|
-
) : 'None'
|
942
|
-
) : 'None'
|
943
|
-
}
|
944
|
-
</span>
|
945
|
-
<div className="icon-arrowdown">{SVG_ARROWDOWN}</div>
|
946
|
-
</a>
|
947
|
-
<Popover
|
948
|
-
id="pivotPopover"
|
949
|
-
className={Boolean(dropdownPopover) ? 'open-popover' : ''}
|
950
|
-
open={Boolean(pivotPopover)}
|
951
|
-
onClick={event => popoverRequestHandler(event, 'pivot')}
|
952
|
-
|
953
|
-
>
|
954
|
-
{
|
955
|
-
pivot.actions && pivot.actions.constructor === Array && pivot.actions.length > 0 ? (
|
956
|
-
<div className="popover em-popover-list">
|
957
|
-
{pivot.actions.map((pvt: any, idx: number) =>
|
958
|
-
<a href="#" key={idx} onClick={event => actionRequestHandler(event, 'pivot', pvt.value)}>{pvt.label}</a>
|
959
|
-
)}
|
960
|
-
</div>
|
961
|
-
) : null
|
962
|
-
}
|
963
|
-
</Popover>
|
964
|
-
</div>
|
965
|
-
</Fragment>
|
966
|
-
) : null
|
967
|
-
}
|
968
|
-
{
|
969
|
-
// Close Icon Configuration
|
970
|
-
config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("close") >= 0) || (config.iconType === 'close')) ? (
|
971
|
-
<a className="modal-close" href="#" onClick={event => actionRequestHandler(event, 'icon', 'close')} date-testid="menubar-close">
|
972
|
-
{SVG_CLOSE_GRAY}
|
973
|
-
</a>
|
974
|
-
) : null
|
975
|
-
}
|
976
|
-
{
|
977
|
-
toggle && toggle.show && toggle.buttons && toggle.buttons.constructor === Array ? (
|
978
|
-
<Fragment>
|
979
|
-
<div className="belt-toggle">
|
980
|
-
{
|
981
|
-
toggle.buttons.map((item: any, idx: number) => (
|
982
|
-
<a className={"belt-icon icon-calendar " + (item.value === toggle.value ? ' is-active' : '')} key={'toggle-' + idx} href="#"
|
983
|
-
onClick={event => toggleSelectionHandler(event, item.value)}>
|
984
|
-
{
|
985
|
-
item.value === toggle.value ? item.selectedIconDisplay : item.icon
|
986
|
-
}
|
987
|
-
</a>
|
988
|
-
))
|
989
|
-
}
|
990
|
-
</div>
|
991
|
-
</Fragment>
|
992
|
-
) : null
|
993
|
-
}
|
994
|
-
</div>
|
995
|
-
</div>
|
996
|
-
{/* Body */}
|
997
|
-
{/* <div> */}
|
998
|
-
{
|
999
|
-
// Search Configuration
|
1000
|
-
search && search.show && search.show.constructor === Boolean ? (
|
1001
|
-
<div className="field em-card-search">
|
1002
|
-
<div className="e-input">
|
1003
|
-
<Input
|
1004
|
-
config={{
|
1005
|
-
id: 'search',
|
1006
|
-
type: 'text',
|
1007
|
-
placeholder: search.placeholder ? search.placeholder : 'Search',
|
1008
|
-
maxLength: 30,
|
1009
|
-
readOnly: false,
|
1010
|
-
disabled: false,
|
1011
|
-
value: searchTemporaryValue ? searchTemporaryValue : ''
|
1012
|
-
}}
|
1013
|
-
onChanged={(event:any) => handleChangeFormValue(event, 'search')}
|
1014
|
-
keyPressed={(event:any) => actionRequestHandler(event, 'search', 'search')}
|
1015
|
-
/>
|
1016
|
-
</div>
|
1017
|
-
</div>
|
1018
|
-
) : null
|
1019
|
-
}
|
1020
|
-
{children}
|
1021
|
-
{/* </div> */}
|
1022
|
-
{/* Footer */}
|
1023
|
-
<div className="em-card-footer">
|
1024
|
-
{
|
1025
|
-
buttonFooter && buttonFooter.show && buttonFooter.actions.length > 0 &&
|
1026
|
-
<div className={buttonFooter.className}>
|
1027
|
-
{
|
1028
|
-
buttonFooter.actions.map((btn: any, idx: number) => (
|
1029
|
-
btn.show &&
|
1030
|
-
<a className={'em-button ' + btn.className}
|
1031
|
-
href="#" key={idx}
|
1032
|
-
{...(btn.disabled === true ? { onClick: event => { event.preventDefault() } } : { onClick: event => actionRequestHandler(event, 'button', btn.action) })}
|
1033
|
-
data-testid={btn.id && btn.id.constructor === String ? btn.id : 'default-button-footer'}
|
1034
|
-
>
|
1035
|
-
<div className="icon">{btn.icon ? btn.icon : ''}</div>
|
1036
|
-
<span data-testid={'button-action-' + btn.action}>{btn.label ? btn.label : ''}</span>
|
1037
|
-
</a>
|
1038
|
-
))
|
1039
|
-
}
|
1040
|
-
</div>
|
1041
|
-
|
1042
|
-
}
|
1043
|
-
{
|
1044
|
-
|
1045
|
-
|
1046
|
-
// UndoButton Actions Configuration
|
1047
|
-
undoButton && undoButton.show && undoButton.isFooter &&
|
1048
|
-
undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (
|
1049
|
-
undoButton.actions.map((btn: any, idx: number) => {
|
1050
|
-
return seconds > 0 || (btn.timer !== undefined) ? (
|
1051
|
-
|
1052
|
-
<a
|
1053
|
-
className={btn.class ? btn.class : 'em-button ' + ' ' + (idx === 0 ? 'disabled' : 'outline button-undo') + (btn.disabled === true ? ' is-disabled button-undo' : '')}
|
1054
|
-
href="#"
|
1055
|
-
data-testid={`undo-button-${btn.action}`}
|
1056
|
-
key={idx}
|
1057
|
-
{...(btn.disabled === true ? { onClick: event => { event.preventDefault() } } : { onClick: event => actionRequestHandler(event, 'undo-button', btn.action) })}>
|
1058
|
-
<div className="belt-icon">{btn.icon ? btn.icon : ''}</div>
|
1059
|
-
<span data-testid="undo-button-text">{btn.label ? (
|
1060
|
-
`${btn.label} ${btn.timer !== undefined && btn.timer.constructor === Number && seconds > 0 ? (
|
1061
|
-
`in ${seconds}s`
|
1062
|
-
) : ''}`
|
1063
|
-
) : ''}</span>
|
1064
|
-
</a>
|
1065
|
-
) : null
|
1066
|
-
})
|
1067
|
-
) : null
|
1068
|
-
}
|
1069
|
-
</div>
|
1070
|
-
</div>
|
1071
|
-
)
|
1072
|
-
}
|
1073
|
-
|
1074
|
-
export default MenuBar;
|