UNPKG

@ozen-ui/kit

Version:

React component library

23 lines (22 loc) 953 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useDataListBaseOptions = void 0; var utils_1 = require("../../utils"); var useDataListBaseOptions = function (_a) { var optionsStore = _a.optionsStore, valueControl = _a.valueControl, multiple = _a.multiple; var isSelected = function (option) { var _a, _b; if ((0, utils_1.isMultipleInternalValue)(valueControl.value, multiple)) { return ((_b = (_a = valueControl.value) === null || _a === void 0 ? void 0 : _a.some(function (selectedId) { return selectedId === option.id; })) !== null && _b !== void 0 ? _b : false); } return valueControl.value === option.id; }; var isFocused = function (option) { return option.id === optionsStore.focused.current; }; return { isFocused: isFocused, isSelected: isSelected, }; }; exports.useDataListBaseOptions = useDataListBaseOptions;