Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.179/page_editor/plugins/fragments_and_widgets/components/TabCollection",["module","exports","require","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$classnames","frontend-js-components-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../app/config/constants/fragmentsDisplayStyles","../../../app/config/constants/listItemTypes","../../../app/config/index","../hooks/useKeyboardNavigation","./TabItem"],(function(e,t,l){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=TabCollection;var a=_interopRequireDefault(l("@frontend-taglib-clay$clayui/icon")),n=_interopRequireDefault(l("liferay!frontend-js-react-web$classnames")),o=l("frontend-js-components-web"),r=_interopRequireDefault(l("liferay!frontend-js-react-web$prop-types")),i=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var l={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var o=a?Object.getOwnPropertyDescriptor(e,n):null;o&&(o.get||o.set)?Object.defineProperty(l,n,o):l[n]=e[n]}l.default=e,t&&t.set(e,l);return l}(l("liferay!frontend-js-react-web$react")),c=l("../../../app/config/constants/fragmentsDisplayStyles"),s=l("../../../app/config/constants/listItemTypes"),u=l("../../../app/config/index"),d=_interopRequireDefault(l("../hooks/useKeyboardNavigation")),p=_interopRequireDefault(l("./TabItem"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e="highlighted";function TabCollection({collection:t,displayStyle:l,initialOpen:a,isSearchResult:n}){const[r,c]=(0,o.useSessionState)("".concat(u.config.portletNamespace,"_fragment-collection_").concat(t.collectionId,"_open"),a),s=(0,i.useRef)();return i.default.createElement(TabCollectionCollapse,{collapseRef:s,isSearchResult:n,open:r,setOpen:c,title:t.label},t.collections&&t.collections.map(((e,t)=>i.default.createElement(TabCollection,{collection:e,displayStyle:l,initialOpen:!1,isSearchResult:n,key:t}))),i.default.createElement("ul",{"aria-orientation":"vertical",className:"list-unstyled page-editor__fragments-widgets__tab-collection-".concat(l," pb-2 w-100"),role:"menu"},t.children.map(((a,n)=>{var o;return i.default.createElement(i.default.Fragment,{key:a.itemId},i.default.createElement(p.default,{displayStyle:l,item:a,key:a.itemId,onRemoveHighlighted:()=>(l=>{var a,n;if(t.collectionId!==e)return;const o=null===(a=s.current)||void 0===a?void 0:a.querySelectorAll("li");1===o.length&&s.current.nextSibling.querySelector("button").focus();null===(n=o[0===l?1:l-1])||void 0===n||n.focus()})(n)}),(null===(o=a.portletItems)||void 0===o?void 0:o.length)&&i.default.createElement(TabPortletItems,{item:a}))}))))}TabCollection.proptypes={collection:r.default.shape({children:r.default.array,collectionId:r.default.string,label:r.default.string}).isRequired,displayStyle:r.default.oneOf(Object.values(c.FRAGMENTS_DISPLAY_STYLES)),isSearchResult:r.default.bool,open:r.default.bool};const TabPortletItems=({item:e})=>i.default.createElement("ul",{className:"d-flex flex-wrap list-unstyled w-100"},e.portletItems.map(((e,t)=>i.default.createElement(p.default,{item:e,key:t}))));function TabCollectionCollapse({children:e,collapseRef:t,isSearchResult:l,open:o,setOpen:r,title:c}){const[u,p]=(0,i.useState)(!0),f=l?u:o,y=l?p:r,{isTarget:m,setElement:b}=(0,d.default)({handleOpen:y,type:s.LIST_ITEM_TYPES.header});return i.default.createElement("li",{className:"page-editor__collapse panel panel-unstyled",ref:t,role:"none"},i.default.createElement("button",{"aria-expanded":f?"true":"false","aria-haspopup":"menu",className:(0,n.default)("mb-3 panel-header panel-header-link collapse-icon collapse-icon-middle show btn btn-unstyled",{collapsed:!f}),onClick:()=>y(!f),ref:b,role:"menuitem",tabIndex:m?0:-1,type:"button"},i.default.createElement("span",{className:"c-inner panel-title text-truncate",tabIndex:-1},c,i.default.createElement("span",{className:"text-secondary collapse-icon-".concat(f?"open":"closed")},i.default.createElement(a.default,{symbol:f?"angle-down":"angle-right"})))),f&&e)}TabPortletItems.proptypes={data:r.default.shape({instanceable:r.default.bool,portletId:r.default.string,portletItemId:r.default.string,used:r.default.bool}).isRequired,disabled:r.default.bool,icon:r.default.string,itemId:r.default.string,label:r.default.string,portletItems:r.default.array,preview:r.default.string,type:r.default.string},TabCollectionCollapse.proptypes={open:r.default.bool.isRequired,setOpen:r.default.func.isRequired,title:r.default.string.isRequired}}}));
//# sourceMappingURL=TabCollection.js.map