UNPKG

@ozen-ui/kit

Version:

React component library

23 lines (22 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useAutocompleteBaseOptions = void 0; var utils_1 = require("../../utils"); 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 ((0, utils_1.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, }; }; exports.useAutocompleteBaseOptions = useAutocompleteBaseOptions;