@ariakit/react-core
Version:
Ariakit React core
114 lines (93 loc) • 3.73 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _MVDPZI3Lcjs = require('../__chunks/MVDPZI3L.cjs');
var _VYPHKDEDcjs = require('../__chunks/VYPHKDED.cjs');
require('../__chunks/N37IROBR.cjs');
require('../__chunks/YTEJF6TY.cjs');
require('../__chunks/MIBORXQW.cjs');
require('../__chunks/W5V6HX7H.cjs');
var _FCZ3IGUBcjs = require('../__chunks/FCZ3IGUB.cjs');
require('../__chunks/IH6KF7WR.cjs');
var _PH2DFCJScjs = require('../__chunks/PH2DFCJS.cjs');
require('../__chunks/ZVJRPAXY.cjs');
require('../__chunks/YDPERDKF.cjs');
require('../__chunks/KVXNVDJK.cjs');
require('../__chunks/D6FV6EYS.cjs');
require('../__chunks/DHAXJ5PA.cjs');
require('../__chunks/YUGKYIYY.cjs');
require('../__chunks/T3QB4FR3.cjs');
require('../__chunks/25BPIGZH.cjs');
require('../__chunks/6HKL3JR2.cjs');
var _WULEED4Qcjs = require('../__chunks/WULEED4Q.cjs');
var _OZM4QA2Vcjs = require('../__chunks/OZM4QA2V.cjs');
require('../__chunks/FDRJDQ5Y.cjs');
var _7EQBAZ46cjs = require('../__chunks/7EQBAZ46.cjs');
// src/combobox/combobox-item-offscreen.tsx
var _react = require('react');
var _jsxruntime = require('react/jsx-runtime');
var TagName = "div";
var itemRoleByPopupRole = {
menu: "menuitem",
listbox: "option",
tree: "treeitem"
};
function getItemRole(popupRole) {
var _a;
const key = popupRole;
return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
}
function useComboboxItemOffscreen(_a) {
var _b = _a, { store, value } = _b, props = _7EQBAZ46cjs.__objRest.call(void 0, _b, ["store", "value"]);
const context = _PH2DFCJScjs.useComboboxScopedContext.call(void 0, );
store = store || context;
const offscreenProps = _MVDPZI3Lcjs.useCompositeItemOffscreen.call(void 0, _7EQBAZ46cjs.__spreadValues.call(void 0, { store, value }, props));
const popupRole = _react.useContext.call(void 0, _PH2DFCJScjs.ComboboxListRoleContext);
if (!offscreenProps.active) {
return _7EQBAZ46cjs.__spreadProps.call(void 0, _7EQBAZ46cjs.__spreadValues.call(void 0, {}, offscreenProps), {
role: getItemRole(popupRole)
});
}
return offscreenProps;
}
var ComboboxItem2 = _WULEED4Qcjs.forwardRef.call(void 0, function ComboboxItem3(_a) {
var _b = _a, {
offscreenBehavior,
offscreenRoot
} = _b, props = _7EQBAZ46cjs.__objRest.call(void 0, _b, [
"offscreenBehavior",
"offscreenRoot"
]);
const _a2 = useComboboxItemOffscreen(_7EQBAZ46cjs.__spreadValues.call(void 0, {
offscreenBehavior,
offscreenRoot
}, props)), { active, ref } = _a2, rest = _7EQBAZ46cjs.__objRest.call(void 0, _a2, ["active", "ref"]);
const allProps = _7EQBAZ46cjs.__spreadProps.call(void 0, _7EQBAZ46cjs.__spreadValues.call(void 0, _7EQBAZ46cjs.__spreadValues.call(void 0, {}, rest), props), { ref: _OZM4QA2Vcjs.useMergeRefs.call(void 0, ref, props.ref) });
if (active) {
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _VYPHKDEDcjs.ComboboxItem, _7EQBAZ46cjs.__spreadValues.call(void 0, {}, allProps));
}
const _b2 = allProps, {
store,
value,
hideOnClick,
setValueOnClick,
selectValueOnClick,
resetValueOnSelect,
focusOnHover,
blurOnHoverEnd,
moveOnKeyPress,
getItem
} = _b2, htmlProps = _7EQBAZ46cjs.__objRest.call(void 0, _b2, [
"store",
"value",
"hideOnClick",
"setValueOnClick",
"selectValueOnClick",
"resetValueOnSelect",
"focusOnHover",
"blurOnHoverEnd",
"moveOnKeyPress",
"getItem"
]);
const Component = _FCZ3IGUBcjs.Role[TagName];
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, _7EQBAZ46cjs.__spreadValues.call(void 0, {}, htmlProps));
});
exports.ComboboxItem = ComboboxItem2; exports.useComboboxItemOffscreen = useComboboxItemOffscreen;