@via-profit/ui-kit 0.1.0-rc.43 → 0.1.0-rc.44
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Value, OnRequestClose } from '../Menu';
|
|
2
|
+
import { Value, OnRequestClose, GetOptionSelected } from '../Menu';
|
|
3
3
|
import type { MenuItemCommonProps } from '../Menu/MenuItem';
|
|
4
4
|
export type AutocompleteProps<T, Multiple extends boolean | undefined = undefined> = {
|
|
5
5
|
readonly value: Value<T, Multiple> | null;
|
|
@@ -23,6 +23,7 @@ export type AutocompleteProps<T, Multiple extends boolean | undefined = undefine
|
|
|
23
23
|
readonly filterItems?: FilterItems<T>;
|
|
24
24
|
readonly onChange?: OnChange<T, Multiple>;
|
|
25
25
|
readonly selectedItemToString: ItemToString<T, Multiple>;
|
|
26
|
+
readonly getOptionSelected?: GetOptionSelected<T>;
|
|
26
27
|
readonly onRequestClose?: OnRequestClose;
|
|
27
28
|
readonly onInputChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
28
29
|
readonly onRequestOpen?: (event: React.KeyboardEvent<HTMLInputElement> | React.MouseEvent<HTMLInputElement> | React.FocusEvent<HTMLInputElement, Element>) => void;
|
|
@@ -34,7 +34,7 @@ const Spinner_1 = __importDefault(require("../LoadingIndicator/Spinner"));
|
|
|
34
34
|
const IconClear_1 = __importDefault(require("./IconClear"));
|
|
35
35
|
const context_1 = __importStar(require("./context"));
|
|
36
36
|
const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
37
|
-
const { items, value, multiple, isOpen = false, isLoading = false, clearIfNotSelected = true, filterItems, children, onChange, selectedItemToString, onInputChange, onRequestOpen = () => undefined, onRequestClose = () => undefined, } = props;
|
|
37
|
+
const { items, value, multiple, isOpen = false, isLoading = false, clearIfNotSelected = true, filterItems, children, onChange, selectedItemToString, onInputChange, getOptionSelected, onRequestOpen = () => undefined, onRequestClose = () => undefined, } = props;
|
|
38
38
|
const menuRef = react_1.default.useRef(null);
|
|
39
39
|
const inputRef = react_1.default.useRef(null);
|
|
40
40
|
const isFocusedRef = react_1.default.useRef(false);
|
|
@@ -198,7 +198,7 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
198
198
|
filterItems,
|
|
199
199
|
items,
|
|
200
200
|
]),
|
|
201
|
-
react_1.default.useMemo(() => (react_1.default.createElement(Menu_1.default, { ref: menuRef, anchorPos: "left-bottom-right", multiple: multiple, items: filteredItems, value: currentValue, isOpen: currentOpen && filteredItems.length > 0, autofocus: false, anchorElement: anchorElement, closeOutsideClick: true, onSelectItem: item => {
|
|
201
|
+
react_1.default.useMemo(() => (react_1.default.createElement(Menu_1.default, { ref: menuRef, anchorPos: "left-bottom-right", multiple: multiple, items: filteredItems, value: currentValue, isOpen: currentOpen && filteredItems.length > 0, autofocus: false, anchorElement: anchorElement, closeOutsideClick: true, getOptionSelected: getOptionSelected, onSelectItem: item => {
|
|
202
202
|
if (typeof onChange === 'function') {
|
|
203
203
|
onChange(item);
|
|
204
204
|
}
|
|
@@ -222,6 +222,7 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
222
222
|
dispatch,
|
|
223
223
|
onRequestClose,
|
|
224
224
|
onChange,
|
|
225
|
+
getOptionSelected,
|
|
225
226
|
selectedItemToString,
|
|
226
227
|
])));
|
|
227
228
|
});
|