@povio/ui 2.2.12 → 2.3.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
- 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 +10 -5
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +88 -9
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +10 -5
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +94 -7
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +11 -5
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +94 -9
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +5 -3
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +76 -7
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/Calendar.js +23 -6
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +78 -61
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +11 -4
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +4 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +21 -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 +31 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.spec.d.ts +1 -0
- package/dist/components/inputs/File/FileUpload.js +1 -0
- package/dist/components/inputs/File/shared/InputUploadContent.js +1 -0
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +81 -7
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +146 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +235 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +4 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +5 -0
- package/dist/components/inputs/Input/TextArea/TextArea.js +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +82 -7
- package/dist/components/inputs/Input/shared/InputContent.js +7 -6
- 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/InputItem.d.ts +16 -21
- package/dist/components/inputs/Inputs/InputItem.js +6 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +2 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +106 -25
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +17 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +42 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +102 -7
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -18
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +33 -8
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +36 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +14 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.js +42 -0
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +115 -5
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +8 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +11 -3
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +27 -4
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
- 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/querySelect.utils.d.ts +6 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +13 -0
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +27 -4
- package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +77 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +200 -0
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +8 -3
- package/dist/components/inputs/Toggle/Toggle.js +6 -1
- 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 +3 -4
- package/dist/components/inputs/shared/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +13 -1
- package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
- package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
- package/dist/components/inputs/shared/input.cva.d.ts +10 -0
- package/dist/components/inputs/shared/input.cva.js +19 -1
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +13 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.js +47 -0
- package/dist/config/router.context.d.ts +3 -4
- package/dist/config/router.context.js +1 -3
- package/dist/config/uiConfig.context.d.ts +15 -3
- package/dist/config/uiConfig.context.js +16 -3
- package/dist/config/uiStyle.context.d.ts +27 -4
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +3 -0
- package/dist/hooks/useFilters.js +27 -23
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +27 -14
- package/dist/hooks/usePagination.js +8 -4
- package/dist/hooks/useQueryAutocomplete.d.ts +14 -0
- package/dist/hooks/useQueryAutocomplete.js +56 -0
- package/dist/hooks/useSorting.js +7 -4
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -3
- package/dist/tw-ui-plugin.js +2 -0
- package/dist/utils/date-time.utils.d.ts +31 -10
- package/dist/utils/date-time.utils.js +123 -22
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/dist/utils/routing.utils.d.ts +1 -0
- package/dist/utils/routing.utils.js +14 -0
- package/package.json +2 -2
|
@@ -1,23 +1,32 @@
|
|
|
1
|
+
import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
|
|
2
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
4
|
+
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
1
5
|
import { SelectBase } from "../shared/SelectBase.js";
|
|
2
|
-
import {
|
|
6
|
+
import { getStaticSelectValue } from "../shared/staticSelect.utils.js";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { clsx } from "clsx";
|
|
9
|
+
import { useRef, useState } from "react";
|
|
3
10
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
|
-
import { Controller } from "react-hook-form";
|
|
11
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
5
12
|
//#region src/components/inputs/Selection/Autocomplete/Autocomplete.tsx
|
|
6
|
-
|
|
13
|
+
function _Autocomplete(props) {
|
|
7
14
|
if ("formControl" in props && props.formControl) {
|
|
8
|
-
const { formControl, ref, ...innerProps } = props;
|
|
15
|
+
const { ignoreInputValueFiltering = true, formControl, ref, ...innerProps } = props;
|
|
9
16
|
return /* @__PURE__ */ jsx(Controller, {
|
|
10
17
|
control: formControl.control,
|
|
11
18
|
name: formControl.name,
|
|
12
|
-
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
19
|
+
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
13
20
|
...innerProps,
|
|
14
21
|
ref: mergeRefs(ref, field.ref),
|
|
15
22
|
value: field.value,
|
|
16
23
|
onChange: field.onChange,
|
|
17
24
|
onBlur: field.onBlur,
|
|
25
|
+
isDirty,
|
|
18
26
|
isDisabled: field.disabled || props.isDisabled,
|
|
19
27
|
error: props.error ?? error?.message,
|
|
20
|
-
isSearchable: true
|
|
28
|
+
isSearchable: true,
|
|
29
|
+
ignoreInputValueFiltering
|
|
21
30
|
})
|
|
22
31
|
});
|
|
23
32
|
}
|
|
@@ -25,6 +34,92 @@ var Autocomplete = (props) => {
|
|
|
25
34
|
...props,
|
|
26
35
|
isSearchable: true
|
|
27
36
|
});
|
|
28
|
-
}
|
|
37
|
+
}
|
|
38
|
+
function Autocomplete({ renderStaticInput, ...props }) {
|
|
39
|
+
const ui = UIConfig.useConfig();
|
|
40
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
41
|
+
const rootRef = useRef(null);
|
|
42
|
+
const { renderRealInput, replayStaticInputChange } = useStaticInputHandoff({
|
|
43
|
+
inputRef: rootRef,
|
|
44
|
+
renderInput,
|
|
45
|
+
setRenderInput,
|
|
46
|
+
getFocusTarget: (root) => root.querySelector("input, [data-type='select-trigger'], button, [tabindex]")
|
|
47
|
+
});
|
|
48
|
+
const currentValue = ("formControl" in props && props.formControl ? useWatch({
|
|
49
|
+
control: props.formControl.control,
|
|
50
|
+
name: props.formControl.name
|
|
51
|
+
}) : props.value) ?? props.value;
|
|
52
|
+
let isFormControlDisabled = false;
|
|
53
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
54
|
+
if (!renderInput && !!props.customTrigger) setRenderInput(true);
|
|
55
|
+
if (!renderInput) {
|
|
56
|
+
const as = props.as ?? ui.input.as;
|
|
57
|
+
let isDisabled = !!props.isDisabled;
|
|
58
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
59
|
+
const mode = props.selectionMode ?? ui.select.selectionMode;
|
|
60
|
+
const { selectedItem, displayValue, isEmpty } = getStaticSelectValue({
|
|
61
|
+
items: props.items,
|
|
62
|
+
value: currentValue,
|
|
63
|
+
selectionMode: mode,
|
|
64
|
+
initialSelection: props.initialSelection,
|
|
65
|
+
mapInitialToSelectItem: props.mapInitialToSelectItem,
|
|
66
|
+
showSelectionContent: props.showSelectionContent,
|
|
67
|
+
isDisabled,
|
|
68
|
+
collapseAfter: props.collapseAfter ?? ui.select.collapseAfter,
|
|
69
|
+
selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
|
|
70
|
+
});
|
|
71
|
+
const isMultiple = mode === "multiple";
|
|
72
|
+
const trailingContent = props.trailingContent || !props.hideDropdownIcon ? /* @__PURE__ */ jsxs(Fragment, { children: [props.trailingContent, !props.hideDropdownIcon ? /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: "size-6 shrink-0 text-interactive-text-secondary-idle" }) : void 0] }) : void 0;
|
|
73
|
+
const placeholder = as === "floating" ? null : props.placeholder;
|
|
74
|
+
const shouldRenderPlaceholderAfterValue = mode !== "single" && props.placeholder && !isEmpty;
|
|
75
|
+
const inputValue = !isMultiple && selectedItem ? selectedItem.label : "";
|
|
76
|
+
const dataAttributes = {
|
|
77
|
+
dataIsEmpty: isEmpty,
|
|
78
|
+
dataIsFilled: !isEmpty,
|
|
79
|
+
dataIsDirty: props.isDirty,
|
|
80
|
+
dataIsRequired: props.isRequired,
|
|
81
|
+
dataIsDisabled: isDisabled,
|
|
82
|
+
dataDisabled: isDisabled,
|
|
83
|
+
dataInvalid: !!props.error,
|
|
84
|
+
dataHasSelection: !isEmpty,
|
|
85
|
+
dataHasSearch: false
|
|
86
|
+
};
|
|
87
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
88
|
+
...props,
|
|
89
|
+
isDisabled,
|
|
90
|
+
className: clsx("w-full", props.containerClassName),
|
|
91
|
+
inputClassName: clsx("px-0!", props.className, props.inputClassName),
|
|
92
|
+
contentWrapperClassName: "flex flex-1 flex-wrap gap-input-gap-input-text-to-elements truncate",
|
|
93
|
+
labelPlacement: "content-row",
|
|
94
|
+
dataAttributes,
|
|
95
|
+
renderStatic: true,
|
|
96
|
+
onStaticInteract: renderRealInput,
|
|
97
|
+
trailingClassName: "pl-1-5",
|
|
98
|
+
leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
|
|
99
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
100
|
+
children: props.leadingContent
|
|
101
|
+
}),
|
|
102
|
+
trailingContent,
|
|
103
|
+
children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [isMultiple && !isEmpty && displayValue, /* @__PURE__ */ jsx("input", {
|
|
104
|
+
disabled: isDisabled,
|
|
105
|
+
tabIndex: -1,
|
|
106
|
+
role: "combobox",
|
|
107
|
+
"aria-autocomplete": "list",
|
|
108
|
+
"aria-controls": `${dataAttributeProps.id}-listbox`,
|
|
109
|
+
"aria-expanded": false,
|
|
110
|
+
value: inputValue,
|
|
111
|
+
placeholder: isMultiple && shouldRenderPlaceholderAfterValue ? props.placeholder : placeholder ?? void 0,
|
|
112
|
+
className: clsx("w-full flex-1 bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.inputClassName),
|
|
113
|
+
onChange: (event) => replayStaticInputChange(event.target.value),
|
|
114
|
+
...dataAttributeProps,
|
|
115
|
+
"data-rac": true
|
|
116
|
+
})] })
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return /* @__PURE__ */ jsx(_Autocomplete, {
|
|
120
|
+
...props,
|
|
121
|
+
ref: mergeRefs(props.ref, rootRef)
|
|
122
|
+
});
|
|
123
|
+
}
|
|
29
124
|
//#endregion
|
|
30
125
|
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>({ query, queryParams, queryOptions, queryMap, leadingContent, ...props }: QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +1,44 @@
|
|
|
1
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
1
2
|
import { Autocomplete } from "./Autocomplete.js";
|
|
3
|
+
import { getQueryItems } from "../shared/querySelect.utils.js";
|
|
4
|
+
import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
|
|
2
5
|
import { jsx } from "react/jsx-runtime";
|
|
3
6
|
import { useState } from "react";
|
|
4
7
|
//#region src/components/inputs/Selection/Autocomplete/QueryAutocomplete.tsx
|
|
5
|
-
var QueryAutocomplete = ({ query, queryParams, queryOptions, ...props }) => {
|
|
8
|
+
var QueryAutocomplete = ({ query, queryParams, queryOptions, queryMap, leadingContent, ...props }) => {
|
|
9
|
+
const ui = UIConfig.useConfig();
|
|
6
10
|
const [search, setSearch] = useState("");
|
|
7
|
-
const {
|
|
11
|
+
const { onChange, ...restProps } = props;
|
|
12
|
+
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
|
|
13
|
+
query,
|
|
14
|
+
queryParams,
|
|
15
|
+
queryOptions,
|
|
16
|
+
mapItems: (data) => getQueryItems(data, queryMap),
|
|
8
17
|
search,
|
|
9
|
-
|
|
10
|
-
}
|
|
18
|
+
initialQueryState: props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled
|
|
19
|
+
});
|
|
20
|
+
const handleChange = (value) => {
|
|
21
|
+
onChange?.(value);
|
|
22
|
+
props.onBlur?.({ target: { value: null } });
|
|
23
|
+
};
|
|
24
|
+
const { isInitialQueryDisabled: _, ...autocompleteProps } = restProps;
|
|
25
|
+
const onSearchChange = (value) => {
|
|
26
|
+
setSearch(value);
|
|
27
|
+
handleEnableQuery();
|
|
28
|
+
};
|
|
11
29
|
return /* @__PURE__ */ jsx(Autocomplete, {
|
|
12
|
-
...
|
|
13
|
-
items
|
|
14
|
-
|
|
30
|
+
...autocompleteProps,
|
|
31
|
+
items,
|
|
32
|
+
totalItems,
|
|
33
|
+
onSearchChange,
|
|
15
34
|
isClientSearchDisabled: true,
|
|
16
|
-
isLoading
|
|
35
|
+
isLoading,
|
|
36
|
+
onChange: handleChange,
|
|
37
|
+
onMouseEnter: handleEnableQuery,
|
|
38
|
+
onFocusCapture: handleEnableQuery,
|
|
39
|
+
leadingContent,
|
|
40
|
+
hasLoadMore: hasNextPage,
|
|
41
|
+
onLoadMore: fetchNextPage
|
|
17
42
|
});
|
|
18
43
|
};
|
|
19
44
|
//#endregion
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
2
|
+
import { SelectProps } from './Select';
|
|
3
|
+
import { QueryDataType, QueryFn } from '../shared/querySelect.utils';
|
|
4
|
+
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
5
|
+
import { Key } from 'react-aria-components';
|
|
6
|
+
import { FieldValues } from 'react-hook-form';
|
|
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>({ query, queryParams, queryOptions, queryMap, ...props }: QuerySelectProps<TFieldValues, TQueryFn, TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
|
+
import { Select } from "./Select.js";
|
|
3
|
+
import { getQueryItems } from "../shared/querySelect.utils.js";
|
|
4
|
+
import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
//#region src/components/inputs/Selection/Select/QuerySelect.tsx
|
|
8
|
+
var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
|
|
9
|
+
const ui = UIConfig.useConfig();
|
|
10
|
+
const [search, setSearch] = useState("");
|
|
11
|
+
const isSearchable = props.isSearchable ?? ui.select.isSearchable;
|
|
12
|
+
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
|
|
13
|
+
query,
|
|
14
|
+
queryParams,
|
|
15
|
+
queryOptions,
|
|
16
|
+
mapItems: (data) => getQueryItems(data, queryMap),
|
|
17
|
+
search: isSearchable ? search : void 0,
|
|
18
|
+
initialQueryState: props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled
|
|
19
|
+
});
|
|
20
|
+
const { isInitialQueryDisabled: _, onSearchChange, ...selectProps } = props;
|
|
21
|
+
const handleSearchChange = (value) => {
|
|
22
|
+
setSearch(value);
|
|
23
|
+
handleEnableQuery();
|
|
24
|
+
onSearchChange?.(value);
|
|
25
|
+
};
|
|
26
|
+
return /* @__PURE__ */ jsx(Select, {
|
|
27
|
+
...selectProps,
|
|
28
|
+
items,
|
|
29
|
+
isLoading,
|
|
30
|
+
totalItems,
|
|
31
|
+
hasLoadMore: hasNextPage,
|
|
32
|
+
onLoadMore: fetchNextPage,
|
|
33
|
+
onMouseEnter: handleEnableQuery,
|
|
34
|
+
onFocusCapture: handleEnableQuery,
|
|
35
|
+
...isSearchable && {
|
|
36
|
+
isClientSearchDisabled: true,
|
|
37
|
+
onSearchChange: handleSearchChange
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
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;
|
|
@@ -1,26 +1,136 @@
|
|
|
1
|
+
import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
|
|
2
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
4
|
+
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
1
5
|
import { SelectBase } from "../shared/SelectBase.js";
|
|
2
|
-
import {
|
|
6
|
+
import { getStaticSelectValue } from "../shared/staticSelect.utils.js";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { clsx } from "clsx";
|
|
9
|
+
import { useRef, useState } from "react";
|
|
3
10
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
|
-
import { Controller } from "react-hook-form";
|
|
11
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
5
12
|
//#region src/components/inputs/Selection/Select/Select.tsx
|
|
6
|
-
|
|
13
|
+
function _Select(props) {
|
|
7
14
|
if ("formControl" in props && props.formControl) {
|
|
8
15
|
const { formControl, ref, ...innerProps } = props;
|
|
9
16
|
return /* @__PURE__ */ jsx(Controller, {
|
|
10
17
|
control: formControl.control,
|
|
11
18
|
name: formControl.name,
|
|
12
|
-
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
19
|
+
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
13
20
|
...innerProps,
|
|
14
21
|
ref: mergeRefs(ref, field.ref),
|
|
15
22
|
value: field.value,
|
|
16
23
|
onChange: field.onChange,
|
|
17
24
|
onBlur: field.onBlur,
|
|
25
|
+
isDirty,
|
|
18
26
|
isDisabled: field.disabled || props.isDisabled,
|
|
19
27
|
error: props.error ?? error?.message
|
|
20
28
|
})
|
|
21
29
|
});
|
|
22
30
|
}
|
|
23
31
|
return /* @__PURE__ */ jsx(SelectBase, { ...props });
|
|
24
|
-
}
|
|
32
|
+
}
|
|
33
|
+
function Select({ renderStaticInput, ...props }) {
|
|
34
|
+
const ui = UIConfig.useConfig();
|
|
35
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
36
|
+
const rootRef = useRef(null);
|
|
37
|
+
const { renderRealInput, replayStaticInputChange } = useStaticInputHandoff({
|
|
38
|
+
inputRef: rootRef,
|
|
39
|
+
renderInput,
|
|
40
|
+
setRenderInput,
|
|
41
|
+
getFocusTarget: (root) => root.querySelector("[data-type='select-trigger'], input, button, [tabindex]")
|
|
42
|
+
});
|
|
43
|
+
const currentValue = ("formControl" in props && props.formControl ? useWatch({
|
|
44
|
+
control: props.formControl.control,
|
|
45
|
+
name: props.formControl.name
|
|
46
|
+
}) : props.value) ?? props.value;
|
|
47
|
+
let isFormControlDisabled = false;
|
|
48
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
49
|
+
if (!renderInput && props.selectionMode !== "multiple" && !!props.showSelectionContent && currentValue != null) setRenderInput(true);
|
|
50
|
+
if (!renderInput && !!props.customTrigger) setRenderInput(true);
|
|
51
|
+
if (!renderInput) {
|
|
52
|
+
const as = props.as ?? ui.input.as;
|
|
53
|
+
let isDisabled = !!props.isDisabled;
|
|
54
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
55
|
+
const mode = props.selectionMode ?? ui.select.selectionMode;
|
|
56
|
+
const isMultiple = mode === "multiple";
|
|
57
|
+
const { selectedItem, displayValue, isEmpty } = getStaticSelectValue({
|
|
58
|
+
items: props.items,
|
|
59
|
+
value: currentValue,
|
|
60
|
+
selectionMode: mode,
|
|
61
|
+
initialSelection: props.initialSelection,
|
|
62
|
+
mapInitialToSelectItem: props.mapInitialToSelectItem,
|
|
63
|
+
showSelectionContent: props.showSelectionContent,
|
|
64
|
+
isDisabled,
|
|
65
|
+
collapseAfter: props.collapseAfter ?? ui.select.collapseAfter,
|
|
66
|
+
selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
|
|
67
|
+
});
|
|
68
|
+
const isSearchable = props.isSearchable ?? ui.select.isSearchable;
|
|
69
|
+
const trailingContent = props.trailingContent || !props.hideDropdownIcon ? /* @__PURE__ */ jsxs(Fragment, { children: [props.trailingContent, !props.hideDropdownIcon ? /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: `size-6 shrink-0 ${isDisabled ? "text-interactive-text-secondary-disabled" : "text-interactive-text-secondary-idle"}` }) : void 0] }) : void 0;
|
|
70
|
+
const placeholder = as === "floating" ? null : props.placeholder;
|
|
71
|
+
const inputValue = !isMultiple && selectedItem ? selectedItem.label : "";
|
|
72
|
+
const shouldRenderPlaceholderAfterValue = isMultiple && props.placeholder && !isEmpty;
|
|
73
|
+
const dataAttributes = {
|
|
74
|
+
dataIsEmpty: isEmpty,
|
|
75
|
+
dataIsFilled: !isEmpty,
|
|
76
|
+
dataIsDirty: props.isDirty,
|
|
77
|
+
dataIsRequired: props.isRequired,
|
|
78
|
+
dataIsDisabled: isDisabled,
|
|
79
|
+
dataDisabled: isDisabled,
|
|
80
|
+
dataInvalid: !!props.error,
|
|
81
|
+
dataHasSelection: !isEmpty,
|
|
82
|
+
dataHasSearch: false
|
|
83
|
+
};
|
|
84
|
+
const buttonContent = isMultiple && !isEmpty ? /* @__PURE__ */ jsx(Fragment, { children: "\xA0" }) : isEmpty ? /* @__PURE__ */ jsx("span", {
|
|
85
|
+
className: "text-text-default-3",
|
|
86
|
+
children: placeholder
|
|
87
|
+
}) : displayValue;
|
|
88
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
89
|
+
...props,
|
|
90
|
+
isDisabled,
|
|
91
|
+
className: clsx("w-full", props.containerClassName),
|
|
92
|
+
inputClassName: clsx("px-0!", props.className, props.inputClassName),
|
|
93
|
+
typographySize: "label-1",
|
|
94
|
+
labelPlacement: "content-row",
|
|
95
|
+
dataAttributes,
|
|
96
|
+
renderStatic: true,
|
|
97
|
+
trailingClassName: "pl-1-5",
|
|
98
|
+
onStaticInteract: renderRealInput,
|
|
99
|
+
leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
|
|
100
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
101
|
+
children: props.leadingContent
|
|
102
|
+
}),
|
|
103
|
+
showClear: false,
|
|
104
|
+
trailingContent,
|
|
105
|
+
children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [isMultiple && !isEmpty && displayValue, isSearchable ? /* @__PURE__ */ jsx("input", {
|
|
106
|
+
disabled: isDisabled,
|
|
107
|
+
tabIndex: -1,
|
|
108
|
+
role: "combobox",
|
|
109
|
+
"aria-autocomplete": "list",
|
|
110
|
+
"aria-controls": `${dataAttributeProps.id}-listbox`,
|
|
111
|
+
"aria-expanded": false,
|
|
112
|
+
value: inputValue,
|
|
113
|
+
placeholder: shouldRenderPlaceholderAfterValue ? props.placeholder : placeholder ?? void 0,
|
|
114
|
+
className: clsx("w-full flex-1 bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.inputClassName),
|
|
115
|
+
onChange: (event) => replayStaticInputChange(event.target.value),
|
|
116
|
+
...dataAttributeProps,
|
|
117
|
+
"data-rac": true
|
|
118
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
119
|
+
type: "button",
|
|
120
|
+
disabled: isDisabled,
|
|
121
|
+
tabIndex: -1,
|
|
122
|
+
"data-type": "select-trigger",
|
|
123
|
+
className: clsx("w-full truncate bg-transparent text-start outline-none disabled:text-interactive-text-secondary-disabled", isMultiple && !isEmpty && "absolute inset-0 z-0"),
|
|
124
|
+
...dataAttributeProps,
|
|
125
|
+
"data-rac": true,
|
|
126
|
+
children: buttonContent
|
|
127
|
+
})] })
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ jsx(_Select, {
|
|
131
|
+
...props,
|
|
132
|
+
ref: mergeRefs(props.ref, rootRef)
|
|
133
|
+
});
|
|
134
|
+
}
|
|
25
135
|
//#endregion
|
|
26
136
|
export { Select };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, Ref } from 'react';
|
|
1
|
+
import { FocusEventHandler, MouseEventHandler, ReactElement, ReactNode, Ref } from 'react';
|
|
2
2
|
import { AriaButtonProps } from 'react-aria';
|
|
3
3
|
import { Key } from 'react-aria-components';
|
|
4
4
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
@@ -7,21 +7,28 @@ import { InputVariantProps } from '../../shared/input.cva';
|
|
|
7
7
|
export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = FormFieldProps & GroupedSelectProps<TKey, TInitialSelectItem> & SelectNewItemProps & SelectAsyncProps & SelectVirtualizationProps & InputVariantProps & Pick<AriaButtonProps, "onBlur"> & {
|
|
8
8
|
ref?: Ref<HTMLDivElement>;
|
|
9
9
|
className?: string;
|
|
10
|
+
isDirty?: boolean;
|
|
10
11
|
placeholder?: string;
|
|
11
12
|
hideDropdownIcon?: boolean;
|
|
12
13
|
hideSearchIcon?: boolean;
|
|
13
14
|
isSearchable?: boolean;
|
|
14
15
|
isClearable?: boolean;
|
|
15
16
|
isClientSearchDisabled?: boolean;
|
|
17
|
+
ignoreInputValueFiltering?: boolean;
|
|
16
18
|
ignoreTriggerWidth?: boolean;
|
|
17
19
|
items: SelectItem<TKey>[];
|
|
18
20
|
inputClassName?: string;
|
|
19
21
|
containerClassName?: string;
|
|
22
|
+
leadingContent?: ReactNode;
|
|
23
|
+
trailingContent?: ReactNode;
|
|
20
24
|
customTrigger?: ReactElement;
|
|
21
25
|
selectedTagsType?: "tags" | "list";
|
|
22
26
|
collapseAfter?: number;
|
|
27
|
+
fireBlurOnChange?: boolean;
|
|
23
28
|
onInputChange?: (value: string) => void;
|
|
24
29
|
onSearchChange?: (value: string) => void;
|
|
25
30
|
mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
|
|
31
|
+
onMouseEnter?: MouseEventHandler<HTMLDivElement>;
|
|
32
|
+
onFocusCapture?: FocusEventHandler<HTMLDivElement>;
|
|
26
33
|
};
|
|
27
34
|
export declare const SelectBase: <TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(dProps: SelectBaseProps<TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,9 +17,11 @@ var SelectBase = (dProps) => {
|
|
|
17
17
|
isClearable: dProps.isClearable ?? ui.input.isClearable,
|
|
18
18
|
isSearchable: dProps.isSearchable ?? ui.select.isSearchable,
|
|
19
19
|
selectedTagsType: dProps.selectedTagsType ?? ui.select.selectedTagsType,
|
|
20
|
-
ignoreTriggerWidth: dProps.virtualizerOptions || dProps.
|
|
20
|
+
ignoreTriggerWidth: dProps.virtualizerOptions || (dProps.totalItems ?? 0) > 100 || dProps.hasLoadMore ? false : dProps.ignoreTriggerWidth ?? false,
|
|
21
21
|
collapseAfter: dProps.collapseAfter ?? ui.select.collapseAfter,
|
|
22
|
-
hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon
|
|
22
|
+
hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon,
|
|
23
|
+
fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange,
|
|
24
|
+
isClientSearchDisabled: dProps.ignoreInputValueFiltering ?? dProps.isClientSearchDisabled
|
|
23
25
|
};
|
|
24
26
|
const isDesktop = useBreakpoint("md");
|
|
25
27
|
return /* @__PURE__ */ jsx(SelectContext.Provider, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Key } from 'react-aria-components';
|
|
2
2
|
import { SelectBaseProps } from './SelectBase';
|
|
3
3
|
type SelectDesktopProps<TKey extends Key = Key> = SelectBaseProps<TKey>;
|
|
4
|
-
export declare const SelectDesktop: <TKey extends Key = Key>({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }: SelectDesktopProps<TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const SelectDesktop: <TKey extends Key = Key>({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectDesktopProps<TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export {};
|
|
@@ -6,6 +6,7 @@ import "./useSelectItems.js";
|
|
|
6
6
|
import { SelectContext } from "./select.context.js";
|
|
7
7
|
import { SelectInput } from "./SelectInput.js";
|
|
8
8
|
import { SelectListBox } from "./SelectListBox.js";
|
|
9
|
+
import { selectPopoverCva } from "./selectDesktop.cva.js";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { clsx } from "clsx";
|
|
11
12
|
import { Fragment as Fragment$1, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
@@ -13,9 +14,10 @@ import { ComboBox, DialogTrigger, Popover } from "react-aria-components";
|
|
|
13
14
|
import { useLabel, usePreventScroll } from "react-aria";
|
|
14
15
|
import { mergeRefs } from "@react-aria/utils";
|
|
15
16
|
//#region src/components/inputs/Selection/shared/SelectDesktop.tsx
|
|
16
|
-
var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }) => {
|
|
17
|
-
const { label, tooltipText, helperText, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, isSearchable, isClearable, isLoading, as, size, collapseAfter, selectedTagsType } = props;
|
|
17
|
+
var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
|
|
18
|
+
const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, isSearchable, isClearable, isLoading, as, size, collapseAfter, selectedTagsType } = props;
|
|
18
19
|
const popoverCva = UIStyle.useCva("popover.cva", popover);
|
|
20
|
+
const selectPopoverCva$1 = UIStyle.useCva("select.popoverCva", selectPopoverCva);
|
|
19
21
|
const formFieldProps = {
|
|
20
22
|
error,
|
|
21
23
|
label,
|
|
@@ -113,6 +115,8 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
|
|
|
113
115
|
className: clsx("w-full", containerClassName)
|
|
114
116
|
},
|
|
115
117
|
as,
|
|
118
|
+
onMouseEnter,
|
|
119
|
+
onFocusCapture,
|
|
116
120
|
ref: wrapperRef,
|
|
117
121
|
children: [customTrigger ? /* @__PURE__ */ jsx(DialogTrigger, {
|
|
118
122
|
...dialogTriggerProps,
|
|
@@ -135,8 +139,12 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
|
|
|
135
139
|
isClearable,
|
|
136
140
|
showSelectionContent,
|
|
137
141
|
inputClassName,
|
|
142
|
+
leadingContent,
|
|
143
|
+
trailingContent,
|
|
138
144
|
collapseAfter,
|
|
139
145
|
selectedTagsType,
|
|
146
|
+
isRequired,
|
|
147
|
+
isDirty,
|
|
140
148
|
onBlur,
|
|
141
149
|
onCloseComboBox: (state) => {
|
|
142
150
|
if (isSearchable) closeComboBoxRef.current = state;
|
|
@@ -147,7 +155,7 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
|
|
|
147
155
|
triggerRef,
|
|
148
156
|
isOpen,
|
|
149
157
|
onOpenChange: setIsOpen,
|
|
150
|
-
className:
|
|
158
|
+
className: selectPopoverCva$1({}),
|
|
151
159
|
style: { width: !ignoreTriggerWidth ? popoverWidth : void 0 },
|
|
152
160
|
offset: 0,
|
|
153
161
|
children: /* @__PURE__ */ jsx(SelectListBox, {
|
|
@@ -4,12 +4,12 @@ import { FormFieldHeaderProps } from '../../FormField/FormFieldHeader';
|
|
|
4
4
|
import { SelectBaseProps } from './SelectBase';
|
|
5
5
|
import { SelectItem } from './select.types';
|
|
6
6
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
7
|
-
interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter"> {
|
|
7
|
+
interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter" | "isRequired" | "isDirty" | "fireBlurOnChange" | "leadingContent" | "trailingContent" | "onMouseEnter" | "onFocusCapture"> {
|
|
8
8
|
isInvalid?: boolean;
|
|
9
9
|
className?: string;
|
|
10
10
|
fieldProps?: AriaFieldProps;
|
|
11
11
|
headerProps?: FormFieldHeaderProps;
|
|
12
12
|
onCloseComboBox?: (state: ComboBoxState<SelectItem> | null) => void;
|
|
13
13
|
}
|
|
14
|
-
export declare const SelectInput: ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, onCloseComboBox, onBlur, ...props }: SelectInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const SelectInput: ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, leadingContent, trailingContent, onMouseEnter, onFocusCapture, ...props }: SelectInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
export {};
|