@povio/ui 2.2.9-rc.4 → 2.2.9-rc.40
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 +81 -6
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +83 -5
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +84 -7
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +60 -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.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 +78 -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 +233 -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 +77 -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 +12 -9
- package/dist/components/inputs/Inputs/InputItem.js +2 -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 +98 -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 -3
- 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 +111 -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 +77 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +200 -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/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/uiConfig.context.d.ts +8 -2
- package/dist/config/uiConfig.context.js +12 -1
- package/dist/config/uiStyle.context.d.ts +27 -4
- 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 +20 -5
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -2
- package/dist/tw-ui-plugin.js +2 -0
- 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
|
@@ -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,16 @@
|
|
|
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, {
|
|
@@ -22,6 +29,106 @@ var Select = (props) => {
|
|
|
22
29
|
});
|
|
23
30
|
}
|
|
24
31
|
return /* @__PURE__ */ jsx(SelectBase, { ...props });
|
|
25
|
-
}
|
|
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(props.className, props.inputClassName),
|
|
93
|
+
typographySize: "label-1",
|
|
94
|
+
labelPlacement: "content-row",
|
|
95
|
+
dataAttributes,
|
|
96
|
+
renderStatic: true,
|
|
97
|
+
onStaticInteract: renderRealInput,
|
|
98
|
+
leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
|
|
99
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
100
|
+
children: props.leadingContent
|
|
101
|
+
}),
|
|
102
|
+
showClear: false,
|
|
103
|
+
trailingContent,
|
|
104
|
+
children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [isMultiple && !isEmpty && displayValue, isSearchable ? /* @__PURE__ */ jsx("input", {
|
|
105
|
+
disabled: isDisabled,
|
|
106
|
+
tabIndex: -1,
|
|
107
|
+
value: inputValue,
|
|
108
|
+
placeholder: shouldRenderPlaceholderAfterValue ? props.placeholder : placeholder ?? void 0,
|
|
109
|
+
className: clsx("w-full flex-1 bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.inputClassName),
|
|
110
|
+
onChange: (event) => {
|
|
111
|
+
props?.onMouseEnter?.({});
|
|
112
|
+
replayStaticInputChange(event.target.value);
|
|
113
|
+
},
|
|
114
|
+
...dataAttributeProps,
|
|
115
|
+
"data-rac": true
|
|
116
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
117
|
+
type: "button",
|
|
118
|
+
disabled: isDisabled,
|
|
119
|
+
tabIndex: -1,
|
|
120
|
+
"data-type": "select-trigger",
|
|
121
|
+
className: clsx("w-full truncate bg-transparent text-start outline-none disabled:text-interactive-text-secondary-disabled", isMultiple && !isEmpty && "absolute inset-0 z-0"),
|
|
122
|
+
...dataAttributeProps,
|
|
123
|
+
"data-rac": true,
|
|
124
|
+
children: buttonContent
|
|
125
|
+
})] })
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ jsx(_Select, {
|
|
129
|
+
...props,
|
|
130
|
+
ref: mergeRefs(props.ref, rootRef)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
26
133
|
//#endregion
|
|
27
134
|
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 {};
|
|
@@ -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, onMouseEnter, onFocusCapture, ...props }) => {
|
|
17
|
+
var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
|
|
17
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,14 +115,14 @@ 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,
|
|
119
123
|
children: /* @__PURE__ */ jsx("div", {
|
|
120
124
|
...fieldProps,
|
|
121
125
|
ref: mergeRefs(ref, triggerRef),
|
|
122
|
-
onMouseEnter,
|
|
123
|
-
onFocusCapture,
|
|
124
126
|
children: customTrigger
|
|
125
127
|
})
|
|
126
128
|
}) : /* @__PURE__ */ jsx(SelectInput, {
|
|
@@ -137,6 +139,8 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
|
|
|
137
139
|
isClearable,
|
|
138
140
|
showSelectionContent,
|
|
139
141
|
inputClassName,
|
|
142
|
+
leadingContent,
|
|
143
|
+
trailingContent,
|
|
140
144
|
collapseAfter,
|
|
141
145
|
selectedTagsType,
|
|
142
146
|
isRequired,
|
|
@@ -151,7 +155,7 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
|
|
|
151
155
|
triggerRef,
|
|
152
156
|
isOpen,
|
|
153
157
|
onOpenChange: setIsOpen,
|
|
154
|
-
className:
|
|
158
|
+
className: selectPopoverCva$1({}),
|
|
155
159
|
style: { width: !ignoreTriggerWidth ? popoverWidth : void 0 },
|
|
156
160
|
offset: 0,
|
|
157
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" | "isRequired" | "isDirty" | "fireBlurOnChange" | "onMouseEnter" | "onFocusCapture"> {
|
|
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, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, onMouseEnter, onFocusCapture, ...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 {};
|
|
@@ -4,7 +4,7 @@ import { Typography } from "../../../text/Typography/Typography.js";
|
|
|
4
4
|
import "../../../../config/i18n.js";
|
|
5
5
|
import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
|
|
6
6
|
import { InputClear } from "../../shared/InputClear.js";
|
|
7
|
-
import { inputBase, inputSize } from "../../shared/input.cva.js";
|
|
7
|
+
import { inputBase, inputClearClass, inputSize } from "../../shared/input.cva.js";
|
|
8
8
|
import { SelectInputTags } from "./SelectInputTags.js";
|
|
9
9
|
import { SelectContext } from "./select.context.js";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -14,9 +14,10 @@ import { Button, ComboBoxStateContext, Input } from "react-aria-components";
|
|
|
14
14
|
import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
|
|
15
15
|
import { useTranslation } from "react-i18next";
|
|
16
16
|
//#region src/components/inputs/Selection/shared/SelectInput.tsx
|
|
17
|
-
var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, onMouseEnter, onFocusCapture, ...props }) => {
|
|
17
|
+
var 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 }) => {
|
|
18
18
|
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
19
19
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
20
|
+
const inputClearClassCva = UIStyle.useCva("input.clearClassCva", inputClearClass);
|
|
20
21
|
const { t } = useTranslation("ui");
|
|
21
22
|
const state = use(ComboBoxStateContext);
|
|
22
23
|
const { hoverProps, isHovered } = useHover({ isDisabled });
|
|
@@ -70,6 +71,7 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
70
71
|
}),
|
|
71
72
|
"data-rac": "",
|
|
72
73
|
"data-disabled": isDisabled || void 0,
|
|
74
|
+
"data-is-disabled": isDisabled || void 0,
|
|
73
75
|
"data-hovered": isHovered || void 0,
|
|
74
76
|
"data-focused": isOpen || isFocused || void 0,
|
|
75
77
|
"data-focus-within": isFocused || void 0,
|
|
@@ -101,6 +103,10 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
101
103
|
...headerProps,
|
|
102
104
|
labelProps
|
|
103
105
|
}),
|
|
106
|
+
leadingContent && /* @__PURE__ */ jsx("div", {
|
|
107
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
108
|
+
children: leadingContent
|
|
109
|
+
}),
|
|
104
110
|
(showTags || isSearchable) && /* @__PURE__ */ jsxs("div", {
|
|
105
111
|
className: clsx("flex flex-1 flex-wrap gap-input-gap-input-text-to-elements truncate", !isSearchable && "pointer-events-none z-1"),
|
|
106
112
|
children: [showTags && /* @__PURE__ */ jsx(SelectInputTags, {
|
|
@@ -138,8 +144,13 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
138
144
|
onClear();
|
|
139
145
|
if (fireBlurOnChange) onBlur?.({});
|
|
140
146
|
},
|
|
147
|
+
className: inputClearClassCva({ as }),
|
|
141
148
|
show: showClearButton
|
|
142
149
|
}),
|
|
150
|
+
trailingContent && /* @__PURE__ */ jsx("div", {
|
|
151
|
+
className: "flex shrink-0 items-center",
|
|
152
|
+
children: trailingContent
|
|
153
|
+
}),
|
|
143
154
|
!hideDropdownIcon && /* @__PURE__ */ jsx(Button, {
|
|
144
155
|
excludeFromTabOrder: true,
|
|
145
156
|
"aria-label": t(($) => isOpen ? $.ui.closeAlt : $.ui.openAlt),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AriaListBoxProps } from 'react-aria';
|
|
2
2
|
import { SelectBaseProps } from './SelectBase';
|
|
3
3
|
import { SelectItem } from './select.types';
|
|
4
|
-
export interface SelectListBoxProps extends Pick<SelectBaseProps, "label" | "newItemRender" | "onLoadMore" | "selectionMode" | "isSearchable" | "virtualizerOptions">, Omit<AriaListBoxProps<SelectItem>, "children" | "aria-label" | "selectionMode" | "items" | "selectedKeys" | "onSelectionChange" | "escapeKeyBehavior" | "shouldSelectOnPressUp" | "label"> {
|
|
4
|
+
export interface SelectListBoxProps extends Pick<SelectBaseProps, "label" | "newItemRender" | "onLoadMore" | "selectionMode" | "isSearchable" | "virtualizerOptions" | "totalItems" | "hasLoadMore">, Omit<AriaListBoxProps<SelectItem>, "children" | "aria-label" | "selectionMode" | "items" | "selectedKeys" | "onSelectionChange" | "escapeKeyBehavior" | "shouldSelectOnPressUp" | "label"> {
|
|
5
5
|
className?: string;
|
|
6
6
|
isScrollable?: boolean;
|
|
7
7
|
onClose?: () => void;
|
|
8
8
|
}
|
|
9
|
-
export declare const SelectListBox: ({ label, selectionMode, isSearchable, isScrollable, virtualizerOptions, newItemRender, onLoadMore, className, onClose, ...props }: SelectListBoxProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const SelectListBox: ({ label, selectionMode, isSearchable, isScrollable, virtualizerOptions, totalItems, newItemRender, onLoadMore, className, onClose, ...props }: SelectListBoxProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,8 +7,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { ListBox, ListLayout, Virtualizer } from "react-aria-components";
|
|
9
9
|
//#region src/components/inputs/Selection/shared/SelectListBox.tsx
|
|
10
|
-
var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true, virtualizerOptions, newItemRender, onLoadMore, className, onClose, ...props }) => {
|
|
11
|
-
const { fieldState, onChange, listItems, selectableListItems, selectedIds, isMultiple, onClear, onSelectAll } = SelectContext.useSelect();
|
|
10
|
+
var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true, virtualizerOptions, totalItems, newItemRender, onLoadMore, className, onClose, ...props }) => {
|
|
11
|
+
const { fieldState, onChange, listItems, selectableListItems, selectedIds, isMultiple, onClear, onSelectAll, hasLoadMore } = SelectContext.useSelect();
|
|
12
12
|
const onSelectionChange = (value) => {
|
|
13
13
|
const ids = Array.from(value);
|
|
14
14
|
if (!isMultiple && ids.length === 0) {
|
|
@@ -42,7 +42,7 @@ var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true,
|
|
|
42
42
|
newItemRender
|
|
43
43
|
}, item.id);
|
|
44
44
|
};
|
|
45
|
-
if (virtualizerOptions || listItems.length > 100) return /* @__PURE__ */ jsx(Virtualizer, {
|
|
45
|
+
if (virtualizerOptions || (totalItems ?? listItems.length) > 100 || hasLoadMore) return /* @__PURE__ */ jsx(Virtualizer, {
|
|
46
46
|
layout: ListLayout,
|
|
47
47
|
layoutOptions: virtualizerOptions,
|
|
48
48
|
children: /* @__PURE__ */ jsx(ListBox, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Key } from 'react-aria-components';
|
|
2
2
|
import { SelectBaseProps } from './SelectBase';
|
|
3
3
|
type SelectMobileProps<TKey extends Key = Key> = SelectBaseProps<TKey>;
|
|
4
|
-
export declare const SelectMobile: <TKey extends Key = Key>({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectMobileProps<TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const SelectMobile: <TKey extends Key = Key>({ ref, error, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectMobileProps<TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export {};
|
|
@@ -13,7 +13,7 @@ import { useRef } from "react";
|
|
|
13
13
|
import { DialogTrigger } from "react-aria-components";
|
|
14
14
|
import { useLabel } from "react-aria";
|
|
15
15
|
//#region src/components/inputs/Selection/shared/SelectMobile.tsx
|
|
16
|
-
var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
|
|
16
|
+
var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
|
|
17
17
|
const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, hideSearchIcon, isSearchable, isClearable, as, size, collapseAfter, selectedTagsType } = props;
|
|
18
18
|
const formFieldProps = {
|
|
19
19
|
error,
|
|
@@ -57,13 +57,13 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
|
|
|
57
57
|
as,
|
|
58
58
|
labelProps,
|
|
59
59
|
className: clsx("w-full", containerClassName),
|
|
60
|
+
onMouseEnter,
|
|
61
|
+
onFocusCapture,
|
|
60
62
|
children: /* @__PURE__ */ jsxs(DialogTrigger, {
|
|
61
63
|
...dialogTriggerProps,
|
|
62
64
|
children: [customTrigger ? /* @__PURE__ */ jsx("div", {
|
|
63
65
|
...fieldProps,
|
|
64
66
|
ref,
|
|
65
|
-
onMouseEnter,
|
|
66
|
-
onFocusCapture,
|
|
67
67
|
children: customTrigger
|
|
68
68
|
}) : /* @__PURE__ */ jsx(SelectInput, {
|
|
69
69
|
ref,
|
|
@@ -81,6 +81,8 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
|
|
|
81
81
|
onBlur: void 0,
|
|
82
82
|
fieldProps,
|
|
83
83
|
headerProps,
|
|
84
|
+
leadingContent,
|
|
85
|
+
trailingContent,
|
|
84
86
|
collapseAfter,
|
|
85
87
|
selectedTagsType,
|
|
86
88
|
isRequired,
|
|
@@ -17,14 +17,15 @@ export declare namespace SelectContext {
|
|
|
17
17
|
onClear: () => void;
|
|
18
18
|
onSelectAll: () => void;
|
|
19
19
|
onRemove: (val: Key) => void;
|
|
20
|
+
onBlur: () => void;
|
|
20
21
|
listItems: ExtendedSelectItem[];
|
|
21
22
|
selectableListItems: SelectItem[];
|
|
22
23
|
selectedItems: SelectItem[];
|
|
23
24
|
selectedIds: Key[];
|
|
24
25
|
isMultiple: boolean;
|
|
25
26
|
} & Pick<SelectBaseProps, "onInputChange" | "isLoading" | "hasLoadMore">;
|
|
26
|
-
export type ProviderProps = GroupedSelectProps & Pick<SelectBaseProps, "items" | "onInputChange" | "onSearchChange" | "showSelectAllOption" | "showNewItemOption" | "newItemMinLength" | "onNewItemOption" | "isLoading" | "hasLoadMore" | "mapInitialToSelectItem" | "isSearchable" | "isClientSearchDisabled">;
|
|
27
|
-
export const Provider: ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, children, mapInitialToSelectItem, ...props }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export type ProviderProps = GroupedSelectProps & Pick<SelectBaseProps, "items" | "onInputChange" | "onSearchChange" | "showSelectAllOption" | "showNewItemOption" | "newItemMinLength" | "onNewItemOption" | "isLoading" | "hasLoadMore" | "mapInitialToSelectItem" | "isSearchable" | "isClientSearchDisabled" | "ignoreInputValueFiltering">;
|
|
28
|
+
export const Provider: ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, ignoreInputValueFiltering, children, mapInitialToSelectItem, ...props }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
28
29
|
export const useSelect: () => Type;
|
|
29
30
|
export {};
|
|
30
31
|
}
|
|
@@ -10,7 +10,7 @@ var SelectContext;
|
|
|
10
10
|
id: item.id,
|
|
11
11
|
label: item.label ?? item.name ?? ""
|
|
12
12
|
});
|
|
13
|
-
_SelectContext.Provider = ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, children, mapInitialToSelectItem = defaultMapInitialToSelectItem, ...props }) => {
|
|
13
|
+
_SelectContext.Provider = ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, ignoreInputValueFiltering, children, mapInitialToSelectItem = defaultMapInitialToSelectItem, ...props }) => {
|
|
14
14
|
const isMultiple = props.selectionMode === "multiple";
|
|
15
15
|
const initialSelectedItems = useMemo(() => {
|
|
16
16
|
if (!props.initialSelection) return null;
|
|
@@ -42,9 +42,14 @@ var SelectContext;
|
|
|
42
42
|
newItemMinLength,
|
|
43
43
|
isLoading,
|
|
44
44
|
hasLoadMore,
|
|
45
|
-
isClientSearchDisabled
|
|
45
|
+
isClientSearchDisabled: ignoreInputValueFiltering ?? isClientSearchDisabled
|
|
46
46
|
});
|
|
47
|
-
const selectedItems = useMemo(() =>
|
|
47
|
+
const selectedItems = useMemo(() => {
|
|
48
|
+
const getItem = (id) => allItems.find((item) => item.id === id) ?? null;
|
|
49
|
+
if (Array.isArray(fieldState.value)) return fieldState.value.map((id) => getItem(id)).filter((item) => item !== null);
|
|
50
|
+
const selectedItem = fieldState.value != null ? getItem(fieldState.value) : null;
|
|
51
|
+
return selectedItem ? [selectedItem] : [];
|
|
52
|
+
}, [allItems, fieldState.value]);
|
|
48
53
|
const selectedIds = useMemo(() => selectedItems.map(({ id }) => id), [selectedItems]);
|
|
49
54
|
const getItem = useCallback((value) => allItems.find((item) => item && item.id === value) ?? null, [allItems]);
|
|
50
55
|
const updateValue = useCallback((value) => {
|
|
@@ -84,7 +89,7 @@ var SelectContext;
|
|
|
84
89
|
else updateValue(value);
|
|
85
90
|
}, [props.value]);
|
|
86
91
|
useEffect(() => {
|
|
87
|
-
if (!isMultiple && fieldState.value && fieldState.inputValue === "" && getItem(fieldState.value)?.label) syncFieldState(fieldState.value);
|
|
92
|
+
if (!isMultiple && props.value !== null && props.value !== void 0 && fieldState.value !== null && fieldState.value !== void 0 && fieldState.inputValue === "" && getItem(fieldState.value)?.label) syncFieldState(fieldState.value);
|
|
88
93
|
}, [allListItems]);
|
|
89
94
|
const handleInputChange = useCallback((inputValue) => {
|
|
90
95
|
const newFieldState = {
|
|
@@ -144,6 +149,22 @@ var SelectContext;
|
|
|
144
149
|
fieldState.value,
|
|
145
150
|
onChange
|
|
146
151
|
]);
|
|
152
|
+
const onBlur = useCallback(() => {
|
|
153
|
+
if (props.isSearchable && isMultiple && fieldState.searchValue !== "") {
|
|
154
|
+
const newFieldState = {
|
|
155
|
+
...fieldState,
|
|
156
|
+
inputValue: "",
|
|
157
|
+
searchValue: ""
|
|
158
|
+
};
|
|
159
|
+
setFieldState(newFieldState);
|
|
160
|
+
emitStateChanges(newFieldState);
|
|
161
|
+
setShowAll(true);
|
|
162
|
+
}
|
|
163
|
+
}, [
|
|
164
|
+
props.isSearchable,
|
|
165
|
+
isMultiple,
|
|
166
|
+
fieldState
|
|
167
|
+
]);
|
|
147
168
|
const value = useMemo(() => ({
|
|
148
169
|
fieldState,
|
|
149
170
|
isOpen,
|
|
@@ -154,6 +175,7 @@ var SelectContext;
|
|
|
154
175
|
onClear,
|
|
155
176
|
onSelectAll,
|
|
156
177
|
onRemove,
|
|
178
|
+
onBlur,
|
|
157
179
|
listItems,
|
|
158
180
|
selectableListItems,
|
|
159
181
|
selectedItems,
|
|
@@ -171,6 +193,7 @@ var SelectContext;
|
|
|
171
193
|
onClear,
|
|
172
194
|
onSelectAll,
|
|
173
195
|
onRemove,
|
|
196
|
+
onBlur,
|
|
174
197
|
listItems,
|
|
175
198
|
selectableListItems,
|
|
176
199
|
selectedIds,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { Key } from 'react-aria-components';
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { ControlProps } from '../../shared/form.types';
|
|
5
5
|
export interface SelectItem<TKey extends Key = Key> {
|
|
6
6
|
id: TKey;
|
|
7
7
|
label: string;
|
|
8
|
-
content?: string |
|
|
8
|
+
content?: string | ReactNode;
|
|
9
9
|
isDisabled?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface ExtendedSelectItem<TKey extends Key = Key> extends SelectItem<TKey> {
|
|
@@ -54,6 +54,7 @@ export interface SelectAsyncProps {
|
|
|
54
54
|
onLoadMore?: () => void;
|
|
55
55
|
}
|
|
56
56
|
export interface SelectVirtualizationProps {
|
|
57
|
+
totalItems?: number;
|
|
57
58
|
virtualizerOptions?: {
|
|
58
59
|
rowHeight?: number;
|
|
59
60
|
estimatedRowHeight?: number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Key } from 'react-aria-components';
|
|
3
|
+
import { SelectBaseProps } from './SelectBase';
|
|
4
|
+
import { DefaultInitialSelectItem, SelectItem } from './select.types';
|
|
5
|
+
interface GetStaticSelectValueOptions<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> {
|
|
6
|
+
items: SelectItem<TKey>[];
|
|
7
|
+
value: TKey | TKey[] | null | undefined;
|
|
8
|
+
selectionMode: SelectBaseProps<TKey>["selectionMode"];
|
|
9
|
+
initialSelection?: TInitialSelectItem | TInitialSelectItem[] | null;
|
|
10
|
+
mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
|
|
11
|
+
showSelectionContent?: boolean;
|
|
12
|
+
isDisabled?: boolean;
|
|
13
|
+
collapseAfter?: SelectBaseProps<TKey>["collapseAfter"];
|
|
14
|
+
selectedTagsType?: SelectBaseProps<TKey>["selectedTagsType"];
|
|
15
|
+
}
|
|
16
|
+
interface StaticSelectValueResult<TKey extends Key = Key> {
|
|
17
|
+
selectedItem: SelectItem<TKey> | null;
|
|
18
|
+
selectedItems: SelectItem<TKey>[];
|
|
19
|
+
displayValue: ReactNode;
|
|
20
|
+
isEmpty: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare const getStaticSelectValue: <TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>({ items, value, selectionMode, initialSelection, mapInitialToSelectItem, showSelectionContent, isDisabled, collapseAfter, selectedTagsType, }: GetStaticSelectValueOptions<TKey, TInitialSelectItem>) => StaticSelectValueResult<TKey>;
|
|
23
|
+
export {};
|