empower-container 0.1.9 → 0.1.12

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 (83) hide show
  1. package/README.md +70 -2
  2. package/{src/main → dist}/assets/Asset.d.ts +0 -0
  3. package/{src/main → dist}/assets/Asset.js +0 -0
  4. package/{src/main → dist}/assets/Asset.tsx +0 -0
  5. package/{src/main → dist}/assets/icons/icon-check-white-sm.svg +0 -0
  6. package/{src/main → dist}/assets/images/icon-arrowdown-graydark.svg +0 -0
  7. package/{src/main → dist}/assets/images/icon-arrowleft-graydark.svg +0 -0
  8. package/{src/main → dist}/assets/images/icon-arrowright-graydark.svg +0 -0
  9. package/{src/main → dist}/assets/images/icon-arrowup-graydark.svg +0 -0
  10. package/{src/main → dist}/assets/images/icon-check-graydark.svg +0 -0
  11. package/dist/cjs/MenuBar.js +7 -7
  12. package/dist/esm/MenuBar.js +7 -7
  13. package/dist/scss/elements/_button.scss +5 -5
  14. package/dist/scss/library/_menubar.scss +41 -11
  15. package/dist/scss/library/_select.scss +6 -5
  16. package/package.json +2 -2
  17. package/public/favicon.ico +0 -0
  18. package/public/index.html +0 -43
  19. package/public/logo192.png +0 -0
  20. package/public/logo512.png +0 -0
  21. package/public/manifest.json +0 -25
  22. package/public/robots.txt +0 -3
  23. package/src/index.tsx +0 -15
  24. package/src/main/DatetimeFormatter.d.ts +0 -3
  25. package/src/main/DatetimeFormatter.js +0 -389
  26. package/src/main/DatetimeFormatter.tsx +0 -392
  27. package/src/main/Information.d.ts +0 -10
  28. package/src/main/Information.js +0 -65
  29. package/src/main/Information.tsx +0 -112
  30. package/src/main/MenuBar.d.ts +0 -24
  31. package/src/main/MenuBar.js +0 -650
  32. package/src/main/MenuBar.tsx +0 -1072
  33. package/src/main/Modal.d.ts +0 -33
  34. package/src/main/Modal.js +0 -24
  35. package/src/main/Modal.tsx +0 -83
  36. package/src/main/constants/Constant.d.ts +0 -15
  37. package/src/main/constants/Constant.js +0 -44
  38. package/src/main/index.d.ts +0 -3
  39. package/src/main/index.js +0 -10
  40. package/src/main/index.tsx +0 -5
  41. package/src/main/inputs/Input.d.ts +0 -25
  42. package/src/main/inputs/Input.js +0 -135
  43. package/src/main/inputs/Input.tsx +0 -193
  44. package/src/main/inputs/InputSelectionHandler.d.ts +0 -2
  45. package/src/main/inputs/InputSelectionHandler.js +0 -36
  46. package/src/main/inputs/InputSelectionHandler.tsx +0 -21
  47. package/src/main/inputs/Select.d.ts +0 -28
  48. package/src/main/inputs/Select.js +0 -456
  49. package/src/main/inputs/Select.tsx +0 -654
  50. package/src/main/tsconfig.common.json +0 -34
  51. package/src/main/tsconfig.json +0 -35
  52. package/src/sample/App.css +0 -38
  53. package/src/sample/App.d.ts +0 -3
  54. package/src/sample/App.js +0 -13
  55. package/src/sample/App.test.d.ts +0 -1
  56. package/src/sample/App.test.js +0 -13
  57. package/src/sample/App.test.tsx +0 -9
  58. package/src/sample/App.tsx +0 -15
  59. package/src/sample/TestMenuBar.d.ts +0 -2
  60. package/src/sample/TestMenuBar.js +0 -508
  61. package/src/sample/TestMenuBar.tsx +0 -362
  62. package/src/sample/react-app-env.d.ts +0 -1
  63. package/src/sample/reportWebVitals.d.ts +0 -3
  64. package/src/sample/reportWebVitals.js +0 -38
  65. package/src/sample/reportWebVitals.ts +0 -15
  66. package/src/sample/setupTests.d.ts +0 -1
  67. package/src/sample/setupTests.js +0 -7
  68. package/src/sample/setupTests.ts +0 -5
  69. package/src/sample/tsconfig.json +0 -36
  70. package/src/scss/components/_modal.scss +0 -66
  71. package/src/scss/elements/_button.scss +0 -107
  72. package/src/scss/elements/_index.scss +0 -2
  73. package/src/scss/elements/_popover.scss +0 -8
  74. package/src/scss/foundation/_colors.scss +0 -60
  75. package/src/scss/foundation/_mixins.scss +0 -41
  76. package/src/scss/foundation/_normalize.scss +0 -204
  77. package/src/scss/foundation/_settings.scss +0 -36
  78. package/src/scss/foundation/_typography.scss +0 -95
  79. package/src/scss/library/_information.scss +0 -68
  80. package/src/scss/library/_input.scss +0 -37
  81. package/src/scss/library/_menubar.scss +0 -225
  82. package/src/scss/library/_select.scss +0 -258
  83. package/src/scss/style.scss +0 -24
