@ssa-ui-kit/core 2.32.0 → 2.33.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/dist/components/DateRangePicker/DateRangePicker.d.ts +1 -1
- package/dist/components/DateRangePicker/components/TriggerInput.d.ts +1 -4
- package/dist/components/DateRangePicker/hooks/index.d.ts +1 -0
- package/dist/components/DateRangePicker/hooks/useDatePickerMask.d.ts +3 -9
- package/dist/components/DateRangePicker/hooks/useDateRangePicker.d.ts +3 -2
- package/dist/components/DateRangePicker/hooks/useRangeSelection.d.ts +20 -0
- package/dist/components/DateRangePicker/types.d.ts +6 -4
- package/dist/components/DateRangePicker/useDateRangePickerContext.d.ts +2 -1
- package/dist/index.js +412 -262
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -14975,8 +14975,8 @@ const styles_MonthsViewCell = /*#__PURE__*/base_default()("div", true ? {
|
|
|
14975
14975
|
const TriggerWrapper = /*#__PURE__*/base_default()(Wrapper_Wrapper, true ? {
|
|
14976
14976
|
target: "e19l41fq0"
|
|
14977
14977
|
} : 0)( true ? {
|
|
14978
|
-
name: "
|
|
14979
|
-
styles: "padding:14px"
|
|
14978
|
+
name: "1h91tay",
|
|
14979
|
+
styles: "padding:14px;cursor:default"
|
|
14980
14980
|
} : 0);
|
|
14981
14981
|
;// ./src/components/DateRangePicker/utils/dates.ts
|
|
14982
14982
|
|
|
@@ -15068,7 +15068,6 @@ const DateRangePickerContext = /*#__PURE__*/(0,external_react_namespaceObject.cr
|
|
|
15068
15068
|
nameFrom: '',
|
|
15069
15069
|
nameTo: '',
|
|
15070
15070
|
maskOptions: {},
|
|
15071
|
-
openCalendarMode: 'icon',
|
|
15072
15071
|
inputFromRef: {
|
|
15073
15072
|
current: null
|
|
15074
15073
|
},
|
|
@@ -15097,9 +15096,6 @@ const DateRangePickerContext = /*#__PURE__*/(0,external_react_namespaceObject.cr
|
|
|
15097
15096
|
day: 1
|
|
15098
15097
|
}),
|
|
15099
15098
|
currentIndex: 0,
|
|
15100
|
-
handleSetIsOpen: () => {
|
|
15101
|
-
// no-op
|
|
15102
|
-
},
|
|
15103
15099
|
handleToggleOpen: () => {
|
|
15104
15100
|
// no-op
|
|
15105
15101
|
},
|
|
@@ -15109,6 +15105,13 @@ const DateRangePickerContext = /*#__PURE__*/(0,external_react_namespaceObject.cr
|
|
|
15109
15105
|
setCalendarType: () => {
|
|
15110
15106
|
// no-op
|
|
15111
15107
|
},
|
|
15108
|
+
rangeSelectionStep: null,
|
|
15109
|
+
setRangeSelectionStep: () => {
|
|
15110
|
+
// no-op
|
|
15111
|
+
},
|
|
15112
|
+
clearInputValue: () => {
|
|
15113
|
+
// no-op
|
|
15114
|
+
},
|
|
15112
15115
|
setCalendarViewDateTime: () => {
|
|
15113
15116
|
// no-op
|
|
15114
15117
|
},
|
|
@@ -15117,7 +15120,8 @@ const DateRangePickerContext = /*#__PURE__*/(0,external_react_namespaceObject.cr
|
|
|
15117
15120
|
},
|
|
15118
15121
|
setLastFocusedElement: () => {
|
|
15119
15122
|
// no-op
|
|
15120
|
-
}
|
|
15123
|
+
},
|
|
15124
|
+
allowReverseSelection: false
|
|
15121
15125
|
});
|
|
15122
15126
|
;// ./src/components/DateRangePicker/useDateRangePickerContext.tsx
|
|
15123
15127
|
|
|
@@ -15175,6 +15179,88 @@ const useRangeHighlighting = () => {
|
|
|
15175
15179
|
hoveredDate
|
|
15176
15180
|
};
|
|
15177
15181
|
};
|
|
15182
|
+
;// ./src/components/DateRangePicker/hooks/useRangeSelection.ts
|
|
15183
|
+
|
|
15184
|
+
const useRangeSelection = ({
|
|
15185
|
+
createNewDate,
|
|
15186
|
+
getComparisonFormat
|
|
15187
|
+
}) => {
|
|
15188
|
+
const {
|
|
15189
|
+
dateTime,
|
|
15190
|
+
calendarViewDateTime,
|
|
15191
|
+
setCalendarViewDateTime,
|
|
15192
|
+
setDateTime,
|
|
15193
|
+
setIsOpen,
|
|
15194
|
+
setLastFocusedElement,
|
|
15195
|
+
rangeSelectionStep,
|
|
15196
|
+
setRangeSelectionStep,
|
|
15197
|
+
clearInputValue,
|
|
15198
|
+
allowReverseSelection = false,
|
|
15199
|
+
onChange
|
|
15200
|
+
} = useDateRangePickerContext();
|
|
15201
|
+
const handleRangeSelect = selectedValue => {
|
|
15202
|
+
const newDate = createNewDate(selectedValue);
|
|
15203
|
+
if (!newDate) return;
|
|
15204
|
+
|
|
15205
|
+
// Range selection logic
|
|
15206
|
+
const isSelectingStart = rangeSelectionStep === 'start';
|
|
15207
|
+
if (isSelectingStart) {
|
|
15208
|
+
clearInputValue('to');
|
|
15209
|
+
setLastFocusedElement('to');
|
|
15210
|
+
setRangeSelectionStep('end');
|
|
15211
|
+
}
|
|
15212
|
+
let newDateTuple = isSelectingStart ? [newDate, undefined] : [dateTime[0], newDate];
|
|
15213
|
+
setCalendarViewDateTime(isSelectingStart ? [newDate, newDate] : [dateTime[0] ? calendarViewDateTime?.[0] : newDate, newDate]);
|
|
15214
|
+
|
|
15215
|
+
// Check if dates are in reverse order
|
|
15216
|
+
const isReversed = newDateTuple[0] && newDateTuple[1] && newDateTuple[0].toMillis() > newDateTuple[1].toMillis();
|
|
15217
|
+
if (isReversed) {
|
|
15218
|
+
if (allowReverseSelection) {
|
|
15219
|
+
// Auto-swap dates when reverse selection is allowed
|
|
15220
|
+
newDateTuple = [newDateTuple[1], newDateTuple[0]];
|
|
15221
|
+
} else if (!isSelectingStart) {
|
|
15222
|
+
// User selected an earlier date - update start date
|
|
15223
|
+
newDateTuple = [newDateTuple[1], undefined];
|
|
15224
|
+
setLastFocusedElement('to');
|
|
15225
|
+
setRangeSelectionStep('end');
|
|
15226
|
+
setCalendarViewDateTime([newDateTuple[0], newDateTuple[0]]);
|
|
15227
|
+
}
|
|
15228
|
+
}
|
|
15229
|
+
setDateTime(newDateTuple);
|
|
15230
|
+
const normalizeToMidnight = dt => dt.set({
|
|
15231
|
+
hour: 0,
|
|
15232
|
+
minute: 0,
|
|
15233
|
+
second: 0,
|
|
15234
|
+
millisecond: 0
|
|
15235
|
+
}).toJSDate();
|
|
15236
|
+
|
|
15237
|
+
// Call onChange when a date is selected from calendar
|
|
15238
|
+
if (isSelectingStart && newDateTuple[0]) {
|
|
15239
|
+
// First date selected
|
|
15240
|
+
onChange?.([normalizeToMidnight(newDateTuple[0]), null]);
|
|
15241
|
+
} else if (newDateTuple[0] && newDateTuple[1] && newDateTuple[0].toMillis() <= newDateTuple[1].toMillis()) {
|
|
15242
|
+
// Both dates selected and in correct order
|
|
15243
|
+
onChange?.([normalizeToMidnight(newDateTuple[0]), normalizeToMidnight(newDateTuple[1])]);
|
|
15244
|
+
setRangeSelectionStep(null);
|
|
15245
|
+
setIsOpen(false);
|
|
15246
|
+
}
|
|
15247
|
+
};
|
|
15248
|
+
const getDateSelectionState = currentDT => {
|
|
15249
|
+
const comparisonFormat = getComparisonFormat();
|
|
15250
|
+
const isCalendarFirstDateSelected = currentDT.toFormat(comparisonFormat) === dateTime[0]?.toFormat(comparisonFormat);
|
|
15251
|
+
const isCalendarSecondDateSelected = currentDT.toFormat(comparisonFormat) === dateTime[1]?.toFormat(comparisonFormat);
|
|
15252
|
+
const isCalendarDateSelected = isCalendarFirstDateSelected || isCalendarSecondDateSelected;
|
|
15253
|
+
return {
|
|
15254
|
+
isCalendarFirstDateSelected,
|
|
15255
|
+
isCalendarSecondDateSelected,
|
|
15256
|
+
isCalendarDateSelected
|
|
15257
|
+
};
|
|
15258
|
+
};
|
|
15259
|
+
return {
|
|
15260
|
+
handleRangeSelect,
|
|
15261
|
+
getDateSelectionState
|
|
15262
|
+
};
|
|
15263
|
+
};
|
|
15178
15264
|
;// ./src/components/DateRangePicker/components/DaysView.tsx
|
|
15179
15265
|
function components_DaysView_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
15180
15266
|
|
|
@@ -15201,15 +15287,9 @@ var components_DaysView_ref3 = true ? {
|
|
|
15201
15287
|
const DaysView_DaysView = () => {
|
|
15202
15288
|
const weekDays = dates_getWeekDays();
|
|
15203
15289
|
const {
|
|
15204
|
-
dateTime,
|
|
15205
|
-
calendarViewDateTime,
|
|
15206
15290
|
dateMinDT,
|
|
15207
15291
|
dateMaxDT,
|
|
15208
|
-
|
|
15209
|
-
currentCalendarViewDT,
|
|
15210
|
-
setCalendarViewDateTime,
|
|
15211
|
-
setDateTime,
|
|
15212
|
-
setIsOpen
|
|
15292
|
+
currentCalendarViewDT
|
|
15213
15293
|
} = useDateRangePickerContext();
|
|
15214
15294
|
const currentDate = currentCalendarViewDT.toJSDate();
|
|
15215
15295
|
const currentMonth = currentDate?.getMonth();
|
|
@@ -15220,22 +15300,23 @@ const DaysView_DaysView = () => {
|
|
|
15220
15300
|
getClassNames,
|
|
15221
15301
|
isHighlightDate
|
|
15222
15302
|
} = useRangeHighlighting();
|
|
15303
|
+
const {
|
|
15304
|
+
handleRangeSelect,
|
|
15305
|
+
getDateSelectionState
|
|
15306
|
+
} = useRangeSelection({
|
|
15307
|
+
createNewDate: selectedDay => currentCalendarViewDT.set({
|
|
15308
|
+
day: Number(selectedDay)
|
|
15309
|
+
}),
|
|
15310
|
+
getComparisonFormat: () => 'D'
|
|
15311
|
+
});
|
|
15223
15312
|
const handleDaySelect = event => {
|
|
15224
15313
|
const {
|
|
15225
15314
|
target
|
|
15226
15315
|
} = event;
|
|
15227
|
-
const selectedDay =
|
|
15316
|
+
const selectedDay = target.innerHTML;
|
|
15228
15317
|
const isEnabled = target.getAttribute('aria-disabled') === 'false';
|
|
15229
15318
|
if (isEnabled) {
|
|
15230
|
-
|
|
15231
|
-
day: selectedDay
|
|
15232
|
-
});
|
|
15233
|
-
const newDateTuple = lastFocusedElement === 'from' ? [newDate, dateTime[1]] : [dateTime[0], newDate];
|
|
15234
|
-
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, dateTime[1] ? calendarViewDateTime?.[1] : newDate] : [dateTime[0] ? calendarViewDateTime?.[0] : newDate, newDate]);
|
|
15235
|
-
setDateTime(newDateTuple);
|
|
15236
|
-
if (newDateTuple[0] && newDateTuple[1]) {
|
|
15237
|
-
setIsOpen(false);
|
|
15238
|
-
}
|
|
15319
|
+
handleRangeSelect(selectedDay);
|
|
15239
15320
|
}
|
|
15240
15321
|
};
|
|
15241
15322
|
return (0,jsx_runtime_namespaceObject.jsxs)((external_react_default()).Fragment, {
|
|
@@ -15249,16 +15330,18 @@ const DaysView_DaysView = () => {
|
|
|
15249
15330
|
css: components_DaysView_ref3,
|
|
15250
15331
|
onClick: handleDaySelect,
|
|
15251
15332
|
children: dates.map((currentDate, index) => {
|
|
15252
|
-
const currentDT = external_luxon_namespaceObject.DateTime.fromJSDate(currentDate);
|
|
15333
|
+
const currentDT = external_luxon_namespaceObject.DateTime.fromJSDate(currentDate).startOf('day');
|
|
15253
15334
|
const calendarDate = currentDT.toFormat('D');
|
|
15254
15335
|
const calendarDay = currentDate.getDate();
|
|
15255
15336
|
const calendarMonth = currentDate.getMonth();
|
|
15256
15337
|
const ariaLabel = currentDT.toLocaleString(external_luxon_namespaceObject.DateTime.DATE_HUGE);
|
|
15257
15338
|
const isCalendarDateNow = nowDate === calendarDate;
|
|
15258
15339
|
const isCalendarMonth = currentMonth === calendarMonth;
|
|
15259
|
-
const
|
|
15260
|
-
|
|
15261
|
-
|
|
15340
|
+
const {
|
|
15341
|
+
isCalendarFirstDateSelected,
|
|
15342
|
+
isCalendarSecondDateSelected,
|
|
15343
|
+
isCalendarDateSelected
|
|
15344
|
+
} = getDateSelectionState(currentDT);
|
|
15262
15345
|
let isAriaDisabled = false;
|
|
15263
15346
|
if (dateMinDT && dateMaxDT) {
|
|
15264
15347
|
isAriaDisabled = currentDT < dateMinDT || currentDT > dateMaxDT || !isCalendarMonth;
|
|
@@ -15307,24 +15390,36 @@ var components_MonthsView_ref = true ? {
|
|
|
15307
15390
|
} : 0;
|
|
15308
15391
|
const MonthsView_MonthsView = () => {
|
|
15309
15392
|
const {
|
|
15310
|
-
dateTime,
|
|
15311
|
-
calendarViewDateTime,
|
|
15312
15393
|
dateMinDT,
|
|
15313
15394
|
dateMaxDT,
|
|
15314
15395
|
lastFocusedElement,
|
|
15315
15396
|
currentCalendarViewDT,
|
|
15397
|
+
calendarViewDateTime,
|
|
15316
15398
|
rangePickerType,
|
|
15317
15399
|
setCalendarType,
|
|
15318
15400
|
setCalendarViewDateTime,
|
|
15319
|
-
onMonthChange
|
|
15320
|
-
setDateTime,
|
|
15321
|
-
setIsOpen
|
|
15401
|
+
onMonthChange
|
|
15322
15402
|
} = useDateRangePickerContext();
|
|
15323
15403
|
const {
|
|
15324
15404
|
handleDateHover,
|
|
15325
15405
|
getClassNames,
|
|
15326
15406
|
isHighlightDate
|
|
15327
15407
|
} = useRangeHighlighting();
|
|
15408
|
+
const {
|
|
15409
|
+
handleRangeSelect,
|
|
15410
|
+
getDateSelectionState
|
|
15411
|
+
} = useRangeSelection({
|
|
15412
|
+
createNewDate: selectedMonth => {
|
|
15413
|
+
const monthNumber = constants_MONTHS.findIndex(month => month === selectedMonth);
|
|
15414
|
+
const newMonth = currentCalendarViewDT?.set({
|
|
15415
|
+
month: monthNumber + 1
|
|
15416
|
+
});
|
|
15417
|
+
return newMonth?.set({
|
|
15418
|
+
day: lastFocusedElement === 'from' ? 1 : newMonth.daysInMonth
|
|
15419
|
+
});
|
|
15420
|
+
},
|
|
15421
|
+
getComparisonFormat: () => 'yyyy-MM'
|
|
15422
|
+
});
|
|
15328
15423
|
const handleMonthSelect = event => {
|
|
15329
15424
|
const {
|
|
15330
15425
|
target
|
|
@@ -15335,29 +15430,20 @@ const MonthsView_MonthsView = () => {
|
|
|
15335
15430
|
return;
|
|
15336
15431
|
}
|
|
15337
15432
|
const selectedMonth = target.innerHTML;
|
|
15338
|
-
const monthNumber = constants_MONTHS.findIndex(month => month === selectedMonth);
|
|
15339
15433
|
if (rangePickerType === 'days') {
|
|
15434
|
+
// Navigation case: selecting month navigates to days view
|
|
15435
|
+
const monthNumber = constants_MONTHS.findIndex(month => month === selectedMonth);
|
|
15340
15436
|
const newDate = currentCalendarViewDT?.set({
|
|
15341
15437
|
month: monthNumber + 1
|
|
15342
15438
|
});
|
|
15343
|
-
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
|
|
15344
15439
|
if (newDate) {
|
|
15440
|
+
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
|
|
15345
15441
|
onMonthChange?.(newDate.toJSDate());
|
|
15442
|
+
setCalendarType('days');
|
|
15346
15443
|
}
|
|
15347
|
-
setCalendarType('days');
|
|
15348
15444
|
} else {
|
|
15349
|
-
|
|
15350
|
-
|
|
15351
|
-
});
|
|
15352
|
-
const newDate = newMonth?.set({
|
|
15353
|
-
day: lastFocusedElement === 'from' ? 1 : newMonth.daysInMonth
|
|
15354
|
-
});
|
|
15355
|
-
const newDateTuple = lastFocusedElement === 'from' ? [newDate, dateTime[1]] : [dateTime[0], newDate];
|
|
15356
|
-
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, dateTime[1] ? calendarViewDateTime?.[1] : newDate] : [dateTime[0] ? calendarViewDateTime?.[0] : newDate, newDate]);
|
|
15357
|
-
setDateTime(newDateTuple);
|
|
15358
|
-
if (newDateTuple[0] && newDateTuple[1]) {
|
|
15359
|
-
setIsOpen(false);
|
|
15360
|
-
}
|
|
15445
|
+
// Range selection case: selecting month completes the range
|
|
15446
|
+
handleRangeSelect(selectedMonth);
|
|
15361
15447
|
}
|
|
15362
15448
|
};
|
|
15363
15449
|
return (0,jsx_runtime_namespaceObject.jsx)(DatesListWrapper, {
|
|
@@ -15372,8 +15458,10 @@ const MonthsView_MonthsView = () => {
|
|
|
15372
15458
|
const isMinMonthReached = dateMinDT ? currentMonthDT.month < dateMinDT.month && currentMonthDT.year === dateMinDT.year : false;
|
|
15373
15459
|
const isMaxMonthReached = dateMaxDT ? currentMonthDT.month > dateMaxDT.month && currentMonthDT.year === dateMaxDT.year : false;
|
|
15374
15460
|
const isAriaDisabled = isMinMonthReached || isMaxMonthReached;
|
|
15375
|
-
const
|
|
15376
|
-
|
|
15461
|
+
const {
|
|
15462
|
+
isCalendarFirstDateSelected,
|
|
15463
|
+
isCalendarSecondDateSelected
|
|
15464
|
+
} = getDateSelectionState(currentMonthDT);
|
|
15377
15465
|
const classNames = getClassNames(currentMonthDT, {
|
|
15378
15466
|
isCalendarFirstDateSelected,
|
|
15379
15467
|
isCalendarSecondDateSelected
|
|
@@ -15409,7 +15497,6 @@ var components_YearsView_ref = true ? {
|
|
|
15409
15497
|
const YearsView_YearsView = () => {
|
|
15410
15498
|
const {
|
|
15411
15499
|
rangePickerType,
|
|
15412
|
-
dateTime,
|
|
15413
15500
|
calendarViewDateTime,
|
|
15414
15501
|
currentCalendarViewDT,
|
|
15415
15502
|
dateMinParts,
|
|
@@ -15418,9 +15505,7 @@ const YearsView_YearsView = () => {
|
|
|
15418
15505
|
lastFocusedElement,
|
|
15419
15506
|
setCalendarType,
|
|
15420
15507
|
setCalendarViewDateTime,
|
|
15421
|
-
onYearChange
|
|
15422
|
-
setDateTime,
|
|
15423
|
-
setIsOpen
|
|
15508
|
+
onYearChange
|
|
15424
15509
|
} = useDateRangePickerContext();
|
|
15425
15510
|
const wrapper = (0,external_react_namespaceObject.useRef)(null);
|
|
15426
15511
|
const yearsList = dates_getYearsList({
|
|
@@ -15432,6 +15517,24 @@ const YearsView_YearsView = () => {
|
|
|
15432
15517
|
getClassNames,
|
|
15433
15518
|
isHighlightDate
|
|
15434
15519
|
} = useRangeHighlighting();
|
|
15520
|
+
const {
|
|
15521
|
+
handleRangeSelect,
|
|
15522
|
+
getDateSelectionState
|
|
15523
|
+
} = useRangeSelection({
|
|
15524
|
+
createNewDate: selectedYear => {
|
|
15525
|
+
const newYear = currentCalendarViewDT?.set({
|
|
15526
|
+
year: Number(selectedYear)
|
|
15527
|
+
});
|
|
15528
|
+
return newYear?.set(lastFocusedElement === 'from' ? {
|
|
15529
|
+
day: 1,
|
|
15530
|
+
month: 1
|
|
15531
|
+
} : {
|
|
15532
|
+
day: 31,
|
|
15533
|
+
month: 12
|
|
15534
|
+
});
|
|
15535
|
+
},
|
|
15536
|
+
getComparisonFormat: () => 'yyyy'
|
|
15537
|
+
});
|
|
15435
15538
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
15436
15539
|
if (currentCalendarViewDT && wrapper.current) {
|
|
15437
15540
|
wrapper.current.querySelector('[aria-current=date]')?.scrollIntoView({
|
|
@@ -15439,15 +15542,16 @@ const YearsView_YearsView = () => {
|
|
|
15439
15542
|
block: 'center'
|
|
15440
15543
|
});
|
|
15441
15544
|
}
|
|
15442
|
-
}, [calendarViewDateTime, lastFocusedElement]);
|
|
15545
|
+
}, [calendarViewDateTime, lastFocusedElement, currentCalendarViewDT]);
|
|
15443
15546
|
const handleYearSelect = event => {
|
|
15444
15547
|
const {
|
|
15445
15548
|
target
|
|
15446
15549
|
} = event;
|
|
15447
|
-
const selectedYear =
|
|
15550
|
+
const selectedYear = target.innerHTML;
|
|
15448
15551
|
if (rangePickerType !== 'years') {
|
|
15552
|
+
// Navigation case: selecting year navigates to months view
|
|
15449
15553
|
const newDate = currentCalendarViewDT.set({
|
|
15450
|
-
year: selectedYear
|
|
15554
|
+
year: Number(selectedYear)
|
|
15451
15555
|
});
|
|
15452
15556
|
setCalendarType('months');
|
|
15453
15557
|
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
|
|
@@ -15455,22 +15559,8 @@ const YearsView_YearsView = () => {
|
|
|
15455
15559
|
onYearChange?.(newDate.toJSDate());
|
|
15456
15560
|
}
|
|
15457
15561
|
} else {
|
|
15458
|
-
|
|
15459
|
-
|
|
15460
|
-
});
|
|
15461
|
-
const newDate = newYear?.set(lastFocusedElement === 'from' ? {
|
|
15462
|
-
day: 1,
|
|
15463
|
-
month: 1
|
|
15464
|
-
} : {
|
|
15465
|
-
day: 31,
|
|
15466
|
-
month: 12
|
|
15467
|
-
});
|
|
15468
|
-
const newDateTuple = lastFocusedElement === 'from' ? [newDate, dateTime[1]] : [dateTime[0], newDate];
|
|
15469
|
-
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, dateTime[1] ? calendarViewDateTime?.[1] : newDate] : [dateTime[0] ? calendarViewDateTime?.[0] : newDate, newDate]);
|
|
15470
|
-
setDateTime(newDateTuple);
|
|
15471
|
-
if (newDateTuple[0] && newDateTuple[1]) {
|
|
15472
|
-
setIsOpen(false);
|
|
15473
|
-
}
|
|
15562
|
+
// Range selection case: selecting year completes the range
|
|
15563
|
+
handleRangeSelect(selectedYear);
|
|
15474
15564
|
}
|
|
15475
15565
|
};
|
|
15476
15566
|
return (0,jsx_runtime_namespaceObject.jsx)(DatesListWrapper, {
|
|
@@ -15488,8 +15578,10 @@ const YearsView_YearsView = () => {
|
|
|
15488
15578
|
if (isCalendarYear) {
|
|
15489
15579
|
additionalProps['aria-current'] = 'date';
|
|
15490
15580
|
}
|
|
15491
|
-
const
|
|
15492
|
-
|
|
15581
|
+
const {
|
|
15582
|
+
isCalendarFirstDateSelected,
|
|
15583
|
+
isCalendarSecondDateSelected
|
|
15584
|
+
} = getDateSelectionState(currentYearDT);
|
|
15493
15585
|
const classNames = getClassNames(currentYearDT, {
|
|
15494
15586
|
isCalendarFirstDateSelected,
|
|
15495
15587
|
isCalendarSecondDateSelected
|
|
@@ -15829,24 +15921,9 @@ function TriggerInput_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried
|
|
|
15829
15921
|
|
|
15830
15922
|
|
|
15831
15923
|
|
|
15832
|
-
const WithTriggerPopover = ({
|
|
15833
|
-
isEnabled,
|
|
15834
|
-
children
|
|
15835
|
-
}) => {
|
|
15836
|
-
return isEnabled ? (0,jsx_runtime_namespaceObject.jsx)(PopoverTrigger, {
|
|
15837
|
-
asChild: true,
|
|
15838
|
-
children: /*#__PURE__*/external_react_default().cloneElement(children, {
|
|
15839
|
-
...children.props
|
|
15840
|
-
})
|
|
15841
|
-
}) : (/*#__PURE__*/external_react_default().cloneElement(children, {
|
|
15842
|
-
...children.props
|
|
15843
|
-
}));
|
|
15844
|
-
};
|
|
15845
15924
|
const TriggerInput = ({
|
|
15846
15925
|
datepickerType,
|
|
15847
|
-
|
|
15848
|
-
className,
|
|
15849
|
-
onClick
|
|
15926
|
+
className
|
|
15850
15927
|
}) => {
|
|
15851
15928
|
const {
|
|
15852
15929
|
format,
|
|
@@ -15859,7 +15936,9 @@ const TriggerInput = ({
|
|
|
15859
15936
|
messages,
|
|
15860
15937
|
setLastFocusedElement,
|
|
15861
15938
|
classNames,
|
|
15862
|
-
onBlur: handleBlur
|
|
15939
|
+
onBlur: handleBlur,
|
|
15940
|
+
isOpen,
|
|
15941
|
+
setIsOpen
|
|
15863
15942
|
} = useDateRangePickerContext();
|
|
15864
15943
|
const formContext = (0,external_react_hook_form_namespaceObject.useFormContext)(); // Using FormProvider from react-hook-form
|
|
15865
15944
|
const useFormResult = (0,external_react_hook_form_namespaceObject.useForm)();
|
|
@@ -15881,42 +15960,55 @@ const TriggerInput = ({
|
|
|
15881
15960
|
setLastFocusedElement(datepickerType);
|
|
15882
15961
|
inputProps?.inputProps?.onFocus?.(e);
|
|
15883
15962
|
};
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
-
|
|
15893
|
-
|
|
15894
|
-
|
|
15895
|
-
|
|
15896
|
-
|
|
15897
|
-
|
|
15898
|
-
|
|
15899
|
-
onClick
|
|
15900
|
-
onFocus: handleFocus,
|
|
15901
|
-
id: inputProps?.inputProps?.id || currentName,
|
|
15902
|
-
'data-testid': `daterangepicker-input-${datepickerType}`,
|
|
15903
|
-
autoComplete: 'off',
|
|
15904
|
-
className: [/*#__PURE__*/(0,css_namespaceObject.css)( true ? {
|
|
15905
|
-
name: "15obm9d",
|
|
15906
|
-
styles: "border:none!important;height:auto!important;padding:0!important;min-width:75px;line-height:16px;max-height:16px;letter-spacing:0.8px;border-radius:0!important;&::placeholder{letter-spacing:normal;}"
|
|
15907
|
-
} : 0), datepickerType === 'from' ? classNames?.trigger?.inputFrom : classNames?.trigger?.inputTo].filter(Boolean).join(' '),
|
|
15908
|
-
...inputElementProps
|
|
15963
|
+
return (0,jsx_runtime_namespaceObject.jsx)(Input_Input, {
|
|
15964
|
+
name: currentName,
|
|
15965
|
+
placeholder: format,
|
|
15966
|
+
ref: datepickerType === 'from' ? inputFromRef : inputToRef,
|
|
15967
|
+
disabled: disabled,
|
|
15968
|
+
register: register,
|
|
15969
|
+
className: className,
|
|
15970
|
+
wrapperClassName: /*#__PURE__*/(0,css_namespaceObject.css)("display:flex;padding-left:", datepickerType === 'from' ? 0 : 14, "px;" + ( true ? "" : 0), true ? "" : 0),
|
|
15971
|
+
inputProps: {
|
|
15972
|
+
onBlur: handleBlur,
|
|
15973
|
+
onFocus: handleFocus,
|
|
15974
|
+
onClick: e => {
|
|
15975
|
+
if (isOpen) {
|
|
15976
|
+
setIsOpen(false);
|
|
15977
|
+
}
|
|
15978
|
+
inputProps?.inputProps?.onClick?.(e);
|
|
15909
15979
|
},
|
|
15910
|
-
|
|
15911
|
-
|
|
15912
|
-
|
|
15913
|
-
|
|
15914
|
-
|
|
15915
|
-
|
|
15916
|
-
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15980
|
+
onKeyDown: e => {
|
|
15981
|
+
inputProps?.inputProps?.onKeyDown?.(e);
|
|
15982
|
+
},
|
|
15983
|
+
onBeforeInput: e => {
|
|
15984
|
+
// pass-through
|
|
15985
|
+
inputProps?.inputProps?.onBeforeInput?.(e);
|
|
15986
|
+
},
|
|
15987
|
+
onInput: e => {
|
|
15988
|
+
// pass-through
|
|
15989
|
+
inputProps?.inputProps?.onInput?.(e);
|
|
15990
|
+
},
|
|
15991
|
+
onChange: e => {
|
|
15992
|
+
inputProps?.inputProps?.onChange?.(e);
|
|
15993
|
+
},
|
|
15994
|
+
id: inputProps?.inputProps?.id || currentName,
|
|
15995
|
+
'data-testid': `daterangepicker-input-${datepickerType}`,
|
|
15996
|
+
autoComplete: 'off',
|
|
15997
|
+
className: [/*#__PURE__*/(0,css_namespaceObject.css)( true ? {
|
|
15998
|
+
name: "15obm9d",
|
|
15999
|
+
styles: "border:none!important;height:auto!important;padding:0!important;min-width:75px;line-height:16px;max-height:16px;letter-spacing:0.8px;border-radius:0!important;&::placeholder{letter-spacing:normal;}"
|
|
16000
|
+
} : 0), datepickerType === 'from' ? classNames?.trigger?.inputFrom : classNames?.trigger?.inputTo].filter(Boolean).join(' '),
|
|
16001
|
+
...inputElementProps
|
|
16002
|
+
},
|
|
16003
|
+
showStatusIcon: false,
|
|
16004
|
+
errors: fieldError,
|
|
16005
|
+
status: fieldStatus,
|
|
16006
|
+
helperText: fieldStatus === 'basic' ? messages?.description : messages?.error,
|
|
16007
|
+
helperClassName: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
|
|
16008
|
+
name: "lhoo11",
|
|
16009
|
+
styles: "&>span::first-letter{text-transform:uppercase;}"
|
|
16010
|
+
} : 0),
|
|
16011
|
+
...restInputProps
|
|
15920
16012
|
});
|
|
15921
16013
|
};
|
|
15922
16014
|
;// ./src/components/Field/FieldDescription.tsx
|
|
@@ -16016,8 +16108,8 @@ function Trigger_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to st
|
|
|
16016
16108
|
|
|
16017
16109
|
|
|
16018
16110
|
var Trigger_ref = true ? {
|
|
16019
|
-
name: "
|
|
16020
|
-
styles: "margin:0 3px"
|
|
16111
|
+
name: "cx8u11",
|
|
16112
|
+
styles: "margin:0 3px;cursor:pointer"
|
|
16021
16113
|
} : 0;
|
|
16022
16114
|
const Trigger = () => {
|
|
16023
16115
|
const {
|
|
@@ -16027,7 +16119,6 @@ const Trigger = () => {
|
|
|
16027
16119
|
lastFocusedElement,
|
|
16028
16120
|
disabled,
|
|
16029
16121
|
status,
|
|
16030
|
-
openCalendarMode,
|
|
16031
16122
|
isOpen,
|
|
16032
16123
|
showCalendarIcon,
|
|
16033
16124
|
showStatusArea,
|
|
@@ -16060,49 +16151,46 @@ const Trigger = () => {
|
|
|
16060
16151
|
ref: wrapperRef,
|
|
16061
16152
|
className: classNames?.trigger?.controlsWrapper,
|
|
16062
16153
|
children: [(0,jsx_runtime_namespaceObject.jsx)(TriggerInput, {
|
|
16063
|
-
withPopover: true,
|
|
16064
16154
|
datepickerType: "from",
|
|
16065
|
-
className: classNames?.trigger?.inputFrom
|
|
16066
|
-
onClick: () => {
|
|
16067
|
-
if (!isOpen) {
|
|
16068
|
-
setIsOpen(true);
|
|
16069
|
-
}
|
|
16070
|
-
}
|
|
16155
|
+
className: classNames?.trigger?.inputFrom
|
|
16071
16156
|
}), (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
|
|
16072
16157
|
name: "carrot-right",
|
|
16073
16158
|
size: 16,
|
|
16074
16159
|
color: disabled ? theme.colors.grey : theme.colors.greyDarker,
|
|
16075
16160
|
className: classNames?.trigger?.arrowIcon,
|
|
16161
|
+
onClick: () => {
|
|
16162
|
+
if (isOpen) {
|
|
16163
|
+
setIsOpen(false);
|
|
16164
|
+
}
|
|
16165
|
+
},
|
|
16076
16166
|
css: Trigger_ref
|
|
16077
16167
|
}), (0,jsx_runtime_namespaceObject.jsx)(TriggerInput, {
|
|
16078
16168
|
datepickerType: "to",
|
|
16079
|
-
className: classNames?.trigger?.inputTo
|
|
16080
|
-
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
|
|
16084
|
-
|
|
16085
|
-
|
|
16086
|
-
|
|
16087
|
-
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
|
|
16091
|
-
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16100
|
-
|
|
16101
|
-
|
|
16102
|
-
|
|
16103
|
-
|
|
16104
|
-
}
|
|
16105
|
-
}, true ? "" : 0, true ? "" : 0)
|
|
16169
|
+
className: classNames?.trigger?.inputTo
|
|
16170
|
+
}), showCalendarIcon && (0,jsx_runtime_namespaceObject.jsx)(PopoverTrigger, {
|
|
16171
|
+
asChild: true,
|
|
16172
|
+
children: (0,jsx_runtime_namespaceObject.jsx)(Button_Button, {
|
|
16173
|
+
endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
|
|
16174
|
+
name: "calendar",
|
|
16175
|
+
size: 16,
|
|
16176
|
+
color: disabled ? theme.colors.grey : theme.colors.greyDarker
|
|
16177
|
+
}),
|
|
16178
|
+
"data-testid": 'daterangepicker-button',
|
|
16179
|
+
onClick: handleToggleOpen,
|
|
16180
|
+
variant: "tertiary",
|
|
16181
|
+
"aria-label": "Calendar",
|
|
16182
|
+
isDisabled: disabled,
|
|
16183
|
+
className: classNames?.trigger?.calendarIcon,
|
|
16184
|
+
css: /*#__PURE__*/(0,react_namespaceObject.css)({
|
|
16185
|
+
padding: 0,
|
|
16186
|
+
margin: '0 0 0 10px',
|
|
16187
|
+
height: 'auto',
|
|
16188
|
+
cursor: disabled ? 'default' : 'pointer',
|
|
16189
|
+
'&:focus::before': {
|
|
16190
|
+
display: 'none'
|
|
16191
|
+
}
|
|
16192
|
+
}, true ? "" : 0, true ? "" : 0)
|
|
16193
|
+
})
|
|
16106
16194
|
})]
|
|
16107
16195
|
})
|
|
16108
16196
|
}), showStatusArea && (0,jsx_runtime_namespaceObject.jsx)(TriggerStatusArea, {})]
|
|
@@ -16127,12 +16215,8 @@ const Content_DatePickerContent = () => {
|
|
|
16127
16215
|
};
|
|
16128
16216
|
;// ./src/components/DateRangePicker/hooks/useDatePickerMask.tsx
|
|
16129
16217
|
|
|
16130
|
-
|
|
16131
16218
|
const useDatePickerMask_useDatePickerMask = ({
|
|
16132
|
-
maskOptions
|
|
16133
|
-
formatIndexes,
|
|
16134
|
-
dateMinParts,
|
|
16135
|
-
dateMaxParts
|
|
16219
|
+
maskOptions
|
|
16136
16220
|
}) => {
|
|
16137
16221
|
const {
|
|
16138
16222
|
mask,
|
|
@@ -16145,28 +16229,13 @@ const useDatePickerMask_useDatePickerMask = ({
|
|
|
16145
16229
|
mask,
|
|
16146
16230
|
replacement,
|
|
16147
16231
|
track: ({
|
|
16148
|
-
data
|
|
16149
|
-
selectionStart,
|
|
16150
|
-
selectionEnd,
|
|
16151
|
-
value: currentValue
|
|
16232
|
+
data
|
|
16152
16233
|
}) => {
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
replacement
|
|
16159
|
-
});
|
|
16160
|
-
const splittedValue = updatedValue.split('/');
|
|
16161
|
-
const isChecked = dates_processDate({
|
|
16162
|
-
day: splittedValue[formatIndexes['day']],
|
|
16163
|
-
month: splittedValue[formatIndexes['month']],
|
|
16164
|
-
year: splittedValue[formatIndexes['year']]
|
|
16165
|
-
}, dateMinParts[formatIndexes['year']], dateMaxParts[formatIndexes['year']]);
|
|
16166
|
-
return isChecked ? data : '';
|
|
16167
|
-
} else {
|
|
16168
|
-
return data;
|
|
16169
|
-
}
|
|
16234
|
+
// The mask should only format input, not validate it
|
|
16235
|
+
// Validation happens on blur in useDateRangePicker.handleBlur
|
|
16236
|
+
// This allows users to freely type and edit dates without blocking
|
|
16237
|
+
// Return data as-is (string for insertions, null/undefined for deletions)
|
|
16238
|
+
return data;
|
|
16170
16239
|
},
|
|
16171
16240
|
...restMaskOptions
|
|
16172
16241
|
});
|
|
@@ -16208,15 +16277,12 @@ const useDateRangePicker = ({
|
|
|
16208
16277
|
const [isOpen, setIsOpen] = (0,external_react_namespaceObject.useState)(isOpenState);
|
|
16209
16278
|
const [status, setStatus] = (0,external_react_namespaceObject.useState)(rest.status);
|
|
16210
16279
|
const previousOpenState = (0,external_react_namespaceObject.useRef)(isOpenState);
|
|
16211
|
-
const
|
|
16212
|
-
|
|
16213
|
-
};
|
|
16280
|
+
const previousDateTime = (0,external_react_namespaceObject.useRef)([undefined, undefined]);
|
|
16281
|
+
const defaultValueProcessed = (0,external_react_namespaceObject.useRef)(false);
|
|
16214
16282
|
const {
|
|
16215
16283
|
clearErrors,
|
|
16216
16284
|
setError,
|
|
16217
|
-
setValue
|
|
16218
|
-
resetField,
|
|
16219
|
-
setFocus
|
|
16285
|
+
setValue
|
|
16220
16286
|
} = (0,external_react_hook_form_namespaceObject.useFormContext)();
|
|
16221
16287
|
const nameFrom = `${_name}From`;
|
|
16222
16288
|
const nameTo = `${_name}To`;
|
|
@@ -16230,7 +16296,6 @@ const useDateRangePicker = ({
|
|
|
16230
16296
|
const [lastChangedDate, setLastChangedDate] = (0,external_react_namespaceObject.useState)([undefined, undefined]);
|
|
16231
16297
|
const [lastFocusedElement, setLastFocusedElement] = (0,external_react_namespaceObject.useState)('from');
|
|
16232
16298
|
const currentIndex = lastFocusedElement === 'from' ? 0 : 1;
|
|
16233
|
-
const currentName = lastFocusedElement === 'from' ? nameFrom : nameTo;
|
|
16234
16299
|
const [dateTimeForChangeEvent, setDateTimeForChangeEvent] = (0,external_react_namespaceObject.useState)(undefined);
|
|
16235
16300
|
const [currentError, setCurrentError] = (0,external_react_namespaceObject.useState)({
|
|
16236
16301
|
date: null,
|
|
@@ -16243,6 +16308,7 @@ const useDateRangePicker = ({
|
|
|
16243
16308
|
year: splittedFormat.findIndex(item => item === 'yyyy')
|
|
16244
16309
|
});
|
|
16245
16310
|
const [calendarType, setCalendarType] = (0,external_react_namespaceObject.useState)(rangePickerType);
|
|
16311
|
+
const [rangeSelectionStep, setRangeSelectionStep] = (0,external_react_namespaceObject.useState)(null);
|
|
16246
16312
|
const [calendarViewDateTime, setCalendarViewDateTime] = (0,external_react_namespaceObject.useState)([undefined, undefined]);
|
|
16247
16313
|
const currentCalendarViewDT = calendarViewDateTime[currentIndex] || external_luxon_namespaceObject.DateTime.now().set({
|
|
16248
16314
|
day: 1
|
|
@@ -16252,14 +16318,18 @@ const useDateRangePicker = ({
|
|
|
16252
16318
|
const dateMinParts = finalDateMin.split('/').map(Number);
|
|
16253
16319
|
const dateMaxParts = finalDateMax.split('/').map(Number);
|
|
16254
16320
|
const defaultMask = getMaskForFormat(format);
|
|
16255
|
-
|
|
16321
|
+
// separate mask refs per input to prevent focus/typing conflicts
|
|
16322
|
+
const maskInputRefFrom = useDatePickerMask_useDatePickerMask({
|
|
16256
16323
|
maskOptions: {
|
|
16257
16324
|
mask: defaultMask,
|
|
16258
|
-
...maskOptions
|
|
16259
|
-
}
|
|
16260
|
-
|
|
16261
|
-
|
|
16262
|
-
|
|
16325
|
+
...(maskOptions || {})
|
|
16326
|
+
}
|
|
16327
|
+
});
|
|
16328
|
+
const maskInputRefTo = useDatePickerMask_useDatePickerMask({
|
|
16329
|
+
maskOptions: {
|
|
16330
|
+
mask: defaultMask,
|
|
16331
|
+
...(maskOptions || {})
|
|
16332
|
+
}
|
|
16263
16333
|
});
|
|
16264
16334
|
const dateMaxDT = external_luxon_namespaceObject.DateTime.fromObject({
|
|
16265
16335
|
year: dateMaxParts[formatIndexes['year']],
|
|
@@ -16313,7 +16383,7 @@ const useDateRangePicker = ({
|
|
|
16313
16383
|
setError(currentName, {
|
|
16314
16384
|
message: errorMessage
|
|
16315
16385
|
}, {
|
|
16316
|
-
shouldFocus:
|
|
16386
|
+
shouldFocus: false
|
|
16317
16387
|
});
|
|
16318
16388
|
setStatus('error');
|
|
16319
16389
|
setDateTime(newDateTimeIfInvalid);
|
|
@@ -16325,7 +16395,7 @@ const useDateRangePicker = ({
|
|
|
16325
16395
|
setError(currentName, {
|
|
16326
16396
|
message: errorMessage
|
|
16327
16397
|
}, {
|
|
16328
|
-
shouldFocus:
|
|
16398
|
+
shouldFocus: false
|
|
16329
16399
|
});
|
|
16330
16400
|
setStatus('error');
|
|
16331
16401
|
setDateTime(newDateTimeIfInvalid);
|
|
@@ -16333,6 +16403,33 @@ const useDateRangePicker = ({
|
|
|
16333
16403
|
safeOnChange();
|
|
16334
16404
|
} else {
|
|
16335
16405
|
setDateTime(newDateTimeIfValid);
|
|
16406
|
+
// Update calendar view to reflect the manually entered date
|
|
16407
|
+
let adjustedDateTime = newDateTime.startOf('day');
|
|
16408
|
+
if (adjustedDateTime < dateMinDT) {
|
|
16409
|
+
const {
|
|
16410
|
+
year,
|
|
16411
|
+
month,
|
|
16412
|
+
day
|
|
16413
|
+
} = dateMinDT;
|
|
16414
|
+
adjustedDateTime = adjustedDateTime.set({
|
|
16415
|
+
year,
|
|
16416
|
+
month,
|
|
16417
|
+
day
|
|
16418
|
+
});
|
|
16419
|
+
}
|
|
16420
|
+
if (adjustedDateTime > dateMaxDT) {
|
|
16421
|
+
const {
|
|
16422
|
+
year,
|
|
16423
|
+
month,
|
|
16424
|
+
day
|
|
16425
|
+
} = dateMaxDT;
|
|
16426
|
+
adjustedDateTime = adjustedDateTime.set({
|
|
16427
|
+
year,
|
|
16428
|
+
month,
|
|
16429
|
+
day
|
|
16430
|
+
});
|
|
16431
|
+
}
|
|
16432
|
+
setCalendarViewDateTime(currentElementType === 'from' ? [adjustedDateTime, calendarViewDateTime[1] || adjustedDateTime] : [calendarViewDateTime[0] || adjustedDateTime, adjustedDateTime]);
|
|
16336
16433
|
clearErrors();
|
|
16337
16434
|
setStatus('basic');
|
|
16338
16435
|
safeOnError?.(null);
|
|
@@ -16341,26 +16438,35 @@ const useDateRangePicker = ({
|
|
|
16341
16438
|
}
|
|
16342
16439
|
};
|
|
16343
16440
|
const handleBlur = event => {
|
|
16344
|
-
event.preventDefault();
|
|
16345
16441
|
const blurredValue = event.currentTarget.value;
|
|
16442
|
+
const fieldName = event.currentTarget.name;
|
|
16443
|
+
const isFromField = fieldName === nameFrom;
|
|
16346
16444
|
if (blurredValue.length > 0) {
|
|
16347
|
-
processValue(blurredValue);
|
|
16445
|
+
processValue(blurredValue, isFromField ? 'from' : 'to');
|
|
16446
|
+
} else {
|
|
16447
|
+
// User cleared the field - clear the corresponding dateTime
|
|
16448
|
+
setDateTime(prev => isFromField ? [undefined, prev[1]] : [prev[0], undefined]);
|
|
16449
|
+
setLastChangedDate(prev => isFromField ? [undefined, prev[1]] : [prev[0], undefined]);
|
|
16450
|
+
setValue(fieldName, undefined);
|
|
16451
|
+
clearErrors(fieldName);
|
|
16348
16452
|
}
|
|
16349
16453
|
};
|
|
16350
16454
|
const processInputValue = (inputValue, elementName) => {
|
|
16351
16455
|
const currentElementType = elementName || lastFocusedElement;
|
|
16352
16456
|
const currentName = currentElementType === 'from' ? nameFrom : nameTo;
|
|
16457
|
+
const currentWatchedValue = currentElementType === 'from' ? inputValueFrom : inputValueTo;
|
|
16353
16458
|
if (typeof inputValue === 'string' && inputValue.length && inputValue.length < expectedDateLength) {
|
|
16354
16459
|
setIsOpen(false);
|
|
16355
|
-
setTimeout(() => {
|
|
16356
|
-
maskInputRef.current.focus();
|
|
16357
|
-
}, 10);
|
|
16358
16460
|
}
|
|
16359
16461
|
let newDateTime;
|
|
16360
16462
|
if (typeof inputValue === 'string' && inputValue.length === expectedDateLength) {
|
|
16361
16463
|
newDateTime = external_luxon_namespaceObject.DateTime.fromFormat(inputValue, luxonFormat);
|
|
16362
|
-
setValue
|
|
16363
|
-
|
|
16464
|
+
// Avoid redundant setValue to prevent React Hook Form update loops
|
|
16465
|
+
if (currentWatchedValue !== inputValue) {
|
|
16466
|
+
setValue(currentName, inputValue);
|
|
16467
|
+
}
|
|
16468
|
+
// Do NOT validate immediately here to avoid blocking mid-edit scenarios and feedback loops.
|
|
16469
|
+
// Validation will happen on blur explicitly.
|
|
16364
16470
|
}
|
|
16365
16471
|
const newCalendarViewDateTime = newDateTime && newDateTime.isValid ? newDateTime : undefined;
|
|
16366
16472
|
if (newCalendarViewDateTime) {
|
|
@@ -16408,56 +16514,95 @@ const useDateRangePicker = ({
|
|
|
16408
16514
|
}
|
|
16409
16515
|
}, [inputValueTo]);
|
|
16410
16516
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
16411
|
-
|
|
16412
|
-
|
|
16413
|
-
|
|
16414
|
-
|
|
16415
|
-
|
|
16416
|
-
|
|
16517
|
+
// Only sync when dateTime actually changes (from calendar selection or programmatic change)
|
|
16518
|
+
// Don't sync when only inputValue changes (user typing)
|
|
16519
|
+
const dateTimeChanged = previousDateTime.current[0]?.toMillis() !== dateTime[0]?.toMillis() || previousDateTime.current[1]?.toMillis() !== dateTime[1]?.toMillis();
|
|
16520
|
+
|
|
16521
|
+
// Initialize on first run
|
|
16522
|
+
if (previousDateTime.current[0] === undefined && previousDateTime.current[1] === undefined && (dateTime[0] !== undefined || dateTime[1] !== undefined)) {
|
|
16523
|
+
previousDateTime.current = [dateTime[0], dateTime[1]];
|
|
16524
|
+
// Continue to sync on initialization
|
|
16525
|
+
} else if (!dateTimeChanged) {
|
|
16526
|
+
// dateTime hasn't changed, don't sync (user is typing)
|
|
16527
|
+
return;
|
|
16528
|
+
} else {
|
|
16529
|
+
// Update previous dateTime
|
|
16530
|
+
previousDateTime.current = [dateTime[0], dateTime[1]];
|
|
16531
|
+
}
|
|
16532
|
+
const nextFromValue = dateTime[0]?.toFormat(luxonFormat);
|
|
16533
|
+
if (nextFromValue) {
|
|
16534
|
+
// Sync dateTime to form when dateTime changed (calendar selection)
|
|
16535
|
+
// Don't overwrite if user is actively typing (input is focused and partial)
|
|
16536
|
+
const isInputFocused = inputFromRef.current && document.activeElement === inputFromRef.current || inputToRef.current && document.activeElement === inputToRef.current;
|
|
16537
|
+
if (!inputValueFrom) {
|
|
16538
|
+
// Input is empty - sync from dateTime
|
|
16539
|
+
setValue(nameFrom, nextFromValue);
|
|
16540
|
+
} else if (inputValueFrom === nextFromValue) {
|
|
16541
|
+
// Already in sync - no action needed
|
|
16542
|
+
} else if (inputValueFrom.length < expectedDateLength && isInputFocused) {
|
|
16543
|
+
// User is actively typing partial input - don't overwrite
|
|
16544
|
+
} else {
|
|
16545
|
+
// dateTime changed (calendar selection) - sync to form
|
|
16546
|
+
setValue(nameFrom, nextFromValue);
|
|
16547
|
+
}
|
|
16548
|
+
}
|
|
16549
|
+
const nextToValue = dateTime[1]?.toFormat(luxonFormat);
|
|
16550
|
+
if (nextToValue) {
|
|
16551
|
+
// Sync dateTime to form when dateTime changed (calendar selection)
|
|
16552
|
+
// Don't overwrite if user is actively typing (input is focused and partial)
|
|
16553
|
+
const isInputFocused = inputFromRef.current && document.activeElement === inputFromRef.current || inputToRef.current && document.activeElement === inputToRef.current;
|
|
16554
|
+
if (!inputValueTo) {
|
|
16555
|
+
// Input is empty - sync from dateTime
|
|
16556
|
+
setValue(nameTo, nextToValue);
|
|
16557
|
+
} else if (inputValueTo === nextToValue) {
|
|
16558
|
+
// Already in sync - no action needed
|
|
16559
|
+
} else if (inputValueTo.length < expectedDateLength && isInputFocused) {
|
|
16560
|
+
// User is actively typing partial input - don't overwrite
|
|
16561
|
+
} else {
|
|
16562
|
+
// dateTime changed (calendar selection) - sync to form
|
|
16563
|
+
setValue(nameTo, nextToValue);
|
|
16417
16564
|
}
|
|
16418
16565
|
}
|
|
16419
|
-
}, [dateTime,
|
|
16566
|
+
}, [dateTime, inputValueFrom, inputValueTo, luxonFormat, nameFrom, nameTo, setValue, expectedDateLength, inputFromRef, inputToRef]);
|
|
16420
16567
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
16421
16568
|
if (dateTime[0] && dateTime[1] && dateTime[0] > dateTime[1]) {
|
|
16569
|
+
// When dates are in reverse order, swap them silently
|
|
16570
|
+
// Calendar only opens via user click on icon button, not automatically
|
|
16422
16571
|
if (lastFocusedElement === 'from') {
|
|
16423
|
-
resetField(nameTo);
|
|
16424
16572
|
setDateTime([dateTime[0], undefined]);
|
|
16425
16573
|
setLastChangedDate([dateTime[0].toJSDate(), undefined]);
|
|
16426
16574
|
setValue(nameTo, undefined);
|
|
16427
|
-
setLastFocusedElement('to');
|
|
16428
|
-
setTimeout(() => {
|
|
16429
|
-
setFocus(nameTo, {
|
|
16430
|
-
shouldSelect: true
|
|
16431
|
-
});
|
|
16432
|
-
}, 50);
|
|
16433
|
-
setIsOpen(true);
|
|
16434
16575
|
} else {
|
|
16435
|
-
resetField(nameFrom);
|
|
16436
16576
|
setDateTime([undefined, dateTime[1]]);
|
|
16437
16577
|
setLastChangedDate([undefined, dateTime[1].toJSDate()]);
|
|
16438
16578
|
setValue(nameFrom, undefined);
|
|
16439
|
-
setLastFocusedElement('from');
|
|
16440
|
-
setTimeout(() => {
|
|
16441
|
-
setFocus(nameFrom, {
|
|
16442
|
-
shouldSelect: true
|
|
16443
|
-
});
|
|
16444
|
-
}, 50);
|
|
16445
|
-
setIsOpen(true);
|
|
16446
16579
|
}
|
|
16447
16580
|
}
|
|
16448
|
-
}, [dateTime]);
|
|
16581
|
+
}, [dateTime, lastFocusedElement, nameFrom, nameTo, setValue]);
|
|
16449
16582
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
16450
16583
|
if (previousOpenState.current !== isOpen) {
|
|
16451
16584
|
if (isOpen) {
|
|
16452
16585
|
onOpen?.();
|
|
16586
|
+
setRangeSelectionStep('start');
|
|
16587
|
+
setLastFocusedElement('from');
|
|
16588
|
+
// Sync calendar view with current dateTime when opening
|
|
16589
|
+
// This ensures preselected dates are visible in the calendar
|
|
16590
|
+
if (dateTime[0] || dateTime[1]) {
|
|
16591
|
+
setCalendarViewDateTime([dateTime[0] || dateTime[1] || external_luxon_namespaceObject.DateTime.now().set({
|
|
16592
|
+
day: 1
|
|
16593
|
+
}), dateTime[1] || dateTime[0] || external_luxon_namespaceObject.DateTime.now().set({
|
|
16594
|
+
day: 1
|
|
16595
|
+
})]);
|
|
16596
|
+
}
|
|
16453
16597
|
} else {
|
|
16454
16598
|
onClose?.();
|
|
16599
|
+
setRangeSelectionStep(null);
|
|
16455
16600
|
setCalendarType(rangePickerType);
|
|
16456
16601
|
setCalendarViewDateTime([dateTime[0], dateTime[1]]);
|
|
16457
16602
|
}
|
|
16458
16603
|
previousOpenState.current = isOpen;
|
|
16459
16604
|
}
|
|
16460
|
-
}, [isOpen]);
|
|
16605
|
+
}, [isOpen, dateTime, rangePickerType, onOpen, onClose]);
|
|
16461
16606
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
16462
16607
|
const splittedFormat = format.split('/');
|
|
16463
16608
|
setFormatIndexes({
|
|
@@ -16484,27 +16629,18 @@ const useDateRangePicker = ({
|
|
|
16484
16629
|
if (Array.isArray(rest.value)) {
|
|
16485
16630
|
const newDateTimeFrom = typeof rest.value[0] === 'string' && rest.value[0].length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[0], luxonFormat) : undefined;
|
|
16486
16631
|
const newDateTimeTo = typeof rest.value[1] === 'string' && rest.value[1].length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[1], luxonFormat) : undefined;
|
|
16487
|
-
const newDateTime = [newDateTimeFrom?.isValid ? newDateTimeFrom : undefined, newDateTimeTo?.isValid ? newDateTimeTo : undefined];
|
|
16632
|
+
const newDateTime = [newDateTimeFrom?.isValid ? newDateTimeFrom.startOf('day') : undefined, newDateTimeTo?.isValid ? newDateTimeTo.startOf('day') : undefined];
|
|
16488
16633
|
setDateTime(newDateTime);
|
|
16489
16634
|
setLastChangedDate([newDateTime[0]?.toJSDate(), newDateTime[1]?.toJSDate()]);
|
|
16635
|
+
// Sync calendar view with the new dates so they're visible when calendar opens
|
|
16636
|
+
setCalendarViewDateTime([newDateTime[0] || newDateTime[1] || undefined, newDateTime[1] || newDateTime[0] || undefined]);
|
|
16490
16637
|
setValue(nameFrom, newDateTime[0]?.toFormat(luxonFormat));
|
|
16491
16638
|
setValue(nameTo, newDateTime[1]?.toFormat(luxonFormat));
|
|
16492
16639
|
}
|
|
16493
|
-
}, [rest.value]);
|
|
16640
|
+
}, [rest.value, expectedDateLength, luxonFormat, nameFrom, nameTo, setValue, _name]);
|
|
16494
16641
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
16495
16642
|
setStatus(rest.status);
|
|
16496
16643
|
}, [rest.status]);
|
|
16497
|
-
(0,external_react_namespaceObject.useEffect)(() => {
|
|
16498
|
-
if (lastChangedDate[0] || lastChangedDate[1]) {
|
|
16499
|
-
if (lastFocusedElement === 'from' && !lastChangedDate[1]) {
|
|
16500
|
-
setFocus(nameTo);
|
|
16501
|
-
}
|
|
16502
|
-
if (lastFocusedElement === 'to' && !lastChangedDate[0]) {
|
|
16503
|
-
setFocus(nameFrom);
|
|
16504
|
-
inputFromRef.current?.focus();
|
|
16505
|
-
}
|
|
16506
|
-
}
|
|
16507
|
-
}, [lastChangedDate]);
|
|
16508
16644
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
16509
16645
|
if (calendarViewDateTime[0] && !calendarViewDateTime[1]) {
|
|
16510
16646
|
setCalendarViewDateTime([calendarViewDateTime[0], calendarViewDateTime[0]]);
|
|
@@ -16519,11 +16655,20 @@ const useDateRangePicker = ({
|
|
|
16519
16655
|
}
|
|
16520
16656
|
}, [isOpenState]);
|
|
16521
16657
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
16522
|
-
|
|
16523
|
-
|
|
16524
|
-
|
|
16658
|
+
// Only process defaultValue once on mount to avoid re-processing
|
|
16659
|
+
if (Array.isArray(defaultValue) && !defaultValueProcessed.current) {
|
|
16660
|
+
const defaultDateTimeFrom = typeof defaultValue[0] === 'string' && defaultValue[0].length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(defaultValue[0], luxonFormat) : undefined;
|
|
16661
|
+
const defaultDateTimeTo = typeof defaultValue[1] === 'string' && defaultValue[1].length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(defaultValue[1], luxonFormat) : undefined;
|
|
16662
|
+
const newDateTime = [defaultDateTimeFrom?.isValid ? defaultDateTimeFrom.startOf('day') : undefined, defaultDateTimeTo?.isValid ? defaultDateTimeTo.startOf('day') : undefined];
|
|
16663
|
+
setDateTime(newDateTime);
|
|
16664
|
+
setLastChangedDate([newDateTime[0]?.toJSDate(), newDateTime[1]?.toJSDate()]);
|
|
16665
|
+
// Sync calendar view with default dates so they're visible when calendar opens
|
|
16666
|
+
setCalendarViewDateTime([newDateTime[0] || newDateTime[1] || undefined, newDateTime[1] || newDateTime[0] || undefined]);
|
|
16667
|
+
setValue(nameFrom, newDateTime[0]?.toFormat(luxonFormat));
|
|
16668
|
+
setValue(nameTo, newDateTime[1]?.toFormat(luxonFormat));
|
|
16669
|
+
defaultValueProcessed.current = true;
|
|
16525
16670
|
}
|
|
16526
|
-
}, []);
|
|
16671
|
+
}, [defaultValue, expectedDateLength, luxonFormat, nameFrom, nameTo, setCalendarViewDateTime, setValue, _name]);
|
|
16527
16672
|
return {
|
|
16528
16673
|
formatIndexes,
|
|
16529
16674
|
dateMinParts,
|
|
@@ -16534,7 +16679,6 @@ const useDateRangePicker = ({
|
|
|
16534
16679
|
inputValueFrom,
|
|
16535
16680
|
inputValueTo,
|
|
16536
16681
|
calendarViewDateTime,
|
|
16537
|
-
maskInputRef,
|
|
16538
16682
|
calendarType,
|
|
16539
16683
|
lastChangedDate,
|
|
16540
16684
|
luxonFormat,
|
|
@@ -16545,16 +16689,24 @@ const useDateRangePicker = ({
|
|
|
16545
16689
|
currentCalendarViewDT,
|
|
16546
16690
|
isOpen,
|
|
16547
16691
|
status,
|
|
16548
|
-
inputFromRef: (0,external_floating_ui_react_namespaceObject.useMergeRefs)([
|
|
16549
|
-
inputToRef: (0,external_floating_ui_react_namespaceObject.useMergeRefs)([
|
|
16692
|
+
inputFromRef: (0,external_floating_ui_react_namespaceObject.useMergeRefs)([maskInputRefFrom, inputFromRef]),
|
|
16693
|
+
inputToRef: (0,external_floating_ui_react_namespaceObject.useMergeRefs)([maskInputRefTo, inputToRef]),
|
|
16550
16694
|
setIsOpen,
|
|
16551
|
-
handleSetIsOpen,
|
|
16552
16695
|
setLastFocusedElement,
|
|
16553
16696
|
safeOnChange,
|
|
16554
16697
|
setCalendarType,
|
|
16555
16698
|
setCalendarViewDateTime,
|
|
16556
16699
|
setDateTime,
|
|
16557
|
-
handleBlur
|
|
16700
|
+
handleBlur,
|
|
16701
|
+
rangeSelectionStep,
|
|
16702
|
+
setRangeSelectionStep,
|
|
16703
|
+
clearInputValue: field => {
|
|
16704
|
+
const targetName = field === 'from' ? nameFrom : nameTo;
|
|
16705
|
+
clearErrors(targetName);
|
|
16706
|
+
setValue(targetName, undefined);
|
|
16707
|
+
setDateTime(prev => field === 'from' ? [undefined, prev[1]] : [prev[0], undefined]);
|
|
16708
|
+
setLastChangedDate(prev => field === 'from' ? [undefined, prev[1]] : [prev[0], undefined]);
|
|
16709
|
+
}
|
|
16558
16710
|
};
|
|
16559
16711
|
};
|
|
16560
16712
|
;// ./src/components/DateRangePicker/DateRangePickerProvider.tsx
|
|
@@ -16583,7 +16735,7 @@ const DateRangePickerProvider = ({
|
|
|
16583
16735
|
};
|
|
16584
16736
|
const handleToggleOpen = e => {
|
|
16585
16737
|
const tagName = e.currentTarget.tagName.toLowerCase();
|
|
16586
|
-
if (
|
|
16738
|
+
if (tagName === 'button') {
|
|
16587
16739
|
toggleOpen();
|
|
16588
16740
|
}
|
|
16589
16741
|
if (tagName === 'input' && rest.inputProps?.inputProps?.onClick) {
|
|
@@ -16610,7 +16762,6 @@ const DateRangePickerProvider = ({
|
|
|
16610
16762
|
|
|
16611
16763
|
const DateRangePicker = ({
|
|
16612
16764
|
format,
|
|
16613
|
-
openCalendarMode = 'icon',
|
|
16614
16765
|
showCalendarIcon = true,
|
|
16615
16766
|
showStatusArea = true,
|
|
16616
16767
|
rangePickerType = 'days',
|
|
@@ -16619,7 +16770,6 @@ const DateRangePicker = ({
|
|
|
16619
16770
|
const actualFormat = format || getFormatForRangePickerType(rangePickerType);
|
|
16620
16771
|
return (0,jsx_runtime_namespaceObject.jsx)(DateRangePickerProvider, {
|
|
16621
16772
|
format: actualFormat,
|
|
16622
|
-
openCalendarMode: openCalendarMode,
|
|
16623
16773
|
showCalendarIcon: showCalendarIcon,
|
|
16624
16774
|
showStatusArea: showStatusArea,
|
|
16625
16775
|
rangePickerType: rangePickerType,
|