@povio/ui 3.3.0-rc.3 → 3.3.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/README.md +15 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +55 -206
- package/dist/components/buttons/Button/button.cva.d.ts +1 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +9 -34
- package/dist/components/buttons/shared/ButtonContent.js +22 -80
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +10 -24
- package/dist/components/inputs/Checkbox/CheckboxGroup.d.ts +5 -1
- package/dist/components/inputs/Checkbox/CheckboxGroup.js +234 -201
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +93 -227
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +1 -0
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +170 -273
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +60 -147
- package/dist/components/inputs/DateTime/shared/Calendar.js +139 -339
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +114 -308
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +35 -150
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +95 -229
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +115 -296
- package/dist/components/inputs/DateTime/shared/DateField.js +135 -301
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +142 -338
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +10 -59
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +144 -134
- package/dist/components/inputs/DateTime/shared/useFirefoxDateSegmentSelectionGuard.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/useFirefoxDateSegmentSelectionGuard.js +33 -0
- package/dist/components/inputs/File/FileUpload.js +1 -1
- package/dist/components/inputs/File/InputUpload.js +65 -261
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +48 -180
- package/dist/components/inputs/File/shared/FileUploadContentError.js +95 -265
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +99 -261
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +56 -234
- package/dist/components/inputs/File/shared/ProgressBar.js +15 -102
- package/dist/components/inputs/FormField/FormField.js +34 -47
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +2 -1
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +77 -314
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +23 -83
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +56 -2
- package/dist/components/inputs/Selection/Select/QuerySelect.js +82 -94
- package/dist/components/inputs/Selection/Select/Select.js +3 -3
- package/dist/components/inputs/Selection/shared/SelectInput.js +1 -0
- package/dist/components/inputs/Selection/shared/SelectListBox.js +51 -163
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +1 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +1 -0
- package/dist/components/inputs/Selection/shared/select.context.js +19 -9
- package/dist/components/inputs/Selection/shared/useSelectItems.js +48 -108
- package/dist/components/inputs/Skeleton/InputFrame.js +177 -552
- package/dist/components/inputs/TextEditor/TextEditor.js +87 -389
- package/dist/components/inputs/shared/InputClear.js +24 -40
- package/dist/components/inputs/shared/input.cva.js +1 -1
- package/dist/components/navigation/Accordion/Accordion.js +22 -69
- package/dist/components/navigation/Accordion/AccordionItem.js +41 -86
- package/dist/components/navigation/Stepper/Stepper.js +22 -67
- package/dist/components/overlays/ActionModal/ActionModal.js +35 -169
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +29 -110
- package/dist/components/shared/pagination/Pagination.js +22 -108
- package/dist/components/shared/pagination/minWidth.cva.d.ts +1 -1
- package/dist/components/status/Alert/Alert.js +30 -97
- package/dist/components/table/InfiniteTable.js +16 -67
- package/dist/components/table/Table.d.ts +2 -8
- package/dist/components/table/Table.js +33 -55
- package/dist/components/text/Typography/Typography.js +8 -23
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/theme.context.js +45 -98
- package/dist/config/uiConfig.context.d.ts +1 -0
- package/dist/config/uiConfig.context.js +10 -40
- package/dist/config/uiOverrides.context.d.ts +0 -1
- package/dist/helpers/dynamicColumns.js +2 -1
- package/dist/hooks/useDebounceCallback.js +17 -51
- package/dist/hooks/useFormAutosave.js +33 -120
- package/dist/hooks/useLongPressRepeat.js +20 -55
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/utils/date-time.utils.d.ts +0 -1
- package/dist/utils/date-time.utils.js +21 -45
- package/dist/utils/intl.utils.d.ts +7 -0
- package/dist/utils/intl.utils.js +38 -0
- package/dist/utils/intl.utils.spec.d.ts +1 -0
- package/package.json +2 -2
- package/dist/components/inputs/FormField/formField.cva.d.ts +0 -11
- package/dist/components/inputs/FormField/formField.cva.js +0 -16
- package/dist/components/table/TableColumnFilterInput.d.ts +0 -9
- package/dist/components/table/TableColumnFilterInput.js +0 -108
- package/dist/components/table/TableColumnFilterPlaceholder.d.ts +0 -5
- package/dist/components/table/TableColumnFilterPlaceholder.js +0 -41
- package/dist/components/table/TableColumnFilterRow.d.ts +0 -16
- package/dist/components/table/TableColumnFilterRow.js +0 -68
|
@@ -15,10 +15,9 @@ import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
|
15
15
|
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
16
16
|
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
17
17
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
18
|
-
import { c } from "react/compiler-runtime";
|
|
19
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
19
|
import { clsx } from "clsx";
|
|
21
|
-
import { useCallback, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
20
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
22
21
|
import { Button } from "react-aria-components";
|
|
23
22
|
import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
|
|
24
23
|
import { mergeRefs } from "@react-aria/utils";
|
|
@@ -31,7 +30,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
31
30
|
var DateRangePickerBase = (props) => {
|
|
32
31
|
const ui = UIConfig.useConfig();
|
|
33
32
|
const { t } = useTranslation();
|
|
34
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel: hideLabelProp, variant: variantProp, as: asProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconButtonComponent: todayIconButtonComponentProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, autoFixYear: autoFixYearProp, fireBlurOnChange: fireBlurOnChangeProp, minValue, maxValue, ...rest } = props;
|
|
33
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel: hideLabelProp, variant: variantProp, as: asProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconButtonComponent: todayIconButtonComponentProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, autoFixYear: autoFixYearProp, fireBlurOnChange: fireBlurOnChangeProp, allowPartialRange: allowPartialRangeProp, minValue, maxValue, ...rest } = props;
|
|
35
34
|
const hideLabel = hideLabelProp ?? ui.input.hideLabel;
|
|
36
35
|
const variant = variantProp ?? ui.input.variant;
|
|
37
36
|
const as = asProp ?? ui.input.as;
|
|
@@ -45,6 +44,7 @@ var DateRangePickerBase = (props) => {
|
|
|
45
44
|
const disableManualEntry = disableManualEntryProp ?? ui.dateInput.disableManualEntry;
|
|
46
45
|
const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
|
|
47
46
|
const fireBlurOnChange = fireBlurOnChangeProp ?? ui.dateInput.fireBlurOnChange;
|
|
47
|
+
const allowPartialRange = allowPartialRangeProp ?? ui.dateInput.allowPartialRange;
|
|
48
48
|
const timeZone = ui.dateInput.timeZone;
|
|
49
49
|
let effectiveTimeZone = getLocalTimeZone();
|
|
50
50
|
if (timeZone !== "clientLocal") effectiveTimeZone = timeZone;
|
|
@@ -54,6 +54,8 @@ var DateRangePickerBase = (props) => {
|
|
|
54
54
|
return datePickerInputRef.current?.getContainer?.() || null;
|
|
55
55
|
} }), []);
|
|
56
56
|
const normalizedValue = value ?? null;
|
|
57
|
+
const fieldRangeRef = useRef(normalizedValue);
|
|
58
|
+
fieldRangeRef.current = normalizedValue;
|
|
57
59
|
const dialogState = useDateRangePickerState({
|
|
58
60
|
...rest,
|
|
59
61
|
value: normalizedValue,
|
|
@@ -69,6 +71,8 @@ var DateRangePickerBase = (props) => {
|
|
|
69
71
|
minValue,
|
|
70
72
|
maxValue,
|
|
71
73
|
onChange: (newValue) => {
|
|
74
|
+
if (allowPartialRange && newValue === null) return;
|
|
75
|
+
fieldRangeRef.current = newValue;
|
|
72
76
|
const isInvalidRange = isValidRange(newValue);
|
|
73
77
|
onChange?.(newValue);
|
|
74
78
|
if (isInvalidRange) return;
|
|
@@ -91,6 +95,18 @@ var DateRangePickerBase = (props) => {
|
|
|
91
95
|
minValue,
|
|
92
96
|
maxValue
|
|
93
97
|
}, dialogState, dateRangePickerRef);
|
|
98
|
+
const emitPartialRangeChange = (part, date) => {
|
|
99
|
+
if (!allowPartialRange) return;
|
|
100
|
+
const partialRange = {
|
|
101
|
+
start: part === "start" ? date : fieldRangeRef.current?.start ?? null,
|
|
102
|
+
end: part === "end" ? date : fieldRangeRef.current?.end ?? null
|
|
103
|
+
};
|
|
104
|
+
fieldRangeRef.current = partialRange;
|
|
105
|
+
if (partialRange.start && partialRange.end) return;
|
|
106
|
+
const newValue_0 = partialRange.start || partialRange.end ? partialRange : null;
|
|
107
|
+
onChange?.(newValue_0);
|
|
108
|
+
if (fireBlurOnChange) debouncedBlur(newValue_0);
|
|
109
|
+
};
|
|
94
110
|
const { locale } = useLocale$1();
|
|
95
111
|
useImperativeHandle(ref, () => ({
|
|
96
112
|
clear: () => {
|
|
@@ -98,8 +114,8 @@ var DateRangePickerBase = (props) => {
|
|
|
98
114
|
},
|
|
99
115
|
getContainer: () => datePickerInputRef.current?.getContainer?.() ?? null
|
|
100
116
|
}));
|
|
101
|
-
const handleBlur = (
|
|
102
|
-
onBlur?.({ target: { value:
|
|
117
|
+
const handleBlur = (newValue_1) => {
|
|
118
|
+
onBlur?.({ target: { value: newValue_1 } });
|
|
103
119
|
};
|
|
104
120
|
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
105
121
|
const formFieldProps = {
|
|
@@ -152,9 +168,9 @@ var DateRangePickerBase = (props) => {
|
|
|
152
168
|
className: headerClassName,
|
|
153
169
|
labelProps
|
|
154
170
|
};
|
|
155
|
-
const isDateOutsideBounds = useCallback((
|
|
156
|
-
if (minValue &&
|
|
157
|
-
if (maxValue &&
|
|
171
|
+
const isDateOutsideBounds = useCallback((date_0) => {
|
|
172
|
+
if (minValue && date_0.compare(minValue) < 0) return true;
|
|
173
|
+
if (maxValue && date_0.compare(maxValue) > 0) return true;
|
|
158
174
|
return false;
|
|
159
175
|
}, [minValue, maxValue]);
|
|
160
176
|
const clampRangeToBounds = useCallback((range) => {
|
|
@@ -178,10 +194,10 @@ var DateRangePickerBase = (props) => {
|
|
|
178
194
|
if (maxValue && range_0.end.compare(maxValue) > 0) return false;
|
|
179
195
|
return true;
|
|
180
196
|
}, [minValue, maxValue]);
|
|
181
|
-
const isValidRange = useCallback((
|
|
182
|
-
if (
|
|
183
|
-
const startDate_0 =
|
|
184
|
-
if (
|
|
197
|
+
const isValidRange = useCallback((newValue_2) => {
|
|
198
|
+
if (newValue_2?.start && newValue_2?.end) {
|
|
199
|
+
const startDate_0 = newValue_2.start;
|
|
200
|
+
if (newValue_2.end.compare(startDate_0) < 0) {
|
|
185
201
|
setValidationRangeError(t(($) => $.ui.datePicker.errors.endDateBeforeStart, { ns: "ui" }));
|
|
186
202
|
return true;
|
|
187
203
|
}
|
|
@@ -189,9 +205,9 @@ var DateRangePickerBase = (props) => {
|
|
|
189
205
|
} else setValidationRangeError(void 0);
|
|
190
206
|
return false;
|
|
191
207
|
}, [t]);
|
|
192
|
-
const handleCalendarStatesChange = (
|
|
193
|
-
if (
|
|
194
|
-
const clampedValue = clampRangeToBounds(
|
|
208
|
+
const handleCalendarStatesChange = (newValue_3) => {
|
|
209
|
+
if (newValue_3) {
|
|
210
|
+
const clampedValue = clampRangeToBounds(newValue_3);
|
|
195
211
|
if (!clampedValue) return;
|
|
196
212
|
if (isValidRange(clampedValue)) return;
|
|
197
213
|
dialogState.setValue(clampedValue);
|
|
@@ -223,33 +239,33 @@ var DateRangePickerBase = (props) => {
|
|
|
223
239
|
setActivePreset(null);
|
|
224
240
|
}
|
|
225
241
|
};
|
|
226
|
-
const throttledSetHoverDate = useCallback((
|
|
242
|
+
const throttledSetHoverDate = useCallback((date_1) => {
|
|
227
243
|
requestAnimationFrame(() => {
|
|
228
|
-
setHoverDate(
|
|
244
|
+
setHoverDate(date_1);
|
|
229
245
|
});
|
|
230
246
|
}, []);
|
|
231
|
-
const handleDateHover = useCallback((
|
|
232
|
-
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(
|
|
247
|
+
const handleDateHover = useCallback((date_2) => {
|
|
248
|
+
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(date_2);
|
|
233
249
|
}, [
|
|
234
250
|
rangeSelection.isSelecting,
|
|
235
251
|
rangeSelection.start,
|
|
236
252
|
throttledSetHoverDate
|
|
237
253
|
]);
|
|
238
|
-
const handleDateSelection = useCallback((
|
|
254
|
+
const handleDateSelection = useCallback((date_3, calendarSide) => {
|
|
239
255
|
if (calendarSide) {
|
|
240
256
|
const currentVisibleMonth = (calendarSide === "left" ? leftCalendarState : rightCalendarState).visibleRange.start;
|
|
241
|
-
if (
|
|
242
|
-
leftCalendarState.setFocusedDate(
|
|
243
|
-
rightCalendarState.setFocusedDate(
|
|
257
|
+
if (date_3.month !== currentVisibleMonth.month || date_3.year !== currentVisibleMonth.year) if (calendarSide === "left") {
|
|
258
|
+
leftCalendarState.setFocusedDate(date_3);
|
|
259
|
+
rightCalendarState.setFocusedDate(date_3.add({ months: 1 }));
|
|
244
260
|
} else {
|
|
245
|
-
rightCalendarState.setFocusedDate(
|
|
246
|
-
leftCalendarState.setFocusedDate(
|
|
261
|
+
rightCalendarState.setFocusedDate(date_3);
|
|
262
|
+
leftCalendarState.setFocusedDate(date_3.subtract({ months: 1 }));
|
|
247
263
|
}
|
|
248
264
|
}
|
|
249
|
-
if (isDateOutsideBounds(
|
|
265
|
+
if (isDateOutsideBounds(date_3)) return;
|
|
250
266
|
if (!rangeSelection.isSelecting || !rangeSelection.start) {
|
|
251
267
|
setRangeSelection({
|
|
252
|
-
start:
|
|
268
|
+
start: date_3,
|
|
253
269
|
end: null,
|
|
254
270
|
isSelecting: true
|
|
255
271
|
});
|
|
@@ -258,7 +274,7 @@ var DateRangePickerBase = (props) => {
|
|
|
258
274
|
rightCalendarState.setValue(null);
|
|
259
275
|
} else {
|
|
260
276
|
const { start } = rangeSelection;
|
|
261
|
-
const end =
|
|
277
|
+
const end = date_3;
|
|
262
278
|
const clampedRange = clampRangeToBounds({
|
|
263
279
|
start: start.compare(end) <= 0 ? start : end,
|
|
264
280
|
end: start.compare(end) <= 0 ? end : start
|
|
@@ -283,13 +299,13 @@ var DateRangePickerBase = (props) => {
|
|
|
283
299
|
isDateOutsideBounds,
|
|
284
300
|
clampRangeToBounds
|
|
285
301
|
]);
|
|
286
|
-
const handleKeyboardNavigation = useCallback((event,
|
|
302
|
+
const handleKeyboardNavigation = useCallback((event, date_4, calendarSide_0) => {
|
|
287
303
|
const currentState_0 = calendarSide_0 === "left" ? leftCalendarState : rightCalendarState;
|
|
288
304
|
const otherState = calendarSide_0 === "left" ? rightCalendarState : leftCalendarState;
|
|
289
305
|
let shouldPreventDefault = false;
|
|
290
306
|
switch (event.key) {
|
|
291
307
|
case "ArrowRight": {
|
|
292
|
-
const nextDate =
|
|
308
|
+
const nextDate = date_4.add({ days: 1 });
|
|
293
309
|
const currentMonth_2 = currentState_0.visibleRange.start;
|
|
294
310
|
const otherMonth_2 = otherState.visibleRange.start;
|
|
295
311
|
if (calendarSide_0 === "left" && nextDate.month !== currentMonth_2.month) if (nextDate.year === otherMonth_2.year && nextDate.month === otherMonth_2.month) {
|
|
@@ -302,7 +318,7 @@ var DateRangePickerBase = (props) => {
|
|
|
302
318
|
break;
|
|
303
319
|
}
|
|
304
320
|
case "ArrowLeft": {
|
|
305
|
-
const prevDate =
|
|
321
|
+
const prevDate = date_4.subtract({ days: 1 });
|
|
306
322
|
const currentMonth_1 = currentState_0.visibleRange.start;
|
|
307
323
|
const otherMonth_1 = otherState.visibleRange.start;
|
|
308
324
|
if (calendarSide_0 === "right" && prevDate.month !== currentMonth_1.month) if (prevDate.year === otherMonth_1.year && prevDate.month === otherMonth_1.month) {
|
|
@@ -315,7 +331,7 @@ var DateRangePickerBase = (props) => {
|
|
|
315
331
|
break;
|
|
316
332
|
}
|
|
317
333
|
case "ArrowDown": {
|
|
318
|
-
const nextWeekDate =
|
|
334
|
+
const nextWeekDate = date_4.add({ weeks: 1 });
|
|
319
335
|
const currentMonth_0 = currentState_0.visibleRange.start;
|
|
320
336
|
const otherMonth_0 = otherState.visibleRange.start;
|
|
321
337
|
if (calendarSide_0 === "left" && nextWeekDate.month !== currentMonth_0.month) if (nextWeekDate.year === otherMonth_0.year && nextWeekDate.month === otherMonth_0.month) {
|
|
@@ -328,7 +344,7 @@ var DateRangePickerBase = (props) => {
|
|
|
328
344
|
break;
|
|
329
345
|
}
|
|
330
346
|
case "ArrowUp": {
|
|
331
|
-
const prevWeekDate =
|
|
347
|
+
const prevWeekDate = date_4.subtract({ weeks: 1 });
|
|
332
348
|
const currentMonth = currentState_0.visibleRange.start;
|
|
333
349
|
const otherMonth = otherState.visibleRange.start;
|
|
334
350
|
if (calendarSide_0 === "right" && prevWeekDate.month !== currentMonth.month) if (prevWeekDate.year === otherMonth.year && prevWeekDate.month === otherMonth.month) {
|
|
@@ -342,7 +358,7 @@ var DateRangePickerBase = (props) => {
|
|
|
342
358
|
}
|
|
343
359
|
case "Enter":
|
|
344
360
|
case " ":
|
|
345
|
-
handleDateSelection(
|
|
361
|
+
handleDateSelection(date_4);
|
|
346
362
|
shouldPreventDefault = true;
|
|
347
363
|
break;
|
|
348
364
|
case "Escape":
|
|
@@ -366,8 +382,8 @@ var DateRangePickerBase = (props) => {
|
|
|
366
382
|
rightCalendarState,
|
|
367
383
|
handleDateSelection
|
|
368
384
|
]);
|
|
369
|
-
const syncCalendarStates = useCallback((
|
|
370
|
-
if (
|
|
385
|
+
const syncCalendarStates = useCallback((newValue_4) => {
|
|
386
|
+
if (newValue_4 === null) {
|
|
371
387
|
setValidationRangeError(void 0);
|
|
372
388
|
leftCalendarState.setValue(null);
|
|
373
389
|
rightCalendarState.setValue(null);
|
|
@@ -380,7 +396,7 @@ var DateRangePickerBase = (props) => {
|
|
|
380
396
|
setHoverDate(null);
|
|
381
397
|
return;
|
|
382
398
|
}
|
|
383
|
-
const clampedValue_0 = clampRangeToBounds(
|
|
399
|
+
const clampedValue_0 = clampRangeToBounds(newValue_4);
|
|
384
400
|
if (!clampedValue_0) return;
|
|
385
401
|
if (isValidRange(clampedValue_0)) return;
|
|
386
402
|
leftCalendarState.setValue(clampedValue_0);
|
|
@@ -430,6 +446,7 @@ var DateRangePickerBase = (props) => {
|
|
|
430
446
|
syncCalendarStates(clampedTodayRange);
|
|
431
447
|
};
|
|
432
448
|
const onInputClear = () => {
|
|
449
|
+
fieldRangeRef.current = null;
|
|
433
450
|
onChange?.(null);
|
|
434
451
|
dialogState.setValue(null);
|
|
435
452
|
leftCalendarState.setValue(null);
|
|
@@ -442,25 +459,33 @@ var DateRangePickerBase = (props) => {
|
|
|
442
459
|
setHoverDate(null);
|
|
443
460
|
if (fireBlurOnChange) handleBlur(null);
|
|
444
461
|
};
|
|
445
|
-
const
|
|
446
|
-
state.
|
|
447
|
-
if (!
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
leftCalendarState.setValue(state.value);
|
|
451
|
-
rightCalendarState.setValue(state.value);
|
|
452
|
-
const startDate_3 = state.value.start || today(effectiveTimeZone);
|
|
453
|
-
const endDate_3 = state.value.end || today(effectiveTimeZone).add({ months: 1 });
|
|
454
|
-
leftCalendarState.setFocusedDate(startDate_3);
|
|
455
|
-
if (startDate_3.year === endDate_3.year && startDate_3.month === endDate_3.month) rightCalendarState.setFocusedDate(startDate_3.add({ months: 1 }));
|
|
456
|
-
else rightCalendarState.setFocusedDate(endDate_3);
|
|
457
|
-
setRangeSelection({
|
|
458
|
-
start: state.value.start,
|
|
459
|
-
end: state.value.end,
|
|
460
|
-
isSelecting: false
|
|
461
|
-
});
|
|
462
|
-
}
|
|
462
|
+
const syncSelectionFromControlledValue = () => {
|
|
463
|
+
const currentValue = state.value;
|
|
464
|
+
if (!(currentValue != null && currentValue.start != null && currentValue.end != null)) {
|
|
465
|
+
syncCalendarStates(null);
|
|
466
|
+
return;
|
|
463
467
|
}
|
|
468
|
+
syncCalendarStates(currentValue);
|
|
469
|
+
const startDate_3 = currentValue.start;
|
|
470
|
+
const endDate_3 = currentValue.end;
|
|
471
|
+
leftCalendarState.setFocusedDate(startDate_3);
|
|
472
|
+
if (startDate_3.year === endDate_3.year && startDate_3.month === endDate_3.month) {
|
|
473
|
+
rightCalendarState.setFocusedDate(startDate_3.add({ months: 1 }));
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
rightCalendarState.setFocusedDate(endDate_3);
|
|
477
|
+
};
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
if (!state.isOpen) return;
|
|
480
|
+
syncSelectionFromControlledValue();
|
|
481
|
+
}, [state.isOpen]);
|
|
482
|
+
const onOpenChange = (_isOpen) => {
|
|
483
|
+
state.toggle();
|
|
484
|
+
syncSelectionFromControlledValue();
|
|
485
|
+
};
|
|
486
|
+
const onOpenDropdown = () => {
|
|
487
|
+
syncSelectionFromControlledValue();
|
|
488
|
+
state.toggle();
|
|
464
489
|
};
|
|
465
490
|
const todayDate_0 = today(effectiveTimeZone);
|
|
466
491
|
const getThisWeekRange = () => {
|
|
@@ -600,6 +625,10 @@ var DateRangePickerBase = (props) => {
|
|
|
600
625
|
groupProps,
|
|
601
626
|
fieldProps: {
|
|
602
627
|
...startFieldProps,
|
|
628
|
+
onChange: (date_5) => {
|
|
629
|
+
startFieldProps.onChange?.(date_5);
|
|
630
|
+
emitPartialRangeChange("start", date_5);
|
|
631
|
+
},
|
|
603
632
|
onBlur: (event_0) => {
|
|
604
633
|
startFieldProps.onBlur?.(event_0);
|
|
605
634
|
handleBlur(state.value);
|
|
@@ -607,6 +636,10 @@ var DateRangePickerBase = (props) => {
|
|
|
607
636
|
},
|
|
608
637
|
endFieldProps: {
|
|
609
638
|
...endFieldProps,
|
|
639
|
+
onChange: (date_6) => {
|
|
640
|
+
endFieldProps.onChange?.(date_6);
|
|
641
|
+
emitPartialRangeChange("end", date_6);
|
|
642
|
+
},
|
|
610
643
|
onBlur: (event_1) => {
|
|
611
644
|
endFieldProps.onBlur?.(event_1);
|
|
612
645
|
handleBlur(state.value);
|
|
@@ -633,7 +666,7 @@ var DateRangePickerBase = (props) => {
|
|
|
633
666
|
autoFixYear,
|
|
634
667
|
placeholder,
|
|
635
668
|
className: inputClassName,
|
|
636
|
-
onOpenDropdown
|
|
669
|
+
onOpenDropdown,
|
|
637
670
|
timeZone: effectiveTimeZone,
|
|
638
671
|
fireBlurOnChange,
|
|
639
672
|
onClear: onInputClear
|
|
@@ -687,101 +720,67 @@ var DateRangePickerBase = (props) => {
|
|
|
687
720
|
})
|
|
688
721
|
});
|
|
689
722
|
};
|
|
690
|
-
var DateRangePickerInner = (
|
|
691
|
-
const $ = c(25);
|
|
692
|
-
const { fullIso: t1, minValue, maxValue, renderStaticInput, isFormControlDisabled, ...props } = t0;
|
|
693
|
-
const fullIso = t1 === void 0 ? true : t1;
|
|
723
|
+
var DateRangePickerInner = ({ fullIso = true, minValue, maxValue, renderStaticInput, isFormControlDisabled, ...props }) => {
|
|
694
724
|
const ui = UIConfig.useConfig();
|
|
695
725
|
const datePickerInputContentRowCva = UIOverrides.useCva("datePickerInput.contentRowCva", datePickerInputContentRowDefinition);
|
|
696
726
|
const { locale } = useLocale$1();
|
|
697
727
|
const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
728
|
+
const allowPartialRange = props.allowPartialRange ?? ui.dateInput.allowPartialRange;
|
|
698
729
|
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
699
730
|
const inputRef = useRef(null);
|
|
700
731
|
const { renderRealInput, replayStaticInputPress } = useStaticInputHandoff({
|
|
701
732
|
inputRef,
|
|
702
733
|
renderInput,
|
|
703
734
|
setRenderInput,
|
|
704
|
-
getFocusTarget:
|
|
705
|
-
|
|
735
|
+
getFocusTarget: (input, staticTarget) => {
|
|
736
|
+
const container = input.getContainer?.() ?? input;
|
|
737
|
+
return container instanceof HTMLElement ? getStaticDateTimeFocusTarget(container, staticTarget) : null;
|
|
738
|
+
},
|
|
739
|
+
getPressTarget: (input_0) => {
|
|
740
|
+
const container_0 = input_0.getContainer?.() ?? input_0;
|
|
741
|
+
if (!(container_0 instanceof HTMLElement)) return null;
|
|
742
|
+
return container_0.querySelector("[data-static-press-action]");
|
|
743
|
+
}
|
|
706
744
|
});
|
|
707
745
|
const normalizedValue = props.value ?? null;
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
start: DateTimeUtils.fromCalendarDateToUTCISO(range.start),
|
|
714
|
-
end: DateTimeUtils.fromCalendarDateToUTCISO(range.end, { endOfDay: true })
|
|
715
|
-
};
|
|
716
|
-
const startDate = DateTimeUtils.fromDateValueToLocal(range.start, "UTC");
|
|
717
|
-
const endDate = DateTimeUtils.fromDateValueToLocal(range.end, "UTC");
|
|
718
|
-
return {
|
|
719
|
-
start: DateTime.fromJSDate(startDate, { zone: "UTC" }).toISODate(),
|
|
720
|
-
end: DateTime.fromJSDate(endDate, { zone: "UTC" }).toISODate()
|
|
721
|
-
};
|
|
746
|
+
const formatDateRange = (range) => {
|
|
747
|
+
if (!range || !range.start && !range.end || !allowPartialRange && (!range.start || !range.end)) return null;
|
|
748
|
+
if (fullIso) return {
|
|
749
|
+
start: range.start ? DateTimeUtils.fromCalendarDateToUTCISO(range.start) : null,
|
|
750
|
+
end: range.end ? DateTimeUtils.fromCalendarDateToUTCISO(range.end, { endOfDay: true }) : null
|
|
722
751
|
};
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
if ($[2] !== fullIso) {
|
|
729
|
-
t3 = (formattedRange) => {
|
|
730
|
-
if (!formattedRange?.start || !formattedRange?.end) return null;
|
|
731
|
-
if (fullIso) return {
|
|
732
|
-
start: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.start),
|
|
733
|
-
end: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.end)
|
|
734
|
-
};
|
|
735
|
-
const startDate_0 = DateTime.fromISO(formattedRange.start, { zone: "UTC" }).toJSDate();
|
|
736
|
-
const endDate_0 = DateTime.fromISO(formattedRange.end, { zone: "UTC" }).toJSDate();
|
|
737
|
-
const startZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(startDate_0, "UTC");
|
|
738
|
-
const endZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(endDate_0, "UTC");
|
|
739
|
-
return {
|
|
740
|
-
start: toCalendarDate(startZonedDateTime),
|
|
741
|
-
end: toCalendarDate(endZonedDateTime)
|
|
742
|
-
};
|
|
752
|
+
const startDate = range.start ? DateTimeUtils.fromDateValueToLocal(range.start, "UTC") : null;
|
|
753
|
+
const endDate = range.end ? DateTimeUtils.fromDateValueToLocal(range.end, "UTC") : null;
|
|
754
|
+
return {
|
|
755
|
+
start: startDate ? DateTime.fromJSDate(startDate, { zone: "UTC" }).toISODate() : null,
|
|
756
|
+
end: endDate ? DateTime.fromJSDate(endDate, { zone: "UTC" }).toISODate() : null
|
|
743
757
|
};
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
t4 = (formattedDate) => {
|
|
751
|
-
if (formattedDate == null) return null;
|
|
752
|
-
if (fullIso) return DateTimeUtils.fromUTCISOToCalendarDate(formattedDate);
|
|
753
|
-
const date = DateTime.fromISO(formattedDate, { zone: "UTC" }).toJSDate();
|
|
754
|
-
return toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date, "UTC"));
|
|
758
|
+
};
|
|
759
|
+
const parseDateRange = (formattedRange) => {
|
|
760
|
+
if (!formattedRange || !formattedRange.start && !formattedRange.end || !allowPartialRange && (!formattedRange.start || !formattedRange.end)) return null;
|
|
761
|
+
if (fullIso) return {
|
|
762
|
+
start: formattedRange.start ? DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.start) : null,
|
|
763
|
+
end: formattedRange.end ? DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.end) : null
|
|
755
764
|
};
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
$[6] = minValue;
|
|
764
|
-
$[7] = parseCalendarDate;
|
|
765
|
-
$[8] = t5;
|
|
766
|
-
} else t5 = $[8];
|
|
767
|
-
let t6;
|
|
768
|
-
if ($[9] !== maxValue || $[10] !== parseCalendarDate) {
|
|
769
|
-
t6 = typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue;
|
|
770
|
-
$[9] = maxValue;
|
|
771
|
-
$[10] = parseCalendarDate;
|
|
772
|
-
$[11] = t6;
|
|
773
|
-
} else t6 = $[11];
|
|
774
|
-
let t7;
|
|
775
|
-
if ($[12] !== t5 || $[13] !== t6) {
|
|
776
|
-
t7 = {
|
|
777
|
-
minValue: t5,
|
|
778
|
-
maxValue: t6
|
|
765
|
+
const startDate_0 = formattedRange.start ? DateTime.fromISO(formattedRange.start, { zone: "UTC" }).toJSDate() : null;
|
|
766
|
+
const endDate_0 = formattedRange.end ? DateTime.fromISO(formattedRange.end, { zone: "UTC" }).toJSDate() : null;
|
|
767
|
+
const startZonedDateTime = startDate_0 ? DateTimeUtils.fromLocalToZonedDateTime(startDate_0, "UTC") : null;
|
|
768
|
+
const endZonedDateTime = endDate_0 ? DateTimeUtils.fromLocalToZonedDateTime(endDate_0, "UTC") : null;
|
|
769
|
+
return {
|
|
770
|
+
start: startZonedDateTime ? toCalendarDate(startZonedDateTime) : null,
|
|
771
|
+
end: endZonedDateTime ? toCalendarDate(endZonedDateTime) : null
|
|
779
772
|
};
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
773
|
+
};
|
|
774
|
+
const parseCalendarDate = (formattedDate) => {
|
|
775
|
+
if (formattedDate == null) return null;
|
|
776
|
+
if (fullIso) return DateTimeUtils.fromUTCISOToCalendarDate(formattedDate);
|
|
777
|
+
const date = DateTime.fromISO(formattedDate, { zone: "UTC" }).toJSDate();
|
|
778
|
+
return toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date, "UTC"));
|
|
779
|
+
};
|
|
780
|
+
const dateLimits = {
|
|
781
|
+
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
782
|
+
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
783
|
+
};
|
|
785
784
|
if (!renderInput) {
|
|
786
785
|
const startDateValue = parseCalendarDate(normalizedValue?.start ?? null);
|
|
787
786
|
const endDateValue = parseCalendarDate(normalizedValue?.end ?? null);
|
|
@@ -841,153 +840,51 @@ var DateRangePickerInner = (t0) => {
|
|
|
841
840
|
trailingClassName: "py-0! pl-0!",
|
|
842
841
|
action: showDropdown ? {
|
|
843
842
|
icon: ui.dateInput.calendarIcon,
|
|
844
|
-
onClick:
|
|
843
|
+
onClick: () => {},
|
|
845
844
|
altText: ""
|
|
846
845
|
} : void 0,
|
|
847
846
|
children: staticSegments
|
|
848
847
|
});
|
|
849
848
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
$[16] = props;
|
|
858
|
-
$[17] = t10;
|
|
859
|
-
} else t10 = $[17];
|
|
860
|
-
let t11;
|
|
861
|
-
if ($[18] !== T0 || $[19] !== dateLimits || $[20] !== props || $[21] !== t10 || $[22] !== t8 || $[23] !== t9) {
|
|
862
|
-
t11 = /* @__PURE__ */ jsx(T0, {
|
|
863
|
-
...props,
|
|
864
|
-
...dateLimits,
|
|
865
|
-
ref: t8,
|
|
866
|
-
value: t9,
|
|
867
|
-
onChange: t10
|
|
868
|
-
});
|
|
869
|
-
$[18] = T0;
|
|
870
|
-
$[19] = dateLimits;
|
|
871
|
-
$[20] = props;
|
|
872
|
-
$[21] = t10;
|
|
873
|
-
$[22] = t8;
|
|
874
|
-
$[23] = t9;
|
|
875
|
-
$[24] = t11;
|
|
876
|
-
} else t11 = $[24];
|
|
877
|
-
return t11;
|
|
849
|
+
return /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
850
|
+
...props,
|
|
851
|
+
...dateLimits,
|
|
852
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
853
|
+
value: parseDateRange(normalizedValue),
|
|
854
|
+
onChange: (value) => props.onChange?.(formatDateRange(value))
|
|
855
|
+
});
|
|
878
856
|
};
|
|
879
|
-
var DateRangePicker = (
|
|
880
|
-
const $ = c(30);
|
|
881
|
-
let maxValue;
|
|
882
|
-
let minValue;
|
|
883
|
-
let props;
|
|
884
|
-
let renderStaticInput;
|
|
885
|
-
let t1;
|
|
886
|
-
if ($[0] !== t0) {
|
|
887
|
-
({fullIso: t1, minValue, maxValue, renderStaticInput, ...props} = t0);
|
|
888
|
-
$[0] = t0;
|
|
889
|
-
$[1] = maxValue;
|
|
890
|
-
$[2] = minValue;
|
|
891
|
-
$[3] = props;
|
|
892
|
-
$[4] = renderStaticInput;
|
|
893
|
-
$[5] = t1;
|
|
894
|
-
} else {
|
|
895
|
-
maxValue = $[1];
|
|
896
|
-
minValue = $[2];
|
|
897
|
-
props = $[3];
|
|
898
|
-
renderStaticInput = $[4];
|
|
899
|
-
t1 = $[5];
|
|
900
|
-
}
|
|
901
|
-
const fullIso = t1 === void 0 ? true : t1;
|
|
857
|
+
var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
|
|
902
858
|
if ("formControl" in props && props.formControl) {
|
|
903
|
-
|
|
904
|
-
let innerProps;
|
|
905
|
-
let ref;
|
|
906
|
-
if ($[6] !== props) {
|
|
907
|
-
({formControl, ref, ...innerProps} = props);
|
|
908
|
-
$[6] = props;
|
|
909
|
-
$[7] = formControl;
|
|
910
|
-
$[8] = innerProps;
|
|
911
|
-
$[9] = ref;
|
|
912
|
-
} else {
|
|
913
|
-
formControl = $[7];
|
|
914
|
-
innerProps = $[8];
|
|
915
|
-
ref = $[9];
|
|
916
|
-
}
|
|
859
|
+
const { formControl, ref, ...innerProps } = props;
|
|
917
860
|
const controlWithOptions = formControl.control;
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
renderStaticInput
|
|
937
|
-
});
|
|
938
|
-
};
|
|
939
|
-
$[10] = controlWithOptions._options?.disabled;
|
|
940
|
-
$[11] = fullIso;
|
|
941
|
-
$[12] = innerProps;
|
|
942
|
-
$[13] = maxValue;
|
|
943
|
-
$[14] = minValue;
|
|
944
|
-
$[15] = props.error;
|
|
945
|
-
$[16] = props.isDisabled;
|
|
946
|
-
$[17] = ref;
|
|
947
|
-
$[18] = renderStaticInput;
|
|
948
|
-
$[19] = t2;
|
|
949
|
-
} else t2 = $[19];
|
|
950
|
-
let t3;
|
|
951
|
-
if ($[20] !== formControl.control || $[21] !== formControl.name || $[22] !== t2) {
|
|
952
|
-
t3 = /* @__PURE__ */ jsx(Controller, {
|
|
953
|
-
control: formControl.control,
|
|
954
|
-
name: formControl.name,
|
|
955
|
-
render: t2
|
|
956
|
-
});
|
|
957
|
-
$[20] = formControl.control;
|
|
958
|
-
$[21] = formControl.name;
|
|
959
|
-
$[22] = t2;
|
|
960
|
-
$[23] = t3;
|
|
961
|
-
} else t3 = $[23];
|
|
962
|
-
return t3;
|
|
963
|
-
}
|
|
964
|
-
let t2;
|
|
965
|
-
if ($[24] !== fullIso || $[25] !== maxValue || $[26] !== minValue || $[27] !== props || $[28] !== renderStaticInput) {
|
|
966
|
-
t2 = /* @__PURE__ */ jsx(DateRangePickerInner, {
|
|
967
|
-
...props,
|
|
968
|
-
fullIso,
|
|
969
|
-
minValue,
|
|
970
|
-
maxValue,
|
|
971
|
-
renderStaticInput
|
|
861
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
862
|
+
control: formControl.control,
|
|
863
|
+
name: formControl.name,
|
|
864
|
+
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerInner, {
|
|
865
|
+
...innerProps,
|
|
866
|
+
ref: mergeRefs(ref, field.ref),
|
|
867
|
+
value: field.value ?? null,
|
|
868
|
+
onChange: field.onChange,
|
|
869
|
+
onBlur: field.onBlur,
|
|
870
|
+
isDirty,
|
|
871
|
+
isDisabled: field.disabled || props.isDisabled,
|
|
872
|
+
isFormControlDisabled: !!controlWithOptions._options?.disabled,
|
|
873
|
+
error: props.error ?? error?.message,
|
|
874
|
+
fullIso,
|
|
875
|
+
minValue,
|
|
876
|
+
maxValue,
|
|
877
|
+
renderStaticInput
|
|
878
|
+
})
|
|
972
879
|
});
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
880
|
+
}
|
|
881
|
+
return /* @__PURE__ */ jsx(DateRangePickerInner, {
|
|
882
|
+
...props,
|
|
883
|
+
fullIso,
|
|
884
|
+
minValue,
|
|
885
|
+
maxValue,
|
|
886
|
+
renderStaticInput
|
|
887
|
+
});
|
|
981
888
|
};
|
|
982
|
-
function _temp(input, staticTarget) {
|
|
983
|
-
const container = input.getContainer?.() ?? input;
|
|
984
|
-
return container instanceof HTMLElement ? getStaticDateTimeFocusTarget(container, staticTarget) : null;
|
|
985
|
-
}
|
|
986
|
-
function _temp2(input_0) {
|
|
987
|
-
const container_0 = input_0.getContainer?.() ?? input_0;
|
|
988
|
-
if (!(container_0 instanceof HTMLElement)) return null;
|
|
989
|
-
return container_0.querySelector("[data-static-press-action]");
|
|
990
|
-
}
|
|
991
|
-
function _temp3() {}
|
|
992
889
|
//#endregion
|
|
993
890
|
export { DateRangePicker };
|