UNPKG

@ozen-ui/kit

Version:

React component library

19 lines (18 loc) 969 B
import { isMultipleInternalValue } from '../../utils'; export var useAutocompleteBaseOptions = function (_a) { var options = _a.options, filteredOptions = _a.filteredOptions, valueControl = _a.valueControl, multiple = _a.multiple; var isSelected = function (option) { var _a, _b, _c; if (isMultipleInternalValue(valueControl.value, multiple)) { return ((_b = (_a = valueControl.value) === null || _a === void 0 ? void 0 : _a.some(function (selectedOption) { return selectedOption.id === option.id; })) !== null && _b !== void 0 ? _b : false); } return ((_c = valueControl.value) === null || _c === void 0 ? void 0 : _c.id) === option.id; }; var hasOptions = (filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.length) > 0; return { options: options, filteredOptions: filteredOptions, isSelected: isSelected, hasOptions: hasOptions, }; };