empower-container 0.1.13 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/README.md +2 -2
  2. package/{src/main → dist/cjs}/DatetimeFormatter.d.ts +0 -0
  3. package/{src/main → dist/cjs}/DatetimeFormatter.js +0 -0
  4. package/{src/main → dist/cjs}/Information.d.ts +0 -0
  5. package/dist/cjs/Information.js +63 -0
  6. package/{src/main → dist/cjs}/MenuBar.d.ts +0 -0
  7. package/dist/cjs/MenuBar.js +537 -0
  8. package/{src/main → dist/cjs}/Modal.d.ts +0 -0
  9. package/dist/cjs/Modal.js +42 -0
  10. package/{src/main → dist/cjs}/assets/Asset.d.ts +0 -0
  11. package/dist/cjs/assets/Asset.js +30 -0
  12. package/{src/main → dist/cjs}/constants/Constant.d.ts +0 -0
  13. package/dist/cjs/constants/Constant.js +35 -0
  14. package/{src/main → dist/cjs}/index.d.ts +0 -0
  15. package/{src/main → dist/cjs}/index.js +0 -0
  16. package/{src/main → dist/cjs}/inputs/Input.d.ts +0 -0
  17. package/{src/main → dist/cjs}/inputs/Input.js +7 -36
  18. package/{src/main → dist/cjs}/inputs/InputSelectionHandler.d.ts +0 -0
  19. package/{src/main → dist/cjs}/inputs/InputSelectionHandler.js +3 -3
  20. package/{src/main → dist/cjs}/inputs/Select.d.ts +0 -0
  21. package/{src/main → dist/cjs}/inputs/Select.js +11 -64
  22. package/dist/esm/DatetimeFormatter.d.ts +3 -0
  23. package/{src/main/DatetimeFormatter.tsx → dist/esm/DatetimeFormatter.js} +132 -139
  24. package/dist/esm/Information.d.ts +10 -0
  25. package/dist/esm/Information.js +38 -0
  26. package/dist/esm/MenuBar.d.ts +24 -0
  27. package/dist/esm/MenuBar.js +532 -0
  28. package/dist/esm/Modal.d.ts +33 -0
  29. package/dist/esm/Modal.js +37 -0
  30. package/dist/esm/assets/Asset.d.ts +16 -0
  31. package/dist/esm/assets/Asset.js +27 -0
  32. package/dist/esm/constants/Constant.d.ts +15 -0
  33. package/{src/main → dist/esm}/constants/Constant.js +9 -21
  34. package/{src/main/index.tsx → dist/esm/index.d.ts} +1 -3
  35. package/dist/esm/index.js +3 -0
  36. package/dist/esm/inputs/Input.d.ts +25 -0
  37. package/dist/esm/inputs/Input.js +104 -0
  38. package/dist/esm/inputs/InputSelectionHandler.d.ts +3 -0
  39. package/dist/esm/inputs/InputSelectionHandler.js +31 -0
  40. package/dist/esm/inputs/Select.d.ts +28 -0
  41. package/dist/esm/inputs/Select.js +399 -0
  42. package/{src → dist}/scss/components/_modal.scss +0 -0
  43. package/{src → dist}/scss/elements/_button.scss +0 -0
  44. package/{src → dist}/scss/elements/_index.scss +0 -0
  45. package/{src → dist}/scss/elements/_popover.scss +0 -0
  46. package/{src → dist}/scss/foundation/_colors.scss +0 -0
  47. package/{src → dist}/scss/foundation/_mixins.scss +0 -0
  48. package/{src → dist}/scss/foundation/_normalize.scss +0 -0
  49. package/{src → dist}/scss/foundation/_settings.scss +0 -0
  50. package/{src → dist}/scss/foundation/_typography.scss +0 -0
  51. package/{src → dist}/scss/library/_information.scss +0 -0
  52. package/{src → dist}/scss/library/_input.scss +0 -0
  53. package/{src → dist}/scss/library/_menubar.scss +0 -0
  54. package/{src → dist}/scss/library/_select.scss +0 -0
  55. package/{src → dist}/scss/style.scss +0 -0
  56. package/package.json +2 -3
  57. package/public/favicon.ico +0 -0
  58. package/public/index.html +0 -43
  59. package/public/logo192.png +0 -0
  60. package/public/logo512.png +0 -0
  61. package/public/manifest.json +0 -25
  62. package/public/robots.txt +0 -3
  63. package/src/index.tsx +0 -15
  64. package/src/main/Information.js +0 -65
  65. package/src/main/Information.tsx +0 -112
  66. package/src/main/MenuBar.js +0 -651
  67. package/src/main/MenuBar.tsx +0 -1074
  68. package/src/main/Modal.js +0 -24
  69. package/src/main/Modal.tsx +0 -83
  70. package/src/main/assets/Asset.js +0 -49
  71. package/src/main/assets/Asset.tsx +0 -81
  72. package/src/main/assets/icons/icon-check-white-sm.svg +0 -3
  73. package/src/main/assets/images/icon-arrowdown-graydark.svg +0 -3
  74. package/src/main/assets/images/icon-arrowleft-graydark.svg +0 -3
  75. package/src/main/assets/images/icon-arrowright-graydark.svg +0 -3
  76. package/src/main/assets/images/icon-arrowup-graydark.svg +0 -3
  77. package/src/main/assets/images/icon-check-graydark.svg +0 -3
  78. package/src/main/inputs/Input.tsx +0 -193
  79. package/src/main/inputs/InputSelectionHandler.tsx +0 -21
  80. package/src/main/inputs/Select.tsx +0 -654
  81. package/src/main/tsconfig.common.json +0 -34
  82. package/src/main/tsconfig.json +0 -35
  83. package/src/sample/App.css +0 -38
  84. package/src/sample/App.d.ts +0 -3
  85. package/src/sample/App.js +0 -13
  86. package/src/sample/App.test.d.ts +0 -1
  87. package/src/sample/App.test.js +0 -13
  88. package/src/sample/App.test.tsx +0 -9
  89. package/src/sample/App.tsx +0 -15
  90. package/src/sample/TestMenuBar.d.ts +0 -3
  91. package/src/sample/TestMenuBar.js +0 -529
  92. package/src/sample/TestMenuBar.tsx +0 -380
  93. package/src/sample/react-app-env.d.ts +0 -1
  94. package/src/sample/reportWebVitals.d.ts +0 -3
  95. package/src/sample/reportWebVitals.js +0 -38
  96. package/src/sample/reportWebVitals.ts +0 -15
  97. package/src/sample/setupTests.d.ts +0 -1
  98. package/src/sample/setupTests.js +0 -7
  99. package/src/sample/setupTests.ts +0 -5
  100. package/src/sample/tsconfig.json +0 -36
