linear-react-components-ui 1.1.18-beta.17 → 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 (82) 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/input.scss +2 -2
  5. package/lib/assets/styles/periodpicker.scss +60 -20
  6. package/lib/assets/styles/popover.scss +0 -3
  7. package/lib/assets/styles/sidenav.scss +1 -1
  8. package/lib/assets/styles/tabs.scss +32 -15
  9. package/lib/calendar/DangerCalendar.d.ts +1 -0
  10. package/lib/calendar/InfoCalendar.d.ts +1 -0
  11. package/lib/calendar/PrimaryCalendar.d.ts +1 -0
  12. package/lib/calendar/SuccessCalendar.d.ts +1 -0
  13. package/lib/calendar/WarningCalendar.d.ts +1 -0
  14. package/lib/calendar/base/Day.d.ts +1 -0
  15. package/lib/calendar/base/Day.js +6 -2
  16. package/lib/calendar/base/Month.d.ts +2 -1
  17. package/lib/calendar/base/Month.js +2 -0
  18. package/lib/calendar/base/Week.d.ts +1 -0
  19. package/lib/calendar/base/index.d.ts +1 -0
  20. package/lib/calendar/base/index.js +63 -13
  21. package/lib/calendar/index.d.ts +1 -0
  22. package/lib/calendar/types.d.ts +5 -0
  23. package/lib/checkbox/Label.d.ts +11 -0
  24. package/lib/checkbox/index.js +18 -45
  25. package/lib/checkbox/types.d.ts +0 -4
  26. package/lib/dialog/base/Content.js +5 -4
  27. package/lib/dialog/base/Header.js +0 -1
  28. package/lib/dialog/base/index.js +27 -3
  29. package/lib/drawer/Drawer.js +1 -1
  30. package/lib/form/types.d.ts +0 -14
  31. package/lib/inputs/base/InputTextBase.js +8 -34
  32. package/lib/inputs/base/types.d.ts +0 -3
  33. package/lib/inputs/color/types.d.ts +0 -5
  34. package/lib/inputs/date/Dialog.js +5 -4
  35. package/lib/inputs/date/Dropdown.js +15 -7
  36. package/lib/inputs/date/helpers.d.ts +1 -11
  37. package/lib/inputs/date/helpers.js +1 -11
  38. package/lib/inputs/date/index.js +138 -100
  39. package/lib/inputs/date/types.d.ts +7 -10
  40. package/lib/inputs/file/DragDropFile.js +1 -2
  41. package/lib/inputs/file/types.d.ts +0 -3
  42. package/lib/inputs/mask/helpers.d.ts +0 -4
  43. package/lib/inputs/mask/types.d.ts +0 -4
  44. package/lib/inputs/multiSelect/types.d.ts +0 -4
  45. package/lib/inputs/number/BaseNumber.d.ts +1 -1
  46. package/lib/inputs/number/Currency.d.ts +1 -1
  47. package/lib/inputs/number/Decimal.d.ts +1 -1
  48. package/lib/inputs/number/index.d.ts +1 -1
  49. package/lib/inputs/number/index.js +3 -7
  50. package/lib/inputs/number/types.d.ts +2 -14
  51. package/lib/inputs/period/Dialog.d.ts +1 -1
  52. package/lib/inputs/period/Dialog.js +5 -3
  53. package/lib/inputs/period/Dropdown.js +19 -8
  54. package/lib/inputs/period/PeriodList.js +3 -12
  55. package/lib/inputs/period/index.js +241 -112
  56. package/lib/inputs/period/types.d.ts +10 -11
  57. package/lib/inputs/select/ActionButtons.js +3 -2
  58. package/lib/inputs/select/multiple/index.js +10 -11
  59. package/lib/inputs/select/simple/index.js +10 -4
  60. package/lib/inputs/select/types.d.ts +4 -6
  61. package/lib/inputs/types.d.ts +1 -0
  62. package/lib/list/index.js +2 -2
  63. package/lib/popover/index.js +5 -3
  64. package/lib/popover/types.d.ts +1 -2
  65. package/lib/radio/index.d.ts +1 -1
  66. package/lib/radio/index.js +1 -32
  67. package/lib/radio/types.d.ts +0 -6
  68. package/lib/tabs/DropdownTabs.js +21 -7
  69. package/lib/tabs/context.d.ts +1 -1
  70. package/lib/tabs/context.js +3 -3
  71. package/lib/tabs/types.d.ts +2 -1
  72. package/lib/textContent/index.d.ts +4 -18
  73. package/lib/textContent/index.js +4 -14
  74. package/lib/toolbar/types.d.ts +2 -1
  75. package/package.json +1 -1
  76. package/lib/inputs/mask/imaskHOC.js +0 -203
  77. package/lib/menus/sidenav/popup_menu_help/index.js +0 -85
  78. package/lib/tabs/DropdownItems.js +0 -62
  79. package/lib/tabs/MenuItems.js +0 -70
  80. package/lib/treeview_old/Header.js +0 -29
  81. package/lib/treeview_old/Node.js +0 -68
  82. package/lib/treeview_old/index.js +0 -43
