linear-react-components-ui 1.1.25-beta.6 → 1.1.25-beta.7

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 (59) hide show
  1. package/lib/{BaseMask-78847f45.d.ts → BaseMask-0c14ef51.d.ts} +1 -1
  2. package/lib/{Cnpj-8366781f.d.ts → Cnpj-53bfd6ab.d.ts} +2 -1
  3. package/lib/{Cpf-3dfd54eb.d.ts → Cpf-019b21e0.d.ts} +2 -1
  4. package/lib/{Phone-1962c0f2.d.ts → Phone-2bb0b397.d.ts} +1 -1
  5. package/lib/{ZipCode-be9c5b3b.d.ts → ZipCode-09460e18.d.ts} +1 -1
  6. package/lib/index-19761a50.d.ts +26 -0
  7. package/lib/{index-6fcf446c.d.ts → index-208e7f62.d.ts} +20 -2
  8. package/lib/{index-02a27c19.d.ts → index-3b70931d.d.ts} +20 -2
  9. package/lib/index-4bda404f.d.ts +42 -0
  10. package/lib/{index-25b80f32.d.ts → index-7dfa8924.d.ts} +1 -1
  11. package/lib/{index-6f5c772d.d.ts → index-9e576346.d.ts} +1 -1
  12. package/lib/{index-696662fe.d.ts → index-afb7b5a9.d.ts} +1 -1
  13. package/lib/inputs2/checkboxfield/index.d.ts +2 -3
  14. package/lib/inputs2/checkboxfield/index.js +125 -32
  15. package/lib/inputs2/colorfield/index.d.ts +5 -6
  16. package/lib/inputs2/date/datefield/index.js +322 -34
  17. package/lib/inputs2/date/datefield/types.d.ts +3 -5
  18. package/lib/inputs2/date/dateperiodfield/index.js +587 -34
  19. package/lib/inputs2/date/dateperiodfield/types.d.ts +3 -5
  20. package/lib/inputs2/filefield/index.d.ts +5 -6
  21. package/lib/inputs2/index.d.ts +15 -18
  22. package/lib/inputs2/mask/BaseMask.d.ts +5 -6
  23. package/lib/inputs2/mask/Cnpj.d.ts +6 -7
  24. package/lib/inputs2/mask/Cnpj.js +21 -18
  25. package/lib/inputs2/mask/Cpf.d.ts +6 -7
  26. package/lib/inputs2/mask/Cpf.js +19 -12
  27. package/lib/inputs2/mask/Phone.d.ts +6 -7
  28. package/lib/inputs2/mask/ZipCode.d.ts +6 -7
  29. package/lib/inputs2/numberfield/currency.d.ts +4 -5
  30. package/lib/inputs2/numberfield/decimal.d.ts +4 -5
  31. package/lib/inputs2/numberfield/index.d.ts +4 -5
  32. package/lib/inputs2/numberfield/types.d.ts +4 -5
  33. package/lib/inputs2/radiofield/index.d.ts +1 -1
  34. package/lib/inputs2/radiofield/index.js +126 -25
  35. package/lib/inputs2/radiofield/types.d.ts +4 -6
  36. package/lib/inputs2/selectfield/index.d.ts +1 -1
  37. package/lib/inputs2/selectfield/index.js +502 -35
  38. package/lib/inputs2/selectfield/types.d.ts +6 -8
  39. package/lib/inputs2/textareafield/index.d.ts +3 -4
  40. package/lib/inputs2/textareafield/index.js +154 -30
  41. package/lib/inputs2/textfield/index.d.ts +4 -5
  42. package/lib/inputs2/textfield/index.js +120 -30
  43. package/package.json +1 -1
  44. package/lib/index-053f615b.d.ts +0 -26
  45. package/lib/index-7159df18.d.ts +0 -21
  46. package/lib/inputs2/checkboxfield/base.d.ts +0 -29
  47. package/lib/inputs2/checkboxfield/base.js +0 -134
  48. package/lib/inputs2/date/datefield/base.d.ts +0 -13
  49. package/lib/inputs2/date/datefield/base.js +0 -330
  50. package/lib/inputs2/date/dateperiodfield/base.d.ts +0 -13
  51. package/lib/inputs2/date/dateperiodfield/base.js +0 -595
  52. package/lib/inputs2/radiofield/base.d.ts +0 -12
  53. package/lib/inputs2/radiofield/base.js +0 -156
  54. package/lib/inputs2/selectfield/base.d.ts +0 -11
  55. package/lib/inputs2/selectfield/base.js +0 -513
  56. package/lib/inputs2/textareafield/base.d.ts +0 -26
  57. package/lib/inputs2/textareafield/base.js +0 -166
  58. package/lib/inputs2/textfield/base.d.ts +0 -26
  59. package/lib/inputs2/textfield/base.js +0 -131