@@ -0,0 +1,532 @@
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: [mainButton && mainButton.show ? (mainButton.actions && mainButton.actions.constructor === Array && mainButton.actions.length > 1 ? (_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) {
455
+ return _jsx("a", __assign({ href: "#", onClick: function (event) { return actionRequestHandler(event, 'main-button', btn.action); } }, { children: btn.label }), idx);
456
+ }) })) }))] })) })) : mainButton.actions && mainButton.actions.constructor === Array && mainButton.actions.length === 1 ? (mainButton.actions.map(function (btn, idx) {
457
+ 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));
458
+ })) : null) : null,
459
+ // Button Actions Configuration
460
+ button && button.show && button.show.constructor === Boolean &&
461
+ button.actions && button.actions.constructor === Array && button.actions.length > 0 ? (button.actions.map(function (btn, idx) {
462
+ 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));
463
+ })) : null,
464
+ // UndoButton Actions Configuration
465
+ undoButton && undoButton.show && !undoButton.isFooter &&
466
+ undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (undoButton.actions.map(function (btn, idx) {
467
+ 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;
468
+ })) : null] }))] })), _jsxs("div", __assign({ className: "em-belt-right" }, { children: [
469
+ // Dropdown Actions Configuration
470
+ 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) {
471
+ return _jsx("a", __assign({ href: "#", onClick: function (event) { return actionRequestHandler(event, 'dropdown', drpdwn.value); } }, { children: drpdwn.label }), idx);
472
+ }) }))) : 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) {
473
+ 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));
474
+ }) }))] }))) : 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) {
475
+ var classSelect;
476
+ if (JSON.stringify(action.label) === JSON.stringify(dropdown.cutoffValue.label)) {
477
+ if (dropdown.currentYear === calendarYear) {
478
+ classSelect = 'is-selected';
479
+ }
480
+ else {
481
+ classSelect = '';
482
+ }
483
+ // classSelect = 'is-selected';
484
+ }
485
+ else {
486
+ classSelect = '';
487
+ }
488
+ return _jsx("a", __assign({ className: classSelect, href: "#", onClick: function (event) { return dateCutoffPickerHandler(event, action.label, action.value); } }, { children: action.label }), idx);
489
+ })) : 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)
490
+ + ' - ' +
491
+ (pagination.page * pagination.perPage > pagination.total ?
492
+ (pagination.total ? pagination.total : pagination.counter) :
493
+ 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: {
494
+ id: 'paginationPerPage',
495
+ type: 'select',
496
+ placeholder: '-',
497
+ value: perPageTemporaryValue,
498
+ options: PAGE_OPTION
499
+ }, 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: {
500
+ id: 'goToPage',
501
+ type: 'number',
502
+ value: goToPage,
503
+ placeholder: '-',
504
+ maxLength: 5,
505
+ min: '1',
506
+ }, 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,
507
+ // Pivot Configuration
508
+ 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 &&
509
+ 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) {
510
+ return _jsx("a", __assign({ href: "#", onClick: function (event) { return actionRequestHandler(event, 'pivot', pvt.value); } }, { children: pvt.label }), idx);
511
+ }) }))) : null }))] })) })) : null,
512
+ // Close Icon Configuration
513
+ 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] }))] })),
514
+ // Search Configuration
515
+ 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: {
516
+ id: 'search',
517
+ type: 'text',
518
+ placeholder: search.placeholder ? search.placeholder : 'Search',
519
+ maxLength: 30,
520
+ readOnly: false,
521
+ disabled: false,
522
+ value: searchTemporaryValue ? searchTemporaryValue : ''
523
+ }, 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 &&
524
+ _jsx("div", __assign({ className: buttonFooter.className }, { children: buttonFooter.actions.map(function (btn, idx) { return (btn.show &&
525
+ _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)); }) })),
526
+ // UndoButton Actions Configuration
527
+ undoButton && undoButton.show && undoButton.isFooter &&
528
+ undoButton.actions && undoButton.actions.constructor === Array && undoButton.actions.length > 0 ? (undoButton.actions.map(function (btn, idx) {
529
+ 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;
530
+ })) : null] }))] })));
531
+ };
532
+ export default MenuBar;
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ import '../scss/style.scss';
3
+ interface IModalProps {
4
+ id?: string;
5
+ show: boolean;
6
+ hideMenuBar?: boolean;
7
+ config: {
8
+ title: string;
9
+ icon: any;
10
+ showInfo: boolean;
11
+ iconType: Array<string>;
12
+ modalSize: string;
13
+ };
14
+ getActions: any;
15
+ children?: any;
16
+ button?: {
17
+ show: boolean;
18
+ actions?: Array<object>;
19
+ };
20
+ dropdown?: any;
21
+ search?: any;
22
+ pagination?: any;
23
+ pivot?: any;
24
+ check?: any;
25
+ toggle?: any;
26
+ mainButton?: any;
27
+ buttonFooter?: any;
28
+ undoButton?: any;
29
+ info?: any;
30
+ customClass?: string;
31
+ }
32
+ declare const Modal: React.FunctionComponent<IModalProps>;
33
+ export default Modal;
@@ -0,0 +1,37 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import ReactDOM from "react-dom";
14
+ import MenuBar from "./MenuBar";
15
+ import '../scss/style.scss';
16
+ var Modal = function (_a) {
17
+ var id = _a.id, show = _a.show, hideMenuBar = _a.hideMenuBar, config = _a.config, getActions = _a.getActions, children = _a.children, button = _a.button, dropdown = _a.dropdown, search = _a.search, pagination = _a.pagination, pivot = _a.pivot, check = _a.check, toggle = _a.toggle, undoButton = _a.undoButton, mainButton = _a.mainButton, buttonFooter = _a.buttonFooter, info = _a.info, customClass = _a.customClass;
18
+ var sendActions = function (actions, data) {
19
+ returnValues(actions, data);
20
+ };
21
+ var returnValues = function (action, data, addedParam) {
22
+ if (addedParam === void 0) { addedParam = null; }
23
+ return getActions ? getActions(action, data, addedParam) : false;
24
+ };
25
+ var x = document.getElementsByTagName("BODY")[0];
26
+ var dvId = '';
27
+ if (x.children) {
28
+ Array.from(x.children).forEach(function (el) {
29
+ if (el.constructor == HTMLDivElement) {
30
+ dvId = el.id;
31
+ return;
32
+ }
33
+ });
34
+ }
35
+ return (show ? ReactDOM.createPortal(_jsx("div", __assign({ className: "em-modal " + customClass }, { children: _jsx("div", __assign({ className: "em-modal-container", "data-testid": id ? id : 'default-modal-test' }, { children: _jsx("div", __assign({ className: "em-card card-modal modal-".concat(config.modalSize ? config.modalSize : 'md') }, { children: !hideMenuBar ? (_jsx(MenuBar, __assign({ config: config, button: button, pagination: pagination, pivot: pivot, dropdown: dropdown, search: search, toggle: toggle, undoButton: undoButton, buttonFooter: buttonFooter, check: check, info: info, getActions: function (actions, data) { return sendActions(actions, data); } }, { children: _jsx("div", __assign({ className: "em-card-content" }, { children: children })) }))) : _jsx("div", __assign({ className: "em-card-content card-content" }, { children: children })) })) })) })), document.getElementById(dvId)) : null);
36
+ };
37
+ export default Modal;