linear-react-components-ui 2.1.0-beta.5 → 2.2.0-beta.0
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/datepicker2.css +11 -81
- package/lib/form2/useForm/index.js +1 -0
- package/lib/form2/useForm/index.js.map +1 -1
- package/lib/inputs2/date/{hooks/useCalendarPosition.d.ts → base/constants.d.ts} +1 -1
- package/lib/inputs2/date/base/constants.js +69 -0
- package/lib/inputs2/date/base/constants.js.map +1 -0
- package/lib/inputs2/date/datefield/base.js +214 -691
- package/lib/inputs2/date/datefield/base.js.map +1 -1
- package/lib/inputs2/date/datefield/calendarbox.d.ts +6 -0
- package/lib/inputs2/date/datefield/calendarbox.js +228 -0
- package/lib/inputs2/date/datefield/calendarbox.js.map +1 -0
- package/lib/inputs2/date/datefield/triggers.js +4 -4
- package/lib/inputs2/date/datefield/triggers.js.map +1 -1
- package/lib/inputs2/date/datefield/types.d.ts +12 -5
- package/lib/inputs2/date/dateperiodfield/base.js +809 -694
- package/lib/inputs2/date/dateperiodfield/base.js.map +1 -1
- package/lib/inputs2/date/dateperiodfield/calendarbox.d.ts +6 -0
- package/lib/inputs2/date/dateperiodfield/calendarbox.js +282 -0
- package/lib/inputs2/date/dateperiodfield/calendarbox.js.map +1 -0
- package/lib/inputs2/date/dateperiodfield/triggers.js +9 -21
- package/lib/inputs2/date/dateperiodfield/triggers.js.map +1 -1
- package/lib/inputs2/date/dateperiodfield/types.d.ts +23 -13
- package/lib/inputs2/date/helpers.d.ts +4 -44
- package/lib/inputs2/date/helpers.js +4 -200
- package/lib/inputs2/date/helpers.js.map +1 -1
- package/lib/inputs2/date/types.d.ts +1 -22
- package/lib/inputs2/date/types.js.map +1 -1
- package/lib/node_modules/lodash/lodash.js +2 -2
- package/lib/node_modules/lodash/lodash.js.map +1 -1
- package/package.json +1 -1
- package/lib/inputs2/date/calendarbox.d.ts +0 -23
- package/lib/inputs2/date/calendarbox.js +0 -254
- package/lib/inputs2/date/calendarbox.js.map +0 -1
- package/lib/inputs2/date/hooks/useCalendarPosition.js +0 -93
- package/lib/inputs2/date/hooks/useCalendarPosition.js.map +0 -1
- package/lib/inputs2/date/hooks/useDateCalendarState.d.ts +0 -14
- package/lib/inputs2/date/hooks/useDateCalendarState.js +0 -250
- package/lib/inputs2/date/hooks/useDateCalendarState.js.map +0 -1
- package/lib/inputs2/date/hooks/useDateMask.d.ts +0 -22
- package/lib/inputs2/date/hooks/useDateMask.js +0 -143
- package/lib/inputs2/date/hooks/useDateMask.js.map +0 -1
- package/lib/inputs2/date/timeselector.d.ts +0 -17
- package/lib/inputs2/date/timeselector.js +0 -226
- package/lib/inputs2/date/timeselector.js.map +0 -1
- package/lib/node_modules/moment/dist/locale/pt-br.js +0 -54
- package/lib/node_modules/moment/dist/locale/pt-br.js.map +0 -1
|
@@ -1,729 +1,252 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as compilerRuntimeExports } from "../../../_virtual/compiler-runtime.js";
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
2
|
import React from "react";
|
|
4
3
|
import _ from "../../../_virtual/lodash.js";
|
|
4
|
+
import { useIMask } from "react-imask";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
import hooks from "../../../node_modules/moment/dist/moment.js";
|
|
7
7
|
import Hint from "../../../hint/index.js";
|
|
8
8
|
import { Tooltip } from "../../../tooltip/index.js";
|
|
9
9
|
import { mergeRefs } from "../../../form2/helpers.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { TimeSelector } from "../timeselector.js";
|
|
14
|
-
import { parseBoundary, getTimeSelection, isDayOutOfBounds, TOKEN_ISO_FORMAT, getDateFormats, clampDateToBounds, formatPartialDateTime, completePartialDateTime, parseDateValue, resolveAssumedTime } from "../helpers.js";
|
|
15
|
-
import { CalendarBox } from "../calendarbox.js";
|
|
10
|
+
import { Keys } from "../types.js";
|
|
11
|
+
import { Root, Label, Container, Input } from "../base/index.js";
|
|
12
|
+
import { TOKEN_PTBR_FORMAT, TOKEN_ISO_FORMAT, TOKEN_MASK, NAVIGATION_KEYS } from "../helpers.js";
|
|
16
13
|
import { Triggers } from "./triggers.js";
|
|
14
|
+
import { CalendarBox } from "./calendarbox.js";
|
|
17
15
|
import { DateFieldContext } from "./context.js";
|
|
18
16
|
import v1 from "../../../node_modules/uuid/dist/v1.js";
|
|
19
17
|
const InputBase = React.forwardRef((props, ref) => {
|
|
20
|
-
const $ = compilerRuntimeExports.c(209);
|
|
21
|
-
let disabled;
|
|
22
|
-
let errors;
|
|
23
|
-
let label;
|
|
24
|
-
let max;
|
|
25
|
-
let min;
|
|
26
|
-
let onChange;
|
|
27
|
-
let placeholder;
|
|
28
|
-
let readOnly;
|
|
29
|
-
let rest;
|
|
30
|
-
let shouldCloseOnSelect;
|
|
31
|
-
let t0;
|
|
32
|
-
let t1;
|
|
33
|
-
let t10;
|
|
34
|
-
let t11;
|
|
35
|
-
let t12;
|
|
36
|
-
let t13;
|
|
37
|
-
let t14;
|
|
38
|
-
let t15;
|
|
39
|
-
let t2;
|
|
40
|
-
let t3;
|
|
41
|
-
let t4;
|
|
42
|
-
let t5;
|
|
43
|
-
let t6;
|
|
44
|
-
let t7;
|
|
45
|
-
let t8;
|
|
46
|
-
let t9;
|
|
47
|
-
let tooltip;
|
|
48
|
-
let tooltipPosition;
|
|
49
|
-
let tooltipWidth;
|
|
50
|
-
if ($[0] !== props) {
|
|
51
|
-
({
|
|
52
|
-
label,
|
|
53
|
-
errors,
|
|
54
|
-
tooltip,
|
|
55
|
-
tooltipPosition,
|
|
56
|
-
tooltipWidth,
|
|
57
|
-
returnValueType: t0,
|
|
58
|
-
customClass: t1,
|
|
59
|
-
customClassLabel: t2,
|
|
60
|
-
customClassWrapper: t3,
|
|
61
|
-
customClassInputContainer: t4,
|
|
62
|
-
textAlign: t5,
|
|
63
|
-
labelUppercase: t6,
|
|
64
|
-
skeletonize: t7,
|
|
65
|
-
hintPosition: t8,
|
|
66
|
-
themePopover: t9,
|
|
67
|
-
popoverAlign: t10,
|
|
68
|
-
showCalendarButton: t11,
|
|
69
|
-
openCalendarOnFocus: t12,
|
|
70
|
-
undigitable: t13,
|
|
71
|
-
showClearDateButton: t14,
|
|
72
|
-
variant: t15,
|
|
73
|
-
placeholder,
|
|
74
|
-
shouldCloseOnSelect,
|
|
75
|
-
min,
|
|
76
|
-
max,
|
|
77
|
-
onChange,
|
|
78
|
-
readOnly,
|
|
79
|
-
disabled,
|
|
80
|
-
...rest
|
|
81
|
-
} = props);
|
|
82
|
-
$[0] = props;
|
|
83
|
-
$[1] = disabled;
|
|
84
|
-
$[2] = errors;
|
|
85
|
-
$[3] = label;
|
|
86
|
-
$[4] = max;
|
|
87
|
-
$[5] = min;
|
|
88
|
-
$[6] = onChange;
|
|
89
|
-
$[7] = placeholder;
|
|
90
|
-
$[8] = readOnly;
|
|
91
|
-
$[9] = rest;
|
|
92
|
-
$[10] = shouldCloseOnSelect;
|
|
93
|
-
$[11] = t0;
|
|
94
|
-
$[12] = t1;
|
|
95
|
-
$[13] = t10;
|
|
96
|
-
$[14] = t11;
|
|
97
|
-
$[15] = t12;
|
|
98
|
-
$[16] = t13;
|
|
99
|
-
$[17] = t14;
|
|
100
|
-
$[18] = t15;
|
|
101
|
-
$[19] = t2;
|
|
102
|
-
$[20] = t3;
|
|
103
|
-
$[21] = t4;
|
|
104
|
-
$[22] = t5;
|
|
105
|
-
$[23] = t6;
|
|
106
|
-
$[24] = t7;
|
|
107
|
-
$[25] = t8;
|
|
108
|
-
$[26] = t9;
|
|
109
|
-
$[27] = tooltip;
|
|
110
|
-
$[28] = tooltipPosition;
|
|
111
|
-
$[29] = tooltipWidth;
|
|
112
|
-
} else {
|
|
113
|
-
disabled = $[1];
|
|
114
|
-
errors = $[2];
|
|
115
|
-
label = $[3];
|
|
116
|
-
max = $[4];
|
|
117
|
-
min = $[5];
|
|
118
|
-
onChange = $[6];
|
|
119
|
-
placeholder = $[7];
|
|
120
|
-
readOnly = $[8];
|
|
121
|
-
rest = $[9];
|
|
122
|
-
shouldCloseOnSelect = $[10];
|
|
123
|
-
t0 = $[11];
|
|
124
|
-
t1 = $[12];
|
|
125
|
-
t10 = $[13];
|
|
126
|
-
t11 = $[14];
|
|
127
|
-
t12 = $[15];
|
|
128
|
-
t13 = $[16];
|
|
129
|
-
t14 = $[17];
|
|
130
|
-
t15 = $[18];
|
|
131
|
-
t2 = $[19];
|
|
132
|
-
t3 = $[20];
|
|
133
|
-
t4 = $[21];
|
|
134
|
-
t5 = $[22];
|
|
135
|
-
t6 = $[23];
|
|
136
|
-
t7 = $[24];
|
|
137
|
-
t8 = $[25];
|
|
138
|
-
t9 = $[26];
|
|
139
|
-
tooltip = $[27];
|
|
140
|
-
tooltipPosition = $[28];
|
|
141
|
-
tooltipWidth = $[29];
|
|
142
|
-
}
|
|
143
|
-
const returnValueType = t0 === void 0 ? "default" : t0;
|
|
144
|
-
const customClass = t1 === void 0 ? "" : t1;
|
|
145
|
-
const customClassLabel = t2 === void 0 ? "" : t2;
|
|
146
|
-
const customClassWrapper = t3 === void 0 ? "" : t3;
|
|
147
|
-
const customClassInputContainer = t4 === void 0 ? "" : t4;
|
|
148
|
-
const textAlign = t5 === void 0 ? "left" : t5;
|
|
149
|
-
const labelUppercase = t6 === void 0 ? false : t6;
|
|
150
|
-
const skeletonize = t7 === void 0 ? false : t7;
|
|
151
|
-
const hintPosition = t8 === void 0 ? "below" : t8;
|
|
152
|
-
const themePopover = t9 === void 0 ? "light" : t9;
|
|
153
|
-
const popoverAlign = t10 === void 0 ? "left" : t10;
|
|
154
|
-
const showCalendarButton = t11 === void 0 ? true : t11;
|
|
155
|
-
const openCalendarOnFocus = t12 === void 0 ? true : t12;
|
|
156
|
-
const undigitable = t13 === void 0 ? false : t13;
|
|
157
|
-
const showClearDateButton = t14 === void 0 ? true : t14;
|
|
158
|
-
const variant = t15 === void 0 ? "date" : t15;
|
|
159
|
-
const isDateTime = variant === "datetime";
|
|
160
18
|
const {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
19
|
+
label,
|
|
20
|
+
errors,
|
|
21
|
+
tooltip,
|
|
22
|
+
tooltipPosition,
|
|
23
|
+
tooltipWidth,
|
|
24
|
+
shouldCloseOnSelect = true,
|
|
25
|
+
returnValueType = "default",
|
|
26
|
+
customClass = "",
|
|
27
|
+
customClassLabel = "",
|
|
28
|
+
customClassWrapper = "",
|
|
29
|
+
customClassInputContainer = "",
|
|
30
|
+
textAlign = "left",
|
|
31
|
+
labelUppercase = false,
|
|
32
|
+
skeletonize = false,
|
|
33
|
+
hintPosition = "below",
|
|
34
|
+
themePopover = "light",
|
|
35
|
+
popoverAlign = "left",
|
|
36
|
+
showCalendarButton = true,
|
|
37
|
+
openCalendarOnFocus = true,
|
|
38
|
+
undigitable = false,
|
|
39
|
+
showClearDateButton = true,
|
|
40
|
+
placeholder = TOKEN_PTBR_FORMAT,
|
|
41
|
+
readOnly,
|
|
42
|
+
disabled,
|
|
43
|
+
...rest
|
|
44
|
+
} = props;
|
|
45
|
+
const [calendarBoxOpen, setCalendarBoxOpen] = React.useState(false);
|
|
46
|
+
const [activeDescendant, setActiveDescendant] = React.useState(hooks().format(TOKEN_ISO_FORMAT));
|
|
186
47
|
const [selectedDate, setSelectedDate] = React.useState(null);
|
|
48
|
+
const [calendarDisplayDate, setCalendarDisplayDate] = React.useState(selectedDate ?? hooks());
|
|
49
|
+
const calendarRef = React.useRef(null);
|
|
187
50
|
const inputRootRef = React.useRef(null);
|
|
188
51
|
const dateInputRef = React.useRef(null);
|
|
189
|
-
const
|
|
190
|
-
inputRef: dateInputRef,
|
|
191
|
-
min: minDate,
|
|
192
|
-
max: maxDate,
|
|
193
|
-
onPressEnter: (descendant) => handleSelectDay(hooks(_.toString(descendant), TOKEN_ISO_FORMAT))
|
|
194
|
-
});
|
|
52
|
+
const dateContainerRef = React.useRef(null);
|
|
195
53
|
const {
|
|
196
|
-
|
|
197
|
-
activeDescendant,
|
|
198
|
-
calendarDisplayDate,
|
|
199
|
-
calendarRef,
|
|
200
|
-
dateContainerRef,
|
|
201
|
-
handleNextMonth,
|
|
202
|
-
handlePreviousMonth,
|
|
203
|
-
handleSetCalendarBoxOpen,
|
|
204
|
-
handleChangeActiveDescendant,
|
|
205
|
-
handleChangeCalendarDisplayDate,
|
|
206
|
-
handleKeyDownNavigation
|
|
207
|
-
} = calendarState;
|
|
208
|
-
const {
|
|
209
|
-
maskedValue,
|
|
54
|
+
setValue: setMaskValue,
|
|
210
55
|
unmaskedValue,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
defaultValue: selectedDate?.format(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
56
|
+
value: maskedValue
|
|
57
|
+
} = useIMask({
|
|
58
|
+
mask: TOKEN_MASK,
|
|
59
|
+
lazy: false,
|
|
60
|
+
placeholderChar: "_"
|
|
61
|
+
}, {
|
|
62
|
+
ref: dateInputRef,
|
|
63
|
+
defaultValue: selectedDate?.format(TOKEN_PTBR_FORMAT),
|
|
64
|
+
onComplete: (value) => {
|
|
65
|
+
const date = hooks(value, TOKEN_PTBR_FORMAT);
|
|
66
|
+
if (date.isValid()) {
|
|
67
|
+
handleUpdateDateState(date);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
224
70
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
t18 = getTimeSelection(unmaskedValue, variant);
|
|
228
|
-
$[34] = unmaskedValue;
|
|
229
|
-
$[35] = variant;
|
|
230
|
-
$[36] = t18;
|
|
231
|
-
} else {
|
|
232
|
-
t18 = $[36];
|
|
233
|
-
}
|
|
234
|
-
const timeSelection = t18;
|
|
235
|
-
let t19;
|
|
236
|
-
if ($[37] !== props.id || $[38] !== props.name) {
|
|
237
|
-
t19 = props.id || props.name || v1();
|
|
238
|
-
$[37] = props.id;
|
|
239
|
-
$[38] = props.name;
|
|
240
|
-
$[39] = t19;
|
|
241
|
-
} else {
|
|
242
|
-
t19 = $[39];
|
|
243
|
-
}
|
|
244
|
-
const inputId = t19;
|
|
245
|
-
let t20;
|
|
246
|
-
if ($[40] !== props.label) {
|
|
247
|
-
t20 = _.isEmpty(props?.label);
|
|
248
|
-
$[40] = props.label;
|
|
249
|
-
$[41] = t20;
|
|
250
|
-
} else {
|
|
251
|
-
t20 = $[41];
|
|
252
|
-
}
|
|
253
|
-
const hasLabel = !t20;
|
|
71
|
+
const inputId = React.useMemo(() => props.id || props.name || v1(), [props.id, props.name]);
|
|
72
|
+
const hasLabel = !_.isEmpty(props?.label);
|
|
254
73
|
const hasHintMessages = Boolean(props.hint?.length);
|
|
255
74
|
const hasValidationErrors = Boolean(errors?.length);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
$[42] = props.value;
|
|
260
|
-
$[43] = t21;
|
|
261
|
-
} else {
|
|
262
|
-
t21 = $[43];
|
|
263
|
-
}
|
|
264
|
-
const hasValidDateSelected = !t21;
|
|
265
|
-
const handleUpdateDateState = (date_0) => {
|
|
266
|
-
const nonIsoDateFormat = date_0.format(isoFormat);
|
|
75
|
+
const hasValidDateSelected = !_.isEmpty(props?.value);
|
|
76
|
+
const handleUpdateDateState = React.useCallback((date_0) => {
|
|
77
|
+
const nonIsoDateFormat = date_0.format(TOKEN_ISO_FORMAT);
|
|
267
78
|
const isoDateFormat = date_0.toISOString();
|
|
268
79
|
setSelectedDate(date_0.clone());
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
onChange?.({
|
|
80
|
+
setCalendarDisplayDate(date_0.clone());
|
|
81
|
+
props.onChange?.({
|
|
272
82
|
target: {
|
|
273
83
|
name: props.name,
|
|
274
84
|
value: returnValueType === "default" ? nonIsoDateFormat : isoDateFormat
|
|
275
85
|
}
|
|
276
86
|
});
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
handleChangeCalendarDisplayDate(date_1.clone());
|
|
288
|
-
if (shouldCloseCalendarOnSelect) {
|
|
289
|
-
handleSetCalendarBoxOpen(false);
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
$[44] = handleChangeActiveDescendant;
|
|
293
|
-
$[45] = handleChangeCalendarDisplayDate;
|
|
294
|
-
$[46] = handleSetCalendarBoxOpen;
|
|
295
|
-
$[47] = setMaskValue;
|
|
296
|
-
$[48] = setSelectedDate;
|
|
297
|
-
$[49] = shouldCloseCalendarOnSelect;
|
|
298
|
-
$[50] = t22;
|
|
299
|
-
} else {
|
|
300
|
-
t22 = $[50];
|
|
301
|
-
}
|
|
302
|
-
const handleUpdateDraftState = t22;
|
|
303
|
-
let t23;
|
|
304
|
-
if ($[51] !== handleSetCalendarBoxOpen || $[52] !== onChange || $[53] !== props.name || $[54] !== setMaskValue || $[55] !== setSelectedDate) {
|
|
305
|
-
t23 = () => {
|
|
306
|
-
onChange?.({
|
|
307
|
-
target: {
|
|
308
|
-
name: props.name,
|
|
309
|
-
value: ""
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
setSelectedDate(null);
|
|
313
|
-
setMaskValue("");
|
|
314
|
-
handleSetCalendarBoxOpen(false);
|
|
315
|
-
};
|
|
316
|
-
$[51] = handleSetCalendarBoxOpen;
|
|
317
|
-
$[52] = onChange;
|
|
318
|
-
$[53] = props.name;
|
|
319
|
-
$[54] = setMaskValue;
|
|
320
|
-
$[55] = setSelectedDate;
|
|
321
|
-
$[56] = t23;
|
|
322
|
-
} else {
|
|
323
|
-
t23 = $[56];
|
|
324
|
-
}
|
|
325
|
-
const handleOnClickClearSelectedDate = t23;
|
|
326
|
-
let t24;
|
|
327
|
-
if ($[57] !== digits || $[58] !== handleChangeActiveDescendant || $[59] !== handleChangeCalendarDisplayDate || $[60] !== handleSetCalendarBoxOpen || $[61] !== handleUpdateDateState || $[62] !== maxDate || $[63] !== minDate || $[64] !== props || $[65] !== ptbrFormat || $[66] !== selectedDate || $[67] !== setMaskValue || $[68] !== unmaskedValue || $[69] !== variant) {
|
|
328
|
-
t24 = (event) => {
|
|
329
|
-
props?.onBlur?.(event);
|
|
330
|
-
handleSetCalendarBoxOpen(false);
|
|
331
|
-
handleChangeActiveDescendant((selectedDate ?? hooks()).format(TOKEN_ISO_FORMAT));
|
|
332
|
-
handleChangeCalendarDisplayDate(selectedDate ?? hooks());
|
|
333
|
-
const completedDate = completePartialDateTime({
|
|
334
|
-
unmaskedValue,
|
|
335
|
-
variant,
|
|
336
|
-
min: minDate,
|
|
337
|
-
max: maxDate
|
|
338
|
-
});
|
|
339
|
-
if (completedDate) {
|
|
340
|
-
setMaskValue(completedDate.format(ptbrFormat));
|
|
341
|
-
handleUpdateDateState(completedDate);
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
if (_.size(unmaskedValue) !== digits) {
|
|
345
|
-
const date_2 = parseDateValue(props?.value, variant);
|
|
346
|
-
if (date_2.isValid()) {
|
|
347
|
-
setMaskValue(date_2.format(ptbrFormat));
|
|
348
|
-
}
|
|
87
|
+
if (shouldCloseOnSelect) handleCloseCalendar();
|
|
88
|
+
}, [selectedDate, props.name, props.onChange, shouldCloseOnSelect]);
|
|
89
|
+
const handleOpenCalendar = React.useCallback(() => setCalendarBoxOpen(true), []);
|
|
90
|
+
const handleCloseCalendar = React.useCallback(() => setCalendarBoxOpen(false), []);
|
|
91
|
+
const handleNextMonth = React.useCallback(() => setCalendarDisplayDate((prevDisplayDate) => prevDisplayDate.clone().add(1, "month")), []);
|
|
92
|
+
const handlePreviousMonth = React.useCallback(() => setCalendarDisplayDate((prevDisplayDate_0) => prevDisplayDate_0.clone().subtract(1, "month")), []);
|
|
93
|
+
const handleChangeCalendarBoxState = React.useCallback(() => {
|
|
94
|
+
setCalendarBoxOpen((prevState) => {
|
|
95
|
+
if (dateInputRef.current !== document.activeElement) {
|
|
96
|
+
dateInputRef?.current?.focus?.();
|
|
349
97
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
handleChangeCalendarDisplayDate(selectedDate ?? hooks());
|
|
375
|
-
if (!readOnly && openCalendarOnFocus) {
|
|
376
|
-
handleSetCalendarBoxOpen(true);
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
$[71] = handleChangeActiveDescendant;
|
|
380
|
-
$[72] = handleChangeCalendarDisplayDate;
|
|
381
|
-
$[73] = handleSetCalendarBoxOpen;
|
|
382
|
-
$[74] = openCalendarOnFocus;
|
|
383
|
-
$[75] = props;
|
|
384
|
-
$[76] = readOnly;
|
|
385
|
-
$[77] = selectedDate;
|
|
386
|
-
$[78] = t25;
|
|
387
|
-
} else {
|
|
388
|
-
t25 = $[78];
|
|
389
|
-
}
|
|
390
|
-
const handleOnFocus = t25;
|
|
391
|
-
let t26;
|
|
392
|
-
if ($[79] !== handleKeyDownNavigation || $[80] !== props) {
|
|
393
|
-
t26 = (event_1) => {
|
|
394
|
-
props?.onKeyDown?.(event_1);
|
|
395
|
-
handleKeyDownNavigation(event_1);
|
|
396
|
-
};
|
|
397
|
-
$[79] = handleKeyDownNavigation;
|
|
398
|
-
$[80] = props;
|
|
399
|
-
$[81] = t26;
|
|
400
|
-
} else {
|
|
401
|
-
t26 = $[81];
|
|
402
|
-
}
|
|
403
|
-
const handleOnKeyDown = t26;
|
|
404
|
-
let t27;
|
|
405
|
-
if ($[82] !== handleUpdateDateState || $[83] !== handleUpdateDraftState || $[84] !== selectedDate || $[85] !== timeSelection) {
|
|
406
|
-
t27 = (hour_0) => {
|
|
407
|
-
if (!selectedDate) {
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
const {
|
|
411
|
-
minute: minute_0
|
|
412
|
-
} = timeSelection;
|
|
413
|
-
if (_.isNull(minute_0)) {
|
|
414
|
-
handleUpdateDraftState(selectedDate.clone().hour(hour_0), hour_0, null);
|
|
415
|
-
return;
|
|
98
|
+
return !prevState;
|
|
99
|
+
});
|
|
100
|
+
}, []);
|
|
101
|
+
const handleNavigateWithDays = React.useCallback((offset) => {
|
|
102
|
+
setCalendarDisplayDate((prevDisplayDate_1) => {
|
|
103
|
+
const daySelected = prevDisplayDate_1.clone().add(offset, "day");
|
|
104
|
+
setActiveDescendant(daySelected.format(TOKEN_ISO_FORMAT));
|
|
105
|
+
return daySelected;
|
|
106
|
+
});
|
|
107
|
+
}, []);
|
|
108
|
+
const handleNavigateWithWeeks = React.useCallback((when) => {
|
|
109
|
+
setCalendarDisplayDate((prevDisplayDate_2) => {
|
|
110
|
+
let daySelected_0 = prevDisplayDate_2;
|
|
111
|
+
if (when === "end") daySelected_0 = prevDisplayDate_2.clone().endOf("week");
|
|
112
|
+
if (when === "start") daySelected_0 = prevDisplayDate_2.clone().startOf("week");
|
|
113
|
+
setActiveDescendant(daySelected_0.format(TOKEN_ISO_FORMAT));
|
|
114
|
+
return daySelected_0;
|
|
115
|
+
});
|
|
116
|
+
}, []);
|
|
117
|
+
const handleOnClickClearSelectedDate = React.useCallback(() => {
|
|
118
|
+
props.onChange?.({
|
|
119
|
+
target: {
|
|
120
|
+
name: props.name,
|
|
121
|
+
value: ""
|
|
416
122
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
if (!selectedDate) {
|
|
432
|
-
return;
|
|
123
|
+
});
|
|
124
|
+
setSelectedDate(null);
|
|
125
|
+
setMaskValue("");
|
|
126
|
+
handleCloseCalendar();
|
|
127
|
+
}, [props.onChange]);
|
|
128
|
+
const handleOnBlur = (event) => {
|
|
129
|
+
props?.onBlur?.(event);
|
|
130
|
+
handleCloseCalendar();
|
|
131
|
+
setActiveDescendant((selectedDate ?? hooks()).format(TOKEN_ISO_FORMAT));
|
|
132
|
+
setCalendarDisplayDate(selectedDate ?? hooks());
|
|
133
|
+
if (_.size(unmaskedValue) !== 8) {
|
|
134
|
+
const date_1 = hooks(_.toString(props?.value), TOKEN_ISO_FORMAT);
|
|
135
|
+
if (date_1.isValid()) {
|
|
136
|
+
setMaskValue(date_1.format("DD/MM/YYYY"));
|
|
433
137
|
}
|
|
434
|
-
const {
|
|
435
|
-
hour: hour_1
|
|
436
|
-
} = timeSelection;
|
|
437
|
-
handleUpdateDateState(_.isNull(hour_1) ? resolveAssumedTime({
|
|
438
|
-
date: selectedDate,
|
|
439
|
-
hour: null,
|
|
440
|
-
minute: minute_1,
|
|
441
|
-
min: minDate,
|
|
442
|
-
max: maxDate
|
|
443
|
-
}) : selectedDate.clone().hour(hour_1).minute(minute_1).second(0));
|
|
444
|
-
};
|
|
445
|
-
$[87] = handleUpdateDateState;
|
|
446
|
-
$[88] = maxDate;
|
|
447
|
-
$[89] = minDate;
|
|
448
|
-
$[90] = selectedDate;
|
|
449
|
-
$[91] = timeSelection;
|
|
450
|
-
$[92] = t28;
|
|
451
|
-
} else {
|
|
452
|
-
t28 = $[92];
|
|
453
|
-
}
|
|
454
|
-
const handleSelectMinute = t28;
|
|
455
|
-
const handleSelectDay = (day) => {
|
|
456
|
-
const {
|
|
457
|
-
hour: hour_2,
|
|
458
|
-
minute: minute_2,
|
|
459
|
-
isComplete
|
|
460
|
-
} = timeSelection;
|
|
461
|
-
if (isDateTime && !isComplete) {
|
|
462
|
-
handleUpdateDraftState(day.clone().hour(hour_2 ?? 0).minute(minute_2 ?? 0), hour_2, minute_2);
|
|
463
|
-
return;
|
|
464
138
|
}
|
|
465
|
-
const dayWithTime = isDateTime && selectedDate ? day.clone().hour(selectedDate.hour()).minute(selectedDate.minute()) : day;
|
|
466
|
-
handleUpdateDateState(clampDateToBounds(dayWithTime, minDate, maxDate));
|
|
467
139
|
};
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
$[111] = skeletonize;
|
|
526
|
-
$[112] = t32;
|
|
527
|
-
$[113] = t33;
|
|
528
|
-
$[114] = unmaskedValue;
|
|
529
|
-
$[115] = t34;
|
|
530
|
-
} else {
|
|
531
|
-
t34 = $[115];
|
|
532
|
-
}
|
|
533
|
-
const contextValues = t34;
|
|
534
|
-
let t35;
|
|
535
|
-
if ($[116] !== customClassLabel || $[117] !== disabled || $[118] !== hasHintMessages || $[119] !== hasLabel || $[120] !== hintPosition || $[121] !== inputId || $[122] !== label || $[123] !== labelUppercase || $[124] !== popoverAlign || $[125] !== props.hint || $[126] !== props.required || $[127] !== readOnly || $[128] !== skeletonize || $[129] !== themePopover) {
|
|
536
|
-
t35 = hasLabel && /* @__PURE__ */ jsx(Label, { "data-testid": "test-date-field-label", label, inputId, hint: props?.hint, isDisabled: disabled, isReadOnly: readOnly, skeletonize, required: props?.required, hintPosition, themePopover, popoverAlign, labelUppercase, hasHintMessages, customClassLabel });
|
|
537
|
-
$[116] = customClassLabel;
|
|
538
|
-
$[117] = disabled;
|
|
539
|
-
$[118] = hasHintMessages;
|
|
540
|
-
$[119] = hasLabel;
|
|
541
|
-
$[120] = hintPosition;
|
|
542
|
-
$[121] = inputId;
|
|
543
|
-
$[122] = label;
|
|
544
|
-
$[123] = labelUppercase;
|
|
545
|
-
$[124] = popoverAlign;
|
|
546
|
-
$[125] = props.hint;
|
|
547
|
-
$[126] = props.required;
|
|
548
|
-
$[127] = readOnly;
|
|
549
|
-
$[128] = skeletonize;
|
|
550
|
-
$[129] = themePopover;
|
|
551
|
-
$[130] = t35;
|
|
552
|
-
} else {
|
|
553
|
-
t35 = $[130];
|
|
554
|
-
}
|
|
555
|
-
let t36;
|
|
556
|
-
if ($[131] !== ref) {
|
|
557
|
-
t36 = mergeRefs(ref, dateInputRef);
|
|
558
|
-
$[131] = ref;
|
|
559
|
-
$[132] = t36;
|
|
560
|
-
} else {
|
|
561
|
-
t36 = $[132];
|
|
562
|
-
}
|
|
563
|
-
const t37 = props?.name;
|
|
564
|
-
const t38 = !readOnly && !skeletonize ? 0 : -1;
|
|
565
|
-
let t39;
|
|
566
|
-
if ($[133] !== activeDescendant || $[134] !== calendarBoxOpen || $[135] !== customClass || $[136] !== disabled || $[137] !== handleOnBeforeInput || $[138] !== handleOnBlur || $[139] !== handleOnFocus || $[140] !== handleOnKeyDown || $[141] !== handleOnKeyDownCapture || $[142] !== handleOnPaste || $[143] !== hasValidationErrors || $[144] !== inputId || $[145] !== inputPlaceholder || $[146] !== maskedValue || $[147] !== readOnly || $[148] !== rest || $[149] !== skeletonize || $[150] !== t36 || $[151] !== t37 || $[152] !== t38 || $[153] !== textAlign || $[154] !== undigitable) {
|
|
567
|
-
t39 = /* @__PURE__ */ jsx(Input, { ...rest, ref: t36, id: inputId, name: t37, value: maskedValue, readOnly, disabled, customClass, tabIndex: t38, placeholder: inputPlaceholder, "aria-activedescendant": activeDescendant, "aria-expanded": calendarBoxOpen, "aria-controls": inputId, "aria-labelledby": inputId, "data-state-is-period-input": false, "data-testid": "test-date-field-input", "data-state-error": hasValidationErrors, "data-state-read-only": readOnly, "data-state-text-align": textAlign, "data-state-undigitable": undigitable, "data-state-skeletonize": skeletonize, onBlur: handleOnBlur, onFocus: handleOnFocus, onPaste: handleOnPaste, onKeyDown: handleOnKeyDown, onKeyDownCapture: handleOnKeyDownCapture, onBeforeInput: handleOnBeforeInput });
|
|
568
|
-
$[133] = activeDescendant;
|
|
569
|
-
$[134] = calendarBoxOpen;
|
|
570
|
-
$[135] = customClass;
|
|
571
|
-
$[136] = disabled;
|
|
572
|
-
$[137] = handleOnBeforeInput;
|
|
573
|
-
$[138] = handleOnBlur;
|
|
574
|
-
$[139] = handleOnFocus;
|
|
575
|
-
$[140] = handleOnKeyDown;
|
|
576
|
-
$[141] = handleOnKeyDownCapture;
|
|
577
|
-
$[142] = handleOnPaste;
|
|
578
|
-
$[143] = hasValidationErrors;
|
|
579
|
-
$[144] = inputId;
|
|
580
|
-
$[145] = inputPlaceholder;
|
|
581
|
-
$[146] = maskedValue;
|
|
582
|
-
$[147] = readOnly;
|
|
583
|
-
$[148] = rest;
|
|
584
|
-
$[149] = skeletonize;
|
|
585
|
-
$[150] = t36;
|
|
586
|
-
$[151] = t37;
|
|
587
|
-
$[152] = t38;
|
|
588
|
-
$[153] = textAlign;
|
|
589
|
-
$[154] = undigitable;
|
|
590
|
-
$[155] = t39;
|
|
591
|
-
} else {
|
|
592
|
-
t39 = $[155];
|
|
593
|
-
}
|
|
594
|
-
let t40;
|
|
595
|
-
if ($[156] === Symbol.for("react.memo_cache_sentinel")) {
|
|
596
|
-
t40 = /* @__PURE__ */ jsx(Triggers, {});
|
|
597
|
-
$[156] = t40;
|
|
598
|
-
} else {
|
|
599
|
-
t40 = $[156];
|
|
600
|
-
}
|
|
601
|
-
let t41;
|
|
602
|
-
if ($[157] !== customClassInputContainer || $[158] !== dateContainerRef || $[159] !== skeletonize || $[160] !== t39) {
|
|
603
|
-
t41 = /* @__PURE__ */ jsxs(Container, { ref: dateContainerRef, skeletonize, customClassInputContainer, children: [
|
|
604
|
-
t39,
|
|
605
|
-
t40
|
|
606
|
-
] });
|
|
607
|
-
$[157] = customClassInputContainer;
|
|
608
|
-
$[158] = dateContainerRef;
|
|
609
|
-
$[159] = skeletonize;
|
|
610
|
-
$[160] = t39;
|
|
611
|
-
$[161] = t41;
|
|
612
|
-
} else {
|
|
613
|
-
t41 = $[161];
|
|
614
|
-
}
|
|
615
|
-
let t42;
|
|
616
|
-
if ($[162] !== activeDescendant || $[163] !== calendarBoxOpen || $[164] !== calendarDisplayDate || $[165] !== calendarRef || $[166] !== dateContainerRef || $[167] !== handleNextMonth || $[168] !== handlePreviousMonth || $[169] !== handleSelectDay || $[170] !== handleSelectHour || $[171] !== handleSelectMinute || $[172] !== hasBounds || $[173] !== inputId || $[174] !== isDateTime || $[175] !== maxDate || $[176] !== minDate || $[177] !== selectedDate || $[178] !== timeSelection) {
|
|
617
|
-
t42 = calendarBoxOpen && createPortal(/* @__PURE__ */ jsx(CalendarBox, { ref: calendarRef, testIdPrefix: "test-date-field", headerId: inputId, calendarBoxOpen, activeDescendant, calendarDisplayDate, containerRef: dateContainerRef, onNextMonth: handleNextMonth, onPreviousMonth: handlePreviousMonth, getDayState: (day_0) => ({
|
|
618
|
-
isSelected: selectedDate ? day_0.isSame(selectedDate, "day") : false,
|
|
619
|
-
...hasBounds && {
|
|
620
|
-
isDisabled: isDayOutOfBounds(day_0, minDate, maxDate)
|
|
140
|
+
const handleOnFocus = (event_0) => {
|
|
141
|
+
props?.onFocus?.(event_0);
|
|
142
|
+
setActiveDescendant((selectedDate ?? hooks()).format(TOKEN_ISO_FORMAT));
|
|
143
|
+
setCalendarDisplayDate(selectedDate ?? hooks());
|
|
144
|
+
if (!readOnly && openCalendarOnFocus) {
|
|
145
|
+
handleOpenCalendar();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const handleOnPaste = (event_1) => {
|
|
149
|
+
if (undigitable) {
|
|
150
|
+
event_1.preventDefault();
|
|
151
|
+
} else {
|
|
152
|
+
props.onPaste?.(event_1);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const handleOnBeforeInput = (event_2) => {
|
|
156
|
+
if (undigitable) {
|
|
157
|
+
event_2.preventDefault();
|
|
158
|
+
} else {
|
|
159
|
+
props.onBeforeInput?.(event_2);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const handleOnKeyDown = (event_3) => {
|
|
163
|
+
props?.onKeyDown?.(event_3);
|
|
164
|
+
if (calendarBoxOpen && event_3.key && !event_3.shiftKey && !event_3.altKey && NAVIGATION_KEYS.includes(event_3.key)) {
|
|
165
|
+
event_3.preventDefault();
|
|
166
|
+
switch (event_3.key) {
|
|
167
|
+
case Keys.arrowLeft:
|
|
168
|
+
handleNavigateWithDays(-1);
|
|
169
|
+
break;
|
|
170
|
+
case Keys.arrowRight:
|
|
171
|
+
handleNavigateWithDays(1);
|
|
172
|
+
break;
|
|
173
|
+
case Keys.arrowUp:
|
|
174
|
+
handleNavigateWithDays(-7);
|
|
175
|
+
break;
|
|
176
|
+
case Keys.arrowDown:
|
|
177
|
+
handleNavigateWithDays(7);
|
|
178
|
+
break;
|
|
179
|
+
case Keys.pageUp:
|
|
180
|
+
handleNextMonth();
|
|
181
|
+
break;
|
|
182
|
+
case Keys.pageDown:
|
|
183
|
+
handlePreviousMonth();
|
|
184
|
+
break;
|
|
185
|
+
case Keys.home:
|
|
186
|
+
handleNavigateWithWeeks("start");
|
|
187
|
+
break;
|
|
188
|
+
case Keys.end:
|
|
189
|
+
handleNavigateWithWeeks("end");
|
|
190
|
+
break;
|
|
191
|
+
case Keys.escape:
|
|
192
|
+
handleCloseCalendar();
|
|
193
|
+
break;
|
|
194
|
+
case Keys.enter:
|
|
195
|
+
handleUpdateDateState(hooks(_.toString(activeDescendant), TOKEN_ISO_FORMAT));
|
|
196
|
+
break;
|
|
621
197
|
}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
t42,
|
|
673
|
-
t43,
|
|
674
|
-
t44
|
|
675
|
-
] });
|
|
676
|
-
$[191] = customClassWrapper;
|
|
677
|
-
$[192] = hasValidationErrors;
|
|
678
|
-
$[193] = t35;
|
|
679
|
-
$[194] = t41;
|
|
680
|
-
$[195] = t42;
|
|
681
|
-
$[196] = t43;
|
|
682
|
-
$[197] = t44;
|
|
683
|
-
$[198] = t45;
|
|
684
|
-
} else {
|
|
685
|
-
t45 = $[198];
|
|
686
|
-
}
|
|
687
|
-
let t46;
|
|
688
|
-
if ($[199] !== contextValues || $[200] !== t45) {
|
|
689
|
-
t46 = /* @__PURE__ */ jsx(DateFieldContext.Provider, { value: contextValues, children: t45 });
|
|
690
|
-
$[199] = contextValues;
|
|
691
|
-
$[200] = t45;
|
|
692
|
-
$[201] = t46;
|
|
693
|
-
} else {
|
|
694
|
-
t46 = $[201];
|
|
695
|
-
}
|
|
696
|
-
let t47;
|
|
697
|
-
if ($[202] !== tooltip || $[203] !== tooltipPosition || $[204] !== tooltipWidth) {
|
|
698
|
-
t47 = /* @__PURE__ */ jsx(Tooltip, { targetRef: inputRootRef, text: tooltip, width: tooltipWidth, position: tooltipPosition });
|
|
699
|
-
$[202] = tooltip;
|
|
700
|
-
$[203] = tooltipPosition;
|
|
701
|
-
$[204] = tooltipWidth;
|
|
702
|
-
$[205] = t47;
|
|
703
|
-
} else {
|
|
704
|
-
t47 = $[205];
|
|
705
|
-
}
|
|
706
|
-
let t48;
|
|
707
|
-
if ($[206] !== t46 || $[207] !== t47) {
|
|
708
|
-
t48 = /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
709
|
-
t46,
|
|
710
|
-
t47
|
|
711
|
-
] });
|
|
712
|
-
$[206] = t46;
|
|
713
|
-
$[207] = t47;
|
|
714
|
-
$[208] = t48;
|
|
715
|
-
} else {
|
|
716
|
-
t48 = $[208];
|
|
717
|
-
}
|
|
718
|
-
return t48;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
React.useEffect(() => {
|
|
201
|
+
const currentValue = props?.value ?? null;
|
|
202
|
+
const date_2 = hooks(_.toString(currentValue), TOKEN_ISO_FORMAT);
|
|
203
|
+
setSelectedDate(date_2.isValid() ? date_2 : null);
|
|
204
|
+
setMaskValue(date_2.format(TOKEN_PTBR_FORMAT));
|
|
205
|
+
}, [props?.value]);
|
|
206
|
+
const contextValues = {
|
|
207
|
+
label,
|
|
208
|
+
inputFieldId: inputId,
|
|
209
|
+
activeDescendant,
|
|
210
|
+
calendarBoxOpen,
|
|
211
|
+
isReadOnly: Boolean(readOnly),
|
|
212
|
+
isDisabled: Boolean(disabled),
|
|
213
|
+
skeletonize,
|
|
214
|
+
showCalendarButton,
|
|
215
|
+
hasValidDateSelected,
|
|
216
|
+
dateInputRef,
|
|
217
|
+
dateContainerRef,
|
|
218
|
+
handleOpenCalendar,
|
|
219
|
+
handleCloseCalendar,
|
|
220
|
+
handleNextMonth,
|
|
221
|
+
handlePreviousMonth,
|
|
222
|
+
handleSelectDate: handleUpdateDateState,
|
|
223
|
+
selectedDate,
|
|
224
|
+
unmaskedValue,
|
|
225
|
+
maskedValue,
|
|
226
|
+
showClearDateButton,
|
|
227
|
+
handleChangeCalendarBoxState,
|
|
228
|
+
handleOnClickClearSelectedDate,
|
|
229
|
+
calendarDisplayDate,
|
|
230
|
+
calendarRef
|
|
231
|
+
};
|
|
232
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
233
|
+
/* @__PURE__ */ jsx(DateFieldContext.Provider, { value: contextValues, children: /* @__PURE__ */ jsxs(Root, { ref: inputRootRef, "data-testid": "test-date-field-root", customClassWrapper, hasValidationErrors, children: [
|
|
234
|
+
hasLabel && /* @__PURE__ */ jsx(Label, { "data-testid": "test-date-field-label", label, inputId, hint: props?.hint, isDisabled: disabled, isReadOnly: readOnly, skeletonize, required: props?.required, hintPosition, themePopover, popoverAlign, labelUppercase, hasHintMessages, customClassLabel }),
|
|
235
|
+
/* @__PURE__ */ jsxs(Container, { ref: dateContainerRef, skeletonize, customClassInputContainer, children: [
|
|
236
|
+
/* @__PURE__ */ jsx(Input, { ...rest, ref: mergeRefs(ref, dateInputRef), id: inputId, name: props?.name, value: maskedValue, readOnly, disabled, customClass, tabIndex: !readOnly && !skeletonize ? 0 : -1, placeholder, "aria-activedescendant": activeDescendant, "aria-expanded": calendarBoxOpen, "aria-controls": inputId, "aria-labelledby": inputId, "data-state-is-period-input": false, "data-testid": "test-date-field-input", "data-state-error": hasValidationErrors, "data-state-read-only": readOnly, "data-state-text-align": textAlign, "data-state-undigitable": undigitable, "data-state-skeletonize": skeletonize, onBlur: handleOnBlur, onFocus: handleOnFocus, onPaste: handleOnPaste, onKeyDown: handleOnKeyDown, onBeforeInput: handleOnBeforeInput }),
|
|
237
|
+
/* @__PURE__ */ jsx(Triggers, {})
|
|
238
|
+
] }),
|
|
239
|
+
calendarBoxOpen && createPortal(/* @__PURE__ */ jsx(CalendarBox, { ref: calendarRef }), document.body),
|
|
240
|
+
hintPosition === "below" && /* @__PURE__ */ jsx(Hint, { customClass: "hint", description: props.hint, disabled, skeletonize, visible: hasHintMessages }),
|
|
241
|
+
hasValidationErrors && /* @__PURE__ */ jsx("span", { "data-testid": "test-date-field-list-errors", className: "error", "data-state-skeletonize": skeletonize, "aria-describedby": String(props.name).concat("-errors"), children: errors?.map((error, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
242
|
+
error,
|
|
243
|
+
" "
|
|
244
|
+
] }, `${index + 1}-${error}`)) })
|
|
245
|
+
] }) }),
|
|
246
|
+
/* @__PURE__ */ jsx(Tooltip, { targetRef: inputRootRef, text: tooltip, width: tooltipWidth, position: tooltipPosition })
|
|
247
|
+
] });
|
|
719
248
|
});
|
|
720
249
|
InputBase.displayName = "DateFieldInputBase";
|
|
721
|
-
function _temp(error, index) {
|
|
722
|
-
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
723
|
-
error,
|
|
724
|
-
" "
|
|
725
|
-
] }, `${index + 1}-${error}`);
|
|
726
|
-
}
|
|
727
250
|
export {
|
|
728
251
|
InputBase
|
|
729
252
|
};
|