UNPKG

primereact

Version:

PrimeReact is an open source UI library for React featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with Prime

2 lines (1 loc) 21.2 kB
import*as e from"react";import{PrimeReactContext as t,FilterService as n,localeOption as r}from"primereact/api";import{ComponentBase as o,useHandleStyle as i}from"primereact/componentbase";import{useMergeProps as l,useMountEffect as a}from"primereact/hooks";import{Tooltip as u}from"primereact/tooltip";import{classNames as c,IconUtils as s,ObjectUtils as p,DomHandler as f,UniqueComponentId as d}from"primereact/utils";import{VirtualScroller as m}from"primereact/virtualscroller";import{SearchIcon as v}from"primereact/icons/search";import{InputText as b}from"primereact/inputtext";import{Ripple as y}from"primereact/ripple";function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},h.apply(null,arguments)}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function x(e,t){if("object"!=g(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=g(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function O(e){var t=x(e,"string");return"symbol"==g(t)?t:t+""}function I(e,t,n){return(t=O(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function S(e){if(Array.isArray(e))return E(e)}function w(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function D(e,t){if(e){if("string"==typeof e)return E(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E(e,t):void 0}}function F(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function P(e){return S(e)||w(e)||D(e)||F()}function L(e){if(Array.isArray(e))return e}function N(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,l,a=[],u=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=n.return&&(l=n.return(),Object(l)!==l))return}finally{if(c)throw o}}return a}}function j(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function C(e,t){return L(e)||N(e,t)||D(e,t)||j()}var T=o.extend({defaultProps:{__TYPE:"ListBox",className:null,dataKey:null,disabled:null,emptyFilterMessage:null,emptyMessage:null,filter:!1,filterIcon:null,filterBy:null,filterInputProps:null,filterLocale:void 0,filterMatchMode:"contains",filterPlaceholder:null,filterTemplate:null,filterValue:null,focusOnHover:!0,id:null,itemTemplate:null,invalid:!1,listClassName:null,listStyle:null,metaKeySelection:!1,selectOnFocus:!1,autoOptionFocus:!1,multiple:!1,onChange:null,onFilterValueChange:null,optionDisabled:null,optionGroupChildren:null,optionGroupLabel:null,optionGroupTemplate:null,optionLabel:null,optionValue:null,options:null,style:null,tabIndex:0,tooltip:null,tooltipOptions:null,value:null,virtualScrollerOptions:null,children:void 0},css:{classes:{itemGroup:"p-listbox-item-group",emptyMessage:"p-listbox-empty-message",list:"p-listbox-list",wrapper:function(e){return c("p-listbox-list-wrapper",e.props.listClassName)},root:function(e){var t=e.props;return c("p-listbox p-component",{"p-disabled":t.disabled,"p-invalid":t.invalid},t.className)},item:function(e){var t=e.props;return c("p-listbox-item",{"p-highlight":t.selected,"p-focus":t.focusedOptionIndex===t.index,"p-disabled":t.disabled},t.option.className)},filterContainer:"p-listbox-filter-container",filterIcon:"p-listbox-filter-icon",filterInput:"p-listbox-filter",header:"p-listbox-header"},styles:"\n@layer primereact {\n .p-listbox-list-wrapper {\n overflow: auto;\n }\n \n .p-listbox-list {\n list-style-type: none;\n margin: 0;\n padding: 0;\n }\n \n .p-listbox-item {\n cursor: pointer;\n position: relative;\n overflow: hidden;\n outline: none;\n }\n \n .p-listbox-filter-container {\n position: relative;\n }\n \n .p-listbox-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-listbox-filter {\n width: 100%;\n }\n}\n",inlineStyles:{itemGroup:function(e){var t=e.scrollerOptions;return{height:t.props?t.props.itemSize:void 0}},list:function(e){return e.props.virtualScrollerOptions?e.options.style:void 0}}}});function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function K(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var k=e.memo((function(t){var n=l(),r=t.ptCallbacks,o=r.ptm,i=r.cx,a=function(e,n){return o(e,K({hostName:t.hostName},n))},u={filter:function(e){return c(e)},reset:function(){return t.resetFilter()}},c=function(e){t.onFilter&&t.onFilter({originalEvent:e,value:e.target.value})},f=function(){var r=n({className:i("filterIcon")},a("filterIcon")),l=s.getJSXIcon(t.filterIcon||e.createElement(v,r),K({},r),{props:t}),f=n({className:i("header")},a("header")),d=n({className:i("filterContainer")},a("filterContainer")),m=e.createElement("div",d,e.createElement(b,h({type:"text",value:t.filter,onChange:c,className:i("filterInput"),disabled:t.disabled,placeholder:t.filterPlaceholder},t.filterInputProps,{pt:o("filterInput"),unstyled:t.unstyled,__parentMetadata:{parent:t.metaData}})),l);t.filterTemplate&&(m=p.getJSXElement(t.filterTemplate,{className:"p-listbox-filter-container",element:m,filterOptions:u,filterInputChange:c,filterIconClassName:"p-dropdown-filter-icon",props:t}));return e.createElement("div",f,m)}();return e.createElement(e.Fragment,null,f)}));k.displayName="ListBoxHeader";var G=e.memo((function(t){var n=C(e.useState(!1),2),r=n[0],o=n[1],i=l(),a=t.ptCallbacks,u=a.ptm,c=a.cx,s=t.template?p.getJSXElement(t.template,t.option):t.label,f=i({id:t.id,className:c("item",{props:t}),style:t.style,onClick:function(e){return t.onClick(e,t.option,t.index)},onTouchEnd:function(e){t.onTouchEnd&&t.onTouchEnd({originalEvent:e,option:t.option})},onFocus:function(e){o(!0)},onBlur:function(e){o(!1)},tabIndex:"-1",onMouseDown:function(e){return t.onOptionMouseDown(e,t.index)},onMouseMove:function(e){return t.onOptionMouseMove(e,t.index)},"aria-label":t.label,role:"option","aria-selected":t.selected,"aria-disabled":t.disabled,"data-p-disabled":t.disabled},u("item",{hostName:t.hostName,context:{selected:t.selected,disabled:t.disabled,focused:r,focusedOptionIndex:t.focusedOptionIndex}}));return e.createElement("li",h({},f,{key:t.optionKey}),s,e.createElement(y,null))}));function A(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?A(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function V(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=B(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){a=!0,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(a)throw i}}}}function B(e,t){if(e){if("string"==typeof e)return _(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_(e,t):void 0}}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}G.displayName="ListBoxItem";var H=e.memo(e.forwardRef((function(o,c){var s=l(),v=e.useContext(t),b=T.getProps(o,v),y=C(e.useState(null),2),g=y[0],x=y[1],O=e.useRef(null),I=e.useRef(null),E=e.useRef(null),S=C(e.useState(-1),2),w=S[0],D=S[1],F=C(e.useState(!1),2),L=F[0],N=F[1],j=C(e.useState(""),2),M=j[0],K=j[1],A=C(e.useState(""),2),B=A[0],_=A[1],H=e.useRef(null),J=e.useRef(null),U=e.useRef(null),X=e.useRef(null),q=e.useRef(!1),z=(b.onFilterValueChange?b.filterValue:M)||"",$=z&&z.trim().length>0,W={props:b,state:{filterValue:z}},Y=T.setMetaData(W);i(T.css.styles,Y.isUnstyled,{name:"listbox"});var Q=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;b.disabled||_e(t)||(b.multiple?re(e.originalEvent,t):ne(e.originalEvent,t),q.current=!1,-1!==n&&x(n))},Z=function(e,t){he(e,t)},ee=function(e,t){b.focusOnHover&&L&&he(e,t)},te=function(){b.disabled||(q.current=!0)},ne=function(e,t){var n=Ae(t),r=!1,o=null;!q.current&&b.metaKeySelection?n?(e.metaKey||e.ctrlKey)&&(o=null,r=!0):(o=Ve(t),r=!0):(o=n?null:Ve(t),r=!0);r&&Ce(e,o)},re=function(e,t){var n=Ae(t),r=!1,o=null;if(!q&&b.metaKeySelection){var i=e.metaKey||e.ctrlKey;n?(o=i?Te(t):[Ve(t)],r=!0):(o=[].concat(P(o=i&&b.value||[]),[Ve(t)]),r=!0)}else o=n?Te(t):[].concat(P(b.value||[]),[Ve(t)]),r=!0;r&&b.onChange({originalEvent:e,value:o,stopPropagation:function(){null==e||e.stopPropagation()},preventDefault:function(){null==e||e.preventDefault()},target:{name:b.name,id:b.id,value:o}})},oe=function(){return p.isNotEmpty(b.value)},ie=function(e){return b.optionGroupLabel&&e.optionGroup&&e.group},le=function(e){return p.isNotEmpty(e)&&!(_e(e)||ie(e))},ae=function(e){return le(e)&&Ae(e)},ue=function(){return Ye.findIndex((function(e){return le(e)}))},ce=function(){if(oe()){if(!b.multiple)return Ye.findIndex((function(e){return ae(e)}));for(var e,t=function(){var e=b.value[n],t=Ye.findIndex((function(t){return ae(t)&&Ge(e,Ve(t))}));if(t>-1)return{v:t}},n=b.value.length-1;n>=0;n--)if(e=t())return e.v}return-1},se=function(){return p.findLastIndex(Ye,(function(e){return le(e)}))},pe=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=-1;return oe()&&(n=t?-1===(n=ve(e))?me(e):n:-1===(n=me(e))?ve(e):n),n>-1?n:e},fe=function(e){var t;return le(e)&&(null===(t=Re(e))||void 0===t?void 0:t.toLocaleLowerCase(b.filterLocale).startsWith(B.toLocaleLowerCase(b.filterLocale)))},de=function(e,t){_((B||"")+t);var n=-1;p.isNotEmpty(B)&&(-1===(n=-1!==g?-1===(n=Ye.slice(g).findIndex((function(e){return fe(e)})))?Ye.slice(0,g).findIndex((function(e){return fe(e)})):n+g:Ye.findIndex((function(e){return fe(e)})))&&-1===g&&(n=ye()),-1!==n&&he(e,n)),O.current&&clearTimeout(O.current),O.current=setTimeout((function(){_(""),O.current=null}),500)},me=function(e){var t=oe()&&e<Ye.length-1?Ye.slice(e+1).findIndex((function(e){return ae(e)})):-1;return t>-1?t+e+1:-1},ve=function(e){var t=oe()&&e>0?p.findLastIndex(Ye.slice(0,e),(function(e){return ae(e)})):-1;return t>-1?t:-1},be=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;if(-1===t&&(t=pe(n,!0)),-1===n&&(n=pe(t)),-1!==t&&-1!==n){var r=Math.min(t,n),o=Math.max(t,n),i=Ye.slice(r,o+1).filter((function(e){return le(e)})).map((function(e){return Ve(e)}));Ce(e,i)}},ye=function(){var e=oe()?Ye.findIndex((function(e){return ae(e)})):-1;return e<0?ue():e},he=function(e,t){g!==t&&(x(t),Pe(),e&&b.selectOnFocus&&!b.multiple&&Q(e,Ye[t]))},ge=function(e){var t,n,r=-1!==g?(n=(t=g)<Ye.length-1?Ye.slice(t+1).findIndex((function(e){return le(e)})):-1)>-1?n+t+1:t:ye();b.multiple&&e.shiftKey&&be(e,w,r),he(e,r),e.preventDefault()},xe=function(e){var t,n,r,o=-1!==g?(r=(n=g)>0?p.findLastIndex(Ye.slice(0,n),(function(e){return le(e)})):-1)>-1?r:n:(t=oe()?p.findLastIndex(Ye,(function(e){return ae(e)})):-1)<0?se():t;b.multiple&&e.shiftKey&&be(e,o,w),he(e,o),e.preventDefault()},Oe=function(e){-1!==g&&(b.multiple&&e.shiftKey?be(e,g):Q(e,Ye[g])),e.preventDefault()},Ie=function(e){Oe(e)},Ee=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])e.currentTarget.setSelectionRange(0,0),x(-1);else{var t=e.metaKey||e.ctrlKey,n=ue();b.multiple&&e.shiftKey&&t&&be(e,n,w),he(e,n)}e.preventDefault()},Se=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){var t=e.currentTarget,n=t.value.length;t.setSelectionRange(n,n),x(-1)}else{var r=e.metaKey||e.ctrlKey,o=se();b.multiple&&e.shiftKey&&r&&be(e,w,o),he(e,o)}e.preventDefault()},we=function(e){Pe(0),e.preventDefault()},De=function(e){Pe(Ye.length-1),e.preventDefault()},Fe=function(e){var t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":ge(e);break;case"ArrowUp":xe(e);break;case"Home":Ee(e);break;case"End":Se(e);break;case"PageDown":De(e);break;case"PageUp":we(e);break;case"Enter":case"NumpadEnter":case"Space":Ie(e),e.preventDefault();break;case"Tab":break;case"ShiftLeft":case"ShiftRight":D(g);break;default:if(b.multiple&&"a"===e.key&&t){var n=Ye.filter((function(e){return le(e)})).map((function(e){return Ve(e)}));Ce(e,n),e.preventDefault();break}!t&&p.isPrintableCharacter(e.key)&&(de(e,e.key),e.preventDefault())}},Pe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;setTimeout((function(){if(X.current){var t=-1!==e?"".concat(U.current,"_").concat(e):-1!==g?"".concat(U.current,"_").concat(g):null,n=X.current.querySelector('li[id="'.concat(t,'"]'));n?n.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"}):b.virtualScrollerOptions&&J.current&&J.current.scrollToIndex(-1!==e?e:g)}}),0)},Le=function(e){J.current&&J.current.scrollToIndex(0);var t=e.value;b.onFilterValueChange?b.onFilterValueChange({originalEvent:e.originalEvent,value:t}):K(t)},Ne=function(){K(""),b.onFilter&&b.onFilter({filter:""})},je=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:L;if(b.selectOnFocus&&b.autoOptionFocus&&!oe()&&!b.multiple&&e){var t=ye();Q(null,Ye[t]),x(t)}},Ce=function(e,t){b.onChange&&b.onChange({originalEvent:e,value:t,stopPropagation:function(){null==e||e.stopPropagation()},preventDefault:function(){null==e||e.preventDefault()},target:{name:b.name,id:b.id,value:t}})},Te=function(e){return b.value.filter((function(t){return!p.equals(t,Ve(e),b.dataKey)}))},Me=function(){if(null!=b.value&&Ye){if(!b.optionGroupLabel)return ke(b.value,Ye);for(var e=0;e<Ye.length;e++){var t=ke(b.value,Xe(Ye[e]));if(-1!==t)return{group:e,option:t}}}return-1},Ke=function(){return b.optionValue?null:b.dataKey},ke=function(e,t){var n=Ke();return t.findIndex((function(t){return p.equals(e,Ve(t),n)}))},Ge=function(e,t){return p.equals(e,t,Ke())},Ae=function(e){var t=Ve(e);return b.multiple?(b.value||[]).some((function(e){return Ge(e,t)})):Ge(b.value,t)},Re=function(e){return b.optionLabel?p.resolveFieldData(e,b.optionLabel):e&&void 0!==e.label?e.label:e},Ve=function(e){return b.optionValue?p.resolveFieldData(e,b.optionValue):e&&void 0!==e.value?e.value:e},Be=function(e){return b.dataKey?p.resolveFieldData(e,b.dataKey):Re(e)},_e=function(e){return b.optionDisabled?p.isFunction(b.optionDisabled)?b.optionDisabled(e):p.resolveFieldData(e,b.optionDisabled):!(!e||void 0===e.disabled)&&e.disabled},He=function(){N(!0),x(-1!==g?g:b.autoOptionFocus?ye():ce()),je(!0)},Je=function(){N(!1),x(-1),D(-1),_("")},Ue=function(e){return p.resolveFieldData(e,b.optionGroupLabel)},Xe=function(e){return p.resolveFieldData(e,b.optionGroupChildren)},qe=function(e){return(e||[]).reduce((function(e,t,n){e.push({optionGroup:t,group:!0,index:n,code:t.code,label:t.label});var r=Xe(t);return r&&r.forEach((function(t){return e.push(t)})),e}),[])},ze=function(){if(J.current){var e=Me();-1!==e&&setTimeout((function(){return J.current.scrollToIndex(e)}),0)}};e.useImperativeHandle(c,(function(){return{props:b,focus:function(){return f.focusFirstElement(H.current)},getElement:function(){return H.current},getVirtualScroller:function(){return J.current}}})),a((function(){ze(),U.current=d()}));var $e=function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={height:r.props?r.props.itemSize:void 0};if(t.group&&t.optionGroup&&b.optionGroupLabel){var i=b.optionGroupTemplate?p.getJSXElement(b.optionGroupTemplate,t,n):p.resolveFieldData(t,b.optionGroupLabel),l=n+"_"+Ue(t),a=s({className:Y.cx("itemGroup"),style:Y.sx("itemGroup",{scrollerOptions:r}),role:"group"},Y.ptm("itemGroup"));return e.createElement("li",h({},a,{key:l}),i)}var u=Re(t),c=n+"_"+Be(t),f=_e(t);return e.createElement(G,{id:U.current+"_"+n,hostName:"ListBox",optionKey:c,key:c,label:u,index:n,onOptionMouseDown:Z,onOptionMouseMove:ee,focusedOptionIndex:g,option:t,style:o,template:b.itemTemplate,selected:Ae(t),onClick:Q,onTouchEnd:te,disabled:f,ptCallbacks:Y,metaData:W})},We=function(t,n){var o=s({className:Y.cx("emptyMessage")},Y.ptm("emptyMessage")),i=p.getJSXElement(t,b)||r(n?"emptyFilterMessage":"emptyMessage");return e.createElement("li",o,i)},Ye=function(){var e=b.optionGroupLabel?qe(b.options):b.options;if($){var t=z.trim().toLocaleLowerCase(b.filterLocale),r=b.filterBy?b.filterBy.split(","):[b.optionLabel||"label"];if(b.optionGroupLabel){var o,i=[],l=V(b.options);try{for(l.s();!(o=l.n()).done;){var a=o.value,u=n.filter(Xe(a),r,t,b.filterMatchMode,b.filterLocale);u&&u.length&&i.push(R(R({},a),{items:u}))}}catch(e){l.e(e)}finally{l.f()}return qe(i)}return n.filter(e,r,t,b.filterMatchMode,b.filterLocale)}return e}(),Qe=p.isNotEmpty(b.tooltip),Ze=T.getOtherProps(b),et=p.reduceKeys(Ze,f.ARIA_PROPS),tt=function(){if(b.virtualScrollerOptions){var t=R(R({},b.virtualScrollerOptions),{items:Ye,onLazyLoad:function(e){return b.virtualScrollerOptions.onLazyLoad(R(R({},e),{filter:Ye}))},itemTemplate:function(e,t){return e&&$e(e,t.index,t)},contentTemplate:function(t){var n=s(R({ref:X,style:Y.sx("list",{options:t}),className:Y.cx("list",{options:t}),role:"listbox",tabIndex:"-1","aria-multiselectable":b.multiple,onFocus:He,onBlur:Je,onKeyDown:Fe},et),Y.ptm("list"));return e.createElement("ul",n,t.children)}});return e.createElement(m,h({ref:J},t,{pt:Y.ptm("virtualScroller")}))}var n=p.isNotEmpty(Ye)?Ye.map($e):$?We(b.emptyFilterMessage,!0):We(b.emptyMessage),r=s(R({ref:X,className:Y.cx("list"),role:"listbox","aria-multiselectable":b.multiple,tabIndex:"-1",onFocus:He,onBlur:Je,onKeyDown:Fe},et),Y.ptm("list"));return e.createElement("ul",r,n)}(),nt=b.filter?e.createElement(k,{hostName:"ListBox",filter:z,filterIcon:b.filterIcon,onFilter:Le,resetFilter:Ne,filterTemplate:b.filterTemplate,disabled:b.disabled,filterPlaceholder:b.filterPlaceholder,filterInputProps:b.filterInputProps,ptCallbacks:Y,metaData:W}):null,rt=s({className:Y.cx("wrapper"),style:b.listStyle},Y.ptm("wrapper")),ot=s({ref:H,id:b.id,className:Y.cx("root"),style:b.style},T.getOtherProps(b),Y.ptm("root")),it=s({ref:I,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:b.disabled?-1:b.tabIndex,onFocus:function(){f.focus(X.current);var e=f.getFirstFocusableElement(H.current,':not([data-p-hidden-focusable="true"])');E.current.tabIndex=f.isElement(e)?void 0:-1,I.current.tabIndex=-1,he(null,0)},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},Y.ptm("hiddenFirstFocusableEl")),lt=s({ref:E,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:b.disabled?-1:b.tabIndex,onFocus:function(e){if(e.relatedTarget===X.current){var t=f.getFirstFocusableElement(H.current,':not([data-p-hidden-focusable="true"])');f.focus(t),I.current.tabIndex=void 0}else f.focus(I.current);E.current.tabIndex=-1},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},Y.ptm("hiddenLastFocusableEl"));return e.createElement(e.Fragment,null,e.createElement("div",ot,e.createElement("span",it),nt,e.createElement("div",rt,tt),e.createElement("span",lt)),Qe&&e.createElement(u,h({target:H,content:b.tooltip,pt:Y.ptm("tooltip")},b.tooltipOptions)))})));H.displayName="ListBox";export{H as ListBox};