@@ -1,1072 +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
- <a className="belt-action-main" id="main-button" href="#" onClick={event => popoverRequestHandler(event, 'main-button')}>
610
- <div className="belt-icon">{mainButton.icon ? mainButton.icon : ''}</div>
611
- <span>{mainButton.label ? mainButton.label : 'File a Request'}</span>
612
- </a>
613
- <Popover
614
- id="mainButtonPopover"
615
- open={Boolean(mainButtonPopover)}
616
- onClick={event => popoverRequestHandler(event, 'main-button')}
617
- className={Boolean(dropdownPopover) ? 'open-popover' : ''}
618
- >
619
- <div className="popover em-popover-list">
620
- {mainButton.actions.map((btn: any, idx: number) =>
621
- <a href="#" key={idx} onClick={event => actionRequestHandler(event, 'main-button', btn.action)}>{btn.label}</a>
622
- )}
623
- </div>
624
- </Popover>
625
- </Fragment>
626
- ) : mainButton.actions && mainButton.actions.constructor === Array && mainButton.actions.length === 1 ? (
627
- mainButton.actions.map((btn: any, idx: number) => {
628
- return (
629
- <a className={btn.class ? 'belt-action ' + btn.class : 'belt-action'} href="#" key={idx} onClick={event => actionRequestHandler(event, 'main-button', btn.action)}>
630
- <div className="belt-icon ">{btn.icon ? btn.icon : ''}</div>
631
- <span>{btn.label ? btn.label : ''}</span>
632
- </a>
633
- )
634
- })
635
- ) : null
636
- ) : null
637
- }
638
-
639
- {
640
- // Button Actions Configuration
641
- button && button.show && button.show.constructor === Boolean &&
642
- button.actions && button.actions.constructor === Array && button.actions.length > 0 ? (
643
- button.actions.map((btn: any, idx: number) => {
644
- return (
645
- <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">
646
- <div className="belt-icon belt-buttons">{btn.icon ? btn.icon : ''}</div>
647
- <span data-testid={'button-action-' + btn.action}>{btn.label ? btn.label : ''}</span>
648
- </a>
649
- )
650
- })
651
- ) : null
652
- }
653
-
654
- {
655
- // UndoButton Actions Configuration
656
- undoButton && undoButton.show && !undoButton.isFooter &&
657
- undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (
658
- undoButton.actions.map((btn: any, idx: number) => {
659
- return seconds > 0 || (btn.timer !== undefined) ? (
660
- <a
661
- className={btn.class ? btn.class : 'belt-action' + ' ' + (idx === 0 ? 'is-primary' : '') + (btn.disabled === true ? ' is-disabled' : ' button outline button-undo')}
662
- href="#"
663
- data-testid={`undo-button-${btn.action}`}
664
- key={idx}
665
- {...(btn.disabled === true ? { onClick: event => { event.preventDefault() } } : { onClick: event => actionRequestHandler(event, 'undo-button', btn.action) })}>
666
- <div className="belt-icon">{btn.icon ? btn.icon : ''}</div>
667
- <span data-testid="undo-button-text">{btn.label ? (
668
- `${btn.label} ${btn.timer !== undefined && btn.timer.constructor === Number && seconds > 0 ? (
669
- `in ${seconds}s`
670
- ) : ''}`
671
- ) : ''}</span>
672
- </a>
673
- ) : null
674
- })
675
- ) : null
676
- }
677
- </div>
678
- </div>
679
-
680
- {/* Menubar Right */}
681
- <div className="em-belt-right">
682
- {
683
- // Dropdown Actions Configuration
684
- dropdown && dropdown.show && dropdown.show.constructor === Boolean ? (
685
- <Fragment>
686
- <div className="em-dropdown">
687
- {
688
- dropdown.type === 'list' ? (
689
- <a className="belt-dropdown" id="add" href="#" onClick={event => popoverRequestHandler(event, 'dropdown')}>
690
- <div className="icon-add">{dropdown.icon ? dropdown.icon : ''}</div>
691
- <span>{dropdownTitle}</span>
692
- </a>
693
- ) : dropdown.type === 'date-picker-weekly' ? (
694
- <a id="months"
695
- className={`belt-dropdown ${Boolean(dropdownPopover) ? 'is-active' : ''}`}
696
- href="#"
697
- onClick={event => popoverRequestHandler(event, 'dropdown')}
698
- >
699
- <span>{dropdownTitle}</span>
700
- <div className="icon-arrowdown">
701
- {SVG_ARROWDOWN}
702
- </div>
703
- </a>
704
- ) : dropdown.type === 'date-picker-monthly' ? (
705
- <Fragment>
706
- <a id="months"
707
- className={`belt-dropdown ${Boolean(dropdownPopover) ? 'is-active' : ''}`}
708
- href="#"
709
- onClick={event => popoverRequestHandler(event, 'dropdown')}
710
- >
711
- <span>{dropdownTitle}</span>
712
- <div className="icon-arrowdown">
713
- {SVG_ARROWDOWN}
714
- </div>
715
-
716
-
717
-
718
- </a>
719
- {
720
- dropdown.showPagination ? (
721
- <Fragment>
722
- <a
723
- className={'belt-prev' + isDisabledDropdownPagination('prev')}
724
- href="#"
725
- onClick={event => dateMonthlyPickerHandler(event, 'prev-month')}
726
- >
727
- <div className="belt-icon">{SVG_ARROWLEFT}</div>
728
- </a>
729
- <a
730
- className={'belt-next' + isDisabledDropdownPagination('next')}
731
- href="#"
732
- onClick={event => dateMonthlyPickerHandler(event, 'next-month')}
733
- >
734
- <div className="belt-icon">{SVG_ARROWRIGHT}</div>
735
- </a>
736
- </Fragment>
737
- ) : null
738
- }
739
- </Fragment>
740
- ) : dropdown.type === 'date-picker-cutoff' ? (
741
- (
742
- <a className="belt-dropdown" id="add" href="#" onClick={event => popoverRequestHandler(event, 'dropdown')}>
743
- <span>{dropdown.cutoffValue && dropdown.cutoffValue.label ? dropdown.cutoffValue.label : ''}</span>
744
- </a>
745
- )
746
- ) : dropdown.type === 'button' ? (
747
- <a className="belt-dropdown" id="add" href="#" onClick={event => actionRequestHandler(event, 'button', dropdown.action)}>
748
- <div className="belt-icon">{dropdown.icon ? dropdown.icon : ''}</div>
749
- <span>{dropdownTitle}</span>
750
- </a>
751
- ) : (
752
- <a className="belt-dropdown" id="add" href="#" onClick={event => popoverRequestHandler(event, 'dropdown')}>
753
- <span>{dropdownTitle}</span>
754
- </a>
755
- )
756
- }
757
- <Popover
758
- id="dropdownPopover"
759
- className={Boolean(dropdownPopover) ? 'open-popover' : ''}
760
- open={Boolean(dropdownPopover)}
761
- onClick={event => popoverRequestHandler(event, 'dropdown')}
762
-
763
- >
764
-
765
- {
766
- dropdown.type === 'list' ? (
767
- dropdown.actions && dropdown.actions.constructor === Array && dropdown.actions.length > 0 ? (
768
- <div className="popover em-popover-list">
769
- {dropdown.actions.map((drpdwn: any, idx: number) =>
770
- <a href="#" key={idx} onClick={event => actionRequestHandler(event, 'dropdown', drpdwn.value)}>{drpdwn.label}</a>
771
- )}
772
- </div>
773
- ) : null
774
- ) : dropdown.type === 'date-picker-weekly' ? (
775
- <div className="popover">
776
- <Calendar
777
- className="dateRangePickerInput"
778
- onChange={event => onDatePickerChange(event, 'dropdown')}
779
- />
780
- </div>
781
- ) : dropdown.type === 'date-picker-monthly' ? (
782
- <div className="popover em-popover-months">
783
- <div className="list-years">
784
- <button onClick={event => dateMonthlyPickerHandler(event, 'prev')} >{SVG_ARROWLEFT}</button>
785
- <div>{calendarYear}</div>
786
- <button onClick={event => dateMonthlyPickerHandler(event, 'next')} >{SVG_ARROWRIGHT}</button>
787
- </div>
788
- <div className="list-months">
789
- {MONTH_LIST.map((action: any, idx: number) =>
790
- dropdown.minYear && dropdown.minYear.toString() === calendarYear.toString() && minMonthIdx && minMonthIdx > idx ? (
791
- <a href="#" key={idx} className='is-disabled' onClick={event => { event.preventDefault() }}>{action.label}</a>
792
- ) : dropdown.maxYear && dropdown.maxYear.toString() === calendarYear.toString() && maxMonthIdx && maxMonthIdx < idx ? (
793
- <a href="#" key={idx} className='is-disabled' onClick={event => { event.preventDefault() }}>{action.label}</a>
794
- ) : (
795
- <a
796
- className={dateMonthlyPickerIsSelected(action.label) ? 'is-selected' : ''}
797
- href="#"
798
- key={idx}
799
- onClick={event => dateMonthlyPickerHandler(event, 'month-selection', action.value)}>{action.label}</a>
800
- )
801
- )}
802
- </div>
803
- </div>
804
- ) : dropdown.type === 'date-picker-cutoff' ? (
805
- <div className="popover em-popover-months">
806
- <div className="list-years">
807
- <button onClick={event => dateMonthlyPickerHandler(event, 'prev')} ><img src="/images/icons/icon-arrowleft-white.svg" alt="" /></button>
808
- <div>{calendarYear}</div>
809
- <button onClick={event => dateMonthlyPickerHandler(event, 'next')} ><img src="/images/icons/icon-arrowright-white.svg" alt="" /></button>
810
- </div>
811
- <div className="list-months">
812
- {
813
- dropdown.cutoffDates !== null && dropdown.cutoffDates.length > 0 ? (
814
- dropdown.cutoffDates.map((action: any, idx: number) => {
815
- let classSelect;
816
- if (JSON.stringify(action.label) === JSON.stringify(dropdown.cutoffValue.label)) {
817
- if (dropdown.currentYear === calendarYear) {
818
- classSelect = 'is-selected';
819
- } else {
820
- classSelect = '';
821
- }
822
- // classSelect = 'is-selected';
823
- } else {
824
- classSelect = '';
825
- }
826
- return <a
827
- className={classSelect}
828
- href="#"
829
- key={idx}
830
- onClick={event => dateCutoffPickerHandler(event, action.label, action.value)}>{action.label}</a>
831
- }
832
- )
833
- ) : null
834
- }
835
- </div>
836
- </div>
837
- ) : null
838
- }
839
- </Popover>
840
- </div>
841
- </Fragment>
842
- ) : null
843
- }
844
- {
845
- pagination && pagination.show && pagination.show.constructor === Boolean ? (
846
- <Fragment>
847
- {
848
- !pagination.hideSummary || pagination.hideSummary === false ? (
849
- <Fragment>
850
- <div className="em-dropdown">
851
- <a className="pagination-summary" href="#" id="pagination" onClick={event => popoverRequestHandler(event, 'pagination-summary')} data-testid="menubar-pagination">
852
- {
853
- (pagination.counter > 0 ? (((pagination.page - 1) * pagination.perPage) + 1) : 0)
854
- + ' - ' +
855
- (
856
- pagination.page * pagination.perPage > pagination.total ?
857
- (pagination.total ? pagination.total : pagination.counter) :
858
- pagination.page * pagination.perPage
859
- )
860
- } of {pagination.total ? pagination.total : 0}
861
- </a>
862
- <Popover
863
- id="paginationSummaryPopover"
864
- className={Boolean(dropdownPopover) ? 'open-popover' : ''}
865
- open={Boolean(paginationSummaryPopover)}
866
- onClick={event => popoverRequestHandler(event, 'pagination-summary')}
867
-
868
- >
869
- {
870
- <div className="popover em-popover-input">
871
- <div className={'e-field field field-input' + (paginationSummaryFormError.indexOf('perPageTemporaryValue') >= 0 ? ' is-invalid' : '')}>
872
- <label className='e-input-label'>SHOW</label>
873
- <Input
874
- config={{
875
- id: 'paginationPerPage',
876
- type: 'select',
877
- placeholder: '-',
878
- value: perPageTemporaryValue,
879
- options: PAGE_OPTION
880
- }}
881
- onChanged={(event:any) => handleChangeFormValue(event, 'show-per-page')}
882
- />
883
- </div>
884
- <div className={'e-field field field-input' + (paginationSummaryFormError.indexOf('goToPage') >= 0 ? ' is-invalid' : '')}>
885
- <label className='e-input-label'>GO TO PAGE</label>
886
- <div className="e-input">
887
- <Input
888
- config={{
889
- id: 'goToPage',
890
- type: 'number',
891
- value: goToPage,
892
- placeholder: '-',
893
- maxLength: 5,
894
- min: '1',
895
- }}
896
- onChanged={(event:any) => handleChangeFormValue(event, 'go-to-page')}
897
- />
898
- </div>
899
- </div>
900
- <button className="button-check" onClick={(event) => paginationRequestHandler(event, 'submit')}>
901
- {SVG_CHECK}
902
- </button>
903
- </div>
904
- }
905
- </Popover>
906
- </div>
907
- </Fragment>
908
- ) : null
909
- }
910
- <a
911
- className={(pagination.page * pagination.perPage) > pagination.perPage ? 'belt-prev' : 'belt-prev is-disabled'}
912
- href="#"
913
- {...(((pagination.page * pagination.perPage) > pagination.perPage) ? { onClick: (event:any) => paginationRequestHandler(event, 'prev') } : { onClick: event => { event.preventDefault() } })}
914
- >
915
- <div className="belt-icon">{SVG_ARROWLEFT}</div>
916
- </a>
917
- <a
918
- className={pagination.total <= (pagination.page * pagination.perPage) ? 'belt-next is-disabled' : 'belt-next'}
919
- href="#"
920
- {...((pagination.total <= (pagination.page * pagination.perPage)) ? { onClick: event => { event.preventDefault() } } : { onClick: (event:any) => paginationRequestHandler(event, 'next') })}
921
- >
922
- <div className="belt-icon">{SVG_ARROWRIGHT}</div>
923
- </a>
924
- </Fragment>
925
- ) : null
926
- }
927
- {
928
- // Pivot Configuration
929
- pivot && pivot.show ? (
930
- <Fragment>
931
- <div className="em-dropdown">
932
- <a id="months" className="belt-dropdown " href="#" onClick={event => popoverRequestHandler(event, 'pivot')} data-testid="menubar-pivot">
933
- <span>
934
- {
935
- pivot.selected && pivot.actions &&
936
- pivot.actions.constructor === Array && pivot.actions.length > 0 ? (
937
- pivot.actions.filter((item: any) => (item.value === pivot.selected)).length > 0 ? (
938
- pivot.actions.filter((item: any) => (item.value === pivot.selected))[0].label
939
- ) : 'None'
940
- ) : 'None'
941
- }
942
- </span>
943
- <div className="icon-arrowdown">{SVG_ARROWDOWN}</div>
944
- </a>
945
- <Popover
946
- id="pivotPopover"
947
- className={Boolean(dropdownPopover) ? 'open-popover' : ''}
948
- open={Boolean(pivotPopover)}
949
- onClick={event => popoverRequestHandler(event, 'pivot')}
950
-
951
- >
952
- {
953
- pivot.actions && pivot.actions.constructor === Array && pivot.actions.length > 0 ? (
954
- <div className="popover em-popover-list">
955
- {pivot.actions.map((pvt: any, idx: number) =>
956
- <a href="#" key={idx} onClick={event => actionRequestHandler(event, 'pivot', pvt.value)}>{pvt.label}</a>
957
- )}
958
- </div>
959
- ) : null
960
- }
961
- </Popover>
962
- </div>
963
- </Fragment>
964
- ) : null
965
- }
966
- {
967
- // Close Icon Configuration
968
- config && config.iconType && ((config.iconType.constructor === Array && config.iconType.length > 0 && config.iconType.indexOf("close") >= 0) || (config.iconType === 'close')) ? (
969
- <a className="modal-close" href="#" onClick={event => actionRequestHandler(event, 'icon', 'close')} date-testid="menubar-close">
970
- {SVG_CLOSE_GRAY}
971
- </a>
972
- ) : null
973
- }
974
- {
975
- toggle && toggle.show && toggle.buttons && toggle.buttons.constructor === Array ? (
976
- <Fragment>
977
- <div className="belt-toggle">
978
- {
979
- toggle.buttons.map((item: any, idx: number) => (
980
- <a className={"belt-icon icon-calendar " + (item.value === toggle.value ? ' is-active' : '')} key={'toggle-' + idx} href="#"
981
- onClick={event => toggleSelectionHandler(event, item.value)}>
982
- {
983
- item.value === toggle.value ? item.selectedIconDisplay : item.icon
984
- }
985
- </a>
986
- ))
987
- }
988
- </div>
989
- </Fragment>
990
- ) : null
991
- }
992
- </div>
993
- </div>
994
- {/* Body */}
995
- {/* <div> */}
996
- {
997
- // Search Configuration
998
- search && search.show && search.show.constructor === Boolean ? (
999
- <div className="field em-card-search">
1000
- <div className="e-input">
1001
- <Input
1002
- config={{
1003
- id: 'search',
1004
- type: 'text',
1005
- placeholder: search.placeholder ? search.placeholder : 'Search',
1006
- maxLength: 30,
1007
- readOnly: false,
1008
- disabled: false,
1009
- value: searchTemporaryValue ? searchTemporaryValue : ''
1010
- }}
1011
- onChanged={(event:any) => handleChangeFormValue(event, 'search')}
1012
- keyPressed={(event:any) => actionRequestHandler(event, 'search', 'search')}
1013
- />
1014
- </div>
1015
- </div>
1016
- ) : null
1017
- }
1018
- {children}
1019
- {/* </div> */}
1020
- {/* Footer */}
1021
- <div className="em-card-footer">
1022
- {
1023
- buttonFooter && buttonFooter.show && buttonFooter.actions.length > 0 &&
1024
- <div className={buttonFooter.className}>
1025
- {
1026
- buttonFooter.actions.map((btn: any, idx: number) => (
1027
- btn.show &&
1028
- <a className={'button ' + btn.className}
1029
- href="#" key={idx}
1030
- {...(btn.disabled === true ? { onClick: event => { event.preventDefault() } } : { onClick: event => actionRequestHandler(event, 'button', btn.action) })}
1031
- data-testid={btn.id && btn.id.constructor === String ? btn.id : 'default-button-footer'}
1032
- >
1033
- <div className="icon">{btn.icon ? btn.icon : ''}</div>
1034
- <span data-testid={'button-action-' + btn.action}>{btn.label ? btn.label : ''}</span>
1035
- </a>
1036
- ))
1037
- }
1038
- </div>
1039
-
1040
- }
1041
- {
1042
-
1043
-
1044
- // UndoButton Actions Configuration
1045
- undoButton && undoButton.show && undoButton.isFooter &&
1046
- undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (
1047
- undoButton.actions.map((btn: any, idx: number) => {
1048
- return seconds > 0 || (btn.timer !== undefined) ? (
1049
-
1050
- <a
1051
- className={btn.class ? btn.class : 'button ' + ' ' + (idx === 0 ? 'disabled' : 'outline button-undo') + (btn.disabled === true ? ' is-disabled button-undo' : '')}
1052
- href="#"
1053
- data-testid={`undo-button-${btn.action}`}
1054
- key={idx}
1055
- {...(btn.disabled === true ? { onClick: event => { event.preventDefault() } } : { onClick: event => actionRequestHandler(event, 'undo-button', btn.action) })}>
1056
- <div className="belt-icon">{btn.icon ? btn.icon : ''}</div>
1057
- <span data-testid="undo-button-text">{btn.label ? (
1058
- `${btn.label} ${btn.timer !== undefined && btn.timer.constructor === Number && seconds > 0 ? (
1059
- `in ${seconds}s`
1060
- ) : ''}`
1061
- ) : ''}</span>
1062
- </a>
1063
- ) : null
1064
- })
1065
- ) : null
1066
- }
1067
- </div>
1068
- </div>
1069
- )
1070
- }
1071
-
1072
- export default MenuBar;