@@ -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,11 +14,10 @@ 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");
20
- var _textContent = _interopRequireDefault(require("../../textContent"));
21
- var _popover = _interopRequireDefault(require("../../popover"));
22
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
24
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -39,10 +38,10 @@ const PeriodPicker = props => {
39
38
  height: '350px'
40
39
  },
41
40
  hint,
42
- hintPosition = 'below',
43
- themePopover = 'light',
44
- popoverAlign = 'left'
41
+ gridLayout
45
42
  } = props;
43
+ const idValueInitial = (0, _react.useId)();
44
+ const idValueFinal = (0, _react.useId)();
46
45
  const [valueInitial, setValueInitial] = (0, _react.useState)(props.value && (0, _moment.default)(props.value.initial, 'DD/MM/YYYY'));
47
46
  const [valueFinal, setValueFinal] = (0, _react.useState)(props.value && (0, _moment.default)(props.value.final, 'DD/MM/YYYY'));
48
47
  const [valuePeriodSelection, setValuePeriodSelection] = (0, _react.useState)('week');
@@ -51,53 +50,128 @@ const PeriodPicker = props => {
51
50
  const [showPeriodSelection, setShowPeriodSelection] = (0, _react.useState)(false);
52
51
  const [inputDimensions, setInputDimensions] = (0, _react.useState)();
53
52
  const [onDenied, setOnDenied] = (0, _react.useState)();
53
+ const [currentTypeDate, setCurrentTypeDate] = (0, _react.useState)('valueInitial');
54
54
  const wrapperBaseInputPeriodRef = (0, _react.useRef)(null);
55
55
  const inputContainerRef = (0, _react.useRef)(null);
56
56
  const inputInitialRef = (0, _react.useRef)(null);
57
57
  const buttonOpenRef = (0, _react.useRef)(null);
58
+ const currentDateButtonRef = (0, _react.useRef)();
58
59
  const buttonSelectPeriodRef = (0, _react.useRef)(null);
59
60
  const dropdownCalendarContainer = (0, _react.useRef)(null);
60
61
  const dropdownPeriodContainer = (0, _react.useRef)(null);
61
62
  const inputFinalRef = (0, _react.useRef)(null);
63
+ const calendarContainerRef = (0, _react.useRef)(null);
62
64
  const onScreenResize = () => {
63
65
  var _inputContainerRef$cu;
64
- const inputDimensionsAux = inputContainerRef === null || inputContainerRef === void 0 ? void 0 : (_inputContainerRef$cu = inputContainerRef.current) === null || _inputContainerRef$cu === void 0 ? void 0 : _inputContainerRef$cu.getBoundingClientRect();
65
- 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());
66
67
  };
67
- const onClickOutside = event => {
68
- const {
69
- target
70
- } = event;
71
- if (target === inputContainerRef.current || target === inputInitialRef.current || target === inputFinalRef.current || target === buttonOpenRef.current || target === buttonSelectPeriodRef.current) {
72
- 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);
73
73
  }
74
- if (dropdownCalendarContainer.current && dropdownCalendarContainer.current.contains(target)) {
75
- return;
74
+ if (!showCalendarInDialog && showCalendarValueFinal && focusOnAnotherField) {
75
+ setShowCalendarValueFinal(false);
76
76
  }
77
- if (dropdownPeriodContainer.current && dropdownPeriodContainer.current.contains(target)) return;
78
- setShowCalendarValueInitial(false);
79
- setShowCalendarValueFinal(false);
80
- setShowPeriodSelection(false);
81
77
  };
