@povio/ui 2.2.5 → 2.2.7
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/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 +15 -0
- 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 +4 -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 +4 -2
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +3 -1
- package/dist/components/inputs/Checkbox/checkbox.cva.js +7 -4
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +3 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +10 -8
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +3 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +3 -1
- 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 +5 -3
- 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 +6 -14
- 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.js +3 -1
- package/dist/components/inputs/DateTime/shared/YearPicker.js +3 -1
- package/dist/components/inputs/File/FileUpload.d.ts +1 -1
- package/dist/components/inputs/File/FileUpload.js +21 -7
- package/dist/components/inputs/File/FileUploadContainer.js +3 -1
- package/dist/components/inputs/File/InputUpload.js +3 -1
- package/dist/components/inputs/File/fileUpload.types.d.ts +11 -1
- package/dist/components/inputs/File/shared/FileCard.js +3 -1
- package/dist/components/inputs/File/shared/FileCardList.js +4 -2
- 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 +5 -3
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +6 -4
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +6 -4
- 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 +11 -1
- package/dist/components/inputs/FormField/FormFieldError.js +5 -3
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +4 -2
- package/dist/components/inputs/FormField/FormFieldHelper.d.ts +8 -0
- package/dist/components/inputs/FormField/FormFieldHelper.js +14 -0
- package/dist/components/inputs/FormField/FormFieldLabel.js +4 -1
- package/dist/components/inputs/FormField/formFieldError.cva.d.ts +6 -0
- package/dist/components/inputs/FormField/formFieldError.cva.js +11 -0
- package/dist/components/inputs/FormField/formFieldHelper.cva.d.ts +6 -0
- package/dist/components/inputs/FormField/formFieldHelper.cva.js +11 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +3 -1
- 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.js +3 -1
- package/dist/components/inputs/Input/shared/InputContent.js +4 -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 +6 -4
- package/dist/components/inputs/RadioGroup/radio.cva.js +6 -3
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +3 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +3 -1
- package/dist/components/inputs/Selection/Select/Select.js +3 -1
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +1 -0
- package/dist/components/inputs/Selection/shared/SelectBase.js +5 -2
- 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 +19 -13
- 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 +5 -2
- package/dist/components/inputs/shared/CheckContent.js +4 -1
- package/dist/components/inputs/shared/InputClear.js +5 -3
- 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 +9 -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.d.ts +5 -0
- package/dist/components/overlays/BottomSheet/BottomSheet.js +23 -7
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.d.ts +13 -0
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +38 -0
- 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 +7 -10
- 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.d.ts +2 -1
- package/dist/components/table/CellText.js +18 -10
- package/dist/components/table/ColumnConfig.js +3 -1
- package/dist/components/table/HeaderText.d.ts +5 -2
- package/dist/components/table/HeaderText.js +17 -7
- package/dist/components/table/InfiniteTable.js +3 -1
- package/dist/components/table/PaginatedTable.js +3 -1
- package/dist/components/table/Table.js +5 -3
- package/dist/components/table/table.cva.d.ts +6 -0
- package/dist/components/table/table.cva.js +9 -5
- 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 +10 -2
- package/dist/config/uiConfig.context.js +25 -4
- package/dist/config/uiStyle.context.d.ts +9 -1
- 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/index.js +1 -1
- 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.js +3 -1
- package/dist/utils/date.utils.js +3 -1
- package/dist/utils/dom.utils.js +3 -1
- package/dist/utils/file.utils.d.ts +4 -0
- package/dist/utils/file.utils.js +10 -3
- 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,6 +1,6 @@
|
|
|
1
1
|
import { Typography } from "../../../text/Typography/Typography.js";
|
|
2
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
-
import
|
|
3
|
+
import "../../../../config/i18n.js";
|
|
4
4
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
5
5
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
6
6
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
@@ -14,11 +14,12 @@ import { useCallback, useImperativeHandle, useMemo, useRef, useState } from "rea
|
|
|
14
14
|
import { Button } from "react-aria-components";
|
|
15
15
|
import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
|
|
16
16
|
import { mergeRefs } from "@react-aria/utils";
|
|
17
|
+
import { useTranslation } from "react-i18next";
|
|
17
18
|
import { Controller } from "react-hook-form";
|
|
18
19
|
import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
|
|
19
20
|
import { DateTime } from "luxon";
|
|
20
21
|
import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
21
|
-
|
|
22
|
+
//#region src/components/inputs/DateTime/DateRangePicker/DateRangePicker.tsx
|
|
22
23
|
var DateRangePickerBase = (props) => {
|
|
23
24
|
const ui = UIConfig.useConfig();
|
|
24
25
|
const { t } = useTranslation();
|
|
@@ -324,12 +325,12 @@ var DateRangePickerBase = (props) => {
|
|
|
324
325
|
state.toggle();
|
|
325
326
|
};
|
|
326
327
|
const onTodayPress = () => {
|
|
327
|
-
const todayDate
|
|
328
|
-
leftCalendarState.setFocusedDate(todayDate
|
|
329
|
-
rightCalendarState.setFocusedDate(todayDate
|
|
328
|
+
const todayDate = today(getLocalTimeZone());
|
|
329
|
+
leftCalendarState.setFocusedDate(todayDate);
|
|
330
|
+
rightCalendarState.setFocusedDate(todayDate.add({ months: 1 }));
|
|
330
331
|
syncCalendarStates({
|
|
331
|
-
start: todayDate
|
|
332
|
-
end: todayDate
|
|
332
|
+
start: todayDate,
|
|
333
|
+
end: todayDate
|
|
333
334
|
});
|
|
334
335
|
};
|
|
335
336
|
const onOpenChange = (isOpen) => {
|
|
@@ -528,7 +529,7 @@ var DateRangePickerBase = (props) => {
|
|
|
528
529
|
})
|
|
529
530
|
});
|
|
530
531
|
};
|
|
531
|
-
|
|
532
|
+
var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
532
533
|
const formatDateRange = (range) => {
|
|
533
534
|
if (!range?.start || !range?.end) return null;
|
|
534
535
|
if (fullIso) return {
|
|
@@ -592,4 +593,5 @@ const DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
592
593
|
onChange: (value) => props.onChange?.(formatDateRange(value))
|
|
593
594
|
});
|
|
594
595
|
};
|
|
596
|
+
//#endregion
|
|
595
597
|
export { DateRangePicker };
|
|
@@ -13,6 +13,7 @@ import { mergeRefs } from "@react-aria/utils";
|
|
|
13
13
|
import { Controller } from "react-hook-form";
|
|
14
14
|
import { Time, createCalendar, getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
|
|
15
15
|
import { useCalendarState, useDatePickerState } from "react-stately";
|
|
16
|
+
//#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
|
|
16
17
|
var DateTimePickerBase = (props) => {
|
|
17
18
|
const ui = UIConfig.useConfig();
|
|
18
19
|
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 +173,7 @@ var DateTimePickerBase = (props) => {
|
|
|
172
173
|
})
|
|
173
174
|
});
|
|
174
175
|
};
|
|
175
|
-
|
|
176
|
+
var DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
176
177
|
const formatDateValue = (dateValue) => {
|
|
177
178
|
if (dateValue === null) return null;
|
|
178
179
|
if (fullIso) return DateTimeUtils.fromCalendarDateTimeToUTCISO(dateValue);
|
|
@@ -205,4 +206,5 @@ const DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
|
205
206
|
onChange: (value) => props.onChange?.(formatDateValue(value))
|
|
206
207
|
});
|
|
207
208
|
};
|
|
209
|
+
//#endregion
|
|
208
210
|
export { DateTimePicker };
|
|
@@ -14,6 +14,7 @@ import { Controller } from "react-hook-form";
|
|
|
14
14
|
import { getLocalTimeZone, now, toTime } from "@internationalized/date";
|
|
15
15
|
import { DateTime } from "luxon";
|
|
16
16
|
import { useTimeFieldState } from "react-stately";
|
|
17
|
+
//#region src/components/inputs/DateTime/TimePicker/TimePicker.tsx
|
|
17
18
|
var TimePickerBase = (props) => {
|
|
18
19
|
const ui = UIConfig.useConfig();
|
|
19
20
|
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;
|
|
@@ -122,7 +123,7 @@ var TimePickerBase = (props) => {
|
|
|
122
123
|
})
|
|
123
124
|
});
|
|
124
125
|
};
|
|
125
|
-
|
|
126
|
+
var TimePicker = (props) => {
|
|
126
127
|
const formatTimeValue = (timeValue) => {
|
|
127
128
|
if (timeValue === null) return null;
|
|
128
129
|
const parsedDate = props.date ? DateTime.fromISO(props.date).toJSDate() : void 0;
|
|
@@ -155,4 +156,5 @@ const TimePicker = (props) => {
|
|
|
155
156
|
onChange: (value) => props.onChange?.(formatTimeValue(value))
|
|
156
157
|
});
|
|
157
158
|
};
|
|
159
|
+
//#endregion
|
|
158
160
|
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
|
-
import { useDateFormatter } from "@react-aria/i18n";
|
|
13
12
|
import { useTranslation } from "react-i18next";
|
|
14
|
-
|
|
13
|
+
import { useDateFormatter } from "@react-aria/i18n";
|
|
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 };
|
|
@@ -15,7 +15,8 @@ import { useCallback, useImperativeHandle, useRef, useState } from "react";
|
|
|
15
15
|
import { Button } from "react-aria-components";
|
|
16
16
|
import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
|
|
17
17
|
import { getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
|
|
18
|
-
|
|
18
|
+
//#region src/components/inputs/DateTime/shared/DatePickerInput.tsx
|
|
19
|
+
var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, isDirty, isRequired, disableManualEntry, placeholder, className, onOpenDropdown, ...props }) => {
|
|
19
20
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
20
21
|
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
21
22
|
const [canClear, setCanClear] = useState(false);
|
|
@@ -152,4 +153,5 @@ const DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, butto
|
|
|
152
153
|
})]
|
|
153
154
|
});
|
|
154
155
|
};
|
|
156
|
+
//#endregion
|
|
155
157
|
export { DatePickerInput };
|
|
@@ -2,7 +2,8 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { clsx } from "clsx";
|
|
3
3
|
import { useRef } from "react";
|
|
4
4
|
import { useDateSegment } from "react-aria";
|
|
5
|
-
|
|
5
|
+
//#region src/components/inputs/DateTime/shared/DateSegmentItem.tsx
|
|
6
|
+
var getPlaceholder = (segment) => {
|
|
6
7
|
if (!segment.isPlaceholder) return null;
|
|
7
8
|
switch (segment.type) {
|
|
8
9
|
case "hour": return "hh";
|
|
@@ -11,7 +12,7 @@ const getPlaceholder = (segment) => {
|
|
|
11
12
|
default: return segment.placeholder;
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
var DateSegmentItem = ({ segment, state, isDisabled, timePickerOnly, hidePlaceholder }) => {
|
|
15
16
|
const ref = useRef(null);
|
|
16
17
|
const { segmentProps } = useDateSegment(segment, state, ref);
|
|
17
18
|
const isInputEmpty = !state.value;
|
|
@@ -26,4 +27,5 @@ const DateSegmentItem = ({ segment, state, isDisabled, timePickerOnly, hidePlace
|
|
|
26
27
|
}), segment.isPlaceholder ? "" : segment.text] })
|
|
27
28
|
});
|
|
28
29
|
};
|
|
30
|
+
//#endregion
|
|
29
31
|
export { DateSegmentItem, getPlaceholder };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { UIStyle } from "../../../../config/uiStyle.context.js";
|
|
2
2
|
import { BottomSheet } from "../../../overlays/BottomSheet/BottomSheet.js";
|
|
3
3
|
import { useBreakpoint } from "../../../../hooks/useBreakpoint.js";
|
|
4
|
-
import { FormFieldHeader } from "../../FormField/FormFieldHeader.js";
|
|
5
|
-
import { FormFieldHeaderClose } from "../../FormField/FormFieldHeaderClose.js";
|
|
6
4
|
import { popover } from "../../../shared/popover.cva.js";
|
|
7
|
-
import {
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
6
|
import clsx$1 from "clsx";
|
|
9
7
|
import { Dialog, Popover } from "react-aria-components";
|
|
10
|
-
|
|
8
|
+
//#region src/components/inputs/DateTime/shared/DateTimeDialog.tsx
|
|
9
|
+
var DateTimeDialog = ({ hideSidebar, children, footer, sidebar, label, isOpen, triggerRef, dialogProps, onOpenChange }) => {
|
|
11
10
|
const popoverCva = UIStyle.useCva("popover.cva", popover);
|
|
12
11
|
if (useBreakpoint("md")) {
|
|
13
12
|
if (!isOpen) return null;
|
|
@@ -30,7 +29,7 @@ const DateTimeDialog = ({ hideSidebar, children, footer, sidebar, label, isOpen,
|
|
|
30
29
|
})
|
|
31
30
|
});
|
|
32
31
|
}
|
|
33
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ jsxs(BottomSheet, {
|
|
34
33
|
label,
|
|
35
34
|
footer,
|
|
36
35
|
isOpen,
|
|
@@ -39,15 +38,8 @@ const DateTimeDialog = ({ hideSidebar, children, footer, sidebar, label, isOpen,
|
|
|
39
38
|
isScrollable: true,
|
|
40
39
|
height: "auto",
|
|
41
40
|
isDismissable: true,
|
|
42
|
-
children:
|
|
43
|
-
/* @__PURE__ */ jsx(FormFieldHeader, {
|
|
44
|
-
label,
|
|
45
|
-
className: "mb-list-height-title-bottom! shrink-0 px-4 pt-3",
|
|
46
|
-
rightContent: /* @__PURE__ */ jsx(FormFieldHeaderClose, { onClose: close })
|
|
47
|
-
}),
|
|
48
|
-
children,
|
|
49
|
-
!hideSidebar && sidebar
|
|
50
|
-
] })
|
|
41
|
+
children: [children, !hideSidebar && sidebar]
|
|
51
42
|
});
|
|
52
43
|
};
|
|
44
|
+
//#endregion
|
|
53
45
|
export { DateTimeDialog };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import "../../../../config/i18n.js";
|
|
1
2
|
import { TextButton } from "../../../buttons/TextButton/TextButton.js";
|
|
2
|
-
import { ns } from "../../../../config/i18n.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { clsx } from "clsx";
|
|
5
5
|
import { useTranslation } from "react-i18next";
|
|
6
|
-
|
|
6
|
+
//#region src/components/inputs/DateTime/shared/DateTimeDialogFooter.tsx
|
|
7
|
+
var DateTimeDialogFooter = ({ isValid = true, isDisabled = false, onTodayPress, onApply }) => {
|
|
7
8
|
const { t } = useTranslation("ui");
|
|
8
9
|
return /* @__PURE__ */ jsxs("footer", {
|
|
9
10
|
className: clsx("flex shrink-0 items-center gap-2 bg-elevation-fill-default-2 px-4 py-3 md:border-elevation-outline-default-1 md:border-t md:bg-elevation-fill-default-1 md:py-1-5", onTodayPress ? "justify-between" : "justify-end"),
|
|
@@ -22,4 +23,5 @@ const DateTimeDialogFooter = ({ isValid = true, isDisabled = false, onTodayPress
|
|
|
22
23
|
})]
|
|
23
24
|
});
|
|
24
25
|
};
|
|
26
|
+
//#endregion
|
|
25
27
|
export { DateTimeDialogFooter };
|
|
@@ -3,7 +3,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { clsx } from "clsx";
|
|
4
4
|
import { ListBox, ListBoxItem } from "react-aria-components";
|
|
5
5
|
import { useDateFormatter } from "@react-aria/i18n";
|
|
6
|
-
|
|
6
|
+
//#region src/components/inputs/DateTime/shared/MonthPicker.tsx
|
|
7
|
+
var MonthPicker = ({ state, onSelectionChange }) => {
|
|
7
8
|
const formatter = useDateFormatter({
|
|
8
9
|
month: "long",
|
|
9
10
|
timeZone: state.timeZone
|
|
@@ -53,4 +54,5 @@ const MonthPicker = ({ state, onSelectionChange }) => {
|
|
|
53
54
|
})
|
|
54
55
|
});
|
|
55
56
|
};
|
|
57
|
+
//#endregion
|
|
56
58
|
export { MonthPicker };
|
|
@@ -4,7 +4,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
import { clsx } from "clsx";
|
|
5
5
|
import { useMemo, useRef } from "react";
|
|
6
6
|
import { useRangeCalendar } from "@react-aria/calendar";
|
|
7
|
-
|
|
7
|
+
//#region src/components/inputs/DateTime/shared/RangeCalendar.tsx
|
|
8
|
+
var RangeCalendar = ({ className, leftCalendarState, rightCalendarState, calendarProps, onApply, onRangeChange: _onRangeChange, onDateSelection, onDateHover, rangeSelection, hoverDate, onKeyboardNavigation }) => {
|
|
8
9
|
const leftRef = useRef(null);
|
|
9
10
|
const rightRef = useRef(null);
|
|
10
11
|
const { calendarProps: leftCalendarAriaProps } = useRangeCalendar(calendarProps, leftCalendarState, leftRef);
|
|
@@ -93,4 +94,5 @@ const RangeCalendar = ({ className, leftCalendarState, rightCalendarState, calen
|
|
|
93
94
|
})
|
|
94
95
|
});
|
|
95
96
|
};
|
|
97
|
+
//#endregion
|
|
96
98
|
export { RangeCalendar };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DateSegmentItem } from "./DateSegmentItem.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
3
|
+
//#region src/components/inputs/DateTime/shared/TimeField.tsx
|
|
4
|
+
var TimeField = ({ ref, fieldProps, state, isDisabled, hidePlaceholder }) => {
|
|
4
5
|
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", {
|
|
5
6
|
...fieldProps,
|
|
6
7
|
ref,
|
|
@@ -14,4 +15,5 @@ const TimeField = ({ ref, fieldProps, state, isDisabled, hidePlaceholder }) => {
|
|
|
14
15
|
}, i))
|
|
15
16
|
}) });
|
|
16
17
|
};
|
|
18
|
+
//#endregion
|
|
17
19
|
export { TimeField };
|
|
@@ -11,8 +11,9 @@ import { useEffect, useRef } from "react";
|
|
|
11
11
|
import { useDateSegment, useLocale, useTimeField } from "react-aria";
|
|
12
12
|
import { Time } from "@internationalized/date";
|
|
13
13
|
import { useTimeFieldState } from "@react-stately/datepicker";
|
|
14
|
+
//#region src/components/inputs/DateTime/shared/TimePickerForm.tsx
|
|
14
15
|
var INCREMENT_STEP_SIZE = 5;
|
|
15
|
-
|
|
16
|
+
var TimePickerForm = ({ state, datePickerState }) => {
|
|
16
17
|
const isDesktop = useBreakpoint("md");
|
|
17
18
|
const { locale } = useLocale();
|
|
18
19
|
const fieldState = useTimeFieldState({
|
|
@@ -155,4 +156,5 @@ var TimeSegmentButton = ({ segment, state, type }) => {
|
|
|
155
156
|
});
|
|
156
157
|
};
|
|
157
158
|
var showSegmentText = (text) => !/[\u2066\u2069]/.test(text);
|
|
159
|
+
//#endregion
|
|
158
160
|
export { TimePickerForm };
|
|
@@ -11,7 +11,8 @@ import { clsx } from "clsx";
|
|
|
11
11
|
import { useState } from "react";
|
|
12
12
|
import { Button } from "react-aria-components";
|
|
13
13
|
import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
|
|
14
|
-
|
|
14
|
+
//#region src/components/inputs/DateTime/shared/TimePickerInput.tsx
|
|
15
|
+
var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, onPress, ...props }) => {
|
|
15
16
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
16
17
|
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
17
18
|
const { hoverProps, isHovered } = useHover({ isDisabled });
|
|
@@ -85,4 +86,5 @@ const TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isIn
|
|
|
85
86
|
})]
|
|
86
87
|
});
|
|
87
88
|
};
|
|
89
|
+
//#endregion
|
|
88
90
|
export { TimePickerInput };
|
|
@@ -6,7 +6,8 @@ import { useMemo } from "react";
|
|
|
6
6
|
import { ListBox, ListBoxItem } from "react-aria-components";
|
|
7
7
|
import { today } from "@internationalized/date";
|
|
8
8
|
import { useDateFormatter } from "@react-aria/i18n";
|
|
9
|
-
|
|
9
|
+
//#region src/components/inputs/DateTime/shared/YearPicker.tsx
|
|
10
|
+
var YearPicker = ({ state, onSelectionChange }) => {
|
|
10
11
|
const formatter = useDateFormatter({
|
|
11
12
|
year: "numeric",
|
|
12
13
|
timeZone: state.timeZone
|
|
@@ -61,4 +62,5 @@ const YearPicker = ({ state, onSelectionChange }) => {
|
|
|
61
62
|
})
|
|
62
63
|
});
|
|
63
64
|
};
|
|
65
|
+
//#endregion
|
|
64
66
|
export { YearPicker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FieldValues } from 'react-hook-form';
|
|
2
2
|
import { FileUploadProps } from './fileUpload.types';
|
|
3
|
-
export type { FileUploadBaseProps, FileUploadError, FileUploadProps, FileUploadRequest, FileUploadResponse, FileUploadState, } from './fileUpload.types';
|
|
3
|
+
export type { DefaultFile, FileUploadBaseProps, FileUploadError, FileUploadProps, FileUploadRequest, FileUploadResponse, FileUploadState, } from './fileUpload.types';
|
|
4
4
|
export declare const FileUpload: <TFieldValues extends FieldValues = FieldValues>(props: FileUploadProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
2
|
-
import
|
|
2
|
+
import "../../../config/i18n.js";
|
|
3
3
|
import { FormField } from "../FormField/FormField.js";
|
|
4
4
|
import { FileUtils } from "../../../utils/file.utils.js";
|
|
5
5
|
import { FileCardList } from "./shared/FileCardList.js";
|
|
@@ -11,13 +11,26 @@ import { clsx } from "clsx";
|
|
|
11
11
|
import { useCallback, useState } from "react";
|
|
12
12
|
import { DropZone } from "react-aria-components";
|
|
13
13
|
import { mergeRefs, useLabels } from "@react-aria/utils";
|
|
14
|
-
import { Controller } from "react-hook-form";
|
|
15
14
|
import { useTranslation } from "react-i18next";
|
|
15
|
+
import { Controller } from "react-hook-form";
|
|
16
|
+
//#region src/components/inputs/File/FileUpload.tsx
|
|
16
17
|
var FileUploadBase = (props) => {
|
|
17
18
|
const { t } = useTranslation("ui");
|
|
18
|
-
const { ref: _ref, label, tooltipText, variant = "vertical", as = "button", helperText, isRequired, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, className, allowsMultiple = false, hideLabel, acceptedFileTypes, clearOnSuccess, emptyText = t(($) => $.ui.fileUpload.emptyText), uploadText = t(($) => $.ui.fileUpload.uploadText), browseText = t(($) => $.ui.fileUpload.browse), fileUpload, fileRemove, children, listRenderer, onInvalidFileType, ...rest } = props;
|
|
19
|
+
const { ref: _ref, label, tooltipText, variant = "vertical", as = "button", helperText, isRequired, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, className, allowsMultiple = false, hideLabel, acceptedFileTypes, clearOnSuccess, emptyText = t(($) => $.ui.fileUpload.emptyText), uploadText = t(($) => $.ui.fileUpload.uploadText), browseText = t(($) => $.ui.fileUpload.browse), fileUpload, fileRemove, children, listRenderer, onInvalidFileType, defaultState, ...rest } = props;
|
|
19
20
|
const ui = UIConfig.useConfig();
|
|
20
|
-
const
|
|
21
|
+
const getInitialState = () => {
|
|
22
|
+
if (props.value != null && props.value.length > 0) return props.value;
|
|
23
|
+
if (!defaultState?.length) return [];
|
|
24
|
+
const items = defaultState.map((item, index) => ({
|
|
25
|
+
state: "uploaded",
|
|
26
|
+
displayName: item.name,
|
|
27
|
+
displaySize: item.size,
|
|
28
|
+
displayType: item.type,
|
|
29
|
+
id: item.id ?? `default-${index}`
|
|
30
|
+
}));
|
|
31
|
+
return allowsMultiple ? items : items.slice(0, 1);
|
|
32
|
+
};
|
|
33
|
+
const [uploadState, setUploadState] = useState(getInitialState);
|
|
21
34
|
const formFieldProps = {
|
|
22
35
|
error,
|
|
23
36
|
label,
|
|
@@ -77,9 +90,9 @@ var FileUploadBase = (props) => {
|
|
|
77
90
|
} : state));
|
|
78
91
|
});
|
|
79
92
|
if (clearOnSuccess) setUploadState([]);
|
|
80
|
-
} catch (error
|
|
93
|
+
} catch (error) {
|
|
81
94
|
setUploadState((prev) => prev.filter((_, i) => i < startIndex));
|
|
82
|
-
throw error
|
|
95
|
+
throw error;
|
|
83
96
|
}
|
|
84
97
|
};
|
|
85
98
|
const handleSelect = (inputFiles) => {
|
|
@@ -168,7 +181,7 @@ var FileUploadBase = (props) => {
|
|
|
168
181
|
}))]
|
|
169
182
|
});
|
|
170
183
|
};
|
|
171
|
-
|
|
184
|
+
var FileUpload = (props) => {
|
|
172
185
|
if ("formControl" in props && props.formControl) {
|
|
173
186
|
const { formControl, ref, ...innerProps } = props;
|
|
174
187
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -186,4 +199,5 @@ const FileUpload = (props) => {
|
|
|
186
199
|
}
|
|
187
200
|
return /* @__PURE__ */ jsx(FileUploadBase, { ...props });
|
|
188
201
|
};
|
|
202
|
+
//#endregion
|
|
189
203
|
export { FileUpload };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FileUpload } from "./FileUpload.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
3
|
+
//#region src/components/inputs/File/FileUploadContainer.tsx
|
|
4
|
+
var FileUploadContainer = (props) => {
|
|
4
5
|
return /* @__PURE__ */ jsx(FileUpload, {
|
|
5
6
|
label: "",
|
|
6
7
|
hideLabel: true,
|
|
@@ -9,4 +10,5 @@ const FileUploadContainer = (props) => {
|
|
|
9
10
|
...props
|
|
10
11
|
});
|
|
11
12
|
};
|
|
13
|
+
//#endregion
|
|
12
14
|
export { FileUploadContainer };
|
|
@@ -8,6 +8,7 @@ import { clsx } from "clsx";
|
|
|
8
8
|
import { useState } from "react";
|
|
9
9
|
import { mergeRefs, useLabels } from "@react-aria/utils";
|
|
10
10
|
import { Controller } from "react-hook-form";
|
|
11
|
+
//#region src/components/inputs/File/InputUpload.tsx
|
|
11
12
|
var InputUploadBase = ({ ref: _ref, label, tooltipText, variant, helperText, isRequired, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, className, onChange, onInvalidFileType, value, defaultValue, allowsMultiple = false, hideLabel, acceptedFileTypes, ...rest }) => {
|
|
12
13
|
const ui = UIConfig.useConfig();
|
|
13
14
|
const [internalFiles, setInternalFiles] = useState(() => {
|
|
@@ -90,7 +91,7 @@ var InputUploadBase = ({ ref: _ref, label, tooltipText, variant, helperText, isR
|
|
|
90
91
|
})
|
|
91
92
|
});
|
|
92
93
|
};
|
|
93
|
-
|
|
94
|
+
var InputUpload = (props) => {
|
|
94
95
|
if ("formControl" in props && props.formControl) {
|
|
95
96
|
const { formControl, ref, ...innerProps } = props;
|
|
96
97
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -108,4 +109,5 @@ const InputUpload = (props) => {
|
|
|
108
109
|
}
|
|
109
110
|
return /* @__PURE__ */ jsx(InputUploadBase, { ...props });
|
|
110
111
|
};
|
|
112
|
+
//#endregion
|
|
111
113
|
export { InputUpload };
|
|
@@ -38,6 +38,12 @@ export interface FileUploadRequest {
|
|
|
38
38
|
method: string;
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
+
export interface DefaultFile {
|
|
42
|
+
name: string;
|
|
43
|
+
size: number;
|
|
44
|
+
type?: string;
|
|
45
|
+
id?: string;
|
|
46
|
+
}
|
|
41
47
|
export interface FileUploadCallbacks {
|
|
42
48
|
fileUpload?: (request: FileUploadRequest, file: File, options?: {
|
|
43
49
|
abortController?: AbortController;
|
|
@@ -53,7 +59,10 @@ export interface FileUploadCallbacks {
|
|
|
53
59
|
export type FileUploadError = ApplicationException<GeneralErrorCodes>;
|
|
54
60
|
export interface FileUploadState {
|
|
55
61
|
state: "idle" | "uploading" | "uploaded" | "error";
|
|
56
|
-
file
|
|
62
|
+
file?: File;
|
|
63
|
+
displayName?: string;
|
|
64
|
+
displaySize?: number;
|
|
65
|
+
displayType?: string;
|
|
57
66
|
src?: string;
|
|
58
67
|
id?: string;
|
|
59
68
|
progress?: number;
|
|
@@ -74,6 +83,7 @@ export type FileUploadBaseProps = {
|
|
|
74
83
|
uploadText?: string;
|
|
75
84
|
browseText?: string;
|
|
76
85
|
value?: FileUploadState[];
|
|
86
|
+
defaultState?: DefaultFile[];
|
|
77
87
|
clearOnSuccess?: boolean;
|
|
78
88
|
children?: (props: FileUploadContainerChildrenProps) => ReactNode;
|
|
79
89
|
listRenderer?: (props: FileUploadContainerChildrenProps) => ReactNode;
|
|
@@ -4,7 +4,8 @@ import { FileUploadContentLoading } from "./FileUploadContentLoading.js";
|
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { clsx } from "clsx";
|
|
6
6
|
import { useMemo } from "react";
|
|
7
|
-
|
|
7
|
+
//#region src/components/inputs/File/shared/FileCard.tsx
|
|
8
|
+
var FileCard = ({ index, as, state, onRemove, isDisabled, onCancel }) => {
|
|
8
9
|
const content = useMemo(() => {
|
|
9
10
|
if (state.state === "uploading") return /* @__PURE__ */ jsx(FileUploadContentLoading, {
|
|
10
11
|
index,
|
|
@@ -47,4 +48,5 @@ const FileCard = ({ index, as, state, onRemove, isDisabled, onCancel }) => {
|
|
|
47
48
|
children: content
|
|
48
49
|
});
|
|
49
50
|
};
|
|
51
|
+
//#endregion
|
|
50
52
|
export { FileCard };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FileCard } from "./FileCard.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { clsx } from "clsx";
|
|
4
|
-
|
|
4
|
+
//#region src/components/inputs/File/shared/FileCardList.tsx
|
|
5
|
+
var FileCardList = ({ uploadState, as, isDisabled, className, onRemove, onCancel }) => {
|
|
5
6
|
return /* @__PURE__ */ jsx("div", {
|
|
6
7
|
className: clsx("mt-10 flex flex-col items-start gap-4 self-stretch", className),
|
|
7
8
|
children: uploadState.map((state, index) => /* @__PURE__ */ jsx(FileCard, {
|
|
@@ -11,7 +12,8 @@ const FileCardList = ({ uploadState, as, isDisabled, className, onRemove, onCanc
|
|
|
11
12
|
isDisabled,
|
|
12
13
|
onRemove,
|
|
13
14
|
onCancel
|
|
14
|
-
}, state.file
|
|
15
|
+
}, state.file?.name ?? state.displayName ?? state.id ?? state.src))
|
|
15
16
|
});
|
|
16
17
|
};
|
|
18
|
+
//#endregion
|
|
17
19
|
export { FileCardList };
|
|
@@ -4,7 +4,8 @@ import { FileUploadContentLoading } from "./FileUploadContentLoading.js";
|
|
|
4
4
|
import { FileUploadContentEmpty } from "./FileUploadContentEmpty.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { FileTrigger } from "react-aria-components";
|
|
7
|
-
|
|
7
|
+
//#region src/components/inputs/File/shared/FileUploadContent.tsx
|
|
8
|
+
var FileUploadContent = ({ variant, as, isDisabled, browseText, uploadText, emptyText, uploadState, handleCancelUpload, handleRemove, acceptedFileTypes, allowsMultiple, handleSelect, ...rest }) => {
|
|
8
9
|
const currentState = uploadState.at(0);
|
|
9
10
|
const fileTriggerProps = {
|
|
10
11
|
...rest,
|
|
@@ -58,4 +59,5 @@ const FileUploadContent = ({ variant, as, isDisabled, browseText, uploadText, em
|
|
|
58
59
|
})
|
|
59
60
|
});
|
|
60
61
|
};
|
|
62
|
+
//#endregion
|
|
61
63
|
export { FileUploadContent };
|