linear-react-components-ui 1.1.18-beta.16 → 1.1.18-beta.18

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 (55) hide show
  1. package/.eslintcache +1 -1
  2. package/lib/assets/styles/calendar.scss +64 -30
  3. package/lib/assets/styles/datepicker.scss +26 -6
  4. package/lib/assets/styles/periodpicker.scss +60 -20
  5. package/lib/assets/styles/sidenav.scss +1 -1
  6. package/lib/assets/styles/tabs.scss +32 -15
  7. package/lib/calendar/DangerCalendar.d.ts +1 -0
  8. package/lib/calendar/InfoCalendar.d.ts +1 -0
  9. package/lib/calendar/PrimaryCalendar.d.ts +1 -0
  10. package/lib/calendar/SuccessCalendar.d.ts +1 -0
  11. package/lib/calendar/WarningCalendar.d.ts +1 -0
  12. package/lib/calendar/base/Day.d.ts +1 -0
  13. package/lib/calendar/base/Day.js +6 -2
  14. package/lib/calendar/base/Month.d.ts +2 -1
  15. package/lib/calendar/base/Month.js +2 -0
  16. package/lib/calendar/base/Week.d.ts +1 -0
  17. package/lib/calendar/base/index.d.ts +1 -0
  18. package/lib/calendar/base/index.js +63 -13
  19. package/lib/calendar/index.d.ts +1 -0
  20. package/lib/calendar/types.d.ts +5 -0
  21. package/lib/dialog/base/Content.js +5 -4
  22. package/lib/dialog/base/Header.js +0 -1
  23. package/lib/dialog/base/index.js +27 -3
  24. package/lib/drawer/Drawer.js +1 -1
  25. package/lib/inputs/date/Dialog.js +5 -4
  26. package/lib/inputs/date/Dropdown.js +15 -7
  27. package/lib/inputs/date/helpers.d.ts +1 -11
  28. package/lib/inputs/date/helpers.js +1 -11
  29. package/lib/inputs/date/index.js +138 -100
  30. package/lib/inputs/date/types.d.ts +7 -6
  31. package/lib/inputs/period/Dialog.d.ts +1 -1
  32. package/lib/inputs/period/Dialog.js +5 -3
  33. package/lib/inputs/period/Dropdown.js +19 -8
  34. package/lib/inputs/period/PeriodList.js +3 -12
  35. package/lib/inputs/period/index.js +238 -82
  36. package/lib/inputs/period/types.d.ts +10 -8
  37. package/lib/inputs/select/ActionButtons.js +3 -2
  38. package/lib/inputs/select/multiple/index.js +10 -4
  39. package/lib/inputs/select/simple/index.js +10 -4
  40. package/lib/inputs/select/types.d.ts +4 -0
  41. package/lib/inputs/types.d.ts +1 -0
  42. package/lib/list/index.js +2 -2
  43. package/lib/tabs/DropdownTabs.js +21 -7
  44. package/lib/tabs/context.d.ts +1 -1
  45. package/lib/tabs/context.js +3 -3
  46. package/lib/tabs/types.d.ts +2 -1
  47. package/lib/toolbar/types.d.ts +2 -1
  48. package/package.json +1 -1
  49. package/lib/inputs/mask/imaskHOC.js +0 -203
  50. package/lib/menus/sidenav/popup_menu_help/index.js +0 -85
  51. package/lib/tabs/DropdownItems.js +0 -62
  52. package/lib/tabs/MenuItems.js +0 -70
  53. package/lib/treeview_old/Header.js +0 -29
  54. package/lib/treeview_old/Node.js +0 -68
  55. package/lib/treeview_old/index.js +0 -43