82
- const onCloseCalendarWithoutFocus = event => {
83
- if (event.key === 'Tab') {
84
- 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
+ }
85
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
+ }
86
98
  setShowCalendarValueFinal(false);
87
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');
88
139
  }
89
140
  };
90
141
  (0, _react.useEffect)(() => {
142
+ var _document$getElementB;
91
143
  window.addEventListener('resize', onScreenResize);
92
- document.addEventListener('click', onClickOutside);
93
- 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);
94
146
  if (inputContainerRef.current) onScreenResize();
147
+ if (inputInitialRef && inputInitialRef.current) inputInitialRef.current.id = idValueInitial;
148
+ if (inputFinalRef && inputFinalRef.current) inputFinalRef.current.id = idValueFinal;
95
149
  return () => {
150
+ var _document$getElementB2;
96
151
  window.removeEventListener('resize', onScreenResize);
97
- document.removeEventListener('click', onClickOutside);
98
- 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);
99
154
  };
100
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]);
101
175
  (0, _react.useEffect)(() => {
102
176
  if (props.value && !((0, _moment.default)(props.value.initial).isSame(valueInitial) || (0, _moment.default)(props.value.final).isSame(valueFinal))) {
103
177
  const {
@@ -118,17 +192,71 @@ const PeriodPicker = props => {
118
192
  }, [props.value]);
119
193
  const openCalendar = calendarName => {
120
194
  if (calendarName === 'valueInitial') {
195
+ setCurrentTypeDate('valueInitial');
121
196
  setShowCalendarValueFinal(false);
122
- setShowCalendarValueInitial(true);
123
- } 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');
124
211
  setShowCalendarValueInitial(false);
125
- 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
+ }
126
223
  }
127
- setShowPeriodSelection(false);
128
224
  if (inputContainerRef.current) {
129
225
  setInputDimensions(inputContainerRef.current.getBoundingClientRect());
130
226
  }
131
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
+ };
132
260
  const onInputFocus = e => {
133
261
  const {
134
262
  name
@@ -164,12 +292,12 @@ const PeriodPicker = props => {
164
292
  }
165
293
  };
166
294
  const setValue = function (event, value) {
167
- var _inputInitialRef$curr, _inputFinalRef$curren;
295
+ var _inputInitialRef$curr6, _inputFinalRef$curren8;
168
296
  let shouldOpenDropdown = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
169
297
  const valueDateName = event ? event.target.name : '';
170
298
  const dateObj = (0, _moment.default)(value, 'DD/MM/YYYY');
171
- if (showCalendarValueInitial) (_inputInitialRef$curr = inputInitialRef.current) === null || _inputInitialRef$curr === void 0 ? void 0 : _inputInitialRef$curr.focus();
172
- 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();
173
301
  if (valueDateName === 'valueFinal' && valueInitial && dateObj.isBefore(valueInitial)) {
174
302
  setValueInitial(dateObj);
175
303
  setValueFinal(valueInitial);
@@ -198,8 +326,8 @@ const PeriodPicker = props => {
198
326
  });
199
327
  }
200
328
  if (valueDateName === 'valueInitial' && !valueFinal && shouldOpenDropdown) {
201
- var _inputFinalRef$curren2;
202
- (_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();
203
331
  setTimeout(() => setShowCalendarValueFinal(true), 100);
204
332
  }
205
333
  if (shouldCloseOnSelect) {
@@ -213,27 +341,29 @@ const PeriodPicker = props => {
213
341
  } = props;
214
342
  return disabled || onDenied && (onDenied.disabled || onDenied.hideContent);
215
343
  };
216
- const getButtonOpen = () => {
344
+ const getButtonOpen = (0, _react.useCallback)(() => {
217
345
  if (!showButtonOpen) return null;
218
346
  return /*#__PURE__*/_react.default.createElement(_buttons.default, {
219
347
  key: "button-open",
220
348
  boxShadow: false,
349
+ disabled: shouldDisable(),
350
+ customClass: "calendar-button",
221
351
  icon: /*#__PURE__*/_react.default.createElement(_icons.default, {
222
352
  name: "calendar"
223
353
  }),
224
354
  onClick: () => {
225
- var _inputInitialRef$curr2;
226
- (_inputInitialRef$curr2 = inputInitialRef.current) === null || _inputInitialRef$curr2 === void 0 ? void 0 : _inputInitialRef$curr2.focus();
227
- openCalendar('valueInitial');
355
+ if (showCalendarValueFinal || showCalendarValueInitial) {
356
+ closeCalendar(currentTypeDate);
357
+ } else {
358
+ openCalendar(currentTypeDate);
359
+ }
228
360
  },
229
- customClass: "calendar-button",
230
361
  tabIndex: -1,
231
362
  targetRef: ref => {
232
363
  buttonOpenRef.current = ref;
233
- },
234
- disabled: shouldDisable()
364
+ }
235
365
  });
236
- };
366
+ }, [showCalendarValueFinal, showCalendarValueInitial]);
237
367
  const getPeriodSelection = (valuePeriodSelectionAux, setPeriodDates) => /*#__PURE__*/_react.default.createElement(_PeriodList.default, {
238
368
  selected: valuePeriodSelectionAux,
239
369
  handleOnSelect: setPeriodDates
@@ -246,36 +376,46 @@ const PeriodPicker = props => {
246
376
  setInputDimensions(inputContainerRef.current.getBoundingClientRect());
247
377
  }
248
378
  };
249
- const getButtonSelectPeriod = () => /*#__PURE__*/_react.default.createElement(_buttons.default, {
250
- key: "button-select-period",
251
- boxShadow: false,
252
- icon: /*#__PURE__*/_react.default.createElement(_icons.default, {
253
- name: "more1"
254
- }),
255
- onBlur: () => setTimeout(() => setShowPeriodSelection(false), 100),
256
- onClick: () => openPeriodSelecion(),
257
- customClass: "calendar-button",
258
- tabIndex: -1,
259
- targetRef: ref => {
260
- buttonSelectPeriodRef.current = ref;
261
- },
262
- disabled: shouldDisable()
263
- });
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]);
264
401
  const getCalendar = (value, calendarColorStyleCalendar, valueDateName) => /*#__PURE__*/_react.default.createElement(_calendar.default, {
402
+ colorStyle: calendarColorStyleCalendar,
265
403
  currentDate: value !== undefined ? (0, _moment.default)(value) : (0, _moment.default)(),
266
- onDateChange: date => {
267
- setValue({
268
- target: {
269
- name: valueDateName
270
- }
271
- }, date);
404
+ calendarContainer: ref => {
405
+ calendarContainerRef.current = ref;
272
406
  },
273
- colorStyle: calendarColorStyleCalendar
407
+ onDateChange: date => setValue({
408
+ target: {
409
+ name: valueDateName
410
+ }
411
+ }, date),
412
+ currentDateButton: buttonElement => currentDateButtonRef.current = buttonElement
274
413
  });
275
414
  const setPeriodDates = (selected, dates) => {
415
+ var _inputFinalRef$curren11;
276
416
  if (selected === 'custom') {
277
- var _inputInitialRef$curr3;
278
- (_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();
279
419
  setValuePeriodSelection(selected);
280
420
  setShowPeriodSelection(false);
281
421
  return;
@@ -288,99 +428,83 @@ const PeriodPicker = props => {
288
428
  if (shouldCloseOnSelect) {
289
429
  setShowPeriodSelection(false);
290
430
  }
431
+ (_inputFinalRef$curren11 = inputFinalRef.current) === null || _inputFinalRef$curren11 === void 0 ? void 0 : _inputFinalRef$curren11.focus();
432
+ setShowCalendarValueFinal(false);
291
433
  };
292
- const getWrapperComponentCalendarValueInitial = () => {
434
+ const getCalendarInitial = () => {
293
435
  if (onDenied && onDenied.readOnly) return null;
436
+ if (calendarContainerRef && calendarContainerRef.current) calendarContainerRef.current.id = 'valueInitial';
294
437
  if (showCalendarInDialog) {
295
438
  return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
439
+ handlerClose: () => onCloseDateDialog('valueInitial'),
296
440
  dialogSize: dialogSize,
297
441
  onOpenChange: setShowCalendarValueInitial
298
442
  }, getCalendar(valueInitial, calendarColorStyle, 'valueInitial'));
299
443
  }
300
444
  return /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
301
- targetElement: inputContainerRef.current,
302
- topPosition: inputDimensions ? inputDimensions.top + inputDimensions.height + 5 : '',
303
- leftPosition: inputDimensions ? inputDimensions.left : '',
304
- width: inputDimensions ? inputDimensions.width : '',
445
+ containerRef: wrapperBaseInputPeriodRef,
446
+ showButtonOpen: showButtonOpen,
447
+ inputDimensions: inputDimensions,
305
448
  dropdownRef: el => {
306
449
  dropdownCalendarContainer.current = el;
307
450
  }
308
451
  }, getCalendar(valueInitial, calendarColorStyle, 'valueInitial'));
309
452
  };
310
- const getWrapperComponentCalendarValueFinal = () => {
453
+ const getCalendarFinal = () => {
311
454
  if (onDenied && onDenied.readOnly) return null;
455
+ if (calendarContainerRef && calendarContainerRef.current) calendarContainerRef.current.id = 'valueFinal';
312
456
  if (showCalendarInDialog) {
313
457
  return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
458
+ handlerClose: () => onCloseDateDialog('valueFinal'),
314
459
  dialogSize: dialogSize,
315
460
  onOpenChange: setShowCalendarValueFinal
316
461
  }, getCalendar(valueFinal, calendarColorStyle, 'valueFinal'));
317
462
  }
318
463
  return /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
319
- targetElement: inputContainerRef.current,
320
- topPosition: inputDimensions ? inputDimensions.top + inputDimensions.height + 5 : '',
321
- leftPosition: inputDimensions ? inputDimensions.left : '',
322
- width: inputDimensions ? inputDimensions.width : '',
464
+ containerRef: wrapperBaseInputPeriodRef,
465
+ showButtonOpen: showButtonOpen,
466
+ inputDimensions: inputDimensions,
323
467
  dropdownRef: el => {
324
468
  dropdownCalendarContainer.current = el;
325
469
  }
326
470
  }, getCalendar(valueFinal, calendarColorStyle, 'valueFinal'));
