empower-container 0.1.21 → 0.1.24

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.
Files changed (57) hide show
  1. package/README.md +378 -376
  2. package/dist/cjs/DatetimeFormatter.d.ts +3 -3
  3. package/dist/cjs/DatetimeFormatter.js +389 -389
  4. package/dist/cjs/Information.d.ts +10 -10
  5. package/dist/cjs/Information.js +63 -63
  6. package/dist/cjs/MenuBar.d.ts +24 -24
  7. package/dist/cjs/MenuBar.js +539 -539
  8. package/dist/cjs/Modal.d.ts +33 -33
  9. package/dist/cjs/Modal.js +44 -44
  10. package/dist/cjs/assets/Asset.d.ts +17 -16
  11. package/dist/cjs/assets/Asset.js +31 -30
  12. package/dist/cjs/constants/Constant.d.ts +15 -15
  13. package/dist/cjs/constants/Constant.js +35 -35
  14. package/dist/cjs/index.d.ts +3 -3
  15. package/dist/cjs/index.js +10 -10
  16. package/dist/cjs/inputs/Input.d.ts +25 -25
  17. package/dist/cjs/inputs/Input.js +106 -106
  18. package/dist/cjs/inputs/InputSelectionHandler.d.ts +3 -3
  19. package/dist/cjs/inputs/InputSelectionHandler.js +36 -36
  20. package/dist/cjs/inputs/Select.d.ts +28 -28
  21. package/dist/cjs/inputs/Select.js +403 -403
  22. package/dist/esm/DatetimeFormatter.d.ts +3 -3
  23. package/dist/esm/DatetimeFormatter.js +385 -385
  24. package/dist/esm/Information.d.ts +10 -10
  25. package/dist/esm/Information.js +38 -38
  26. package/dist/esm/MenuBar.d.ts +24 -24
  27. package/dist/esm/MenuBar.js +534 -534
  28. package/dist/esm/Modal.d.ts +33 -33
  29. package/dist/esm/Modal.js +39 -39
  30. package/dist/esm/assets/Asset.d.ts +17 -16
  31. package/dist/esm/assets/Asset.js +28 -27
  32. package/dist/esm/constants/Constant.d.ts +15 -15
  33. package/dist/esm/constants/Constant.js +32 -32
  34. package/dist/esm/index.d.ts +3 -3
  35. package/dist/esm/index.js +3 -3
  36. package/dist/esm/inputs/Input.d.ts +25 -25
  37. package/dist/esm/inputs/Input.js +104 -104
  38. package/dist/esm/inputs/InputSelectionHandler.d.ts +3 -3
  39. package/dist/esm/inputs/InputSelectionHandler.js +31 -31
  40. package/dist/esm/inputs/Select.d.ts +28 -28
  41. package/dist/esm/inputs/Select.js +399 -399
  42. package/dist/scss/components/_modal.scss +66 -66
  43. package/dist/scss/elements/_button.scss +133 -107
  44. package/dist/scss/elements/_index.scss +1 -1
  45. package/dist/scss/elements/_popover.scss +7 -7
  46. package/dist/scss/foundation/_colors.scss +59 -59
  47. package/dist/scss/foundation/_mixins.scss +40 -40
  48. package/dist/scss/foundation/_normalize.scss +203 -203
  49. package/dist/scss/foundation/_settings.scss +36 -36
  50. package/dist/scss/foundation/_typography.scss +94 -94
  51. package/dist/scss/library/_information.scss +63 -67
  52. package/dist/scss/library/_input.scss +37 -37
  53. package/dist/scss/library/_menubar.scss +240 -255
  54. package/dist/scss/library/_select.scss +258 -258
  55. package/dist/scss/style.scss +38 -23
  56. package/package.json +62 -62
  57. package/tscnofig.old +26 -26