@@ -6,23 +6,34 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _reactDom = _interopRequireDefault(require("react-dom"));
9
- var _helper = _interopRequireDefault(require("./helper"));
10
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const body = document.getElementsByTagName('body')[0];
10
+ const CALENDAR_MIN_WIDTH = 250;
12
11
  const Dropdown = props => {
12
+ const {
13
+ children,
14
+ dropdownRef,
15
+ containerRef,
16
+ inputDimensions
17
+ } = props;
13
18
  const elementRef = (0, _react.useRef)(document.createElement('div'));
19
+ const width = inputDimensions && inputDimensions.width || CALENDAR_MIN_WIDTH;
14
20
  (0, _react.useEffect)(() => {
21
+ var _containerRef$current;
15
22
  elementRef.current.className = 'datepicker-component';
16
- elementRef.current.setAttribute('style', (0, _helper.default)(props));
17
- body.appendChild(elementRef.current);
18
- props.dropdownRef(elementRef.current);
23
+ elementRef.current.style.width = String(width).concat('px');
24
+ elementRef.current.style.top = String(inputDimensions === null || inputDimensions === void 0 ? void 0 : inputDimensions.bottom).concat('px');
25
+ (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.appendChild(elementRef.current);
26
+ dropdownRef(elementRef.current);
19
27
  return () => {
20
- body.removeChild(elementRef.current);
28
+ var _containerRef$current2;
29
+ (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.removeChild(elementRef.current);
21
30
  };
22
31
  }, []);
23
32
  (0, _react.useEffect)(() => {
24
- elementRef.current.setAttribute('style', (0, _helper.default)(props));
33
+ var _props$inputDimension;
34
+ elementRef.current.style.width = String(width).concat('px');
35
+ elementRef.current.style.top = String((_props$inputDimension = props.inputDimensions) === null || _props$inputDimension === void 0 ? void 0 : _props$inputDimension.bottom).concat('px');
25
36
  }, [props]);
26
- return /*#__PURE__*/_reactDom.default.createPortal(props.children, elementRef.current);
37
+ return /*#__PURE__*/_reactDom.default.createPortal(children, elementRef.current);
27
38
  };
28
39
  var _default = exports.default = Dropdown;
@@ -38,24 +38,15 @@ const PeriodList = _ref => {
38
38
  className: "dropdown-period"
39
39
  }, periodOptions.map(item => {
40
40
  const itemSelected = selected === item.id;
41
- return /*#__PURE__*/_react.default.createElement("div", {
42
- role: "button",
41
+ return /*#__PURE__*/_react.default.createElement("button", {
42
+ key: String('item-').concat(item.id),
43
43
  tabIndex: -1,
44
- onKeyDown: () => {},
45
- key: "item-".concat(item.id),
46
44
  className: (0, _helper.getDropdownItemCssClass)(itemSelected),
47
45
  onClick: () => {
48
46
  const dates = item.id !== 'custom' ? (0, _helper.CalcDatesByPeriod)(item.id) : null;
49
47
  handleOnSelect(item.id, dates);
50
48
  }
51
- }, /*#__PURE__*/_react.default.createElement("span", {
52
- role: "button",
53
- className: "menubutton",
54
- tabIndex: -1,
55
- onKeyPress: () => {}
56
- }, /*#__PURE__*/_react.default.createElement("span", {
57
- className: "label"
58
- }, item.label)));
49
+ }, item.label);
59
50
  }));
60
51
  };
61
52
  var _default = exports.default = PeriodList;
@@ -14,6 +14,7 @@ var _buttons = _interopRequireDefault(require("../../buttons"));
14
14
  var _icons = _interopRequireDefault(require("../../icons"));
15
15
  var _Dialog = _interopRequireDefault(require("./Dialog"));
16
16
  var _hint = _interopRequireDefault(require("../../hint"));
17
+ var _gridlayout = _interopRequireDefault(require("../../gridlayout"));
17
18
  var helperBase = _interopRequireWildcard(require("../base/helpers"));
18
19
  require("../../assets/styles/periodpicker.scss");
19
20
  var _errorMessage = require("../errorMessage");
@@ -36,8 +37,11 @@ const PeriodPicker = props => {
36
37
  width: '350px',
37
38
  height: '350px'
38
39
  },
39
- hint
40
+ hint,
41
+ gridLayout
40
42
  } = props;
43
+ const idValueInitial = (0, _react.useId)();
44
+ const idValueFinal = (0, _react.useId)();
41
45
  const [valueInitial, setValueInitial] = (0, _react.useState)(props.value && (0, _moment.default)(props.value.initial, 'DD/MM/YYYY'));
42
46
  const [valueFinal, setValueFinal] = (0, _react.useState)(props.value && (0, _moment.default)(props.value.final, 'DD/MM/YYYY'));
43
47
  const [valuePeriodSelection, setValuePeriodSelection] = (0, _react.useState)('week');
