linear-react-components-ui 1.1.21-beta.4 → 1.1.21-beta.6
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.
- package/lib/assets/styles/button.scss +1 -0
- package/lib/assets/styles/calendar.scss +64 -30
- package/lib/assets/styles/datepicker.scss +26 -6
- package/lib/assets/styles/periodpicker.scss +60 -20
- package/lib/assets/styles/select.scss +19 -15
- package/lib/assets/styles/sidenav.scss +1 -1
- package/lib/assets/styles/tabs.scss +48 -18
- package/lib/buttons/DefaultButton.js +6 -3
- package/lib/buttons/types.d.ts +1 -0
- package/lib/calendar/DangerCalendar.d.ts +1 -0
- package/lib/calendar/InfoCalendar.d.ts +1 -0
- package/lib/calendar/PrimaryCalendar.d.ts +1 -0
- package/lib/calendar/SuccessCalendar.d.ts +1 -0
- package/lib/calendar/WarningCalendar.d.ts +1 -0
- package/lib/calendar/base/Day.d.ts +1 -0
- package/lib/calendar/base/Day.js +6 -2
- package/lib/calendar/base/Month.d.ts +2 -1
- package/lib/calendar/base/Month.js +2 -0
- package/lib/calendar/base/Week.d.ts +1 -0
- package/lib/calendar/base/index.d.ts +1 -0
- package/lib/calendar/base/index.js +61 -13
- package/lib/calendar/index.d.ts +1 -0
- package/lib/calendar/types.d.ts +5 -0
- package/lib/checkbox/Label.js +31 -0
- package/lib/dialog/base/Content.js +5 -4
- package/lib/dialog/base/Header.js +0 -1
- package/lib/dialog/base/index.js +26 -3
- package/lib/drawer/Drawer.js +1 -1
- package/lib/dropdown/Popup.d.ts +2 -2
- package/lib/dropdown/Popup.js +38 -17
- package/lib/dropdown/types.d.ts +7 -3
- package/lib/dropdown/withDropdown.js +5 -4
- package/lib/form/Field.js +11 -2
- package/lib/form/FieldArray.js +11 -2
- package/lib/form/FieldNumber.js +10 -1
- package/lib/form/FieldPeriod.js +15 -12
- package/lib/form/index.d.ts +1 -1
- package/lib/form/index.js +25 -3
- package/lib/form/types.d.ts +13 -1
- package/lib/form/withFieldHOC.js +4 -2
- package/lib/inputs/base/InputTextBase.js +9 -2
- package/lib/inputs/base/types.d.ts +2 -0
- package/lib/inputs/date/Dialog.js +5 -4
- package/lib/inputs/date/Dropdown.js +13 -7
- package/lib/inputs/date/helpers.d.ts +31 -11
- package/lib/inputs/date/helpers.js +32 -15
- package/lib/inputs/date/index.js +142 -102
- package/lib/inputs/date/types.d.ts +8 -6
- package/lib/inputs/mask/BaseMask.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.js +6 -4
- package/lib/inputs/mask/helpers.d.ts +6 -53
- package/lib/inputs/mask/helpers.js +15 -35
- package/lib/inputs/mask/imaskHOC.js +203 -0
- package/lib/inputs/mask/types.d.ts +1 -0
- package/lib/inputs/number/BaseNumber.d.ts +1 -1
- package/lib/inputs/number/BaseNumber.js +9 -2
- package/lib/inputs/number/Currency.d.ts +1 -1
- package/lib/inputs/number/Currency.js +11 -4
- package/lib/inputs/period/Dialog.d.ts +1 -1
- package/lib/inputs/period/Dialog.js +5 -3
- package/lib/inputs/period/Dropdown.js +16 -8
- package/lib/inputs/period/PeriodList.js +3 -12
- package/lib/inputs/period/index.js +210 -74
- package/lib/inputs/period/types.d.ts +10 -8
- package/lib/inputs/select/ActionButtons.js +3 -2
- package/lib/inputs/select/Dropdown.js +4 -2
- package/lib/inputs/select/multiple/Selecteds.d.ts +1 -1
- package/lib/inputs/select/multiple/Selecteds.js +3 -1
- package/lib/inputs/select/multiple/index.js +12 -5
- package/lib/inputs/select/simple/index.js +10 -4
- package/lib/inputs/select/types.d.ts +5 -0
- package/lib/inputs/types.d.ts +1 -0
- package/lib/menus/sidenav/popup_menu_help/index.js +85 -0
- package/lib/popover/PopoverText.d.ts +1 -0
- package/lib/popover/PopoverTitle.d.ts +1 -0
- package/lib/popover/index.d.ts +3 -5
- package/lib/popover/index.js +21 -15
- package/lib/popover/types.d.ts +11 -0
- package/lib/tabs/DropdownItems.js +62 -0
- package/lib/tabs/DropdownTabs.js +21 -7
- package/lib/tabs/Menu.d.ts +1 -1
- package/lib/tabs/Menu.js +4 -2
- package/lib/tabs/MenuItems.js +70 -0
- package/lib/tabs/MenuTabs.js +16 -5
- package/lib/tabs/context.d.ts +1 -1
- package/lib/tabs/context.js +6 -4
- package/lib/tabs/index.d.ts +1 -1
- package/lib/tabs/index.js +13 -6
- package/lib/tabs/types.d.ts +8 -1
- package/lib/toolbar/types.d.ts +2 -1
- package/lib/treeview_old/Header.js +29 -0
- package/lib/treeview_old/Node.js +68 -0
- package/lib/treeview_old/index.js +43 -0
- package/package.json +1 -1
|
@@ -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");
|
|
@@ -41,8 +42,11 @@ const PeriodPicker = props => {
|
|
|
41
42
|
hint,
|
|
42
43
|
hintPosition = 'below',
|
|
43
44
|
themePopover = 'light',
|
|
44
|
-
popoverAlign = 'left'
|
|
45
|
+
popoverAlign = 'left',
|
|
46
|
+
gridLayout
|
|
45
47
|
} = props;
|
|
48
|
+
const idValueInitial = (0, _react.useId)();
|
|
49
|
+
const idValueFinal = (0, _react.useId)();
|
|
46
50
|
const [valueInitial, setValueInitial] = (0, _react.useState)(props.value && (0, _moment.default)(props.value.initial, 'DD/MM/YYYY'));
|
|
47
51
|
const [valueFinal, setValueFinal] = (0, _react.useState)(props.value && (0, _moment.default)(props.value.final, 'DD/MM/YYYY'));
|
|
48
52
|
const [valuePeriodSelection, setValuePeriodSelection] = (0, _react.useState)('week');
|
|
@@ -51,52 +55,117 @@ const PeriodPicker = props => {
|
|
|
51
55
|
const [showPeriodSelection, setShowPeriodSelection] = (0, _react.useState)(false);
|
|
52
56
|
const [inputDimensions, setInputDimensions] = (0, _react.useState)();
|
|
53
57
|
const [onDenied, setOnDenied] = (0, _react.useState)();
|
|
58
|
+
const [currentTypeDate, setCurrentTypeDate] = (0, _react.useState)('valueInitial');
|
|
54
59
|
const wrapperBaseInputPeriodRef = (0, _react.useRef)(null);
|
|
55
60
|
const inputContainerRef = (0, _react.useRef)(null);
|
|
56
61
|
const inputInitialRef = (0, _react.useRef)(null);
|
|
57
62
|
const buttonOpenRef = (0, _react.useRef)(null);
|
|
63
|
+
const currentDateButtonRef = (0, _react.useRef)();
|
|
58
64
|
const buttonSelectPeriodRef = (0, _react.useRef)(null);
|
|
59
65
|
const dropdownCalendarContainer = (0, _react.useRef)(null);
|
|
60
66
|
const dropdownPeriodContainer = (0, _react.useRef)(null);
|
|
61
67
|
const inputFinalRef = (0, _react.useRef)(null);
|
|
68
|
+
const calendarContainerRef = (0, _react.useRef)(null);
|
|
62
69
|
const onScreenResize = () => {
|
|
63
|
-
|
|
64
|
-
setInputDimensions(inputDimensionsAux);
|
|
70
|
+
setInputDimensions(inputContainerRef?.current?.getBoundingClientRect());
|
|
65
71
|
};
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (target === inputContainerRef.current || target === inputInitialRef.current || target === inputFinalRef.current || target === buttonOpenRef.current || target === buttonSelectPeriodRef.current) {
|
|
71
|
-
return;
|
|
72
|
+
const onBlurWithoutWrapper = event => {
|
|
73
|
+
const focusOnAnotherField = !wrapperBaseInputPeriodRef.current?.contains(event.relatedTarget);
|
|
74
|
+
if (!showCalendarInDialog && showCalendarValueInitial && focusOnAnotherField) {
|
|
75
|
+
setShowCalendarValueInitial(false);
|
|
72
76
|
}
|
|
73
|
-
if (
|
|
74
|
-
|
|
77
|
+
if (!showCalendarInDialog && showCalendarValueFinal && focusOnAnotherField) {
|
|
78
|
+
setShowCalendarValueFinal(false);
|
|
75
79
|
}
|
|
76
|
-
if (dropdownPeriodContainer.current && dropdownPeriodContainer.current.contains(target)) return;
|
|
77
|
-
setShowCalendarValueInitial(false);
|
|
78
|
-
setShowCalendarValueFinal(false);
|
|
79
|
-
setShowPeriodSelection(false);
|
|
80
80
|
};
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const onKeyDownPress = event => {
|
|
82
|
+
const {
|
|
83
|
+
target
|
|
84
|
+
} = event;
|
|
85
|
+
const targetElement = target;
|
|
86
|
+
if (calendarContainerRef.current && event && event.key && event.key === 'Escape') {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
targetElement.focus();
|
|
89
|
+
if (showCalendarValueInitial) {
|
|
90
|
+
if (targetElement.id !== 'valueInitial') {
|
|
91
|
+
inputInitialRef.current?.focus();
|
|
92
|
+
}
|
|
84
93
|
setShowCalendarValueInitial(false);
|
|
94
|
+
}
|
|
95
|
+
if (showCalendarValueFinal) {
|
|
96
|
+
if (targetElement.id !== 'valueFinal') {
|
|
97
|
+
inputFinalRef.current?.focus();
|
|
98
|
+
}
|
|
99
|
+
setShowCalendarValueFinal(false);
|
|
100
|
+
}
|
|
101
|
+
if (showPeriodSelection) {
|
|
102
|
+
setShowPeriodSelection(false);
|
|
103
|
+
inputFinalRef.current?.focus();
|
|
85
104
|
setShowCalendarValueFinal(false);
|
|
86
105
|
}
|
|
87
106
|
}
|
|
107
|
+
if (calendarContainerRef.current && event && event.key && event.key === 'Tab') {
|
|
108
|
+
const buttonForNavigateCalendar = calendarContainerRef.current?.getElementsByClassName('navbutton');
|
|
109
|
+
const datePicked = calendarContainerRef.current?.getElementsByClassName('-selectedday');
|
|
110
|
+
const buttonDatePicked = datePicked[0].firstChild;
|
|
111
|
+
const buttonsForFocus = Array.from([...buttonForNavigateCalendar, buttonDatePicked]);
|
|
112
|
+
const firstElement = buttonsForFocus[0];
|
|
113
|
+
const lastElement = buttonsForFocus[buttonsForFocus.length - 1];
|
|
114
|
+
const calendarOpenedIsInitial = calendarContainerRef.current.id === 'valueInitial';
|
|
115
|
+
if (!event.shiftKey && showCalendarValueInitial && document.activeElement === inputInitialRef.current) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
firstElement.focus();
|
|
118
|
+
}
|
|
119
|
+
if (event.shiftKey && calendarOpenedIsInitial && document.activeElement === firstElement) {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
inputInitialRef.current?.focus();
|
|
122
|
+
}
|
|
123
|
+
if (!event.shiftKey && calendarOpenedIsInitial && document.activeElement === lastElement) {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
inputFinalRef.current?.focus();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
event.stopPropagation();
|
|
129
|
+
};
|
|
130
|
+
const keepPositionCalendarByScroll = () => {
|
|
131
|
+
const inputDateDimensions = inputContainerRef.current?.getBoundingClientRect();
|
|
132
|
+
const positionTop = inputDateDimensions && inputDateDimensions.bottom;
|
|
133
|
+
if (dropdownCalendarContainer && dropdownCalendarContainer.current && inputDateDimensions) {
|
|
134
|
+
dropdownCalendarContainer.current.style.top = String(positionTop).concat('px');
|
|
135
|
+
}
|
|
88
136
|
};
|
|
89
137
|
(0, _react.useEffect)(() => {
|
|
90
138
|
window.addEventListener('resize', onScreenResize);
|
|
91
|
-
document.addEventListener('
|
|
92
|
-
document.addEventListener('
|
|
139
|
+
document.addEventListener('scroll', keepPositionCalendarByScroll);
|
|
140
|
+
document.getElementById('modal-dialog-content')?.addEventListener('scroll', keepPositionCalendarByScroll);
|
|
93
141
|
if (inputContainerRef.current) onScreenResize();
|
|
142
|
+
if (inputInitialRef && inputInitialRef.current) inputInitialRef.current.id = idValueInitial;
|
|
143
|
+
if (inputFinalRef && inputFinalRef.current) inputFinalRef.current.id = idValueFinal;
|
|
94
144
|
return () => {
|
|
95
145
|
window.removeEventListener('resize', onScreenResize);
|
|
96
|
-
document.removeEventListener('
|
|
97
|
-
document.removeEventListener('
|
|
146
|
+
document.removeEventListener('scroll', keepPositionCalendarByScroll);
|
|
147
|
+
document.getElementById('modal-dialog-content')?.removeEventListener('scroll', keepPositionCalendarByScroll);
|
|
98
148
|
};
|
|
99
149
|
}, []);
|
|
150
|
+
(0, _react.useEffect)(() => {
|
|
151
|
+
document.addEventListener('keydown', onKeyDownPress);
|
|
152
|
+
return () => {
|
|
153
|
+
document.removeEventListener('keydown', onKeyDownPress);
|
|
154
|
+
};
|
|
155
|
+
}, [showCalendarValueFinal, showCalendarValueInitial, showPeriodSelection, calendarContainerRef.current]);
|
|
156
|
+
(0, _react.useEffect)(() => {
|
|
157
|
+
if (valueFinal && valueInitial && (0, _moment.default)(valueFinal).isBefore((0, _moment.default)(valueInitial))) {
|
|
158
|
+
setValueInitial(valueFinal);
|
|
159
|
+
setValueFinal(valueInitial);
|
|
160
|
+
} else if (props.onChange) {
|
|
161
|
+
const initial = valueInitial ? valueInitial.format('YYYY-MM-DD') : '';
|
|
162
|
+
const final = valueFinal ? valueFinal.format('YYYY-MM-DD') : '';
|
|
163
|
+
props.onChange(undefined, '', {
|
|
164
|
+
initial,
|
|
165
|
+
final
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}, [valueInitial, valueFinal]);
|
|
100
169
|
(0, _react.useEffect)(() => {
|
|
101
170
|
if (props.value && !((0, _moment.default)(props.value.initial).isSame(valueInitial) || (0, _moment.default)(props.value.final).isSame(valueFinal))) {
|
|
102
171
|
const {
|
|
@@ -117,17 +186,62 @@ const PeriodPicker = props => {
|
|
|
117
186
|
}, [props.value]);
|
|
118
187
|
const openCalendar = calendarName => {
|
|
119
188
|
if (calendarName === 'valueInitial') {
|
|
189
|
+
setCurrentTypeDate('valueInitial');
|
|
120
190
|
setShowCalendarValueFinal(false);
|
|
121
|
-
|
|
122
|
-
|
|
191
|
+
if (!showCalendarValueInitial) {
|
|
192
|
+
inputInitialRef.current?.focus();
|
|
193
|
+
if (showCalendarInDialog) {
|
|
194
|
+
setTimeout(() => {
|
|
195
|
+
currentDateButtonRef.current?.focus();
|
|
196
|
+
}, 100);
|
|
197
|
+
}
|
|
198
|
+
setShowCalendarValueInitial(true);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (calendarName === 'valueFinal') {
|
|
202
|
+
setCurrentTypeDate('valueFinal');
|
|
123
203
|
setShowCalendarValueInitial(false);
|
|
124
|
-
|
|
204
|
+
if (!showCalendarValueFinal) {
|
|
205
|
+
inputFinalRef.current?.focus();
|
|
206
|
+
if (showCalendarInDialog) {
|
|
207
|
+
setTimeout(() => {
|
|
208
|
+
currentDateButtonRef.current?.focus();
|
|
209
|
+
}, 100);
|
|
210
|
+
}
|
|
211
|
+
setShowCalendarValueFinal(true);
|
|
212
|
+
}
|
|
125
213
|
}
|
|
126
|
-
setShowPeriodSelection(false);
|
|
127
214
|
if (inputContainerRef.current) {
|
|
128
215
|
setInputDimensions(inputContainerRef.current.getBoundingClientRect());
|
|
129
216
|
}
|
|
130
217
|
};
|
|
218
|
+
const closeCalendar = calendarName => {
|
|
219
|
+
if (calendarName === 'valueInitial') {
|
|
220
|
+
inputInitialRef.current?.focus();
|
|
221
|
+
}
|
|
222
|
+
if (calendarName === 'valueFinal') {
|
|
223
|
+
inputFinalRef.current?.focus();
|
|
224
|
+
}
|
|
225
|
+
setShowCalendarValueInitial(false);
|
|
226
|
+
setShowCalendarValueFinal(false);
|
|
227
|
+
};
|
|
228
|
+
const onCloseDateDialog = calendarName => {
|
|
229
|
+
setTimeout(() => {
|
|
230
|
+
if (calendarName === 'valueInitial') {
|
|
231
|
+
inputInitialRef.current?.focus();
|
|
232
|
+
setShowCalendarValueInitial(false);
|
|
233
|
+
}
|
|
234
|
+
if (calendarName === 'valueFinal') {
|
|
235
|
+
inputFinalRef.current?.focus();
|
|
236
|
+
setShowCalendarValueFinal(false);
|
|
237
|
+
}
|
|
238
|
+
if (calendarName === 'periodSelection') {
|
|
239
|
+
setShowPeriodSelection(false);
|
|
240
|
+
inputFinalRef.current?.focus();
|
|
241
|
+
setShowCalendarValueFinal(false);
|
|
242
|
+
}
|
|
243
|
+
}, 100);
|
|
244
|
+
};
|
|
131
245
|
const onInputFocus = e => {
|
|
132
246
|
const {
|
|
133
247
|
name
|
|
@@ -210,26 +324,29 @@ const PeriodPicker = props => {
|
|
|
210
324
|
} = props;
|
|
211
325
|
return disabled || onDenied && (onDenied.disabled || onDenied.hideContent);
|
|
212
326
|
};
|
|
213
|
-
const getButtonOpen = () => {
|
|
327
|
+
const getButtonOpen = (0, _react.useCallback)(() => {
|
|
214
328
|
if (!showButtonOpen) return null;
|
|
215
329
|
return /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
216
330
|
key: "button-open",
|
|
217
331
|
boxShadow: false,
|
|
332
|
+
disabled: shouldDisable(),
|
|
333
|
+
customClass: "calendar-button",
|
|
218
334
|
icon: /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
219
335
|
name: "calendar"
|
|
220
336
|
}),
|
|
221
337
|
onClick: () => {
|
|
222
|
-
|
|
223
|
-
|
|
338
|
+
if (showCalendarValueFinal || showCalendarValueInitial) {
|
|
339
|
+
closeCalendar(currentTypeDate);
|
|
340
|
+
} else {
|
|
341
|
+
openCalendar(currentTypeDate);
|
|
342
|
+
}
|
|
224
343
|
},
|
|
225
|
-
customClass: "calendar-button",
|
|
226
344
|
tabIndex: -1,
|
|
227
345
|
targetRef: ref => {
|
|
228
346
|
buttonOpenRef.current = ref;
|
|
229
|
-
}
|
|
230
|
-
disabled: shouldDisable()
|
|
347
|
+
}
|
|
231
348
|
});
|
|
232
|
-
};
|
|
349
|
+
}, [showCalendarValueFinal, showCalendarValueInitial]);
|
|
233
350
|
const getPeriodSelection = (valuePeriodSelectionAux, setPeriodDates) => /*#__PURE__*/_react.default.createElement(_PeriodList.default, {
|
|
234
351
|
selected: valuePeriodSelectionAux,
|
|
235
352
|
handleOnSelect: setPeriodDates
|
|
@@ -242,31 +359,39 @@ const PeriodPicker = props => {
|
|
|
242
359
|
setInputDimensions(inputContainerRef.current.getBoundingClientRect());
|
|
243
360
|
}
|
|
244
361
|
};
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
362
|
+
const closePeriodSelection = () => {
|
|
363
|
+
setShowPeriodSelection(false);
|
|
364
|
+
inputFinalRef.current?.focus();
|
|
365
|
+
setShowCalendarValueFinal(false);
|
|
366
|
+
};
|
|
367
|
+
const getButtonSelectPeriod = (0, _react.useCallback)(() => {
|
|
368
|
+
return /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
369
|
+
key: "button-select-period",
|
|
370
|
+
disabled: shouldDisable(),
|
|
371
|
+
tabIndex: -1,
|
|
372
|
+
customClass: "calendar-button",
|
|
373
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
374
|
+
name: "more1"
|
|
375
|
+
}),
|
|
376
|
+
onBlur: () => setTimeout(() => setShowPeriodSelection(false), 100),
|
|
377
|
+
onClick: () => !showPeriodSelection ? openPeriodSelecion() : closePeriodSelection(),
|
|
378
|
+
targetRef: ref => {
|
|
379
|
+
buttonSelectPeriodRef.current = ref;
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
}, [showPeriodSelection]);
|
|
260
383
|
const getCalendar = (value, calendarColorStyleCalendar, valueDateName) => /*#__PURE__*/_react.default.createElement(_calendar.default, {
|
|
384
|
+
colorStyle: calendarColorStyleCalendar,
|
|
261
385
|
currentDate: value !== undefined ? (0, _moment.default)(value) : (0, _moment.default)(),
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
target: {
|
|
265
|
-
name: valueDateName
|
|
266
|
-
}
|
|
267
|
-
}, date);
|
|
386
|
+
calendarContainer: ref => {
|
|
387
|
+
calendarContainerRef.current = ref;
|
|
268
388
|
},
|
|
269
|
-
|
|
389
|
+
onDateChange: date => setValue({
|
|
390
|
+
target: {
|
|
391
|
+
name: valueDateName
|
|
392
|
+
}
|
|
393
|
+
}, date),
|
|
394
|
+
currentDateButton: buttonElement => currentDateButtonRef.current = buttonElement
|
|
270
395
|
});
|
|
271
396
|
const setPeriodDates = (selected, dates) => {
|
|
272
397
|
if (selected === 'custom') {
|
|
@@ -283,64 +408,69 @@ const PeriodPicker = props => {
|
|
|
283
408
|
if (shouldCloseOnSelect) {
|
|
284
409
|
setShowPeriodSelection(false);
|
|
285
410
|
}
|
|
411
|
+
inputFinalRef.current?.focus();
|
|
412
|
+
setShowCalendarValueFinal(false);
|
|
286
413
|
};
|
|
287
|
-
const
|
|
414
|
+
const getCalendarInitial = () => {
|
|
288
415
|
if (onDenied && onDenied.readOnly) return null;
|
|
416
|
+
if (calendarContainerRef && calendarContainerRef.current) calendarContainerRef.current.id = 'valueInitial';
|
|
289
417
|
if (showCalendarInDialog) {
|
|
290
418
|
return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
|
|
419
|
+
handlerClose: () => onCloseDateDialog('valueInitial'),
|
|
291
420
|
dialogSize: dialogSize,
|
|
292
421
|
onOpenChange: setShowCalendarValueInitial
|
|
293
422
|
}, getCalendar(valueInitial, calendarColorStyle, 'valueInitial'));
|
|
294
423
|
}
|
|
295
424
|
return /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
width: inputDimensions ? inputDimensions.width : '',
|
|
425
|
+
containerRef: wrapperBaseInputPeriodRef,
|
|
426
|
+
showButtonOpen: showButtonOpen,
|
|
427
|
+
inputDimensions: inputDimensions,
|
|
300
428
|
dropdownRef: el => {
|
|
301
429
|
dropdownCalendarContainer.current = el;
|
|
302
430
|
}
|
|
303
431
|
}, getCalendar(valueInitial, calendarColorStyle, 'valueInitial'));
|
|
304
432
|
};
|
|
305
|
-
const
|
|
433
|
+
const getCalendarFinal = () => {
|
|
306
434
|
if (onDenied && onDenied.readOnly) return null;
|
|
435
|
+
if (calendarContainerRef && calendarContainerRef.current) calendarContainerRef.current.id = 'valueFinal';
|
|
307
436
|
if (showCalendarInDialog) {
|
|
308
437
|
return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
|
|
438
|
+
handlerClose: () => onCloseDateDialog('valueFinal'),
|
|
309
439
|
dialogSize: dialogSize,
|
|
310
440
|
onOpenChange: setShowCalendarValueFinal
|
|
311
441
|
}, getCalendar(valueFinal, calendarColorStyle, 'valueFinal'));
|
|
312
442
|
}
|
|
313
443
|
return /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
width: inputDimensions ? inputDimensions.width : '',
|
|
444
|
+
containerRef: wrapperBaseInputPeriodRef,
|
|
445
|
+
showButtonOpen: showButtonOpen,
|
|
446
|
+
inputDimensions: inputDimensions,
|
|
318
447
|
dropdownRef: el => {
|
|
319
448
|
dropdownCalendarContainer.current = el;
|
|
320
449
|
}
|
|
321
450
|
}, getCalendar(valueFinal, calendarColorStyle, 'valueFinal'));
|
|
322
451
|
};
|
|
323
|
-
const
|
|
452
|
+
const getPeriodOfDatesSelection = () => {
|
|
324
453
|
if (showCalendarInDialog) {
|
|
325
454
|
return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
|
|
455
|
+
handlerClose: () => onCloseDateDialog('periodSelection'),
|
|
326
456
|
dialogSize: dialogSize,
|
|
327
457
|
onOpenChange: setShowPeriodSelection
|
|
328
458
|
}, getPeriodSelection(valuePeriodSelection, setPeriodDates));
|
|
329
459
|
}
|
|
330
460
|
return /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
width: inputDimensions ? inputDimensions.width : '',
|
|
461
|
+
containerRef: wrapperBaseInputPeriodRef,
|
|
462
|
+
showButtonOpen: showButtonOpen,
|
|
463
|
+
inputDimensions: inputDimensions,
|
|
335
464
|
dropdownRef: el => {
|
|
336
|
-
|
|
465
|
+
dropdownCalendarContainer.current = el;
|
|
337
466
|
}
|
|
338
467
|
}, getPeriodSelection(valuePeriodSelection, setPeriodDates));
|
|
339
468
|
};
|
|
340
469
|
if (onDenied && onDenied.unvisible) return null;
|
|
341
|
-
|
|
470
|
+
const component = () => /*#__PURE__*/_react.default.createElement("div", {
|
|
342
471
|
ref: wrapperBaseInputPeriodRef,
|
|
343
|
-
|
|
472
|
+
onBlur: onBlurWithoutWrapper,
|
|
473
|
+
className: "input-base-component datepicker-period-container"
|
|
344
474
|
}, props.label && /*#__PURE__*/_react.default.createElement("div", {
|
|
345
475
|
className: "labelcontainer"
|
|
346
476
|
}, /*#__PURE__*/_react.default.createElement(_textContent.default, {
|
|
@@ -376,6 +506,7 @@ const PeriodPicker = props => {
|
|
|
376
506
|
}))}`,
|
|
377
507
|
ref: inputContainerRef
|
|
378
508
|
}, /*#__PURE__*/_react.default.createElement(_BaseMask.default, {
|
|
509
|
+
gridLayout: undefined,
|
|
379
510
|
permissionAttr: props.permissionAttr,
|
|
380
511
|
name: "valueInitial",
|
|
381
512
|
value: !valueInitial ? '' : (0, _moment.default)(valueInitial).format('DD/MM/YYYY'),
|
|
@@ -397,6 +528,7 @@ const PeriodPicker = props => {
|
|
|
397
528
|
name: "arrow_right",
|
|
398
529
|
customClass: "separation_icon"
|
|
399
530
|
}), /*#__PURE__*/_react.default.createElement(_BaseMask.default, {
|
|
531
|
+
gridLayout: undefined,
|
|
400
532
|
permissionAttr: props.permissionAttr,
|
|
401
533
|
name: "valueFinal",
|
|
402
534
|
value: !valueFinal ? '' : (0, _moment.default)(valueFinal).format('DD/MM/YYYY'),
|
|
@@ -412,12 +544,16 @@ const PeriodPicker = props => {
|
|
|
412
544
|
},
|
|
413
545
|
handlerSetOnDenied: denied => setOnDenied(denied),
|
|
414
546
|
required: props.required
|
|
415
|
-
}), getButtonOpen(), getButtonSelectPeriod()), showCalendarValueInitial &&
|
|
547
|
+
}), getButtonOpen(), getButtonSelectPeriod()), showCalendarValueInitial && getCalendarInitial(), showCalendarValueFinal && getCalendarFinal(), showPeriodSelection && getPeriodOfDatesSelection(), /*#__PURE__*/_react.default.createElement(_hint.default, {
|
|
416
548
|
visible: !!hint && hintPosition === 'below',
|
|
417
549
|
customClass: "hint",
|
|
418
550
|
description: hint
|
|
419
551
|
}), /*#__PURE__*/_react.default.createElement(_errorMessage.ErrorMessage, {
|
|
420
552
|
messages: props.errorMessages
|
|
421
553
|
}));
|
|
554
|
+
return !gridLayout ? component() : /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|
|
555
|
+
customClass: "-withinput",
|
|
556
|
+
cols: gridLayout
|
|
557
|
+
}, component());
|
|
422
558
|
};
|
|
423
559
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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;
|
|
@@ -62,6 +63,7 @@ interface IPeriodPickerProps {
|
|
|
62
63
|
hintPosition?: 'below' | 'onLabelRight';
|
|
63
64
|
onBlur?: (e: CustomInputEvent) => void;
|
|
64
65
|
onFocus?: (e: CustomInputEvent) => void;
|
|
66
|
+
gridLayout?: string;
|
|
65
67
|
themePopover?: 'light' | 'dark';
|
|
66
68
|
popoverAlign?: 'right' | 'left';
|
|
67
69
|
}
|
|
@@ -70,4 +72,4 @@ interface IPeriodListProps {
|
|
|
70
72
|
selected?: string;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
export { ChangeInputPeriodEvent, DateTypes, IDialogProps, IPeriodDropdownProps, IPeriodListProps, IPeriodOptions, IPeriodPickerProps };
|
|
75
|
+
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:
|
|
20
|
+
className: `actionbuttonsselect ${customClassForSideButtons}`
|
|
20
21
|
}, showClearButton && /*#__PURE__*/_react.default.createElement("button", {
|
|
21
22
|
disabled: disabled,
|
|
22
23
|
tabIndex: -1,
|
|
@@ -37,7 +37,8 @@ const Dropdown = props => {
|
|
|
37
37
|
searchOnDropdown,
|
|
38
38
|
handleOnKeydown,
|
|
39
39
|
searchNotFoundText,
|
|
40
|
-
idKey
|
|
40
|
+
idKey,
|
|
41
|
+
selectFieldRef
|
|
41
42
|
} = props;
|
|
42
43
|
const [dropdownDynamicStyles, setDropdownDynamicStyles] = (0, _react.useState)(helper.returnDropdownDynamicStyles(_objectSpread({}, props)));
|
|
43
44
|
(0, _react.useEffect)(() => {
|
|
@@ -48,7 +49,8 @@ const Dropdown = props => {
|
|
|
48
49
|
return /*#__PURE__*/_react.default.createElement(_Popup.default, {
|
|
49
50
|
align: "left",
|
|
50
51
|
leftPosition: dropdownDynamicStyles.left,
|
|
51
|
-
topPosition: dropdownDynamicStyles.top
|
|
52
|
+
topPosition: dropdownDynamicStyles.top,
|
|
53
|
+
targetRef: selectFieldRef?.current
|
|
52
54
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
53
55
|
className: "select-dropdown",
|
|
54
56
|
ref: dropdownRef,
|
|
@@ -8,6 +8,6 @@ import '../../../@types/Period.js';
|
|
|
8
8
|
import '../../../internals/types.js';
|
|
9
9
|
import '../../../@types/Position.js';
|
|
10
10
|
|
|
11
|
-
declare const Selecteds: ({ currents, descriptionKey, idKey, handlerOnUnselect, }: ISelectedsMultipleProps) => JSX.Element;
|
|
11
|
+
declare const Selecteds: ({ currents, descriptionKey, idKey, disabled, handlerOnUnselect, }: ISelectedsMultipleProps) => JSX.Element;
|
|
12
12
|
|
|
13
13
|
export { Selecteds as default };
|
|
@@ -11,12 +11,14 @@ const Selecteds = _ref => {
|
|
|
11
11
|
currents,
|
|
12
12
|
descriptionKey,
|
|
13
13
|
idKey,
|
|
14
|
+
disabled,
|
|
14
15
|
handlerOnUnselect
|
|
15
16
|
} = _ref;
|
|
16
17
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currents.map(selected => /*#__PURE__*/_react.default.createElement("div", {
|
|
17
|
-
className:
|
|
18
|
+
className: `selecteditem ${disabled ? '-disabled' : ''}`,
|
|
18
19
|
key: `selected-${selected[idKey]}`
|
|
19
20
|
}, typeof descriptionKey === 'string' ? selected[descriptionKey] : descriptionKey(selected), /*#__PURE__*/_react.default.createElement("button", {
|
|
21
|
+
disabled: disabled,
|
|
20
22
|
className: "close",
|
|
21
23
|
tabIndex: -1,
|
|
22
24
|
onClick: () => handlerOnUnselect(selected[idKey])
|
|
@@ -29,7 +29,12 @@ const MultipleSelect = props => {
|
|
|
29
29
|
showClearButton,
|
|
30
30
|
rightElements = [],
|
|
31
31
|
hint,
|
|
32
|
-
hintPosition = 'below'
|
|
32
|
+
hintPosition = 'below',
|
|
33
|
+
customClassForLabel,
|
|
34
|
+
customClassForWrapper,
|
|
35
|
+
customClassForInputContent,
|
|
36
|
+
customClassForSideButtons,
|
|
37
|
+
disabled = false
|
|
33
38
|
} = props;
|
|
34
39
|
const [dataCombo, setDataCombo] = (0, _react.useState)(dataSource);
|
|
35
40
|
const [currents, setCurrents] = (0, _react.useState)([]);
|
|
@@ -166,7 +171,7 @@ const MultipleSelect = props => {
|
|
|
166
171
|
const setOnDenied = denied => {
|
|
167
172
|
setOnDeniedSelect(denied);
|
|
168
173
|
};
|
|
169
|
-
const shouldDisable = () =>
|
|
174
|
+
const shouldDisable = () => disabled || onDenied && (onDenied.disabled || onDenied.hideContent);
|
|
170
175
|
const shouldBeReadOnly = () => props.readOnly || onDenied && onDenied.readOnly;
|
|
171
176
|
(0, _react.useEffect)(() => {
|
|
172
177
|
window.addEventListener('resize', onScreenResize);
|
|
@@ -233,8 +238,9 @@ const MultipleSelect = props => {
|
|
|
233
238
|
},
|
|
234
239
|
onClick: onFocus,
|
|
235
240
|
onKeyDown: onInputKeyDown,
|
|
236
|
-
|
|
237
|
-
|
|
241
|
+
customClassForLabel: customClassForLabel,
|
|
242
|
+
customClassForWrapper: `selectwrapper ${(props.readOnly || shouldDisable() || shouldBeReadOnly()) && ' -undigitable'} ${customClassForWrapper}`,
|
|
243
|
+
customClassForInputContent: `multiselect ${customClassForInputContent}`,
|
|
238
244
|
inputBaseRef: r => {
|
|
239
245
|
selectWrapper.current = r;
|
|
240
246
|
},
|
|
@@ -248,7 +254,8 @@ const MultipleSelect = props => {
|
|
|
248
254
|
if (shouldDisable()) return null;
|
|
249
255
|
return onClearClick();
|
|
250
256
|
},
|
|
251
|
-
handlerOpenClose: onOpenClose
|
|
257
|
+
handlerOpenClose: onOpenClose,
|
|
258
|
+
customClassForSideButtons: customClassForSideButtons
|
|
252
259
|
})]
|
|
253
260
|
}), /*#__PURE__*/_react.default.createElement(_Selecteds.default, _extends({}, props, {
|
|
254
261
|
currents: currents,
|
|
@@ -35,7 +35,11 @@ const SimpleSelect = props => {
|
|
|
35
35
|
allOptions = undefined,
|
|
36
36
|
showClearButton = false,
|
|
37
37
|
searchNotFoundText,
|
|
38
|
-
rightElements = []
|
|
38
|
+
rightElements = [],
|
|
39
|
+
customClassForWrapper,
|
|
40
|
+
customClassForInputContent,
|
|
41
|
+
customClassForLabel,
|
|
42
|
+
customClassForSideButtons
|
|
39
43
|
} = props;
|
|
40
44
|
const descriptionKeyIsString = typeof descriptionKey === 'string';
|
|
41
45
|
const dataSourceWithAllOptions = allOptions ? [{
|
|
@@ -262,8 +266,9 @@ const SimpleSelect = props => {
|
|
|
262
266
|
},
|
|
263
267
|
onClick: onFocus,
|
|
264
268
|
onKeyDown: onInputKeyDown,
|
|
265
|
-
|
|
266
|
-
|
|
269
|
+
customClassForLabel: customClassForLabel,
|
|
270
|
+
customClassForWrapper: `selectwrapper ${(undigitable || searchOnDropdown || shouldBeReadOnly()) && ' -undigitable'} ${customClassForWrapper}`,
|
|
271
|
+
customClassForInputContent: `multiselect ${customClassForInputContent}`,
|
|
267
272
|
inputBaseRef: r => {
|
|
268
273
|
selectWrapper.current = r;
|
|
269
274
|
},
|
|
@@ -277,7 +282,8 @@ const SimpleSelect = props => {
|
|
|
277
282
|
if (shouldDisable()) return null;
|
|
278
283
|
return onClearClick();
|
|
279
284
|
},
|
|
280
|
-
handlerOpenClose: onOpenClose
|
|
285
|
+
handlerOpenClose: onOpenClose,
|
|
286
|
+
customClassForSideButtons: customClassForSideButtons
|
|
281
287
|
})]
|
|
282
288
|
})), opened && /*#__PURE__*/_react.default.createElement(_Dropdown.default, _extends({}, props, {
|
|
283
289
|
opened: opened,
|
|
@@ -50,6 +50,10 @@ interface ISimpleSelectProps {
|
|
|
50
50
|
onFocus?: () => void;
|
|
51
51
|
allOptions?: AllOptions;
|
|
52
52
|
inputRef?: MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null> | ((ref: HTMLInputElement | HTMLTextAreaElement | null) => void);
|
|
53
|
+
customClassForWrapper?: string;
|
|
54
|
+
customClassForInputContent?: string;
|
|
55
|
+
customClassForLabel?: string;
|
|
56
|
+
customClassForSideButtons?: string;
|
|
53
57
|
rightElements?: JSX.Element[];
|
|
54
58
|
hintPosition?: 'below' | 'onLabelRight';
|
|
55
59
|
themePopover?: 'light' | 'dark';
|
|
@@ -99,6 +103,7 @@ interface IMultipleSelectProps extends Omit<ISimpleSelectProps, 'idKey' | 'value
|
|
|
99
103
|
popoverAlign?: 'right' | 'left';
|
|
100
104
|
}
|
|
101
105
|
interface ISelectedsMultipleProps {
|
|
106
|
+
disabled?: boolean;
|
|
102
107
|
idKey: string;
|
|
103
108
|
descriptionKey: DescriptionKey;
|
|
104
109
|
currents: DataCombo[];
|
package/lib/inputs/types.d.ts
CHANGED
|
@@ -137,6 +137,7 @@ interface IActionButtonsSelectProps {
|
|
|
137
137
|
dropDownOpened: boolean;
|
|
138
138
|
showClearButton?: boolean;
|
|
139
139
|
disabled?: boolean;
|
|
140
|
+
customClassForSideButtons?: string;
|
|
140
141
|
}
|
|
141
142
|
interface IButtonsProps {
|
|
142
143
|
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
|