Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.151/page_editor/plugins/fragments_and_widgets/components/TabCollection",["module","exports","require","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../app/config/constants/fragmentsDisplayStyles","../../../app/config/constants/listItemTypes","../../../app/config/index","../../../common/hooks/useSessionState","../hooks/useKeyboardNavigation","./TabItem"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=TabCollection;var l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),n=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),o=_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),i=_interopRequireDefault(a("liferay!frontend-js-react-web$react")),s=a("../../../app/config/constants/fragmentsDisplayStyles"),r=a("../../../app/config/constants/listItemTypes"),c=a("../../../app/config/index"),d=a("../../../common/hooks/useSessionState"),u=_interopRequireDefault(a("../hooks/useKeyboardNavigation")),p=_interopRequireDefault(a("./TabItem"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function TabCollection({collection:e,displayStyle:t,initialOpen:a,isSearchResult:l}){const[n,o]=(0,d.useSessionState)("".concat(c.config.portletNamespace,"_fragment-collection_").concat(e.collectionId,"_open"),a);return i.default.createElement(TabCollectionCollapse,{open:n||l,setOpen:o,title:e.label},e.collections&&e.collections.map(((e,a)=>i.default.createElement(TabCollection,{collection:e,displayStyle:t,initialOpen:!1,isSearchResult:l,key:a}))),i.default.createElement("ul",{"aria-orientation":"vertical",className:"list-unstyled page-editor__fragments-widgets__tab-collection-".concat(t," pb-2 w-100"),role:"menu"},e.children.map((e=>{var a;return i.default.createElement(i.default.Fragment,{key:e.itemId},i.default.createElement(p.default,{displayStyle:t,item:e,key:e.itemId}),(null===(a=e.portletItems)||void 0===a?void 0:a.length)&&i.default.createElement(TabPortletItems,{item:e}))}))))}TabCollection.proptypes={collection:o.default.shape({children:o.default.array,collectionId:o.default.string,label:o.default.string}).isRequired,displayStyle:o.default.oneOf(Object.values(s.FRAGMENTS_DISPLAY_STYLES)),isSearchResult:o.default.bool,open:o.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,open:t,setOpen:a,title:o}){const{isTarget:s,setElement:c}=(0,u.default)({handleOpen:e=>{a(e)},type:r.LIST_ITEM_TYPES.header});return i.default.createElement("li",{className:"page-editor__collapse panel-group panel-group-flush",role:"none"},i.default.createElement("button",{"aria-expanded":t?"true":"false","aria-haspopup":"menu",className:(0,n.default)("btn","btn-unstyled","collapse-icon","sheet-subtitle",{collapsed:!t}),onClick:()=>a(!t),ref:c,role:"menuitem",tabIndex:s?0:-1,type:"button"},i.default.createElement("span",{className:"c-inner text-truncate",tabIndex:-1},o,i.default.createElement("span",{className:"text-secondary collapse-icon-".concat(t?"open":"closed")},i.default.createElement(l.default,{symbol:t?"angle-down":"angle-right"})))),t&&e)}TabPortletItems.proptypes={data:o.default.shape({instanceable:o.default.bool,portletId:o.default.string,portletItemId:o.default.string,used:o.default.bool}).isRequired,disabled:o.default.bool,icon:o.default.string,itemId:o.default.string,label:o.default.string,portletItems:o.default.array,preview:o.default.string,type:o.default.string},TabCollectionCollapse.proptypes={open:o.default.bool.isRequired,setOpen:o.default.func.isRequired,title:o.default.string.isRequired}}}));
//# sourceMappingURL=TabCollection.js.map