@@ -1,595 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.InputBase = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
- var _reactImask = require("react-imask");
10
- var _reactDom = require("react-dom");
11
- var _moment = _interopRequireDefault(require("moment"));
12
- var _hint = _interopRequireDefault(require("../../../hint"));
13
- var _icons = _interopRequireDefault(require("../../../icons"));
14
- var _tooltip = require("../../../tooltip");
15
- var _helpers = require("../../../form2/helpers");
16
- var _types = require("../types");
17
- var BaseDate = _interopRequireWildcard(require("../base"));
18
- var _helpers2 = require("../helpers");
19
- var _triggers = require("./triggers");
20
- var _calendarbox = require("./calendarbox");
21
- var _context = require("./context");
22
- const _excluded = ["label", "errors", "initialName", "finalName", "customClass", "customClassLabel", "customClassWrapper", "customClassInputContainer", "labelUppercase", "undigitable", "skeletonize", "hintPosition", "themePopover", "popoverAlign", "showCalendarButton", "textAlign", "openCalendarOnFocus", "shouldCloseOnSelect", "showPredefinedPeriodsButton", "showClearDateButton", "placeholder", "returnValueType", "tooltip", "tooltipPosition", "tooltipWidth", "disabled", "readOnly"];
23
- /* eslint-disable @typescript-eslint/no-use-before-define */
24
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
25
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
27
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
28
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
29
- const InputBase = exports.InputBase = /*#__PURE__*/_react.default.forwardRef((props, __) => {
30
- var _selectedDate$inicial, _selectedDate$final, _props$hint;
31
- const {
32
- label,
33
- errors,
34
- initialName = 'inicial',
35
- finalName = 'final',
36
- customClass = '',
37
- customClassLabel = '',
38
- customClassWrapper = '',
39
- customClassInputContainer = '',
40
- labelUppercase = false,
41
- undigitable = false,
42
- skeletonize = false,
43
- hintPosition = 'below',
44
- themePopover = 'light',
45
- popoverAlign = 'left',
46
- showCalendarButton = true,
47
- textAlign = 'left',
48
- openCalendarOnFocus = true,
49
- shouldCloseOnSelect = true,
50
- showPredefinedPeriodsButton = true,
51
- showClearDateButton = true,
52
- placeholder = _helpers2.TOKEN_PTBR_FORMAT,
53
- returnValueType = 'default',
54
- tooltip,
55
- tooltipPosition,
56
- tooltipWidth,
57
- disabled,
58
- readOnly
59
- } = props,
60
- rest = _objectWithoutProperties(props, _excluded);
61
- const [selectedDate, setSelectedDate] = _react.default.useState({
62
- inicial: null,
63
- final: null
64
- });
65
- const [calendarBoxOpen, setCalendarBoxOpen] = _react.default.useState(false);
66
- const [activeDescendant, setActiveDescendant] = _react.default.useState((0, _moment.default)().format(_helpers2.TOKEN_ISO_FORMAT));
67
- const [calendarDisplayDate, setCalendarDisplayDate] = _react.default.useState((0, _moment.default)());
68
- const calendarRef = _react.default.useRef(null);
69
- const inputRootRef = _react.default.useRef(null);
70
- const finalInputRef = _react.default.useRef(null);
71
- const initialInputRef = _react.default.useRef(null);
72
- const dateContainerRef = _react.default.useRef(null);
73
- const initialInputName = _react.default.useMemo(() => String(props.name).concat('.').concat(initialName), [props.name, initialName]);
74
- const finalInputName = _react.default.useMemo(() => String(props.name).concat('.').concat(finalName), [props.name, finalName]);
75
- const {
76
- value: initialMaskedValue,
77
- setValue: setInitialMaskValue,
78
- unmaskedValue: initialUnmaskedValue
79
- } = (0, _reactImask.useIMask)({
80
- mask: _helpers2.TOKEN_MASK,
81
- lazy: false,
82
- placeholderChar: '_'
83
- }, {
84
- ref: initialInputRef,
85
- defaultValue: (_selectedDate$inicial = selectedDate.inicial) === null || _selectedDate$inicial === void 0 ? void 0 : _selectedDate$inicial.format(_helpers2.TOKEN_PTBR_FORMAT),
86
- onComplete: value => {
87
- const date = (0, _moment.default)(value, _helpers2.TOKEN_PTBR_FORMAT);
88
- if (date.isValid()) {
89
- handleChangeUpdateDateState({
90
- date,
91
- inputType: 'initial',
92
- typing: true
93
- });
94
- }
95
- }
96
- });
97
- const {
98
- value: finalMaskedValue,
99
- setValue: setFinalMaskValue,
100
- unmaskedValue: finalUnmaskedValue
101
- } = (0, _reactImask.useIMask)({
102
- mask: _helpers2.TOKEN_MASK,
103
- lazy: false,
104
- placeholderChar: '_'
105
- }, {
106
- ref: finalInputRef,
107
- defaultValue: (_selectedDate$final = selectedDate.final) === null || _selectedDate$final === void 0 ? void 0 : _selectedDate$final.format(_helpers2.TOKEN_PTBR_FORMAT),
108
- onComplete: value => {
109
- const date = (0, _moment.default)(value, _helpers2.TOKEN_PTBR_FORMAT);
110
- if (date.isValid()) {
111
- handleChangeUpdateDateState({
112
- date,
113
- inputType: 'final',
114
- typing: true
115
- });
116
- }
117
- }
118
- });
119
- const hasLabel = !_lodash.default.isEmpty(props === null || props === void 0 ? void 0 : props.label);
120
- const hasHintMessages = Boolean((_props$hint = props.hint) === null || _props$hint === void 0 ? void 0 : _props$hint.length);
121
- const hasValidationErrors = Boolean(errors === null || errors === void 0 ? void 0 : errors.length);
122
- const handleChangeSelectedDate = _react.default.useCallback(object => setSelectedDate(object), []);
123
- const handleChangeCalendarBoxState = _react.default.useCallback(value => setCalendarBoxOpen(value), []);
124
- const handleChangeActiveDescendant = _react.default.useCallback(value => setActiveDescendant(value), []);
125
- const handleChangeCalendarDisplayDate = _react.default.useCallback(value => setCalendarDisplayDate(value), []);
126
- const handleChangePreviousMonth = _react.default.useCallback(() => setCalendarDisplayDate(prevDisplayDate => prevDisplayDate.clone().subtract(1, 'month')), []);
127
- const handleChangeNextMonth = _react.default.useCallback(() => setCalendarDisplayDate(prevDisplayDate => prevDisplayDate.clone().add(1, 'month')), []);
128
- const handleNavigateWithDays = _react.default.useCallback(offset => {
129
- setCalendarDisplayDate(prevDisplayDate => {
130
- const daySelected = prevDisplayDate.clone().add(offset, 'day');
131
- handleChangeActiveDescendant(daySelected.format(_helpers2.TOKEN_ISO_FORMAT));
132
- return daySelected;
133
- });
134
- }, []);
135
- const handleNavigateWithWeeks = _react.default.useCallback(when => {
136
- setCalendarDisplayDate(prevDisplayDate => {
137
- let daySelected = prevDisplayDate;
138
- if (when === 'end') daySelected = prevDisplayDate.clone().endOf('week');
139
- if (when === 'start') daySelected = prevDisplayDate.clone().startOf('week');
140
- handleChangeActiveDescendant(daySelected.format(_helpers2.TOKEN_ISO_FORMAT));
141
- return daySelected;
142
- });
143
- }, []);
144
- const verifyPeriodSelectedIsValid = _react.default.useCallback(() => {
145
- const objectValue = props === null || props === void 0 ? void 0 : props.value;
146
- const isValidInitialValue = !_lodash.default.isEmpty(objectValue[initialName]);
147
- const isValidFinalValue = !_lodash.default.isEmpty(objectValue[finalName]);
148
- return isValidInitialValue && isValidFinalValue;
149
- }, [props === null || props === void 0 ? void 0 : props.value, initialName, finalName]);
150
- const handleOnClickClearSelectedPeriod = _react.default.useCallback(() => {
151
- var _props$onChange;
152
- (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
153
- target: {
154
- name: props.name,
155
- value: {
156
- [initialName]: '',
157
- [finalName]: ''
158
- }
159
- }
160
- });
161
- setSelectedDate(() => ({
162
- inicial: null,
163
- final: null
164
- }));
165
- setInitialMaskValue('');
166
- setFinalMaskValue('');
167
- handleChangeCalendarBoxState(false);
168
- }, [props.onChange]);
169
- const handleChangeUpdateDateState = _react.default.useCallback(params => {
170
- const {
171
- date,
172
- inputType,
173
- typing
174
- } = params;
175
- const rawDate = date.clone();
176
- const verifyDateRangeOrder = (initialDate, finalDate) => {
177
- const inicial = initialDate !== null && initialDate !== void 0 && initialDate.isAfter(finalDate) ? finalDate : initialDate;
178
- const final = initialDate !== null && initialDate !== void 0 && initialDate.isAfter(finalDate) ? initialDate : finalDate;
179
- return {
180
- inicial,
181
- final
182
- };
183
- };
184
- switch (inputType) {
185
- case 'initial':
186
- {
187
- var _props$onChange2;
188
- setSelectedDate(prevSelectedDate => {
189
- const {
190
- inicial,
191
- final
192
- } = verifyDateRangeOrder(rawDate, prevSelectedDate.final);
193
- const updatedState = {
194
- inicial,
195
- final
196
- };
197
- return updatedState;
198
- });
199
- const {
200
- inicial,
201
- final
202
- } = verifyDateRangeOrder(rawDate, selectedDate.final);
203
- (_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 ? void 0 : _props$onChange2.call(props, {
204
- target: {
205
- name: props.name,
206
- value: {
207
- [initialName]: returnValueType === 'default' ? inicial === null || inicial === void 0 ? void 0 : inicial.format(_helpers2.TOKEN_ISO_FORMAT) : inicial === null || inicial === void 0 ? void 0 : inicial.toISOString(),
208
- [finalName]: returnValueType === 'default' ? final === null || final === void 0 ? void 0 : final.format(_helpers2.TOKEN_ISO_FORMAT) : final === null || final === void 0 ? void 0 : final.toISOString()
209
- }
210
- }
211
- });
212
- requestAnimationFrame(() => {
213
- var _finalInputRef$curren, _finalInputRef$curren2;
214
- if (!typing) (_finalInputRef$curren = finalInputRef.current) === null || _finalInputRef$curren === void 0 ? void 0 : (_finalInputRef$curren2 = _finalInputRef$curren.focus) === null || _finalInputRef$curren2 === void 0 ? void 0 : _finalInputRef$curren2.call(_finalInputRef$curren);
215
- });
216
- break;
217
- }
218
- case 'final':
219
- {
220
- var _props$onChange3;
221
- setSelectedDate(prevSelectedDate => {
222
- const {
223
- inicial,
224
- final
225
- } = verifyDateRangeOrder(prevSelectedDate.inicial, rawDate);
226
- const updatedState = {
227
- inicial,
228
- final
229
- };
230
- return updatedState;
231
- });
232
- const {
233
- inicial,
234
- final
235
- } = verifyDateRangeOrder(selectedDate.inicial, rawDate);
236
- (_props$onChange3 = props.onChange) === null || _props$onChange3 === void 0 ? void 0 : _props$onChange3.call(props, {
237
- target: {
238
- name: props.name,
239
- value: {
240
- [initialName]: returnValueType === 'default' ? inicial === null || inicial === void 0 ? void 0 : inicial.format(_helpers2.TOKEN_ISO_FORMAT) : inicial === null || inicial === void 0 ? void 0 : inicial.toISOString(),
241
- [finalName]: returnValueType === 'default' ? final === null || final === void 0 ? void 0 : final.format(_helpers2.TOKEN_ISO_FORMAT) : final === null || final === void 0 ? void 0 : final.toISOString()
242
- }
243
- }
244
- });
245
- if (shouldCloseOnSelect) handleChangeCalendarBoxState(false);
246
- break;
247
- }
248
- default:
249
- break;
250
- }
251
- setCalendarDisplayDate(rawDate.clone());
252
- }, [props.name, props.onChange, initialName, finalName, selectedDate, shouldCloseOnSelect]);
253
- const handleChangeUpdateDateStateWithPredefinedPeriod = _react.default.useCallback(period => {
254
- var _finalInputRef$curren3, _finalInputRef$curren4;
255
- const localOnChange = (initialDate, finalDate) => {
256
- var _props$onChange4;
257
- const valueToUpdate = {
258
- [initialName]: returnValueType === 'default' ? initialDate.format(_helpers2.TOKEN_ISO_FORMAT) : initialDate.toISOString(),
259
- [finalName]: returnValueType === 'default' ? finalDate.format(_helpers2.TOKEN_ISO_FORMAT) : finalDate.toISOString()
260
- };
261
- setSelectedDate(() => {
262
- const updatedState = {
263
- inicial: initialDate.clone(),
264
- final: finalDate.clone()
265
- };
266
- return updatedState;
267
- });
268
- (_props$onChange4 = props.onChange) === null || _props$onChange4 === void 0 ? void 0 : _props$onChange4.call(props, {
269
- target: {
270
- name: props.name,
271
- value: valueToUpdate
272
- }
273
- });
274
- };
275
- switch (period) {
276
- case 'today':
277
- {
278
- const date = (0, _moment.default)();
279
- localOnChange(date, date);
280
- break;
281
- }
282
- case 'week':
283
- {
284
- const startOfWeek = (0, _moment.default)().startOf('week');
285
- const endOfWeek = (0, _moment.default)().endOf('week');
286
- localOnChange(startOfWeek, endOfWeek);
287
- break;
288
- }
289
- case 'lastweek':
290
- {
291
- const startOfLastWeek = (0, _moment.default)().add(-1, 'week').startOf('week');
292
- const endOfLastWeek = (0, _moment.default)().add(-1, 'week').endOf('week');
293
- localOnChange(startOfLastWeek, endOfLastWeek);
294
- break;
295
- }
296
- case 'last15':
297
- {
298
- const startOfLastFifteenDays = (0, _moment.default)().add(-14, 'd');
299
- const endOfLastFifteenDays = (0, _moment.default)();
300
- localOnChange(startOfLastFifteenDays, endOfLastFifteenDays);
301
- break;
302
- }
303
- case 'month':
304
- {
305
- const startOfMonth = (0, _moment.default)().startOf('month');
306
- const endOfMonth = (0, _moment.default)().endOf('month');
307
- localOnChange(startOfMonth, endOfMonth);
308
- break;
309
- }
310
- case 'lastmonth':
311
- {
312
- const startOfMonth = (0, _moment.default)().add(-1, 'month').startOf('month');
313
- const endOfMonth = (0, _moment.default)().add(-1, 'month').endOf('month');
314
- localOnChange(startOfMonth, endOfMonth);
315
- break;
316
- }
317
- default:
318
- break;
319
- }
320
- finalInputRef === null || finalInputRef === void 0 ? void 0 : (_finalInputRef$curren3 = finalInputRef.current) === null || _finalInputRef$curren3 === void 0 ? void 0 : (_finalInputRef$curren4 = _finalInputRef$curren3.focus) === null || _finalInputRef$curren4 === void 0 ? void 0 : _finalInputRef$curren4.call(_finalInputRef$curren3);
321
- if (shouldCloseOnSelect) handleChangeCalendarBoxState(false);
322
- }, [props.name, props.onChange, initialName, finalName]);
323
- const handleOnBlurMaskInput = (event, inputType) => {
324
- var _props$onBlur;
325
- props === null || props === void 0 ? void 0 : (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 ? void 0 : _props$onBlur.call(props, event);
326
- if (inputType === 'initial') {
327
- var _event$relatedTarget;
328
- if (((_event$relatedTarget = event.relatedTarget) === null || _event$relatedTarget === void 0 ? void 0 : _event$relatedTarget.id) !== finalInputName) handleChangeCalendarBoxState(false);
329
- if (calendarBoxOpen) {
330
- var _selectedDate$inicial2, _selectedDate$inicial3;
331
- handleChangeActiveDescendant(((_selectedDate$inicial2 = selectedDate.inicial) !== null && _selectedDate$inicial2 !== void 0 ? _selectedDate$inicial2 : (0, _moment.default)()).format(_helpers2.TOKEN_ISO_FORMAT));
332
- setCalendarDisplayDate((_selectedDate$inicial3 = selectedDate.inicial) !== null && _selectedDate$inicial3 !== void 0 ? _selectedDate$inicial3 : (0, _moment.default)());
333
- }
334
- if (_lodash.default.size(initialUnmaskedValue) !== 8) {
335
- const date = (0, _moment.default)(selectedDate.inicial, _helpers2.TOKEN_ISO_FORMAT);
336
- if (date.isValid()) {
337
- setInitialMaskValue(date.format(_helpers2.TOKEN_PTBR_FORMAT));
338
- }
339
- }
340
- }
341
- if (inputType === 'final') {
342
- var _event$relatedTarget2;
343
- if (((_event$relatedTarget2 = event.relatedTarget) === null || _event$relatedTarget2 === void 0 ? void 0 : _event$relatedTarget2.id) !== initialInputName) handleChangeCalendarBoxState(false);
344
- if (calendarBoxOpen) {
345
- var _selectedDate$final2, _selectedDate$final3;
346
- handleChangeActiveDescendant(((_selectedDate$final2 = selectedDate.final) !== null && _selectedDate$final2 !== void 0 ? _selectedDate$final2 : (0, _moment.default)()).format(_helpers2.TOKEN_ISO_FORMAT));
347
- setCalendarDisplayDate((_selectedDate$final3 = selectedDate.final) !== null && _selectedDate$final3 !== void 0 ? _selectedDate$final3 : (0, _moment.default)());
348
- }
349
- if (_lodash.default.size(finalUnmaskedValue) !== 8) {
350
- const date = (0, _moment.default)(selectedDate.final, _helpers2.TOKEN_ISO_FORMAT);
351
- if (date.isValid()) {
352
- setFinalMaskValue(date.format(_helpers2.TOKEN_PTBR_FORMAT));
353
- }
354
- }
355
- }
356
- };
357
- const handleOnFocusMaskInput = (event, inputType) => {
358
- var _props$onFocus;
359
- props === null || props === void 0 ? void 0 : (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 ? void 0 : _props$onFocus.call(props, event);
360
- if (!readOnly && !calendarBoxOpen && openCalendarOnFocus) {
361
- setCalendarBoxOpen(true);
362
- }
363
- if (inputType === 'initial') {
364
- var _selectedDate$inicial4, _selectedDate$inicial5;
365
- handleChangeActiveDescendant(((_selectedDate$inicial4 = selectedDate.inicial) !== null && _selectedDate$inicial4 !== void 0 ? _selectedDate$inicial4 : (0, _moment.default)()).format(_helpers2.TOKEN_ISO_FORMAT));
366
- setCalendarDisplayDate((_selectedDate$inicial5 = selectedDate.inicial) !== null && _selectedDate$inicial5 !== void 0 ? _selectedDate$inicial5 : (0, _moment.default)());
367
- }
368
- if (inputType === 'final') {
369
- var _selectedDate$final4, _selectedDate$final5;
370
- handleChangeActiveDescendant(((_selectedDate$final4 = selectedDate.final) !== null && _selectedDate$final4 !== void 0 ? _selectedDate$final4 : (0, _moment.default)()).format(_helpers2.TOKEN_ISO_FORMAT));
371
- setCalendarDisplayDate((_selectedDate$final5 = selectedDate.final) !== null && _selectedDate$final5 !== void 0 ? _selectedDate$final5 : (0, _moment.default)());
372
- }
373
- };
374
- const handleOnKeyDownMaskInput = (event, inputType) => {
375
- var _props$onKeyDown;
376
- props === null || props === void 0 ? void 0 : (_props$onKeyDown = props.onKeyDown) === null || _props$onKeyDown === void 0 ? void 0 : _props$onKeyDown.call(props, event);
377
- if (calendarBoxOpen && event.key && !event.shiftKey && !event.altKey && event.key === _types.Keys.enter) {
378
- event.preventDefault();
379
- const rawDate = (0, _moment.default)(_lodash.default.toString(activeDescendant), _helpers2.TOKEN_ISO_FORMAT);
380
- handleChangeUpdateDateState({
381
- date: rawDate,
382
- inputType
383
- });
384
- }
385
- };
386
- const handleOnPaste = event => {
387
- if (undigitable) {
388
- event.preventDefault();
389
- } else {
390
- var _props$onPaste;
391
- (_props$onPaste = props.onPaste) === null || _props$onPaste === void 0 ? void 0 : _props$onPaste.call(props, event);
392
- }
393
- };
394
- const handleOnBeforeInput = event => {
395
- if (undigitable) {
396
- event.preventDefault();
397
- } else {
398
- var _props$onBeforeInput;
399
- (_props$onBeforeInput = props.onBeforeInput) === null || _props$onBeforeInput === void 0 ? void 0 : _props$onBeforeInput.call(props, event);
400
- }
401
- };
402
- const handleOnKeyDown = event => {
403
- if (calendarBoxOpen && event.key && !event.shiftKey && !event.altKey && _helpers2.NAVIGATION_KEYS.includes(event.key)) {
404
- event.preventDefault();
405
- switch (event.key) {
406
- case _types.Keys.arrowLeft:
407
- handleNavigateWithDays(-1);
408
- break;
409
- case _types.Keys.arrowRight:
410
- handleNavigateWithDays(1);
411
- break;
412
- case _types.Keys.arrowUp:
413
- handleNavigateWithDays(-7);
414
- break;
415
- case _types.Keys.arrowDown:
416
- handleNavigateWithDays(7);
417
- break;
418
- case _types.Keys.pageUp:
419
- handleChangeNextMonth();
420
- break;
421
- case _types.Keys.pageDown:
422
- handleChangePreviousMonth();
423
- break;
424
- case _types.Keys.home:
425
- handleNavigateWithWeeks('start');
426
- break;
427
- case _types.Keys.end:
428
- handleNavigateWithWeeks('end');
429
- break;
430
- case _types.Keys.escape:
431
- handleChangeCalendarBoxState(false);
432
- break;
433
- default:
434
- break;
435
- }
436
- }
437
- };
438
- _react.default.useEffect(() => {
439
- if (props !== null && props !== void 0 && props.value) {
440
- const objectValue = props.value;
441
- const initialDate = (0, _moment.default)(_lodash.default.toString(objectValue[initialName]), _helpers2.TOKEN_ISO_FORMAT);
442
- const finalDate = (0, _moment.default)(_lodash.default.toString(objectValue[finalName]), _helpers2.TOKEN_ISO_FORMAT);
443
- setSelectedDate(() => ({
444
- inicial: initialDate.isValid() ? initialDate : null,
445
- final: finalDate.isValid() ? finalDate : null
446
- }));
447
- setInitialMaskValue(initialDate.format(_helpers2.TOKEN_PTBR_FORMAT));
448
- setFinalMaskValue(finalDate.format(_helpers2.TOKEN_PTBR_FORMAT));
449
- }
450
- }, [props === null || props === void 0 ? void 0 : props.value]);
451
- const contextValues = _react.default.useMemo(() => ({
452
- isReadOnly: Boolean(readOnly),
453
- isDisabled: Boolean(readOnly),
454
- undigitable,
455
- skeletonize,
456
- dateContainerRef,
457
- calendarBoxOpen,
458
- activeDescendant,
459
- selectedDate,
460
- initialInputId: initialInputName,
461
- finalInputId: finalInputName,
462
- initialInputRef,
463
- finalInputRef,
464
- showCalendarButton,
465
- calendarDisplayDate,
466
- hasValidationErrors,
467
- openCalendarOnFocus,
468
- showPredefinedPeriodsButton,
469
- showClearDateButton,
470
- handleChangeSelectedDate,
471
- handleChangePreviousMonth,
472
- handleChangeNextMonth,
473
- handleChangeCalendarBoxState,
474
- handleChangeActiveDescendant,
475
- handleChangeCalendarDisplayDate,
476
- handleChangeUpdateDateState,
477
- handleOnClickClearSelectedPeriod,
478
- handleChangeUpdateDateStateWithPredefinedPeriod,
479
- hasValidPeriodSelected: verifyPeriodSelectedIsValid()
480
- }), [readOnly, disabled, undigitable, skeletonize, initialInputName, finalInputName, selectedDate, calendarBoxOpen, activeDescendant, calendarDisplayDate, hasValidationErrors, openCalendarOnFocus, showClearDateButton]);
481
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_context.DatePeriodFieldContext.Provider, {
482
- value: contextValues
483
- }, /*#__PURE__*/_react.default.createElement(BaseDate.Root, {
484
- ref: inputRootRef,
485
- "data-testid": "test-date-period-field-root",
486
- "data-state-error": hasValidationErrors,
487
- customClassWrapper: customClassWrapper
488
- }, hasLabel && /*#__PURE__*/_react.default.createElement(BaseDate.Label, {
489
- "data-testid": "test-date-period-field-label",
490
- label: label,
491
- inputId: initialInputName,
492
- hint: props === null || props === void 0 ? void 0 : props.hint,
493
- isDisabled: disabled,
494
- isReadOnly: readOnly,
495
- skeletonize: skeletonize,
496
- required: props === null || props === void 0 ? void 0 : props.required,
497
- hintPosition: hintPosition,
498
- themePopover: themePopover,
499
- popoverAlign: popoverAlign,
500
- labelUppercase: labelUppercase,
501
- hasHintMessages: hasHintMessages,
502
- customClassLabel: customClassLabel
503
- }), /*#__PURE__*/_react.default.createElement(BaseDate.Container, {
504
- ref: dateContainerRef,
505
- "data-testid": "test-date-period-field-container",
506
- onKeyDown: handleOnKeyDown,
507
- skeletonize: skeletonize,
508
- customClassInputContainer: customClassInputContainer
509
- }, /*#__PURE__*/_react.default.createElement(BaseDate.Input, _extends({}, _lodash.default.omit(rest, ['initialRef', 'finalRef']), {
510
- ref: (0, _helpers.mergeRefs)(initialInputRef, props === null || props === void 0 ? void 0 : props.initialRef),
511
- id: initialInputName,
512
- name: initialInputName,
513
- value: initialMaskedValue,
514
- disabled: disabled,
515
- readOnly: readOnly,
516
- customClass: customClass,
517
- tabIndex: !readOnly && !skeletonize ? 0 : -1,
518
- placeholder: placeholder,
519
- "aria-autocomplete": "list",
520
- "aria-activedescendant": activeDescendant,
521
- "aria-expanded": calendarBoxOpen,
522
- "aria-controls": initialInputName,
523
- "aria-labelledby": initialInputName,
524
- "data-testid": "test-date-period-field-initial-input",
525
- "data-state-is-period-input": true,
526
- "data-state-error": hasValidationErrors,
527
- "data-state-read-only": readOnly,
528
- "data-state-text-align": textAlign,
529
- "data-state-undigitable": undigitable,
530
- "data-state-skeletonize": skeletonize,
531
- onPaste: handleOnPaste,
532
- onBeforeInput: handleOnBeforeInput,
533
- onBlur: event => handleOnBlurMaskInput(event, 'initial'),
534
- onFocus: event => handleOnFocusMaskInput(event, 'initial'),
535
- onKeyDown: event => handleOnKeyDownMaskInput(event, 'initial')
536
- })), /*#__PURE__*/_react.default.createElement("span", {
537
- className: "separator",
538
- "data-state-disabled": disabled,
539
- "data-state-read-only": readOnly,
540
- onMouseDown: event => {
541
- event.preventDefault();
542
- }
543
- }, /*#__PURE__*/_react.default.createElement(_icons.default, {
544
- name: "arrow_right",
545
- size: 10
546
- })), /*#__PURE__*/_react.default.createElement(BaseDate.Input, _extends({}, _lodash.default.omit(rest, ['initialRef', 'finalRef']), {
547
- ref: (0, _helpers.mergeRefs)(finalInputRef, props === null || props === void 0 ? void 0 : props.finalRef),
548
- id: finalInputName,
549
- name: finalInputName,
550
- value: finalMaskedValue,
551
- readOnly: readOnly,
552
- disabled: disabled,
553
- customClass: customClass,
554
- tabIndex: !readOnly && !skeletonize ? 0 : -1,
555
- placeholder: placeholder,
556
- "aria-autocomplete": "list",
557
- "aria-activedescendant": activeDescendant,
558
- "aria-expanded": calendarBoxOpen,
559
- "aria-controls": finalInputName,
560
- "aria-labelledby": finalInputName,
561
- "data-testid": "test-date-period-field-final-input",
562
- "data-state-is-period-input": true,
563
- "data-state-error": hasValidationErrors,
564
- "data-state-read-only": readOnly,
565
- "data-state-text-align": textAlign,
566
- "data-state-undigitable": undigitable,
567
- "data-state-skeletonize": skeletonize,
568
- onPaste: handleOnPaste,
569
- onBeforeInput: handleOnBeforeInput,
570
- onBlur: event => handleOnBlurMaskInput(event, 'final'),
571
- onFocus: event => handleOnFocusMaskInput(event, 'final'),
572
- onKeyDown: event => handleOnKeyDownMaskInput(event, 'final')
573
- })), /*#__PURE__*/_react.default.createElement(_triggers.Triggers, null)), calendarBoxOpen && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_calendarbox.CalendarBox, {
574
- ref: calendarRef
575
- }), document.body), hintPosition === 'below' && /*#__PURE__*/_react.default.createElement(_hint.default, {
576
- customClass: "hint",
577
- description: props.hint,
578
- disabled: disabled,
579
- skeletonize: skeletonize,
580
- visible: hasHintMessages
581
- }), hasValidationErrors && /*#__PURE__*/_react.default.createElement("span", {
582
- "data-testid": "test-date-period-field-list-errors",
583
- className: "error",
584
- "data-state-skeletonize": skeletonize,
585
- "aria-describedby": String(label).concat('-errors')
586
- }, errors === null || errors === void 0 ? void 0 : errors.map((error, index) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
587
- key: "".concat(index + 1, "-").concat(error)
588
- }, error, "\xA0"))))), /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
589
- targetRef: inputRootRef,
590
- text: tooltip,
591
- width: tooltipWidth,
592
- position: tooltipPosition
593
- }));
594
- });
595
- InputBase.displayName = 'DatePeriodFieldInputBase';
@@ -1,12 +0,0 @@
1
- import React__default from 'react';
2
- import { RadioFieldInputProps } from './types.js';
3
- import '../../@types/Size.js';
4
- import '../../@types/Align.js';
5
- import '../../@types/ColorStyles.js';
6
- import '../../tooltip/types.js';
7
- import '../../@types/Position.js';
8
- import '../../@types/PermissionAttr.js';
9
-
10
- declare const InputBase: React__default.ForwardRefExoticComponent<Pick<RadioFieldInputProps, "form" | "label" | "slot" | "style" | "title" | "pattern" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "align" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "customClass" | "permissionAttr" | "size" | "skeletonize" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "value" | "tooltip" | "tooltipWidth" | "tooltipPosition" | "checked" | "required" | "labelUppercase" | "hint" | "hintPosition" | "themePopover" | "popoverAlign" | "width" | "height" | "readOnly" | "list" | "step" | "maxLength" | "textAlign" | "onDeniedActions" | "gridLayout" | "accept" | "autoComplete" | "src" | "alt" | "max" | "min" | "fieldId" | "errors" | "capture" | "crossOrigin" | "enterKeyHint" | "minLength" | "customClassLabel" | "customClassWrapper" | "customClassInputContainer" | "getFieldValue"> & React__default.RefAttributes<HTMLInputElement>>;
11
-
12
- export { InputBase };