Liferay.Loader.define("@liferay/frontend-data-set-web@1.0.31/management_bar/components/BulkActions",["module","exports","require","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/link","liferay!frontend-js-react-web$classnames","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../FrontendDataSetContext","../../utils/eventsDefinitions","../../utils/sidePanels"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=d(n("@frontend-taglib-clay$clayui/icon")),r=d(n("@frontend-taglib-clay$clayui/link")),l=d(n("liferay!frontend-js-react-web$classnames")),o=n("frontend-js-web"),c=(d(n("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=a?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(n,r,l):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react"))),i=d(n("../../FrontendDataSetContext")),u=n("../../utils/eventsDefinitions"),s=n("../../utils/sidePanels");function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function d(e){return e&&e.__esModule?e:{default:e}}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e,t=[]){return"?".concat(e,"=").concat(t.join(","))}function g(e,t,n=[]){return m(m({},e),{},{url:e.baseURL+y(t,n)})}var O=function({bulkActions:e,fluid:t,selectAllItems:n,selectedItems:f,selectedItemsKey:d,selectedItemsValue:b,total:p}){const{actionParameterName:y,onBulkActionItemClick:O}=(0,c.useContext)(i.default),[j,v]=(0,c.useState)(null);return(0,c.useEffect)((()=>{if(!j)return;const e=(0,s.getOpenedSidePanel)();(null==e?void 0:e.id)===j.id&&e.url.indexOf(j.baseURL)>-1&&Liferay.fire(u.OPEN_SIDE_PANEL,g(j,b))}),[b]),b.length?c.default.createElement(i.default.Consumer,null,(({formId:i,formName:s,loadData:j,namespace:P,sidePanelId:w})=>c.default.createElement("nav",{className:"management-bar management-bar-primary navbar navbar-expand-md pb-2 pt-2 subnav-tbar"},c.default.createElement("div",{className:(0,l.default)("container-fluid container-fluid-max-xl py-1",!t&&"px-0")},c.default.createElement("ul",{className:"navbar-nav"},c.default.createElement("li",{className:"nav-item"},c.default.createElement("span",{className:"text-truncate"},Liferay.Util.sub(Liferay.Language.get("x-of-x-items-selected"),b.length,p)),c.default.createElement(r.default,{className:"ml-3",href:"#",onClick:e=>{e.preventDefault(),n()}},Liferay.Language.get("select-all")))),c.default.createElement("div",{className:"bulk-actions"},e.map(((e,t)=>c.default.createElement("button",{className:(0,l.default)("btn btn-monospaced btn-link",t>0&&"ml-1"),key:e.label,onClick:()=>function(e,t,n,a,r,l){const{data:c,href:i,slug:s,target:p}=e;if("sidePanel"===p){const e={baseURL:i,id:l,onAfterSubmit:()=>a(),slug:null!=s?s:null};Liferay.fire(u.OPEN_SIDE_PANEL,g(e,d,b)),v(e)}else if(O)O({action:e,selectedData:{items:f,keyValues:b}});else if(t||n&&r){const e=t||"".concat(r).concat(n),a=document.getElementById(e);a&&(0,o.postForm)(a,{data:m(m({},c),{},{["".concat(y||d)]:b.join(",")}),url:i||a.action})}}(e,i,s,j,P,w),type:"button"},c.default.createElement(a.default,{symbol:e.icon}))))))))):null};t.default=O}}));
//# sourceMappingURL=BulkActions.js.map