@povio/ui 2.2.6 → 2.2.8-rc
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 +2 -0
- package/dist/assets/icons/AlignCenter.js +3 -1
- package/dist/assets/icons/AlignLeft.js +3 -1
- package/dist/assets/icons/AlignLeftRight.js +3 -1
- package/dist/assets/icons/AlignRight.js +3 -1
- package/dist/assets/icons/ArrowDropDown.js +3 -1
- package/dist/assets/icons/ArrowDropUp.js +3 -1
- package/dist/assets/icons/ArrowLeft.js +3 -1
- package/dist/assets/icons/ArrowRight.js +3 -1
- package/dist/assets/icons/Bold.js +3 -1
- package/dist/assets/icons/BulletedList.js +3 -1
- package/dist/assets/icons/Calendar.js +3 -1
- package/dist/assets/icons/Check.js +3 -1
- package/dist/assets/icons/CheckCircle.js +3 -1
- package/dist/assets/icons/CheckboxCheckmark.js +3 -1
- package/dist/assets/icons/CheckboxIndeterminate.js +3 -1
- package/dist/assets/icons/ChevronDown.js +3 -1
- package/dist/assets/icons/ChevronLeft.js +3 -1
- package/dist/assets/icons/ChevronRight.js +3 -1
- package/dist/assets/icons/ChevronUp.js +3 -1
- package/dist/assets/icons/ChevronsLeft.js +3 -1
- package/dist/assets/icons/ChevronsRight.js +3 -1
- package/dist/assets/icons/Clock.js +3 -1
- package/dist/assets/icons/Close.js +3 -1
- package/dist/assets/icons/DateTime.js +3 -1
- package/dist/assets/icons/DragIndicator.js +3 -1
- package/dist/assets/icons/File.js +3 -1
- package/dist/assets/icons/Highlight.js +3 -1
- package/dist/assets/icons/HighlightOn.js +3 -1
- package/dist/assets/icons/Home.js +3 -1
- package/dist/assets/icons/Info.js +3 -1
- package/dist/assets/icons/Italic.js +3 -1
- package/dist/assets/icons/Link.js +3 -1
- package/dist/assets/icons/Menu.js +3 -1
- package/dist/assets/icons/NumberedList.js +3 -1
- package/dist/assets/icons/PointerHorizontal.js +3 -1
- package/dist/assets/icons/PointerVertical.js +3 -1
- package/dist/assets/icons/Search.js +3 -1
- package/dist/assets/icons/Send.js +3 -1
- package/dist/assets/icons/Strikethrough.js +3 -1
- package/dist/assets/icons/TextColor.js +3 -1
- package/dist/assets/icons/Today.js +3 -1
- package/dist/assets/icons/Underlined.js +3 -1
- package/dist/assets/icons/Upload.js +3 -1
- package/dist/assets/icons/Visibility.js +3 -1
- package/dist/assets/icons/VisibilityOff.js +3 -1
- package/dist/assets/icons/WarningFilled.js +3 -1
- package/dist/assets/locales/en/translation.json.js +1 -0
- package/dist/assets/locales/sl/translation.json.js +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +5 -3
- package/dist/components/Breadcrumbs/breadcrumbs.cva.js +7 -5
- package/dist/components/Menu/Menu.js +3 -1
- package/dist/components/Menu/MenuDesktop.js +3 -1
- package/dist/components/Menu/MenuItem.js +3 -1
- package/dist/components/Menu/MenuMobile.js +3 -1
- package/dist/components/Menu/MenuPopover.js +3 -1
- package/dist/components/Menu/menu.cva.js +6 -4
- package/dist/components/buttons/Button/Button.js +3 -1
- package/dist/components/buttons/Button/button.cva.js +7 -5
- package/dist/components/buttons/IconButton/IconButton.js +3 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +3 -1
- package/dist/components/buttons/PillButton/PillButton.js +3 -1
- package/dist/components/buttons/PillButton/pillButton.cva.js +6 -4
- package/dist/components/buttons/SplitButton/SplitButton.js +3 -1
- package/dist/components/buttons/TextButton/TextButton.js +3 -1
- package/dist/components/buttons/ToggleButton/ToggleButton.js +3 -1
- package/dist/components/buttons/shared/ButtonContent.js +3 -1
- package/dist/components/buttons/shared/buttonContent.cva.js +2 -1
- package/dist/components/inputs/Checkbox/Checkbox.js +3 -1
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +3 -1
- package/dist/components/inputs/Checkbox/checkbox.cva.js +6 -4
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +63 -4
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +98 -10
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +63 -4
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +1 -0
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +64 -6
- package/dist/components/inputs/DateTime/shared/Calendar.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +4 -2
- package/dist/components/inputs/DateTime/shared/DateField.js +3 -1
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +3 -1
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +4 -2
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +3 -1
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +4 -2
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +3 -1
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +3 -1
- package/dist/components/inputs/DateTime/shared/TimeField.js +3 -1
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +3 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +6 -5
- package/dist/components/inputs/DateTime/shared/YearPicker.js +3 -1
- package/dist/components/inputs/File/FileUpload.js +6 -4
- package/dist/components/inputs/File/FileUploadContainer.js +3 -1
- package/dist/components/inputs/File/InputUpload.js +3 -1
- package/dist/components/inputs/File/shared/FileCard.js +3 -1
- package/dist/components/inputs/File/shared/FileCardList.js +3 -1
- package/dist/components/inputs/File/shared/FileUploadContent.js +3 -1
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +3 -1
- package/dist/components/inputs/File/shared/FileUploadContentError.js +4 -2
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +4 -2
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +4 -2
- package/dist/components/inputs/File/shared/InputUploadContent.js +4 -2
- package/dist/components/inputs/File/shared/InputUploadFilled.js +3 -1
- package/dist/components/inputs/File/shared/ProgressBar.js +3 -1
- package/dist/components/inputs/File/shared/fileUpload.cva.js +4 -2
- package/dist/components/inputs/File/shared/inputUploadButton.cva.js +6 -3
- package/dist/components/inputs/FormField/FormField.js +3 -1
- package/dist/components/inputs/FormField/FormFieldError.js +3 -1
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +4 -2
- package/dist/components/inputs/FormField/FormFieldHelper.js +3 -1
- package/dist/components/inputs/FormField/FormFieldLabel.js +3 -1
- package/dist/components/inputs/FormField/formFieldError.cva.js +3 -1
- package/dist/components/inputs/FormField/formFieldHelper.cva.js +3 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +1 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +82 -8
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +4 -2
- package/dist/components/inputs/Input/TextArea/TextArea.js +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +1 -0
- package/dist/components/inputs/Input/TextInput/TextInput.js +85 -8
- package/dist/components/inputs/Input/shared/InputContent.js +3 -1
- package/dist/components/inputs/Inputs/Form.js +2 -0
- package/dist/components/inputs/Inputs/InputItem.js +2 -0
- package/dist/components/inputs/Inputs/Inputs.js +2 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.js +3 -1
- package/dist/components/inputs/RadioGroup/radio.cva.js +5 -3
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +64 -2
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +3 -1
- package/dist/components/inputs/Selection/Select/Select.js +65 -2
- package/dist/components/inputs/Selection/shared/SelectBase.js +3 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectInputTags.js +3 -1
- package/dist/components/inputs/Selection/shared/SelectListBox.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +5 -3
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectMobile.js +3 -1
- package/dist/components/inputs/Selection/shared/select.context.js +20 -18
- package/dist/components/inputs/Selection/shared/useSelectItems.js +6 -4
- package/dist/components/inputs/Slider/Slider.js +3 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +4 -2
- package/dist/components/inputs/TextEditor/textEditor.types.js +3 -1
- package/dist/components/inputs/Toggle/Toggle.js +3 -1
- package/dist/components/inputs/Toggle/toggle.cva.js +4 -2
- package/dist/components/inputs/shared/CheckContent.js +3 -1
- package/dist/components/inputs/shared/InputClear.js +5 -3
- package/dist/components/inputs/shared/StaticInput.d.ts +18 -0
- package/dist/components/inputs/shared/StaticInput.js +69 -0
- package/dist/components/inputs/shared/TooltipWrapper.js +3 -1
- package/dist/components/inputs/shared/input.cva.js +6 -4
- package/dist/components/inputs/shared/label.cva.js +4 -2
- package/dist/components/navigation/Accordion/Accordion.js +3 -1
- package/dist/components/navigation/Accordion/AccordionItem.js +3 -1
- package/dist/components/navigation/Accordion/accordion.cva.js +12 -10
- package/dist/components/navigation/Stepper/Stepper.js +3 -1
- package/dist/components/navigation/Stepper/StepperItem.js +3 -1
- package/dist/components/navigation/Stepper/StepperSeparator.js +3 -1
- package/dist/components/navigation/Stepper/stepper.cva.js +9 -7
- package/dist/components/outline.clsx.js +4 -2
- package/dist/components/overlays/ActionModal/ActionModal.js +3 -1
- package/dist/components/overlays/BottomSheet/BottomSheet.js +3 -1
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +4 -2
- package/dist/components/overlays/Drawer/Drawer.js +3 -1
- package/dist/components/overlays/Modal/Modal.js +4 -2
- package/dist/components/overlays/Modal/modal.cva.js +5 -3
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +3 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +7 -2
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +3 -1
- package/dist/components/overlays/Tooltip/tooltip.cva.js +6 -4
- package/dist/components/segment/Segment.js +3 -1
- package/dist/components/segment/SegmentItem.js +3 -1
- package/dist/components/segment/segment.cva.js +4 -2
- package/dist/components/shared/pagination/Pagination.js +4 -2
- package/dist/components/shared/pagination/PaginationList.js +4 -2
- package/dist/components/shared/pagination/minWidth.cva.js +3 -1
- package/dist/components/shared/popover.cva.js +3 -1
- package/dist/components/status/Alert/Alert.js +3 -1
- package/dist/components/status/Alert/alert.cva.js +3 -1
- package/dist/components/status/Loader/Loader.js +3 -1
- package/dist/components/status/Loader/loader.cva.js +4 -2
- package/dist/components/status/Toast/Toast.js +15 -6
- package/dist/components/status/Toast/toast.cva.js +6 -20
- package/dist/components/status/Toast/useToast.js +3 -1
- package/dist/components/status/shared/status.cva.js +4 -2
- package/dist/components/table/CellText.js +3 -1
- package/dist/components/table/ColumnConfig.js +3 -1
- package/dist/components/table/HeaderText.js +3 -1
- package/dist/components/table/InfiniteTable.js +3 -1
- package/dist/components/table/PaginatedTable.js +3 -1
- package/dist/components/table/Table.js +4 -2
- package/dist/components/table/table.cva.js +8 -6
- package/dist/components/text/Link/Link.js +3 -1
- package/dist/components/text/Link/link.cva.js +3 -1
- package/dist/components/text/Tag/Tag.d.ts +3 -0
- package/dist/components/text/Tag/Tag.js +9 -4
- package/dist/components/text/Tag/tag.cva.js +3 -1
- package/dist/components/text/Typography/Typography.js +3 -1
- package/dist/components/text/Typography/typography.cva.js +3 -1
- package/dist/config/confirmation.context.js +4 -2
- package/dist/config/i18n.js +4 -2
- package/dist/config/link.context.js +3 -1
- package/dist/config/router.context.js +3 -1
- package/dist/config/theme.context.js +8 -6
- package/dist/config/uiConfig.context.d.ts +5 -0
- package/dist/config/uiConfig.context.js +10 -2
- package/dist/config/uiStyle.context.js +3 -1
- package/dist/helpers/dynamicColumns.js +4 -2
- package/dist/helpers/dynamicInputs.js +5 -3
- package/dist/hooks/useAutosave.js +2 -0
- package/dist/hooks/useBreakpoint.js +5 -3
- package/dist/hooks/useDebounceCallback.js +2 -0
- package/dist/hooks/useDeepCompare.js +5 -3
- package/dist/hooks/useFilters.js +3 -1
- package/dist/hooks/useForm.js +2 -0
- package/dist/hooks/useFormAutosave.js +2 -0
- package/dist/hooks/useIntersectionObserver.js +3 -1
- package/dist/hooks/useLocalStorage.js +3 -1
- package/dist/hooks/useLongPressRepeat.js +3 -1
- package/dist/hooks/usePagination.js +2 -0
- package/dist/hooks/useScrollableListBox.js +2 -0
- package/dist/hooks/useSorting.js +2 -0
- package/dist/hooks/useStateAndRef.js +3 -1
- package/dist/hooks/useTableColumnConfig.js +2 -0
- package/dist/hooks/useTableNav.js +124 -20
- package/dist/hooks/useTranslationMemo.js +2 -0
- package/dist/tw-ui-plugin.js +4 -2
- package/dist/utils/array.utils.js +3 -1
- package/dist/utils/compoundMapper.js +3 -1
- package/dist/utils/date-time.utils.d.ts +10 -0
- package/dist/utils/date-time.utils.js +85 -2
- package/dist/utils/date.utils.js +3 -1
- package/dist/utils/dom.utils.js +3 -1
- package/dist/utils/file.utils.js +3 -1
- package/dist/utils/isEqual.js +3 -1
- package/dist/utils/logger.js +3 -1
- package/dist/utils/object.utils.js +3 -1
- package/dist/utils/queries.utils.js +3 -1
- package/dist/utils/rest.utils.js +3 -1
- package/dist/utils/routing.utils.js +3 -1
- package/dist/utils/string.utils.js +3 -1
- package/dist/utils/zod.utils.js +3 -1
- package/package.json +2 -2
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import { CalendarIcon } from "../../../../assets/icons/Calendar.js";
|
|
1
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { TodayIcon } from "../../../../assets/icons/Today.js";
|
|
2
4
|
import { Calendar } from "../shared/Calendar.js";
|
|
3
5
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
4
6
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
5
7
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
6
8
|
import { FormField } from "../../FormField/FormField.js";
|
|
9
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
7
10
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
8
11
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
9
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
13
|
import { clsx } from "clsx";
|
|
11
|
-
import { useImperativeHandle, useMemo, useRef } from "react";
|
|
14
|
+
import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
12
15
|
import { useDatePicker, useLocale } from "react-aria";
|
|
13
16
|
import { mergeRefs } from "@react-aria/utils";
|
|
14
|
-
import { Controller } from "react-hook-form";
|
|
17
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
15
18
|
import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
|
|
16
19
|
import { DateTime } from "luxon";
|
|
17
20
|
import { useCalendarState, useDatePickerState } from "react-stately";
|
|
21
|
+
//#region src/components/inputs/DateTime/DatePicker/DatePicker.tsx
|
|
18
22
|
var DatePickerBase = (props) => {
|
|
19
23
|
const ui = UIConfig.useConfig();
|
|
20
24
|
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, placeholder, inputClassName, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
@@ -149,7 +153,19 @@ var DatePickerBase = (props) => {
|
|
|
149
153
|
})
|
|
150
154
|
});
|
|
151
155
|
};
|
|
152
|
-
|
|
156
|
+
var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
157
|
+
const ui = UIConfig.useConfig();
|
|
158
|
+
const { locale } = useLocale();
|
|
159
|
+
const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
|
|
160
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
161
|
+
const inputRef = useRef(null);
|
|
162
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
163
|
+
control: props.formControl.control,
|
|
164
|
+
name: props.formControl.name
|
|
165
|
+
}) : props.value;
|
|
166
|
+
let isFormControlDisabled = false;
|
|
167
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
168
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
153
169
|
const formatCalendarDate = (calendarDate) => {
|
|
154
170
|
if (calendarDate === null) return null;
|
|
155
171
|
if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(calendarDate);
|
|
@@ -166,6 +182,47 @@ const DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
166
182
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
167
183
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
168
184
|
};
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (!renderInput || !shouldFocus) return;
|
|
187
|
+
requestAnimationFrame(() => {
|
|
188
|
+
((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
|
|
189
|
+
});
|
|
190
|
+
setShouldFocus(false);
|
|
191
|
+
}, [renderInput, shouldFocus]);
|
|
192
|
+
if (!renderInput) {
|
|
193
|
+
const as = props.as ?? ui.input.as;
|
|
194
|
+
const size = props.size ?? ui.input.size;
|
|
195
|
+
const variant = props.variant ?? ui.input.variant;
|
|
196
|
+
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
197
|
+
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
198
|
+
let isDisabled = !!props.isDisabled;
|
|
199
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
200
|
+
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
201
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
202
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
203
|
+
const staticPlaceholder = props.placeholder ?? DateTimeUtils.getDatePlaceholder(locale);
|
|
204
|
+
const staticDateValue = rawValue ? parseCalendarDate(rawValue) : null;
|
|
205
|
+
const displayValue = staticDateValue ? DateTimeUtils.formatCalendarDateLocalized(staticDateValue, locale) : "";
|
|
206
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
207
|
+
...props,
|
|
208
|
+
onInteract: (focus) => {
|
|
209
|
+
setShouldFocus(focus);
|
|
210
|
+
setRenderInput(true);
|
|
211
|
+
},
|
|
212
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
213
|
+
as,
|
|
214
|
+
size,
|
|
215
|
+
variant,
|
|
216
|
+
hideLabel,
|
|
217
|
+
isHeaderHidden,
|
|
218
|
+
isDisabled,
|
|
219
|
+
placeholder: staticPlaceholder,
|
|
220
|
+
displayValue,
|
|
221
|
+
isEmpty: !displayValue,
|
|
222
|
+
leadingVisual: todayIcon ? /* @__PURE__ */ jsx(TodayIcon, { className: "size-6 text-interactive-text-secondary-idle" }) : void 0,
|
|
223
|
+
trailingVisual: showDropdown ? /* @__PURE__ */ jsx(CalendarIcon, { className: "size-6 text-interactive-text-secondary-idle" }) : void 0
|
|
224
|
+
});
|
|
225
|
+
}
|
|
169
226
|
if ("formControl" in props && props.formControl) {
|
|
170
227
|
const { formControl, ref, ...innerProps } = props;
|
|
171
228
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -174,7 +231,7 @@ const DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
174
231
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerBase, {
|
|
175
232
|
...innerProps,
|
|
176
233
|
...dateLimits,
|
|
177
|
-
ref: mergeRefs(ref, field.ref),
|
|
234
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
178
235
|
value: parseCalendarDate(field.value),
|
|
179
236
|
onChange: (value) => field.onChange(formatCalendarDate(value)),
|
|
180
237
|
onBlur: field.onBlur,
|
|
@@ -187,8 +244,10 @@ const DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
187
244
|
return /* @__PURE__ */ jsx(DatePickerBase, {
|
|
188
245
|
...props,
|
|
189
246
|
...dateLimits,
|
|
247
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
190
248
|
value: parseCalendarDate(props.value),
|
|
191
249
|
onChange: (value) => props.onChange?.(formatCalendarDate(value))
|
|
192
250
|
});
|
|
193
251
|
};
|
|
252
|
+
//#endregion
|
|
194
253
|
export { DatePicker };
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
+
import { CalendarIcon } from "../../../../assets/icons/Calendar.js";
|
|
1
2
|
import { Typography } from "../../../text/Typography/Typography.js";
|
|
2
3
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
-
import
|
|
4
|
+
import "../../../../config/i18n.js";
|
|
5
|
+
import { TodayIcon } from "../../../../assets/icons/Today.js";
|
|
4
6
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
5
7
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
6
8
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
7
9
|
import { FormField } from "../../FormField/FormField.js";
|
|
10
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
8
11
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
9
12
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
10
13
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
11
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
15
|
import { clsx } from "clsx";
|
|
13
|
-
import { useCallback, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
16
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
14
17
|
import { Button } from "react-aria-components";
|
|
15
18
|
import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
|
|
16
19
|
import { mergeRefs } from "@react-aria/utils";
|
|
17
20
|
import { useTranslation } from "react-i18next";
|
|
18
|
-
import { Controller } from "react-hook-form";
|
|
21
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
19
22
|
import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
|
|
20
23
|
import { DateTime } from "luxon";
|
|
21
24
|
import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
25
|
+
//#region src/components/inputs/DateTime/DateRangePicker/DateRangePicker.tsx
|
|
22
26
|
var DateRangePickerBase = (props) => {
|
|
23
27
|
const ui = UIConfig.useConfig();
|
|
24
28
|
const { t } = useTranslation();
|
|
@@ -324,12 +328,12 @@ var DateRangePickerBase = (props) => {
|
|
|
324
328
|
state.toggle();
|
|
325
329
|
};
|
|
326
330
|
const onTodayPress = () => {
|
|
327
|
-
const todayDate
|
|
328
|
-
leftCalendarState.setFocusedDate(todayDate
|
|
329
|
-
rightCalendarState.setFocusedDate(todayDate
|
|
331
|
+
const todayDate = today(getLocalTimeZone());
|
|
332
|
+
leftCalendarState.setFocusedDate(todayDate);
|
|
333
|
+
rightCalendarState.setFocusedDate(todayDate.add({ months: 1 }));
|
|
330
334
|
syncCalendarStates({
|
|
331
|
-
start: todayDate
|
|
332
|
-
end: todayDate
|
|
335
|
+
start: todayDate,
|
|
336
|
+
end: todayDate
|
|
333
337
|
});
|
|
334
338
|
};
|
|
335
339
|
const onOpenChange = (isOpen) => {
|
|
@@ -528,7 +532,19 @@ var DateRangePickerBase = (props) => {
|
|
|
528
532
|
})
|
|
529
533
|
});
|
|
530
534
|
};
|
|
531
|
-
|
|
535
|
+
var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
536
|
+
const ui = UIConfig.useConfig();
|
|
537
|
+
const { locale } = useLocale$1();
|
|
538
|
+
const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
|
|
539
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
540
|
+
const inputRef = useRef(null);
|
|
541
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
542
|
+
control: props.formControl.control,
|
|
543
|
+
name: props.formControl.name
|
|
544
|
+
}) : props.value;
|
|
545
|
+
let isFormControlDisabled = false;
|
|
546
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
547
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
532
548
|
const formatDateRange = (range) => {
|
|
533
549
|
if (!range?.start || !range?.end) return null;
|
|
534
550
|
if (fullIso) return {
|
|
@@ -567,6 +583,76 @@ const DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
567
583
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
568
584
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
569
585
|
};
|
|
586
|
+
useEffect(() => {
|
|
587
|
+
if (!renderInput || !shouldFocus) return;
|
|
588
|
+
requestAnimationFrame(() => {
|
|
589
|
+
((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
|
|
590
|
+
});
|
|
591
|
+
setShouldFocus(false);
|
|
592
|
+
}, [renderInput, shouldFocus]);
|
|
593
|
+
if (!renderInput) {
|
|
594
|
+
const as = props.as ?? ui.input.as;
|
|
595
|
+
const size = props.size ?? ui.input.size;
|
|
596
|
+
const variant = props.variant ?? ui.input.variant;
|
|
597
|
+
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
598
|
+
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
599
|
+
let isDisabled = !!props.isDisabled;
|
|
600
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
601
|
+
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
602
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
603
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
604
|
+
const defaultDatePlaceholder = DateTimeUtils.getDatePlaceholder(locale);
|
|
605
|
+
const staticPlaceholder = props.placeholder ?? /* @__PURE__ */ jsxs("span", {
|
|
606
|
+
className: "inline-flex items-center gap-input-gap-input-text-to-elements",
|
|
607
|
+
children: [
|
|
608
|
+
/* @__PURE__ */ jsx("span", { children: defaultDatePlaceholder }),
|
|
609
|
+
/* @__PURE__ */ jsx("span", {
|
|
610
|
+
className: "pointer-events-none select-none",
|
|
611
|
+
children: "–"
|
|
612
|
+
}),
|
|
613
|
+
/* @__PURE__ */ jsx("span", { children: defaultDatePlaceholder })
|
|
614
|
+
]
|
|
615
|
+
});
|
|
616
|
+
const formatStaticDate = (value) => {
|
|
617
|
+
if (!value) return "";
|
|
618
|
+
const parsedDate = parseCalendarDate(value);
|
|
619
|
+
if (!parsedDate) return "";
|
|
620
|
+
return DateTimeUtils.formatCalendarDateLocalized(parsedDate, locale);
|
|
621
|
+
};
|
|
622
|
+
const start = formatStaticDate(rawValue?.start ?? null);
|
|
623
|
+
const end = formatStaticDate(rawValue?.end ?? null);
|
|
624
|
+
const hasRangeValue = !!(start && end);
|
|
625
|
+
const displayValue = hasRangeValue ? /* @__PURE__ */ jsxs("span", {
|
|
626
|
+
className: "inline-flex items-center gap-input-gap-input-text-to-elements",
|
|
627
|
+
children: [
|
|
628
|
+
/* @__PURE__ */ jsx("span", { children: start }),
|
|
629
|
+
/* @__PURE__ */ jsx("span", {
|
|
630
|
+
className: "pointer-events-none select-none",
|
|
631
|
+
children: "–"
|
|
632
|
+
}),
|
|
633
|
+
/* @__PURE__ */ jsx("span", { children: end })
|
|
634
|
+
]
|
|
635
|
+
}) : void 0;
|
|
636
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
637
|
+
...props,
|
|
638
|
+
onInteract: (focus) => {
|
|
639
|
+
setShouldFocus(focus);
|
|
640
|
+
setRenderInput(true);
|
|
641
|
+
},
|
|
642
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
643
|
+
as,
|
|
644
|
+
size,
|
|
645
|
+
variant,
|
|
646
|
+
hideLabel,
|
|
647
|
+
isHeaderHidden,
|
|
648
|
+
isDisabled,
|
|
649
|
+
placeholder: staticPlaceholder,
|
|
650
|
+
displayValue,
|
|
651
|
+
isEmpty: !hasRangeValue,
|
|
652
|
+
leadingVisual: todayIcon ? /* @__PURE__ */ jsx(TodayIcon, { className: "size-6 text-interactive-text-secondary-idle" }) : void 0,
|
|
653
|
+
trailingVisual: showDropdown ? /* @__PURE__ */ jsx(CalendarIcon, { className: "size-6 text-interactive-text-secondary-idle" }) : void 0
|
|
654
|
+
});
|
|
655
|
+
}
|
|
570
656
|
if ("formControl" in props && props.formControl) {
|
|
571
657
|
const { formControl, ref, ...innerProps } = props;
|
|
572
658
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -575,7 +661,7 @@ const DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
575
661
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
576
662
|
...innerProps,
|
|
577
663
|
...dateLimits,
|
|
578
|
-
ref: mergeRefs(ref, field.ref),
|
|
664
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
579
665
|
value: parseDateRange(field.value),
|
|
580
666
|
onChange: (value) => field.onChange(formatDateRange(value)),
|
|
581
667
|
onBlur: field.onBlur,
|
|
@@ -588,8 +674,10 @@ const DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
588
674
|
return /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
589
675
|
...props,
|
|
590
676
|
...dateLimits,
|
|
677
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
591
678
|
value: parseDateRange(props.value),
|
|
592
679
|
onChange: (value) => props.onChange?.(formatDateRange(value))
|
|
593
680
|
});
|
|
594
681
|
};
|
|
682
|
+
//#endregion
|
|
595
683
|
export { DateRangePicker };
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
import { DateTimeIcon } from "../../../../assets/icons/DateTime.js";
|
|
1
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { TodayIcon } from "../../../../assets/icons/Today.js";
|
|
2
4
|
import { Calendar } from "../shared/Calendar.js";
|
|
3
5
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
4
6
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
5
7
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
6
8
|
import { FormField } from "../../FormField/FormField.js";
|
|
9
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
7
10
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
8
11
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
9
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { useEffect, useImperativeHandle, useMemo, useRef } from "react";
|
|
13
|
+
import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
11
14
|
import { useDatePicker, useLocale } from "react-aria";
|
|
12
15
|
import { mergeRefs } from "@react-aria/utils";
|
|
13
|
-
import { Controller } from "react-hook-form";
|
|
16
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
14
17
|
import { Time, createCalendar, getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
|
|
15
18
|
import { useCalendarState, useDatePickerState } from "react-stately";
|
|
19
|
+
//#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
|
|
16
20
|
var DateTimePickerBase = (props) => {
|
|
17
21
|
const ui = UIConfig.useConfig();
|
|
18
22
|
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, isTimeOptional, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
@@ -172,7 +176,19 @@ var DateTimePickerBase = (props) => {
|
|
|
172
176
|
})
|
|
173
177
|
});
|
|
174
178
|
};
|
|
175
|
-
|
|
179
|
+
var DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
180
|
+
const ui = UIConfig.useConfig();
|
|
181
|
+
const { locale } = useLocale();
|
|
182
|
+
const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
|
|
183
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
184
|
+
const inputRef = useRef(null);
|
|
185
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
186
|
+
control: props.formControl.control,
|
|
187
|
+
name: props.formControl.name
|
|
188
|
+
}) : props.value;
|
|
189
|
+
let isFormControlDisabled = false;
|
|
190
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
191
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
176
192
|
const formatDateValue = (dateValue) => {
|
|
177
193
|
if (dateValue === null) return null;
|
|
178
194
|
if (fullIso) return DateTimeUtils.fromCalendarDateTimeToUTCISO(dateValue);
|
|
@@ -182,6 +198,47 @@ const DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
|
182
198
|
if (isoString == null) return isoString;
|
|
183
199
|
return DateTimeUtils.fromUTCISOToCalendarDateTime(isoString);
|
|
184
200
|
};
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
if (!renderInput || !shouldFocus) return;
|
|
203
|
+
requestAnimationFrame(() => {
|
|
204
|
+
((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
|
|
205
|
+
});
|
|
206
|
+
setShouldFocus(false);
|
|
207
|
+
}, [renderInput, shouldFocus]);
|
|
208
|
+
if (!renderInput) {
|
|
209
|
+
const as = props.as ?? ui.input.as;
|
|
210
|
+
const size = props.size ?? ui.input.size;
|
|
211
|
+
const variant = props.variant ?? ui.input.variant;
|
|
212
|
+
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
213
|
+
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
214
|
+
let isDisabled = !!props.isDisabled;
|
|
215
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
216
|
+
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
217
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
218
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
219
|
+
const staticPlaceholder = props.placeholder ?? DateTimeUtils.getDateTimePlaceholder(locale);
|
|
220
|
+
const staticDateTimeValue = rawValue ? parseDateValue(rawValue) : null;
|
|
221
|
+
const displayValue = staticDateTimeValue && "hour" in staticDateTimeValue ? DateTimeUtils.formatCalendarDateTimeLocalized(staticDateTimeValue, locale) : "";
|
|
222
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
223
|
+
...props,
|
|
224
|
+
onInteract: (focus) => {
|
|
225
|
+
setShouldFocus(focus);
|
|
226
|
+
setRenderInput(true);
|
|
227
|
+
},
|
|
228
|
+
className: props.className ? `relative inline-flex w-full flex-col text-left ${props.className}` : "relative inline-flex w-full flex-col text-left",
|
|
229
|
+
as,
|
|
230
|
+
size,
|
|
231
|
+
variant,
|
|
232
|
+
hideLabel,
|
|
233
|
+
isHeaderHidden,
|
|
234
|
+
isDisabled,
|
|
235
|
+
placeholder: staticPlaceholder,
|
|
236
|
+
displayValue,
|
|
237
|
+
isEmpty: !displayValue,
|
|
238
|
+
leadingVisual: todayIcon ? /* @__PURE__ */ jsx(TodayIcon, { className: "size-6 text-interactive-text-secondary-idle" }) : void 0,
|
|
239
|
+
trailingVisual: showDropdown ? /* @__PURE__ */ jsx(DateTimeIcon, { className: "size-6 text-interactive-text-secondary-idle" }) : void 0
|
|
240
|
+
});
|
|
241
|
+
}
|
|
185
242
|
if ("formControl" in props && props.formControl) {
|
|
186
243
|
const { formControl, ref, ...innerProps } = props;
|
|
187
244
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -189,7 +246,7 @@ const DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
|
189
246
|
name: formControl.name,
|
|
190
247
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateTimePickerBase, {
|
|
191
248
|
...innerProps,
|
|
192
|
-
ref: mergeRefs(ref, field.ref),
|
|
249
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
193
250
|
value: parseDateValue(field.value),
|
|
194
251
|
onChange: (value) => field.onChange(formatDateValue(value)),
|
|
195
252
|
onBlur: field.onBlur,
|
|
@@ -201,8 +258,10 @@ const DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
|
201
258
|
}
|
|
202
259
|
return /* @__PURE__ */ jsx(DateTimePickerBase, {
|
|
203
260
|
...props,
|
|
261
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
204
262
|
value: parseDateValue(props.value),
|
|
205
263
|
onChange: (value) => props.onChange?.(formatDateValue(value))
|
|
206
264
|
});
|
|
207
265
|
};
|
|
266
|
+
//#endregion
|
|
208
267
|
export { DateTimePicker };
|
|
@@ -12,6 +12,7 @@ interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Ar
|
|
|
12
12
|
isDirty?: boolean;
|
|
13
13
|
disableManualEntry?: boolean;
|
|
14
14
|
placeholder?: string;
|
|
15
|
+
inputClassName?: string;
|
|
15
16
|
}
|
|
16
17
|
export interface TimePickerProps extends Omit<TimePickerBaseProps, "value" | "onChange"> {
|
|
17
18
|
value?: string | null;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
+
import { ClockIcon } from "../../../../assets/icons/Clock.js";
|
|
1
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
3
|
import { TimePickerForm } from "../shared/TimePickerForm.js";
|
|
3
4
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
4
5
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
5
6
|
import { FormField } from "../../FormField/FormField.js";
|
|
7
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
6
8
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
7
9
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
8
10
|
import { TimePickerInput } from "../shared/TimePickerInput.js";
|
|
9
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { clsx } from "clsx";
|
|
10
13
|
import { useEffect, useRef, useState } from "react";
|
|
11
14
|
import { useLocale, useTimeField } from "react-aria";
|
|
12
15
|
import { mergeRefs } from "@react-aria/utils";
|
|
13
|
-
import { Controller } from "react-hook-form";
|
|
16
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
14
17
|
import { getLocalTimeZone, now, toTime } from "@internationalized/date";
|
|
15
18
|
import { DateTime } from "luxon";
|
|
16
19
|
import { useTimeFieldState } from "react-stately";
|
|
20
|
+
//#region src/components/inputs/DateTime/TimePicker/TimePicker.tsx
|
|
17
21
|
var TimePickerBase = (props) => {
|
|
18
22
|
const ui = UIConfig.useConfig();
|
|
19
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, placeholder, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
23
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, placeholder, className, inputClassName, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
20
24
|
const formFieldProps = {
|
|
21
25
|
error,
|
|
22
26
|
label,
|
|
@@ -89,7 +93,7 @@ var TimePickerBase = (props) => {
|
|
|
89
93
|
...formFieldProps,
|
|
90
94
|
as,
|
|
91
95
|
labelProps,
|
|
92
|
-
className: "relative inline-flex w-full flex-col text-left",
|
|
96
|
+
className: clsx("relative inline-flex w-full flex-col text-left", className),
|
|
93
97
|
tabIndex: as === "inline" ? -1 : void 0,
|
|
94
98
|
children: [/* @__PURE__ */ jsx(TimePickerInput, {
|
|
95
99
|
ref: mergeRefs(ref, timeFieldRef),
|
|
@@ -106,7 +110,8 @@ var TimePickerBase = (props) => {
|
|
|
106
110
|
isClearable,
|
|
107
111
|
headerProps,
|
|
108
112
|
disableManualEntry,
|
|
109
|
-
placeholder
|
|
113
|
+
placeholder,
|
|
114
|
+
className: inputClassName
|
|
110
115
|
}), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
111
116
|
footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
|
|
112
117
|
isDisabled,
|
|
@@ -122,7 +127,19 @@ var TimePickerBase = (props) => {
|
|
|
122
127
|
})
|
|
123
128
|
});
|
|
124
129
|
};
|
|
125
|
-
|
|
130
|
+
var TimePicker = (props) => {
|
|
131
|
+
const ui = UIConfig.useConfig();
|
|
132
|
+
const { locale } = useLocale();
|
|
133
|
+
const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
|
|
134
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
135
|
+
const inputRef = useRef(null);
|
|
136
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
137
|
+
control: props.formControl.control,
|
|
138
|
+
name: props.formControl.name
|
|
139
|
+
}) : props.value;
|
|
140
|
+
let isFormControlDisabled = false;
|
|
141
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
142
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
126
143
|
const formatTimeValue = (timeValue) => {
|
|
127
144
|
if (timeValue === null) return null;
|
|
128
145
|
const parsedDate = props.date ? DateTime.fromISO(props.date).toJSDate() : void 0;
|
|
@@ -133,6 +150,45 @@ const TimePicker = (props) => {
|
|
|
133
150
|
if (isoString == null) return isoString;
|
|
134
151
|
return toTime(DateTimeUtils.fromISOtoZonedDateTime(isoString));
|
|
135
152
|
};
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
if (!renderInput || !shouldFocus) return;
|
|
155
|
+
requestAnimationFrame(() => {
|
|
156
|
+
(inputRef.current?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
|
|
157
|
+
});
|
|
158
|
+
setShouldFocus(false);
|
|
159
|
+
}, [renderInput, shouldFocus]);
|
|
160
|
+
if (!renderInput) {
|
|
161
|
+
const as = props.as ?? ui.input.as;
|
|
162
|
+
const size = props.size ?? ui.input.size;
|
|
163
|
+
const variant = props.variant ?? ui.input.variant;
|
|
164
|
+
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
165
|
+
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
166
|
+
let isDisabled = !!props.isDisabled;
|
|
167
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
168
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
169
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
170
|
+
const staticPlaceholder = props.placeholder ?? DateTimeUtils.getTimePlaceholder(locale);
|
|
171
|
+
const staticTimeValue = rawValue ? parseTimeValue(rawValue) : null;
|
|
172
|
+
const displayValue = staticTimeValue ? DateTimeUtils.formatTimeLocalized(staticTimeValue, locale) : "";
|
|
173
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
174
|
+
...props,
|
|
175
|
+
onInteract: (focus) => {
|
|
176
|
+
setShouldFocus(focus);
|
|
177
|
+
setRenderInput(true);
|
|
178
|
+
},
|
|
179
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
180
|
+
as,
|
|
181
|
+
size,
|
|
182
|
+
variant,
|
|
183
|
+
hideLabel,
|
|
184
|
+
isHeaderHidden,
|
|
185
|
+
isDisabled,
|
|
186
|
+
placeholder: staticPlaceholder,
|
|
187
|
+
displayValue,
|
|
188
|
+
isEmpty: !displayValue,
|
|
189
|
+
trailingVisual: showDropdown ? /* @__PURE__ */ jsx(ClockIcon, { className: "size-6 text-interactive-text-secondary-idle" }) : void 0
|
|
190
|
+
});
|
|
191
|
+
}
|
|
136
192
|
if ("formControl" in props && props.formControl) {
|
|
137
193
|
const { formControl, ref, ...innerProps } = props;
|
|
138
194
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -140,7 +196,7 @@ const TimePicker = (props) => {
|
|
|
140
196
|
name: formControl.name,
|
|
141
197
|
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(TimePickerBase, {
|
|
142
198
|
...innerProps,
|
|
143
|
-
ref: mergeRefs(ref, field.ref),
|
|
199
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
144
200
|
value: parseTimeValue(field.value),
|
|
145
201
|
onChange: (value) => field.onChange(formatTimeValue(value)),
|
|
146
202
|
onBlur: field.onBlur,
|
|
@@ -151,8 +207,10 @@ const TimePicker = (props) => {
|
|
|
151
207
|
}
|
|
152
208
|
return /* @__PURE__ */ jsx(TimePickerBase, {
|
|
153
209
|
...props,
|
|
210
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
154
211
|
value: parseTimeValue(props.value),
|
|
155
212
|
onChange: (value) => props.onChange?.(formatTimeValue(value))
|
|
156
213
|
});
|
|
157
214
|
};
|
|
215
|
+
//#endregion
|
|
158
216
|
export { TimePicker };
|
|
@@ -7,7 +7,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { useState } from "react";
|
|
9
9
|
import { useCalendar } from "@react-aria/calendar";
|
|
10
|
-
|
|
10
|
+
//#region src/components/inputs/DateTime/shared/Calendar.tsx
|
|
11
|
+
var Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply, ...props }) => {
|
|
11
12
|
const [toggleState, setToggleState] = useState(null);
|
|
12
13
|
const { calendarProps, prevButtonProps, nextButtonProps } = useCalendar(props.calendarProps, props.state);
|
|
13
14
|
const handleDateChange = () => {
|
|
@@ -51,4 +52,5 @@ const Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply
|
|
|
51
52
|
})]
|
|
52
53
|
});
|
|
53
54
|
};
|
|
55
|
+
//#endregion
|
|
54
56
|
export { Calendar };
|
|
@@ -6,10 +6,11 @@ import { mergeProps } from "@react-aria/utils";
|
|
|
6
6
|
import { isSameDay } from "@internationalized/date";
|
|
7
7
|
import { useCalendarCell } from "@react-aria/calendar";
|
|
8
8
|
import { useFocusRing } from "@react-aria/focus";
|
|
9
|
+
//#region src/components/inputs/DateTime/shared/CalendarCell.tsx
|
|
9
10
|
var isRange = (state) => {
|
|
10
11
|
return "highlightedRange" in state;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
+
var CalendarCell = ({ state, onApply, shouldCloseOnSelect = true, onDateSelection, onDateHover, rangeSelection, hoverDate, onKeyboardNavigation, ...props }) => {
|
|
13
14
|
const ref = useRef(null);
|
|
14
15
|
const { cellProps, buttonProps, formattedDate, isSelected, isDisabled, isOutsideVisibleRange } = useCalendarCell(props, state, ref);
|
|
15
16
|
const { focusProps } = useFocusRing();
|
|
@@ -127,4 +128,5 @@ const CalendarCell = ({ state, onApply, shouldCloseOnSelect = true, onDateSelect
|
|
|
127
128
|
})
|
|
128
129
|
});
|
|
129
130
|
};
|
|
131
|
+
//#endregion
|
|
130
132
|
export { CalendarCell };
|
|
@@ -3,6 +3,7 @@ import { CalendarCell } from "./CalendarCell.js";
|
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { clsx } from "clsx";
|
|
5
5
|
import { useCalendarGrid } from "@react-aria/calendar";
|
|
6
|
+
//#region src/components/inputs/DateTime/shared/CalendarGrid.tsx
|
|
6
7
|
var WEEK_INDICES = [
|
|
7
8
|
0,
|
|
8
9
|
1,
|
|
@@ -11,7 +12,7 @@ var WEEK_INDICES = [
|
|
|
11
12
|
4,
|
|
12
13
|
5
|
|
13
14
|
];
|
|
14
|
-
|
|
15
|
+
var CalendarGrid = ({ state, onApply, shouldCloseOnSelect, offset = {}, onDateSelection, onDateHover, rangeSelection, hoverDate, onKeyboardNavigation, className, calendarSide, ...props }) => {
|
|
15
16
|
const { gridProps, headerProps, weekDays } = useCalendarGrid({
|
|
16
17
|
...props,
|
|
17
18
|
weekdayStyle: "short"
|
|
@@ -47,4 +48,5 @@ const CalendarGrid = ({ state, onApply, shouldCloseOnSelect, offset = {}, onDate
|
|
|
47
48
|
})
|
|
48
49
|
});
|
|
49
50
|
};
|
|
51
|
+
//#endregion
|
|
50
52
|
export { CalendarGrid };
|
|
@@ -8,11 +8,12 @@ import { clsx } from "clsx";
|
|
|
8
8
|
import { Button, ToggleButtonGroup } from "react-aria-components";
|
|
9
9
|
import { Time } from "@internationalized/date";
|
|
10
10
|
import { useDateFormatter } from "@react-aria/i18n";
|
|
11
|
+
//#region src/components/inputs/DateTime/shared/CalendarHeader.tsx
|
|
11
12
|
var HourCycle = {
|
|
12
13
|
12: "h12",
|
|
13
14
|
24: "h23"
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
var CalendarHeader = ({ calendarState, datePickerState, prevButtonProps, nextButtonProps, includesTime, hourCycle, toggleState, setToggleState }) => {
|
|
16
17
|
const formatter = useDateFormatter({
|
|
17
18
|
month: "long",
|
|
18
19
|
timeZone: calendarState.timeZone
|
|
@@ -86,4 +87,5 @@ const CalendarHeader = ({ calendarState, datePickerState, prevButtonProps, nextB
|
|
|
86
87
|
]
|
|
87
88
|
});
|
|
88
89
|
};
|
|
90
|
+
//#endregion
|
|
89
91
|
export { CalendarHeader };
|
|
@@ -5,13 +5,14 @@ import { ChevronsLeftIcon } from "../../../../assets/icons/ChevronsLeft.js";
|
|
|
5
5
|
import { ChevronsRightIcon } from "../../../../assets/icons/ChevronsRight.js";
|
|
6
6
|
import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
|
|
7
7
|
import { PillButton } from "../../../buttons/PillButton/PillButton.js";
|
|
8
|
-
import
|
|
8
|
+
import "../../../../config/i18n.js";
|
|
9
9
|
import { Select } from "../../Selection/Select/Select.js";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { useMemo } from "react";
|
|
12
12
|
import { useTranslation } from "react-i18next";
|
|
13
13
|
import { useDateFormatter } from "@react-aria/i18n";
|
|
14
|
-
|
|
14
|
+
//#region src/components/inputs/DateTime/shared/CalendarSelectHeader.tsx
|
|
15
|
+
var CalendarSelectHeader = ({ state, isPrevMonthDisabled, isPrevYearDisabled, isNextMonthDisabled, isNextYearDisabled, offset = { months: 0 }, onNavigate, maxDate, minDate }) => {
|
|
15
16
|
const { t } = useTranslation("ui");
|
|
16
17
|
const displayDate = state.visibleRange.start.add(offset);
|
|
17
18
|
const currentMonth = displayDate.month - 1;
|
|
@@ -172,4 +173,5 @@ const CalendarSelectHeader = ({ state, isPrevMonthDisabled, isPrevYearDisabled,
|
|
|
172
173
|
]
|
|
173
174
|
});
|
|
174
175
|
};
|
|
176
|
+
//#endregion
|
|
175
177
|
export { CalendarSelectHeader };
|
|
@@ -5,7 +5,8 @@ import { useEffect, useImperativeHandle, useRef } from "react";
|
|
|
5
5
|
import { useDateField, useLocale } from "react-aria";
|
|
6
6
|
import { createCalendar } from "@internationalized/date";
|
|
7
7
|
import { useDateFieldState } from "react-stately";
|
|
8
|
-
|
|
8
|
+
//#region src/components/inputs/DateTime/shared/DateField.tsx
|
|
9
|
+
var DateField = ({ ref, onClearChange, hidePlaceholder, isDisabled, disableManualEntry, ...props }) => {
|
|
9
10
|
const { locale } = useLocale();
|
|
10
11
|
const state = useDateFieldState({
|
|
11
12
|
...props,
|
|
@@ -86,4 +87,5 @@ const DateField = ({ ref, onClearChange, hidePlaceholder, isDisabled, disableMan
|
|
|
86
87
|
})
|
|
87
88
|
});
|
|
88
89
|
};
|
|
90
|
+
//#endregion
|
|
89
91
|
export { DateField };
|