@mantine/dates 9.0.0-alpha.2 → 9.0.0-alpha.4
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/cjs/components/Calendar/Calendar.cjs +6 -3
- package/cjs/components/Calendar/Calendar.cjs.map +1 -1
- package/cjs/components/DateInput/DateInput.cjs +5 -3
- package/cjs/components/DateInput/DateInput.cjs.map +1 -1
- package/esm/components/Calendar/Calendar.mjs +6 -3
- package/esm/components/Calendar/Calendar.mjs.map +1 -1
- package/esm/components/DateInput/DateInput.mjs +5 -3
- package/esm/components/DateInput/DateInput.mjs.map +1 -1
- package/lib/components/DateInput/DateInput.d.ts +2 -0
- package/package.json +3 -3
- package/cjs/components/MaskedDateInput/MaskedDateInput.cjs +0 -632
- package/cjs/components/MaskedDateInput/MaskedDateInput.cjs.map +0 -1
- package/cjs/components/MaskedDateInput/MaskedDateInput.context.cjs +0 -12
- package/cjs/components/MaskedDateInput/MaskedDateInput.context.cjs.map +0 -1
- package/cjs/components/MaskedDateInput/MaskedDateInput.module.css.cjs +0 -7
- package/cjs/components/MaskedDateInput/MaskedDateInput.module.css.cjs.map +0 -1
- package/cjs/components/MaskedDateInput/use-masked-date-input.cjs +0 -447
- package/cjs/components/MaskedDateInput/use-masked-date-input.cjs.map +0 -1
- package/esm/components/MaskedDateInput/MaskedDateInput.context.mjs +0 -9
- package/esm/components/MaskedDateInput/MaskedDateInput.context.mjs.map +0 -1
- package/esm/components/MaskedDateInput/MaskedDateInput.mjs +0 -626
- package/esm/components/MaskedDateInput/MaskedDateInput.mjs.map +0 -1
- package/esm/components/MaskedDateInput/MaskedDateInput.module.css.mjs +0 -5
- package/esm/components/MaskedDateInput/MaskedDateInput.module.css.mjs.map +0 -1
- package/esm/components/MaskedDateInput/use-masked-date-input.mjs +0 -441
- package/esm/components/MaskedDateInput/use-masked-date-input.mjs.map +0 -1
- package/lib/components/MaskedDateInput/MaskedDateInput.context.d.ts +0 -7
- package/lib/components/MaskedDateInput/MaskedDateInput.d.ts +0 -123
- package/lib/components/MaskedDateInput/MaskedDateInput.types.d.ts +0 -19
- package/lib/components/MaskedDateInput/index.d.ts +0 -12
- package/lib/components/MaskedDateInput/use-masked-date-input.d.ts +0 -56
|
@@ -1,626 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
|
-
import { useRef, useState } from 'react';
|
|
5
|
-
import { factory, useProps, useResolvedStylesApi, useStyles, Popover, InputBase, CloseButton } from '@mantine/core';
|
|
6
|
-
import { useMergedRef, useId } from '@mantine/hooks';
|
|
7
|
-
import { Calendar } from '../Calendar/Calendar.mjs';
|
|
8
|
-
import { pickCalendarProps } from '../Calendar/pick-calendar-levels-props/pick-calendar-levels-props.mjs';
|
|
9
|
-
import '../DatesProvider/DatesProvider.mjs';
|
|
10
|
-
import { useDatesContext } from '../DatesProvider/use-dates-context.mjs';
|
|
11
|
-
import { isSameMonth } from '../Month/is-same-month/is-same-month.mjs';
|
|
12
|
-
import '../Month/Month.mjs';
|
|
13
|
-
import { SpinInput } from '../SpinInput/SpinInput.mjs';
|
|
14
|
-
import { MaskedDateInputProvider } from './MaskedDateInput.context.mjs';
|
|
15
|
-
import classes from './MaskedDateInput.module.css.mjs';
|
|
16
|
-
import { useMaskedDateInput } from './use-masked-date-input.mjs';
|
|
17
|
-
|
|
18
|
-
function SimpleAmPmSelect({
|
|
19
|
-
labels,
|
|
20
|
-
value,
|
|
21
|
-
onChange,
|
|
22
|
-
className,
|
|
23
|
-
style,
|
|
24
|
-
onPreviousInput,
|
|
25
|
-
readOnly,
|
|
26
|
-
onMouseDown,
|
|
27
|
-
disabled,
|
|
28
|
-
...others
|
|
29
|
-
}) {
|
|
30
|
-
const handleKeyDown = (event) => {
|
|
31
|
-
if (readOnly) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (event.key === "Home") {
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
onChange(labels.am);
|
|
37
|
-
}
|
|
38
|
-
if (event.key === "End") {
|
|
39
|
-
event.preventDefault();
|
|
40
|
-
onChange(labels.pm);
|
|
41
|
-
}
|
|
42
|
-
if (event.key === "Backspace" || event.key === "Delete") {
|
|
43
|
-
event.preventDefault();
|
|
44
|
-
if (value === null) {
|
|
45
|
-
onPreviousInput?.();
|
|
46
|
-
} else {
|
|
47
|
-
onChange(null);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (event.key === "ArrowLeft") {
|
|
51
|
-
event.preventDefault();
|
|
52
|
-
onPreviousInput?.();
|
|
53
|
-
}
|
|
54
|
-
if (event.key === "ArrowUp" || event.key === "ArrowDown") {
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
onChange(value === labels.am ? labels.pm : labels.am);
|
|
57
|
-
}
|
|
58
|
-
if (event.code === "KeyA") {
|
|
59
|
-
event.preventDefault();
|
|
60
|
-
onChange(labels.am);
|
|
61
|
-
}
|
|
62
|
-
if (event.code === "KeyP") {
|
|
63
|
-
event.preventDefault();
|
|
64
|
-
onChange(labels.pm);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
return /* @__PURE__ */ jsxs(
|
|
68
|
-
"select",
|
|
69
|
-
{
|
|
70
|
-
className,
|
|
71
|
-
style,
|
|
72
|
-
value: value || "",
|
|
73
|
-
onChange: (event) => !readOnly && onChange(event.target.value || null),
|
|
74
|
-
onClick: (event) => event.stopPropagation(),
|
|
75
|
-
onKeyDown: handleKeyDown,
|
|
76
|
-
onMouseDown: (event) => {
|
|
77
|
-
event.stopPropagation();
|
|
78
|
-
onMouseDown?.(event);
|
|
79
|
-
},
|
|
80
|
-
disabled,
|
|
81
|
-
"data-am-pm": true,
|
|
82
|
-
"data-mantine-stop-propagation": true,
|
|
83
|
-
...others,
|
|
84
|
-
children: [
|
|
85
|
-
/* @__PURE__ */ jsx("option", { value: "", children: "--" }),
|
|
86
|
-
/* @__PURE__ */ jsx("option", { value: labels.am, children: labels.am }),
|
|
87
|
-
/* @__PURE__ */ jsx("option", { value: labels.pm, children: labels.pm })
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
const defaultProps = {
|
|
93
|
-
dateFieldsOrder: ["day", "month", "year"],
|
|
94
|
-
dateSeparator: "/",
|
|
95
|
-
timeSeparator: ":",
|
|
96
|
-
dateTimeSeparator: " ",
|
|
97
|
-
timeFormat: "24h",
|
|
98
|
-
amPmLabels: { am: "AM", pm: "PM" },
|
|
99
|
-
dayPlaceholder: "DD",
|
|
100
|
-
monthPlaceholder: "MM",
|
|
101
|
-
yearPlaceholder: "YYYY",
|
|
102
|
-
hoursPlaceholder: "--",
|
|
103
|
-
minutesPlaceholder: "--",
|
|
104
|
-
secondsPlaceholder: "--"
|
|
105
|
-
};
|
|
106
|
-
const MaskedDateInput = factory((_props) => {
|
|
107
|
-
const props = useProps("MaskedDateInput", defaultProps, _props);
|
|
108
|
-
const {
|
|
109
|
-
classNames,
|
|
110
|
-
className,
|
|
111
|
-
style,
|
|
112
|
-
styles,
|
|
113
|
-
unstyled,
|
|
114
|
-
vars,
|
|
115
|
-
dateFieldsOrder,
|
|
116
|
-
dateSeparator,
|
|
117
|
-
timeSeparator,
|
|
118
|
-
dateTimeSeparator,
|
|
119
|
-
withTime,
|
|
120
|
-
withSeconds,
|
|
121
|
-
timeFormat,
|
|
122
|
-
amPmLabels,
|
|
123
|
-
value,
|
|
124
|
-
defaultValue,
|
|
125
|
-
onChange,
|
|
126
|
-
clearable,
|
|
127
|
-
clearButtonProps,
|
|
128
|
-
popoverProps,
|
|
129
|
-
name,
|
|
130
|
-
form,
|
|
131
|
-
onFocus,
|
|
132
|
-
onBlur,
|
|
133
|
-
readOnly,
|
|
134
|
-
disabled,
|
|
135
|
-
size,
|
|
136
|
-
dayInputProps,
|
|
137
|
-
monthInputProps,
|
|
138
|
-
yearInputProps,
|
|
139
|
-
hoursInputProps,
|
|
140
|
-
minutesInputProps,
|
|
141
|
-
secondsInputProps,
|
|
142
|
-
amPmSelectProps,
|
|
143
|
-
hiddenInputProps,
|
|
144
|
-
pasteSplit,
|
|
145
|
-
dayRef,
|
|
146
|
-
monthRef,
|
|
147
|
-
yearRef,
|
|
148
|
-
hoursRef,
|
|
149
|
-
minutesRef,
|
|
150
|
-
secondsRef,
|
|
151
|
-
amPmRef,
|
|
152
|
-
dayPlaceholder,
|
|
153
|
-
monthPlaceholder,
|
|
154
|
-
yearPlaceholder,
|
|
155
|
-
hoursPlaceholder,
|
|
156
|
-
minutesPlaceholder,
|
|
157
|
-
secondsPlaceholder,
|
|
158
|
-
dayInputLabel,
|
|
159
|
-
monthInputLabel,
|
|
160
|
-
yearInputLabel,
|
|
161
|
-
hoursInputLabel,
|
|
162
|
-
minutesInputLabel,
|
|
163
|
-
secondsInputLabel,
|
|
164
|
-
amPmInputLabel,
|
|
165
|
-
rightSection,
|
|
166
|
-
labelProps,
|
|
167
|
-
attributes,
|
|
168
|
-
onClick,
|
|
169
|
-
onMouseDown,
|
|
170
|
-
onFocusCapture,
|
|
171
|
-
onBlurCapture,
|
|
172
|
-
getDayProps,
|
|
173
|
-
getMonthControlProps,
|
|
174
|
-
getYearControlProps,
|
|
175
|
-
locale,
|
|
176
|
-
minDate,
|
|
177
|
-
maxDate,
|
|
178
|
-
...others
|
|
179
|
-
} = props;
|
|
180
|
-
const { calendarProps, others: rest } = pickCalendarProps(others);
|
|
181
|
-
useDatesContext();
|
|
182
|
-
const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
|
|
183
|
-
classNames,
|
|
184
|
-
styles,
|
|
185
|
-
props
|
|
186
|
-
});
|
|
187
|
-
const getStyles = useStyles({
|
|
188
|
-
name: "MaskedDateInput",
|
|
189
|
-
classes,
|
|
190
|
-
props,
|
|
191
|
-
className,
|
|
192
|
-
style,
|
|
193
|
-
classNames,
|
|
194
|
-
styles,
|
|
195
|
-
unstyled,
|
|
196
|
-
attributes,
|
|
197
|
-
vars
|
|
198
|
-
});
|
|
199
|
-
const controller = useMaskedDateInput({
|
|
200
|
-
value: value || void 0,
|
|
201
|
-
defaultValue: defaultValue || void 0,
|
|
202
|
-
onChange,
|
|
203
|
-
withTime,
|
|
204
|
-
withSeconds,
|
|
205
|
-
format: timeFormat,
|
|
206
|
-
amPmLabels,
|
|
207
|
-
min: void 0,
|
|
208
|
-
max: void 0,
|
|
209
|
-
minDate,
|
|
210
|
-
maxDate,
|
|
211
|
-
clearable,
|
|
212
|
-
readOnly,
|
|
213
|
-
disabled,
|
|
214
|
-
pasteSplit
|
|
215
|
-
});
|
|
216
|
-
const _dayRef = useMergedRef(controller.refs.day, dayRef);
|
|
217
|
-
const _monthRef = useMergedRef(controller.refs.month, monthRef);
|
|
218
|
-
const _yearRef = useMergedRef(controller.refs.year, yearRef);
|
|
219
|
-
const _hoursRef = useMergedRef(controller.refs.hours, hoursRef);
|
|
220
|
-
const _minutesRef = useMergedRef(controller.refs.minutes, minutesRef);
|
|
221
|
-
const _secondsRef = useMergedRef(controller.refs.seconds, secondsRef);
|
|
222
|
-
const _amPmRef = useMergedRef(controller.refs.amPm, amPmRef);
|
|
223
|
-
const dayInputId = useId();
|
|
224
|
-
const hasFocusRef = useRef(false);
|
|
225
|
-
const [dropdownOpened, setDropdownOpened] = useState(false);
|
|
226
|
-
const handleFocus = (event) => {
|
|
227
|
-
if (!hasFocusRef.current) {
|
|
228
|
-
hasFocusRef.current = true;
|
|
229
|
-
onFocus?.(event);
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
const handleBlur = (event) => {
|
|
233
|
-
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
234
|
-
hasFocusRef.current = false;
|
|
235
|
-
onBlur?.(event);
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
const getNextField = (currentField, order) => {
|
|
239
|
-
const currentIndex = order.indexOf(currentField);
|
|
240
|
-
if (currentIndex < order.length - 1) {
|
|
241
|
-
return order[currentIndex + 1];
|
|
242
|
-
}
|
|
243
|
-
return withTime ? "hours" : null;
|
|
244
|
-
};
|
|
245
|
-
const getPreviousField = (currentField, order) => {
|
|
246
|
-
const currentIndex = order.indexOf(currentField);
|
|
247
|
-
if (currentIndex > 0) {
|
|
248
|
-
return order[currentIndex - 1];
|
|
249
|
-
}
|
|
250
|
-
return null;
|
|
251
|
-
};
|
|
252
|
-
const handleDateSelect = (selectedDate) => {
|
|
253
|
-
dayjs(selectedDate);
|
|
254
|
-
controller.setDateValue(selectedDate);
|
|
255
|
-
setDropdownOpened(false);
|
|
256
|
-
};
|
|
257
|
-
const _getDayProps = (day) => ({
|
|
258
|
-
...getDayProps?.(day),
|
|
259
|
-
selected: controller.calendarValue ? dayjs(controller.calendarValue).isSame(day, "day") : false,
|
|
260
|
-
onClick: (event) => {
|
|
261
|
-
getDayProps?.(day)?.onClick?.(event);
|
|
262
|
-
handleDateSelect(day);
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
const renderDateField = (field, isFirst, isLast) => {
|
|
266
|
-
const fieldOrder = dateFieldsOrder;
|
|
267
|
-
const getOnPreviousInput = () => {
|
|
268
|
-
const previousField = getPreviousField(field, fieldOrder);
|
|
269
|
-
return previousField ? () => controller.focus(previousField) : void 0;
|
|
270
|
-
};
|
|
271
|
-
const getOnNextInput = () => {
|
|
272
|
-
const nextField = getNextField(field, fieldOrder);
|
|
273
|
-
return nextField ? () => controller.focus(nextField) : void 0;
|
|
274
|
-
};
|
|
275
|
-
switch (field) {
|
|
276
|
-
case "day":
|
|
277
|
-
return /* @__PURE__ */ jsx(
|
|
278
|
-
SpinInput,
|
|
279
|
-
{
|
|
280
|
-
id: isFirst ? dayInputId : void 0,
|
|
281
|
-
...dayInputProps,
|
|
282
|
-
...getStyles("field", {
|
|
283
|
-
className: dayInputProps?.className,
|
|
284
|
-
style: dayInputProps?.style
|
|
285
|
-
}),
|
|
286
|
-
value: controller.values.day,
|
|
287
|
-
onChange: controller.setDay,
|
|
288
|
-
onNextInput: getOnNextInput(),
|
|
289
|
-
onPreviousInput: getOnPreviousInput(),
|
|
290
|
-
min: 1,
|
|
291
|
-
max: controller.getDaysInMonth(),
|
|
292
|
-
focusable: true,
|
|
293
|
-
step: 1,
|
|
294
|
-
ref: _dayRef,
|
|
295
|
-
"aria-label": dayInputLabel,
|
|
296
|
-
readOnly,
|
|
297
|
-
disabled,
|
|
298
|
-
onPaste: controller.onPaste,
|
|
299
|
-
onFocus: (event) => {
|
|
300
|
-
handleFocus(event);
|
|
301
|
-
dayInputProps?.onFocus?.(event);
|
|
302
|
-
},
|
|
303
|
-
placeholder: dayPlaceholder,
|
|
304
|
-
tabIndex: isFirst ? 0 : -1
|
|
305
|
-
},
|
|
306
|
-
"day"
|
|
307
|
-
);
|
|
308
|
-
case "month":
|
|
309
|
-
return /* @__PURE__ */ jsx(
|
|
310
|
-
SpinInput,
|
|
311
|
-
{
|
|
312
|
-
id: isFirst ? dayInputId : void 0,
|
|
313
|
-
...monthInputProps,
|
|
314
|
-
...getStyles("field", {
|
|
315
|
-
className: monthInputProps?.className,
|
|
316
|
-
style: monthInputProps?.style
|
|
317
|
-
}),
|
|
318
|
-
value: controller.values.month,
|
|
319
|
-
onChange: controller.setMonth,
|
|
320
|
-
onNextInput: getOnNextInput(),
|
|
321
|
-
onPreviousInput: getOnPreviousInput(),
|
|
322
|
-
min: 1,
|
|
323
|
-
max: 12,
|
|
324
|
-
focusable: true,
|
|
325
|
-
step: 1,
|
|
326
|
-
ref: _monthRef,
|
|
327
|
-
"aria-label": monthInputLabel,
|
|
328
|
-
readOnly,
|
|
329
|
-
disabled,
|
|
330
|
-
onPaste: controller.onPaste,
|
|
331
|
-
onFocus: (event) => {
|
|
332
|
-
handleFocus(event);
|
|
333
|
-
monthInputProps?.onFocus?.(event);
|
|
334
|
-
},
|
|
335
|
-
placeholder: monthPlaceholder,
|
|
336
|
-
tabIndex: isFirst ? 0 : -1
|
|
337
|
-
},
|
|
338
|
-
"month"
|
|
339
|
-
);
|
|
340
|
-
case "year":
|
|
341
|
-
return /* @__PURE__ */ jsx(
|
|
342
|
-
SpinInput,
|
|
343
|
-
{
|
|
344
|
-
id: isFirst ? dayInputId : void 0,
|
|
345
|
-
...yearInputProps,
|
|
346
|
-
...getStyles("yearField", {
|
|
347
|
-
className: yearInputProps?.className,
|
|
348
|
-
style: yearInputProps?.style
|
|
349
|
-
}),
|
|
350
|
-
value: controller.values.year,
|
|
351
|
-
onChange: controller.setYear,
|
|
352
|
-
onNextInput: getOnNextInput(),
|
|
353
|
-
onPreviousInput: getOnPreviousInput(),
|
|
354
|
-
min: 1,
|
|
355
|
-
max: 9999,
|
|
356
|
-
focusable: true,
|
|
357
|
-
step: 1,
|
|
358
|
-
ref: _yearRef,
|
|
359
|
-
"aria-label": yearInputLabel,
|
|
360
|
-
readOnly,
|
|
361
|
-
disabled,
|
|
362
|
-
onPaste: controller.onPaste,
|
|
363
|
-
onFocus: (event) => {
|
|
364
|
-
handleFocus(event);
|
|
365
|
-
yearInputProps?.onFocus?.(event);
|
|
366
|
-
},
|
|
367
|
-
placeholder: yearPlaceholder,
|
|
368
|
-
tabIndex: isFirst ? 0 : -1
|
|
369
|
-
},
|
|
370
|
-
"year"
|
|
371
|
-
);
|
|
372
|
-
default:
|
|
373
|
-
return null;
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
const dateFields = dateFieldsOrder.map((field, index) => {
|
|
377
|
-
const isFirst = index === 0;
|
|
378
|
-
const isLast = index === dateFieldsOrder.length - 1;
|
|
379
|
-
const fieldElement = renderDateField(field, isFirst);
|
|
380
|
-
if (isLast) {
|
|
381
|
-
return fieldElement;
|
|
382
|
-
}
|
|
383
|
-
return /* @__PURE__ */ jsxs("span", { children: [
|
|
384
|
-
fieldElement,
|
|
385
|
-
/* @__PURE__ */ jsx("span", { ...getStyles("separator"), children: dateSeparator })
|
|
386
|
-
] }, `${field}-group`);
|
|
387
|
-
});
|
|
388
|
-
const calendarDate = controller.calendarValue ? dayjs(controller.calendarValue).toDate() : void 0;
|
|
389
|
-
return /* @__PURE__ */ jsx(MaskedDateInputProvider, { value: { getStyles }, children: /* @__PURE__ */ jsxs(
|
|
390
|
-
Popover,
|
|
391
|
-
{
|
|
392
|
-
opened: dropdownOpened,
|
|
393
|
-
transitionProps: { duration: 0 },
|
|
394
|
-
position: "bottom-start",
|
|
395
|
-
withRoles: false,
|
|
396
|
-
disabled: disabled || readOnly,
|
|
397
|
-
...popoverProps,
|
|
398
|
-
children: [
|
|
399
|
-
/* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsxs(
|
|
400
|
-
InputBase,
|
|
401
|
-
{
|
|
402
|
-
component: "div",
|
|
403
|
-
size,
|
|
404
|
-
disabled,
|
|
405
|
-
onClick: (event) => {
|
|
406
|
-
onClick?.(event);
|
|
407
|
-
controller.focus(dateFieldsOrder[0]);
|
|
408
|
-
},
|
|
409
|
-
onMouseDown: (event) => {
|
|
410
|
-
event.preventDefault();
|
|
411
|
-
onMouseDown?.(event);
|
|
412
|
-
},
|
|
413
|
-
onFocusCapture: (event) => {
|
|
414
|
-
setDropdownOpened(true);
|
|
415
|
-
onFocusCapture?.(event);
|
|
416
|
-
},
|
|
417
|
-
onBlurCapture: (event) => {
|
|
418
|
-
setDropdownOpened(false);
|
|
419
|
-
onBlurCapture?.(event);
|
|
420
|
-
},
|
|
421
|
-
rightSection: rightSection || controller.isClearable && /* @__PURE__ */ jsx(
|
|
422
|
-
CloseButton,
|
|
423
|
-
{
|
|
424
|
-
...clearButtonProps,
|
|
425
|
-
size,
|
|
426
|
-
onClick: (event) => {
|
|
427
|
-
controller.clear();
|
|
428
|
-
clearButtonProps?.onClick?.(event);
|
|
429
|
-
},
|
|
430
|
-
onMouseDown: (event) => {
|
|
431
|
-
event.preventDefault();
|
|
432
|
-
clearButtonProps?.onMouseDown?.(event);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
),
|
|
436
|
-
labelProps: { htmlFor: dayInputId, ...labelProps },
|
|
437
|
-
style,
|
|
438
|
-
className,
|
|
439
|
-
classNames: resolvedClassNames,
|
|
440
|
-
styles: resolvedStyles,
|
|
441
|
-
attributes,
|
|
442
|
-
__staticSelector: "MaskedDateInput",
|
|
443
|
-
...rest,
|
|
444
|
-
children: [
|
|
445
|
-
/* @__PURE__ */ jsx("div", { ...getStyles("fieldsRoot"), dir: "ltr", children: /* @__PURE__ */ jsxs("div", { ...getStyles("fieldsGroup"), onBlur: handleBlur, children: [
|
|
446
|
-
dateFields,
|
|
447
|
-
withTime && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
448
|
-
/* @__PURE__ */ jsx("span", { ...getStyles("separator"), children: dateTimeSeparator }),
|
|
449
|
-
/* @__PURE__ */ jsx(
|
|
450
|
-
SpinInput,
|
|
451
|
-
{
|
|
452
|
-
...hoursInputProps,
|
|
453
|
-
...getStyles("field", {
|
|
454
|
-
className: hoursInputProps?.className,
|
|
455
|
-
style: hoursInputProps?.style
|
|
456
|
-
}),
|
|
457
|
-
value: controller.values.hours,
|
|
458
|
-
onChange: controller.setHours,
|
|
459
|
-
onPreviousInput: () => controller.focus(dateFieldsOrder[dateFieldsOrder.length - 1]),
|
|
460
|
-
onNextInput: () => controller.focus("minutes"),
|
|
461
|
-
min: timeFormat === "12h" ? 1 : 0,
|
|
462
|
-
max: timeFormat === "12h" ? 12 : 23,
|
|
463
|
-
allowTemporaryZero: timeFormat === "12h",
|
|
464
|
-
focusable: true,
|
|
465
|
-
step: 1,
|
|
466
|
-
ref: _hoursRef,
|
|
467
|
-
"aria-label": hoursInputLabel,
|
|
468
|
-
tabIndex: -1,
|
|
469
|
-
readOnly,
|
|
470
|
-
disabled,
|
|
471
|
-
onPaste: controller.onPaste,
|
|
472
|
-
onFocus: (event) => {
|
|
473
|
-
handleFocus(event);
|
|
474
|
-
hoursInputProps?.onFocus?.(event);
|
|
475
|
-
},
|
|
476
|
-
onBlur: (event) => {
|
|
477
|
-
const actualInputValue = event.currentTarget.value;
|
|
478
|
-
const numericValue = actualInputValue ? parseInt(actualInputValue, 10) : null;
|
|
479
|
-
if (timeFormat === "12h" && numericValue === 0) {
|
|
480
|
-
controller.setHours(12);
|
|
481
|
-
}
|
|
482
|
-
hoursInputProps?.onBlur?.(event);
|
|
483
|
-
},
|
|
484
|
-
placeholder: hoursPlaceholder
|
|
485
|
-
}
|
|
486
|
-
),
|
|
487
|
-
/* @__PURE__ */ jsx("span", { ...getStyles("separator"), children: timeSeparator }),
|
|
488
|
-
/* @__PURE__ */ jsx(
|
|
489
|
-
SpinInput,
|
|
490
|
-
{
|
|
491
|
-
...minutesInputProps,
|
|
492
|
-
...getStyles("field", {
|
|
493
|
-
className: minutesInputProps?.className,
|
|
494
|
-
style: minutesInputProps?.style
|
|
495
|
-
}),
|
|
496
|
-
value: controller.values.minutes,
|
|
497
|
-
onChange: controller.setMinutes,
|
|
498
|
-
min: 0,
|
|
499
|
-
max: 59,
|
|
500
|
-
focusable: true,
|
|
501
|
-
step: 1,
|
|
502
|
-
ref: _minutesRef,
|
|
503
|
-
onPreviousInput: () => controller.focus("hours"),
|
|
504
|
-
onNextInput: () => withSeconds ? controller.focus("seconds") : controller.focus("amPm"),
|
|
505
|
-
"aria-label": minutesInputLabel,
|
|
506
|
-
tabIndex: -1,
|
|
507
|
-
readOnly,
|
|
508
|
-
disabled,
|
|
509
|
-
onPaste: controller.onPaste,
|
|
510
|
-
onFocus: (event) => {
|
|
511
|
-
handleFocus(event);
|
|
512
|
-
minutesInputProps?.onFocus?.(event);
|
|
513
|
-
},
|
|
514
|
-
placeholder: minutesPlaceholder
|
|
515
|
-
}
|
|
516
|
-
),
|
|
517
|
-
withSeconds && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
518
|
-
/* @__PURE__ */ jsx("span", { ...getStyles("separator"), children: timeSeparator }),
|
|
519
|
-
/* @__PURE__ */ jsx(
|
|
520
|
-
SpinInput,
|
|
521
|
-
{
|
|
522
|
-
...secondsInputProps,
|
|
523
|
-
...getStyles("field", {
|
|
524
|
-
className: secondsInputProps?.className,
|
|
525
|
-
style: secondsInputProps?.style
|
|
526
|
-
}),
|
|
527
|
-
value: controller.values.seconds,
|
|
528
|
-
onChange: controller.setSeconds,
|
|
529
|
-
min: 0,
|
|
530
|
-
max: 59,
|
|
531
|
-
focusable: true,
|
|
532
|
-
step: 1,
|
|
533
|
-
ref: _secondsRef,
|
|
534
|
-
onPreviousInput: () => controller.focus("minutes"),
|
|
535
|
-
onNextInput: () => controller.focus("amPm"),
|
|
536
|
-
"aria-label": secondsInputLabel,
|
|
537
|
-
tabIndex: -1,
|
|
538
|
-
readOnly,
|
|
539
|
-
disabled,
|
|
540
|
-
onPaste: controller.onPaste,
|
|
541
|
-
onFocus: (event) => {
|
|
542
|
-
handleFocus(event);
|
|
543
|
-
secondsInputProps?.onFocus?.(event);
|
|
544
|
-
},
|
|
545
|
-
placeholder: secondsPlaceholder
|
|
546
|
-
}
|
|
547
|
-
)
|
|
548
|
-
] }),
|
|
549
|
-
timeFormat === "12h" && /* @__PURE__ */ jsx(
|
|
550
|
-
SimpleAmPmSelect,
|
|
551
|
-
{
|
|
552
|
-
...amPmSelectProps,
|
|
553
|
-
...getStyles("field", {
|
|
554
|
-
className: amPmSelectProps?.className,
|
|
555
|
-
style: amPmSelectProps?.style
|
|
556
|
-
}),
|
|
557
|
-
labels: amPmLabels,
|
|
558
|
-
value: controller.values.amPm,
|
|
559
|
-
onChange: controller.setAmPm,
|
|
560
|
-
ref: _amPmRef,
|
|
561
|
-
"aria-label": amPmInputLabel,
|
|
562
|
-
onPreviousInput: () => withSeconds ? controller.focus("seconds") : controller.focus("minutes"),
|
|
563
|
-
readOnly,
|
|
564
|
-
disabled,
|
|
565
|
-
tabIndex: -1,
|
|
566
|
-
onFocus: (event) => {
|
|
567
|
-
handleFocus(event);
|
|
568
|
-
amPmSelectProps?.onFocus?.(event);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
)
|
|
572
|
-
] })
|
|
573
|
-
] }) }),
|
|
574
|
-
/* @__PURE__ */ jsx(
|
|
575
|
-
"input",
|
|
576
|
-
{
|
|
577
|
-
type: "hidden",
|
|
578
|
-
name,
|
|
579
|
-
form,
|
|
580
|
-
value: controller.hiddenInputValue,
|
|
581
|
-
...hiddenInputProps
|
|
582
|
-
}
|
|
583
|
-
)
|
|
584
|
-
]
|
|
585
|
-
}
|
|
586
|
-
) }),
|
|
587
|
-
/* @__PURE__ */ jsx(
|
|
588
|
-
Popover.Dropdown,
|
|
589
|
-
{
|
|
590
|
-
...getStyles("dropdown"),
|
|
591
|
-
onMouseDown: (event) => event.preventDefault(),
|
|
592
|
-
children: /* @__PURE__ */ jsx(
|
|
593
|
-
Calendar,
|
|
594
|
-
{
|
|
595
|
-
__staticSelector: "MaskedDateInput",
|
|
596
|
-
...calendarProps,
|
|
597
|
-
unstyled,
|
|
598
|
-
__preventFocus: true,
|
|
599
|
-
minDate,
|
|
600
|
-
maxDate,
|
|
601
|
-
locale,
|
|
602
|
-
getDayProps: _getDayProps,
|
|
603
|
-
size,
|
|
604
|
-
date: calendarDate,
|
|
605
|
-
getMonthControlProps: (date) => ({
|
|
606
|
-
selected: controller.calendarValue ? isSameMonth(date, controller.calendarValue) : false,
|
|
607
|
-
...getMonthControlProps?.(date)
|
|
608
|
-
}),
|
|
609
|
-
getYearControlProps: (date) => ({
|
|
610
|
-
selected: controller.calendarValue ? dayjs(date).isSame(controller.calendarValue, "year") : false,
|
|
611
|
-
...getYearControlProps?.(date)
|
|
612
|
-
}),
|
|
613
|
-
attributes
|
|
614
|
-
}
|
|
615
|
-
)
|
|
616
|
-
}
|
|
617
|
-
)
|
|
618
|
-
]
|
|
619
|
-
}
|
|
620
|
-
) });
|
|
621
|
-
});
|
|
622
|
-
MaskedDateInput.displayName = "@mantine/dates/MaskedDateInput";
|
|
623
|
-
MaskedDateInput.classes = classes;
|
|
624
|
-
|
|
625
|
-
export { MaskedDateInput };
|
|
626
|
-
//# sourceMappingURL=MaskedDateInput.mjs.map
|