@@ -46,53 +50,128 @@ const PeriodPicker = props => {
46
50
  const [showPeriodSelection, setShowPeriodSelection] = (0, _react.useState)(false);
47
51
  const [inputDimensions, setInputDimensions] = (0, _react.useState)();
48
52
  const [onDenied, setOnDenied] = (0, _react.useState)();
53
+ const [currentTypeDate, setCurrentTypeDate] = (0, _react.useState)('valueInitial');
49
54
  const wrapperBaseInputPeriodRef = (0, _react.useRef)(null);
50
55
  const inputContainerRef = (0, _react.useRef)(null);
51
56
  const inputInitialRef = (0, _react.useRef)(null);
52
57
  const buttonOpenRef = (0, _react.useRef)(null);
58
+ const currentDateButtonRef = (0, _react.useRef)();
53
59
  const buttonSelectPeriodRef = (0, _react.useRef)(null);
54
60
  const dropdownCalendarContainer = (0, _react.useRef)(null);
55
61
  const dropdownPeriodContainer = (0, _react.useRef)(null);
56
62
  const inputFinalRef = (0, _react.useRef)(null);
63
+ const calendarContainerRef = (0, _react.useRef)(null);
57
64
  const onScreenResize = () => {
58
65
  var _inputContainerRef$cu;
59
- const inputDimensionsAux = inputContainerRef === null || inputContainerRef === void 0 ? void 0 : (_inputContainerRef$cu = inputContainerRef.current) === null || _inputContainerRef$cu === void 0 ? void 0 : _inputContainerRef$cu.getBoundingClientRect();
60
- setInputDimensions(inputDimensionsAux);
66
+ setInputDimensions(inputContainerRef === null || inputContainerRef === void 0 ? void 0 : (_inputContainerRef$cu = inputContainerRef.current) === null || _inputContainerRef$cu === void 0 ? void 0 : _inputContainerRef$cu.getBoundingClientRect());
61
67
  };
62
- const onClickOutside = event => {
63
- const {
64
- target
65
- } = event;
66
- if (target === inputContainerRef.current || target === inputInitialRef.current || target === inputFinalRef.current || target === buttonOpenRef.current || target === buttonSelectPeriodRef.current) {
67
- return;
68
+ const onBlurWithoutWrapper = event => {
69
+ var _wrapperBaseInputPeri;
70
+ const focusOnAnotherField = !((_wrapperBaseInputPeri = wrapperBaseInputPeriodRef.current) !== null && _wrapperBaseInputPeri !== void 0 && _wrapperBaseInputPeri.contains(event.relatedTarget));
71
+ if (!showCalendarInDialog && showCalendarValueInitial && focusOnAnotherField) {
72
+ setShowCalendarValueInitial(false);
68
73
  }
69
- if (dropdownCalendarContainer.current && dropdownCalendarContainer.current.contains(target)) {
70
- return;
74
+ if (!showCalendarInDialog && showCalendarValueFinal && focusOnAnotherField) {
75
+ setShowCalendarValueFinal(false);
71
76
  }
72
- if (dropdownPeriodContainer.current && dropdownPeriodContainer.current.contains(target)) return;
73
- setShowCalendarValueInitial(false);
74
- setShowCalendarValueFinal(false);
75
- setShowPeriodSelection(false);
76
77
  };
77
- const onCloseCalendarWithoutFocus = event => {
78
- if (event.key === 'Tab') {
79
- if (wrapperBaseInputPeriodRef.current && wrapperBaseInputPeriodRef.current.contains(document.activeElement) && document.activeElement instanceof HTMLInputElement) {
78
+ const onKeyDownPress = event => {
79
+ const {
80
+ target
81
+ } = event;
82
+ const targetElement = target;
83
+ if (calendarContainerRef.current && event && event.key && event.key === 'Escape') {
84
+ event.preventDefault();
85
+ targetElement.focus();
86
+ if (showCalendarValueInitial) {
87
+ if (targetElement.id !== 'valueInitial') {
88
+ var _inputInitialRef$curr;
89
+ (_inputInitialRef$curr = inputInitialRef.current) === null || _inputInitialRef$curr === void 0 ? void 0 : _inputInitialRef$curr.focus();
90
+ }
80
91
  setShowCalendarValueInitial(false);
92
+ }
93
+ if (showCalendarValueFinal) {
94
+ if (targetElement.id !== 'valueFinal') {
95
+ var _inputFinalRef$curren;
96
+ (_inputFinalRef$curren = inputFinalRef.current) === null || _inputFinalRef$curren === void 0 ? void 0 : _inputFinalRef$curren.focus();
97
+ }
81
98
  setShowCalendarValueFinal(false);
82
99
  }
100
+ if (showPeriodSelection) {
101
+ var _inputFinalRef$curren2;
102
+ setShowPeriodSelection(false);
103
+ (_inputFinalRef$curren2 = inputFinalRef.current) === null || _inputFinalRef$curren2 === void 0 ? void 0 : _inputFinalRef$curren2.focus();
104
+ setShowCalendarValueFinal(false);
105
+ }
106
+ }
107
+ if (calendarContainerRef.current && event && event.key && event.key === 'Tab') {
108
+ var _calendarContainerRef, _calendarContainerRef2;
109
+ const buttonForNavigateCalendar = (_calendarContainerRef = calendarContainerRef.current) === null || _calendarContainerRef === void 0 ? void 0 : _calendarContainerRef.getElementsByClassName('navbutton');
110
+ const datePicked = (_calendarContainerRef2 = calendarContainerRef.current) === null || _calendarContainerRef2 === void 0 ? void 0 : _calendarContainerRef2.getElementsByClassName('-selectedday');
111
+ const buttonDatePicked = datePicked[0].firstChild;
112
+ const buttonsForFocus = Array.from([...buttonForNavigateCalendar, buttonDatePicked]);
113
+ const firstElement = buttonsForFocus[0];
114
+ const lastElement = buttonsForFocus[buttonsForFocus.length - 1];
115
+ const calendarOpenedIsInitial = calendarContainerRef.current.id === 'valueInitial';
116
+ if (!event.shiftKey && showCalendarValueInitial && document.activeElement === inputInitialRef.current) {
117
+ event.preventDefault();
118
+ firstElement.focus();
119
+ }
120
+ if (event.shiftKey && calendarOpenedIsInitial && document.activeElement === firstElement) {
121
+ var _inputInitialRef$curr2;
122
+ event.preventDefault();
123
+ (_inputInitialRef$curr2 = inputInitialRef.current) === null || _inputInitialRef$curr2 === void 0 ? void 0 : _inputInitialRef$curr2.focus();
124
+ }
125
+ if (!event.shiftKey && calendarOpenedIsInitial && document.activeElement === lastElement) {
126
+ var _inputFinalRef$curren3;
127
+ event.preventDefault();
128
+ (_inputFinalRef$curren3 = inputFinalRef.current) === null || _inputFinalRef$curren3 === void 0 ? void 0 : _inputFinalRef$curren3.focus();
129
+ }
130
+ }
131
+ event.stopPropagation();
132
+ };
133
+ const keepPositionCalendarByScroll = () => {
134
+ var _inputContainerRef$cu2;
135
+ const inputDateDimensions = (_inputContainerRef$cu2 = inputContainerRef.current) === null || _inputContainerRef$cu2 === void 0 ? void 0 : _inputContainerRef$cu2.getBoundingClientRect();
136
+ const positionTop = inputDateDimensions && inputDateDimensions.bottom;
137
+ if (dropdownCalendarContainer && dropdownCalendarContainer.current && inputDateDimensions) {
138
+ dropdownCalendarContainer.current.style.top = String(positionTop).concat('px');
83
139
  }
84
140
  };
85
141
  (0, _react.useEffect)(() => {
142
+ var _document$getElementB;
86
143
  window.addEventListener('resize', onScreenResize);
87
- document.addEventListener('click', onClickOutside);
88
- document.addEventListener('keydown', onCloseCalendarWithoutFocus);
144
+ document.addEventListener('scroll', keepPositionCalendarByScroll);
145
+ (_document$getElementB = document.getElementById('modal-dialog-content')) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.addEventListener('scroll', keepPositionCalendarByScroll);
89
146
  if (inputContainerRef.current) onScreenResize();
147
+ if (inputInitialRef && inputInitialRef.current) inputInitialRef.current.id = idValueInitial;
148
+ if (inputFinalRef && inputFinalRef.current) inputFinalRef.current.id = idValueFinal;
90
149
  return () => {
150
+ var _document$getElementB2;
91
151
  window.removeEventListener('resize', onScreenResize);
92
- document.removeEventListener('click', onClickOutside);
93
- document.removeEventListener('keydown', onCloseCalendarWithoutFocus);
152
+ document.removeEventListener('scroll', keepPositionCalendarByScroll);
153
+ (_document$getElementB2 = document.getElementById('modal-dialog-content')) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.removeEventListener('scroll', keepPositionCalendarByScroll);
94
154
  };
95
155
  }, []);
156
+ (0, _react.useEffect)(() => {
157
+ document.addEventListener('keydown', onKeyDownPress);
158
+ return () => {
159
+ document.removeEventListener('keydown', onKeyDownPress);
160
+ };
161
+ }, [showCalendarValueFinal, showCalendarValueInitial, showPeriodSelection, calendarContainerRef.current]);
162
+ (0, _react.useEffect)(() => {
163
+ if (valueFinal && valueInitial && (0, _moment.default)(valueFinal).isBefore((0, _moment.default)(valueInitial))) {
164
+ setValueInitial(valueFinal);
165
+ setValueFinal(valueInitial);
166
+ } else if (props.onChange) {
167
+ const initial = valueInitial ? valueInitial.format('YYYY-MM-DD') : '';
168
+ const final = valueFinal ? valueFinal.format('YYYY-MM-DD') : '';
169
+ props.onChange(undefined, '', {
170
+ initial,
171
+ final
172
+ });
173
+ }
174
+ }, [valueInitial, valueFinal]);
96
175
  (0, _react.useEffect)(() => {
97
176
  if (props.value && !((0, _moment.default)(props.value.initial).isSame(valueInitial) || (0, _moment.default)(props.value.final).isSame(valueFinal))) {
98
177
  const {
@@ -113,17 +192,71 @@ const PeriodPicker = props => {
113
192
  }, [props.value]);
114
193
  const openCalendar = calendarName => {
115
194
  if (calendarName === 'valueInitial') {
195
+ setCurrentTypeDate('valueInitial');
116
196
  setShowCalendarValueFinal(false);
117
- setShowCalendarValueInitial(true);
118
- } else {
197
+ if (!showCalendarValueInitial) {
198
+ var _inputInitialRef$curr3;
199
+ (_inputInitialRef$curr3 = inputInitialRef.current) === null || _inputInitialRef$curr3 === void 0 ? void 0 : _inputInitialRef$curr3.focus();
200
+ if (showCalendarInDialog) {
201
+ setTimeout(() => {
202
+ var _currentDateButtonRef;
203
+ (_currentDateButtonRef = currentDateButtonRef.current) === null || _currentDateButtonRef === void 0 ? void 0 : _currentDateButtonRef.focus();
204
+ }, 100);
205
+ }
206
+ setShowCalendarValueInitial(true);
207
+ }
208
+ }
209
+ if (calendarName === 'valueFinal') {
210
+ setCurrentTypeDate('valueFinal');
119
211
  setShowCalendarValueInitial(false);
120
- setShowCalendarValueFinal(true);
212
+ if (!showCalendarValueFinal) {
213
+ var _inputFinalRef$curren4;
214
+ (_inputFinalRef$curren4 = inputFinalRef.current) === null || _inputFinalRef$curren4 === void 0 ? void 0 : _inputFinalRef$curren4.focus();
215
+ if (showCalendarInDialog) {
216
+ setTimeout(() => {
217
+ var _currentDateButtonRef2;
218
+ (_currentDateButtonRef2 = currentDateButtonRef.current) === null || _currentDateButtonRef2 === void 0 ? void 0 : _currentDateButtonRef2.focus();
219
+ }, 100);
220
+ }
221
+ setShowCalendarValueFinal(true);
222
+ }
121
223
  }
122
- setShowPeriodSelection(false);
123
224
  if (inputContainerRef.current) {
124
225
  setInputDimensions(inputContainerRef.current.getBoundingClientRect());
125
226
  }
126
227
  };
228
+ const closeCalendar = calendarName => {
229
+ if (calendarName === 'valueInitial') {
230
+ var _inputInitialRef$curr4;
231
+ (_inputInitialRef$curr4 = inputInitialRef.current) === null || _inputInitialRef$curr4 === void 0 ? void 0 : _inputInitialRef$curr4.focus();
232
+ }
233
+ if (calendarName === 'valueFinal') {
234
+ var _inputFinalRef$curren5;
235
+ (_inputFinalRef$curren5 = inputFinalRef.current) === null || _inputFinalRef$curren5 === void 0 ? void 0 : _inputFinalRef$curren5.focus();
236
+ }
237
+ setShowCalendarValueInitial(false);
238
+ setShowCalendarValueFinal(false);
239
+ };
240
+ const onCloseDateDialog = calendarName => {
241
+ setTimeout(() => {
242
+ if (calendarName === 'valueInitial') {
243
+ var _inputInitialRef$curr5;
244
+ (_inputInitialRef$curr5 = inputInitialRef.current) === null || _inputInitialRef$curr5 === void 0 ? void 0 : _inputInitialRef$curr5.focus();
245
+ setShowCalendarValueInitial(false);
246
+ }
247
+ if (calendarName === 'valueFinal') {
248
+ var _inputFinalRef$curren6;
249
+ (_inputFinalRef$curren6 = inputFinalRef.current) === null || _inputFinalRef$curren6 === void 0 ? void 0 : _inputFinalRef$curren6.focus();
250
+ setShowCalendarValueFinal(false);
251
+ }
252
+ if (calendarName === 'periodSelection') {
253
+ var _inputFinalRef$curren7;
254
+ setShowPeriodSelection(false);
255
+ (_inputFinalRef$curren7 = inputFinalRef.current) === null || _inputFinalRef$curren7 === void 0 ? void 0 : _inputFinalRef$curren7.focus();
256
+ setShowCalendarValueFinal(false);
257
+ }
258
+ }, 100);
259
+ };
127
260
  const onInputFocus = e => {
128
261
  const {
129
262
  name
@@ -159,12 +292,12 @@ const PeriodPicker = props => {
159
292
  }
160
293
  };
161
294
  const setValue = function (event, value) {
162
- var _inputInitialRef$curr, _inputFinalRef$curren;
295
+ var _inputInitialRef$curr6, _inputFinalRef$curren8;
163
296
  let shouldOpenDropdown = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
164
297
  const valueDateName = event ? event.target.name : '';
165
298
  const dateObj = (0, _moment.default)(value, 'DD/MM/YYYY');
166
- if (showCalendarValueInitial) (_inputInitialRef$curr = inputInitialRef.current) === null || _inputInitialRef$curr === void 0 ? void 0 : _inputInitialRef$curr.focus();
167
- if (showCalendarValueFinal) (_inputFinalRef$curren = inputFinalRef.current) === null || _inputFinalRef$curren === void 0 ? void 0 : _inputFinalRef$curren.focus();
299
+ if (showCalendarValueInitial) (_inputInitialRef$curr6 = inputInitialRef.current) === null || _inputInitialRef$curr6 === void 0 ? void 0 : _inputInitialRef$curr6.focus();
300
+ if (showCalendarValueFinal) (_inputFinalRef$curren8 = inputFinalRef.current) === null || _inputFinalRef$curren8 === void 0 ? void 0 : _inputFinalRef$curren8.focus();
168
301
  if (valueDateName === 'valueFinal' && valueInitial && dateObj.isBefore(valueInitial)) {
169
302
  setValueInitial(dateObj);
170
303
  setValueFinal(valueInitial);
@@ -193,8 +326,8 @@ const PeriodPicker = props => {
193
326
  });
194
327
  }
195
328
  if (valueDateName === 'valueInitial' && !valueFinal && shouldOpenDropdown) {
196
- var _inputFinalRef$curren2;
197
- (_inputFinalRef$curren2 = inputFinalRef.current) === null || _inputFinalRef$curren2 === void 0 ? void 0 : _inputFinalRef$curren2.focus();
329
+ var _inputFinalRef$curren9;
330
+ (_inputFinalRef$curren9 = inputFinalRef.current) === null || _inputFinalRef$curren9 === void 0 ? void 0 : _inputFinalRef$curren9.focus();
198
331
  setTimeout(() => setShowCalendarValueFinal(true), 100);
199
332
  }
200
333
  if (shouldCloseOnSelect) {
@@ -208,27 +341,29 @@ const PeriodPicker = props => {
208
341
  } = props;
209
342
  return disabled || onDenied && (onDenied.disabled || onDenied.hideContent);
210
343
  };
211
- const getButtonOpen = () => {
344
+ const getButtonOpen = (0, _react.useCallback)(() => {
212
345
  if (!showButtonOpen) return null;
213
346
  return /*#__PURE__*/_react.default.createElement(_buttons.default, {
214
347
  key: "button-open",
215
348
  boxShadow: false,
349
+ disabled: shouldDisable(),
350
+ customClass: "calendar-button",
216
351
  icon: /*#__PURE__*/_react.default.createElement(_icons.default, {
217
352
  name: "calendar"
218
353
  }),
219
354
  onClick: () => {
220
- var _inputInitialRef$curr2;
221
- (_inputInitialRef$curr2 = inputInitialRef.current) === null || _inputInitialRef$curr2 === void 0 ? void 0 : _inputInitialRef$curr2.focus();
222
- openCalendar('valueInitial');
355
+ if (showCalendarValueFinal || showCalendarValueInitial) {
356
+ closeCalendar(currentTypeDate);
357
+ } else {
358
+ openCalendar(currentTypeDate);
359
+ }
223
360
  },
224
- customClass: "calendar-button",
225
361
  tabIndex: -1,
226
362
  targetRef: ref => {
227
363
  buttonOpenRef.current = ref;
228
- },
229
- disabled: shouldDisable()
364
+ }
230
365
  });
231
- };
366
+ }, [showCalendarValueFinal, showCalendarValueInitial]);
232
367
  const getPeriodSelection = (valuePeriodSelectionAux, setPeriodDates) => /*#__PURE__*/_react.default.createElement(_PeriodList.default, {
233
368
  selected: valuePeriodSelectionAux,
234
369
  handleOnSelect: setPeriodDates
@@ -241,36 +376,46 @@ const PeriodPicker = props => {
241
376
  setInputDimensions(inputContainerRef.current.getBoundingClientRect());
242
377
  }
243
378
  };
244
- const getButtonSelectPeriod = () => /*#__PURE__*/_react.default.createElement(_buttons.default, {
245
- key: "button-select-period",
246
- boxShadow: false,
247
- icon: /*#__PURE__*/_react.default.createElement(_icons.default, {
248
- name: "more1"
249
- }),
250
- onBlur: () => setTimeout(() => setShowPeriodSelection(false), 100),
251
- onClick: () => openPeriodSelecion(),
252
- customClass: "calendar-button",
253
- tabIndex: -1,
254
- targetRef: ref => {
255
- buttonSelectPeriodRef.current = ref;
256
- },
257
- disabled: shouldDisable()
258
- });
379
+ const closePeriodSelection = () => {
380
+ var _inputFinalRef$curren10;
381
+ setShowPeriodSelection(false);
382
+ (_inputFinalRef$curren10 = inputFinalRef.current) === null || _inputFinalRef$curren10 === void 0 ? void 0 : _inputFinalRef$curren10.focus();
383
+ setShowCalendarValueFinal(false);
384
+ };
385
+ const getButtonSelectPeriod = (0, _react.useCallback)(() => {
386
+ return /*#__PURE__*/_react.default.createElement(_buttons.default, {
387
+ key: "button-select-period",
388
+ disabled: shouldDisable(),
389
+ tabIndex: -1,
390
+ customClass: "calendar-button",
391
+ icon: /*#__PURE__*/_react.default.createElement(_icons.default, {
392
+ name: "more1"
393
+ }),
394
+ onBlur: () => setTimeout(() => setShowPeriodSelection(false), 100),
395
+ onClick: () => !showPeriodSelection ? openPeriodSelecion() : closePeriodSelection(),
396
+ targetRef: ref => {
397
+ buttonSelectPeriodRef.current = ref;
398
+ }
399
+ });
400
+ }, [showPeriodSelection]);
259
401
  const getCalendar = (value, calendarColorStyleCalendar, valueDateName) => /*#__PURE__*/_react.default.createElement(_calendar.default, {
402
+ colorStyle: calendarColorStyleCalendar,
260
403
  currentDate: value !== undefined ? (0, _moment.default)(value) : (0, _moment.default)(),
261
- onDateChange: date => {
262
- setValue({
263
- target: {
264
- name: valueDateName
265
- }
266
- }, date);
404
+ calendarContainer: ref => {
405
+ calendarContainerRef.current = ref;
267
406
  },
268
- colorStyle: calendarColorStyleCalendar
407
+ onDateChange: date => setValue({
408
+ target: {
409
+ name: valueDateName
410
+ }
411
+ }, date),
412
+ currentDateButton: buttonElement => currentDateButtonRef.current = buttonElement
269
413
  });
270
414
  const setPeriodDates = (selected, dates) => {
415
+ var _inputFinalRef$curren11;
271
416
  if (selected === 'custom') {
272
- var _inputInitialRef$curr3;
273
- (_inputInitialRef$curr3 = inputInitialRef.current) === null || _inputInitialRef$curr3 === void 0 ? void 0 : _inputInitialRef$curr3.focus();
417
+ var _inputInitialRef$curr7;
418
+ (_inputInitialRef$curr7 = inputInitialRef.current) === null || _inputInitialRef$curr7 === void 0 ? void 0 : _inputInitialRef$curr7.focus();
274
419
  setValuePeriodSelection(selected);
275
420
  setShowPeriodSelection(false);
276
421
  return;
@@ -283,64 +428,69 @@ const PeriodPicker = props => {
283
428
  if (shouldCloseOnSelect) {
284
429
  setShowPeriodSelection(false);
285
430
  }
431
+ (_inputFinalRef$curren11 = inputFinalRef.current) === null || _inputFinalRef$curren11 === void 0 ? void 0 : _inputFinalRef$curren11.focus();
432
+ setShowCalendarValueFinal(false);
286
433
  };
287
- const getWrapperComponentCalendarValueInitial = () => {
434
+ const getCalendarInitial = () => {
288
435
  if (onDenied && onDenied.readOnly) return null;
436
+ if (calendarContainerRef && calendarContainerRef.current) calendarContainerRef.current.id = 'valueInitial';
289
437
  if (showCalendarInDialog) {
290
438
  return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
439
+ handlerClose: () => onCloseDateDialog('valueInitial'),
291
440
  dialogSize: dialogSize,
292
441
  onOpenChange: setShowCalendarValueInitial
293
442
  }, getCalendar(valueInitial, calendarColorStyle, 'valueInitial'));
294
443
  }
295
444
  return /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
296
- targetElement: inputContainerRef.current,
297
- topPosition: inputDimensions ? inputDimensions.top + inputDimensions.height + 5 : '',
298
- leftPosition: inputDimensions ? inputDimensions.left : '',
299
- width: inputDimensions ? inputDimensions.width : '',
445
+ containerRef: wrapperBaseInputPeriodRef,
446
+ showButtonOpen: showButtonOpen,
447
+ inputDimensions: inputDimensions,
300
448
  dropdownRef: el => {
301
449
  dropdownCalendarContainer.current = el;
302
450
  }
303
451
  }, getCalendar(valueInitial, calendarColorStyle, 'valueInitial'));
304
452
  };
305
- const getWrapperComponentCalendarValueFinal = () => {
453
+ const getCalendarFinal = () => {
306
454
  if (onDenied && onDenied.readOnly) return null;
455
+ if (calendarContainerRef && calendarContainerRef.current) calendarContainerRef.current.id = 'valueFinal';
307
456
  if (showCalendarInDialog) {
308
457
  return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
458
+ handlerClose: () => onCloseDateDialog('valueFinal'),
309
459
  dialogSize: dialogSize,
310
460
  onOpenChange: setShowCalendarValueFinal
311
461
  }, getCalendar(valueFinal, calendarColorStyle, 'valueFinal'));
312
462
  }
313
463
  return /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
314
- targetElement: inputContainerRef.current,
315
- topPosition: inputDimensions ? inputDimensions.top + inputDimensions.height + 5 : '',
316
- leftPosition: inputDimensions ? inputDimensions.left : '',
317
- width: inputDimensions ? inputDimensions.width : '',
464
+ containerRef: wrapperBaseInputPeriodRef,
465
+ showButtonOpen: showButtonOpen,
466
+ inputDimensions: inputDimensions,
318
467
  dropdownRef: el => {
319
468
  dropdownCalendarContainer.current = el;
320
469
  }
321
470
  }, getCalendar(valueFinal, calendarColorStyle, 'valueFinal'));
322
471
  };
323
- const getWrapperComponentPeriodSelection = () => {
472
+ const getPeriodOfDatesSelection = () => {
324
473
  if (showCalendarInDialog) {
325
474
  return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
475
+ handlerClose: () => onCloseDateDialog('periodSelection'),
326
476
  dialogSize: dialogSize,
327
477
  onOpenChange: setShowPeriodSelection
328
478
  }, getPeriodSelection(valuePeriodSelection, setPeriodDates));
329
479
  }
330
480
  return /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
331
- targetElement: inputContainerRef.current,
332
- topPosition: inputDimensions ? inputDimensions.top + inputDimensions.height + 5 : '',
333
- leftPosition: inputDimensions ? inputDimensions.left : '',
334
- width: inputDimensions ? inputDimensions.width : '',
481
+ containerRef: wrapperBaseInputPeriodRef,
482
+ showButtonOpen: showButtonOpen,
483
+ inputDimensions: inputDimensions,
335
484
  dropdownRef: el => {
336
- dropdownPeriodContainer.current = el;
485
+ dropdownCalendarContainer.current = el;
337
486
  }
338
487
  }, getPeriodSelection(valuePeriodSelection, setPeriodDates));
339
488
  };
340
489
  if (onDenied && onDenied.unvisible) return null;
341
- return /*#__PURE__*/_react.default.createElement("div", {
490
+ const component = () => /*#__PURE__*/_react.default.createElement("div", {
342
491
  ref: wrapperBaseInputPeriodRef,
343
- className: "input-base-component"
492
+ onBlur: onBlurWithoutWrapper,
493
+ className: "input-base-component datepicker-period-container"
344
494
  }, props.label && /*#__PURE__*/_react.default.createElement("div", {
345
495
  className: "labelcontainer"
346
496
  }, /*#__PURE__*/_react.default.createElement("span", {
@@ -354,6 +504,7 @@ const PeriodPicker = props => {
354
504
  }))),
355
505
  ref: inputContainerRef
356
506
  }, /*#__PURE__*/_react.default.createElement(_BaseMask.default, {
507
+ gridLayout: undefined,
357
508
  permissionAttr: props.permissionAttr,
358
509
  name: "valueInitial",
359
510
  value: !valueInitial ? '' : (0, _moment.default)(valueInitial).format('DD/MM/YYYY'),
@@ -375,6 +526,7 @@ const PeriodPicker = props => {
375
526
  name: "arrow_right",
376
527
  customClass: "separation_icon"
377
528
  }), /*#__PURE__*/_react.default.createElement(_BaseMask.default, {
529
+ gridLayout: undefined,
378
530
  permissionAttr: props.permissionAttr,
379
531
  name: "valueFinal",
380
532
  value: !valueFinal ? '' : (0, _moment.default)(valueFinal).format('DD/MM/YYYY'),
@@ -390,12 +542,16 @@ const PeriodPicker = props => {
390
542
  },
391
543
  handlerSetOnDenied: denied => setOnDenied(denied),
392
544
  required: props.required
393
- }), getButtonOpen(), getButtonSelectPeriod()), showCalendarValueInitial && getWrapperComponentCalendarValueInitial(), showCalendarValueFinal && getWrapperComponentCalendarValueFinal(), showPeriodSelection && getWrapperComponentPeriodSelection(), /*#__PURE__*/_react.default.createElement(_hint.default, {
545
+ }), getButtonOpen(), getButtonSelectPeriod()), showCalendarValueInitial && getCalendarInitial(), showCalendarValueFinal && getCalendarFinal(), showPeriodSelection && getPeriodOfDatesSelection(), /*#__PURE__*/_react.default.createElement(_hint.default, {
394
546
  visible: !!hint,
395
547
  customClass: "hint",
396
548
  description: hint
397
549
  }), /*#__PURE__*/_react.default.createElement(_errorMessage.ErrorMessage, {
398
550
  messages: props.errorMessages
399
551
  }));
552
+ return !gridLayout ? component() : /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
553
+ customClass: "-withinput",
554
+ cols: gridLayout
555
+ }, component());
400
556
  };
401
557
  var _default = exports.default = PeriodPicker;
@@ -1,5 +1,5 @@
1
1
  import { Moment } from 'moment';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, RefObject } from 'react';
3
3
  import { ColorStyles } from '../../@types/ColorStyles.js';
4
4
  import { Period } from '../../@types/Period.js';
5
5
  import { PermissionAttr } from '../../@types/PermissionAttr.js';
@@ -9,6 +9,7 @@ import '../../internals/types.js';
9
9
  import '../../@types/Position.js';
10
10
 
11
11
  type DateTypes = 'today' | 'week' | 'lastweek' | 'last15' | 'month' | 'lastmonth';
12
+ type TypeCurrentDate = 'valueInitial' | 'valueFinal';
12
13
  interface ChangeInputPeriodEvent {
13
14
  target: {
14
15
  value?: string;
@@ -26,14 +27,14 @@ interface IDialogProps {
26
27
  width: string;
27
28
  height: string;
28
29
  };
30
+ handlerClose: (open: boolean) => void;
29
31
  }
30
32
  interface IPeriodDropdownProps {
31
- topPosition: number | string;
32
- leftPosition: number | string;
33
- width: number | string;
34
- children: JSX.Element | JSX.Element[];
35
- dropdownRef: (el: HTMLElement) => void;
36
- targetElement?: HTMLDivElement | HTMLInputElement | null;
33
+ children: ReactNode | ReactNode[];
34
+ dropdownRef: (el: HTMLDivElement) => void;
35
+ containerRef: RefObject<HTMLDivElement | HTMLElement>;
36
+ showButtonOpen: boolean;
37
+ inputDimensions?: DOMRect;
37
38
  }
38
39
  interface IPeriodPickerProps {
39
40
  label?: string;
@@ -61,10 +62,11 @@ interface IPeriodPickerProps {
61
62
  hint?: string;
62
63
  onBlur?: (e: CustomInputEvent) => void;
63
64
  onFocus?: (e: CustomInputEvent) => void;
65
+ gridLayout?: string;
64
66
  }
65
67
  interface IPeriodListProps {
66
68
  handleOnSelect: (value: DateTypes | 'custom', date: Moment[] | null) => void;
67
69
  selected?: string;
68
70
  }
69
71
 
70
- export { ChangeInputPeriodEvent, DateTypes, IDialogProps, IPeriodDropdownProps, IPeriodListProps, IPeriodOptions, IPeriodPickerProps };
72
+ export { ChangeInputPeriodEvent, DateTypes, IDialogProps, IPeriodDropdownProps, IPeriodListProps, IPeriodOptions, IPeriodPickerProps, TypeCurrentDate };
@@ -13,10 +13,11 @@ const ActionButtons = props => {
13
13
  showClearButton = true,
14
14
  dropDownOpened,
15
15
  handlerOpenClose,
16
- handlerClear
16
+ handlerClear,
17
+ customClassForSideButtons
17
18
  } = props;
18
19
  return /*#__PURE__*/_react.default.createElement("div", {
19
- className: "actionbuttonsselect"
20
+ className: "actionbuttonsselect ".concat(customClassForSideButtons)
20
21
  }, showClearButton && /*#__PURE__*/_react.default.createElement("button", {
21
22
  disabled: disabled,
22
23
  tabIndex: -1,