@povio/ui 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/icons/AlignCenter.js +26 -11
- package/dist/assets/icons/AlignLeft.js +26 -11
- package/dist/assets/icons/AlignLeftRight.js +26 -11
- package/dist/assets/icons/AlignRight.js +26 -11
- package/dist/assets/icons/ArrowDropDown.js +26 -11
- package/dist/assets/icons/ArrowDropUp.js +26 -11
- package/dist/assets/icons/ArrowLeft.js +26 -11
- package/dist/assets/icons/ArrowRight.js +26 -11
- package/dist/assets/icons/Bold.js +26 -11
- package/dist/assets/icons/BulletedList.js +26 -11
- package/dist/assets/icons/Calendar.js +28 -13
- package/dist/assets/icons/Check.js +28 -13
- package/dist/assets/icons/CheckCircle.js +26 -11
- package/dist/assets/icons/CheckboxCheckmark.js +29 -14
- package/dist/assets/icons/CheckboxIndeterminate.js +29 -14
- package/dist/assets/icons/ChevronDown.js +28 -13
- package/dist/assets/icons/ChevronLeft.js +28 -13
- package/dist/assets/icons/ChevronRight.js +28 -13
- package/dist/assets/icons/ChevronUp.js +28 -13
- package/dist/assets/icons/ChevronsLeft.js +28 -13
- package/dist/assets/icons/ChevronsRight.js +28 -13
- package/dist/assets/icons/Clock.js +26 -11
- package/dist/assets/icons/Close.js +26 -11
- package/dist/assets/icons/DateTime.js +35 -14
- package/dist/assets/icons/DragIndicator.js +26 -11
- package/dist/assets/icons/File.js +28 -13
- package/dist/assets/icons/Highlight.js +26 -11
- package/dist/assets/icons/HighlightOn.js +49 -15
- package/dist/assets/icons/Home.js +26 -11
- package/dist/assets/icons/Info.js +37 -16
- package/dist/assets/icons/Italic.js +26 -11
- package/dist/assets/icons/Link.js +26 -11
- package/dist/assets/icons/Menu.js +26 -11
- package/dist/assets/icons/NumberedList.js +26 -11
- package/dist/assets/icons/PointerHorizontal.js +26 -11
- package/dist/assets/icons/PointerVertical.js +26 -11
- package/dist/assets/icons/Search.js +26 -11
- package/dist/assets/icons/Send.js +28 -13
- package/dist/assets/icons/Strikethrough.js +26 -11
- package/dist/assets/icons/TextColor.js +48 -14
- package/dist/assets/icons/Today.js +26 -11
- package/dist/assets/icons/Underlined.js +28 -13
- package/dist/assets/icons/Upload.js +35 -14
- package/dist/assets/icons/Visibility.js +26 -11
- package/dist/assets/icons/VisibilityOff.js +26 -11
- package/dist/assets/icons/WarningFilled.js +28 -13
- package/dist/components/Breadcrumbs/Breadcrumbs.js +207 -56
- package/dist/components/Menu/Menu.js +18 -2
- package/dist/components/Menu/MenuDesktop.js +41 -7
- package/dist/components/Menu/MenuItem.js +32 -9
- package/dist/components/Menu/MenuMobile.js +102 -39
- package/dist/components/Menu/MenuPopover.js +105 -29
- package/dist/components/buttons/Button/button.cva.d.ts +3 -3
- package/dist/components/buttons/IconButton/IconButton.js +40 -8
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +34 -9
- package/dist/components/buttons/PillButton/PillButton.js +55 -17
- package/dist/components/buttons/PillButton/pillButton.cva.d.ts +1 -1
- package/dist/components/buttons/SplitButton/SplitButton.js +103 -18
- package/dist/components/buttons/TextButton/TextButton.js +30 -8
- package/dist/components/buttons/ToggleButton/ToggleButton.js +28 -8
- package/dist/components/buttons/shared/ButtonContent.js +80 -22
- package/dist/components/inputs/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/inputs/Checkbox/Checkbox.js +201 -35
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +24 -10
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
- package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +12 -5
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +380 -75
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +12 -5
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +499 -186
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +14 -5
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +280 -46
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +7 -3
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +616 -121
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/Calendar.js +342 -119
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +4 -2
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +310 -103
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +4 -2
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +150 -33
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +233 -98
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +318 -137
- package/dist/components/inputs/DateTime/shared/DateField.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/DateField.js +288 -112
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +14 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +359 -129
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +18 -1
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +104 -11
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +83 -28
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +59 -10
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +103 -58
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +193 -82
- package/dist/components/inputs/DateTime/shared/TimeField.js +27 -8
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +279 -110
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +4 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +211 -65
- package/dist/components/inputs/DateTime/shared/YearPicker.js +119 -68
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +5 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +16 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +16 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +15 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +32 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +41 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +99 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.spec.d.ts +1 -0
- package/dist/components/inputs/File/FileUpload.js +91 -46
- package/dist/components/inputs/File/FileUploadContainer.js +15 -7
- package/dist/components/inputs/File/InputUpload.js +317 -79
- package/dist/components/inputs/File/index.d.ts +1 -1
- package/dist/components/inputs/File/shared/FileCard.js +104 -41
- package/dist/components/inputs/File/shared/FileCardList.js +47 -12
- package/dist/components/inputs/File/shared/FileUploadContent.js +175 -44
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +149 -46
- package/dist/components/inputs/File/shared/FileUploadContentError.js +234 -93
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +230 -97
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +199 -55
- package/dist/components/inputs/File/shared/InputUploadContent.js +148 -34
- package/dist/components/inputs/File/shared/InputUploadFilled.js +49 -8
- package/dist/components/inputs/File/shared/ProgressBar.js +102 -15
- package/dist/components/inputs/File/shared/fileUpload.cva.d.ts +0 -11
- package/dist/components/inputs/File/shared/fileUpload.cva.js +1 -18
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormField.js +119 -37
- package/dist/components/inputs/FormField/FormFieldError.js +25 -5
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +81 -22
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +31 -7
- package/dist/components/inputs/FormField/FormFieldHelper.js +26 -6
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldLabel.js +40 -9
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +13 -0
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +14 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +446 -97
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +571 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +574 -0
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +48 -9
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +8 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +5 -0
- package/dist/components/inputs/Input/TextArea/TextArea.js +305 -90
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +429 -90
- package/dist/components/inputs/Input/shared/InputContent.js +193 -59
- package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
- package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
- package/dist/components/inputs/Inputs/Form.js +40 -11
- package/dist/components/inputs/Inputs/InputItem.d.ts +15 -21
- package/dist/components/inputs/Inputs/InputItem.js +69 -14
- package/dist/components/inputs/Inputs/Inputs.js +37 -11
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +3 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +353 -61
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +45 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +48 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +217 -22
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -18
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +107 -8
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +37 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +14 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.js +178 -0
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +227 -18
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +8 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +69 -18
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +393 -138
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +397 -116
- package/dist/components/inputs/Selection/shared/SelectInputTags.js +99 -25
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +164 -52
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +85 -35
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +69 -16
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +70 -21
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +58 -9
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +9 -3
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.d.ts +9 -0
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.js +47 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +14 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +43 -0
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +67 -36
- package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +6 -0
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
- package/dist/components/inputs/Selection/shared/selectInput.cva.d.ts +12 -0
- package/dist/components/inputs/Selection/shared/selectInput.cva.js +8 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +54 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
- package/dist/components/inputs/Selection/shared/useSelectItems.js +109 -49
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +83 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +612 -0
- package/dist/components/inputs/Slider/Slider.d.ts +2 -1
- package/dist/components/inputs/Slider/Slider.js +265 -76
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +447 -98
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +37 -11
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +102 -30
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +194 -45
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +88 -28
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +48 -14
- package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +66 -19
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +49 -15
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +92 -32
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +126 -54
- package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +141 -38
- package/dist/components/inputs/Toggle/Toggle.d.ts +1 -0
- package/dist/components/inputs/Toggle/Toggle.js +214 -37
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
- package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
- package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
- package/dist/components/inputs/shared/CheckContent.js +21 -11
- package/dist/components/inputs/shared/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +88 -12
- package/dist/components/inputs/shared/TooltipWrapper.js +50 -11
- package/dist/components/inputs/shared/input.cva.d.ts +28 -0
- package/dist/components/inputs/shared/input.cva.js +38 -4
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +8 -0
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +15 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.js +112 -0
- package/dist/components/navigation/Accordion/Accordion.js +69 -22
- package/dist/components/navigation/Accordion/AccordionItem.js +86 -41
- package/dist/components/navigation/Stepper/Stepper.js +67 -22
- package/dist/components/navigation/Stepper/StepperItem.js +104 -31
- package/dist/components/navigation/Stepper/StepperSeparator.js +23 -5
- package/dist/components/overlays/ActionModal/ActionModal.js +169 -35
- package/dist/components/overlays/BottomSheet/BottomSheet.js +96 -23
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +48 -8
- package/dist/components/overlays/Drawer/Drawer.js +62 -20
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +85 -28
- package/dist/components/overlays/Tooltip/Tooltip.js +137 -28
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +37 -12
- package/dist/components/segment/Segment.js +218 -57
- package/dist/components/segment/SegmentItem.js +67 -10
- package/dist/components/shared/pagination/Pagination.js +108 -22
- package/dist/components/shared/pagination/PaginationList.js +167 -64
- package/dist/components/shared/pagination/minWidth.cva.d.ts +1 -1
- package/dist/components/status/Alert/Alert.js +97 -30
- package/dist/components/status/Loader/Loader.js +77 -22
- package/dist/components/status/Toast/Toast.js +28 -14
- package/dist/components/status/Toast/toast.cva.d.ts +1 -1
- package/dist/components/status/Toast/useToast.js +62 -57
- package/dist/components/table/ColumnConfig.js +158 -54
- package/dist/components/table/InfiniteTable.js +67 -16
- package/dist/components/table/PaginatedTable.js +84 -18
- package/dist/components/table/Table.js +28 -27
- package/dist/components/text/Link/Link.js +19 -7
- package/dist/components/text/Typography/Typography.js +23 -8
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/link.context.js +23 -9
- package/dist/config/router.context.js +42 -16
- package/dist/config/theme.context.js +98 -45
- package/dist/config/uiConfig.context.d.ts +20 -6
- package/dist/config/uiConfig.context.js +68 -14
- package/dist/config/uiOverrides.context.d.ts +30 -11
- package/dist/config/uiOverrides.context.js +54 -14
- package/dist/helpers/dynamicInputs.d.ts +12 -9
- package/dist/helpers/dynamicInputs.js +13 -8
- package/dist/hooks/useAutosave.d.ts +2 -1
- package/dist/hooks/useAutosave.js +12 -4
- package/dist/hooks/useAutosave.spec.d.ts +1 -0
- package/dist/hooks/useBreakpoint.js +16 -3
- package/dist/hooks/useDebounceCallback.js +51 -17
- package/dist/hooks/useFilters.js +125 -64
- package/dist/hooks/useForm.js +42 -8
- package/dist/hooks/useFormAutosave.d.ts +3 -1
- package/dist/hooks/useFormAutosave.js +122 -30
- package/dist/hooks/useFormAutosave.spec.d.ts +1 -0
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +91 -24
- package/dist/hooks/useKeyInteractions.d.ts +20 -0
- package/dist/hooks/useKeyInteractions.js +54 -0
- package/dist/hooks/useKeyInteractions.spec.d.ts +1 -0
- package/dist/hooks/useLocalStorage.js +43 -10
- package/dist/hooks/useLongPressRepeat.js +55 -20
- package/dist/hooks/usePagination.js +49 -19
- package/dist/hooks/useQueryAutocomplete.d.ts +14 -0
- package/dist/hooks/useQueryAutocomplete.js +72 -0
- package/dist/hooks/useScrollableListBox.js +37 -16
- package/dist/hooks/useSorting.js +69 -28
- package/dist/hooks/useStateAndRef.js +21 -7
- package/dist/hooks/useTableColumnConfig.js +124 -31
- package/dist/hooks/useTranslationMemo.js +25 -5
- package/dist/index.d.ts +18 -3
- package/dist/index.js +15 -5
- package/dist/tw-ui-plugin.js +6 -0
- package/dist/utils/date-time.utils.d.ts +38 -10
- package/dist/utils/date-time.utils.js +136 -22
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/dist/utils/zod.utils.d.ts +2 -0
- package/dist/utils/zod.utils.js +5 -0
- package/package.json +2 -2
|
@@ -1,30 +1,225 @@
|
|
|
1
|
+
import { UIOverrides } from "../../../../config/uiOverrides.context.js";
|
|
2
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
4
|
+
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
5
|
+
import { selectInputTagsContentWrapperDefinition } from "../shared/selectInput.cva.js";
|
|
1
6
|
import { SelectBase } from "../shared/SelectBase.js";
|
|
2
|
-
import {
|
|
7
|
+
import { StaticSelectTrailingContent } from "../shared/StaticSelectTrailingContent.js";
|
|
8
|
+
import { getStaticSelectValue } from "../shared/staticSelect.utils.js";
|
|
9
|
+
import { c } from "react/compiler-runtime";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { clsx } from "clsx";
|
|
12
|
+
import { useRef, useState } from "react";
|
|
3
13
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
14
|
import { Controller } from "react-hook-form";
|
|
5
15
|
//#region src/components/inputs/Selection/Autocomplete/Autocomplete.tsx
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
function AutocompleteInner(t0) {
|
|
17
|
+
const $ = c(8);
|
|
18
|
+
const { renderStaticInput, isFormControlDisabled, ...props } = t0;
|
|
19
|
+
const ui = UIConfig.useConfig();
|
|
20
|
+
const selectInputTagsContentWrapperCva = UIOverrides.useCva("select.tagsContentWrapperCva", selectInputTagsContentWrapperDefinition);
|
|
21
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
22
|
+
const rootRef = useRef(null);
|
|
23
|
+
let t1;
|
|
24
|
+
if ($[0] !== renderInput) {
|
|
25
|
+
t1 = {
|
|
26
|
+
inputRef: rootRef,
|
|
27
|
+
renderInput,
|
|
28
|
+
setRenderInput,
|
|
29
|
+
getFocusTarget: _temp
|
|
30
|
+
};
|
|
31
|
+
$[0] = renderInput;
|
|
32
|
+
$[1] = t1;
|
|
33
|
+
} else t1 = $[1];
|
|
34
|
+
const { renderRealInput, replayStaticInputChange, replayStaticInputPress } = useStaticInputHandoff(t1);
|
|
35
|
+
const currentValue = props.value;
|
|
36
|
+
if (!renderInput && !!props.customTrigger) setRenderInput(true);
|
|
37
|
+
if (!renderInput) {
|
|
38
|
+
const as = props.as ?? ui.input.as;
|
|
39
|
+
const size = props.size ?? ui.input.size;
|
|
40
|
+
let isDisabled = !!props.isDisabled;
|
|
41
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
42
|
+
const mode = props.selectionMode ?? ui.select.selectionMode;
|
|
43
|
+
const { selectedItem, displayValue, isEmpty } = getStaticSelectValue({
|
|
44
|
+
items: props.items,
|
|
45
|
+
value: currentValue,
|
|
46
|
+
selectionMode: mode,
|
|
47
|
+
initialSelection: props.initialSelection,
|
|
48
|
+
mapInitialToSelectItem: props.mapInitialToSelectItem,
|
|
49
|
+
showSelectionContent: props.showSelectionContent,
|
|
50
|
+
isDisabled,
|
|
51
|
+
collapseAfter: props.collapseAfter ?? ui.select.collapseAfter,
|
|
52
|
+
selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
|
|
53
|
+
});
|
|
54
|
+
const isMultiple = mode === "multiple";
|
|
55
|
+
const trailingContent = /* @__PURE__ */ jsx(StaticSelectTrailingContent, {
|
|
56
|
+
trailingContent: props.trailingContent,
|
|
57
|
+
hideDropdownIcon: props.hideDropdownIcon,
|
|
58
|
+
isDisabled,
|
|
59
|
+
size
|
|
60
|
+
});
|
|
61
|
+
const placeholder = as === "floating" ? null : props.placeholder;
|
|
62
|
+
const shouldRenderPlaceholderAfterValue = mode !== "single" && props.placeholder && !isEmpty;
|
|
63
|
+
const inputValue = !isMultiple && selectedItem ? selectedItem.label : "";
|
|
64
|
+
const dataAttributes = {
|
|
65
|
+
dataIsEmpty: isEmpty,
|
|
66
|
+
dataIsFilled: !isEmpty,
|
|
67
|
+
dataIsDirty: props.isDirty,
|
|
68
|
+
dataIsRequired: props.isRequired,
|
|
69
|
+
dataIsDisabled: isDisabled,
|
|
70
|
+
dataDisabled: isDisabled,
|
|
71
|
+
dataInvalid: !!props.error,
|
|
72
|
+
dataHasSelection: !isEmpty,
|
|
73
|
+
dataHasSearch: false
|
|
74
|
+
};
|
|
75
|
+
const t2 = isDisabled;
|
|
76
|
+
const t3 = clsx("w-full", props.containerClassName);
|
|
77
|
+
const t4 = clsx(props.className, props.inputClassName);
|
|
78
|
+
let t5;
|
|
79
|
+
if ($[2] !== selectInputTagsContentWrapperCva) {
|
|
80
|
+
t5 = selectInputTagsContentWrapperCva({ isSearchable: true });
|
|
81
|
+
$[2] = selectInputTagsContentWrapperCva;
|
|
82
|
+
$[3] = t5;
|
|
83
|
+
} else t5 = $[3];
|
|
84
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
85
|
+
...props,
|
|
86
|
+
isDisabled: t2,
|
|
87
|
+
isLoading: false,
|
|
88
|
+
className: t3,
|
|
89
|
+
inputClassName: t4,
|
|
90
|
+
contentWrapperClassName: t5,
|
|
91
|
+
contentGroup: "select",
|
|
92
|
+
labelPlacement: "content-row",
|
|
93
|
+
dataAttributes,
|
|
94
|
+
onStaticInteract: renderRealInput,
|
|
95
|
+
onStaticPress: replayStaticInputPress,
|
|
96
|
+
wrapTrailingContent: false,
|
|
97
|
+
leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
|
|
98
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
99
|
+
children: props.leadingContent
|
|
100
|
+
}),
|
|
101
|
+
trailingContent,
|
|
102
|
+
children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [isMultiple && !isEmpty && displayValue, /* @__PURE__ */ jsx("input", {
|
|
103
|
+
disabled: isDisabled,
|
|
104
|
+
tabIndex: -1,
|
|
105
|
+
role: "combobox",
|
|
106
|
+
"aria-autocomplete": "list",
|
|
107
|
+
"aria-controls": `${dataAttributeProps.id}-listbox`,
|
|
108
|
+
"aria-expanded": false,
|
|
109
|
+
value: inputValue,
|
|
110
|
+
placeholder: isMultiple && shouldRenderPlaceholderAfterValue ? props.placeholder : placeholder ?? void 0,
|
|
111
|
+
className: clsx("w-full flex-1 bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.inputClassName),
|
|
112
|
+
onChange: (event) => replayStaticInputChange(event.target.value),
|
|
113
|
+
...dataAttributeProps,
|
|
114
|
+
"data-rac": true
|
|
115
|
+
})] })
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const T0 = SelectBase;
|
|
119
|
+
const t2 = mergeRefs(props.ref, rootRef);
|
|
120
|
+
let t3;
|
|
121
|
+
if ($[4] !== T0 || $[5] !== props || $[6] !== t2) {
|
|
122
|
+
t3 = /* @__PURE__ */ jsx(T0, {
|
|
123
|
+
...props,
|
|
124
|
+
ref: t2,
|
|
125
|
+
isSearchable: true
|
|
22
126
|
});
|
|
127
|
+
$[4] = T0;
|
|
128
|
+
$[5] = props;
|
|
129
|
+
$[6] = t2;
|
|
130
|
+
$[7] = t3;
|
|
131
|
+
} else t3 = $[7];
|
|
132
|
+
return t3;
|
|
133
|
+
}
|
|
134
|
+
function _temp(root) {
|
|
135
|
+
return root.querySelector("input, [data-type='select-trigger'], button, [tabindex]");
|
|
136
|
+
}
|
|
137
|
+
function Autocomplete(t0) {
|
|
138
|
+
const $ = c(23);
|
|
139
|
+
let props;
|
|
140
|
+
let renderStaticInput;
|
|
141
|
+
if ($[0] !== t0) {
|
|
142
|
+
({renderStaticInput, ...props} = t0);
|
|
143
|
+
$[0] = t0;
|
|
144
|
+
$[1] = props;
|
|
145
|
+
$[2] = renderStaticInput;
|
|
146
|
+
} else {
|
|
147
|
+
props = $[1];
|
|
148
|
+
renderStaticInput = $[2];
|
|
149
|
+
}
|
|
150
|
+
if ("formControl" in props && props.formControl) {
|
|
151
|
+
let formControl;
|
|
152
|
+
let innerProps;
|
|
153
|
+
let ref;
|
|
154
|
+
let t1;
|
|
155
|
+
if ($[3] !== props) {
|
|
156
|
+
({ignoreInputValueFiltering: t1, formControl, ref, ...innerProps} = props);
|
|
157
|
+
$[3] = props;
|
|
158
|
+
$[4] = formControl;
|
|
159
|
+
$[5] = innerProps;
|
|
160
|
+
$[6] = ref;
|
|
161
|
+
$[7] = t1;
|
|
162
|
+
} else {
|
|
163
|
+
formControl = $[4];
|
|
164
|
+
innerProps = $[5];
|
|
165
|
+
ref = $[6];
|
|
166
|
+
t1 = $[7];
|
|
167
|
+
}
|
|
168
|
+
const ignoreInputValueFiltering = t1 === void 0 ? true : t1;
|
|
169
|
+
const controlWithOptions = formControl.control;
|
|
170
|
+
let t2;
|
|
171
|
+
if ($[8] !== controlWithOptions._options?.disabled || $[9] !== ignoreInputValueFiltering || $[10] !== innerProps || $[11] !== props.error || $[12] !== props.isDisabled || $[13] !== ref || $[14] !== renderStaticInput) {
|
|
172
|
+
t2 = (t3) => {
|
|
173
|
+
const { field, fieldState: t4 } = t3;
|
|
174
|
+
const { error, isDirty } = t4;
|
|
175
|
+
return /* @__PURE__ */ jsx(AutocompleteInner, {
|
|
176
|
+
...innerProps,
|
|
177
|
+
ref: mergeRefs(ref, field.ref),
|
|
178
|
+
value: field.value,
|
|
179
|
+
onChange: field.onChange,
|
|
180
|
+
onBlur: field.onBlur,
|
|
181
|
+
isDirty,
|
|
182
|
+
isDisabled: field.disabled || props.isDisabled,
|
|
183
|
+
isFormControlDisabled: !!controlWithOptions._options?.disabled,
|
|
184
|
+
error: props.error ?? error?.message,
|
|
185
|
+
ignoreInputValueFiltering,
|
|
186
|
+
renderStaticInput
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
$[8] = controlWithOptions._options?.disabled;
|
|
190
|
+
$[9] = ignoreInputValueFiltering;
|
|
191
|
+
$[10] = innerProps;
|
|
192
|
+
$[11] = props.error;
|
|
193
|
+
$[12] = props.isDisabled;
|
|
194
|
+
$[13] = ref;
|
|
195
|
+
$[14] = renderStaticInput;
|
|
196
|
+
$[15] = t2;
|
|
197
|
+
} else t2 = $[15];
|
|
198
|
+
let t3;
|
|
199
|
+
if ($[16] !== formControl.control || $[17] !== formControl.name || $[18] !== t2) {
|
|
200
|
+
t3 = /* @__PURE__ */ jsx(Controller, {
|
|
201
|
+
control: formControl.control,
|
|
202
|
+
name: formControl.name,
|
|
203
|
+
render: t2
|
|
204
|
+
});
|
|
205
|
+
$[16] = formControl.control;
|
|
206
|
+
$[17] = formControl.name;
|
|
207
|
+
$[18] = t2;
|
|
208
|
+
$[19] = t3;
|
|
209
|
+
} else t3 = $[19];
|
|
210
|
+
return t3;
|
|
23
211
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
212
|
+
let t1;
|
|
213
|
+
if ($[20] !== props || $[21] !== renderStaticInput) {
|
|
214
|
+
t1 = /* @__PURE__ */ jsx(AutocompleteInner, {
|
|
215
|
+
...props,
|
|
216
|
+
renderStaticInput
|
|
217
|
+
});
|
|
218
|
+
$[20] = props;
|
|
219
|
+
$[21] = renderStaticInput;
|
|
220
|
+
$[22] = t1;
|
|
221
|
+
} else t1 = $[22];
|
|
222
|
+
return t1;
|
|
223
|
+
}
|
|
29
224
|
//#endregion
|
|
30
225
|
export { Autocomplete };
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { Key } from 'react-aria-components';
|
|
3
1
|
import { FieldValues } from 'react-hook-form';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
type QueryFn<TSelectItem extends SelectItem = SelectItem> = (...args: any) => UseQueryResult<Array<TSelectItem>>;
|
|
8
|
-
type TKey<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>[0] extends {
|
|
9
|
-
id: infer InferredKey extends Key;
|
|
10
|
-
} ? InferredKey : never;
|
|
11
|
-
type QueryAutocompleteProps<TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>> = OmitDiscriminatedUnion<AutocompleteProps<TKey<TQueryFn>>, "items" | "onSearchChange" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey<TQueryFn>> & {
|
|
12
|
-
query: Parameters<TQueryFn>[0] extends {
|
|
13
|
-
search?: string;
|
|
14
|
-
} ? TQueryFn : never;
|
|
15
|
-
queryParams?: Omit<Parameters<TQueryFn>[0], "search">;
|
|
16
|
-
queryOptions?: Parameters<TQueryFn>[1];
|
|
17
|
-
};
|
|
18
|
-
export declare const QueryAutocomplete: <TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>>({ query, queryParams, queryOptions, ...props }: QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export {};
|
|
2
|
+
import { QueryAutocompleteProps, QueryFn } from './queryAutocomplete.types';
|
|
3
|
+
import { SelectItem } from '../shared/select.types';
|
|
4
|
+
export declare const QueryAutocomplete: <TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn>(props: QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,20 +1,119 @@
|
|
|
1
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
1
2
|
import { Autocomplete } from "./Autocomplete.js";
|
|
3
|
+
import { getQueryItems, getSelectionIdsToResolve } from "../shared/querySelect.utils.js";
|
|
4
|
+
import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
2
6
|
import { jsx } from "react/jsx-runtime";
|
|
3
7
|
import { useState } from "react";
|
|
8
|
+
import { mergeRefs } from "@react-aria/utils";
|
|
9
|
+
import { Controller } from "react-hook-form";
|
|
4
10
|
//#region src/components/inputs/Selection/Autocomplete/QueryAutocomplete.tsx
|
|
5
|
-
var
|
|
11
|
+
var QueryAutocompleteContent = ({ query, queryParams, queryOptions, queryMap, leadingContent, ...props }) => {
|
|
12
|
+
"use no memo";
|
|
13
|
+
const ui = UIConfig.useConfig();
|
|
6
14
|
const [search, setSearch] = useState("");
|
|
7
|
-
const {
|
|
15
|
+
const { onChange, ...restProps } = props;
|
|
16
|
+
const value = "value" in props ? props.value : void 0;
|
|
17
|
+
const selectedIdsToResolve = getSelectionIdsToResolve({
|
|
18
|
+
initialSelection: props.initialSelection,
|
|
19
|
+
value,
|
|
20
|
+
mapInitialToSelectItem: props.mapInitialToSelectItem
|
|
21
|
+
});
|
|
22
|
+
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
|
|
23
|
+
query,
|
|
24
|
+
queryParams,
|
|
25
|
+
queryOptions,
|
|
26
|
+
mapItems: (data) => getQueryItems(data, queryMap),
|
|
8
27
|
search,
|
|
9
|
-
|
|
10
|
-
|
|
28
|
+
initialQueryState: selectedIdsToResolve.count > 0 ? false : props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled,
|
|
29
|
+
selectedIdsToResolve: selectedIdsToResolve.items
|
|
30
|
+
});
|
|
31
|
+
const handleChange = (value_0) => {
|
|
32
|
+
onChange?.(value_0);
|
|
33
|
+
props.onBlur?.({ target: { value: null } });
|
|
34
|
+
};
|
|
35
|
+
const { isInitialQueryDisabled: _, ...autocompleteProps } = restProps;
|
|
36
|
+
const onSearchChange = (value_1) => {
|
|
37
|
+
setSearch(value_1);
|
|
38
|
+
handleEnableQuery();
|
|
39
|
+
};
|
|
11
40
|
return /* @__PURE__ */ jsx(Autocomplete, {
|
|
12
|
-
...
|
|
13
|
-
items
|
|
14
|
-
|
|
41
|
+
...autocompleteProps,
|
|
42
|
+
items,
|
|
43
|
+
totalItems,
|
|
44
|
+
onSearchChange,
|
|
15
45
|
isClientSearchDisabled: true,
|
|
16
|
-
isLoading
|
|
46
|
+
isLoading,
|
|
47
|
+
onChange: handleChange,
|
|
48
|
+
onMouseEnter: handleEnableQuery,
|
|
49
|
+
onFocusCapture: handleEnableQuery,
|
|
50
|
+
leadingContent,
|
|
51
|
+
hasLoadMore: hasNextPage,
|
|
52
|
+
onLoadMore: fetchNextPage
|
|
17
53
|
});
|
|
18
54
|
};
|
|
55
|
+
var QueryAutocomplete = (props) => {
|
|
56
|
+
const $ = c(16);
|
|
57
|
+
if ("formControl" in props && props.formControl) {
|
|
58
|
+
let formControl;
|
|
59
|
+
let innerProps;
|
|
60
|
+
let ref;
|
|
61
|
+
if ($[0] !== props) {
|
|
62
|
+
({formControl, ref, ...innerProps} = props);
|
|
63
|
+
$[0] = props;
|
|
64
|
+
$[1] = formControl;
|
|
65
|
+
$[2] = innerProps;
|
|
66
|
+
$[3] = ref;
|
|
67
|
+
} else {
|
|
68
|
+
formControl = $[1];
|
|
69
|
+
innerProps = $[2];
|
|
70
|
+
ref = $[3];
|
|
71
|
+
}
|
|
72
|
+
const controlWithOptions = formControl.control;
|
|
73
|
+
let t0;
|
|
74
|
+
if ($[4] !== controlWithOptions || $[5] !== innerProps || $[6] !== props.error || $[7] !== props.isDisabled || $[8] !== ref) {
|
|
75
|
+
t0 = (t1) => {
|
|
76
|
+
const { field, fieldState: t2 } = t1;
|
|
77
|
+
const { error, isDirty } = t2;
|
|
78
|
+
return /* @__PURE__ */ jsx(QueryAutocompleteContent, {
|
|
79
|
+
...innerProps,
|
|
80
|
+
ref: mergeRefs(ref, field.ref),
|
|
81
|
+
value: field.value,
|
|
82
|
+
onChange: field.onChange,
|
|
83
|
+
onBlur: field.onBlur,
|
|
84
|
+
isDirty,
|
|
85
|
+
isDisabled: field.disabled || props.isDisabled || !!controlWithOptions._options?.disabled,
|
|
86
|
+
error: props.error ?? error?.message
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
$[4] = controlWithOptions;
|
|
90
|
+
$[5] = innerProps;
|
|
91
|
+
$[6] = props.error;
|
|
92
|
+
$[7] = props.isDisabled;
|
|
93
|
+
$[8] = ref;
|
|
94
|
+
$[9] = t0;
|
|
95
|
+
} else t0 = $[9];
|
|
96
|
+
let t1;
|
|
97
|
+
if ($[10] !== formControl.control || $[11] !== formControl.name || $[12] !== t0) {
|
|
98
|
+
t1 = /* @__PURE__ */ jsx(Controller, {
|
|
99
|
+
control: formControl.control,
|
|
100
|
+
name: formControl.name,
|
|
101
|
+
render: t0
|
|
102
|
+
});
|
|
103
|
+
$[10] = formControl.control;
|
|
104
|
+
$[11] = formControl.name;
|
|
105
|
+
$[12] = t0;
|
|
106
|
+
$[13] = t1;
|
|
107
|
+
} else t1 = $[13];
|
|
108
|
+
return t1;
|
|
109
|
+
}
|
|
110
|
+
let t0;
|
|
111
|
+
if ($[14] !== props) {
|
|
112
|
+
t0 = /* @__PURE__ */ jsx(QueryAutocompleteContent, { ...props });
|
|
113
|
+
$[14] = props;
|
|
114
|
+
$[15] = t0;
|
|
115
|
+
} else t0 = $[15];
|
|
116
|
+
return t0;
|
|
117
|
+
};
|
|
19
118
|
//#endregion
|
|
20
119
|
export { QueryAutocomplete };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { InfiniteData, UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { Key } from 'react-aria-components';
|
|
3
|
+
import { FieldValues } from 'react-hook-form';
|
|
4
|
+
import { AutocompleteProps } from './Autocomplete';
|
|
5
|
+
import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
6
|
+
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
7
|
+
export type InfiniteQueryPage<TKey extends Key> = {
|
|
8
|
+
items?: SelectItem<TKey>[];
|
|
9
|
+
totalItems?: number;
|
|
10
|
+
};
|
|
11
|
+
export type QueryResult<TData> = UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
|
|
12
|
+
export type QueryFn = (params: any, options?: any) => QueryResult<any>;
|
|
13
|
+
export type ExtractQueryParams<TQueryFn> = TQueryFn extends (params: infer TParams, ...args: any[]) => any ? TParams : never;
|
|
14
|
+
export type ExtractQueryOptions<TQueryFn> = TQueryFn extends (params: any, options?: infer TOptions) => any ? TOptions : never;
|
|
15
|
+
export type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
|
|
16
|
+
export type ExtractPageType<T> = T extends InfiniteData<infer TPage> ? TPage : T;
|
|
17
|
+
export type ExtractedDataType<TQueryFn extends QueryFn> = ExtractPageType<QueryDataType<TQueryFn>> | ExtractPageType<QueryDataType<TQueryFn>>[];
|
|
18
|
+
export type QueryAutocompleteProps<TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn> = OmitDiscriminatedUnion<AutocompleteProps<TSelectItem["id"]>, "items" | "onSearchChange" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TSelectItem["id"]> & {
|
|
19
|
+
query: TQueryFn;
|
|
20
|
+
queryParams?: Omit<ExtractQueryParams<TQueryFn>, "search" | "limit"> & {
|
|
21
|
+
limit?: number;
|
|
22
|
+
};
|
|
23
|
+
queryOptions?: ExtractQueryOptions<TQueryFn>;
|
|
24
|
+
queryMap?: (data: ExtractedDataType<TQueryFn>) => SelectItem<TSelectItem["id"]>[];
|
|
25
|
+
isInitialQueryDisabled?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export interface UseQueryAutocompleteOptions<TQueryFn extends QueryFn, TKey extends Key = Key> {
|
|
28
|
+
query: TQueryFn;
|
|
29
|
+
queryParams?: Omit<ExtractQueryParams<TQueryFn>, "search" | "limit"> & {
|
|
30
|
+
limit?: number;
|
|
31
|
+
};
|
|
32
|
+
queryOptions?: ExtractQueryOptions<TQueryFn>;
|
|
33
|
+
mapItems: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
|
|
34
|
+
initialQueryState?: boolean;
|
|
35
|
+
search?: string;
|
|
36
|
+
selectedIdsToResolve?: TKey[];
|
|
37
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Key } from 'react-aria-components';
|
|
2
|
+
import { FieldValues } from 'react-hook-form';
|
|
3
|
+
import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
4
|
+
import { SelectProps } from './Select';
|
|
5
|
+
import { QueryDataType, QueryFn } from '../shared/querySelect.utils';
|
|
6
|
+
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
7
|
+
export type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectProps<TKey, TInitialSelectItem>, "items" | "totalItems" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey, TInitialSelectItem> & {
|
|
8
|
+
query: TQueryFn;
|
|
9
|
+
queryParams?: Parameters<TQueryFn>[0];
|
|
10
|
+
queryOptions?: Parameters<TQueryFn>[1];
|
|
11
|
+
queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
|
|
12
|
+
isInitialQueryDisabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const QuerySelect: <TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: QuerySelectProps<TFieldValues, TQueryFn, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
|
+
import { Select } from "./Select.js";
|
|
3
|
+
import { getQueryItems, getSelectionIdsToResolve } from "../shared/querySelect.utils.js";
|
|
4
|
+
import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { mergeRefs } from "@react-aria/utils";
|
|
9
|
+
import { Controller } from "react-hook-form";
|
|
10
|
+
//#region src/components/inputs/Selection/Select/QuerySelect.tsx
|
|
11
|
+
var QuerySelectContent = (t0) => {
|
|
12
|
+
const $ = c(29);
|
|
13
|
+
const { query, queryParams, queryOptions, queryMap, ...props } = t0;
|
|
14
|
+
const ui = UIConfig.useConfig();
|
|
15
|
+
const [search, setSearch] = useState("");
|
|
16
|
+
const isSearchable = props.isSearchable ?? ui.select.isSearchable;
|
|
17
|
+
const value = "value" in props ? props.value : void 0;
|
|
18
|
+
const selectedIdsToResolve = getSelectionIdsToResolve({
|
|
19
|
+
initialSelection: props.initialSelection,
|
|
20
|
+
value,
|
|
21
|
+
mapInitialToSelectItem: props.mapInitialToSelectItem
|
|
22
|
+
});
|
|
23
|
+
const shouldEnableInitialQuery = selectedIdsToResolve.count > 0;
|
|
24
|
+
let t1;
|
|
25
|
+
if ($[0] !== queryMap) {
|
|
26
|
+
t1 = (data) => getQueryItems(data, queryMap);
|
|
27
|
+
$[0] = queryMap;
|
|
28
|
+
$[1] = t1;
|
|
29
|
+
} else t1 = $[1];
|
|
30
|
+
const t2 = isSearchable ? search : void 0;
|
|
31
|
+
const t3 = shouldEnableInitialQuery ? false : props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled;
|
|
32
|
+
let t4;
|
|
33
|
+
if ($[2] !== query || $[3] !== queryOptions || $[4] !== queryParams || $[5] !== selectedIdsToResolve.items || $[6] !== t1 || $[7] !== t2 || $[8] !== t3) {
|
|
34
|
+
t4 = {
|
|
35
|
+
query,
|
|
36
|
+
queryParams,
|
|
37
|
+
queryOptions,
|
|
38
|
+
mapItems: t1,
|
|
39
|
+
search: t2,
|
|
40
|
+
initialQueryState: t3,
|
|
41
|
+
selectedIdsToResolve: selectedIdsToResolve.items
|
|
42
|
+
};
|
|
43
|
+
$[2] = query;
|
|
44
|
+
$[3] = queryOptions;
|
|
45
|
+
$[4] = queryParams;
|
|
46
|
+
$[5] = selectedIdsToResolve.items;
|
|
47
|
+
$[6] = t1;
|
|
48
|
+
$[7] = t2;
|
|
49
|
+
$[8] = t3;
|
|
50
|
+
$[9] = t4;
|
|
51
|
+
} else t4 = $[9];
|
|
52
|
+
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete(t4);
|
|
53
|
+
let onSearchChange;
|
|
54
|
+
let selectProps;
|
|
55
|
+
if ($[10] !== props) {
|
|
56
|
+
const { isInitialQueryDisabled: _, onSearchChange: t5, ...t6 } = props;
|
|
57
|
+
onSearchChange = t5;
|
|
58
|
+
selectProps = t6;
|
|
59
|
+
$[10] = props;
|
|
60
|
+
$[11] = onSearchChange;
|
|
61
|
+
$[12] = selectProps;
|
|
62
|
+
} else {
|
|
63
|
+
onSearchChange = $[11];
|
|
64
|
+
selectProps = $[12];
|
|
65
|
+
}
|
|
66
|
+
let t5;
|
|
67
|
+
if ($[13] !== handleEnableQuery || $[14] !== onSearchChange || $[15] !== setSearch) {
|
|
68
|
+
t5 = (value_0) => {
|
|
69
|
+
setSearch(value_0);
|
|
70
|
+
handleEnableQuery();
|
|
71
|
+
onSearchChange?.(value_0);
|
|
72
|
+
};
|
|
73
|
+
$[13] = handleEnableQuery;
|
|
74
|
+
$[14] = onSearchChange;
|
|
75
|
+
$[15] = setSearch;
|
|
76
|
+
$[16] = t5;
|
|
77
|
+
} else t5 = $[16];
|
|
78
|
+
const handleSearchChange = t5;
|
|
79
|
+
let t6;
|
|
80
|
+
if ($[17] !== handleSearchChange || $[18] !== isSearchable) {
|
|
81
|
+
t6 = isSearchable && {
|
|
82
|
+
isClientSearchDisabled: true,
|
|
83
|
+
onSearchChange: handleSearchChange
|
|
84
|
+
};
|
|
85
|
+
$[17] = handleSearchChange;
|
|
86
|
+
$[18] = isSearchable;
|
|
87
|
+
$[19] = t6;
|
|
88
|
+
} else t6 = $[19];
|
|
89
|
+
let t7;
|
|
90
|
+
if ($[20] !== fetchNextPage || $[21] !== handleEnableQuery || $[22] !== hasNextPage || $[23] !== isLoading || $[24] !== items || $[25] !== selectProps || $[26] !== t6 || $[27] !== totalItems) {
|
|
91
|
+
t7 = /* @__PURE__ */ jsx(Select, {
|
|
92
|
+
...selectProps,
|
|
93
|
+
items,
|
|
94
|
+
isLoading,
|
|
95
|
+
totalItems,
|
|
96
|
+
hasLoadMore: hasNextPage,
|
|
97
|
+
onLoadMore: fetchNextPage,
|
|
98
|
+
onMouseEnter: handleEnableQuery,
|
|
99
|
+
onFocusCapture: handleEnableQuery,
|
|
100
|
+
...t6
|
|
101
|
+
});
|
|
102
|
+
$[20] = fetchNextPage;
|
|
103
|
+
$[21] = handleEnableQuery;
|
|
104
|
+
$[22] = hasNextPage;
|
|
105
|
+
$[23] = isLoading;
|
|
106
|
+
$[24] = items;
|
|
107
|
+
$[25] = selectProps;
|
|
108
|
+
$[26] = t6;
|
|
109
|
+
$[27] = totalItems;
|
|
110
|
+
$[28] = t7;
|
|
111
|
+
} else t7 = $[28];
|
|
112
|
+
return t7;
|
|
113
|
+
};
|
|
114
|
+
var QuerySelect = (props) => {
|
|
115
|
+
const $ = c(16);
|
|
116
|
+
if ("formControl" in props && props.formControl) {
|
|
117
|
+
let formControl;
|
|
118
|
+
let innerProps;
|
|
119
|
+
let ref;
|
|
120
|
+
if ($[0] !== props) {
|
|
121
|
+
({formControl, ref, ...innerProps} = props);
|
|
122
|
+
$[0] = props;
|
|
123
|
+
$[1] = formControl;
|
|
124
|
+
$[2] = innerProps;
|
|
125
|
+
$[3] = ref;
|
|
126
|
+
} else {
|
|
127
|
+
formControl = $[1];
|
|
128
|
+
innerProps = $[2];
|
|
129
|
+
ref = $[3];
|
|
130
|
+
}
|
|
131
|
+
const controlWithOptions = formControl.control;
|
|
132
|
+
let t0;
|
|
133
|
+
if ($[4] !== controlWithOptions || $[5] !== innerProps || $[6] !== props.error || $[7] !== props.isDisabled || $[8] !== ref) {
|
|
134
|
+
t0 = (t1) => {
|
|
135
|
+
const { field, fieldState: t2 } = t1;
|
|
136
|
+
const { error, isDirty } = t2;
|
|
137
|
+
return /* @__PURE__ */ jsx(QuerySelectContent, {
|
|
138
|
+
...innerProps,
|
|
139
|
+
ref: mergeRefs(ref, field.ref),
|
|
140
|
+
value: field.value,
|
|
141
|
+
onChange: field.onChange,
|
|
142
|
+
onBlur: field.onBlur,
|
|
143
|
+
isDirty,
|
|
144
|
+
isDisabled: field.disabled || props.isDisabled || !!controlWithOptions._options?.disabled,
|
|
145
|
+
error: props.error ?? error?.message
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
$[4] = controlWithOptions;
|
|
149
|
+
$[5] = innerProps;
|
|
150
|
+
$[6] = props.error;
|
|
151
|
+
$[7] = props.isDisabled;
|
|
152
|
+
$[8] = ref;
|
|
153
|
+
$[9] = t0;
|
|
154
|
+
} else t0 = $[9];
|
|
155
|
+
let t1;
|
|
156
|
+
if ($[10] !== formControl.control || $[11] !== formControl.name || $[12] !== t0) {
|
|
157
|
+
t1 = /* @__PURE__ */ jsx(Controller, {
|
|
158
|
+
control: formControl.control,
|
|
159
|
+
name: formControl.name,
|
|
160
|
+
render: t0
|
|
161
|
+
});
|
|
162
|
+
$[10] = formControl.control;
|
|
163
|
+
$[11] = formControl.name;
|
|
164
|
+
$[12] = t0;
|
|
165
|
+
$[13] = t1;
|
|
166
|
+
} else t1 = $[13];
|
|
167
|
+
return t1;
|
|
168
|
+
}
|
|
169
|
+
let t0;
|
|
170
|
+
if ($[14] !== props) {
|
|
171
|
+
t0 = /* @__PURE__ */ jsx(QuerySelectContent, { ...props });
|
|
172
|
+
$[14] = props;
|
|
173
|
+
$[15] = t0;
|
|
174
|
+
} else t0 = $[15];
|
|
175
|
+
return t0;
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
export { QuerySelect };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
1
2
|
import { Key } from 'react-aria-components';
|
|
2
3
|
import { FieldValues } from 'react-hook-form';
|
|
3
4
|
import { SelectBaseProps } from '../shared/SelectBase';
|
|
4
5
|
import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps, SelectAsyncProps } from '../shared/select.types';
|
|
5
6
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
6
|
-
export type SelectProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export type SelectProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>, keyof SelectAsyncProps> & {
|
|
8
|
+
renderStaticInput?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type ControlledSelectProps<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = Omit<SelectProps<TKey, TInitialSelectItem>, keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey, TInitialSelectItem>;
|
|
11
|
+
export declare function Select<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: SelectProps<TKey, TInitialSelectItem>): ReactElement;
|
|
12
|
+
export declare function Select<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: ControlledSelectProps<TFieldValues, TKey, TInitialSelectItem>): ReactElement;
|