327
471
  };
328
- const getWrapperComponentPeriodSelection = () => {
472
+ const getPeriodOfDatesSelection = () => {
329
473
  if (showCalendarInDialog) {
330
474
  return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
475
+ handlerClose: () => onCloseDateDialog('periodSelection'),
331
476
  dialogSize: dialogSize,
332
477
  onOpenChange: setShowPeriodSelection
333
478
  }, getPeriodSelection(valuePeriodSelection, setPeriodDates));
334
479
  }
335
480
  return /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
336
- targetElement: inputContainerRef.current,
337
- topPosition: inputDimensions ? inputDimensions.top + inputDimensions.height + 5 : '',
338
- leftPosition: inputDimensions ? inputDimensions.left : '',
339
- width: inputDimensions ? inputDimensions.width : '',
481
+ containerRef: wrapperBaseInputPeriodRef,
482
+ showButtonOpen: showButtonOpen,
483
+ inputDimensions: inputDimensions,
340
484
  dropdownRef: el => {
341
- dropdownPeriodContainer.current = el;
485
+ dropdownCalendarContainer.current = el;
342
486
  }
343
487
  }, getPeriodSelection(valuePeriodSelection, setPeriodDates));
344
488
  };
345
489
  if (onDenied && onDenied.unvisible) return null;
