@e-llm-studio/federated-dashboard-components 2.2.9-rca-test-7 → 2.2.9-rca-test-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ExecutiveDashboard/components/Insights/AgReport.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/DrillTable.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/drillDay.js +2 -0
- package/dist/ExecutiveDashboard/components/Insights/drillDay.js.map +1 -0
- package/dist/ExecutiveDashboard/components/Table/FTable.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/AgReport.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/DrillTable.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/drillDay.js +2 -0
- package/dist/cjs/ExecutiveDashboard/components/Insights/drillDay.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/components/Table/FTable.js +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/ExecutiveDashboard/TestExecutiveDashboard.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/AgReport.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/DrillTable.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/drillDay.d.ts +12 -0
- package/dist/types/ExecutiveDashboard/components/Insights/drillDay.d.ts.map +1 -0
- package/dist/types/ExecutiveDashboard/components/Table/FTable.d.ts +2 -0
- package/dist/types/ExecutiveDashboard/components/Table/FTable.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/types/insights.d.ts +1 -0
- package/dist/types/ExecutiveDashboard/types/insights.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),n=require("react/jsx-runtime"),t=require("lucide-react"),l=require("react"),r=require("../../api/insightsApi.js"),i=require("./agPrimitives.js"),o=require("./insightsContextCore.js"),a=/\{([^{}]+)\}/g,s=function(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()})},u=function(e,n){return n.split(".").reduce(function(e,n){return e&&"object"==typeof e?e[n]:void 0},e)};function c(e,n){if(null==e||""===e)return"—";if("date"===n&&"string"==typeof e){var t=new Date("".concat(e.slice(0,10),"T00:00:00"));return Number.isNaN(t.getTime())?e:t.toLocaleDateString()}var l="number"==typeof e?e:"string"==typeof e&&""!==e.trim()&&!Number.isNaN(Number(e))&&n&&"text"!==n&&"chip"!==n?Number(e):null;return null!==l?"percent"===n?"".concat(new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(l),"%"):new Intl.NumberFormat(void 0,{maximumFractionDigits:"rating"===n?2:1}).format(l):"object"==typeof e?JSON.stringify(e):String(e)}function d(e,n,t){var l,i,o,a,s,u=n.trail;return{record:t.record,context:{row:null!==(i=null===(l=u[u.length-1])||void 0===l?void 0:l.label)&&void 0!==i?i:"",parent:null!==(a=null===(o=u[u.length-2])||void 0===o?void 0:o.label)&&void 0!==a?a:"",day:null!==(s=n.day)&&void 0!==s?s:"",startDate:r.toIsoDay(e.range.startDate),endDate:r.toIsoDay(e.range.endDate),trail:Object.fromEntries(u.map(function(e){return[e.entityKey,e.label]}))}}}var v=function(e,n,t,l){return e.replace(a,function(e,r){var i=function(e,n,t){var l=t.trim();return l.startsWith("context.")?u(e.context,l.slice(8)):l.startsWith("input.")?n[l.slice(6)]:u(e.record,l)}(n,t,r),o=null==i?"":"object"==typeof i?JSON.stringify(i):String(i);return l?encodeURIComponent(o):o})},y=function(e,n,t){return"string"==typeof e?v(e,n,t,!1):Array.isArray(e)?e.map(function(e){return y(e,n,t)}):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(function(e){var l=e[0],r=e[1];return[l,y(r,n,t)]})):e},f=new Set,h=["good","warning","bad","info","neutral"],g=function(e){return String(null!=e?e:"").trim().toLowerCase().replace(/[\s_-]+/g," ")};function p(t){var l,r=t.text,i=t.value,o=t.colors,a=o?null===(l=Object.entries(o).find(function(e){var n=e[0];return g(n)===g(i)}))||void 0===l?void 0:l[1]:void 0;if(a&&"object"==typeof a)return n.jsx("span",e.__assign({className:"ag-drill__chip",style:e.__assign({background:a.background,color:a.color},a.border?{boxShadow:"inset 0 0 0 1px ".concat(a.border)}:{})},{children:r}));var s="string"==typeof a&&h.includes(a)?a:"neutral";return n.jsx("span",e.__assign({className:"ag-drill__chip ag-drill__chip--".concat(s)},{children:r}))}function _(r){var i,o=r.button,a=r.question,s=r.onCancel,u=r.onSubmit,c=l.useState({}),d=c[0],v=c[1],y=l.useRef(null);l.useEffect(function(){var e;return null===(e=y.current)||void 0===e?void 0:e.focus()},[]);var f=null!==(i=o.ask)&&void 0!==i?i:[],h=f.some(function(e){var n;return!(null===(n=d[e.key])||void 0===n?void 0:n.trim())});return n.jsx("div",e.__assign({className:"ag-drill__dialog",role:"presentation",onMouseDown:function(e){return e.target===e.currentTarget&&s()}},{children:n.jsxs("form",e.__assign({className:"ag-drill__dialog-box",role:"dialog","aria-modal":"true","aria-label":o.label,onSubmit:function(e){e.preventDefault(),h||u(d)},onKeyDown:function(e){"Escape"===e.key&&(e.stopPropagation(),s())}},{children:[n.jsxs("header",{children:[n.jsx("strong",{children:o.label}),n.jsx("button",e.__assign({type:"button","aria-label":"Cancel",onClick:s},{children:n.jsx(t.X,{"aria-hidden":"true"})}))]}),a?n.jsx("p",{children:a}):null,f.map(function(t,l){var r;return n.jsxs("label",{children:[n.jsx("span",{children:t.label}),n.jsx("input",{ref:0===l?function(e){y.current=e}:void 0,value:null!==(r=d[t.key])&&void 0!==r?r:"",onChange:function(n){return v(function(l){var r;return e.__assign(e.__assign({},l),((r={})[t.key]=n.target.value,r))})},required:!0})]},t.key)}),n.jsxs("footer",{children:[n.jsx("button",e.__assign({type:"button",onClick:s},{children:"Cancel"})),n.jsx("button",e.__assign({ref:f.length?void 0:function(e){y.current=e},type:"submit",disabled:h},{children:o.label}))]})]}))}))}exports.default=function(a){var h,g,b,m,x,w,j,k,K,N,S,C,D,T,E,A,I,B=this,O=a.table,P=a.tabEntityKey,M=a.context,R=a.onRowClick,q=a.className,L=o.useInsights(),z=M.trail.length>0,F=l.useMemo(function(){return function(n,t,l){var r,i,o,a,s,u={filterBy:l?"trail":"none",period:l?"day":"range"};return(null===(r=n.views)||void 0===r?void 0:r.length)?n.views.map(function(t){var l,r,i,o,a,s;return e.__assign(e.__assign({},t),{source:null!==(l=t.source)&&void 0!==l?l:"insights",filterBy:null!==(r=t.filterBy)&&void 0!==r?r:"row"===t.scope?"row":u.filterBy,period:null!==(i=t.period)&&void 0!==i?i:u.period,onRowClick:null!==(o=t.onRowClick)&&void 0!==o?o:n.onRowClick,buttons:null!==(s=null!==(a=t.buttons)&&void 0!==a?a:n.buttons)&&void 0!==s?s:[]})}):[{source:null!==(i=n.source)&&void 0!==i?i:"insights",entityKey:t,tableKey:n.tableKey,columns:n.columns,onRowClick:n.onRowClick,filterBy:l?null!==(o=n.filterBy)&&void 0!==o?o:u.filterBy:"none",period:l?null!==(a=n.period)&&void 0!==a?a:u.period:"range",buttons:null!==(s=n.buttons)&&void 0!==s?s:[]}]}(O,P,z)},[O,P,z]),H=F.map(function(e){var n;return"".concat(e.source,":").concat(null!==(n=e.entityKey)&&void 0!==n?n:e.tableKey)}).join("|"),J=l.useState(0),U=J[0],W=J[1],X=l.useState(""),G=X[0],Q=X[1],V=l.useState(""),Y=V[0],Z=V[1],$=l.useState(O.defaultSort),ee=$[0],ne=$[1],te=l.useState([]),le=te[0],re=te[1],ie=l.useState(null),oe=ie[0],ae=ie[1],se=l.useState(0),ue=se[0],ce=se[1],de=l.useState(!1),ve=de[0],ye=de[1],fe=l.useState(0),he=fe[0],ge=fe[1],pe=l.useState(!1),_e=pe[0],be=pe[1],me=l.useState(null),xe=me[0],we=me[1],je=l.useState(null),ke=je[0],Ke=je[1],Ne=l.useState(null),Se=Ne[0],Ce=Ne[1],De=l.useState(null),Te=De[0],Ee=De[1];l.useEffect(function(){return W(0)},[H]),l.useEffect(function(){var e=setTimeout(function(){return Z(G.trim())},300);return function(){return clearTimeout(e)}},[G]);var Ae=F[Math.min(U,F.length-1)],Ie=M.trail,Be=Ie[Ie.length-1],Oe=null!==(h=O.pageSize)&&void 0!==h?h:10,Pe=Ae&&"table"!==Ae.source?Be&&Ae.entityKey&&!(null==L?void 0:L.isChildOf(Ae.entityKey,Be.entityKey))?"movers":"rows":"table",Me="rows"===Pe&&Be?Be.nodeKey:void 0,Re=l.useMemo(function(){var n,t,l;if(!L||!Ae||"table"===Ae.source)return[];if(null===(n=Ae.columns)||void 0===n?void 0:n.length)return Ae.columns;var r=L.entityKpis(null!==(t=Ae.entityKey)&&void 0!==t?t:"").slice(0,4);return e.__spreadArray([{key:"label",source:"field",label:L.entityName(null!==(l=Ae.entityKey)&&void 0!==l?l:"")}],r.map(function(e){return{key:e,source:"kpi",show:"both",sortable:!0}}),!0)},[L,Ae]),qe=Re.find(function(e){return"children"===e.source}),Le=null!==(g=null==L?void 0:L.headlineKpi)&&void 0!==g?g:"",ze=l.useMemo(function(){return L?"day"===(null==Ae?void 0:Ae.period)&&M.day?{start:M.day,end:M.day}:{start:r.toIsoDay(L.range.startDate),end:r.toIsoDay(L.range.endDate)}:{start:"",end:""}},[L,null==Ae?void 0:Ae.period,M.day]),Fe=Ie.map(function(e){return"".concat(e.entityKey,":").concat(e.nodeKey)}).join("|"),He=l.useMemo(function(){if(!L||!Ae)return{};var n=e.__assign({},L.sidebarFilters);return("trail"===Ae.filterBy?Ie:"row"===Ae.filterBy?Ie.slice(-1):[]).forEach(function(e){var t=L.labelColumnOf(e.entityKey);t&&e.label&&(n[t]=[e.label])}),n},[L,Ae,Fe]),Je=JSON.stringify(He),Ue="chip.criticality"===(null==ee?void 0:ee.key)?"criticality":null==ee?void 0:ee.key,We="table"===Pe?"":Y,Xe=function(n,t){return e.__awaiter(B,void 0,void 0,function(){var l,i,o,a,s,u,c,d,v,y,f;return e.__generator(this,function(h){switch(h.label){case 0:if(!L||!Ae)return[2,void 0];if("table"!==Pe)return[3,2];if(!Ae.tableKey)throw new Error("Pick a Table Builder table for this list.");return[4,r.fetchDrillTableRows(L.api,{tableKey:Ae.tableKey,startDay:ze.start,endDay:ze.end,filters:He,pageSize:Oe,cursor:n?oe:null},t)];case 1:return l=h.sent(),i=n?le.length:0,[2,{rows:l.rows.map(function(e,n){return{id:"t".concat(i+n),record:e}}),count:l.count,hasMore:l.hasNext,cursor:l.nextCursor,offset:0}];case 2:return"movers"!==Pe?[3,4]:(o=n?ue:0,[4,r.fetchInsightsDrivers(L.api,{dataDay:null!==(d=M.day)&&void 0!==d?d:void 0,kpiId:Le,parentNodeKey:null==Be?void 0:Be.nodeKey,entityKey:Ae.entityKey,tab:"drivers",limit:Oe,offset:o,filters:L.range.filters},t)]);case 3:return a=h.sent(),s=a.rows.map(function(e){return function(e,n){var t,l,r,i,o;return{rank:e.rank,nodeKey:e.nodeKey,label:e.label,parent:null,metrics:(t={},t[n]={value:e.value,previous:e.previous,deltaPct:e.deltaPct,direction:e.changeDirection,tone:e.tone},t),barPct:null,chip:{criticality:e.criticality,movementType:e.movementType},report:{reportId:null!==(r=null===(l=e.report)||void 0===l?void 0:l.reportId)&&void 0!==r?r:null,status:(null===(i=e.report)||void 0===i?void 0:i.reportId)?"generated":"none",kpiId:n},action:null,children:[],entityKey:null!==(o=e.entityKey)&&void 0!==o?o:null}}(e,Le)}),u=a,[2,{rows:s.map(function(e){return{id:e.nodeKey,record:e,insights:e}}),count:null!==(v=u.total)&&void 0!==v?v:o+s.length,hasMore:Boolean(u.hasMore),cursor:null,offset:o+s.length}];case 4:return[4,r.fetchLevelRows(L.api,null!==(y=Ae.entityKey)&&void 0!==y?y:"",e.__assign({},L.range),{sort:Ue,order:null==ee?void 0:ee.order,search:We||void 0,pageSize:Oe,parentNodeKey:Me,includeChildren:qe?null!==(f=qe.max)&&void 0!==f?f:3:void 0,childEntityKey:null==qe?void 0:qe.childEntityKey,cursor:n&&null!=oe?oe:void 0},t)];case 5:return[2,{rows:(c=h.sent()).rows.map(function(n){var t,l;return{id:n.nodeKey,record:n,insights:e.__assign(e.__assign({},n),{entityKey:null!==(l=null!==(t=n.entityKey)&&void 0!==t?t:Ae.entityKey)&&void 0!==l?l:null})}}),count:c.count,hasMore:c.hasNext,cursor:c.nextCursor,offset:0}]}})})};if(l.useEffect(function(){if(L&&Ae){var e=new AbortController;return be(!0),we(null),re([]),ae(null),ce(0),Ke(null),Xe(!1,e.signal).then(function(e){var n;e&&(re(e.rows),ge(e.count),ye(e.hasMore),ae(null!==(n=e.cursor)&&void 0!==n?n:null),ce(e.offset))}).catch(function(e){"AbortError"!==(null==e?void 0:e.name)&&we(e instanceof Error?e.message:"The rows couldn't be loaded.")}).finally(function(){e.signal.aborted||be(!1)}),function(){return e.abort()}}},[null==L?void 0:L.api,null==L?void 0:L.revision,null==L?void 0:L.rangeKey,H,U,Pe,Me,Fe,M.day,ze.start,ze.end,Je,We,Ue,null==ee?void 0:ee.order,Oe,null==qe?void 0:qe.childEntityKey]),!L||!Ae)return null;var Ge="table"===Pe?function(n,t,l){var r,i,o=t.tableKey?n.tableSource(t.tableKey):void 0,a=(null===(r=null==o?void 0:o.columns)||void 0===r?void 0:r.length)?o.columns:Object.keys(null!=l?l:{}).map(function(e){return{key:e,label:s(e)}}),u=null!==(i=t.columns)&&void 0!==i?i:[];return e.__spreadArray(e.__spreadArray([],u.filter(function(e){return e.key&&a.some(function(n){return n.key===e.key})}),!0),a.filter(function(e){return!u.some(function(n){return n.key===e.key})}).map(function(e){return{key:e.key,source:"field"}}),!0).filter(function(e){return!e.hidden}).map(function(n){var t,l,r,i;return e.__assign(e.__assign({},n),{source:"field",label:null!==(r=null!==(t=n.label)&&void 0!==t?t:null===(l=a.find(function(e){return e.key===n.key}))||void 0===l?void 0:l.label)&&void 0!==r?r:s(null!==(i=n.key)&&void 0!==i?i:"")})})}(L,Ae,null===(b=le[0])||void 0===b?void 0:b.record):Re,Qe=L.hostTables["table"===Ae.source?null!==(m=Ae.tableKey)&&void 0!==m?m:"":"insights.".concat(null!==(x=Ae.entityKey)&&void 0!==x?x:"")],Ve=(null===(w=null==Qe?void 0:Qe.columns)||void 0===w?void 0:w.length)?Qe.columns:null,Ye=function(n){return n.insights?function(e){var n,t,l,r,i,o,a,s,u,c,d,v,y,f,h,g,p,_={id:e.nodeKey,nodeKey:e.nodeKey,label:null!==(n=e.label)&&void 0!==n?n:e.nodeKey,entityKey:null!==(t=e.entityKey)&&void 0!==t?t:null,parent:null!==(r=null===(l=e.parent)||void 0===l?void 0:l.label)&&void 0!==r?r:null,criticality:null!==(o=null===(i=e.chip)||void 0===i?void 0:i.criticality)&&void 0!==o?o:null,movementType:null!==(s=null===(a=e.chip)||void 0===a?void 0:a.movementType)&&void 0!==s?s:null,reportId:null!==(c=null===(u=e.report)||void 0===u?void 0:u.reportId)&&void 0!==c?c:null,reportStatus:null!==(v=null===(d=e.report)||void 0===d?void 0:d.status)&&void 0!==v?v:null,actionStatus:null!==(f=null===(y=e.action)||void 0===y?void 0:y.status)&&void 0!==f?f:null,assignee:null!==(g=null===(h=e.action)||void 0===h?void 0:h.assigneeName)&&void 0!==g?g:null,children:e.children.map(function(e){return e.label}).filter(Boolean),__row:e};return Object.entries(null!==(p=e.metrics)&&void 0!==p?p:{}).forEach(function(e){var n,t,l,r=e[0],i=e[1];_[r]=null!==(n=null==i?void 0:i.value)&&void 0!==n?n:null,_["".concat(r,"_delta")]=null!==(t=null==i?void 0:i.deltaPct)&&void 0!==t?t:null,_["".concat(r,"_previous")]=null!==(l=null==i?void 0:i.previous)&&void 0!==l?l:null}),_}(n.insights):e.__assign({id:n.id},n.record)},Ze="table"===Pe?"none":null!==(j=Ae.onRowClick)&&void 0!==j?j:"none",$e="none"!==Ze,en="table"===Pe?e.__spreadArray([],le,!0).filter(function(e){return!Y||(Ve?Ve.map(function(e){return e.key}):Ge.map(function(e){var n;return null!==(n=e.key)&&void 0!==n?n:""})).some(function(n){var t;return String(null!==(t=e.record[n])&&void 0!==t?t:"").toLowerCase().includes(Y.toLowerCase())})}).sort(function(e,n){if(!(null==ee?void 0:ee.key))return 0;var t=e.record[ee.key],l=n.record[ee.key],r=Number(t),i=Number(l),o=null==t||null==l||""===t||""===l||Number.isNaN(r)||Number.isNaN(i)?String(null!=t?t:"").localeCompare(String(null!=l?l:"")):r-i;return"asc"===ee.order?o:-o}):le,nn=function(e){var n;return"movers"!==Pe&&("table"===Pe?!1!==e.sortable:null!==(n=e.sortable)&&void 0!==n?n:"kpi"===e.source||"chip.criticality"===e.key)},tn=function(e){var n;return(null===(n=L.tableSource(null!=e?e:""))||void 0===n?void 0:n.title)||s(null!=e?e:"")},ln="table"===Ae.source?tn(Ae.tableKey):L.entityName(null!==(k=Ae.entityKey)&&void 0!==k?k:""),rn="table"===Ae.source?ln:L.entityPluralName(null!==(K=Ae.entityKey)&&void 0!==K?K:""),on=function(e){var n;return e.title||("table"===e.source?tn(e.tableKey):L.entityPluralName(null!==(n=e.entityKey)&&void 0!==n?n:""))},an=F.length>1?"Drill down in {row}":z?"table"===Ae.source?"{part}":L.labels.drillTableTitle:"{parts}",sn=(null!==(N=O.title)&&void 0!==N?N:an).replace(/\{row\}/g,null!==(S=null==Be?void 0:Be.label)&&void 0!==S?S:"").replace(/\{parent\}/g,null!==(D=null===(C=Ie[Ie.length-2])||void 0===C?void 0:C.label)&&void 0!==D?D:"").replace(/\{day\}/g,M.day?i.formatHeaderDate(M.day):"").replace(/\{parts\}|\{plural\}/g,rn).replace(/\{part\}/g,ln).replace(/\s+/g," ").trim(),un=function(e){return Ae.buttons.filter(function(n){var t,l,r;if(n.adminOnly&&!L.viewer.isAdmin)return!1;if(!("host"!==n.type||n.handler&&L.actionHandlers[n.handler]))return f.has(null!==(t=n.handler)&&void 0!==t?t:"")||(f.add(null!==(l=n.handler)&&void 0!==l?l:""),console.warn('Decision Advantage: no host handler named "'.concat(null!==(r=n.handler)&&void 0!==r?r:"",'" is registered, so its button is hidden.'))),!1;if(n.when){var i=u(e.record,n.when);if(null==i||""===i)return!1}return!0})},cn=function(n,t,l){return e.__awaiter(B,void 0,void 0,function(){var r,i,o,a,s,u,c,f,h,g,p,_,b,m,x,w,j,k,K,N,S,C;return e.__generator(this,function(e){switch(e.label){case 0:r=d(L,M,t),i="".concat(t.id,":").concat(null!==(m=n.id)&&void 0!==m?m:n.label),Ke(null),e.label=1;case 1:if(e.trys.push([1,9,10,11]),"open"===n.type){if(o=v(null!==(x=n.url)&&void 0!==x?x:"",r,l,!0),/^https:\/\//i.test(o))window.open(o,"_blank","noopener,noreferrer");else{if(!/^mailto:/i.test(o))throw new Error("This link isn't allowed: only https and mailto links open.");window.location.href=o}return[2]}return Ee(i),"host"!==n.type?[3,3]:[4,(0,L.actionHandlers[null!==(w=n.handler)&&void 0!==w?w:""])({button:n,row:t.record,context:r.context,inputs:l})];case 2:return a=e.sent(),Ke({tone:"ok",text:a&&a.message||"".concat(n.label,": done.")}),[2];case 3:if("https:"!==(s=new URL(v(null!==(j=n.url)&&void 0!==j?j:"",r,l,!0))).protocol)throw new Error("Only https APIs can be called.");return u=null!==(k=n.method)&&void 0!==k?k:"POST",c={Accept:"application/json"},Object.entries(null!==(K=n.headers)&&void 0!==K?K:{}).forEach(function(e){var n=e[0],t=e[1];c[n]=v(String(t),r,l,!1)}),L.api.accessToken&&L.approvedApiHosts.includes(s.host.toLowerCase())&&(c.Authorization="Bearer ".concat(L.api.accessToken)),(f="GET"!==u&&void 0!==n.body&&null!==n.body)&&(c["Content-Type"]="application/json"),[4,fetch(s.toString(),{method:u,headers:c,body:f?JSON.stringify(y(n.body,r,l)):void 0})];case 4:h=e.sent(),g="",e.label=5;case 5:return e.trys.push([5,7,,8]),[4,h.json()];case 6:return p=e.sent(),_=null==p?void 0:p.error,g=String(null!==(C=null!==(S=null!==(N=null==p?void 0:p.message)&&void 0!==N?N:null==_?void 0:_.errorMessage)&&void 0!==S?S:null==p?void 0:p.detail)&&void 0!==C?C:""),[3,8];case 7:return e.sent(),g="",[3,8];case 8:if(!h.ok)throw new Error(g||"".concat(n.label," failed (status ").concat(h.status,")."));return Ke({tone:"ok",text:g||"".concat(n.label,": done.")}),[3,11];case 9:return b=e.sent(),Ke({tone:"error",text:b instanceof Error?b.message:"".concat(n.label," failed.")}),[3,11];case 10:return Ee(null),[7];case 11:return[2]}})})},dn=function(e){var n,t,l,r=null!==(t=null!==(n=e.key)&&void 0!==n?n:e.id)&&void 0!==t?t:"",i="table"===Ae.source?Ae.tableKey:Ae.entityKey;return null!==(l=i?L.cellRenderers["".concat(i,".").concat(r)]:void 0)&&void 0!==l?l:L.cellRenderers[r]},vn=function(t,l){var r,i,o,a,s,d,v,y,f=null!==(r=l.key)&&void 0!==r?r:"",h=dn(l),g="kpi"===l.source&&t.insights?null===(i=t.insights.metrics[f])||void 0===i?void 0:i.value:"children"===l.source&&t.insights?t.insights.children.map(function(e){return e.label}).filter(Boolean):"label"===f&&t.insights?t.insights.label||t.insights.nodeKey:u(t.record,f);if(null==h?void 0:h.render){var _=h.render({column:l,value:g,record:t.record,row:t.insights,entityKey:Ae.entityKey,tableKey:Ae.tableKey});if(void 0!==_)return _}if(t.insights){var b=null===(o=L.renderInsightsCell)||void 0===o?void 0:o.call(L,{column:l,row:t.insights,entityKey:null!==(a=Ae.entityKey)&&void 0!==a?a:""});if(void 0!==b)return b}if("custom"===l.source)return null!==(s=l.emptyText)&&void 0!==s?s:"—";if("kpi"===l.source&&t.insights&&!(null==h?void 0:h.as)){var m=t.insights.metrics[f],x=c(null==m?void 0:m.value,l.format),w=null==(null==m?void 0:m.deltaPct)?"—":"".concat(m.deltaPct>0?"↑":m.deltaPct<0?"↓":""," ").concat(Math.abs(m.deltaPct),"%");return"delta"===l.show?n.jsx("span",e.__assign({className:(null==m?void 0:m.tone)?"ag-drill__change--".concat(m.tone):void 0},{children:w})):"value"===l.show?x:n.jsxs("span",e.__assign({className:"ag-drill__metric"},{children:[n.jsx("strong",{children:x}),n.jsx("small",e.__assign({className:(null==m?void 0:m.tone)?"ag-drill__change--".concat(m.tone):void 0},{children:w}))]}))}if("children"===l.source&&t.insights&&!(null==h?void 0:h.as)){var j=Array.from(new Set(g)),k=null!==(d=l.max)&&void 0!==d?d:3,K=j.length?"".concat(j.slice(0,k).join(", ")).concat(j.length>k?" +".concat(j.length-k):""):null!==(v=l.emptyText)&&void 0!==v?v:"—";return n.jsx("span",e.__assign({className:"ag-drill__contributors",title:j.join(", ")||void 0},{children:K}))}var N=null!==(y=null==h?void 0:h.as)&&void 0!==y?y:l.format;if("link"===N){var S="string"==typeof g?g:"";return/^https:\/\//i.test(S)?n.jsx("a",e.__assign({href:S,target:"_blank",rel:"noopener noreferrer"},{children:S})):c(g,"text")}var C=c(g,"chip"===N?"text":N);return"—"===C&&l.emptyText?l.emptyText:"chip"!==N&&!(null==h?void 0:h.colors)||"—"===C?C:n.jsx(p,{text:C.replace(/_/g," "),value:g,colors:null==h?void 0:h.colors})},yn=function(e){e.insights&&(null==R||R(e.insights,Ze))},fn=Ae.buttons.length>0,hn=function(e){var n;return null!==(n=e.align)&&void 0!==n?n:"kpi"===e.source?"right":"left"},gn="ag-drill-".concat(String(null!==(T=O.id)&&void 0!==T?T:sn).replace(/[^a-z0-9]+/gi,"-")),pn=!1!==O.search&&"movers"!==Pe;return n.jsxs("section",e.__assign({className:"ag-drill".concat(q?" ".concat(q):""),"aria-labelledby":gn,style:null===(E=null==Qe?void 0:Qe.card)||void 0===E?void 0:E.root},{children:[n.jsxs("header",e.__assign({className:"ag-drill__header",style:null===(A=null==Qe?void 0:Qe.card)||void 0===A?void 0:A.header},{children:[n.jsxs("div",{children:[n.jsx("h3",e.__assign({id:gn,style:null===(I=null==Qe?void 0:Qe.card)||void 0===I?void 0:I.title},{children:sn})),"movers"===Pe?n.jsxs("span",{children:["Rows that moved",M.day?" on ".concat(i.formatHeaderDate(M.day)):""]}):null]}),pn?n.jsxs("label",e.__assign({className:"ag-drill__search"},{children:[n.jsx(t.Search,{"aria-hidden":"true"}),n.jsx("input",{type:"search",value:G,onChange:function(e){return Q(e.target.value)},placeholder:"Search ".concat(rn.toLowerCase(),"…"),"aria-label":"Search ".concat(rn)})]})):null]})),F.length>1?n.jsx("div",e.__assign({className:"ag-drill__tabs",role:"tablist","aria-label":"What this table lists"},{children:F.map(function(t,l){var r;return n.jsx("button",e.__assign({type:"button",role:"tab","aria-selected":l===U,className:l===U?"is-active":void 0,onClick:function(){W(l),Q(""),Z(""),ne(O.defaultSort)}},{children:on(t)}),"".concat(t.source,":").concat(null!==(r=t.entityKey)&&void 0!==r?r:t.tableKey,":").concat(l))})})):null,ke?n.jsxs("p",e.__assign({className:"ag-drill__notice ag-drill__notice--".concat(ke.tone),role:"status"},{children:[ke.text,n.jsx("button",e.__assign({type:"button","aria-label":"Dismiss",onClick:function(){return Ke(null)}},{children:n.jsx(t.X,{"aria-hidden":"true"})}))]})):null,n.jsxs("div",e.__assign({className:"ag-drill__table-wrap","aria-live":"polite"},{children:[n.jsxs("table",e.__assign({className:"ag-drill__table"},{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[Ve?Ve.map(function(t){return n.jsx("th",e.__assign({className:t.headerClassName,style:e.__assign(e.__assign({},t.style),t.headerStyle)},{children:t.header}),t.key)}):Ge.map(function(t){var l,r,i,o,a,u=null!==(r=null!==(l=t.key)&&void 0!==l?l:t.id)&&void 0!==r?r:"",c=null!==(i=t.label)&&void 0!==i?i:"kpi"===t.source?L.kpiLabel(u):"children"===t.source?L.entityPluralName(null!==(o=t.childEntityKey)&&void 0!==o?o:""):s(null!==(a=u.split(".").pop())&&void 0!==a?a:u);return n.jsx("th",e.__assign({className:"ag-drill__col--".concat(hn(t)," ").concat(t.hideBelow?"ag-drill__hide--".concat(t.hideBelow):""),style:{width:t.width},"aria-sort":(null==ee?void 0:ee.key)===u?"asc"===ee.order?"ascending":"descending":void 0},{children:nn(t)?n.jsxs("button",e.__assign({type:"button",onClick:function(){return function(e){var n;if(nn(e)){var t=null!==(n=e.key)&&void 0!==n?n:"";ne(function(e){return{key:t,order:(null==e?void 0:e.key)===t&&"desc"===e.order?"asc":"desc"}})}}(t)}},{children:[c,(null==ee?void 0:ee.key)===u?n.jsxs("span",e.__assign({"aria-hidden":"true"},{children:[" ","asc"===ee.order?"↑":"↓"]})):null]})):c}),"".concat(t.source,":").concat(u))}),fn?n.jsx("th",{children:n.jsx("span",e.__assign({className:"ins-visually-hidden"},{children:"Actions"}))}):null,$e?n.jsx("th",{children:n.jsx("span",e.__assign({className:"ins-visually-hidden"},{children:"Open"}))}):null]})}),n.jsx("tbody",{children:en.map(function(l){return n.jsxs("tr",e.__assign({className:$e?void 0:"is-static",tabIndex:$e?0:void 0,onClick:$e?function(e){e.target.closest("a,button,input,select,textarea")||yn(l)}:void 0,onKeyDown:$e?function(e){return function(e,n){$e&&e.target===e.currentTarget&&("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),yn(n)))}(e,l)}:void 0},{children:[Ve?(r=Ye(l),Ve.map(function(t){return n.jsx("td",e.__assign({className:t.bodyClassName,style:e.__assign(e.__assign({},t.style),t.bodyStyle)},{children:t.body(r)}),t.key)})):Ge.map(function(t,r){var i,o,a=0===r?"th":"td",s=null===(i=dn(t))||void 0===i?void 0:i.className;return n.jsx(a,e.__assign({scope:0===r?"row":void 0,className:"ag-drill__col--".concat(hn(t)," ").concat(t.hideBelow?"ag-drill__hide--".concat(t.hideBelow):"").concat(s?" ".concat(s):"")},{children:vn(l,t)}),"".concat(t.source,":").concat(null!==(o=t.key)&&void 0!==o?o:t.id))}),fn?n.jsx("td",e.__assign({className:"ag-drill__buttons"},{children:un(l).map(function(t){var r,i,o=Te==="".concat(l.id,":").concat(null!==(r=t.id)&&void 0!==r?r:t.label);return n.jsx("button",e.__assign({type:"button",disabled:o,"aria-busy":o||void 0,onClick:function(){return function(e,n){var t,l=e.confirm?v(e.confirm,d(L,M,n),{},!1):"";"call"!==e.type||!(null!==(t=e.ask)&&void 0!==t?t:[]).length&&!l?l&&!window.confirm(l)||cn(e,n,{}):Ce({button:e,row:n,question:l})}(t,l)}},{children:o?"…":t.label}),null!==(i=t.id)&&void 0!==i?i:t.label)})})):null,$e?n.jsx("td",{children:n.jsx(t.ChevronRight,{className:"ag-drill__open","aria-hidden":"true"})}):null]}),l.id);var r})})]})),_e&&!le.length?n.jsx("p",e.__assign({className:"ag-drill__state"},{children:"Loading rows…"})):null,_e||en.length||xe?null:n.jsx("p",e.__assign({className:"ag-drill__state"},{children:"No rows found."})),xe?n.jsx("p",e.__assign({className:"ag-drill__state ag-drill__state--error"},{children:xe})):null]})),n.jsxs("footer",e.__assign({className:"ag-drill__footer"},{children:[n.jsx("span",{children:"rows"===Pe&&he?"".concat(le.length," of ").concat(he):""}),ve?n.jsx("button",e.__assign({type:"button",onClick:function(){return e.__awaiter(B,void 0,void 0,function(){var n,t,l;return e.__generator(this,function(r){switch(r.label){case 0:if(_e||!ve)return[2];be(!0),we(null),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,Xe(!0)];case 2:return(n=r.sent())?(re(function(t){return e.__spreadArray(e.__spreadArray([],t,!0),n.rows,!0)}),ye(n.hasMore),ae(null!==(l=n.cursor)&&void 0!==l?l:null),ce(n.offset),[3,5]):[2];case 3:return t=r.sent(),we(t instanceof Error?t.message:"More rows couldn't be loaded."),[3,5];case 4:return be(!1),[7];case 5:return[2]}})})},disabled:_e},{children:_e?"Loading…":"Show more"})):null]})),Se?n.jsx(_,{button:Se.button,question:Se.question,onCancel:function(){return Ce(null)},onSubmit:function(e){var n=Se.button,t=Se.row;Ce(null),cn(n,t,e)}}):null]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),n=require("react/jsx-runtime"),t=require("lucide-react"),l=require("react"),r=require("../../api/insightsApi.js"),i=require("./agPrimitives.js"),o=require("./insightsContextCore.js"),a=/\{([^{}]+)\}/g,s=function(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()})},u=function(e,n){return n.split(".").reduce(function(e,n){return e&&"object"==typeof e?e[n]:void 0},e)};function c(e,n){if(null==e||""===e)return"—";if("date"===n&&"string"==typeof e){var t=new Date("".concat(e.slice(0,10),"T00:00:00"));return Number.isNaN(t.getTime())?e:t.toLocaleDateString()}var l="number"==typeof e?e:"string"==typeof e&&""!==e.trim()&&!Number.isNaN(Number(e))&&n&&"text"!==n&&"chip"!==n?Number(e):null;return null!==l?"percent"===n?"".concat(new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(l),"%"):new Intl.NumberFormat(void 0,{maximumFractionDigits:"rating"===n?2:1}).format(l):"object"==typeof e?JSON.stringify(e):String(e)}function d(e,n,t){var l,i,o,a,s,u=n.trail;return{record:t.record,context:{row:null!==(i=null===(l=u[u.length-1])||void 0===l?void 0:l.label)&&void 0!==i?i:"",parent:null!==(a=null===(o=u[u.length-2])||void 0===o?void 0:o.label)&&void 0!==a?a:"",day:null!==(s=n.day)&&void 0!==s?s:"",startDate:r.toIsoDay(e.range.startDate),endDate:r.toIsoDay(e.range.endDate),trail:Object.fromEntries(u.map(function(e){return[e.entityKey,e.label]}))}}}var v=function(e,n,t,l){return e.replace(a,function(e,r){var i=function(e,n,t){var l=t.trim();return l.startsWith("context.")?u(e.context,l.slice(8)):l.startsWith("input.")?n[l.slice(6)]:u(e.record,l)}(n,t,r),o=null==i?"":"object"==typeof i?JSON.stringify(i):String(i);return l?encodeURIComponent(o):o})},y=function(e,n,t){return"string"==typeof e?v(e,n,t,!1):Array.isArray(e)?e.map(function(e){return y(e,n,t)}):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(function(e){var l=e[0],r=e[1];return[l,y(r,n,t)]})):e},f=new Set,h=["good","warning","bad","info","neutral"],g=function(e){return String(null!=e?e:"").trim().toLowerCase().replace(/[\s_-]+/g," ")};function p(t){var l,r=t.text,i=t.value,o=t.colors,a=o?null===(l=Object.entries(o).find(function(e){var n=e[0];return g(n)===g(i)}))||void 0===l?void 0:l[1]:void 0;if(a&&"object"==typeof a)return n.jsx("span",e.__assign({className:"ag-drill__chip",style:e.__assign({background:a.background,color:a.color},a.border?{boxShadow:"inset 0 0 0 1px ".concat(a.border)}:{})},{children:r}));var s="string"==typeof a&&h.includes(a)?a:"neutral";return n.jsx("span",e.__assign({className:"ag-drill__chip ag-drill__chip--".concat(s)},{children:r}))}function _(r){var i,o=r.button,a=r.question,s=r.onCancel,u=r.onSubmit,c=l.useState({}),d=c[0],v=c[1],y=l.useRef(null);l.useEffect(function(){var e;return null===(e=y.current)||void 0===e?void 0:e.focus()},[]);var f=null!==(i=o.ask)&&void 0!==i?i:[],h=f.some(function(e){var n;return!(null===(n=d[e.key])||void 0===n?void 0:n.trim())});return n.jsx("div",e.__assign({className:"ag-drill__dialog",role:"presentation",onMouseDown:function(e){return e.target===e.currentTarget&&s()}},{children:n.jsxs("form",e.__assign({className:"ag-drill__dialog-box",role:"dialog","aria-modal":"true","aria-label":o.label,onSubmit:function(e){e.preventDefault(),h||u(d)},onKeyDown:function(e){"Escape"===e.key&&(e.stopPropagation(),s())}},{children:[n.jsxs("header",{children:[n.jsx("strong",{children:o.label}),n.jsx("button",e.__assign({type:"button","aria-label":"Cancel",onClick:s},{children:n.jsx(t.X,{"aria-hidden":"true"})}))]}),a?n.jsx("p",{children:a}):null,f.map(function(t,l){var r;return n.jsxs("label",{children:[n.jsx("span",{children:t.label}),n.jsx("input",{ref:0===l?function(e){y.current=e}:void 0,value:null!==(r=d[t.key])&&void 0!==r?r:"",onChange:function(n){return v(function(l){var r;return e.__assign(e.__assign({},l),((r={})[t.key]=n.target.value,r))})},required:!0})]},t.key)}),n.jsxs("footer",{children:[n.jsx("button",e.__assign({type:"button",onClick:s},{children:"Cancel"})),n.jsx("button",e.__assign({ref:f.length?void 0:function(e){y.current=e},type:"submit",disabled:h},{children:o.label}))]})]}))}))}exports.default=function(a){var h,g,b,m,x,w,j,k,K,N,S,C,D,T,E,A,I,B=this,O=a.table,P=a.tabEntityKey,M=a.context,R=a.onRowClick,q=a.className,L=o.useInsights(),z=M.trail.length>0,F=l.useMemo(function(){return function(n,t,l){var r,i,o,a,s,u={filterBy:l?"trail":"none",period:l?"day":"range"};return(null===(r=n.views)||void 0===r?void 0:r.length)?n.views.map(function(t){var l,r,i,o,a,s;return e.__assign(e.__assign({},t),{source:null!==(l=t.source)&&void 0!==l?l:"insights",filterBy:null!==(r=t.filterBy)&&void 0!==r?r:"row"===t.scope?"row":u.filterBy,period:null!==(i=t.period)&&void 0!==i?i:u.period,onRowClick:null!==(o=t.onRowClick)&&void 0!==o?o:n.onRowClick,buttons:null!==(s=null!==(a=t.buttons)&&void 0!==a?a:n.buttons)&&void 0!==s?s:[]})}):[{source:null!==(i=n.source)&&void 0!==i?i:"insights",entityKey:t,tableKey:n.tableKey,columns:n.columns,onRowClick:n.onRowClick,filterBy:l?null!==(o=n.filterBy)&&void 0!==o?o:u.filterBy:"none",period:l?null!==(a=n.period)&&void 0!==a?a:u.period:"range",buttons:null!==(s=n.buttons)&&void 0!==s?s:[]}]}(O,P,z)},[O,P,z]),H=F.map(function(e){var n;return"".concat(e.source,":").concat(null!==(n=e.entityKey)&&void 0!==n?n:e.tableKey)}).join("|"),J=l.useState(0),U=J[0],W=J[1],X=l.useState(""),G=X[0],Q=X[1],V=l.useState(""),Y=V[0],Z=V[1],$=l.useState(O.defaultSort),ee=$[0],ne=$[1],te=l.useState([]),le=te[0],re=te[1],ie=l.useState(null),oe=ie[0],ae=ie[1],se=l.useState(0),ue=se[0],ce=se[1],de=l.useState(!1),ve=de[0],ye=de[1],fe=l.useState(0),he=fe[0],ge=fe[1],pe=l.useState(!1),_e=pe[0],be=pe[1],me=l.useState(null),xe=me[0],we=me[1],je=l.useState(null),ke=je[0],Ke=je[1],Ne=l.useState(null),Se=Ne[0],Ce=Ne[1],De=l.useState(null),Te=De[0],Ee=De[1];l.useEffect(function(){return W(0)},[H]),l.useEffect(function(){var e=setTimeout(function(){return Z(G.trim())},300);return function(){return clearTimeout(e)}},[G]);var Ae=F[Math.min(U,F.length-1)],Ie=M.trail,Be=Ie[Ie.length-1],Oe=null!==(h=O.pageSize)&&void 0!==h?h:10,Pe=Ae&&"table"!==Ae.source?Be&&Ae.entityKey&&!(null==L?void 0:L.isChildOf(Ae.entityKey,Be.entityKey))?"movers":"rows":"table",Me="rows"===Pe&&Be?Be.nodeKey:void 0,Re=l.useMemo(function(){var n,t,l;if(!L||!Ae||"table"===Ae.source)return[];if(null===(n=Ae.columns)||void 0===n?void 0:n.length)return Ae.columns;var r=L.entityKpis(null!==(t=Ae.entityKey)&&void 0!==t?t:"").slice(0,4);return e.__spreadArray([{key:"label",source:"field",label:L.entityName(null!==(l=Ae.entityKey)&&void 0!==l?l:"")}],r.map(function(e){return{key:e,source:"kpi",show:"both"}}),!0)},[L,Ae]),qe=Re.find(function(e){return"children"===e.source}),Le=null!==(g=null==L?void 0:L.headlineKpi)&&void 0!==g?g:"",ze=l.useMemo(function(){return L?"day"===(null==Ae?void 0:Ae.period)&&M.day?{start:M.day,end:M.day}:{start:r.toIsoDay(L.range.startDate),end:r.toIsoDay(L.range.endDate)}:{start:"",end:""}},[L,null==Ae?void 0:Ae.period,M.day]),Fe=Ie.map(function(e){return"".concat(e.entityKey,":").concat(e.nodeKey)}).join("|"),He=l.useMemo(function(){if(!L||!Ae)return{};var n=e.__assign({},L.sidebarFilters);return("trail"===Ae.filterBy?Ie:"row"===Ae.filterBy?Ie.slice(-1):[]).forEach(function(e){var t=L.labelColumnOf(e.entityKey);t&&e.label&&(n[t]=[e.label])}),n},[L,Ae,Fe]),Je=JSON.stringify(He),Ue="table"===Pe?void 0:"chip.criticality"===(null==ee?void 0:ee.key)?"criticality":null==ee?void 0:ee.key,We="table"===Pe||null==ee?void 0:ee.order,Xe="table"===Pe?"":Y,Ge=function(n,t){return e.__awaiter(B,void 0,void 0,function(){var l,i,o,a,s,u,c,d,v,y,f;return e.__generator(this,function(h){switch(h.label){case 0:if(!L||!Ae)return[2,void 0];if("table"!==Pe)return[3,2];if(!Ae.tableKey)throw new Error("Pick a Table Builder table for this list.");return[4,r.fetchDrillTableRows(L.api,{tableKey:Ae.tableKey,startDay:ze.start,endDay:ze.end,filters:He,pageSize:Oe,cursor:n?oe:null},t)];case 1:return l=h.sent(),i=n?le.length:0,[2,{rows:l.rows.map(function(e,n){return{id:"t".concat(i+n),record:e}}),count:l.count,hasMore:l.hasNext,cursor:l.nextCursor,offset:0}];case 2:return"movers"!==Pe?[3,4]:(o=n?ue:0,[4,r.fetchInsightsDrivers(L.api,{dataDay:null!==(d=M.day)&&void 0!==d?d:void 0,kpiId:Le,parentNodeKey:null==Be?void 0:Be.nodeKey,entityKey:Ae.entityKey,tab:"drivers",limit:Oe,offset:o,filters:L.range.filters},t)]);case 3:return a=h.sent(),s=a.rows.map(function(e){return function(e,n){var t,l,r,i,o;return{rank:e.rank,nodeKey:e.nodeKey,label:e.label,parent:null,metrics:(t={},t[n]={value:e.value,previous:e.previous,deltaPct:e.deltaPct,direction:e.changeDirection,tone:e.tone},t),barPct:null,chip:{criticality:e.criticality,movementType:e.movementType},report:{reportId:null!==(r=null===(l=e.report)||void 0===l?void 0:l.reportId)&&void 0!==r?r:null,status:(null===(i=e.report)||void 0===i?void 0:i.reportId)?"generated":"none",kpiId:n},action:null,children:[],entityKey:null!==(o=e.entityKey)&&void 0!==o?o:null}}(e,Le)}),u=a,[2,{rows:s.map(function(e){return{id:e.nodeKey,record:e,insights:e}}),count:null!==(v=u.total)&&void 0!==v?v:o+s.length,hasMore:Boolean(u.hasMore),cursor:null,offset:o+s.length}];case 4:return[4,r.fetchLevelRows(L.api,null!==(y=Ae.entityKey)&&void 0!==y?y:"",e.__assign({},L.range),{sort:Ue,order:We,search:Xe||void 0,pageSize:Oe,parentNodeKey:Me,includeChildren:qe?null!==(f=qe.max)&&void 0!==f?f:3:void 0,childEntityKey:null==qe?void 0:qe.childEntityKey,cursor:n&&null!=oe?oe:void 0},t)];case 5:return[2,{rows:(c=h.sent()).rows.map(function(n){var t,l;return{id:n.nodeKey,record:n,insights:e.__assign(e.__assign({},n),{entityKey:null!==(l=null!==(t=n.entityKey)&&void 0!==t?t:Ae.entityKey)&&void 0!==l?l:null})}}),count:c.count,hasMore:c.hasNext,cursor:c.nextCursor,offset:0}]}})})};if(l.useEffect(function(){if(L&&Ae){var e=new AbortController;return be(!0),we(null),re([]),ae(null),ce(0),Ke(null),Ge(!1,e.signal).then(function(e){var n;e&&(re(e.rows),ge(e.count),ye(e.hasMore),ae(null!==(n=e.cursor)&&void 0!==n?n:null),ce(e.offset))}).catch(function(e){"AbortError"!==(null==e?void 0:e.name)&&we(e instanceof Error?e.message:"The rows couldn't be loaded.")}).finally(function(){e.signal.aborted||be(!1)}),function(){return e.abort()}}},[null==L?void 0:L.api,null==L?void 0:L.revision,null==L?void 0:L.rangeKey,H,U,Pe,Me,Fe,M.day,ze.start,ze.end,Je,Xe,Ue,We,Oe,null==qe?void 0:qe.childEntityKey]),!L||!Ae)return null;var Qe="table"===Pe?function(n,t,l){var r,i,o=t.tableKey?n.tableSource(t.tableKey):void 0,a=(null===(r=null==o?void 0:o.columns)||void 0===r?void 0:r.length)?o.columns:Object.keys(null!=l?l:{}).map(function(e){return{key:e,label:s(e)}}),u=null!==(i=t.columns)&&void 0!==i?i:[];return e.__spreadArray(e.__spreadArray([],u.filter(function(e){return e.key&&a.some(function(n){return n.key===e.key})}),!0),a.filter(function(e){return!u.some(function(n){return n.key===e.key})}).map(function(n){return e.__assign(e.__assign({},n),{source:"field"})}),!0).filter(function(e){return!e.hidden}).map(function(n){var t,l,r,i,o,u;return e.__assign(e.__assign({},n),{source:"field",sortable:null!==(t=n.sortable)&&void 0!==t?t:null===(l=a.find(function(e){return e.key===n.key}))||void 0===l?void 0:l.sortable,label:null!==(o=null!==(r=n.label)&&void 0!==r?r:null===(i=a.find(function(e){return e.key===n.key}))||void 0===i?void 0:i.label)&&void 0!==o?o:s(null!==(u=n.key)&&void 0!==u?u:"")})})}(L,Ae,null===(b=le[0])||void 0===b?void 0:b.record):Re,Ve=L.hostTables["table"===Ae.source?null!==(m=Ae.tableKey)&&void 0!==m?m:"":"insights.".concat(null!==(x=Ae.entityKey)&&void 0!==x?x:"")],Ye=(null===(w=null==Ve?void 0:Ve.columns)||void 0===w?void 0:w.length)?Ve.columns:null,Ze=function(n){return n.insights?function(e){var n,t,l,r,i,o,a,s,u,c,d,v,y,f,h,g,p,_={id:e.nodeKey,nodeKey:e.nodeKey,label:null!==(n=e.label)&&void 0!==n?n:e.nodeKey,entityKey:null!==(t=e.entityKey)&&void 0!==t?t:null,parent:null!==(r=null===(l=e.parent)||void 0===l?void 0:l.label)&&void 0!==r?r:null,criticality:null!==(o=null===(i=e.chip)||void 0===i?void 0:i.criticality)&&void 0!==o?o:null,movementType:null!==(s=null===(a=e.chip)||void 0===a?void 0:a.movementType)&&void 0!==s?s:null,reportId:null!==(c=null===(u=e.report)||void 0===u?void 0:u.reportId)&&void 0!==c?c:null,reportStatus:null!==(v=null===(d=e.report)||void 0===d?void 0:d.status)&&void 0!==v?v:null,actionStatus:null!==(f=null===(y=e.action)||void 0===y?void 0:y.status)&&void 0!==f?f:null,assignee:null!==(g=null===(h=e.action)||void 0===h?void 0:h.assigneeName)&&void 0!==g?g:null,children:e.children.map(function(e){return e.label}).filter(Boolean),__row:e};return Object.entries(null!==(p=e.metrics)&&void 0!==p?p:{}).forEach(function(e){var n,t,l,r=e[0],i=e[1];_[r]=null!==(n=null==i?void 0:i.value)&&void 0!==n?n:null,_["".concat(r,"_delta")]=null!==(t=null==i?void 0:i.deltaPct)&&void 0!==t?t:null,_["".concat(r,"_previous")]=null!==(l=null==i?void 0:i.previous)&&void 0!==l?l:null}),_}(n.insights):e.__assign({id:n.id},n.record)},$e="table"===Pe?"none":null!==(j=Ae.onRowClick)&&void 0!==j?j:"none",en="none"!==$e,nn="table"===Pe?e.__spreadArray([],le,!0).filter(function(e){return!Y||(Ye?Ye.map(function(e){return e.key}):Qe.map(function(e){var n;return null!==(n=e.key)&&void 0!==n?n:""})).some(function(n){var t;return String(null!==(t=e.record[n])&&void 0!==t?t:"").toLowerCase().includes(Y.toLowerCase())})}).sort(function(e,n){if(!(null==ee?void 0:ee.key))return 0;var t=e.record[ee.key],l=n.record[ee.key],r=Number(t),i=Number(l),o=null==t||null==l||""===t||""===l||Number.isNaN(r)||Number.isNaN(i)?String(null!=t?t:"").localeCompare(String(null!=l?l:"")):r-i;return"asc"===ee.order?o:-o}):le,tn=function(e){return"movers"!==Pe&&!0===e.sortable},ln=function(e){var n;if(tn(e)){var t=null!==(n=e.key)&&void 0!==n?n:"";ne(function(e){return{key:t,order:(null==e?void 0:e.key)===t&&"desc"===e.order?"asc":"desc"}})}},rn=function(e){var n;return(null===(n=L.tableSource(null!=e?e:""))||void 0===n?void 0:n.title)||s(null!=e?e:"")},on="table"===Ae.source?rn(Ae.tableKey):L.entityName(null!==(k=Ae.entityKey)&&void 0!==k?k:""),an="table"===Ae.source?on:L.entityPluralName(null!==(K=Ae.entityKey)&&void 0!==K?K:""),sn=function(e){var n;return e.title||("table"===e.source?rn(e.tableKey):L.entityPluralName(null!==(n=e.entityKey)&&void 0!==n?n:""))},un=F.length>1?"Drill down in {row}":z?"table"===Ae.source?"{part}":L.labels.drillTableTitle:"{parts}",cn=(null!==(N=O.title)&&void 0!==N?N:un).replace(/\{row\}/g,null!==(S=null==Be?void 0:Be.label)&&void 0!==S?S:"").replace(/\{parent\}/g,null!==(D=null===(C=Ie[Ie.length-2])||void 0===C?void 0:C.label)&&void 0!==D?D:"").replace(/\{day\}/g,M.day?i.formatHeaderDate(M.day):"").replace(/\{parts\}|\{plural\}/g,an).replace(/\{part\}/g,on).replace(/\s+/g," ").trim(),dn=function(e){return Ae.buttons.filter(function(n){var t,l,r;if(n.adminOnly&&!L.viewer.isAdmin)return!1;if(!("host"!==n.type||n.handler&&L.actionHandlers[n.handler]))return f.has(null!==(t=n.handler)&&void 0!==t?t:"")||(f.add(null!==(l=n.handler)&&void 0!==l?l:""),console.warn('Decision Advantage: no host handler named "'.concat(null!==(r=n.handler)&&void 0!==r?r:"",'" is registered, so its button is hidden.'))),!1;if(n.when){var i=u(e.record,n.when);if(null==i||""===i)return!1}return!0})},vn=function(n,t,l){return e.__awaiter(B,void 0,void 0,function(){var r,i,o,a,s,u,c,f,h,g,p,_,b,m,x,w,j,k,K,N,S,C;return e.__generator(this,function(e){switch(e.label){case 0:r=d(L,M,t),i="".concat(t.id,":").concat(null!==(m=n.id)&&void 0!==m?m:n.label),Ke(null),e.label=1;case 1:if(e.trys.push([1,9,10,11]),"open"===n.type){if(o=v(null!==(x=n.url)&&void 0!==x?x:"",r,l,!0),/^https:\/\//i.test(o))window.open(o,"_blank","noopener,noreferrer");else{if(!/^mailto:/i.test(o))throw new Error("This link isn't allowed: only https and mailto links open.");window.location.href=o}return[2]}return Ee(i),"host"!==n.type?[3,3]:[4,(0,L.actionHandlers[null!==(w=n.handler)&&void 0!==w?w:""])({button:n,row:t.record,context:r.context,inputs:l})];case 2:return a=e.sent(),Ke({tone:"ok",text:a&&a.message||"".concat(n.label,": done.")}),[2];case 3:if("https:"!==(s=new URL(v(null!==(j=n.url)&&void 0!==j?j:"",r,l,!0))).protocol)throw new Error("Only https APIs can be called.");return u=null!==(k=n.method)&&void 0!==k?k:"POST",c={Accept:"application/json"},Object.entries(null!==(K=n.headers)&&void 0!==K?K:{}).forEach(function(e){var n=e[0],t=e[1];c[n]=v(String(t),r,l,!1)}),L.api.accessToken&&L.approvedApiHosts.includes(s.host.toLowerCase())&&(c.Authorization="Bearer ".concat(L.api.accessToken)),(f="GET"!==u&&void 0!==n.body&&null!==n.body)&&(c["Content-Type"]="application/json"),[4,fetch(s.toString(),{method:u,headers:c,body:f?JSON.stringify(y(n.body,r,l)):void 0})];case 4:h=e.sent(),g="",e.label=5;case 5:return e.trys.push([5,7,,8]),[4,h.json()];case 6:return p=e.sent(),_=null==p?void 0:p.error,g=String(null!==(C=null!==(S=null!==(N=null==p?void 0:p.message)&&void 0!==N?N:null==_?void 0:_.errorMessage)&&void 0!==S?S:null==p?void 0:p.detail)&&void 0!==C?C:""),[3,8];case 7:return e.sent(),g="",[3,8];case 8:if(!h.ok)throw new Error(g||"".concat(n.label," failed (status ").concat(h.status,")."));return Ke({tone:"ok",text:g||"".concat(n.label,": done.")}),[3,11];case 9:return b=e.sent(),Ke({tone:"error",text:b instanceof Error?b.message:"".concat(n.label," failed.")}),[3,11];case 10:return Ee(null),[7];case 11:return[2]}})})},yn=function(e){var n,t,l,r=null!==(t=null!==(n=e.key)&&void 0!==n?n:e.id)&&void 0!==t?t:"",i="table"===Ae.source?Ae.tableKey:Ae.entityKey;return null!==(l=i?L.cellRenderers["".concat(i,".").concat(r)]:void 0)&&void 0!==l?l:L.cellRenderers[r]},fn=function(t,l){var r,i,o,a,s,d,v,y,f=null!==(r=l.key)&&void 0!==r?r:"",h=yn(l),g="kpi"===l.source&&t.insights?null===(i=t.insights.metrics[f])||void 0===i?void 0:i.value:"children"===l.source&&t.insights?t.insights.children.map(function(e){return e.label}).filter(Boolean):"label"===f&&t.insights?t.insights.label||t.insights.nodeKey:u(t.record,f);if(null==h?void 0:h.render){var _=h.render({column:l,value:g,record:t.record,row:t.insights,entityKey:Ae.entityKey,tableKey:Ae.tableKey});if(void 0!==_)return _}if(t.insights){var b=null===(o=L.renderInsightsCell)||void 0===o?void 0:o.call(L,{column:l,row:t.insights,entityKey:null!==(a=Ae.entityKey)&&void 0!==a?a:""});if(void 0!==b)return b}if("custom"===l.source)return null!==(s=l.emptyText)&&void 0!==s?s:"—";if("kpi"===l.source&&t.insights&&!(null==h?void 0:h.as)){var m=t.insights.metrics[f],x=c(null==m?void 0:m.value,l.format),w=null==(null==m?void 0:m.deltaPct)?"—":"".concat(m.deltaPct>0?"↑":m.deltaPct<0?"↓":""," ").concat(Math.abs(m.deltaPct),"%");return"delta"===l.show?n.jsx("span",e.__assign({className:(null==m?void 0:m.tone)?"ag-drill__change--".concat(m.tone):void 0},{children:w})):"value"===l.show?x:n.jsxs("span",e.__assign({className:"ag-drill__metric"},{children:[n.jsx("strong",{children:x}),n.jsx("small",e.__assign({className:(null==m?void 0:m.tone)?"ag-drill__change--".concat(m.tone):void 0},{children:w}))]}))}if("children"===l.source&&t.insights&&!(null==h?void 0:h.as)){var j=Array.from(new Set(g)),k=null!==(d=l.max)&&void 0!==d?d:3,K=j.length?"".concat(j.slice(0,k).join(", ")).concat(j.length>k?" +".concat(j.length-k):""):null!==(v=l.emptyText)&&void 0!==v?v:"—";return n.jsx("span",e.__assign({className:"ag-drill__contributors",title:j.join(", ")||void 0},{children:K}))}var N=null!==(y=null==h?void 0:h.as)&&void 0!==y?y:l.format;if("link"===N){var S="string"==typeof g?g:"";return/^https:\/\//i.test(S)?n.jsx("a",e.__assign({href:S,target:"_blank",rel:"noopener noreferrer"},{children:S})):c(g,"text")}var C=c(g,"chip"===N?"text":N);return"—"===C&&l.emptyText?l.emptyText:"chip"!==N&&!(null==h?void 0:h.colors)||"—"===C?C:n.jsx(p,{text:C.replace(/_/g," "),value:g,colors:null==h?void 0:h.colors})},hn=function(e){e.insights&&(null==R||R(e.insights,$e))},gn=Ae.buttons.length>0,pn=function(e){var n;return null!==(n=e.align)&&void 0!==n?n:"kpi"===e.source?"right":"left"},_n="ag-drill-".concat(String(null!==(T=O.id)&&void 0!==T?T:cn).replace(/[^a-z0-9]+/gi,"-")),bn=!1!==O.search&&"movers"!==Pe;return n.jsxs("section",e.__assign({className:"ag-drill".concat(q?" ".concat(q):""),"aria-labelledby":_n,style:null===(E=null==Ve?void 0:Ve.card)||void 0===E?void 0:E.root},{children:[n.jsxs("header",e.__assign({className:"ag-drill__header",style:null===(A=null==Ve?void 0:Ve.card)||void 0===A?void 0:A.header},{children:[n.jsxs("div",{children:[n.jsx("h3",e.__assign({id:_n,style:null===(I=null==Ve?void 0:Ve.card)||void 0===I?void 0:I.title},{children:cn})),"movers"===Pe?n.jsxs("span",{children:["Rows that moved",M.day?" on ".concat(i.formatHeaderDate(M.day)):""]}):null]}),bn?n.jsxs("label",e.__assign({className:"ag-drill__search"},{children:[n.jsx(t.Search,{"aria-hidden":"true"}),n.jsx("input",{type:"search",value:G,onChange:function(e){return Q(e.target.value)},placeholder:"Search ".concat(an.toLowerCase(),"…"),"aria-label":"Search ".concat(an)})]})):null]})),F.length>1?n.jsx("div",e.__assign({className:"ag-drill__tabs",role:"tablist","aria-label":"What this table lists"},{children:F.map(function(t,l){var r;return n.jsx("button",e.__assign({type:"button",role:"tab","aria-selected":l===U,className:l===U?"is-active":void 0,onClick:function(){W(l),Q(""),Z(""),ne(O.defaultSort)}},{children:sn(t)}),"".concat(t.source,":").concat(null!==(r=t.entityKey)&&void 0!==r?r:t.tableKey,":").concat(l))})})):null,ke?n.jsxs("p",e.__assign({className:"ag-drill__notice ag-drill__notice--".concat(ke.tone),role:"status"},{children:[ke.text,n.jsx("button",e.__assign({type:"button","aria-label":"Dismiss",onClick:function(){return Ke(null)}},{children:n.jsx(t.X,{"aria-hidden":"true"})}))]})):null,n.jsxs("div",e.__assign({className:"ag-drill__table-wrap","aria-live":"polite"},{children:[n.jsxs("table",e.__assign({className:"ag-drill__table"},{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[Ye?Ye.map(function(t){var l,r,i=Qe.find(function(e){return e.key===t.key}),o=e.__assign(e.__assign({},i),{key:t.key,source:null!==(l=null==i?void 0:i.source)&&void 0!==l?l:"field",sortable:null!==(r=t.sortable)&&void 0!==r?r:null==i?void 0:i.sortable});return n.jsx("th",e.__assign({className:t.headerClassName,style:e.__assign(e.__assign({},t.style),t.headerStyle),"aria-sort":(null==ee?void 0:ee.key)===t.key?"asc"===ee.order?"ascending":"descending":void 0},{children:tn(o)?n.jsxs("button",e.__assign({type:"button",onClick:function(){return ln(o)}},{children:[t.header,n.jsx("span",e.__assign({"aria-hidden":"true"},{children:(null==ee?void 0:ee.key)===t.key?"asc"===ee.order?"↑":"↓":"↕"}))]})):t.header}),t.key)}):Qe.map(function(t){var l,r,i,o,a,u=null!==(r=null!==(l=t.key)&&void 0!==l?l:t.id)&&void 0!==r?r:"",c=null!==(i=t.label)&&void 0!==i?i:"kpi"===t.source?L.kpiLabel(u):"children"===t.source?L.entityPluralName(null!==(o=t.childEntityKey)&&void 0!==o?o:""):s(null!==(a=u.split(".").pop())&&void 0!==a?a:u);return n.jsx("th",e.__assign({className:"ag-drill__col--".concat(pn(t)," ").concat(t.hideBelow?"ag-drill__hide--".concat(t.hideBelow):""),style:{width:t.width},"aria-sort":(null==ee?void 0:ee.key)===u?"asc"===ee.order?"ascending":"descending":void 0},{children:tn(t)?n.jsxs("button",e.__assign({type:"button",onClick:function(){return ln(t)}},{children:[c,n.jsx("span",e.__assign({"aria-hidden":"true"},{children:(null==ee?void 0:ee.key)===u?"asc"===ee.order?"↑":"↓":"↕"}))]})):c}),"".concat(t.source,":").concat(u))}),gn?n.jsx("th",{children:n.jsx("span",e.__assign({className:"ins-visually-hidden"},{children:"Actions"}))}):null,en?n.jsx("th",{children:n.jsx("span",e.__assign({className:"ins-visually-hidden"},{children:"Open"}))}):null]})}),n.jsx("tbody",{children:nn.map(function(l){return n.jsxs("tr",e.__assign({className:en?void 0:"is-static",tabIndex:en?0:void 0,onClick:en?function(e){e.target.closest("a,button,input,select,textarea")||hn(l)}:void 0,onKeyDown:en?function(e){return function(e,n){en&&e.target===e.currentTarget&&("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),hn(n)))}(e,l)}:void 0},{children:[Ye?(r=Ze(l),Ye.map(function(t){return n.jsx("td",e.__assign({className:t.bodyClassName,style:e.__assign(e.__assign({},t.style),t.bodyStyle)},{children:t.body(r)}),t.key)})):Qe.map(function(t,r){var i,o,a=0===r?"th":"td",s=null===(i=yn(t))||void 0===i?void 0:i.className;return n.jsx(a,e.__assign({scope:0===r?"row":void 0,className:"ag-drill__col--".concat(pn(t)," ").concat(t.hideBelow?"ag-drill__hide--".concat(t.hideBelow):"").concat(s?" ".concat(s):"")},{children:fn(l,t)}),"".concat(t.source,":").concat(null!==(o=t.key)&&void 0!==o?o:t.id))}),gn?n.jsx("td",e.__assign({className:"ag-drill__buttons"},{children:dn(l).map(function(t){var r,i,o=Te==="".concat(l.id,":").concat(null!==(r=t.id)&&void 0!==r?r:t.label);return n.jsx("button",e.__assign({type:"button",disabled:o,"aria-busy":o||void 0,onClick:function(){return function(e,n){var t,l=e.confirm?v(e.confirm,d(L,M,n),{},!1):"";"call"!==e.type||!(null!==(t=e.ask)&&void 0!==t?t:[]).length&&!l?l&&!window.confirm(l)||vn(e,n,{}):Ce({button:e,row:n,question:l})}(t,l)}},{children:o?"…":t.label}),null!==(i=t.id)&&void 0!==i?i:t.label)})})):null,en?n.jsx("td",{children:n.jsx(t.ChevronRight,{className:"ag-drill__open","aria-hidden":"true"})}):null]}),l.id);var r})})]})),_e&&!le.length?n.jsx("p",e.__assign({className:"ag-drill__state"},{children:"Loading rows…"})):null,_e||nn.length||xe?null:n.jsx("p",e.__assign({className:"ag-drill__state"},{children:"No rows found."})),xe?n.jsx("p",e.__assign({className:"ag-drill__state ag-drill__state--error"},{children:xe})):null]})),n.jsxs("footer",e.__assign({className:"ag-drill__footer"},{children:[n.jsx("span",{children:"rows"===Pe&&he?"".concat(le.length," of ").concat(he):""}),ve?n.jsx("button",e.__assign({type:"button",onClick:function(){return e.__awaiter(B,void 0,void 0,function(){var n,t,l;return e.__generator(this,function(r){switch(r.label){case 0:if(_e||!ve)return[2];be(!0),we(null),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,Ge(!0)];case 2:return(n=r.sent())?(re(function(t){return e.__spreadArray(e.__spreadArray([],t,!0),n.rows,!0)}),ye(n.hasMore),ae(null!==(l=n.cursor)&&void 0!==l?l:null),ce(n.offset),[3,5]):[2];case 3:return t=r.sent(),we(t instanceof Error?t.message:"More rows couldn't be loaded."),[3,5];case 4:return be(!1),[7];case 5:return[2]}})})},disabled:_e},{children:_e?"Loading…":"Show more"})):null]})),Se?n.jsx(_,{button:Se.button,question:Se.question,onCancel:function(){return Ce(null)},onSubmit:function(e){var n=Se.button,t=Se.row;Ce(null),vn(n,t,e)}}):null]}))};
|
|
2
2
|
//# sourceMappingURL=DrillTable.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js");function t(e){var t=e.endDate,a=e.workingDays,r=e.selectedDay,n=e.reportDay,s=e.now,D=void 0===s?new Date:s;if(r)return r;var o=function(e){return"".concat(e.getFullYear(),"-").concat(String(e.getMonth()+1).padStart(2,"0"),"-").concat(String(e.getDate()).padStart(2,"0"))};if(!a)return n||o(t);var g=new Date(D.getFullYear(),D.getMonth(),D.getDate());g.setDate(g.getDate()-1);var i=new Date(t.getFullYear(),t.getMonth(),t.getDate());for(i<g&&g.setTime(i.getTime());0===g.getDay()||6===g.getDay();)g.setDate(g.getDate()-1);return o(g)}exports.resolveDrillDay=t,exports.resolveL2SummaryRange=function(a,r,n,s){if(!r&&!n)return e.__assign(e.__assign({},a),{workingDaysOnly:!1});var D=t({endDate:a.endDate,workingDays:r,selectedDay:n,now:s}),o=new Date("".concat(D,"T00:00:00"));return e.__assign(e.__assign({},a),{startDate:n||a.startDate>o?o:a.startDate,endDate:o,workingDaysOnly:!n&&r})};
|
|
2
|
+
//# sourceMappingURL=drillDay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drillDay.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),l=require("react/jsx-runtime"),i=require("react"),n=require("primereact/datatable"),o=require("primereact/column"),r=require("primereact/columngroup"),a=require("primereact/row"),t=require("primereact/skeleton");require("primereact/resources/primereact.min.css"),require("primeicons/primeicons.css"),exports.default=function(s){var d,u,c,v,p=s.rows,m=void 0===p?[]:p,_=s.loading,f=s.loadingMore,g=s.onLoadMore,h=s.hasMore,x=s.emptyState,y=s.columns,j=s.tableProps,w=s.onRowClick,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),l=require("react/jsx-runtime"),i=require("react"),n=require("primereact/datatable"),o=require("primereact/column"),r=require("primereact/columngroup"),a=require("primereact/row"),t=require("primereact/skeleton");require("primereact/resources/primereact.min.css"),require("primeicons/primeicons.css"),exports.default=function(s){var d,u,c,v,p=s.rows,m=void 0===p?[]:p,_=s.loading,f=s.loadingMore,g=s.onLoadMore,h=s.hasMore,x=s.emptyState,y=s.columns,j=s.tableProps,w=s.onRowClick,b=s.rowDetail,N=s.scrollHeight,C=void 0===N?"flex":N,k=i.useRef(null);i.useRef(null);var S="function"==typeof(null==b?void 0:b.render),q=i.useState({}),R=q[0],E=q[1],T=function(e){return!(!(null==e?void 0:e.id)||!R[e.id])},A=function(l){(null==l?void 0:l.id)&&E(function(i){var n,o;return(null==b?void 0:b.multiple)?e.__assign(e.__assign({},i),((n={})[l.id]=!0,n)):((o={})[l.id]=!0,o)})},D=function(l){(null==l?void 0:l.id)&&E(function(i){var n=e.__assign({},i);return delete n[l.id],n})},M=function(e){return T(e)?D(e):A(e)},H=null!=j?j:{},L=H.onRowClick,B=H.rowClassName,G=e.__rest(H,["onRowClick","rowClassName"]),O=e.__spreadArray(e.__spreadArray([],m,!0),f?[{id:"__loading-more",__loading:!0}]:[],!0),P=!f&&g&&!1===h&&(null!==(d=null==y?void 0:y.length)&&void 0!==d?d:0)>0?l.jsx(r.ColumnGroup,{children:l.jsx(a.Row,{children:l.jsx(o.Column,{colSpan:y.length,footer:l.jsxs("span",e.__assign({className:"audit-paginationEndContent"},{children:[l.jsx("i",{className:"pi pi-check-circle","aria-hidden":"true"}),"No more records to load"]})),footerClassName:"audit-paginationEnd"})})}):void 0;return i.useEffect(function(){var e,l=null===(e=k.current)||void 0===e?void 0:e.querySelector(".p-datatable-wrapper");if(l){var i=!1,n=function(){i||(i=!0,requestAnimationFrame(function(){var e=l.scrollTop;l.scrollHeight-e-l.clientHeight<100&&h&&!f&&(null==g||g()),i=!1}))};return l.addEventListener("scroll",n),function(){l.removeEventListener("scroll",n)}}},[m,h,f,g]),_?l.jsx("div",{children:e.__spreadArray([],Array(5),!0).map(function(i,n){return l.jsxs("div",e.__assign({className:"audit-skeletonRow"},{children:[l.jsx(t.Skeleton,{height:0===n?"55px":"25px",width:"25%"}),l.jsx(t.Skeleton,{height:0===n?"55px":"25px",width:"50%"}),l.jsx(t.Skeleton,{height:0===n?"55px":"25px",width:"25%"})]}),n)})}):m&&0!==m.length?l.jsx("div",e.__assign({className:"audit-tableWrap",ref:k},{children:l.jsx(n.DataTable,e.__assign({value:O,className:"audit-table ".concat(null!==(v=null==j?void 0:j.className)&&void 0!==v?v:""),dataKey:"id",scrollable:!0,scrollHeight:C},G,{rowClassName:function(l,i){var n="function"==typeof B?B(l,i):B,o=!S&&!w||(null==l?void 0:l.__loading)?"":"audit-row--clickable";return n&&"object"==typeof n?e.__assign(e.__assign({},n),{"audit-row--clickable":!!o}):[n,o].filter(Boolean).join(" ")},expandedRows:R,onRowToggle:function(e){return E(e.data)},rowExpansionTemplate:S?function(i){var n;return!S||(null==i?void 0:i.__loading)?null:l.jsx("div",e.__assign({className:"audit-rowDetail ".concat(null!==(n=null==b?void 0:b.className)&&void 0!==n?n:""),style:null==b?void 0:b.style},{children:b.render(i,{close:function(){return D(i)}})}))}:void 0,onRowClick:function(e){var l,i,n=null==e?void 0:e.data;if(n&&!n.__loading){var o=null===(l=null==e?void 0:e.originalEvent)||void 0===l?void 0:l.target;(null===(i=null==o?void 0:o.closest)||void 0===i?void 0:i.call(o,"button, a, input, .audit-seeMore"))||(null==w||w(n,{isExpanded:T(n),expand:function(){return A(n)},collapse:function(){return D(n)},toggle:function(){return M(n)}}),S&&!1!==(null==b?void 0:b.expandOnRowClick)&&M(n)),null==L||L(e)}},footerColumnGroup:P},{children:null==y?void 0:y.map(function(e){return l.jsx(o.Column,{field:e.key,sortable:e.sortable,header:null==e?void 0:e.header,body:function(i){return(null==i?void 0:i.__loading)?l.jsx(t.Skeleton,{height:"25px"}):null==e?void 0:e.body(i)},style:null==e?void 0:e.style,headerStyle:null==e?void 0:e.headerStyle,bodyStyle:null==e?void 0:e.bodyStyle,headerClassName:null==e?void 0:e.headerClassName,bodyClassName:null==e?void 0:e.bodyClassName,pt:{bodyCell:{style:{padding:"16px"}},headerCell:{style:{padding:"16px"}}}},null==e?void 0:e.key)})}))})):l.jsxs("div",e.__assign({className:"audit-emptyState"},{children:[(null==x?void 0:x.icon)?x.icon:l.jsx("i",{className:"pi pi-file",style:{fontSize:"63px",marginBottom:"8px"}}),l.jsx("div",e.__assign({className:"audit-emptyTitle"},{children:null!==(u=null==x?void 0:x.title)&&void 0!==u?u:"No Data found"})),l.jsx("div",e.__assign({className:"audit-emptyDesc"},{children:null!==(c=null==x?void 0:x.description)&&void 0!==c?c:"Try adjusting your filters or search criteria."}))]}))};
|
|
2
2
|
//# sourceMappingURL=FTable.js.map
|