import { __assign, __rest } from "tslib";
import React, { useContext, useState } from 'react';
import classNames from 'classnames';
import { SelectContext } from './select-context';
import { ConfigContext } from '../config-provider/config-context';
import { getPrefixCls } from '../_utils/general';
var SelectOption = function (props) {
    var _a;
    var _b = props.disabled, disabled = _b === void 0 ? false : _b, customisedCls = props.prefixCls, value = props.value, className = props.className, children = props.children, otherProps = __rest(props, ["disabled", "prefixCls", "value", "className", "children"]);
    var context = useContext(SelectContext);
    var isSelect = context.value === value;
    var _c = useState(false), active = _c[0], setActive = _c[1];
    var configContext = useContext(ConfigContext);
    var prefixCls = getPrefixCls('select-option', configContext.prefixCls, customisedCls);
    var cls = classNames(prefixCls, className, (_a = {},
        _a[prefixCls + "_selected"] = isSelect,
        _a[prefixCls + "_active"] = active,
        _a[prefixCls + "_disabled"] = disabled,
        _a));
    var onMouseEnter = function () {
        setActive(true);
    };
    var onMouseLeave = function () {
        setActive(false);
    };
    var onClick = function () {
        !disabled && context.onSelect(value);
    };
    return (React.createElement("li", __assign({}, otherProps, { key: value, className: cls, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, "aria-selected": isSelect, "aria-disabled": disabled }), children));
};
SelectOption.displayName = 'SelectOption';
export default SelectOption;
//# sourceMappingURL=option.js.map