346
- return /*#__PURE__*/_react.default.createElement("div", {
490
+ const component = () => /*#__PURE__*/_react.default.createElement("div", {
347
491
  ref: wrapperBaseInputPeriodRef,
348
- className: "input-base-component"
492
+ onBlur: onBlurWithoutWrapper,
493
+ className: "input-base-component datepicker-period-container"
349
494
  }, props.label && /*#__PURE__*/_react.default.createElement("div", {
350
495
  className: "labelcontainer"
351
- }, /*#__PURE__*/_react.default.createElement(_textContent.default, {
352
- required: props.required,
353
- className: props.customClassForLabel,
354
- labelUppercase: props.labelUppercase
355
- }), /*#__PURE__*/_react.default.createElement("div", {
356
- className: "text-content",
357
- style: {
358
- display: 'flex'
359
- }
360
- }, /*#__PURE__*/_react.default.createElement("div", {
361
- className: "label ".concat(props.customClassForLabel, " ").concat(props.labelUppercase && ' -uppercase'),
362
- style: {
363
- alignSelf: 'center'
364
- }
496
+ }, /*#__PURE__*/_react.default.createElement("span", {
497
+ className: "label ".concat(props.customClassForLabel, " ").concat(props.labelUppercase && ' -uppercase')
365
498
  }, props.label, props.required && /*#__PURE__*/_react.default.createElement("span", {
366
499
  className: "-requiredlabel"
367
- }, "*"), !!hint && hintPosition === 'onLabelRight' && /*#__PURE__*/_react.default.createElement(_popover.default, {
368
- theme: themePopover,
369
- align: popoverAlign,
370
- iconColor: "#03bde2",
371
- customClass: "-hint",
372
- style: {
373
- margin: '0px 5px',
374
- height: 'auto',
375
- width: 20
376
- }
377
- }, hint))), /*#__PURE__*/_react.default.createElement(_textContent.default, null)), /*#__PURE__*/_react.default.createElement("div", {
500
+ }, "*"))), /*#__PURE__*/_react.default.createElement("div", {
378
501
  className: "periodpicker-component ".concat(helperBase.getInputWrapperClass(_objectSpread(_objectSpread({}, props), {}, {
379
502
  value: !valueInitial ? '' : (0, _moment.default)(valueInitial).format('DD/MM/YYYY'),
380
503
  disabled: shouldDisable()
381
504
  }))),
382
505
  ref: inputContainerRef
383
506
  }, /*#__PURE__*/_react.default.createElement(_BaseMask.default, {
507
+ gridLayout: undefined,
384
508
  permissionAttr: props.permissionAttr,
385
509
  name: "valueInitial",
386
510
  value: !valueInitial ? '' : (0, _moment.default)(valueInitial).format('DD/MM/YYYY'),
@@ -402,6 +526,7 @@ const PeriodPicker = props => {
402
526
  name: "arrow_right",
403
527
  customClass: "separation_icon"
404
528
  }), /*#__PURE__*/_react.default.createElement(_BaseMask.default, {
529
+ gridLayout: undefined,
405
530
  permissionAttr: props.permissionAttr,
406
531
  name: "valueFinal",
407
532
  value: !valueFinal ? '' : (0, _moment.default)(valueFinal).format('DD/MM/YYYY'),
@@ -417,12 +542,16 @@ const PeriodPicker = props => {
417
542
  },
418
543
  handlerSetOnDenied: denied => setOnDenied(denied),
419
544
  required: props.required
420
- }), getButtonOpen(), getButtonSelectPeriod()), showCalendarValueInitial && getWrapperComponentCalendarValueInitial(), showCalendarValueFinal && getWrapperComponentCalendarValueFinal(), showPeriodSelection && getWrapperComponentPeriodSelection(), /*#__PURE__*/_react.default.createElement(_hint.default, {
421
- visible: !!hint && hintPosition === 'below',
545
+ }), getButtonOpen(), getButtonSelectPeriod()), showCalendarValueInitial && getCalendarInitial(), showCalendarValueFinal && getCalendarFinal(), showPeriodSelection && getPeriodOfDatesSelection(), /*#__PURE__*/_react.default.createElement(_hint.default, {
546
+ visible: !!hint,
422
547
  customClass: "hint",
423
548
  description: hint
424
549
  }), /*#__PURE__*/_react.default.createElement(_errorMessage.ErrorMessage, {
425
550
  messages: props.errorMessages
426
551
  }));
552
+ return !gridLayout ? component() : /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
553
+ customClass: "-withinput",
554
+ cols: gridLayout
555
+ }, component());
427
556
  };
428
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;
@@ -59,15 +60,13 @@ interface IPeriodPickerProps {
59
60
  errorMessages?: string[];
60
61
  name?: string;
61
62
  hint?: string;
62
- hintPosition?: 'below' | 'onLabelRight';
63
63
  onBlur?: (e: CustomInputEvent) => void;
64
64
  onFocus?: (e: CustomInputEvent) => void;
65
- themePopover?: 'light' | 'dark';
66
- popoverAlign?: 'right' | 'left';
65
+ gridLayout?: string;
67
66
  }
68
67
  interface IPeriodListProps {
69
68
  handleOnSelect: (value: DateTypes | 'custom', date: Moment[] | null) => void;
70
69
  selected?: string;
71
70
  }
72
71
 
73
- 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,