@povio/ui 2.2.9-rc.3 → 2.2.9-rc.30
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/Button/Button.d.ts +2 -1
- package/dist/components/buttons/Button/Button.js +41 -32
- 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 +8 -3
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +88 -6
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +91 -6
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +91 -7
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +73 -4
- 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/DateField.js +3 -10
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +65 -55
- 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.js +4 -2
- 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.js +9 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -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.js +3 -1
- 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 +85 -7
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +38 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +318 -0
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +88 -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 +15 -18
- package/dist/components/inputs/Inputs/InputItem.js +2 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.js +17 -9
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +104 -6
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +15 -10
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -4
- package/dist/components/inputs/Selection/Select/QuerySelect.js +8 -35
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +119 -4
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +13 -2
- 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 +5 -3
- 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 +68 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +171 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +1 -0
- 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/StaticInput.js +104 -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/config/uiConfig.context.d.ts +8 -2
- package/dist/config/uiConfig.context.js +12 -1
- package/dist/config/uiStyle.context.d.ts +20 -3
- package/dist/helpers/dynamicInputs.d.ts +1 -1
- package/dist/helpers/dynamicInputs.js +3 -0
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +29 -10
- package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
- package/dist/hooks/useQueryAutocomplete.js +13 -3
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -2
- package/dist/utils/date-time.utils.d.ts +30 -9
- package/dist/utils/date-time.utils.js +113 -1
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { UIStyle } from "../../../config/uiStyle.context.js";
|
|
|
2
2
|
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
3
3
|
import { CheckContent } from "../shared/CheckContent.js";
|
|
4
4
|
import { FormField } from "../FormField/FormField.js";
|
|
5
|
-
import { radio, radioIndicatorClass, radioTypography } from "./radio.cva.js";
|
|
5
|
+
import { radio, radioContentClassName, radioIndicatorClass, radioTypography } from "./radio.cva.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { Radio, RadioGroup } from "react-aria-components";
|
|
@@ -13,7 +13,20 @@ var RadioGroupBase = (props) => {
|
|
|
13
13
|
const ui = UIConfig.useConfig();
|
|
14
14
|
const radioCva = UIStyle.useCva("radio.cva", radio);
|
|
15
15
|
const radioTypographyMap = UIStyle.useMapper("radio.typography", radioTypography);
|
|
16
|
+
const radioContentClassNameMap = UIStyle.useMapper("radio.contentClassName", radioContentClassName);
|
|
16
17
|
const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isDisabled, headerClassName, errorClassName, labelClassName, inputClassName, isHeaderHidden, error, className, options, variant = ui.radioGroup.variant, hideLabel = ui.radioGroup.hideLabel, ...rest } = props;
|
|
18
|
+
const radioClassName = radioCva({
|
|
19
|
+
variant,
|
|
20
|
+
...rest
|
|
21
|
+
});
|
|
22
|
+
const radioTypographyProps = radioTypographyMap({
|
|
23
|
+
variant,
|
|
24
|
+
...rest
|
|
25
|
+
});
|
|
26
|
+
const radioContentClassNameValue = radioContentClassNameMap({
|
|
27
|
+
variant,
|
|
28
|
+
...rest
|
|
29
|
+
});
|
|
17
30
|
const formFieldProps = {
|
|
18
31
|
className,
|
|
19
32
|
error,
|
|
@@ -41,14 +54,9 @@ var RadioGroupBase = (props) => {
|
|
|
41
54
|
children: options.map((option) => /* @__PURE__ */ jsxs(Radio, {
|
|
42
55
|
value: option.value,
|
|
43
56
|
className: clsx("relative", radioIndicatorClass),
|
|
44
|
-
children: [/* @__PURE__ */ jsx("div", { className:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}) }), /* @__PURE__ */ jsx(CheckContent, {
|
|
48
|
-
typography: radioTypographyMap({
|
|
49
|
-
variant,
|
|
50
|
-
...rest
|
|
51
|
-
}),
|
|
57
|
+
children: [/* @__PURE__ */ jsx("div", { className: radioClassName }), /* @__PURE__ */ jsx(CheckContent, {
|
|
58
|
+
typography: radioTypographyProps,
|
|
59
|
+
contentClassName: radioContentClassNameValue,
|
|
52
60
|
className: labelClassName,
|
|
53
61
|
children: option.label
|
|
54
62
|
})]
|
|
@@ -9,3 +9,6 @@ export declare const radioIndicatorClass = "group flex items-center gap-2";
|
|
|
9
9
|
export declare const radioTypography: (props: {
|
|
10
10
|
variant?: "default" | null | undefined;
|
|
11
11
|
}) => TypographyVariantProps | undefined;
|
|
12
|
+
export declare const radioContentClassName: (props: {
|
|
13
|
+
variant?: "default" | null | undefined;
|
|
14
|
+
}) => string | undefined;
|
|
@@ -31,5 +31,6 @@ var radioTypography = compoundMapper({ default: {
|
|
|
31
31
|
sizeMobile: "label-1",
|
|
32
32
|
variant: "default"
|
|
33
33
|
} });
|
|
34
|
+
var radioContentClassName = compoundMapper({ default: "text-text-default-2" });
|
|
34
35
|
//#endregion
|
|
35
|
-
export { radio, radioIndicatorClass, radioTypography };
|
|
36
|
+
export { radio, radioContentClassName, radioIndicatorClass, radioTypography };
|
|
@@ -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 } from '../shared/select.types';
|
|
5
6
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
6
|
-
export type AutocompleteProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>, "isSearchable"
|
|
7
|
+
export type AutocompleteProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>, "isSearchable"> & {
|
|
8
|
+
renderStaticInput?: boolean;
|
|
9
|
+
};
|
|
7
10
|
export type ControlledAutocompleteProps<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = Omit<AutocompleteProps<TKey, TInitialSelectItem>, keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey, TInitialSelectItem>;
|
|
8
|
-
export declare
|
|
11
|
+
export declare function Autocomplete<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: AutocompleteProps<TKey, TInitialSelectItem>): ReactElement;
|
|
12
|
+
export declare function Autocomplete<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: ControlledAutocompleteProps<TFieldValues, TKey, TInitialSelectItem>): ReactElement;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
|
|
2
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
1
4
|
import { SelectBase } from "../shared/SelectBase.js";
|
|
2
|
-
import {
|
|
5
|
+
import { getStaticSelectValue } from "../shared/staticSelect.utils.js";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { clsx } from "clsx";
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
9
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
|
-
import { Controller } from "react-hook-form";
|
|
10
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
5
11
|
//#region src/components/inputs/Selection/Autocomplete/Autocomplete.tsx
|
|
6
|
-
|
|
12
|
+
function _Autocomplete(props) {
|
|
7
13
|
if ("formControl" in props && props.formControl) {
|
|
8
|
-
const { formControl, ref, ...innerProps } = props;
|
|
14
|
+
const { ignoreInputValueFiltering = true, formControl, ref, ...innerProps } = props;
|
|
9
15
|
return /* @__PURE__ */ jsx(Controller, {
|
|
10
16
|
control: formControl.control,
|
|
11
17
|
name: formControl.name,
|
|
@@ -18,7 +24,8 @@ var Autocomplete = (props) => {
|
|
|
18
24
|
isDirty,
|
|
19
25
|
isDisabled: field.disabled || props.isDisabled,
|
|
20
26
|
error: props.error ?? error?.message,
|
|
21
|
-
isSearchable: true
|
|
27
|
+
isSearchable: true,
|
|
28
|
+
ignoreInputValueFiltering
|
|
22
29
|
})
|
|
23
30
|
});
|
|
24
31
|
}
|
|
@@ -26,6 +33,97 @@ var Autocomplete = (props) => {
|
|
|
26
33
|
...props,
|
|
27
34
|
isSearchable: true
|
|
28
35
|
});
|
|
29
|
-
}
|
|
36
|
+
}
|
|
37
|
+
function Autocomplete({ renderStaticInput, ...props }) {
|
|
38
|
+
const ui = UIConfig.useConfig();
|
|
39
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
40
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
41
|
+
const rootRef = useRef(null);
|
|
42
|
+
const currentValue = ("formControl" in props && props.formControl ? useWatch({
|
|
43
|
+
control: props.formControl.control,
|
|
44
|
+
name: props.formControl.name
|
|
45
|
+
}) : props.value) ?? props.value;
|
|
46
|
+
let isFormControlDisabled = false;
|
|
47
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
48
|
+
if (!renderInput && !!props.customTrigger) setRenderInput(true);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!renderInput || !shouldFocus) return;
|
|
51
|
+
requestAnimationFrame(() => {
|
|
52
|
+
(rootRef.current?.querySelector("input, [data-type='select-trigger'], button, [tabindex]"))?.focus();
|
|
53
|
+
});
|
|
54
|
+
setShouldFocus(false);
|
|
55
|
+
}, [renderInput, shouldFocus]);
|
|
56
|
+
if (!renderInput) {
|
|
57
|
+
const as = props.as ?? ui.input.as;
|
|
58
|
+
let isDisabled = !!props.isDisabled;
|
|
59
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
60
|
+
const mode = props.selectionMode ?? ui.select.selectionMode;
|
|
61
|
+
const { selectedItem, displayValue, isEmpty } = getStaticSelectValue({
|
|
62
|
+
items: props.items,
|
|
63
|
+
value: currentValue,
|
|
64
|
+
selectionMode: mode,
|
|
65
|
+
initialSelection: props.initialSelection,
|
|
66
|
+
mapInitialToSelectItem: props.mapInitialToSelectItem,
|
|
67
|
+
showSelectionContent: props.showSelectionContent,
|
|
68
|
+
isDisabled,
|
|
69
|
+
collapseAfter: props.collapseAfter ?? ui.select.collapseAfter,
|
|
70
|
+
selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
|
|
71
|
+
});
|
|
72
|
+
const isMultiple = mode === "multiple";
|
|
73
|
+
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;
|
|
74
|
+
const placeholder = as === "floating" ? null : props.placeholder;
|
|
75
|
+
const shouldRenderPlaceholderAfterValue = mode !== "single" && props.placeholder && !isEmpty;
|
|
76
|
+
const inputValue = !isMultiple && selectedItem ? selectedItem.label : "";
|
|
77
|
+
const dataAttributes = {
|
|
78
|
+
dataIsEmpty: isEmpty,
|
|
79
|
+
dataIsFilled: !isEmpty,
|
|
80
|
+
dataIsDirty: props.isDirty,
|
|
81
|
+
dataIsRequired: props.isRequired,
|
|
82
|
+
dataIsDisabled: isDisabled,
|
|
83
|
+
dataDisabled: isDisabled,
|
|
84
|
+
dataInvalid: !!props.error,
|
|
85
|
+
dataHasSelection: !isEmpty,
|
|
86
|
+
dataHasSearch: false
|
|
87
|
+
};
|
|
88
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
89
|
+
...props,
|
|
90
|
+
isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
|
|
91
|
+
hideLabel: props.hideLabel ?? ui.input.hideLabel,
|
|
92
|
+
isDisabled,
|
|
93
|
+
className: clsx("w-full", props.containerClassName),
|
|
94
|
+
inputClassName: clsx(props.className, props.inputClassName),
|
|
95
|
+
contentWrapperClassName: "flex flex-1 flex-wrap gap-input-gap-input-text-to-elements truncate",
|
|
96
|
+
labelPlacement: "content-row",
|
|
97
|
+
dataAttributes,
|
|
98
|
+
renderStatic: true,
|
|
99
|
+
onStaticInteract: (focus) => {
|
|
100
|
+
setShouldFocus(focus);
|
|
101
|
+
setRenderInput(true);
|
|
102
|
+
},
|
|
103
|
+
as,
|
|
104
|
+
size: props.size ?? ui.input.size,
|
|
105
|
+
variant: props.variant ?? ui.input.variant,
|
|
106
|
+
leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
|
|
107
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
108
|
+
children: props.leadingContent
|
|
109
|
+
}),
|
|
110
|
+
trailingContent,
|
|
111
|
+
children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [isMultiple && !isEmpty && displayValue, /* @__PURE__ */ jsx("input", {
|
|
112
|
+
readOnly: true,
|
|
113
|
+
disabled: isDisabled,
|
|
114
|
+
tabIndex: -1,
|
|
115
|
+
value: inputValue,
|
|
116
|
+
placeholder: isMultiple && shouldRenderPlaceholderAfterValue ? props.placeholder : placeholder ?? void 0,
|
|
117
|
+
className: clsx("w-full flex-1 bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.inputClassName),
|
|
118
|
+
...dataAttributeProps,
|
|
119
|
+
"data-rac": true
|
|
120
|
+
})] })
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return /* @__PURE__ */ jsx(_Autocomplete, {
|
|
124
|
+
...props,
|
|
125
|
+
ref: mergeRefs(props.ref, rootRef)
|
|
126
|
+
});
|
|
127
|
+
}
|
|
30
128
|
//#endregion
|
|
31
129
|
export { Autocomplete };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FieldValues } from 'react-hook-form';
|
|
2
2
|
import { QueryAutocompleteProps, QueryFn } from './queryAutocomplete.types';
|
|
3
3
|
import { SelectItem } from '../shared/select.types';
|
|
4
|
-
export declare const QueryAutocomplete: <TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn
|
|
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,35 +1,40 @@
|
|
|
1
1
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
2
|
import { Autocomplete } from "./Autocomplete.js";
|
|
3
|
+
import { getQueryItems } from "../shared/querySelect.utils.js";
|
|
3
4
|
import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
import { useState } from "react";
|
|
6
7
|
//#region src/components/inputs/Selection/Autocomplete/QueryAutocomplete.tsx
|
|
7
|
-
var QueryAutocomplete = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
|
|
8
|
+
var QueryAutocomplete = ({ query, queryParams, queryOptions, queryMap, leadingContent, ...props }) => {
|
|
8
9
|
const ui = UIConfig.useConfig();
|
|
9
10
|
const [search, setSearch] = useState("");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
return queryMap?.(extractedData) ?? extractedData;
|
|
13
|
-
};
|
|
14
|
-
const { items, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
|
|
11
|
+
const { onChange, ...restProps } = props;
|
|
12
|
+
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
|
|
15
13
|
query,
|
|
16
14
|
queryParams,
|
|
17
15
|
queryOptions,
|
|
18
|
-
mapItems: (data) =>
|
|
16
|
+
mapItems: (data) => getQueryItems(data, queryMap),
|
|
19
17
|
search,
|
|
20
18
|
initialQueryState: props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled
|
|
21
19
|
});
|
|
22
|
-
const
|
|
20
|
+
const handleChange = (value) => {
|
|
21
|
+
onChange?.(value);
|
|
22
|
+
props.onBlur?.({ target: { value: null } });
|
|
23
|
+
};
|
|
24
|
+
const { isInitialQueryDisabled: _, ...autocompleteProps } = restProps;
|
|
23
25
|
return /* @__PURE__ */ jsx(Autocomplete, {
|
|
24
|
-
...
|
|
26
|
+
...autocompleteProps,
|
|
25
27
|
items,
|
|
28
|
+
totalItems,
|
|
26
29
|
onSearchChange: setSearch,
|
|
27
30
|
isClientSearchDisabled: true,
|
|
28
31
|
isLoading,
|
|
32
|
+
onChange: handleChange,
|
|
29
33
|
onMouseEnter: handleEnableQuery,
|
|
30
34
|
onFocusCapture: handleEnableQuery,
|
|
35
|
+
leadingContent,
|
|
31
36
|
hasLoadMore: hasNextPage,
|
|
32
|
-
onLoadMore: fetchNextPage
|
|
37
|
+
onLoadMore: fetchNextPage
|
|
33
38
|
});
|
|
34
39
|
};
|
|
35
40
|
//#endregion
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
import { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
|
|
1
|
+
import { InfiniteData, UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { Key } from 'react-aria-components';
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { AutocompleteProps } from './Autocomplete';
|
|
5
5
|
import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
6
6
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
7
|
-
export
|
|
8
|
-
items
|
|
7
|
+
export type InfiniteQueryPage<TKey extends Key> = {
|
|
8
|
+
items?: SelectItem<TKey>[];
|
|
9
9
|
totalItems?: number;
|
|
10
|
-
}
|
|
11
|
-
export type QueryResult<
|
|
12
|
-
export type QueryFn
|
|
13
|
-
export type
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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"]>[];
|
|
21
25
|
isInitialQueryDisabled?: boolean;
|
|
22
26
|
};
|
|
23
|
-
export interface UseQueryAutocompleteOptions<
|
|
27
|
+
export interface UseQueryAutocompleteOptions<TQueryFn extends QueryFn, TKey extends Key = Key> {
|
|
24
28
|
query: TQueryFn;
|
|
25
|
-
queryParams?:
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
queryParams?: Omit<ExtractQueryParams<TQueryFn>, "search" | "limit"> & {
|
|
30
|
+
limit?: number;
|
|
31
|
+
};
|
|
32
|
+
queryOptions?: ExtractQueryOptions<TQueryFn>;
|
|
33
|
+
mapItems: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
|
|
28
34
|
initialQueryState?: boolean;
|
|
29
|
-
search
|
|
35
|
+
search?: string;
|
|
30
36
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
2
|
-
import {
|
|
1
|
+
import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
2
|
+
import { SelectProps } from './Select';
|
|
3
3
|
import { QueryDataType, QueryFn } from '../shared/querySelect.utils';
|
|
4
4
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
5
5
|
import { Key } from 'react-aria-components';
|
|
6
6
|
import { FieldValues } from 'react-hook-form';
|
|
7
|
-
type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key
|
|
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
8
|
query: TQueryFn;
|
|
9
9
|
queryParams?: Parameters<TQueryFn>[0];
|
|
10
10
|
queryOptions?: Parameters<TQueryFn>[1];
|
|
@@ -12,4 +12,3 @@ type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn
|
|
|
12
12
|
isInitialQueryDisabled?: boolean;
|
|
13
13
|
};
|
|
14
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;
|
|
15
|
-
export {};
|
|
@@ -1,53 +1,26 @@
|
|
|
1
1
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
|
-
import {
|
|
3
|
-
import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
|
|
2
|
+
import { Select } from "./Select.js";
|
|
4
3
|
import { getQueryItems } from "../shared/querySelect.utils.js";
|
|
4
|
+
import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { mergeRefs } from "@react-aria/utils";
|
|
7
|
-
import { Controller } from "react-hook-form";
|
|
8
6
|
//#region src/components/inputs/Selection/Select/QuerySelect.tsx
|
|
9
7
|
var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
|
|
10
8
|
const ui = UIConfig.useConfig();
|
|
11
|
-
const { items, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
|
|
9
|
+
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
|
|
12
10
|
query,
|
|
13
11
|
queryParams,
|
|
14
12
|
queryOptions,
|
|
15
13
|
mapItems: (data) => getQueryItems(data, queryMap),
|
|
16
14
|
initialQueryState: props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled
|
|
17
15
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
control: formControl.control,
|
|
22
|
-
name: formControl.name,
|
|
23
|
-
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
24
|
-
...innerProps,
|
|
25
|
-
ref: mergeRefs(ref, field.ref),
|
|
26
|
-
items,
|
|
27
|
-
isLoading,
|
|
28
|
-
hasLoadMore: hasNextPage,
|
|
29
|
-
onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0,
|
|
30
|
-
value: field.value,
|
|
31
|
-
onChange: (value) => {
|
|
32
|
-
field.onChange(value);
|
|
33
|
-
field.onBlur?.();
|
|
34
|
-
},
|
|
35
|
-
onBlur: field.onBlur,
|
|
36
|
-
isDirty,
|
|
37
|
-
isDisabled: field.disabled || props.isDisabled,
|
|
38
|
-
error: props.error ?? error?.message,
|
|
39
|
-
onMouseEnter: handleEnableQuery,
|
|
40
|
-
onFocusCapture: handleEnableQuery
|
|
41
|
-
})
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const { isInitialQueryDisabled: _, ...restProps } = props;
|
|
45
|
-
return /* @__PURE__ */ jsx(SelectBase, {
|
|
46
|
-
...restProps,
|
|
16
|
+
const { isInitialQueryDisabled: _, ...selectProps } = props;
|
|
17
|
+
return /* @__PURE__ */ jsx(Select, {
|
|
18
|
+
...selectProps,
|
|
47
19
|
items,
|
|
48
20
|
isLoading,
|
|
21
|
+
totalItems,
|
|
49
22
|
hasLoadMore: hasNextPage,
|
|
50
|
-
onLoadMore: fetchNextPage
|
|
23
|
+
onLoadMore: fetchNextPage,
|
|
51
24
|
onMouseEnter: handleEnableQuery,
|
|
52
25
|
onFocusCapture: handleEnableQuery
|
|
53
26
|
});
|
|
@@ -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,9 +1,15 @@
|
|
|
1
|
+
import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
|
|
2
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
1
4
|
import { SelectBase } from "../shared/SelectBase.js";
|
|
2
|
-
import {
|
|
5
|
+
import { getStaticSelectValue } from "../shared/staticSelect.utils.js";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { clsx } from "clsx";
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
9
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
|
-
import { Controller } from "react-hook-form";
|
|
10
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
5
11
|
//#region src/components/inputs/Selection/Select/Select.tsx
|
|
6
|
-
|
|
12
|
+
function _Select(props) {
|
|
7
13
|
if ("formControl" in props && props.formControl) {
|
|
8
14
|
const { formControl, ref, ...innerProps } = props;
|
|
9
15
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -22,6 +28,115 @@ var Select = (props) => {
|
|
|
22
28
|
});
|
|
23
29
|
}
|
|
24
30
|
return /* @__PURE__ */ jsx(SelectBase, { ...props });
|
|
25
|
-
}
|
|
31
|
+
}
|
|
32
|
+
function Select({ renderStaticInput, ...props }) {
|
|
33
|
+
const ui = UIConfig.useConfig();
|
|
34
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
35
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
36
|
+
const rootRef = useRef(null);
|
|
37
|
+
const currentValue = ("formControl" in props && props.formControl ? useWatch({
|
|
38
|
+
control: props.formControl.control,
|
|
39
|
+
name: props.formControl.name
|
|
40
|
+
}) : props.value) ?? props.value;
|
|
41
|
+
let isFormControlDisabled = false;
|
|
42
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
43
|
+
if (!renderInput && props.selectionMode !== "multiple" && !!props.showSelectionContent && currentValue != null) setRenderInput(true);
|
|
44
|
+
if (!renderInput && !!props.customTrigger) setRenderInput(true);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!renderInput || !shouldFocus) return;
|
|
47
|
+
requestAnimationFrame(() => {
|
|
48
|
+
(rootRef.current?.querySelector("[data-type='select-trigger'], input, button, [tabindex]"))?.focus();
|
|
49
|
+
});
|
|
50
|
+
setShouldFocus(false);
|
|
51
|
+
}, [renderInput, shouldFocus]);
|
|
52
|
+
if (!renderInput) {
|
|
53
|
+
const as = props.as ?? ui.input.as;
|
|
54
|
+
let isDisabled = !!props.isDisabled;
|
|
55
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
56
|
+
const isClearable = props.isClearable ?? ui.input.isClearable;
|
|
57
|
+
const mode = props.selectionMode ?? ui.select.selectionMode;
|
|
58
|
+
const isMultiple = mode === "multiple";
|
|
59
|
+
const { selectedItem, displayValue, isEmpty } = getStaticSelectValue({
|
|
60
|
+
items: props.items,
|
|
61
|
+
value: currentValue,
|
|
62
|
+
selectionMode: mode,
|
|
63
|
+
initialSelection: props.initialSelection,
|
|
64
|
+
mapInitialToSelectItem: props.mapInitialToSelectItem,
|
|
65
|
+
showSelectionContent: props.showSelectionContent,
|
|
66
|
+
isDisabled,
|
|
67
|
+
collapseAfter: props.collapseAfter ?? ui.select.collapseAfter,
|
|
68
|
+
selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
|
|
69
|
+
});
|
|
70
|
+
const isSearchable = props.isSearchable ?? ui.select.isSearchable;
|
|
71
|
+
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;
|
|
72
|
+
const placeholder = as === "floating" ? null : props.placeholder;
|
|
73
|
+
const inputValue = !isMultiple && selectedItem ? selectedItem.label : "";
|
|
74
|
+
const shouldRenderPlaceholderAfterValue = isMultiple && props.placeholder && !isEmpty;
|
|
75
|
+
const dataAttributes = {
|
|
76
|
+
dataIsEmpty: isEmpty,
|
|
77
|
+
dataIsFilled: !isEmpty,
|
|
78
|
+
dataIsDirty: props.isDirty,
|
|
79
|
+
dataIsRequired: props.isRequired,
|
|
80
|
+
dataIsDisabled: isDisabled,
|
|
81
|
+
dataDisabled: isDisabled,
|
|
82
|
+
dataInvalid: !!props.error,
|
|
83
|
+
dataHasSelection: !isEmpty,
|
|
84
|
+
dataHasSearch: false
|
|
85
|
+
};
|
|
86
|
+
const buttonContent = isMultiple && !isEmpty ? /* @__PURE__ */ jsx(Fragment, { children: "\xA0" }) : isEmpty ? /* @__PURE__ */ jsx("span", {
|
|
87
|
+
className: "text-text-default-3",
|
|
88
|
+
children: placeholder
|
|
89
|
+
}) : displayValue;
|
|
90
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
91
|
+
...props,
|
|
92
|
+
isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
|
|
93
|
+
hideLabel: props.hideLabel ?? ui.input.hideLabel,
|
|
94
|
+
isDisabled,
|
|
95
|
+
className: clsx("w-full", props.containerClassName),
|
|
96
|
+
inputClassName: clsx(props.className, props.inputClassName),
|
|
97
|
+
typographySize: "label-1",
|
|
98
|
+
labelPlacement: "content-row",
|
|
99
|
+
dataAttributes,
|
|
100
|
+
renderStatic: true,
|
|
101
|
+
onStaticInteract: (focus) => {
|
|
102
|
+
setShouldFocus(focus);
|
|
103
|
+
setRenderInput(true);
|
|
104
|
+
},
|
|
105
|
+
as,
|
|
106
|
+
size: props.size ?? ui.input.size,
|
|
107
|
+
variant: props.variant ?? ui.input.variant,
|
|
108
|
+
leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
110
|
+
children: props.leadingContent
|
|
111
|
+
}),
|
|
112
|
+
isClearable,
|
|
113
|
+
showClear: false,
|
|
114
|
+
trailingContent,
|
|
115
|
+
children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [isMultiple && !isEmpty && displayValue, isSearchable ? /* @__PURE__ */ jsx("input", {
|
|
116
|
+
readOnly: true,
|
|
117
|
+
disabled: isDisabled,
|
|
118
|
+
tabIndex: -1,
|
|
119
|
+
value: inputValue,
|
|
120
|
+
placeholder: shouldRenderPlaceholderAfterValue ? props.placeholder : placeholder ?? void 0,
|
|
121
|
+
className: clsx("w-full flex-1 bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.inputClassName),
|
|
122
|
+
...dataAttributeProps,
|
|
123
|
+
"data-rac": true
|
|
124
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
125
|
+
type: "button",
|
|
126
|
+
disabled: isDisabled,
|
|
127
|
+
tabIndex: -1,
|
|
128
|
+
"data-type": "select-trigger",
|
|
129
|
+
className: clsx("w-full truncate bg-transparent text-start outline-none disabled:text-interactive-text-secondary-disabled", isMultiple && !isEmpty && "absolute inset-0 z-0"),
|
|
130
|
+
...dataAttributeProps,
|
|
131
|
+
"data-rac": true,
|
|
132
|
+
children: buttonContent
|
|
133
|
+
})] })
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return /* @__PURE__ */ jsx(_Select, {
|
|
137
|
+
...props,
|
|
138
|
+
ref: mergeRefs(props.ref, rootRef)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
26
141
|
//#endregion
|
|
27
142
|
export { Select };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FocusEventHandler, MouseEventHandler, 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';
|
|
@@ -14,10 +14,13 @@ export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = Default
|
|
|
14
14
|
isSearchable?: boolean;
|
|
15
15
|
isClearable?: boolean;
|
|
16
16
|
isClientSearchDisabled?: boolean;
|
|
17
|
+
ignoreInputValueFiltering?: boolean;
|
|
17
18
|
ignoreTriggerWidth?: boolean;
|
|
18
19
|
items: SelectItem<TKey>[];
|
|
19
20
|
inputClassName?: string;
|
|
20
21
|
containerClassName?: string;
|
|
22
|
+
leadingContent?: ReactNode;
|
|
23
|
+
trailingContent?: ReactNode;
|
|
21
24
|
customTrigger?: ReactElement;
|
|
22
25
|
selectedTagsType?: "tags" | "list";
|
|
23
26
|
collapseAfter?: number;
|
|
@@ -17,10 +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
22
|
hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon,
|
|
23
|
-
fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange
|
|
23
|
+
fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange,
|
|
24
|
+
isClientSearchDisabled: dProps.ignoreInputValueFiltering ?? dProps.isClientSearchDisabled
|
|
24
25
|
};
|
|
25
26
|
const isDesktop = useBreakpoint("md");
|
|
26
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, onMouseEnter, onFocusCapture, ...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 {};
|