@@ -1,534 +1,534 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
- if (ar || !(i in from)) {
15
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
- ar[i] = from[i];
17
- }
18
- }
19
- return to.concat(ar || Array.prototype.slice.call(from));
20
- };
21
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
- /* eslint-disable no-useless-concat */
23
- /* eslint-disable jsx-a11y/anchor-is-valid */
24
- import { useState, Fragment, useEffect } from "react";
25
- import '../scss/style.scss';
26
- // Imports
27
- import { SVG_BACK, SVG_CLOSE_GRAY, SVG_ARROWLEFT, SVG_ARROWRIGHT, SVG_CHECK, SVG_ARROWDOWN, SVG_INFORMATION } from './assets/Asset';
28
- import { CHECKBOX, MONTH_LIST, INFO_LOADER, PAGE_OPTION } from "./constants/Constant";
29
- import Information from './Information';
30
- import Input from './inputs/InputSelectionHandler';
31
- import datetimeFormatter from './DatetimeFormatter';
32
- import { Popover } from './inputs/Select';
33
- // Package
34
- import { Calendar } from 'react-date-range';
35
- var MenuBar = function (_a) {
36
- var config = _a.config, info = _a.info, button = _a.button, getActions = _a.getActions, dropdown = _a.dropdown, search = _a.search, pagination = _a.pagination, pivot = _a.pivot, check = _a.check, toggle = _a.toggle, mainButton = _a.mainButton, buttonFooter = _a.buttonFooter, undoButton = _a.undoButton, customClass = _a.customClass, children = _a.children;
37
- // React Hooks Popover
38
- var _b = useState(null), infoPopover = _b[0], setInfoPopover = _b[1];
39
- var _c = useState(null), mainButtonPopover = _c[0], setMainButtonPopover = _c[1];
40
- var _d = useState(null), dropdownPopover = _d[0], setDropdownPopover = _d[1];
41
- var _e = useState(null), paginationSummaryPopover = _e[0], setPaginationSummaryPopover = _e[1];
42
- var _f = useState(null), pivotPopover = _f[0], setPivotPopover = _f[1];
43
- var _g = useState(null), filterPopover = _g[0], setFilterPopover = _g[1];
44
- var _h = useState(""), calendarYear = _h[0], setCalendarYear = _h[1];
45
- var _j = useState(null), minMonthIdx = _j[0], setMinMonthIdx = _j[1];
46
- var _k = useState(null), maxMonthIdx = _k[0], setMaxMonthIdx = _k[1];
47
- // React Hooks Variables
48
- var _l = useState(''), searchTemporaryValue = _l[0], setSearchTemporaryValue = _l[1];
49
- var _m = useState(1), goToPage = _m[0], setGoToPage = _m[1];
50
- var _o = useState(""), perPageTemporaryValue = _o[0], setPerPageTemporaryValue = _o[1];
51
- var _p = useState([]), paginationSummaryFormError = _p[0], setPaginationSummaryFormError = _p[1];
52
- var _q = useState(false), loaded = _q[0], setLoaded = _q[1];
53
- var _r = useState(0), seconds = _r[0], setSeconds = _r[1];
54
- var _s = useState(undoButton && undoButton.show ? true : false), undoShow = _s[0], setUndoShow = _s[1];
55
- var _t = useState(false), doneTimer = _t[0], setDoneTimer = _t[1];
56
- useEffect(function () {
57
- var filteredMonthList = [];
58
- if (dropdown && dropdown.minMonth) {
59
- filteredMonthList = __spreadArray([], MONTH_LIST, true).filter(function (item) { return (item.value.toLowerCase() === dropdown.minMonth.toLowerCase()); });
60
- if (filteredMonthList.length > 0) {
61
- minMonthIdx = MONTH_LIST.indexOf(filteredMonthList[0]);
62
- setMinMonthIdx(minMonthIdx);
63
- }
64
- }
65
- if (dropdown && dropdown.maxMonth) {
66
- filteredMonthList = __spreadArray([], MONTH_LIST, true).filter(function (item) { return (item.value.toLowerCase() === dropdown.maxMonth.toLowerCase()); });
67
- if (filteredMonthList.length > 0) {
68
- maxMonthIdx = MONTH_LIST.indexOf(filteredMonthList[0]);
69
- setMaxMonthIdx(maxMonthIdx);
70
- }
71
- }
72
- if (search && search.value && loaded === false) {
73
- setSearchTemporaryValue(search.value);
74
- setLoaded(true);
75
- }
76
- if (undoButton && undoButton.show) {
77
- var buttonWithTimer_1 = undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (undoButton.actions.filter(function (item) { return (item.hasOwnProperty('timer') && item.timer !== undefined && item.timer.constructor === Number); })) : [];
78
- if (buttonWithTimer_1.length > 0) {
79
- if (undoShow !== undoButton.show) {
80
- if (buttonWithTimer_1[0] && buttonWithTimer_1[0].hasOwnProperty('timer')) {
81
- buttonWithTimer_1[0].timer && setSeconds(buttonWithTimer_1[0].timer);
82
- }
83
- setDoneTimer(false);
84
- setUndoShow(undoButton.show ? true : false);
85
- }
86
- var myInterval_1 = setInterval(function () {
87
- if (seconds > 0) {
88
- setSeconds(seconds - 1);
89
- }
90
- else {
91
- if (!doneTimer) {
92
- clearInterval(myInterval_1);
93
- setDoneTimer(true);
94
- returnValues('button', buttonWithTimer_1[0].action, null);
95
- }
96
- }
97
- }, 1000);
98
- return function () {
99
- clearInterval(myInterval_1);
100
- };
101
- }
102
- }
103
- else {
104
- setUndoShow(false);
105
- }
106
- });
107
- // Belt Configuration Variables
108
- info = info ? (info.constructor === Object && info.infoDetails ? (info) : info.constructor === String ? (info) : INFO_LOADER) : INFO_LOADER;
109
- var dropdownTitle = dropdown && (dropdown.type === 'list' || dropdown.type === 'button') ? (dropdown.title ? dropdown.title : "") : dropdown && dropdown.type === 'date-picker-weekly' ? (dropdown.selection && dropdown.selection.startDate && dropdown.selection.endDate ? (dropdown.selection.startDate + ' to ' + dropdown.selection.endDate) : "") : dropdown && dropdown.type === 'date-picker-monthly' ? dropdown.selection.startDate : "";
110
- /**
111
- * popoverRequestHandler
112
- * hide and show the popover of specific action
113
- * @param {*} e - event of the click item
114
- * @param {*} popover - popover type
115
- */
116
- var popoverRequestHandler = function (e, popover, hide) {
117
- if (hide === void 0) { hide = false; }
118
- switch (popover) {
119
- case 'info':
120
- var currentTarget_1 = e.currentTarget;
121
- if (hide === false && info.constructor === String && info === INFO_LOADER) {
122
- actionRequestHandler(e, 'icon', 'info');
123
- setInfoPopover(e.currentTarget);
124
- setTimeout(function () {
125
- setInfoPopover(null);
126
- setInfoPopover(currentTarget_1);
127
- }, 2000);
128
- }
129
- else {
130
- infoPopover ? setInfoPopover(null) : setInfoPopover(e.currentTarget);
131
- }
132
- break;
133
- case 'dropdown':
134
- if (dropdown.type === 'date-picker-monthly' && !dropdownPopover) {
135
- dropdown.selection && dropdown.selection.startDate ? setCalendarYear(datetimeFormatter(dropdown.selection.startDate, 'full-year')) : setCalendarYear(new Date());
136
- }
137
- else if (dropdown.type === 'date-picker-cutoff' && !dropdownPopover) {
138
- setCalendarYear(dropdown.currentYear); //need to improve on this one
139
- }
140
- dropdownPopover ? setDropdownPopover(null) : setDropdownPopover(e.currentTarget);
141
- break;
142
- case 'pagination-summary':
143
- if (!Boolean(paginationSummaryPopover)) {
144
- pagination && pagination.page ? setGoToPage(pagination.page) : setGoToPage(1);
145
- setPerPageTemporaryValue(pagination.perPage ? pagination.perPage.toString() : '');
146
- }
147
- paginationSummaryPopover ? setPaginationSummaryPopover(null) : setPaginationSummaryPopover(e.currentTarget);
148
- break;
149
- case 'pivot':
150
- pivotPopover ? setPivotPopover(null) : setPivotPopover(e.currentTarget);
151
- break;
152
- case 'filter':
153
- filterPopover ? setFilterPopover(null) : setFilterPopover(e.currentTarget);
154
- break;
155
- case 'main-button':
156
- if (hide) {
157
- setMainButtonPopover(null);
158
- }
159
- else {
160
- mainButtonPopover ? setMainButtonPopover(null) : setMainButtonPopover(e.currentTarget);
161
- }
162
- break;
163
- default:
164
- break;
165
- }
166
- };
167
- /**
168
- * actionRequestHandler
169
- * manipulate the action and data of each action
170
- * @param {*} e - event
171
- * @param {*} type - action type / can be the action itself
172
- * @param {*} action - it can be action type / data depends on the used actions
173
- */
174
- var actionRequestHandler = function (e, type, action, hidePopover) {
175
- if (hidePopover === void 0) { hidePopover = true; }
176
- if (e.preventDefault) {
177
- e.preventDefault();
178
- }
179
- var data = null;
180
- var addedParam = null;
181
- if (type === 'search') {
182
- data = searchTemporaryValue;
183
- }
184
- else if (type === 'pagination' || type === 'pagination-summary') {
185
- data = pagination;
186
- }
187
- else if (type === 'dropdown' || type === 'pivot' || type === 'main-button' || type === 'button' || type === 'icon' || type === 'check' || type === 'tab' || type === 'toggle') {
188
- data = action;
189
- action = type;
190
- if (dropdown && dropdown.type === 'date-picker-cutoff') {
191
- addedParam = calendarYear;
192
- }
193
- }
194
- else if (type === 'undo-button') {
195
- data = action;
196
- action = type;
197
- }
198
- if (hidePopover) {
199
- popoverRequestHandler(e, type, true);
200
- }
201
- setTimeout(function () {
202
- returnValues(action, data, addedParam);
203
- }, 200);
204
- };
205
- /**
206
- * handleChangeFormValue
207
- * manipulate the inputs temporary values
208
- * @param {*} e - event
209
- * @param {*} type - type of the input that has been changed
210
- */
211
- var handleChangeFormValue = function (e, type) {
212
- switch (type) {
213
- case 'search':
214
- e.target.value ? setSearchTemporaryValue(e.target.value) : setSearchTemporaryValue("");
215
- break;
216
- case 'show-per-page':
217
- setPerPageTemporaryValue(e.target.value.toString());
218
- setGoToPage(1);
219
- if (paginationSummaryFormError.indexOf('perPageTemporaryValue') >= 0 && (e !== "")) {
220
- paginationSummaryFormError = paginationSummaryFormError.filter(function (item) { return item !== 'perPageTemporaryValue'; });
221
- setPaginationSummaryFormError(paginationSummaryFormError);
222
- }
223
- break;
224
- case 'go-to-page':
225
- setGoToPage(e.target.value);
226
- if (paginationSummaryFormError.indexOf('goToPage') >= 0 && (e.currentTarget.value !== "" || e.currentTarget.value > 1)) {
227
- paginationSummaryFormError = paginationSummaryFormError.filter(function (item) { return item !== 'goToPage'; });
228
- setPaginationSummaryFormError(paginationSummaryFormError);
229
- }
230
- break;
231
- case 'advanced-filter':
232
- returnValues(type, e);
233
- break;
234
- default:
235
- break;
236
- }
237
- };
238
- /**
239
- * paginationRequestHandler
240
- * manipulate the paginations value depend on the action
241
- * @param {*} e - event
242
- * @param {*} action - action that the user do
243
- */
244
- var paginationRequestHandler = function (e, action) {
245
- e.preventDefault();
246
- var paginationCopy = __assign({}, pagination);
247
- switch (action) {
248
- case 'check-pagination-required':
249
- var formError = [];
250
- if (goToPage === "" || goToPage < 1) {
251
- formError.push('goToPage');
252
- }
253
- if (perPageTemporaryValue === "") {
254
- formError.push('perPageTemporaryValue');
255
- }
256
- return formError;
257
- case 'submit':
258
- var errorFields = paginationRequestHandler(e, 'check-pagination-required');
259
- if (errorFields.length > 0) {
260
- setPaginationSummaryFormError(errorFields);
261
- }
262
- else {
263
- pagination.perPage = perPageTemporaryValue ? parseInt(perPageTemporaryValue) : pagination.perPage;
264
- pagination.page = goToPage ? ((pagination.perPage * goToPage) > pagination.total ? (Math.floor(pagination.total / pagination.perPage) + 1) : parseInt(goToPage)) : 1;
265
- pagination.counter = (pagination.page * pagination.perPage) > pagination.total ? pagination.total : (pagination.page * pagination.perPage);
266
- // if (paginationCopy.perPage !== pagination.perPage || paginationCopy.page !== pagination.page || paginationCopy.counter !== pagination.counter) {
267
- actionRequestHandler(e, 'pagination-summary', 'pagination');
268
- // }
269
- }
270
- break;
271
- case 'next':
272
- pagination.page = ((pagination.page++) * pagination.perPage) > pagination.total ? (Math.floor(pagination.total / pagination.perPage) + 1) : pagination.page++;
273
- pagination.counter = (pagination.page * pagination.perPage) > pagination.total ? pagination.total : (pagination.page * pagination.perPage);
274
- if (paginationCopy.page !== pagination.page || paginationCopy.counter !== pagination.counter) {
275
- actionRequestHandler(e, 'pagination', 'pagination');
276
- }
277
- break;
278
- case 'prev':
279
- pagination.page = pagination.page > 1 ? pagination.page -= 1 : pagination.page;
280
- pagination.counter = pagination.page * pagination.perPage;
281
- if (paginationCopy.page !== pagination.page || paginationCopy.counter !== pagination.counter) {
282
- actionRequestHandler(e, 'pagination', 'pagination');
283
- }
284
- break;
285
- default:
286
- break;
287
- }
288
- };
289
- /**
290
- * checkboxRequestHandler
291
- * select all / unselect all items
292
- * @param {*} e - event
293
- * @param {*} action - action of the checkbox
294
- */
295
- var checkboxRequestHandler = function (e, action) {
296
- // e.preventDefault();
297
- if (check.disabled !== true) {
298
- if (action === 'all') {
299
- actionRequestHandler(e, 'check', 'all');
300
- }
301
- else {
302
- actionRequestHandler(e, 'check', 'none');
303
- }
304
- }
305
- };
306
- /**
307
- * onDatePickerChange
308
- * change the datepicker value
309
- * @param {*} e - event
310
- * @param {*} type - action type
311
- */
312
- var onDatePickerChange = function (e, type) {
313
- if (dropdown.type === 'date-picker-weekly') {
314
- dropdown.selection.startDate = datetimeFormatter(e, 'start-of-Week');
315
- dropdown.selection.endDate = datetimeFormatter(e, 'end-of-Week');
316
- }
317
- actionRequestHandler(e, type, dropdown.selection);
318
- };
319
- /**
320
- * dateMonthlyPickerHandler
321
- * selection of month on a calendar and changing of year
322
- * @param {*} e - event
323
- * @param {*} action - action type
324
- */
325
- var dateMonthlyPickerHandler = function (e, action, data) {
326
- if (data === void 0) { data = ''; }
327
- var _a = __assign({}, dropdown), maxYear = _a.maxYear, minYear = _a.minYear;
328
- var newDateValue = null;
329
- var standardDate = null;
330
- var selectedMonthDate = null;
331
- var monthIdx = null;
332
- var fullYear = null;
333
- if (action === 'next') {
334
- if (!maxYear || (maxYear && parseInt(maxYear) >= calendarYear + 1)) {
335
- calendarYear += 1;
336
- setCalendarYear(calendarYear);
337
- }
338
- }
339
- else if (action === 'prev') {
340
- if (!minYear || (minYear && parseInt(minYear) <= calendarYear - 1)) {
341
- calendarYear -= 1;
342
- setCalendarYear(calendarYear);
343
- }
344
- }
345
- else if (action === 'month-selection') {
346
- newDateValue = datetimeFormatter(data + ' ' + calendarYear, 'month-year');
347
- actionRequestHandler(e, 'dropdown', newDateValue);
348
- }
349
- else if (action === 'next-month') {
350
- standardDate = datetimeFormatter(dropdown.selection.startDate, 'date-standard');
351
- 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;
352
- monthIdx = selectedMonthDate.getMonth();
353
- fullYear = selectedMonthDate.getFullYear();
354
- if (monthIdx + 1 < 12) {
355
- monthIdx = monthIdx + 1;
356
- }
357
- else {
358
- monthIdx = 0;
359
- fullYear = fullYear + 1;
360
- }
361
- if ((!maxYear && !maxMonthIdx) || fullYear < parseInt(maxYear) || (fullYear === parseInt(maxYear) && monthIdx <= parseInt(maxMonthIdx))) {
362
- newDateValue = datetimeFormatter(MONTH_LIST[monthIdx].value + ' ' + fullYear, 'month-year');
363
- actionRequestHandler(e, 'dropdown', newDateValue, false);
364
- }
365
- }
366
- else if (action === 'prev-month') {
367
- standardDate = datetimeFormatter(dropdown.selection.startDate, 'date-standard');
368
- 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;
369
- monthIdx = selectedMonthDate.getMonth();
370
- fullYear = selectedMonthDate.getFullYear();
371
- if (monthIdx - 1 >= 0) {
372
- monthIdx = monthIdx - 1;
373
- }
374
- else {
375
- monthIdx = 11;
376
- fullYear = fullYear - 1;
377
- }
378
- if ((!minYear && !minMonthIdx) || fullYear > parseInt(minYear) || (fullYear === parseInt(minYear) && monthIdx >= parseInt(minMonthIdx))) {
379
- var newDateValue_1 = datetimeFormatter(MONTH_LIST[monthIdx].value + ' ' + fullYear, 'month-year');
380
- actionRequestHandler(e, 'dropdown', newDateValue_1, false);
381
- }
382
- }
383
- };
384
- var dateCutoffPickerHandler = function (e, label, value) {
385
- var cutOffVal = {
386
- "label": label,
387
- "value": value,
388
- };
389
- actionRequestHandler(e, 'dropdown', cutOffVal);
390
- };
391
- /**
392
- * returnValues
393
- * return manipulated value from beltConfig to the parent component
394
- * @param {*} action - done action on beltConfig
395
- * @param {*} data - manipulated data from the action
396
- */
397
- var returnValues = function (action, data, addedParam) {
398
- if (addedParam === void 0) { addedParam = null; }
399
- return getActions ? getActions(action, data, addedParam) : false;
400
- };
401
- /**
402
- * dateMonthlyPickerIsSelected
403
- * determine if month is selected
404
- * @param {*} month - month value
405
- */
406
- var dateMonthlyPickerIsSelected = function (month) {
407
- var isSelected = false;
408
- if (dropdown && dropdown.selection && dropdown.selection.startDate && calendarYear) {
409
- var monthYear = month + ' ' + calendarYear;
410
- isSelected = datetimeFormatter(dropdown.selection.startDate.toString(), 'month-year') === datetimeFormatter(monthYear, 'month-year') ? true : false;
411
- }
412
- return isSelected;
413
- };
414
- var isDisabledDropdownPagination = function (action) {
415
- var _a = __assign({}, dropdown), maxYear = _a.maxYear, minYear = _a.minYear, selection = _a.selection;
416
- var selectedMonthDate = new Date(selection.startDate);
417
- var monthIdx = selectedMonthDate.getMonth();
418
- var fullYear = selectedMonthDate.getFullYear();
419
- if (action === 'prev') {
420
- if (minYear && minMonthIdx && fullYear === parseInt(minYear) && monthIdx === parseInt(minMonthIdx)) {
421
- return ' is-disabled';
422
- }
423
- else {
424
- return '';
425
- }
426
- }
427
- else if (action === 'next') {
428
- if (maxYear && maxMonthIdx && fullYear === parseInt(maxYear) && monthIdx === parseInt(maxMonthIdx)) {
429
- return ' is-disabled';
430
- }
431
- else {
432
- return '';
433
- }
434
- }
435
- };
436
- var toggleSelectionHandler = function (event, value) {
437
- event.preventDefault();
438
- actionRequestHandler(event, 'toggle', value, false);
439
- };
440
- return (_jsxs("div", __assign({ className: customClass && customClass.constructor === String ? customClass : 'custom-card' }, { children: [_jsxs("div", __assign({ className: "em-card-belt" }, { children: [_jsxs("div", __assign({ className: "em-belt-left" }, { children: [_jsxs("div", __assign({ className: "em-beltleft-container" }, { children: [
441
- // Back Icon Configuration
442
- config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("back") >= 0) || (config.iconType === 'back')) ? (_jsx("a", __assign({ className: "belt-icon icon-back", href: "#", onClick: function (event) { return actionRequestHandler(event, 'icon', 'back'); }, "data-testid": "menubar-back" }, { children: SVG_BACK }))) : null,
443
- // Check Icon Configuration
444
- config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("check") >= 0) || (config.iconType === 'check')) ? (_jsx("div", __assign({ className: "belt-icon-check", "data-testid": "menubar-checkbox" }, { children: check ? (check.selected === 0 ? (_jsx("div", __assign({ onClick: function (event) { return checkboxRequestHandler(event, 'all'); } }, { children: CHECKBOX.NONE }))) : check.selected > 0 && check.selected < check.total ? (_jsx("div", __assign({ onClick: function (event) { return checkboxRequestHandler(event, 'all'); } }, { children: CHECKBOX.FEW }))) : check.selected === check.total ? (_jsx("div", __assign({ onClick: function (event) { return checkboxRequestHandler(event, 'none'); } }, { children: CHECKBOX.ALL }))) : _jsx("div", { children: CHECKBOX.NONE })) : _jsx("div", { children: CHECKBOX.NONE }) }))) : null,
445
- // Standard Icon Configuration
446
- config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("standard") >= 0) || (config.iconType === 'standard')) ? (_jsx("div", __assign({ className: "belt-icon", "data-testid": "menubar-standard-icon" }, { children: config.icon }))) : null, _jsxs("div", __assign({ className: "belt-title" }, { children: [
447
- // Title Configuration
448
- check && check.selected && check.selected > 0 && check.selected < check.total ? (_jsx("h6", { children: "".concat(check.selected, " ").concat(check.selected === 1 ? 'item selected' : 'items selected') })) : check && check.selected && check.selected === check.total ? (_jsx("h6", { children: "All item(s) selected" })) : config && config.title && (config.title.constructor === String || config.title.constructor === Object) ? (_jsx("h6", __assign({ className: "config-title", "data-testid": "menubar-title" }, { children: config.title }))) : null,
449
- // Title Information Configuration
450
- config && config.titleDescription ? (_jsx("p", { children: config.titleDescription })) : null] })),
451
- // Information Configuration
452
- config && config.showInfo.constructor === Boolean && config.showInfo === true ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-belt-info" }, { children: [_jsx("a", __assign({ href: "#", onClick: function (event) { return popoverRequestHandler(event, 'info'); }, "data-testid": "menubar-information" }, { children: _jsx("div", __assign({ className: "em-info-icon" }, { children: SVG_INFORMATION })) })), _jsx(Popover, __assign({ id: "InfoPopOver", open: Boolean(infoPopover), className: Boolean(dropdownPopover) ? 'open-popover' : '', onClick: function (event) { return popoverRequestHandler(event, 'info'); } }, { children: _jsx(Information, { items: info && info.infoDetails ? info.infoDetails : info, listRow: info && info.listRow ? info.listRow : [], desc: info && info.listRow && info.listRow.length > 0 ? false : true, title: config && config.title ? config.title : null, hide: function (event) { return popoverRequestHandler(event, 'info', true); } }) }))] })) })) : null,
453
- // Additional title on the modal
454
- config && config.addedTitle ? (_jsx("p", { children: config.addedTitle })) : null] })), _jsxs("div", __assign({ className: "em-beltleft-cta" }, { children: [
455
- // Main Button
456
- mainButton && mainButton.show ? (mainButton.actions && mainButton.actions.constructor === Array && mainButton.actions.length > 0 ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-dropdown" }, { children: [_jsxs("a", __assign({ className: "em-button belt-action-main", id: "main-button", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'main-button'); } }, { children: [_jsx("div", __assign({ className: "belt-icon" }, { children: mainButton.icon ? mainButton.icon : '' })), _jsx("span", { children: mainButton.label ? mainButton.label : 'File a Request' })] })), _jsx(Popover, __assign({ id: "mainButtonPopover", open: Boolean(mainButtonPopover), onClick: function (event) { return popoverRequestHandler(event, 'main-button'); }, className: Boolean(dropdownPopover) ? 'open-popover' : '' }, { children: _jsx("div", __assign({ className: "popover em-popover-list" }, { children: mainButton.actions.map(function (btn, idx) {
457
- return _jsx("a", __assign({ href: "#", onClick: function (event) { return actionRequestHandler(event, 'main-button', btn.action); } }, { children: btn.label }), idx);
458
- }) })) }))] })) })) : mainButton.actions && mainButton.actions.constructor === Array && mainButton.actions.length === 1 ? (mainButton.actions.map(function (btn, idx) {
459
- return (_jsxs("a", __assign({ className: btn.class ? 'belt-action ' + btn.class : 'belt-action', href: "#", onClick: function (event) { return actionRequestHandler(event, 'main-button', btn.action); } }, { children: [_jsx("div", __assign({ className: "belt-icon " }, { children: btn.icon ? btn.icon : '' })), _jsx("span", { children: btn.label ? btn.label : '' })] }), idx));
460
- })) : null) : null,
461
- // Button Actions Configuration
462
- button && button.show && button.show.constructor === Boolean &&
463
- button.actions && button.actions.constructor === Array && button.actions.length > 0 ? (button.actions.map(function (btn, idx) {
464
- return (_jsxs("a", __assign({ className: btn.class ? btn.class : ' belt-action' + ' ' + (idx === 0 ? 'is-primary' : ''), href: "#", onClick: function (event) { return actionRequestHandler(event, 'button', btn.action); }, "data-testid": "menubar-button" }, { children: [_jsx("div", __assign({ className: "belt-icon belt-buttons" }, { children: btn.icon ? btn.icon : '' })), _jsx("span", __assign({ "data-testid": 'button-action-' + btn.action }, { children: btn.label ? btn.label : '' }))] }), idx));
465
- })) : null,
466
- // UndoButton Actions Configuration
467
- undoButton && undoButton.show && !undoButton.isFooter &&
468
- undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (undoButton.actions.map(function (btn, idx) {
469
- return seconds > 0 || (btn.timer !== undefined) ? (_jsxs("a", __assign({ className: btn.class ? btn.class : 'belt-action' + ' ' + (idx === 0 ? 'is-primary' : '') + (btn.disabled === true ? ' is-disabled' : ' em-button outline button-undo'), href: "#", "data-testid": "undo-button-".concat(btn.action) }, (btn.disabled === true ? { onClick: function (event) { event.preventDefault(); } } : { onClick: function (event) { return actionRequestHandler(event, 'undo-button', btn.action); } }), { children: [_jsx("div", __assign({ className: "belt-icon" }, { children: btn.icon ? btn.icon : '' })), _jsx("span", __assign({ "data-testid": "undo-button-text" }, { children: btn.label ? ("".concat(btn.label, " ").concat(btn.timer !== undefined && btn.timer.constructor === Number && seconds > 0 ? ("in ".concat(seconds, "s")) : '')) : '' }))] }), idx)) : null;
470
- })) : null] }))] })), _jsxs("div", __assign({ className: "em-belt-right" }, { children: [
471
- // Dropdown Actions Configuration
472
- dropdown && dropdown.show && dropdown.show.constructor === Boolean ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-dropdown" }, { children: [dropdown.type === 'list' ? (_jsxs("a", __assign({ className: "belt-dropdown", id: "add", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: [_jsx("div", __assign({ className: "icon-add" }, { children: dropdown.icon ? dropdown.icon : '' })), _jsx("span", { children: dropdownTitle })] }))) : dropdown.type === 'date-picker-weekly' ? (_jsxs("a", __assign({ id: "months", className: "belt-dropdown ".concat(Boolean(dropdownPopover) ? 'is-active' : ''), href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: [_jsx("span", { children: dropdownTitle }), _jsx("div", __assign({ className: "icon-arrowdown" }, { children: SVG_ARROWDOWN }))] }))) : dropdown.type === 'date-picker-monthly' ? (_jsxs(Fragment, { children: [_jsxs("a", __assign({ id: "months", className: "belt-dropdown ".concat(Boolean(dropdownPopover) ? 'is-active' : ''), href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: [_jsx("span", { children: dropdownTitle }), _jsx("div", __assign({ className: "icon-arrowdown" }, { children: SVG_ARROWDOWN }))] })), dropdown.showPagination ? (_jsxs(Fragment, { children: [_jsx("a", __assign({ className: 'belt-prev' + isDisabledDropdownPagination('prev'), href: "#", onClick: function (event) { return dateMonthlyPickerHandler(event, 'prev-month'); } }, { children: _jsx("div", __assign({ className: "belt-icon" }, { children: SVG_ARROWLEFT })) })), _jsx("a", __assign({ className: 'belt-next' + isDisabledDropdownPagination('next'), href: "#", onClick: function (event) { return dateMonthlyPickerHandler(event, 'next-month'); } }, { children: _jsx("div", __assign({ className: "belt-icon" }, { children: SVG_ARROWRIGHT })) }))] })) : null] })) : dropdown.type === 'date-picker-cutoff' ? ((_jsx("a", __assign({ className: "belt-dropdown", id: "add", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: _jsx("span", { children: dropdown.cutoffValue && dropdown.cutoffValue.label ? dropdown.cutoffValue.label : '' }) })))) : dropdown.type === 'button' ? (_jsxs("a", __assign({ className: "belt-dropdown", id: "add", href: "#", onClick: function (event) { return actionRequestHandler(event, 'button', dropdown.action); } }, { children: [_jsx("div", __assign({ className: "belt-icon" }, { children: dropdown.icon ? dropdown.icon : '' })), _jsx("span", { children: dropdownTitle })] }))) : (_jsx("a", __assign({ className: "belt-dropdown", id: "add", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: _jsx("span", { children: dropdownTitle }) }))), _jsx(Popover, __assign({ id: "dropdownPopover", className: Boolean(dropdownPopover) ? 'open-popover' : '', open: Boolean(dropdownPopover), onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: dropdown.type === 'list' ? (dropdown.actions && dropdown.actions.constructor === Array && dropdown.actions.length > 0 ? (_jsx("div", __assign({ className: "popover em-popover-list" }, { children: dropdown.actions.map(function (drpdwn, idx) {
473
- return _jsx("a", __assign({ href: "#", onClick: function (event) { return actionRequestHandler(event, 'dropdown', drpdwn.value); } }, { children: drpdwn.label }), idx);
474
- }) }))) : null) : dropdown.type === 'date-picker-weekly' ? (_jsx("div", __assign({ className: "popover" }, { children: _jsx(Calendar, { className: "dateRangePickerInput", onChange: function (event) { return onDatePickerChange(event, 'dropdown'); } }) }))) : dropdown.type === 'date-picker-monthly' ? (_jsxs("div", __assign({ className: "popover em-popover-months" }, { children: [_jsxs("div", __assign({ className: "list-years" }, { children: [_jsx("button", __assign({ onClick: function (event) { return dateMonthlyPickerHandler(event, 'prev'); } }, { children: SVG_ARROWLEFT })), _jsx("div", { children: calendarYear }), _jsx("button", __assign({ onClick: function (event) { return dateMonthlyPickerHandler(event, 'next'); } }, { children: SVG_ARROWRIGHT }))] })), _jsx("div", __assign({ className: "list-months" }, { children: MONTH_LIST.map(function (action, idx) {
475
- return dropdown.minYear && dropdown.minYear.toString() === calendarYear.toString() && minMonthIdx && minMonthIdx > idx ? (_jsx("a", __assign({ href: "#", className: 'is-disabled', onClick: function (event) { event.preventDefault(); } }, { children: action.label }), idx)) : dropdown.maxYear && dropdown.maxYear.toString() === calendarYear.toString() && maxMonthIdx && maxMonthIdx < idx ? (_jsx("a", __assign({ href: "#", className: 'is-disabled', onClick: function (event) { event.preventDefault(); } }, { children: action.label }), idx)) : (_jsx("a", __assign({ className: dateMonthlyPickerIsSelected(action.label) ? 'is-selected' : '', href: "#", onClick: function (event) { return dateMonthlyPickerHandler(event, 'month-selection', action.value); } }, { children: action.label }), idx));
476
- }) }))] }))) : dropdown.type === 'date-picker-cutoff' ? (_jsxs("div", __assign({ className: "popover em-popover-months" }, { children: [_jsxs("div", __assign({ className: "list-years" }, { children: [_jsx("button", __assign({ onClick: function (event) { return dateMonthlyPickerHandler(event, 'prev'); } }, { children: _jsx("img", { src: "/images/icons/icon-arrowleft-white.svg", alt: "" }) })), _jsx("div", { children: calendarYear }), _jsx("button", __assign({ onClick: function (event) { return dateMonthlyPickerHandler(event, 'next'); } }, { children: _jsx("img", { src: "/images/icons/icon-arrowright-white.svg", alt: "" }) }))] })), _jsx("div", __assign({ className: "list-months" }, { children: dropdown.cutoffDates !== null && dropdown.cutoffDates.length > 0 ? (dropdown.cutoffDates.map(function (action, idx) {
477
- var classSelect;
478
- if (JSON.stringify(action.label) === JSON.stringify(dropdown.cutoffValue.label)) {
479
- if (dropdown.currentYear === calendarYear) {
480
- classSelect = 'is-selected';
481
- }
482
- else {
483
- classSelect = '';
484
- }
485
- // classSelect = 'is-selected';
486
- }
487
- else {
488
- classSelect = '';
489
- }
490
- return _jsx("a", __assign({ className: classSelect, href: "#", onClick: function (event) { return dateCutoffPickerHandler(event, action.label, action.value); } }, { children: action.label }), idx);
491
- })) : null }))] }))) : null }))] })) })) : null, pagination && pagination.show && pagination.show.constructor === Boolean ? (_jsxs(Fragment, { children: [!pagination.hideSummary || pagination.hideSummary === false ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-dropdown" }, { children: [_jsxs("a", __assign({ className: "pagination-summary", href: "#", id: "pagination", onClick: function (event) { return popoverRequestHandler(event, 'pagination-summary'); }, "data-testid": "menubar-pagination" }, { children: [(pagination.counter > 0 ? (((pagination.page - 1) * pagination.perPage) + 1) : 0)
492
- + ' - ' +
493
- (pagination.page * pagination.perPage > pagination.total ?
494
- (pagination.total ? pagination.total : pagination.counter) :
495
- pagination.page * pagination.perPage), " of ", pagination.total ? pagination.total : 0] })), _jsx(Popover, __assign({ id: "paginationSummaryPopover", className: Boolean(dropdownPopover) ? 'open-popover' : '', open: Boolean(paginationSummaryPopover), onClick: function (event) { return popoverRequestHandler(event, 'pagination-summary'); } }, { children: _jsxs("div", __assign({ className: "popover em-popover-input" }, { children: [_jsxs("div", __assign({ className: 'e-field field field-input' + (paginationSummaryFormError.indexOf('perPageTemporaryValue') >= 0 ? ' is-invalid' : '') }, { children: [_jsx("label", __assign({ className: 'e-input-label' }, { children: "SHOW" })), _jsx(Input, { config: {
496
- id: 'paginationPerPage',
497
- type: 'select',
498
- placeholder: '-',
499
- value: perPageTemporaryValue,
500
- options: PAGE_OPTION
501
- }, onChanged: function (event) { return handleChangeFormValue(event, 'show-per-page'); } })] })), _jsxs("div", __assign({ className: 'e-field field field-input' + (paginationSummaryFormError.indexOf('goToPage') >= 0 ? ' is-invalid' : '') }, { children: [_jsx("label", __assign({ className: 'e-input-label' }, { children: "GO TO PAGE" })), _jsx("div", __assign({ className: "e-input" }, { children: _jsx(Input, { config: {
502
- id: 'goToPage',
503
- type: 'number',
504
- value: goToPage,
505
- placeholder: '-',
506
- maxLength: 5,
507
- min: '1',
508
- }, onChanged: function (event) { return handleChangeFormValue(event, 'go-to-page'); } }) }))] })), _jsx("button", __assign({ className: "button-check", onClick: function (event) { return paginationRequestHandler(event, 'submit'); } }, { children: SVG_CHECK }))] })) }))] })) })) : null, _jsx("a", __assign({ className: (pagination.page * pagination.perPage) > pagination.perPage ? 'belt-prev' : 'belt-prev is-disabled', href: "#" }, (((pagination.page * pagination.perPage) > pagination.perPage) ? { onClick: function (event) { return paginationRequestHandler(event, 'prev'); } } : { onClick: function (event) { event.preventDefault(); } }), { children: _jsx("div", __assign({ className: "belt-icon" }, { children: SVG_ARROWLEFT })) })), _jsx("a", __assign({ className: pagination.total <= (pagination.page * pagination.perPage) ? 'belt-next is-disabled' : 'belt-next', href: "#" }, ((pagination.total <= (pagination.page * pagination.perPage)) ? { onClick: function (event) { event.preventDefault(); } } : { onClick: function (event) { return paginationRequestHandler(event, 'next'); } }), { children: _jsx("div", __assign({ className: "belt-icon" }, { children: SVG_ARROWRIGHT })) }))] })) : null,
509
- // Pivot Configuration
510
- pivot && pivot.show ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-dropdown" }, { children: [_jsxs("a", __assign({ id: "months", className: "belt-dropdown ", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'pivot'); }, "data-testid": "menubar-pivot" }, { children: [_jsx("span", { children: pivot.selected && pivot.actions &&
511
- pivot.actions.constructor === Array && pivot.actions.length > 0 ? (pivot.actions.filter(function (item) { return (item.value === pivot.selected); }).length > 0 ? (pivot.actions.filter(function (item) { return (item.value === pivot.selected); })[0].label) : 'None') : 'None' }), _jsx("div", __assign({ className: "icon-arrowdown" }, { children: SVG_ARROWDOWN }))] })), _jsx(Popover, __assign({ id: "pivotPopover", className: Boolean(dropdownPopover) ? 'open-popover' : '', open: Boolean(pivotPopover), onClick: function (event) { return popoverRequestHandler(event, 'pivot'); } }, { children: pivot.actions && pivot.actions.constructor === Array && pivot.actions.length > 0 ? (_jsx("div", __assign({ className: "popover em-popover-list" }, { children: pivot.actions.map(function (pvt, idx) {
512
- return _jsx("a", __assign({ href: "#", onClick: function (event) { return actionRequestHandler(event, 'pivot', pvt.value); } }, { children: pvt.label }), idx);
513
- }) }))) : null }))] })) })) : null,
514
- // Close Icon Configuration
515
- config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("close") >= 0) || (config.iconType === 'close')) ? (_jsx("a", __assign({ className: "modal-close", href: "#", onClick: function (event) { return actionRequestHandler(event, 'icon', 'close'); }, "date-testid": "menubar-close" }, { children: SVG_CLOSE_GRAY }))) : null, toggle && toggle.show && toggle.buttons && toggle.buttons.constructor === Array ? (_jsx(Fragment, { children: _jsx("div", __assign({ className: "belt-toggle" }, { children: toggle.buttons.map(function (item, idx) { return (_jsx("a", __assign({ className: "belt-icon icon-calendar " + (item.value === toggle.value ? ' is-active' : ''), href: "#", onClick: function (event) { return toggleSelectionHandler(event, item.value); } }, { children: item.value === toggle.value ? item.selectedIconDisplay : item.icon }), 'toggle-' + idx)); }) })) })) : null] }))] })),
516
- // Search Configuration
517
- search && search.show && search.show.constructor === Boolean ? (_jsx("div", __assign({ className: "field em-card-search" }, { children: _jsx("div", __assign({ className: "e-input" }, { children: _jsx(Input, { config: {
518
- id: 'search',
519
- type: 'text',
520
- placeholder: search.placeholder ? search.placeholder : 'Search',
521
- maxLength: 30,
522
- readOnly: false,
523
- disabled: false,
524
- value: searchTemporaryValue ? searchTemporaryValue : ''
525
- }, onChanged: function (event) { return handleChangeFormValue(event, 'search'); }, keyPressed: function (event) { return actionRequestHandler(event, 'search', 'search'); } }) })) }))) : null, children, _jsxs("div", __assign({ className: "em-card-footer" }, { children: [buttonFooter && buttonFooter.show && buttonFooter.actions.length > 0 &&
526
- _jsx("div", __assign({ className: buttonFooter.className }, { children: buttonFooter.actions.map(function (btn, idx) { return (btn.show &&
527
- _jsxs("a", __assign({ className: 'em-button ' + btn.className, href: "#" }, (btn.disabled === true ? { onClick: function (event) { event.preventDefault(); } } : { onClick: function (event) { return actionRequestHandler(event, 'button', btn.action); } }), { "data-testid": btn.id && btn.id.constructor === String ? btn.id : 'default-button-footer' }, { children: [_jsx("div", __assign({ className: "icon" }, { children: btn.icon ? btn.icon : '' })), _jsx("span", __assign({ "data-testid": 'button-action-' + btn.action }, { children: btn.label ? btn.label : '' }))] }), idx)); }) })),
528
- // UndoButton Actions Configuration
529
- undoButton && undoButton.show && undoButton.isFooter &&
530
- undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (undoButton.actions.map(function (btn, idx) {
531
- return seconds > 0 || (btn.timer !== undefined) ? (_jsxs("a", __assign({ className: btn.class ? btn.class : 'em-button ' + ' ' + (idx === 0 ? 'disabled' : 'outline button-undo') + (btn.disabled === true ? ' is-disabled button-undo' : ''), href: "#", "data-testid": "undo-button-".concat(btn.action) }, (btn.disabled === true ? { onClick: function (event) { event.preventDefault(); } } : { onClick: function (event) { return actionRequestHandler(event, 'undo-button', btn.action); } }), { children: [_jsx("div", __assign({ className: "belt-icon" }, { children: btn.icon ? btn.icon : '' })), _jsx("span", __assign({ "data-testid": "undo-button-text" }, { children: btn.label ? ("".concat(btn.label, " ").concat(btn.timer !== undefined && btn.timer.constructor === Number && seconds > 0 ? ("in ".concat(seconds, "s")) : '')) : '' }))] }), idx)) : null;
532
- })) : null] }))] })));
533
- };
534
- export default MenuBar;
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ /* eslint-disable no-useless-concat */
23
+ /* eslint-disable jsx-a11y/anchor-is-valid */
24
+ import { useState, Fragment, useEffect } from "react";
25
+ import '../scss/style.scss';
26
+ // Imports
27
+ import { SVG_BACK, SVG_CLOSE_GRAY, SVG_ARROWLEFT, SVG_ARROWRIGHT, SVG_CHECK, SVG_ARROWDOWN, SVG_INFORMATION } from './assets/Asset';
28
+ import { CHECKBOX, MONTH_LIST, INFO_LOADER, PAGE_OPTION } from "./constants/Constant";
29
+ import Information from './Information';
30
+ import Input from './inputs/InputSelectionHandler';
31
+ import datetimeFormatter from './DatetimeFormatter';
32
+ import { Popover } from './inputs/Select';
33
+ // Package
34
+ import { Calendar } from 'react-date-range';
35
+ var MenuBar = function (_a) {
36
+ var config = _a.config, info = _a.info, button = _a.button, getActions = _a.getActions, dropdown = _a.dropdown, search = _a.search, pagination = _a.pagination, pivot = _a.pivot, check = _a.check, toggle = _a.toggle, mainButton = _a.mainButton, buttonFooter = _a.buttonFooter, undoButton = _a.undoButton, customClass = _a.customClass, children = _a.children;
37
+ // React Hooks Popover
38
+ var _b = useState(null), infoPopover = _b[0], setInfoPopover = _b[1];
39
+ var _c = useState(null), mainButtonPopover = _c[0], setMainButtonPopover = _c[1];
40
+ var _d = useState(null), dropdownPopover = _d[0], setDropdownPopover = _d[1];
41
+ var _e = useState(null), paginationSummaryPopover = _e[0], setPaginationSummaryPopover = _e[1];
42
+ var _f = useState(null), pivotPopover = _f[0], setPivotPopover = _f[1];
43
+ var _g = useState(null), filterPopover = _g[0], setFilterPopover = _g[1];
44
+ var _h = useState(""), calendarYear = _h[0], setCalendarYear = _h[1];
45
+ var _j = useState(null), minMonthIdx = _j[0], setMinMonthIdx = _j[1];
46
+ var _k = useState(null), maxMonthIdx = _k[0], setMaxMonthIdx = _k[1];
47
+ // React Hooks Variables
48
+ var _l = useState(''), searchTemporaryValue = _l[0], setSearchTemporaryValue = _l[1];
49
+ var _m = useState(1), goToPage = _m[0], setGoToPage = _m[1];
50
+ var _o = useState(""), perPageTemporaryValue = _o[0], setPerPageTemporaryValue = _o[1];
51
+ var _p = useState([]), paginationSummaryFormError = _p[0], setPaginationSummaryFormError = _p[1];
52
+ var _q = useState(false), loaded = _q[0], setLoaded = _q[1];
53
+ var _r = useState(0), seconds = _r[0], setSeconds = _r[1];
54
+ var _s = useState(undoButton && undoButton.show ? true : false), undoShow = _s[0], setUndoShow = _s[1];
55
+ var _t = useState(false), doneTimer = _t[0], setDoneTimer = _t[1];
56
+ useEffect(function () {
57
+ var filteredMonthList = [];
58
+ if (dropdown && dropdown.minMonth) {
59
+ filteredMonthList = __spreadArray([], MONTH_LIST, true).filter(function (item) { return (item.value.toLowerCase() === dropdown.minMonth.toLowerCase()); });
60
+ if (filteredMonthList.length > 0) {
61
+ minMonthIdx = MONTH_LIST.indexOf(filteredMonthList[0]);
62
+ setMinMonthIdx(minMonthIdx);
63
+ }
64
+ }
65
+ if (dropdown && dropdown.maxMonth) {
66
+ filteredMonthList = __spreadArray([], MONTH_LIST, true).filter(function (item) { return (item.value.toLowerCase() === dropdown.maxMonth.toLowerCase()); });
67
+ if (filteredMonthList.length > 0) {
68
+ maxMonthIdx = MONTH_LIST.indexOf(filteredMonthList[0]);
69
+ setMaxMonthIdx(maxMonthIdx);
70
+ }
71
+ }
72
+ if (search && search.value && loaded === false) {
73
+ setSearchTemporaryValue(search.value);
74
+ setLoaded(true);
75
+ }
76
+ if (undoButton && undoButton.show) {
77
+ var buttonWithTimer_1 = undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (undoButton.actions.filter(function (item) { return (item.hasOwnProperty('timer') && item.timer !== undefined && item.timer.constructor === Number); })) : [];
78
+ if (buttonWithTimer_1.length > 0) {
79
+ if (undoShow !== undoButton.show) {
80
+ if (buttonWithTimer_1[0] && buttonWithTimer_1[0].hasOwnProperty('timer')) {
81
+ buttonWithTimer_1[0].timer && setSeconds(buttonWithTimer_1[0].timer);
82
+ }
83
+ setDoneTimer(false);
84
+ setUndoShow(undoButton.show ? true : false);
85
+ }
86
+ var myInterval_1 = setInterval(function () {
87
+ if (seconds > 0) {
88
+ setSeconds(seconds - 1);
89
+ }
90
+ else {
91
+ if (!doneTimer) {
92
+ clearInterval(myInterval_1);
93
+ setDoneTimer(true);
94
+ returnValues('button', buttonWithTimer_1[0].action, null);
95
+ }
96
+ }
97
+ }, 1000);
98
+ return function () {
99
+ clearInterval(myInterval_1);
100
+ };
101
+ }
102
+ }
103
+ else {
104
+ setUndoShow(false);
105
+ }
106
+ });
107
+ // Belt Configuration Variables
108
+ info = info ? (info.constructor === Object && info.infoDetails ? (info) : info.constructor === String ? (info) : INFO_LOADER) : INFO_LOADER;
109
+ var dropdownTitle = dropdown && (dropdown.type === 'list' || dropdown.type === 'button') ? (dropdown.title ? dropdown.title : "") : dropdown && dropdown.type === 'date-picker-weekly' ? (dropdown.selection && dropdown.selection.startDate && dropdown.selection.endDate ? (dropdown.selection.startDate + ' to ' + dropdown.selection.endDate) : "") : dropdown && dropdown.type === 'date-picker-monthly' ? dropdown.selection.startDate : "";
110
+ /**
111
+ * popoverRequestHandler
112
+ * hide and show the popover of specific action
113
+ * @param {*} e - event of the click item
114
+ * @param {*} popover - popover type
115
+ */
116
+ var popoverRequestHandler = function (e, popover, hide) {
117
+ if (hide === void 0) { hide = false; }
118
+ switch (popover) {
119
+ case 'info':
120
+ var currentTarget_1 = e.currentTarget;
121
+ if (hide === false && info.constructor === String && info === INFO_LOADER) {
122
+ actionRequestHandler(e, 'icon', 'info');
123
+ setInfoPopover(e.currentTarget);
124
+ setTimeout(function () {
125
+ setInfoPopover(null);
126
+ setInfoPopover(currentTarget_1);
127
+ }, 2000);
128
+ }
129
+ else {
130
+ infoPopover ? setInfoPopover(null) : setInfoPopover(e.currentTarget);
131
+ }
132
+ break;
133
+ case 'dropdown':
134
+ if (dropdown.type === 'date-picker-monthly' && !dropdownPopover) {
135
+ dropdown.selection && dropdown.selection.startDate ? setCalendarYear(datetimeFormatter(dropdown.selection.startDate, 'full-year')) : setCalendarYear(new Date());
136
+ }
137
+ else if (dropdown.type === 'date-picker-cutoff' && !dropdownPopover) {
138
+ setCalendarYear(dropdown.currentYear); //need to improve on this one
139
+ }
140
+ dropdownPopover ? setDropdownPopover(null) : setDropdownPopover(e.currentTarget);
141
+ break;
142
+ case 'pagination-summary':
143
+ if (!Boolean(paginationSummaryPopover)) {
144
+ pagination && pagination.page ? setGoToPage(pagination.page) : setGoToPage(1);
145
+ setPerPageTemporaryValue(pagination.perPage ? pagination.perPage.toString() : '');
146
+ }
147
+ paginationSummaryPopover ? setPaginationSummaryPopover(null) : setPaginationSummaryPopover(e.currentTarget);
148
+ break;
149
+ case 'pivot':
150
+ pivotPopover ? setPivotPopover(null) : setPivotPopover(e.currentTarget);
151
+ break;
152
+ case 'filter':
153
+ filterPopover ? setFilterPopover(null) : setFilterPopover(e.currentTarget);
154
+ break;
155
+ case 'main-button':
156
+ if (hide) {
157
+ setMainButtonPopover(null);
158
+ }
159
+ else {
160
+ mainButtonPopover ? setMainButtonPopover(null) : setMainButtonPopover(e.currentTarget);
161
+ }
162
+ break;
163
+ default:
164
+ break;
165
+ }
166
+ };
167
+ /**
168
+ * actionRequestHandler
169
+ * manipulate the action and data of each action
170
+ * @param {*} e - event
171
+ * @param {*} type - action type / can be the action itself
172
+ * @param {*} action - it can be action type / data depends on the used actions
173
+ */
174
+ var actionRequestHandler = function (e, type, action, hidePopover) {
175
+ if (hidePopover === void 0) { hidePopover = true; }
176
+ if (e.preventDefault) {
177
+ e.preventDefault();
178
+ }
179
+ var data = null;
180
+ var addedParam = null;
181
+ if (type === 'search') {
182
+ data = searchTemporaryValue;
183
+ }
184
+ else if (type === 'pagination' || type === 'pagination-summary') {
185
+ data = pagination;
186
+ }
187
+ else if (type === 'dropdown' || type === 'pivot' || type === 'main-button' || type === 'button' || type === 'icon' || type === 'check' || type === 'tab' || type === 'toggle') {
188
+ data = action;
189
+ action = type;
190
+ if (dropdown && dropdown.type === 'date-picker-cutoff') {
191
+ addedParam = calendarYear;
192
+ }
193
+ }
194
+ else if (type === 'undo-button') {
195
+ data = action;
196
+ action = type;
197
+ }
198
+ if (hidePopover) {
199
+ popoverRequestHandler(e, type, true);
200
+ }
201
+ setTimeout(function () {
202
+ returnValues(action, data, addedParam);
203
+ }, 200);
204
+ };
205
+ /**
206
+ * handleChangeFormValue
207
+ * manipulate the inputs temporary values
208
+ * @param {*} e - event
209
+ * @param {*} type - type of the input that has been changed
210
+ */
211
+ var handleChangeFormValue = function (e, type) {
212
+ switch (type) {
213
+ case 'search':
214
+ e.target.value ? setSearchTemporaryValue(e.target.value) : setSearchTemporaryValue("");
215
+ break;
216
+ case 'show-per-page':
217
+ setPerPageTemporaryValue(e.target.value.toString());
218
+ setGoToPage(1);
219
+ if (paginationSummaryFormError.indexOf('perPageTemporaryValue') >= 0 && (e !== "")) {
220
+ paginationSummaryFormError = paginationSummaryFormError.filter(function (item) { return item !== 'perPageTemporaryValue'; });
221
+ setPaginationSummaryFormError(paginationSummaryFormError);
222
+ }
223
+ break;
224
+ case 'go-to-page':
225
+ setGoToPage(e.target.value);
226
+ if (paginationSummaryFormError.indexOf('goToPage') >= 0 && (e.currentTarget.value !== "" || e.currentTarget.value > 1)) {
227
+ paginationSummaryFormError = paginationSummaryFormError.filter(function (item) { return item !== 'goToPage'; });
228
+ setPaginationSummaryFormError(paginationSummaryFormError);
229
+ }
230
+ break;
231
+ case 'advanced-filter':
232
+ returnValues(type, e);
233
+ break;
234
+ default:
235
+ break;
236
+ }
237
+ };
238
+ /**
239
+ * paginationRequestHandler
240
+ * manipulate the paginations value depend on the action
241
+ * @param {*} e - event
242
+ * @param {*} action - action that the user do
243
+ */
244
+ var paginationRequestHandler = function (e, action) {
245
+ e.preventDefault();
246
+ var paginationCopy = __assign({}, pagination);
247
+ switch (action) {
248
+ case 'check-pagination-required':
249
+ var formError = [];
250
+ if (goToPage === "" || goToPage < 1) {
251
+ formError.push('goToPage');
252
+ }
253
+ if (perPageTemporaryValue === "") {
254
+ formError.push('perPageTemporaryValue');
255
+ }
256
+ return formError;
257
+ case 'submit':
258
+ var errorFields = paginationRequestHandler(e, 'check-pagination-required');
259
+ if (errorFields.length > 0) {
260
+ setPaginationSummaryFormError(errorFields);
261
+ }
262
+ else {
263
+ pagination.perPage = perPageTemporaryValue ? parseInt(perPageTemporaryValue) : pagination.perPage;
264
+ pagination.page = goToPage ? ((pagination.perPage * goToPage) > pagination.total ? (Math.floor(pagination.total / pagination.perPage) + 1) : parseInt(goToPage)) : 1;
265
+ pagination.counter = (pagination.page * pagination.perPage) > pagination.total ? pagination.total : (pagination.page * pagination.perPage);
266
+ // if (paginationCopy.perPage !== pagination.perPage || paginationCopy.page !== pagination.page || paginationCopy.counter !== pagination.counter) {
267
+ actionRequestHandler(e, 'pagination-summary', 'pagination');
268
+ // }
269
+ }
270
+ break;
271
+ case 'next':
272
+ pagination.page = ((pagination.page++) * pagination.perPage) > pagination.total ? (Math.floor(pagination.total / pagination.perPage) + 1) : pagination.page++;
273
+ pagination.counter = (pagination.page * pagination.perPage) > pagination.total ? pagination.total : (pagination.page * pagination.perPage);
274
+ if (paginationCopy.page !== pagination.page || paginationCopy.counter !== pagination.counter) {
275
+ actionRequestHandler(e, 'pagination', 'pagination');
276
+ }
277
+ break;
278
+ case 'prev':
279
+ pagination.page = pagination.page > 1 ? pagination.page -= 1 : pagination.page;
280
+ pagination.counter = pagination.page * pagination.perPage;
281
+ if (paginationCopy.page !== pagination.page || paginationCopy.counter !== pagination.counter) {
282
+ actionRequestHandler(e, 'pagination', 'pagination');
283
+ }
284
+ break;
285
+ default:
286
+ break;
287
+ }
288
+ };
289
+ /**
290
+ * checkboxRequestHandler
291
+ * select all / unselect all items
292
+ * @param {*} e - event
293
+ * @param {*} action - action of the checkbox
294
+ */
295
+ var checkboxRequestHandler = function (e, action) {
296
+ // e.preventDefault();
297
+ if (check.disabled !== true) {
298
+ if (action === 'all') {
299
+ actionRequestHandler(e, 'check', 'all');
300
+ }
301
+ else {
302
+ actionRequestHandler(e, 'check', 'none');
303
+ }
304
+ }
305
+ };
306
+ /**
307
+ * onDatePickerChange
308
+ * change the datepicker value
309
+ * @param {*} e - event
310
+ * @param {*} type - action type
311
+ */
312
+ var onDatePickerChange = function (e, type) {
313
+ if (dropdown.type === 'date-picker-weekly') {
314
+ dropdown.selection.startDate = datetimeFormatter(e, 'start-of-Week');
315
+ dropdown.selection.endDate = datetimeFormatter(e, 'end-of-Week');
316
+ }
317
+ actionRequestHandler(e, type, dropdown.selection);
318
+ };
319
+ /**
320
+ * dateMonthlyPickerHandler
321
+ * selection of month on a calendar and changing of year
322
+ * @param {*} e - event
323
+ * @param {*} action - action type
324
+ */
325
+ var dateMonthlyPickerHandler = function (e, action, data) {
326
+ if (data === void 0) { data = ''; }
327
+ var _a = __assign({}, dropdown), maxYear = _a.maxYear, minYear = _a.minYear;
328
+ var newDateValue = null;
329
+ var standardDate = null;
330
+ var selectedMonthDate = null;
331
+ var monthIdx = null;
332
+ var fullYear = null;
333
+ if (action === 'next') {
334
+ if (!maxYear || (maxYear && parseInt(maxYear) >= calendarYear + 1)) {
335
+ calendarYear += 1;
336
+ setCalendarYear(calendarYear);
337
+ }
338
+ }
339
+ else if (action === 'prev') {
340
+ if (!minYear || (minYear && parseInt(minYear) <= calendarYear - 1)) {
341
+ calendarYear -= 1;
342
+ setCalendarYear(calendarYear);
343
+ }
344
+ }
345
+ else if (action === 'month-selection') {
346
+ newDateValue = datetimeFormatter(data + ' ' + calendarYear, 'month-year');
347
+ actionRequestHandler(e, 'dropdown', newDateValue);
348
+ }
349
+ else if (action === 'next-month') {
350
+ standardDate = datetimeFormatter(dropdown.selection.startDate, 'date-standard');
351
+ 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;
352
+ monthIdx = selectedMonthDate.getMonth();
353
+ fullYear = selectedMonthDate.getFullYear();
354
+ if (monthIdx + 1 < 12) {
355
+ monthIdx = monthIdx + 1;
356
+ }
357
+ else {
358
+ monthIdx = 0;
359
+ fullYear = fullYear + 1;
360
+ }
361
+ if ((!maxYear && !maxMonthIdx) || fullYear < parseInt(maxYear) || (fullYear === parseInt(maxYear) && monthIdx <= parseInt(maxMonthIdx))) {
362
+ newDateValue = datetimeFormatter(MONTH_LIST[monthIdx].value + ' ' + fullYear, 'month-year');
363
+ actionRequestHandler(e, 'dropdown', newDateValue, false);
364
+ }
365
+ }
366
+ else if (action === 'prev-month') {
367
+ standardDate = datetimeFormatter(dropdown.selection.startDate, 'date-standard');
368
+ 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;
369
+ monthIdx = selectedMonthDate.getMonth();
370
+ fullYear = selectedMonthDate.getFullYear();
371
+ if (monthIdx - 1 >= 0) {
372
+ monthIdx = monthIdx - 1;
373
+ }
374
+ else {
375
+ monthIdx = 11;
376
+ fullYear = fullYear - 1;
377
+ }
378
+ if ((!minYear && !minMonthIdx) || fullYear > parseInt(minYear) || (fullYear === parseInt(minYear) && monthIdx >= parseInt(minMonthIdx))) {
379
+ var newDateValue_1 = datetimeFormatter(MONTH_LIST[monthIdx].value + ' ' + fullYear, 'month-year');
380
+ actionRequestHandler(e, 'dropdown', newDateValue_1, false);
381
+ }
382
+ }
383
+ };
384
+ var dateCutoffPickerHandler = function (e, label, value) {
385
+ var cutOffVal = {
386
+ "label": label,
387
+ "value": value,
388
+ };
389
+ actionRequestHandler(e, 'dropdown', cutOffVal);
390
+ };
391
+ /**
392
+ * returnValues
393
+ * return manipulated value from beltConfig to the parent component
394
+ * @param {*} action - done action on beltConfig
395
+ * @param {*} data - manipulated data from the action
396
+ */
397
+ var returnValues = function (action, data, addedParam) {
398
+ if (addedParam === void 0) { addedParam = null; }
399
+ return getActions ? getActions(action, data, addedParam) : false;
400
+ };
401
+ /**
402
+ * dateMonthlyPickerIsSelected
403
+ * determine if month is selected
404
+ * @param {*} month - month value
405
+ */
406
+ var dateMonthlyPickerIsSelected = function (month) {
407
+ var isSelected = false;
408
+ if (dropdown && dropdown.selection && dropdown.selection.startDate && calendarYear) {
409
+ var monthYear = month + ' ' + calendarYear;
410
+ isSelected = datetimeFormatter(dropdown.selection.startDate.toString(), 'month-year') === datetimeFormatter(monthYear, 'month-year') ? true : false;
411
+ }
412
+ return isSelected;
413
+ };
414
+ var isDisabledDropdownPagination = function (action) {
415
+ var _a = __assign({}, dropdown), maxYear = _a.maxYear, minYear = _a.minYear, selection = _a.selection;
416
+ var selectedMonthDate = new Date(selection.startDate);
417
+ var monthIdx = selectedMonthDate.getMonth();
418
+ var fullYear = selectedMonthDate.getFullYear();
419
+ if (action === 'prev') {
420
+ if (minYear && minMonthIdx && fullYear === parseInt(minYear) && monthIdx === parseInt(minMonthIdx)) {
421
+ return ' is-disabled';
422
+ }
423
+ else {
424
+ return '';
425
+ }
426
+ }
427
+ else if (action === 'next') {
428
+ if (maxYear && maxMonthIdx && fullYear === parseInt(maxYear) && monthIdx === parseInt(maxMonthIdx)) {
429
+ return ' is-disabled';
430
+ }
431
+ else {
432
+ return '';
433
+ }
434
+ }
435
+ };
436
+ var toggleSelectionHandler = function (event, value) {
437
+ event.preventDefault();
438
+ actionRequestHandler(event, 'toggle', value, false);
439
+ };
440
+ return (_jsxs("div", __assign({ className: customClass && customClass.constructor === String ? customClass : 'custom-card' }, { children: [_jsxs("div", __assign({ className: "em-card-belt" }, { children: [_jsxs("div", __assign({ className: "em-belt-left" }, { children: [_jsxs("div", __assign({ className: "em-beltleft-container" }, { children: [
441
+ // Back Icon Configuration
442
+ config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("back") >= 0) || (config.iconType === 'back')) ? (_jsx("a", __assign({ className: "belt-icon icon-back", href: "#", onClick: function (event) { return actionRequestHandler(event, 'icon', 'back'); }, "data-testid": "menubar-back" }, { children: SVG_BACK }))) : null,
443
+ // Check Icon Configuration
444
+ config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("check") >= 0) || (config.iconType === 'check')) ? (_jsx("div", __assign({ className: "belt-icon-check", "data-testid": "menubar-checkbox" }, { children: check ? (check.selected === 0 ? (_jsx("div", __assign({ onClick: function (event) { return checkboxRequestHandler(event, 'all'); } }, { children: CHECKBOX.NONE }))) : check.selected > 0 && check.selected < check.total ? (_jsx("div", __assign({ onClick: function (event) { return checkboxRequestHandler(event, 'all'); } }, { children: CHECKBOX.FEW }))) : check.selected === check.total ? (_jsx("div", __assign({ onClick: function (event) { return checkboxRequestHandler(event, 'none'); } }, { children: CHECKBOX.ALL }))) : _jsx("div", { children: CHECKBOX.NONE })) : _jsx("div", { children: CHECKBOX.NONE }) }))) : null,
445
+ // Standard Icon Configuration
446
+ config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("standard") >= 0) || (config.iconType === 'standard')) ? (_jsx("div", __assign({ className: "belt-icon", "data-testid": "menubar-standard-icon" }, { children: config.icon }))) : null, _jsxs("div", __assign({ className: "belt-title" }, { children: [
447
+ // Title Configuration
448
+ check && check.selected && check.selected > 0 && check.selected < check.total ? (_jsx("h6", { children: "".concat(check.selected, " ").concat(check.selected === 1 ? 'item selected' : 'items selected') })) : check && check.selected && check.selected === check.total ? (_jsx("h6", { children: "All item(s) selected" })) : config && config.title && (config.title.constructor === String || config.title.constructor === Object) ? (_jsx("h6", __assign({ className: "config-title", "data-testid": "menubar-title" }, { children: config.title }))) : null,
449
+ // Title Information Configuration
450
+ config && config.titleDescription ? (_jsx("p", { children: config.titleDescription })) : null] })),
451
+ // Information Configuration
452
+ config && config.showInfo.constructor === Boolean && config.showInfo === true ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-belt-info" }, { children: [_jsx("a", __assign({ href: "#", onClick: function (event) { return popoverRequestHandler(event, 'info'); }, "data-testid": "menubar-information" }, { children: _jsx("div", __assign({ className: "em-info-icon" }, { children: SVG_INFORMATION })) })), _jsx(Popover, __assign({ id: "InfoPopOver", open: Boolean(infoPopover), className: Boolean(dropdownPopover) ? 'open-popover' : '', onClick: function (event) { return popoverRequestHandler(event, 'info'); } }, { children: _jsx(Information, { items: info && info.infoDetails ? info.infoDetails : info, listRow: info && info.listRow ? info.listRow : [], desc: info && info.listRow && info.listRow.length > 0 ? false : true, title: config && config.title ? config.title : null, hide: function (event) { return popoverRequestHandler(event, 'info', true); } }) }))] })) })) : null,
453
+ // Additional title on the modal
454
+ config && config.addedTitle ? (_jsx("p", { children: config.addedTitle })) : null] })), _jsxs("div", __assign({ className: "em-beltleft-cta" }, { children: [
455
+ // Main Button
456
+ mainButton && mainButton.show ? (mainButton.actions && mainButton.actions.constructor === Array && mainButton.actions.length > 0 ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-dropdown" }, { children: [_jsxs("a", __assign({ className: "em-button belt-action-main", id: "main-button", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'main-button'); } }, { children: [_jsx("div", __assign({ className: "belt-icon" }, { children: mainButton.icon ? mainButton.icon : '' })), _jsx("span", { children: mainButton.label ? mainButton.label : 'File a Request' })] })), _jsx(Popover, __assign({ id: "mainButtonPopover", open: Boolean(mainButtonPopover), onClick: function (event) { return popoverRequestHandler(event, 'main-button'); }, className: Boolean(dropdownPopover) ? 'open-popover' : '' }, { children: _jsx("div", __assign({ className: "popover em-popover-list" }, { children: mainButton.actions.map(function (btn, idx) {
457
+ return _jsx("a", __assign({ href: "#", onClick: function (event) { return actionRequestHandler(event, 'main-button', btn.action); } }, { children: btn.label }), idx);
458
+ }) })) }))] })) })) : mainButton.actions && mainButton.actions.constructor === Array && mainButton.actions.length === 1 ? (mainButton.actions.map(function (btn, idx) {
459
+ return (_jsxs("a", __assign({ className: btn.class ? 'belt-action ' + btn.class : 'belt-action', href: "#", onClick: function (event) { return actionRequestHandler(event, 'main-button', btn.action); } }, { children: [_jsx("div", __assign({ className: "belt-icon " }, { children: btn.icon ? btn.icon : '' })), _jsx("span", { children: btn.label ? btn.label : '' })] }), idx));
460
+ })) : null) : null,
461
+ // Button Actions Configuration
462
+ button && button.show && button.show.constructor === Boolean &&
463
+ button.actions && button.actions.constructor === Array && button.actions.length > 0 ? (button.actions.map(function (btn, idx) {
464
+ return (_jsxs("a", __assign({ className: btn.class ? btn.class : ' belt-action' + ' ' + (idx === 0 ? 'is-primary' : ''), href: "#", onClick: function (event) { return actionRequestHandler(event, 'button', btn.action); }, "data-testid": "menubar-button" }, { children: [_jsx("div", __assign({ className: "belt-icon belt-buttons" }, { children: btn.icon ? btn.icon : '' })), _jsx("span", __assign({ "data-testid": 'button-action-' + btn.action }, { children: btn.label ? btn.label : '' }))] }), idx));
465
+ })) : null,
466
+ // UndoButton Actions Configuration
467
+ undoButton && undoButton.show && !undoButton.isFooter &&
468
+ undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (undoButton.actions.map(function (btn, idx) {
469
+ return seconds > 0 || (btn.timer !== undefined) ? (_jsxs("a", __assign({ className: btn.class ? btn.class : 'belt-action' + ' ' + (idx === 0 ? 'is-primary' : '') + (btn.disabled === true ? ' is-disabled' : ' em-button outline button-undo'), href: "#", "data-testid": "undo-button-".concat(btn.action) }, (btn.disabled === true ? { onClick: function (event) { event.preventDefault(); } } : { onClick: function (event) { return actionRequestHandler(event, 'undo-button', btn.action); } }), { children: [_jsx("div", __assign({ className: "belt-icon" }, { children: btn.icon ? btn.icon : '' })), _jsx("span", __assign({ "data-testid": "undo-button-text" }, { children: btn.label ? ("".concat(btn.label, " ").concat(btn.timer !== undefined && btn.timer.constructor === Number && seconds > 0 ? ("in ".concat(seconds, "s")) : '')) : '' }))] }), idx)) : null;
470
+ })) : null] }))] })), _jsxs("div", __assign({ className: "em-belt-right" }, { children: [
471
+ // Dropdown Actions Configuration
472
+ dropdown && dropdown.show && dropdown.show.constructor === Boolean ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-dropdown" }, { children: [dropdown.type === 'list' ? (_jsxs("a", __assign({ className: "belt-dropdown", id: "add", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: [_jsx("div", __assign({ className: "icon-add" }, { children: dropdown.icon ? dropdown.icon : '' })), _jsx("span", { children: dropdownTitle })] }))) : dropdown.type === 'date-picker-weekly' ? (_jsxs("a", __assign({ id: "months", className: "belt-dropdown ".concat(Boolean(dropdownPopover) ? 'is-active' : ''), href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: [_jsx("span", { children: dropdownTitle }), _jsx("div", __assign({ className: "icon-arrowdown" }, { children: SVG_ARROWDOWN }))] }))) : dropdown.type === 'date-picker-monthly' ? (_jsxs(Fragment, { children: [_jsxs("a", __assign({ id: "months", className: "belt-dropdown ".concat(Boolean(dropdownPopover) ? 'is-active' : ''), href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: [_jsx("span", { children: dropdownTitle }), _jsx("div", __assign({ className: "icon-arrowdown" }, { children: SVG_ARROWDOWN }))] })), dropdown.showPagination ? (_jsxs(Fragment, { children: [_jsx("a", __assign({ className: 'belt-prev' + isDisabledDropdownPagination('prev'), href: "#", onClick: function (event) { return dateMonthlyPickerHandler(event, 'prev-month'); } }, { children: _jsx("div", __assign({ className: "belt-icon" }, { children: SVG_ARROWLEFT })) })), _jsx("a", __assign({ className: 'belt-next' + isDisabledDropdownPagination('next'), href: "#", onClick: function (event) { return dateMonthlyPickerHandler(event, 'next-month'); } }, { children: _jsx("div", __assign({ className: "belt-icon" }, { children: SVG_ARROWRIGHT })) }))] })) : null] })) : dropdown.type === 'date-picker-cutoff' ? ((_jsx("a", __assign({ className: "belt-dropdown", id: "add", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: _jsx("span", { children: dropdown.cutoffValue && dropdown.cutoffValue.label ? dropdown.cutoffValue.label : '' }) })))) : dropdown.type === 'button' ? (_jsxs("a", __assign({ className: "belt-dropdown", id: "add", href: "#", onClick: function (event) { return actionRequestHandler(event, 'button', dropdown.action); } }, { children: [_jsx("div", __assign({ className: "belt-icon" }, { children: dropdown.icon ? dropdown.icon : '' })), _jsx("span", { children: dropdownTitle })] }))) : (_jsx("a", __assign({ className: "belt-dropdown", id: "add", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: _jsx("span", { children: dropdownTitle }) }))), _jsx(Popover, __assign({ id: "dropdownPopover", className: Boolean(dropdownPopover) ? 'open-popover' : '', open: Boolean(dropdownPopover), onClick: function (event) { return popoverRequestHandler(event, 'dropdown'); } }, { children: dropdown.type === 'list' ? (dropdown.actions && dropdown.actions.constructor === Array && dropdown.actions.length > 0 ? (_jsx("div", __assign({ className: "popover em-popover-list" }, { children: dropdown.actions.map(function (drpdwn, idx) {
473
+ return _jsx("a", __assign({ href: "#", onClick: function (event) { return actionRequestHandler(event, 'dropdown', drpdwn.value); } }, { children: drpdwn.label }), idx);
474
+ }) }))) : null) : dropdown.type === 'date-picker-weekly' ? (_jsx("div", __assign({ className: "popover" }, { children: _jsx(Calendar, { className: "dateRangePickerInput", onChange: function (event) { return onDatePickerChange(event, 'dropdown'); } }) }))) : dropdown.type === 'date-picker-monthly' ? (_jsxs("div", __assign({ className: "popover em-popover-months" }, { children: [_jsxs("div", __assign({ className: "list-years" }, { children: [_jsx("button", __assign({ onClick: function (event) { return dateMonthlyPickerHandler(event, 'prev'); } }, { children: SVG_ARROWLEFT })), _jsx("div", { children: calendarYear }), _jsx("button", __assign({ onClick: function (event) { return dateMonthlyPickerHandler(event, 'next'); } }, { children: SVG_ARROWRIGHT }))] })), _jsx("div", __assign({ className: "list-months" }, { children: MONTH_LIST.map(function (action, idx) {
475
+ return dropdown.minYear && dropdown.minYear.toString() === calendarYear.toString() && minMonthIdx && minMonthIdx > idx ? (_jsx("a", __assign({ href: "#", className: 'is-disabled', onClick: function (event) { event.preventDefault(); } }, { children: action.label }), idx)) : dropdown.maxYear && dropdown.maxYear.toString() === calendarYear.toString() && maxMonthIdx && maxMonthIdx < idx ? (_jsx("a", __assign({ href: "#", className: 'is-disabled', onClick: function (event) { event.preventDefault(); } }, { children: action.label }), idx)) : (_jsx("a", __assign({ className: dateMonthlyPickerIsSelected(action.label) ? 'is-selected' : '', href: "#", onClick: function (event) { return dateMonthlyPickerHandler(event, 'month-selection', action.value); } }, { children: action.label }), idx));
476
+ }) }))] }))) : dropdown.type === 'date-picker-cutoff' ? (_jsxs("div", __assign({ className: "popover em-popover-months" }, { children: [_jsxs("div", __assign({ className: "list-years" }, { children: [_jsx("button", __assign({ onClick: function (event) { return dateMonthlyPickerHandler(event, 'prev'); } }, { children: _jsx("img", { src: "/images/icons/icon-arrowleft-white.svg", alt: "" }) })), _jsx("div", { children: calendarYear }), _jsx("button", __assign({ onClick: function (event) { return dateMonthlyPickerHandler(event, 'next'); } }, { children: _jsx("img", { src: "/images/icons/icon-arrowright-white.svg", alt: "" }) }))] })), _jsx("div", __assign({ className: "list-months" }, { children: dropdown.cutoffDates !== null && dropdown.cutoffDates.length > 0 ? (dropdown.cutoffDates.map(function (action, idx) {
477
+ var classSelect;
478
+ if (JSON.stringify(action.label) === JSON.stringify(dropdown.cutoffValue.label)) {
479
+ if (dropdown.currentYear === calendarYear) {
480
+ classSelect = 'is-selected';
481
+ }
482
+ else {
483
+ classSelect = '';
484
+ }
485
+ // classSelect = 'is-selected';
486
+ }
487
+ else {
488
+ classSelect = '';
489
+ }
490
+ return _jsx("a", __assign({ className: classSelect, href: "#", onClick: function (event) { return dateCutoffPickerHandler(event, action.label, action.value); } }, { children: action.label }), idx);
491
+ })) : null }))] }))) : null }))] })) })) : null, pagination && pagination.show && pagination.show.constructor === Boolean ? (_jsxs(Fragment, { children: [!pagination.hideSummary || pagination.hideSummary === false ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-dropdown" }, { children: [_jsxs("a", __assign({ className: "pagination-summary", href: "#", id: "pagination", onClick: function (event) { return popoverRequestHandler(event, 'pagination-summary'); }, "data-testid": "menubar-pagination" }, { children: [(pagination.counter > 0 ? (((pagination.page - 1) * pagination.perPage) + 1) : 0)
492
+ + ' - ' +
493
+ (pagination.page * pagination.perPage > pagination.total ?
494
+ (pagination.total ? pagination.total : pagination.counter) :
495
+ pagination.page * pagination.perPage), " of ", pagination.total ? pagination.total : 0] })), _jsx(Popover, __assign({ id: "paginationSummaryPopover", className: Boolean(dropdownPopover) ? 'open-popover' : '', open: Boolean(paginationSummaryPopover), onClick: function (event) { return popoverRequestHandler(event, 'pagination-summary'); } }, { children: _jsxs("div", __assign({ className: "popover em-popover-input" }, { children: [_jsxs("div", __assign({ className: 'e-field field field-input' + (paginationSummaryFormError.indexOf('perPageTemporaryValue') >= 0 ? ' is-invalid' : '') }, { children: [_jsx("label", __assign({ className: 'e-input-label' }, { children: "SHOW" })), _jsx(Input, { config: {
496
+ id: 'paginationPerPage',
497
+ type: 'select',
498
+ placeholder: '-',
499
+ value: perPageTemporaryValue,
500
+ options: PAGE_OPTION
501
+ }, onChanged: function (event) { return handleChangeFormValue(event, 'show-per-page'); } })] })), _jsxs("div", __assign({ className: 'e-field field field-input' + (paginationSummaryFormError.indexOf('goToPage') >= 0 ? ' is-invalid' : '') }, { children: [_jsx("label", __assign({ className: 'e-input-label' }, { children: "GO TO PAGE" })), _jsx("div", __assign({ className: "e-input" }, { children: _jsx(Input, { config: {
502
+ id: 'goToPage',
503
+ type: 'number',
504
+ value: goToPage,
505
+ placeholder: '-',
506
+ maxLength: 5,
507
+ min: '1',
508
+ }, onChanged: function (event) { return handleChangeFormValue(event, 'go-to-page'); } }) }))] })), _jsx("button", __assign({ className: "button-check", onClick: function (event) { return paginationRequestHandler(event, 'submit'); } }, { children: SVG_CHECK }))] })) }))] })) })) : null, _jsx("a", __assign({ className: (pagination.page * pagination.perPage) > pagination.perPage ? 'belt-prev' : 'belt-prev is-disabled', href: "#" }, (((pagination.page * pagination.perPage) > pagination.perPage) ? { onClick: function (event) { return paginationRequestHandler(event, 'prev'); } } : { onClick: function (event) { event.preventDefault(); } }), { children: _jsx("div", __assign({ className: "belt-icon" }, { children: SVG_ARROWLEFT })) })), _jsx("a", __assign({ className: pagination.total <= (pagination.page * pagination.perPage) ? 'belt-next is-disabled' : 'belt-next', href: "#" }, ((pagination.total <= (pagination.page * pagination.perPage)) ? { onClick: function (event) { event.preventDefault(); } } : { onClick: function (event) { return paginationRequestHandler(event, 'next'); } }), { children: _jsx("div", __assign({ className: "belt-icon" }, { children: SVG_ARROWRIGHT })) }))] })) : null,
509
+ // Pivot Configuration
510
+ pivot && pivot.show ? (_jsx(Fragment, { children: _jsxs("div", __assign({ className: "em-dropdown" }, { children: [_jsxs("a", __assign({ id: "months", className: "belt-dropdown ", href: "#", onClick: function (event) { return popoverRequestHandler(event, 'pivot'); }, "data-testid": "menubar-pivot" }, { children: [_jsx("span", { children: pivot.selected && pivot.actions &&
511
+ pivot.actions.constructor === Array && pivot.actions.length > 0 ? (pivot.actions.filter(function (item) { return (item.value === pivot.selected); }).length > 0 ? (pivot.actions.filter(function (item) { return (item.value === pivot.selected); })[0].label) : 'None') : 'None' }), _jsx("div", __assign({ className: "icon-arrowdown" }, { children: SVG_ARROWDOWN }))] })), _jsx(Popover, __assign({ id: "pivotPopover", className: Boolean(dropdownPopover) ? 'open-popover' : '', open: Boolean(pivotPopover), onClick: function (event) { return popoverRequestHandler(event, 'pivot'); } }, { children: pivot.actions && pivot.actions.constructor === Array && pivot.actions.length > 0 ? (_jsx("div", __assign({ className: "popover em-popover-list" }, { children: pivot.actions.map(function (pvt, idx) {
512
+ return _jsx("a", __assign({ href: "#", onClick: function (event) { return actionRequestHandler(event, 'pivot', pvt.value); } }, { children: pvt.label }), idx);
513
+ }) }))) : null }))] })) })) : null,
514
+ // Close Icon Configuration
515
+ config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("close") >= 0) || (config.iconType === 'close')) ? (_jsx("a", __assign({ className: "em-close", href: "#", onClick: function (event) { return actionRequestHandler(event, 'icon', 'close'); }, "date-testid": "menubar-close" }, { children: SVG_CLOSE_GRAY }))) : null, toggle && toggle.show && toggle.buttons && toggle.buttons.constructor === Array ? (_jsx(Fragment, { children: _jsx("div", __assign({ className: "belt-toggle" }, { children: toggle.buttons.map(function (item, idx) { return (_jsx("a", __assign({ className: "belt-icon icon-calendar " + (item.value === toggle.value ? ' is-active' : ''), href: "#", onClick: function (event) { return toggleSelectionHandler(event, item.value); } }, { children: item.value === toggle.value ? item.selectedIconDisplay : item.icon }), 'toggle-' + idx)); }) })) })) : null] }))] })),
516
+ // Search Configuration
517
+ search && search.show && search.show.constructor === Boolean ? (_jsx("div", __assign({ className: "field em-card-search" }, { children: _jsx("div", __assign({ className: "e-input" }, { children: _jsx(Input, { config: {
518
+ id: 'search',
519
+ type: 'text',
520
+ placeholder: search.placeholder ? search.placeholder : 'Search',
521
+ maxLength: 30,
522
+ readOnly: false,
523
+ disabled: false,
524
+ value: searchTemporaryValue ? searchTemporaryValue : ''
525
+ }, onChanged: function (event) { return handleChangeFormValue(event, 'search'); }, keyPressed: function (event) { return actionRequestHandler(event, 'search', 'search'); } }) })) }))) : null, children, _jsxs("div", __assign({ className: "em-card-footer" }, { children: [buttonFooter && buttonFooter.show && buttonFooter.actions.length > 0 &&
526
+ _jsx("div", __assign({ className: buttonFooter.className }, { children: buttonFooter.actions.map(function (btn, idx) { return (btn.show &&
527
+ _jsxs("a", __assign({ className: 'em-button ' + btn.className, href: "#" }, (btn.disabled === true ? { onClick: function (event) { event.preventDefault(); } } : { onClick: function (event) { return actionRequestHandler(event, 'button', btn.action); } }), { "data-testid": btn.id && btn.id.constructor === String ? btn.id : 'default-button-footer' }, { children: [_jsx("div", __assign({ className: "icon" }, { children: btn.icon ? btn.icon : '' })), _jsx("span", __assign({ "data-testid": 'button-action-' + btn.action }, { children: btn.label ? btn.label : '' }))] }), idx)); }) })),
528
+ // UndoButton Actions Configuration
529
+ undoButton && undoButton.show && undoButton.isFooter &&
530
+ undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (undoButton.actions.map(function (btn, idx) {
531
+ return seconds > 0 || (btn.timer !== undefined) ? (_jsxs("a", __assign({ className: btn.class ? btn.class : 'em-button ' + ' ' + (idx === 0 ? 'disabled' : 'outline button-undo') + (btn.disabled === true ? ' is-disabled button-undo' : ''), href: "#", "data-testid": "undo-button-".concat(btn.action) }, (btn.disabled === true ? { onClick: function (event) { event.preventDefault(); } } : { onClick: function (event) { return actionRequestHandler(event, 'undo-button', btn.action); } }), { children: [_jsx("div", __assign({ className: "belt-icon" }, { children: btn.icon ? btn.icon : '' })), _jsx("span", __assign({ "data-testid": "undo-button-text" }, { children: btn.label ? ("".concat(btn.label, " ").concat(btn.timer !== undefined && btn.timer.constructor === Number && seconds > 0 ? ("in ".concat(seconds, "s")) : '')) : '' }))] }), idx)) : null;
532
+ })) : null] }))] })));
533
+ };
534
+ export default MenuBar;