Liferay.Loader.define("data-engine-js-components-web@1.0.112/js/custom/form-report/components/chart/Legend",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$react","../../utils/colors","../../utils/data"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function Legend({activeIndex:t,data:a,onMouseOut:n,onMouseOver:r}){const[u,c]=(0,l.useState)(!1),handleOnMouseOver=({currentTarget:e})=>{const t=e.closest("li").dataset.item;r(parseInt(t,10))},i=a.map((({label:e})=>e)),d=a.map((({count:e})=>e)).reduce(((e,t)=>e+t));return l.default.createElement("div",{className:"legend-container well well-lg"},l.default.createElement("div",{className:"legend-list"},l.default.createElement("ul",null,i.slice(0,u?i.length:e).map(((e,r)=>l.default.createElement(Label,{active:null===t||t===r,color:(0,o.default)(r),entries:a[r].count,index:r,key:"item-".concat(r),label:e,onMouseOut:n,onMouseOver:handleOnMouseOver,totalEntries:d}))),l.default.createElement(ShowAll,{expand:c,expanded:u,labelsLength:i.length}))))};var n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),l=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 a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),o=_interopRequireDefault(a("../../utils/colors")),u=a("../../utils/data");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=10,Label=({active:e,color:t,entries:a,index:n,label:r,onMouseOut:o,onMouseOver:c,totalEntries:i})=>l.default.createElement("li",{className:e?"":"dim","data-item":n},l.default.createElement("svg",{height:"20",width:"20"},l.default.createElement("circle",{cx:"10",cy:"10",fill:t,onMouseOut:o,onMouseOver:c,r:"9",strokeWidth:"3"})),l.default.createElement("p",{onBlur:o,onFocus:c,onMouseOut:o,onMouseOver:c,tabIndex:0,x:"0em",y:"1em"},l.default.createElement("span",{dy:"2em",x:"2.5em"},r),l.default.createElement("span",{className:"sr-only"},": ".concat(a," "),1===Number(a)?"".concat(Liferay.Language.get("entry").toLowerCase()," "):"".concat(Liferay.Language.get("entries").toLowerCase()," "),(0,u.roundPercentage)((0,u.getPercentage)(a,i))))),ShowAll=({expand:t,expanded:a,labelsLength:o})=>{if(o<=e)return null;return l.default.createElement("div",{className:"show-more-action"},l.default.createElement("svg",{height:"20",width:"20"},l.default.createElement("g",null,l.default.createElement("circle",{cx:"10",cy:"10",fill:"#F0F5FF",r:"9",strokeWidth:"3"}),l.default.createElement(r.default,{symbol:a?"caret-top-l":"caret-bottom-l"}))),l.default.createElement(n.default,{className:"show-more-button",displayType:"unstyled",onClick:()=>{t(!a)}},a?Liferay.Language.get("show-less"):Liferay.Language.get("show-all")))}}}));
//# sourceMappingURL=Legend.js.map