@e-llm-studio/federated-dashboard-components 2.2.3 → 2.2.5
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/README.md +297 -0
- package/dist/ExecutiveDashboard/ExecutiveDashboardWrapper.js +1 -1
- package/dist/ExecutiveDashboard/api/alertsapi.js +1 -1
- package/dist/ExecutiveDashboard/api/dashboardApi.js +1 -1
- package/dist/ExecutiveDashboard/components/Alerts/AlertsViewTrigger.js +1 -1
- package/dist/ExecutiveDashboard/components/Alerts/CreateAlertModal.js +1 -1
- package/dist/ExecutiveDashboard/components/BarChart/BarChart.js +1 -1
- package/dist/ExecutiveDashboard/components/BarChart/utils.js +1 -1
- package/dist/ExecutiveDashboard/components/DashboardDateFilter/DashboardDateFilter.js +1 -1
- package/dist/ExecutiveDashboard/components/DashboardDateFilter/SubscriptionFeature/CreateSubscriptionModal.js +1 -1
- package/dist/ExecutiveDashboard/components/DashboardGrid/DashboardGrid.js +2 -0
- package/dist/ExecutiveDashboard/components/DashboardGrid/DashboardGrid.js.map +1 -0
- package/dist/ExecutiveDashboard/components/DashboardGrid/buildDashboardWidgets.js +2 -0
- package/dist/ExecutiveDashboard/components/DashboardGrid/buildDashboardWidgets.js.map +1 -0
- package/dist/ExecutiveDashboard/components/DashboardGrid/layout.js +2 -0
- package/dist/ExecutiveDashboard/components/DashboardGrid/layout.js.map +1 -0
- package/dist/ExecutiveDashboard/components/DashboardGrid/useElementSize.js +2 -0
- package/dist/ExecutiveDashboard/components/DashboardGrid/useElementSize.js.map +1 -0
- package/dist/ExecutiveDashboard/components/DatePickers/CustomRangePicker.js +2 -0
- package/dist/ExecutiveDashboard/components/DatePickers/CustomRangePicker.js.map +1 -0
- package/dist/ExecutiveDashboard/components/ExecutiveDashboard.js +1 -1
- package/dist/ExecutiveDashboard/components/Graph/Graph.js +1 -1
- package/dist/ExecutiveDashboard/components/Graph/LineChart.js +1 -1
- package/dist/ExecutiveDashboard/components/PieChart/utils.js +1 -1
- package/dist/ExecutiveDashboard/components/Table/TableCard.js +1 -1
- package/dist/ExecutiveDashboard/components/common/TooltipWrapper.js +2 -0
- package/dist/ExecutiveDashboard/components/common/TooltipWrapper.js.map +1 -0
- package/dist/ExecutiveDashboard/components/ui/chart.js +1 -1
- package/dist/ExecutiveDashboard/utils/chartCards.js +2 -0
- package/dist/ExecutiveDashboard/utils/chartCards.js.map +1 -0
- package/dist/ExecutiveDashboard/utils/sectionOrder.js +1 -1
- package/dist/assets/icons/thresholdGrey.svg.js +2 -0
- package/dist/assets/icons/thresholdGrey.svg.js.map +1 -0
- package/dist/assets/icons/thresholdRed.svg.js +2 -0
- package/dist/assets/icons/thresholdRed.svg.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/ExecutiveDashboardWrapper.js +1 -1
- package/dist/cjs/ExecutiveDashboard/api/alertsapi.js +1 -1
- package/dist/cjs/ExecutiveDashboard/api/dashboardApi.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Alerts/AlertsViewTrigger.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Alerts/CreateAlertModal.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/BarChart/BarChart.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/BarChart/utils.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/DashboardDateFilter/DashboardDateFilter.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/DashboardDateFilter/SubscriptionFeature/CreateSubscriptionModal.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/DashboardGrid/DashboardGrid.js +2 -0
- package/dist/cjs/ExecutiveDashboard/components/DashboardGrid/DashboardGrid.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/components/DashboardGrid/buildDashboardWidgets.js +2 -0
- package/dist/cjs/ExecutiveDashboard/components/DashboardGrid/buildDashboardWidgets.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/components/DashboardGrid/layout.js +2 -0
- package/dist/cjs/ExecutiveDashboard/components/DashboardGrid/layout.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/components/DashboardGrid/useElementSize.js +2 -0
- package/dist/cjs/ExecutiveDashboard/components/DashboardGrid/useElementSize.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/components/DatePickers/CustomRangePicker.js +2 -0
- package/dist/cjs/ExecutiveDashboard/components/DatePickers/CustomRangePicker.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/components/ExecutiveDashboard.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Graph/Graph.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Graph/LineChart.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/PieChart/utils.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Table/TableCard.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/common/TooltipWrapper.js +2 -0
- package/dist/cjs/ExecutiveDashboard/components/common/TooltipWrapper.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/components/ui/chart.js +1 -1
- package/dist/cjs/ExecutiveDashboard/utils/chartCards.js +2 -0
- package/dist/cjs/ExecutiveDashboard/utils/chartCards.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/utils/sectionOrder.js +1 -1
- package/dist/cjs/assets/icons/thresholdGrey.svg.js +2 -0
- package/dist/cjs/assets/icons/thresholdGrey.svg.js.map +1 -0
- package/dist/cjs/assets/icons/thresholdRed.svg.js +2 -0
- package/dist/cjs/assets/icons/thresholdRed.svg.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/ExecutiveDashboard/ExecutiveDashboardWrapper.d.ts +1 -1
- package/dist/types/ExecutiveDashboard/ExecutiveDashboardWrapper.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/TestExecutiveDashboard.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/api/alertsapi.d.ts +0 -1
- package/dist/types/ExecutiveDashboard/api/alertsapi.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/api/dashboardApi.d.ts +3 -3
- package/dist/types/ExecutiveDashboard/api/dashboardApi.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Alerts/AlertsViewTrigger.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Alerts/CreateAlertModal.d.ts +1 -0
- package/dist/types/ExecutiveDashboard/components/Alerts/CreateAlertModal.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/BarChart/BarChart.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/BarChart/types.d.ts +24 -0
- package/dist/types/ExecutiveDashboard/components/BarChart/types.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/BarChart/utils.d.ts +6 -0
- package/dist/types/ExecutiveDashboard/components/BarChart/utils.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/DashboardDateFilter/DashboardDateFilter.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/DashboardDateFilter/SubscriptionFeature/CreateSubscriptionModal.d.ts +5 -0
- package/dist/types/ExecutiveDashboard/components/DashboardDateFilter/SubscriptionFeature/CreateSubscriptionModal.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/DashboardGrid/DashboardGrid.d.ts +19 -0
- package/dist/types/ExecutiveDashboard/components/DashboardGrid/DashboardGrid.d.ts.map +1 -0
- package/dist/types/ExecutiveDashboard/components/DashboardGrid/buildDashboardWidgets.d.ts +32 -0
- package/dist/types/ExecutiveDashboard/components/DashboardGrid/buildDashboardWidgets.d.ts.map +1 -0
- package/dist/types/ExecutiveDashboard/components/DashboardGrid/layout.d.ts +205 -0
- package/dist/types/ExecutiveDashboard/components/DashboardGrid/layout.d.ts.map +1 -0
- package/dist/types/ExecutiveDashboard/components/DashboardGrid/useElementSize.d.ts +15 -0
- package/dist/types/ExecutiveDashboard/components/DashboardGrid/useElementSize.d.ts.map +1 -0
- package/dist/types/ExecutiveDashboard/components/DatePickers/CustomRangePicker.d.ts +30 -0
- package/dist/types/ExecutiveDashboard/components/DatePickers/CustomRangePicker.d.ts.map +1 -0
- package/dist/types/ExecutiveDashboard/components/ExecutiveDashboard.d.ts +34 -1
- package/dist/types/ExecutiveDashboard/components/ExecutiveDashboard.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Graph/Graph.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Graph/LineChart.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Graph/types.d.ts +2 -0
- package/dist/types/ExecutiveDashboard/components/Graph/types.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/PieChart/utils.d.ts +9 -0
- package/dist/types/ExecutiveDashboard/components/PieChart/utils.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/common/TooltipWrapper.d.ts +9 -0
- package/dist/types/ExecutiveDashboard/components/common/TooltipWrapper.d.ts.map +1 -0
- package/dist/types/ExecutiveDashboard/components/ui/chart.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/types/index.d.ts +71 -19
- package/dist/types/ExecutiveDashboard/types/index.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/utils/chartCards.d.ts +36 -0
- package/dist/types/ExecutiveDashboard/utils/chartCards.d.ts.map +1 -0
- package/dist/types/ExecutiveDashboard/utils/sectionOrder.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as l,__generator as a,__spreadArray as r}from"../../../_virtual/_tslib.js";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{useState as n,useMemo as o,useEffect as s}from"react";import{X as c,Check as d,Info as u,Loader2 as v}from"lucide-react";import p from"../DropDowns/CustomSingleSelect.js";import m from"../DropDowns/CustomMultiSelect.js";var h=function(h){var f=h.isOpen,y=h.onClose,b=h.uiConfig,g=h.onSearchSubscribers,N=h.onSave,q=h.editData,C=n(1),w=C[0],k=C[1],x=(null==b?void 0:b.data)||b,S=o(function(){return((null==x?void 0:x.sidebarFilters)||[]).map(function(e){var l,a;return{id:e.schemaFilterName||e.label,label:e.label,options:(null===(l=e.options)||void 0===l?void 0:l.map(function(e){var l="string"==typeof e?e:void 0!==e.value?e.value:e;return{label:"string"==typeof e?e:e.label||l,value:l}}))||[],scopeType:(null===(a=e.type)||void 0===a?void 0:a.toLowerCase().includes("multi"))?"multiSelect":"singleSelect"}})},[x]),A=o(function(){var e,l=[];return((null===(e=null==x?void 0:x.graphBuilder)||void 0===e?void 0:e.tiers)||[]).forEach(function(e){e.series&&Array.isArray(e.series)&&e.series.forEach(function(e){e.name&&e.key&&l.push({label:e.name,value:e.key})})}),l},[x]),L=n(""),T=L[0],B=L[1],E=n({}),_=E[0],O=E[1],P=n(""),j=P[0],z=P[1],D=n(""),I=D[0],K=D[1],M=n(!1),V=M[0],U=M[1],W=n(""),F=W[0],R=W[1],G=n(void 0),Y=G[0],H=G[1],J=n(""),Q=J[0],X=J[1],Z=n("snapshot"),$=Z[0],ee=Z[1],le=n(""),ae=le[0],re=le[1],ie=n(void 0),te=ie[0],ne=ie[1],oe=n([]),se=oe[0],ce=oe[1],de=n(""),ue=de[0],ve=de[1],pe=n(!1),me=pe[0],he=pe[1],fe=n([]),ye=fe[0],be=fe[1],ge=n(!1),Ne=ge[0],qe=ge[1],Ce=[{label:"Greater Than",value:"greater_than"},{label:"Less Than",value:"less_than"}];s(function(){var e,l,a,r,i,t,n,o,s,c,d,u,v,p,m,h,y;if(f&&he(!1),f&&q){B(q.alertName||(null===(e=q.raw)||void 0===e?void 0:e.name)||"");var b={},g=q.rawScope||(null===(l=q.raw)||void 0===l?void 0:l.entityType)||{};Object.keys(g).forEach(function(e){var l=S.find(function(l){var a;return(null===(a=l.id)||void 0===a?void 0:a.toLowerCase())===e.toLowerCase()}),a=l?l.id:e,r=g[e];if(l&&l.options)if(Array.isArray(r))r=r.map(function(e){var a=l.options.find(function(l){return String(l.value).toLowerCase()===String(e).toLowerCase()});return a?a.value:e});else{var i=l.options.find(function(e){return String(e.value).toLowerCase()===String(r).toLowerCase()});r=i?i.value:r}b[a]=r}),O(b);var N=(null===(a=q.raw)||void 0===a?void 0:a.kpiKey)||"",C=N,w=A.find(function(e){return String(e.value).toLowerCase()===N.toLowerCase()||e.label.toLowerCase()===N.toLowerCase()});w&&(C=w.value),z(C),U(null===(i=null===(r=q.raw)||void 0===r?void 0:r.isPrimaryKpi)||void 0===i||i),K(q.type||(null===(t=q.raw)||void 0===t?void 0:t.kpiType)||"");var x=null===(n=q.raw)||void 0===n?void 0:n.conditionType,L=Ce.find(function(e){return e.value===x||e.value===(">"===x?"greater_than":"<"===x?"less_than":x)});R(L?L.value:x||""),H(void 0!==(null===(o=q.raw)||void 0===o?void 0:o.thresholdValue)&&null!==(null===(s=q.raw)||void 0===s?void 0:s.thresholdValue)?Number(q.raw.thresholdValue):void 0);var T=q.severity||(null===(c=q.raw)||void 0===c?void 0:c.severity)||"";X(T.toLowerCase());var E=(null===(u=null===(d=q.raw)||void 0===d?void 0:d.evaluationType)||void 0===u?void 0:u.toLowerCase())||"";ee("accumulate"===E||"snapshot"===E?E:void 0),re((null===(v=q.raw)||void 0===v?void 0:v.evaluationPeriod)||""),ne(null!==(m=null===(p=q.raw)||void 0===p?void 0:p.triggerAfter)&&void 0!==m?m:void 0);var _=Array.isArray(q.subscribers)&&q.subscribers.length>0?q.subscribers.map(function(e){return{label:e.label||e.email,value:e.value||e.email}}):Array.isArray(null===(y=null===(h=q.raw)||void 0===h?void 0:h.recipients)||void 0===y?void 0:y.userEmails)?q.raw.recipients.userEmails.map(function(e){return{label:e,value:e}}):[];ce(_),k(1)}else f&&!q&&(k(1),B(""),O({}),z(""),U(!1),K(""),R(""),H(void 0),X(""),ee("snapshot"),re(""),ne(void 0),ce([]),ve(""),be([]))},[f,q,S]);if(s(function(){!function(e){var l,a;if(e){if(q){var r=q.type||(null===(l=q.raw)||void 0===l?void 0:l.kpiType);if(r)return void K(String(r).toLowerCase())}for(var i="",t=0,n=(null===(a=null==x?void 0:x.graphBuilder)||void 0===a?void 0:a.tiers)||[];t<n.length;t++){var o=n[t];if(o.series&&Array.isArray(o.series)&&o.series.find(function(l){return l.key===e})&&o.plotOptions&&Array.isArray(o.plotOptions)&&o.plotOptions.length>0){i=o.plotOptions[0].value;break}}if(i)K(i);else{var s=e.toLowerCase(),c=A.find(function(e){return e.value.toLowerCase()===s});c&&K(c.value)}}}(j)},[j,A,q]),!f)return null;var we=function(e,l){if(!e)return l?[]:"";var a=Object.keys(_).find(function(l){return l.toLowerCase()===(null==e?void 0:e.toLowerCase())});if(a&&void 0!==_[a]){var r=_[a];return l?Array.isArray(r)?r:r?[r]:[]:Array.isArray(r)?r.length>0?r[0]:"":r}return l?[]:""},ke=""!==T.trim(),xe=!(""===j||""===F||void 0===Y||""===Q||void 0===$||"accumulate"===$&&""===ae||"snapshot"===$&&void 0===te);return i("div",e({className:"q-alert-modal-overlay",onClick:me?void 0:y},{children:t("div",e({className:"q-alert-modal",onClick:function(e){return e.stopPropagation()}},{children:[t("div",e({className:"q-alert-modal-header"},{children:[i("div",e({className:"q-alert-modal-title"},{children:q?"Edit alert":"Create alert"})),i("button",e({className:"q-alert-modal-close",onClick:y,disabled:me},{children:i(c,{size:14})}))]})),t("div",e({className:"q-alert-stepper"},{children:[t("div",e({className:"q-alert-step ".concat(w>=1?w>1?"completed":"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:w>1?i(d,{size:14}):"1"})),"Define Alert"]})),i("div",{className:"q-alert-step-line ".concat(w>1?"completed":"")}),t("div",e({className:"q-alert-step ".concat(w>=2?w>2?"completed":"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:w>2?i(d,{size:14}):"2"})),"Configure Alert"]})),i("div",{className:"q-alert-step-line ".concat(w>2?"completed":"")}),t("div",e({className:"q-alert-step ".concat(w>=3?"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:"3"})),"Set Recipients"]}))]})),t("div",e({className:"q-alert-modal-body"},{children:[1===w&&t("div",{children:[t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label"},{children:["Alert name ",i("span",e({className:"req"},{children:"*"}))]})),i("input",{type:"text",className:"q-alert-input",placeholder:"Enter a name so it can be easily identified",value:T,onChange:function(e){return B(e.target.value)}})]})),i("div",{style:{height:"1px",background:"#E2E8F0",margin:"0 0 24px 0"}}),i("label",e({className:"q-alert-form-label"},{children:"Alert Scope"})),i("div",e({className:"q-alert-grid-2"},{children:S.map(function(l){var a,r;return t("div",{children:[i("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:l.label})),"multiSelect"===l.scopeType?i(m,{options:l.options,value:we(l.id,!0)||[],onChange:function(a){var r,i=Object.keys(_).find(function(e){return e.toLowerCase()===(l.id||"").toLowerCase()});O(e(e({},_),((r={})[i||l.id]=a,r)))},placeholder:"Select ".concat((null===(a=l.label)||void 0===a?void 0:a.toLowerCase())||"")}):i(p,{options:l.options,value:we(l.id,!1)||"",onChange:function(a){var r,i=Object.keys(_).find(function(e){return e.toLowerCase()===(l.id||"").toLowerCase()});O(e(e({},_),((r={})[i||l.id]=a,r)))},placeholder:"Select ".concat((null===(r=l.label)||void 0===r?void 0:r.toLowerCase())||"")})]},l.id)})}))]}),2===w&&t("div",{children:[t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:["KPI ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:A,value:j,onChange:function(e){return z(e)},placeholder:"Select a KPI"}),t("label",e({className:"q-alert-checkbox-label"},{children:[i("input",{type:"checkbox",className:"q-alert-checkbox",checked:V,onChange:function(e){return U(e.target.checked)}}),"Set as Primary KPI to display its threshold line on the chart."]}))]})),t("div",e({className:"q-alert-form-group"},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"Threshold Configuration"})),i("div",e({className:"q-alert-form-desc"},{children:"Define the threshold condition that will trigger the alert."})),t("div",e({className:"q-alert-grid-2"},{children:[t("div",{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Condition ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:Ce,value:F,onChange:function(e){return R(e)},placeholder:"Select condition"})]}),t("div",{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Value ",i("span",e({className:"req"},{children:"*"}))]})),i("input",{type:"number",className:"q-alert-input",placeholder:"Enter value",value:void 0===Y?"":Y,onChange:function(e){return H(""===e.target.value?void 0:Number(e.target.value))}})]})]})),t("div",e({style:{marginTop:"16px",width:"calc(50% - 8px)"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Severity ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:[{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:Q,onChange:function(e){return X(e)},placeholder:"Select severity"})]}))]})),t("div",e({className:"q-alert-form-group"},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"Trigger Configuration"})),i("div",e({className:"q-alert-form-desc"},{children:"Who should receive this report?"})),t("div",e({style:{width:"calc(50% - 8px)"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Evaluation Type ",i("span",e({className:"req"},{children:"*"}))," ",i(u,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i(p,{options:[{label:"Snapshot",value:"snapshot"},{label:"Accumulate",value:"accumulate"}],value:$,onChange:function(e){return ee(e)},placeholder:"Select evaluation type"})]})),"accumulate"===$&&t("div",e({style:{width:"calc(50% - 8px)",marginTop:"16px"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Evaluation period ",i("span",e({className:"req"},{children:"*"}))," ",i(u,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i(p,{options:[{label:"Daily",value:"daily"},{label:"Weekly",value:"weekly"},{label:"Monthly",value:"monthly"}],value:ae,onChange:function(e){return re(e)},placeholder:"Select evaluation period"})]})),"snapshot"===$&&t("div",e({style:{width:"calc(50% - 8px)",marginTop:"16px"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Trigger After ",i("span",e({className:"req"},{children:"*"}))," ",i(u,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i("input",{type:"number",className:"q-alert-input",placeholder:"Enter no. of data points",value:void 0===te?"":te,min:"0",onChange:function(e){return ne(""===e.target.value?void 0:Math.max(0,Number(e.target.value)))}})]}))]}))]}),3===w&&i("div",{children:t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:["Alert Recipients ",i("span",e({className:"req"},{children:"*"}))]})),i("div",e({className:"q-alert-form-desc"},{children:"Add users who should receive an email when this alert is triggered."})),t("div",e({className:"q-alert-search-box",style:{position:"relative"}},{children:[i("input",{type:"text",className:"q-alert-input",placeholder:"Type name or email...",value:ue,onChange:function(e){return l(void 0,void 0,void 0,function(){var l,r;return a(this,function(a){switch(a.label){case 0:if(l=e.target.value,ve(l),!l)return be([]),[2];if(!g)return[3,5];qe(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,g(l)];case 2:return r=a.sent(),be(r||[]),[3,5];case 3:return a.sent(),be([]),[3,5];case 4:return qe(!1),[7];case 5:return[2]}})})}}),Ne&&i("div",e({style:{position:"absolute",right:"12px",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center"}},{children:i(v,{size:16,className:"animate-spin",color:"#94a3b8"})})),ye.length>0&&ue&&i("div",e({className:"q-alert-search-results"},{children:ye.map(function(l){return i("div",e({className:"q-alert-search-item",onClick:function(){return function(e){se.find(function(l){return l.value===e.value})||ce(r(r([],se,!0),[e],!1)),ve(""),be([])}(l)}},{children:l.label}),l.value)})}))]})),se.length>0&&i("div",e({className:"q-alert-chips"},{children:se.map(function(l){return t("div",e({className:"q-alert-chip"},{children:[l.label,i("div",e({className:"q-alert-chip-remove",onClick:function(){return e=l.value,void ce(se.filter(function(l){return l.value!==e}));var e}},{children:i(c,{size:12,strokeWidth:3})}))]}),l.value)})}))]}))})]})),t("div",e({className:"q-alert-modal-footer"},{children:[i("button",1===w?e({className:"q-alert-btn-cancel",onClick:y,disabled:me},{children:"Cancel"}):e({className:"q-alert-btn-cancel",onClick:function(){return k(function(e){return Math.max(e-1,1)})},disabled:me},{children:"Back"})),w<3?t("button",e({className:"q-alert-btn-primary",onClick:function(){return k(function(e){return Math.min(e+1,3)})},disabled:1===w?!ke:2===w&&!xe},{children:["Next ",i("span",e({style:{marginLeft:"4px"}},{children:"→"}))]})):i("button",e({className:"q-alert-btn-primary",onClick:function(){return l(void 0,void 0,void 0,function(){var e,l;return a(this,function(a){switch(a.label){case 0:he(!0),e={name:T,kpi_key:j,kpi_type:I,entity_type:_,isPrimaryKpi:V,conditionType:"greater_than"===F?">":"less_than"===F?"<":F,thresholdValue:void 0!==Y?Number(Y):null,severity:Q.toUpperCase(),evaluationType:(null==$?void 0:$.toUpperCase())||"",evaluationPeriod:ae||null,triggerAfter:void 0!==te?Number(te):0,recipients:{userIds:se.map(function(e){return e.userId}).filter(Boolean),userEmails:se.map(function(e){return e.value})}},a.label=1;case 1:return a.trys.push([1,,4,5]),N?[4,N(e,!!(null==q?void 0:q.id)||(null===(l=null==q?void 0:q.raw)||void 0===l?void 0:l.id))]:[3,3];case 2:!1!==a.sent()&&(y(),k(1),B(""),O({}),z(""),K(""),U(!1),R(""),H(void 0),X(""),re(""),ne(void 0),ce([]),ve("")),a.label=3;case 3:return[3,5];case 4:return he(!1),[7];case 5:return[2]}})})},disabled:me||0===se.length},{children:me?q?"Updating...":"Creating...":q?"Update alert":"Create alert"}))]}))]}))}))};export{h as default};
|
|
1
|
+
import{__assign as e,__awaiter as a,__generator as l,__spreadArray as r}from"../../../_virtual/_tslib.js";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{useState as n,useMemo as o,useEffect as s}from"react";import{X as c,Check as d,Info as u,Loader2 as v}from"lucide-react";import p from"../DropDowns/CustomSingleSelect.js";import m from"../DropDowns/CustomMultiSelect.js";var h=function(h){var f=h.isOpen,y=h.onClose,b=h.uiConfig,g=h.onSearchSubscribers,N=h.onSave,q=h.editData,C=h.status,w=n(1),k=w[0],x=w[1],A=(null==b?void 0:b.data)||b,S=o(function(){return((null==A?void 0:A.sidebarFilters)||[]).map(function(e){var a,l;return{id:e.schemaFilterName||e.label,label:e.label,options:(null===(a=e.options)||void 0===a?void 0:a.map(function(e){var a="string"==typeof e?e:void 0!==e.value?e.value:e;return{label:"string"==typeof e?e:e.label||a,value:a}}))||[],scopeType:(null===(l=e.type)||void 0===l?void 0:l.toLowerCase().includes("multi"))?"multiSelect":"singleSelect"}})},[A]),L=o(function(){var e,a=[];return((null===(e=null==A?void 0:A.graphBuilder)||void 0===e?void 0:e.tiers)||[]).forEach(function(e){e.series&&Array.isArray(e.series)&&e.series.forEach(function(e){e.name&&e.key&&a.push({label:e.name,value:e.key})})}),a},[A]),T=n(""),B=T[0],E=T[1],I=n({}),O=I[0],j=I[1],z=n(""),D=z[0],_=z[1],V=n(""),M=V[0],P=V[1],K=n(""),U=K[0],W=K[1],F=n(void 0),R=F[0],G=F[1],Y=n(""),H=Y[0],J=Y[1],Q=n("snapshot"),X=Q[0],Z=Q[1],$=n(""),ee=$[0],ae=$[1],le=n(void 0),re=le[0],ie=le[1],te=n([]),ne=te[0],oe=te[1],se=n(""),ce=se[0],de=se[1],ue=n(!1),ve=ue[0],pe=ue[1],me=n([]),he=me[0],fe=me[1],ye=n(!1),be=ye[0],ge=ye[1],Ne=[{label:"Greater Than",value:"greater_than"},{label:"Less Than",value:"less_than"}];s(function(){var e,a,l,r,i,t,n,o,s,c,d,u,v,p,m;if(f&&pe(!1),f&&q){E(q.alertName||(null===(e=q.raw)||void 0===e?void 0:e.name)||"");var h={},y=q.rawScope||(null===(a=q.raw)||void 0===a?void 0:a.entityType)||{};Object.keys(y).forEach(function(e){var a=S.find(function(a){var l;return(null===(l=a.id)||void 0===l?void 0:l.toLowerCase())===e.toLowerCase()}),l=a?a.id:e,r=y[e];if(a&&a.options)if(Array.isArray(r))r=r.map(function(e){var l=a.options.find(function(a){return String(a.value).toLowerCase()===String(e).toLowerCase()});return l?l.value:e});else{var i=a.options.find(function(e){return String(e.value).toLowerCase()===String(r).toLowerCase()});r=i?i.value:r}h[l]=r}),j(h);var b=(null===(l=q.raw)||void 0===l?void 0:l.kpiKey)||"",g=b,N=L.find(function(e){return String(e.value).toLowerCase()===b.toLowerCase()||e.label.toLowerCase()===b.toLowerCase()});N&&(g=N.value),_(g),P(q.type||(null===(r=q.raw)||void 0===r?void 0:r.kpiType)||"");var C=null===(i=q.raw)||void 0===i?void 0:i.conditionType,w=Ne.find(function(e){return e.value===C||e.value===(">"===C?"greater_than":"<"===C?"less_than":C)});W(w?w.value:C||""),G(void 0!==(null===(t=q.raw)||void 0===t?void 0:t.thresholdValue)&&null!==(null===(n=q.raw)||void 0===n?void 0:n.thresholdValue)?Number(q.raw.thresholdValue):void 0);var k=q.severity||(null===(o=q.raw)||void 0===o?void 0:o.severity)||"";J(k.toLowerCase());var A=(null===(c=null===(s=q.raw)||void 0===s?void 0:s.evaluationType)||void 0===c?void 0:c.toLowerCase())||"";Z("accumulate"===A||"snapshot"===A?A:void 0),ae((null===(d=q.raw)||void 0===d?void 0:d.evaluationPeriod)||""),ie(null!==(v=null===(u=q.raw)||void 0===u?void 0:u.triggerAfter)&&void 0!==v?v:void 0);var T=Array.isArray(q.subscribers)&&q.subscribers.length>0?q.subscribers.map(function(e){return{label:e.label||e.email,value:e.value||e.email,userId:e.userId}}):Array.isArray(null===(m=null===(p=q.raw)||void 0===p?void 0:p.recipients)||void 0===m?void 0:m.userEmails)?q.raw.recipients.userEmails.map(function(e,a){var l;return{label:e,value:e,userId:null===(l=q.raw.recipients.userIds)||void 0===l?void 0:l[a]}}):[];oe(T),x(1)}else f&&!q&&(x(1),E(""),j({}),_(""),P(""),W(""),G(void 0),J(""),Z("snapshot"),ae(""),ie(void 0),oe([]),de(""),fe([]))},[f,q,S]);if(s(function(){!function(e){var a,l;if(e){if(q){var r=q.type||(null===(a=q.raw)||void 0===a?void 0:a.kpiType);if(r)return void P(String(r).toLowerCase())}for(var i="",t=0,n=(null===(l=null==A?void 0:A.graphBuilder)||void 0===l?void 0:l.tiers)||[];t<n.length;t++){var o=n[t];if(o.series&&Array.isArray(o.series)&&o.series.find(function(a){return a.key===e})&&o.plotOptions&&Array.isArray(o.plotOptions)&&o.plotOptions.length>0){i=o.plotOptions[0].value;break}}if(i)P(i);else{var s=e.toLowerCase(),c=L.find(function(e){return e.value.toLowerCase()===s});c&&P(c.value)}}}(D)},[D,L,q]),!f)return null;var qe=function(e,a){if(!e)return a?[]:"";var l=Object.keys(O).find(function(a){return a.toLowerCase()===(null==e?void 0:e.toLowerCase())});if(l&&void 0!==O[l]){var r=O[l];return a?Array.isArray(r)?r:r?[r]:[]:Array.isArray(r)?r.length>0?r[0]:"":r}return a?[]:""},Ce=""!==B.trim(),we=!(""===D||""===U||void 0===R||""===H||void 0===X||"accumulate"===X&&""===ee||"snapshot"===X&&void 0===re);return i("div",e({className:"q-alert-modal-overlay",onClick:ve?void 0:y},{children:t("div",e({className:"q-alert-modal",onClick:function(e){return e.stopPropagation()}},{children:[t("div",e({className:"q-alert-modal-header"},{children:[i("div",e({className:"q-alert-modal-title"},{children:q?"Edit alert":"Create alert"})),i("button",e({className:"q-alert-modal-close",onClick:y,disabled:ve},{children:i(c,{size:14})}))]})),t("div",e({className:"q-alert-stepper"},{children:[t("div",e({className:"q-alert-step ".concat(k>=1?k>1?"completed":"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:k>1?i(d,{size:14}):"1"})),"Define Alert"]})),i("div",{className:"q-alert-step-line ".concat(k>1?"completed":"")}),t("div",e({className:"q-alert-step ".concat(k>=2?k>2?"completed":"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:k>2?i(d,{size:14}):"2"})),"Configure Alert"]})),i("div",{className:"q-alert-step-line ".concat(k>2?"completed":"")}),t("div",e({className:"q-alert-step ".concat(k>=3?"active":"")},{children:[i("div",e({className:"q-alert-step-num"},{children:"3"})),"Set Recipients"]}))]})),t("div",e({className:"q-alert-modal-body"},{children:[1===k&&t("div",{children:[t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label"},{children:["Alert name ",i("span",e({className:"req"},{children:"*"}))]})),i("input",{type:"text",className:"q-alert-input",placeholder:"Enter a name so it can be easily identified",value:B,onChange:function(e){return E(e.target.value)}})]})),i("div",{style:{height:"1px",background:"#E2E8F0",margin:"0 0 24px 0"}}),i("label",e({className:"q-alert-form-label"},{children:"Alert Scope"})),i("div",e({className:"q-alert-grid-2"},{children:S.map(function(a){var l,r;return t("div",{children:[i("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:a.label})),"multiSelect"===a.scopeType?i(m,{options:a.options,value:qe(a.id,!0)||[],onChange:function(l){var r,i=Object.keys(O).find(function(e){return e.toLowerCase()===(a.id||"").toLowerCase()});j(e(e({},O),((r={})[i||a.id]=l,r)))},placeholder:"Select ".concat((null===(l=a.label)||void 0===l?void 0:l.toLowerCase())||"")}):i(p,{options:a.options,value:qe(a.id,!1)||"",onChange:function(l){var r,i=Object.keys(O).find(function(e){return e.toLowerCase()===(a.id||"").toLowerCase()});j(e(e({},O),((r={})[i||a.id]=l,r)))},placeholder:"Select ".concat((null===(r=a.label)||void 0===r?void 0:r.toLowerCase())||"")})]},a.id)})}))]}),2===k&&t("div",{children:[t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:["KPI ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:L,value:D,onChange:function(e){return _(e)},placeholder:"Select a KPI"})]})),t("div",e({className:"q-alert-form-group"},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"Threshold Configuration"})),i("div",e({className:"q-alert-form-desc"},{children:"Define the threshold condition that will trigger the alert."})),t("div",e({className:"q-alert-grid-2"},{children:[t("div",{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Condition ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:Ne,value:U,onChange:function(e){return W(e)},placeholder:"Select condition"})]}),t("div",{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Value ",i("span",e({className:"req"},{children:"*"}))]})),i("input",{type:"number",className:"q-alert-input",placeholder:"Enter value",value:void 0===R?"":R,onChange:function(e){return G(""===e.target.value?void 0:Number(e.target.value))}})]})]})),t("div",e({style:{marginTop:"16px",width:"calc(50% - 8px)"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Severity ",i("span",e({className:"req"},{children:"*"}))]})),i(p,{options:[{label:"Critical",value:"critical"},{label:"Warning",value:"warning"},{label:"Info",value:"info"}],value:H,onChange:function(e){return J(e)},placeholder:"Select severity"})]}))]})),t("div",e({className:"q-alert-form-group"},{children:[i("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:"Trigger Configuration"})),i("div",e({className:"q-alert-form-desc"},{children:"Who should receive this report?"})),t("div",e({style:{width:"calc(50% - 8px)"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Evaluation Type ",i("span",e({className:"req"},{children:"*"}))," ",i(u,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i(p,{options:[{label:"Snapshot",value:"snapshot"},{label:"Accumulate",value:"accumulate"}],value:X,onChange:function(e){return Z(e)},placeholder:"Select evaluation type"})]})),"accumulate"===X&&t("div",e({style:{width:"calc(50% - 8px)",marginTop:"16px"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Evaluation period ",i("span",e({className:"req"},{children:"*"}))," ",i(u,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i(p,{options:[{label:"Daily",value:"daily"},{label:"Weekly",value:"weekly"},{label:"Monthly",value:"monthly"}],value:ee,onChange:function(e){return ae(e)},placeholder:"Select evaluation period"})]})),"snapshot"===X&&t("div",e({style:{width:"calc(50% - 8px)",marginTop:"16px"}},{children:[t("label",e({className:"q-alert-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:["Trigger After ",i("span",e({className:"req"},{children:"*"}))," ",i(u,{size:12,style:{display:"inline",color:"#94a3b8"}})]})),i("input",{type:"number",className:"q-alert-input",placeholder:"Enter no. of data points",value:void 0===re?"":re,min:"0",onChange:function(e){return ie(""===e.target.value?void 0:Math.max(0,Number(e.target.value)))}})]}))]}))]}),3===k&&i("div",{children:t("div",e({className:"q-alert-form-group"},{children:[t("label",e({className:"q-alert-form-label",style:{marginBottom:"4px"}},{children:["Alert Recipients ",i("span",e({className:"req"},{children:"*"}))]})),i("div",e({className:"q-alert-form-desc"},{children:"Add users who should receive an email when this alert is triggered."})),t("div",e({className:"q-alert-search-box",style:{position:"relative"}},{children:[i("input",{type:"text",className:"q-alert-input",placeholder:"Type name or email...",value:ce,onChange:function(e){return a(void 0,void 0,void 0,function(){var a,r;return l(this,function(l){switch(l.label){case 0:if(a=e.target.value,de(a),!a)return fe([]),[2];if(!g)return[3,5];ge(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,g(a)];case 2:return r=l.sent(),fe(r||[]),[3,5];case 3:return l.sent(),fe([]),[3,5];case 4:return ge(!1),[7];case 5:return[2]}})})}}),be&&i("div",e({style:{position:"absolute",right:"12px",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center"}},{children:i(v,{size:16,className:"animate-spin",color:"#94a3b8"})})),he.length>0&&ce&&i("div",e({className:"q-alert-search-results"},{children:he.map(function(a){return i("div",e({className:"q-alert-search-item",onClick:function(){return function(e){ne.find(function(a){return a.value===e.value})||oe(r(r([],ne,!0),[e],!1)),de(""),fe([])}(a)}},{children:a.label}),a.value)})}))]})),ne.length>0&&i("div",e({className:"q-alert-chips"},{children:ne.map(function(a){return t("div",e({className:"q-alert-chip"},{children:[a.label,i("div",e({className:"q-alert-chip-remove",onClick:function(){return e=a.value,void oe(ne.filter(function(a){return a.value!==e}));var e}},{children:i(c,{size:12,strokeWidth:3})}))]}),a.value)})}))]}))})]})),t("div",e({className:"q-alert-modal-footer"},{children:[i("button",1===k?e({className:"q-alert-btn-cancel",onClick:y,disabled:ve},{children:"Cancel"}):e({className:"q-alert-btn-cancel",onClick:function(){return x(function(e){return Math.max(e-1,1)})},disabled:ve},{children:"Back"})),k<3?t("button",e({className:"q-alert-btn-primary",onClick:function(){return x(function(e){return Math.min(e+1,3)})},disabled:1===k?!Ce:2===k&&!we},{children:["Next ",i("span",e({style:{marginLeft:"4px"}},{children:"→"}))]})):i("button",e({className:"q-alert-btn-primary",onClick:function(){return a(void 0,void 0,void 0,function(){var e,a;return l(this,function(l){switch(l.label){case 0:pe(!0),e={name:B,kpiKey:D,kpiType:M,entityType:O,conditionType:"greater_than"===U?">":"less_than"===U?"<":U,thresholdValue:void 0!==R?Number(R):null,severity:H.toUpperCase(),evaluationType:(null==X?void 0:X.toUpperCase())||"",evaluationPeriod:ee||null,triggerAfter:void 0!==re?Number(re):0,recipients:{userIds:ne.map(function(e){return e.userId}).filter(Boolean),userEmails:ne.map(function(e){return e.value})},status:q?"ACTIVE":C},l.label=1;case 1:return l.trys.push([1,,4,5]),N?[4,N(e,!!(null==q?void 0:q.id)||(null===(a=null==q?void 0:q.raw)||void 0===a?void 0:a.id))]:[3,3];case 2:!1!==l.sent()&&(y(),x(1),E(""),j({}),_(""),P(""),W(""),G(void 0),J(""),ae(""),ie(void 0),oe([]),de("")),l.label=3;case 3:return[3,5];case 4:return pe(!1),[7];case 5:return[2]}})})},disabled:ve||0===ne.length},{children:ve?q?"Updating...":"Creating...":q?"Update alert":"Create alert"}))]}))]}))}))};export{h as default};
|
|
2
2
|
//# sourceMappingURL=CreateAlertModal.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as l,__spreadArray as i}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as e,Fragment as t}from"react/jsx-runtime";import{useState as a,useMemo as o}from"react";import{BarChart as r,CartesianGrid as u,XAxis as d,YAxis as c,Bar as s,Cell as v}from"recharts";import{ChartContainer as m,ChartTooltip as h}from"../ui/chart.js";import{compactNumber as f}from"../../utils/index.js";import b from"./BarChartEmptyState.js";import p from"./BarChartSkeleton.js";import x from"./BarChartTooltip.js";import{DEFAULT_BAR_COLOR as y}from"./types.js";import{resolveBarColors as g,sumValues as _,withAlpha as k,wrapLabel as C,darken as N}from"./utils.js";var L=function(l){return"number"==typeof l&&Number.isFinite(l)};function S(i){var e,t,a,o=i.x,r=i.y,u=i.payload,d=i.fill,c=i.maxChars,s=i.maxLines,v=i.axis,m=i.formatTick,h=m?m(String(null!==(e=null==u?void 0:u.value)&&void 0!==e?e:""),null!==(t=null==u?void 0:u.index)&&void 0!==t?t:0):String(null!==(a=null==u?void 0:u.value)&&void 0!==a?a:""),f=C(h,c,s),b="x"===v,p=b?12:-13*(f.length-1)/2+4;return n("text",l({x:o,y:r,fill:d,fontSize:11,textAnchor:b?"middle":"end",className:"ellm-bar-chart__tick"},{children:f.map(function(i,e){return n("tspan",l({x:o,dy:0===e?p:13},{children:i}),e)})}))}function M(C){var M,w,z,A,B,j,F,T,G,O,V,W,E,H=C.data,R=C.title,I=C.description,K=C.icon,D=C.headerActions,Z=C.color,q=void 0===Z?y:Z,J=C.shadeMode,P=void 0===J?"rank":J,Q=C.yAxisLabel,U=C.xAxisLabel,X=C.xAxis,Y=C.yAxis,$=C.tooltip,ll=C.legend,il=C.config,nl=C.style,el=C.valueFormatter,tl=C.loading,al=C.emptyState,ol=C.onBarClick,rl=a(null),ul=rl[0],dl=rl[1],cl=null!==(M=null==nl?void 0:nl.chartHeight)&&void 0!==M?M:300,sl=null!==(w=null==nl?void 0:nl.gridColor)&&void 0!==w?w:"#eef0f4",vl=null!==(z=null==nl?void 0:nl.axisColor)&&void 0!==z?z:"#d7dbe3",ml=null!==(A=null==nl?void 0:nl.axisLabelColor)&&void 0!==A?A:"#6b7280",hl=null!==(B=null==nl?void 0:nl.tickColor)&&void 0!==B?B:"#9ca3af",fl=null!==(j=null==nl?void 0:nl.fontFamily)&&void 0!==j?j:"Inter, system-ui, -apple-system, sans-serif",bl="horizontal"===(null==il?void 0:il.orientation),pl=null!==(F=null==il?void 0:il.showValueLabels)&&void 0!==F&&F,xl=!1!==(null==il?void 0:il.highlightOnHover),yl=!1!==(null==il?void 0:il.animate),gl=!1!==(null==il?void 0:il.showHeader),_l=null!==(T=null==il?void 0:il.sortBy)&&void 0!==T?T:"none",kl=l({label:U},X),Cl=l({label:Q},Y),Nl=o(function(){var l=null!=H?H:[];if("none"===_l)return l;var n="asc"===_l?1:-1;return i([],l,!0).sort(function(l,i){var e,t;return((null!==(e=l.value)&&void 0!==e?e:-1/0)-(null!==(t=i.value)&&void 0!==t?t:-1/0))*n})},[H,_l]),Ll=o(function(){return g(Nl,q,P,null==nl?void 0:nl.shadeRange)},[Nl,q,P,null==nl?void 0:nl.shadeRange]),Sl=o(function(){return _(Nl)},[Nl]),Ml=o(function(){return Nl.map(function(l,i){return{label:l.label,value:l.value,__index:i}})},[Nl]),wl=o(function(){return Nl.some(function(l){return L(l.value)})},[Nl]),zl=o(function(){var l=Nl.map(function(l){return l.value}).filter(L);return l.length?Math.max.apply(Math,l):0},[Nl]),Al=[null!=Cl.min?Cl.min:!1!==Cl.beginAtZero?0:"auto",null!=Cl.max?Cl.max:zl>0?Math.ceil(1.1*zl):"auto"],Bl=o(function(){return{value:{label:"Value",color:q}}},[q]),jl=function(l){var i=Nl[l];return i&&L(i.value)?{datum:i,value:i.value,color:Ll[l],index:l,total:Sl}:null},Fl=function(l){if(ol){var i=jl(l);i&&ol(i)}},Tl=function(l,i){var n=null==el?void 0:el(l,i);return"string"==typeof n||"number"==typeof n?String(n):f(l)},Gl=function(i){var e,t=i.x,a=i.y,o=i.width,r=i.height,u=i.index,d=Nl[u];return d&&L(d.value)?n("text",l({x:bl?t+o+6:t+o/2,y:bl?a+r/2+4:a-7,textAnchor:bl?"start":"middle",className:"ellm-bar-chart__value-label",opacity:xl&&null!==ul&&ul!==u?null!==(e=null==nl?void 0:nl.dimOpacity)&&void 0!==e?e:.45:1},{children:Tl(d.value,d)})):n("g",{})},Ol=null!==(G=null==nl?void 0:nl.barRadius)&&void 0!==G?G:6,Vl=bl?[0,Ol,Ol,0]:[Ol,Ol,0,0],Wl={dataKey:"label",type:"category",hide:!1===kl.show,tickLine:!1,axisLine:!kl.hideLine&&{stroke:vl},tickMargin:8,interval:null!==(O=kl.interval)&&void 0!==O?O:0,tick:function(i){var e,t;return n(S,l({},i,{fill:hl,maxChars:null!==(e=kl.tickMaxChars)&&void 0!==e?e:14,maxLines:null!==(t=kl.tickMaxLines)&&void 0!==t?t:2,axis:bl?"y":"x",formatTick:kl.formatTick}))}},El={type:"number",hide:!1===Cl.show,domain:Al,tickLine:!1,axisLine:!1===Cl.hideLine&&{stroke:vl},tickCount:Cl.tickCount,tick:{fill:hl,fontSize:11},tickFormatter:function(l){return Cl.formatTick?Cl.formatTick(Number(l),0):"number"==typeof l?f(l):String(l)}},Hl=null!==(V=Cl.width)&&void 0!==V?V:Cl.label?64:48,Rl={top:pl?24:12,right:bl&&pl?48:16,bottom:!bl&&kl.label?24:8,left:0},Il=null!==(W=null==nl?void 0:nl.cursorFill)&&void 0!==W?W:k(q,.06),Kl=R||I||K||D;return e("div",l({className:"ellm-bar-chart".concat((null==nl?void 0:nl.className)?" ".concat(nl.className):""),style:null==nl?void 0:nl.container},{children:[gl&&Kl&&e("div",l({className:"ellm-bar-chart__header"},{children:[e("div",l({className:"ellm-bar-chart__heading"},{children:[K&&n("span",l({className:"ellm-bar-chart__icon"},{children:K})),e("div",{children:[R&&n("div",l({className:"ellm-bar-chart__title"},{children:R})),I&&n("div",l({className:"ellm-bar-chart__description"},{children:I}))]})]})),D&&n("div",l({className:"ellm-bar-chart__actions"},{children:D}))]})),tl?n(p,{height:cl,bars:Math.max(Nl.length||6,3)}):wl?e(t,{children:[n(m,l({config:Bl,style:{height:cl,fontFamily:fl}},{children:function(){var i,a,o;return e(r,l({accessibilityLayer:!0,data:Ml,margin:Rl,layout:bl?"vertical":"horizontal",barCategoryGap:null!==(i=null==nl?void 0:nl.barCategoryGap)&&void 0!==i?i:"28%",onMouseMove:function(l){var i=(null==l?void 0:l.isTooltipActive)?l.activeTooltipIndex:null;dl("number"==typeof i?i:null)},onMouseLeave:function(){return dl(null)}},{children:[n(u,{horizontal:bl?!!(null==nl?void 0:nl.showVerticalGrid):!1!==(null==nl?void 0:nl.showGrid),vertical:bl?!1!==(null==nl?void 0:nl.showGrid):!!(null==nl?void 0:nl.showVerticalGrid),stroke:sl}),e(t,bl?{children:[n(d,l({},El,{height:Cl.label?48:void 0,label:Cl.label?{value:Cl.label,position:"insideBottom",offset:-4,fill:ml,fontSize:12,fontWeight:500}:void 0})),n(c,l({},Wl,{width:kl.tickMaxChars?7*kl.tickMaxChars:96}))]}:{children:[n(d,l({},Wl,{height:kl.label?64:44,label:kl.label?{value:kl.label,position:"insideBottom",offset:0,fill:ml,fontSize:12,fontWeight:500}:void 0})),n(c,l({},El,{width:Hl,label:Cl.label?{value:Cl.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"},fill:ml,fontSize:12,fontWeight:500}:void 0}))]}),!1!==(null==$?void 0:$.enabled)&&n(h,{cursor:{fill:Il,radius:6},content:function(l){var i,e,a,o=null===(a=null===(e=null===(i=null==l?void 0:l.payload)||void 0===i?void 0:i[0])||void 0===e?void 0:e.payload)||void 0===a?void 0:a.__index,r="number"==typeof o?jl(o):null;return r?(null==$?void 0:$.render)?n(t,{children:$.render(r)}):n(x,{ctx:r,config:$,valueFormatter:el}):null}}),n(s,l({dataKey:"value",radius:Vl,maxBarSize:null!==(o=null!==(a=null==nl?void 0:nl.barSize)&&void 0!==a?a:null==nl?void 0:nl.maxBarSize)&&void 0!==o?o:56,barSize:null==nl?void 0:nl.barSize,isAnimationActive:yl,animationDuration:600,onClick:function(l,i){return Fl(i)},onMouseEnter:function(l,i){return dl(i)},className:ol?"ellm-bar-chart__bar--clickable":void 0,label:pl?Gl:void 0},{children:Ml.map(function(l,i){var e,t=ul===i,a=xl&&null!==ul&&!t;return n(v,{className:"ellm-bar-chart__bar",fill:Ll[i],fillOpacity:a?null!==(e=null==nl?void 0:nl.dimOpacity)&&void 0!==e?e:.45:1,stroke:t?N(Ll[i],.22):void 0,strokeWidth:t?1.5:0},"".concat(l.label,"-").concat(i))})}))]}))}()})),(null==ll?void 0:ll.show)&&n("div",l({className:"ellm-bar-chart__legend ellm-bar-chart__legend--".concat(null!==(E=ll.align)&&void 0!==E?E:"center")},{children:Nl.map(function(i,t){return e("button",l({type:"button",className:"ellm-bar-chart__legend-item".concat(null!==ul&&ul!==t?" ellm-bar-chart__legend-item--off":""),onMouseEnter:function(){return dl(t)},onMouseLeave:function(){return dl(null)},onFocus:function(){return dl(t)},onBlur:function(){return dl(null)},onClick:function(){return Fl(t)}},{children:[n("span",{className:"ellm-bar-chart__legend-swatch",style:{background:Ll[t]}}),i.label]}),"".concat(i.label,"-").concat(t))})}))]}):n("div",l({className:"ellm-bar-chart__empty"},{children:null!=al?al:n(b,{})}))]}))}export{M as default};
|
|
1
|
+
import{__assign as l,__spreadArray as e}from"../../../_virtual/_tslib.js";import{jsx as i,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useState as a,useRef as r,useMemo as o,useLayoutEffect as c}from"react";import{BarChart as d,XAxis as u,YAxis as s,Bar as h,CartesianGrid as v,Cell as m}from"recharts";import{ChartContainer as f,ChartTooltip as b}from"../ui/chart.js";import{compactNumber as g}from"../../utils/index.js";import p from"./BarChartEmptyState.js";import y from"./BarChartSkeleton.js";import _ from"./BarChartTooltip.js";import{useElementSize as x}from"../DashboardGrid/useElementSize.js";import{DEFAULT_BAR_COLOR as k}from"./types.js";import{resolveBarColors as w,sumValues as N,humanizeLabel as L,withAlpha as S,wrapLabel as C,darken as M}from"./utils.js";var A=function(l){return"number"==typeof l&&Number.isFinite(l)};function z(e){var n,a,r,o=e.x,c=e.y,d=e.payload,u=e.fill,s=e.maxChars,h=e.maxLines,v=e.axis,m=e.formatTick,f=m?m(String(null!==(n=null==d?void 0:d.value)&&void 0!==n?n:""),null!==(a=null==d?void 0:d.index)&&void 0!==a?a:0):String(null!==(r=null==d?void 0:d.value)&&void 0!==r?r:""),b=C(f,s,h),g="x"===v,p=g?12:-13*(b.length-1)/2+4;return t("text",l({x:o,y:c,fill:u,fontSize:11,textAnchor:g?"middle":"end",className:"ellm-bar-chart__tick"},{children:[i("title",{children:f}),b.map(function(e,t){return i("tspan",l({x:o,dy:0===t?p:13},{children:e}),t)})]}))}function H(C){var H,T,F,j,B,W,G,K,E,O,V,R,D,I,Z,q,J=C.data,P=C.title,Q=C.description,U=C.icon,X=C.headerActions,Y=C.color,$=void 0===Y?k:Y,ll=C.shadeMode,el=void 0===ll?"rank":ll,il=C.yAxisLabel,tl=C.xAxisLabel,nl=C.xAxis,al=C.yAxis,rl=C.tooltip,ol=C.legend,cl=C.config,dl=C.style,ul=C.valueFormatter,sl=C.loading,hl=C.emptyState,vl=C.onBarClick,ml=a(null),fl=ml[0],bl=ml[1],gl=x(),pl=gl[0],yl=gl[1],_l=r(null),xl=r(null),kl=a({start:!1,end:!1}),wl=kl[0],Nl=kl[1],Ll=null!==(H=null==dl?void 0:dl.chartHeight)&&void 0!==H?H:300,Sl=null!==(T=null==dl?void 0:dl.gridColor)&&void 0!==T?T:"#eef0f4",Cl=null!==(F=null==dl?void 0:dl.axisColor)&&void 0!==F?F:"#d7dbe3",Ml=null!==(j=null==dl?void 0:dl.axisLabelColor)&&void 0!==j?j:"#6b7280",Al=null!==(B=null==dl?void 0:dl.tickColor)&&void 0!==B?B:"#9ca3af",zl=null!==(W=null==dl?void 0:dl.fontFamily)&&void 0!==W?W:"Inter, system-ui, -apple-system, sans-serif",Hl="horizontal"===(null==cl?void 0:cl.orientation),Tl=null!==(G=null==cl?void 0:cl.showValueLabels)&&void 0!==G&&G,Fl=!1!==(null==cl?void 0:cl.highlightOnHover),jl=!1!==(null==cl?void 0:cl.animate),Bl=!1!==(null==cl?void 0:cl.showHeader),Wl=null!==(K=null==cl?void 0:cl.sortBy)&&void 0!==K?K:"none",Gl=!1!==(null==cl?void 0:cl.humanizeLabels),Kl=function(l){return Gl?L(l):l},El=l({label:tl},nl),Ol=l({label:il},al),Vl=o(function(){var l=null!=J?J:[];if("none"===Wl)return l;var i="asc"===Wl?1:-1;return e([],l,!0).sort(function(l,e){var t,n;return((null!==(t=l.value)&&void 0!==t?t:-1/0)-(null!==(n=e.value)&&void 0!==n?n:-1/0))*i})},[J,Wl]),Rl=o(function(){return w(Vl,$,el,null==dl?void 0:dl.shadeRange)},[Vl,$,el,null==dl?void 0:dl.shadeRange]),Dl=o(function(){return N(Vl)},[Vl]),Il=o(function(){return Vl.map(function(l,e){return{label:Gl?L(l.label):l.label,value:l.value,__index:e}})},[Vl,Gl]),Zl=o(function(){return Il.map(function(l){return"".concat(l.label,"\0").concat(l.value)}).join("")},[Il]),ql=a(null),Jl=ql[0],Pl=ql[1],Ql=jl&&Jl!==Zl,Ul=o(function(){return Vl.some(function(l){return A(l.value)})},[Vl]),Xl=o(function(){var l=Vl.map(function(l){return l.value}).filter(A);return l.length?Math.max.apply(Math,l):0},[Vl]),Yl=[null!=Ol.min?Ol.min:!1!==Ol.beginAtZero?0:"auto",null!=Ol.max?Ol.max:Xl>0?Math.ceil(1.1*Xl):"auto"],$l=o(function(){return{value:{label:"Value",color:$}}},[$]),le=function(l){var e=Vl[l];return e&&A(e.value)?{datum:e,value:e.value,color:Rl[l],index:l,total:Dl}:null},ee=function(l){if(vl){var e=le(l);e&&vl(e)}},ie=function(l,e){var i=null==ul?void 0:ul(l,e);return"string"==typeof i||"number"==typeof i?String(i):g(l)},te=function(e){var t,n=e.x,a=e.y,r=e.width,o=e.height,c=e.index,d=Vl[c];return d&&A(d.value)?i("text",l({x:Hl?n+r+6:n+r/2,y:Hl?a+o/2+4:a-7,textAnchor:Hl?"start":"middle",className:"ellm-bar-chart__value-label",opacity:Fl&&null!==fl&&fl!==c?null!==(t=null==dl?void 0:dl.dimOpacity)&&void 0!==t?t:.45:1},{children:ie(d.value,d)})):i("g",{})},ne=null!==(E=null==dl?void 0:dl.barRadius)&&void 0!==E?E:6,ae=Hl?[0,ne,ne,0]:[ne,ne,0,0],re={type:"number",hide:!1===Ol.show,domain:Yl,tickLine:!1,axisLine:!1===Ol.hideLine&&{stroke:Cl},tickCount:Ol.tickCount,tick:{fill:Al,fontSize:11},tickFormatter:function(l){return Ol.formatTick?Ol.formatTick(Number(l),0):"number"==typeof l?g(l):String(l)}},oe=null!==(O=Ol.width)&&void 0!==O?O:Ol.label?64:48,ce={top:Tl?24:12,right:Hl&&Tl?48:16,bottom:!Hl&&El.label?24:8,left:0},de=null!==(V=null==dl?void 0:dl.cursorFill)&&void 0!==V?V:S($,.06),ue=null!==(R=null==dl?void 0:dl.rowHeight)&&void 0!==R?R:36,se=Ol.label?56:30,he=Il.length*ue+ce.top+ce.bottom,ve=Hl&&he+se>Ll,me=ve&&!(null==dl?void 0:dl.autoHeight),fe=ve&&(null==dl?void 0:dl.autoHeight)?he+se:Ll,be=El.tickMaxChars?7*El.tickMaxChars:96,ge=null!==(D=null==dl?void 0:dl.columnWidth)&&void 0!==D?D:96,pe=Il.length*ge+ce.left+ce.right,ye=!Hl&&null!=yl&&pe+oe>yl.width,_e=ye&&El.label?El.label:null,xe=El.label&&!_e?64:44,ke=_e?l(l({},ce),{bottom:8}):ce,we=_e?fe-24:fe,Ne=ye?ge:yl&&Il.length?(yl.width-oe-ce.left-ce.right)/Il.length:null,Le=null!==(I=El.tickMaxChars)&&void 0!==I?I:Hl||null==Ne?14:Math.min(24,Math.max(3,Math.floor((Ne-8)/6.2))),Se={dataKey:"label",type:"category",hide:!1===El.show,tickLine:!1,axisLine:!El.hideLine&&{stroke:Cl},tickMargin:8,interval:null!==(Z=El.interval)&&void 0!==Z?Z:0,tick:function(e){var t;return i(z,l({},e,{fill:Al,maxChars:Le,maxLines:null!==(t=El.tickMaxLines)&&void 0!==t?t:2,axis:Hl?"y":"x",formatTick:El.formatTick}))}},Ce=function(){var l,e=null!==(l=_l.current)&&void 0!==l?l:xl.current,i={start:!1,end:!1};if(e){var t=_l.current?[e.scrollLeft,e.scrollWidth,e.clientWidth]:[e.scrollTop,e.scrollHeight,e.clientHeight],n=t[0];i={start:n>1,end:n+t[2]<t[1]-1}}Nl(function(l){return l.start===i.start&&l.end===i.end?l:i})};c(Ce,[ye,me,yl,Il.length,sl]);var Me=Ol.label?{value:Ol.label,position:"insideBottom",offset:-4,fill:Ml,fontSize:12,fontWeight:500}:void 0,Ae=function(){var e,a,r;return t(d,l({accessibilityLayer:!0,data:Il,margin:ke,layout:Hl?"vertical":"horizontal",barCategoryGap:null!==(e=null==dl?void 0:dl.barCategoryGap)&&void 0!==e?e:"28%",onMouseMove:function(l){var e=(null==l?void 0:l.isTooltipActive)?l.activeTooltipIndex:null;bl("number"==typeof e?e:null)},onMouseLeave:function(){return bl(null)}},{children:[i(v,{horizontal:Hl?!!(null==dl?void 0:dl.showVerticalGrid):!1!==(null==dl?void 0:dl.showGrid),vertical:Hl?!1!==(null==dl?void 0:dl.showGrid):!!(null==dl?void 0:dl.showVerticalGrid),stroke:Sl}),t(n,Hl?{children:[i(u,l({},re,{hide:me||re.hide,height:Ol.label?48:void 0,label:Me})),i(s,l({},Se,{width:be}))]}:{children:[i(u,l({},Se,{height:xe,label:El.label&&!_e?{value:El.label,position:"insideBottom",offset:0,fill:Ml,fontSize:12,fontWeight:500}:void 0})),i(s,l({},re,{hide:ye||re.hide,width:oe,label:Ol.label?{value:Ol.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"},fill:Ml,fontSize:12,fontWeight:500}:void 0}))]}),!1!==(null==rl?void 0:rl.enabled)&&i(b,{cursor:{fill:de,radius:6},content:function(e){var t,a,r,o,c=null===(r=null===(a=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t[0])||void 0===a?void 0:a.payload)||void 0===r?void 0:r.__index,d="number"==typeof c?le(c):null;return d?(null==rl?void 0:rl.render)?i(n,{children:rl.render(d)}):i(_,{ctx:d,config:l(l({},rl),{formatHeading:null!==(o=null==rl?void 0:rl.formatHeading)&&void 0!==o?o:Kl}),valueFormatter:ul}):null}}),i(h,l({dataKey:"value",radius:ae,maxBarSize:null!==(r=null!==(a=null==dl?void 0:dl.barSize)&&void 0!==a?a:null==dl?void 0:dl.maxBarSize)&&void 0!==r?r:56,barSize:null==dl?void 0:dl.barSize,isAnimationActive:Ql,animationDuration:600,onAnimationEnd:function(){return Pl(Zl)},onClick:function(l,e){return ee(e)},onMouseEnter:function(l,e){return bl(e)},className:vl?"ellm-bar-chart__bar--clickable":void 0,label:Tl?te:void 0},{children:Il.map(function(l,e){var t,n=fl===e,a=Fl&&null!==fl&&!n;return i(m,{className:"ellm-bar-chart__bar",fill:Rl[e],fillOpacity:a?null!==(t=null==dl?void 0:dl.dimOpacity)&&void 0!==t?t:.45:1,stroke:n?M(Rl[e],.22):void 0,strokeWidth:n?1.5:0},"".concat(l.label,"-").concat(e))})}))]}))},ze=P||Q||U||X;return t("div",l({className:"ellm-bar-chart".concat((null==dl?void 0:dl.className)?" ".concat(dl.className):""),style:null==dl?void 0:dl.container},{children:[Bl&&ze&&t("div",l({className:"ellm-bar-chart__header"},{children:[t("div",l({className:"ellm-bar-chart__heading"},{children:[U&&i("span",l({className:"ellm-bar-chart__icon"},{children:U})),t("div",{children:[P&&i("div",l({className:"ellm-bar-chart__title"},{children:P})),Q&&i("div",l({className:"ellm-bar-chart__description"},{children:Q}))]})]})),X&&i("div",l({className:"ellm-bar-chart__actions"},{children:X}))]})),i("div",l({ref:pl,className:"ellm-bar-chart__body"},{children:sl?i(y,{height:Ll,bars:Math.max(Vl.length||6,3)}):Ul?t(n,{children:[me?t(n,{children:[i("div",l({className:"ellm-bar-chart__scroll-frame ellm-bar-chart__scroll-frame--y".concat(wl.start?" is-fade-start":"").concat(wl.end?" is-fade-end":"")},{children:i("div",l({ref:xl,className:"ellm-bar-chart__scroll",style:{maxHeight:Ll-se},onScroll:Ce},{children:i(f,l({config:$l,style:{height:he,fontFamily:zl}},{children:Ae()}))}))})),!1!==Ol.show&&i("div",l({className:"ellm-bar-chart__pinned-axis"},{children:i(f,l({config:$l,style:{height:se,fontFamily:zl}},{children:t(d,l({data:Il,layout:"vertical",margin:{top:0,right:ce.right,bottom:0,left:ce.left}},{children:[i(u,l({},re,{height:se,label:Me&&l(l({},Me),{offset:8})})),i(s,{dataKey:"label",type:"category",width:be,tick:!1,tickLine:!1,axisLine:!1}),i(h,{dataKey:"value",fill:"transparent",isAnimationActive:!1})]}))}))}))]}):ye?t(n,{children:[i("div",l({className:"ellm-bar-chart__scroll-frame ellm-bar-chart__scroll-frame--x".concat(wl.start?" is-fade-start":"").concat(wl.end?" is-fade-end":""),style:{"--ellm-bar-pinned":!1!==Ol.show?"".concat(oe,"px"):"0px"}},{children:t("div",l({ref:_l,className:"ellm-bar-chart__scroll-x",onScroll:Ce},{children:[!1!==Ol.show&&i("div",l({className:"ellm-bar-chart__pinned-scale",style:{width:oe}},{children:i(f,l({config:$l,style:{height:we,fontFamily:zl}},{children:t(d,l({data:Il,margin:{top:ke.top,right:0,bottom:ke.bottom,left:ke.left}},{children:[i(u,{dataKey:"label",type:"category",height:xe,tick:!1,tickLine:!1,axisLine:!1}),i(s,l({},re,{width:oe,label:Ol.label?{value:Ol.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"},fill:Ml,fontSize:12,fontWeight:500}:void 0})),i(h,{dataKey:"value",fill:"transparent",isAnimationActive:!1})]}))}))})),i("div",l({style:{width:pe,flexShrink:0}},{children:i(f,l({config:$l,style:{height:we,fontFamily:zl}},{children:Ae()}))}))]}))})),_e&&i("div",l({className:"ellm-bar-chart__axis-title",style:{height:24,paddingLeft:!1!==Ol.show?oe:0,color:Ml}},{children:_e}))]}):i(f,l({config:$l,style:{height:fe,fontFamily:zl}},{children:Ae()})),(null==ol?void 0:ol.show)&&i("div",l({className:"ellm-bar-chart__legend ellm-bar-chart__legend--".concat(null!==(q=ol.align)&&void 0!==q?q:"center")},{children:Vl.map(function(e,n){return t("button",l({type:"button",className:"ellm-bar-chart__legend-item".concat(fl===n?" ellm-bar-chart__legend-item--active":null!==fl?" ellm-bar-chart__legend-item--off":""),onMouseEnter:function(){return bl(n)},onMouseLeave:function(){return bl(null)},onFocus:function(){return bl(n)},onBlur:function(){return bl(null)},onClick:function(){!function(l){var e,i="undefined"!=typeof window&&(null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth",t=_l.current;if(ye&&t){var n=!1!==Ol.show?oe:0,a=n+ce.left+l*ge,r=t.scrollLeft+n,o=t.scrollLeft+t.clientWidth;if(a<r||a+ge>o){var c=t.clientWidth-n;t.scrollTo({left:a-n-(c-ge)/2,behavior:i})}}var d=xl.current;me&&d&&((a=ce.top+l*ue)<d.scrollTop||a+ue>d.scrollTop+d.clientHeight)&&d.scrollTo({top:a-(d.clientHeight-ue)/2,behavior:i})}(n),ee(n)}},{children:[i("span",{className:"ellm-bar-chart__legend-swatch",style:{background:Rl[n]}}),i("span",l({className:"ellm-bar-chart__legend-label"},{children:Kl(e.label)})),A(e.value)&&i("span",l({className:"ellm-bar-chart__legend-value"},{children:ie(e.value,e)}))]}),"".concat(e.label,"-").concat(n))})}))]}):i("div",l({className:"ellm-bar-chart__empty"},{children:null!=hl?hl:i(p,{})}))}))]}))}export{H as default};
|
|
2
2
|
//# sourceMappingURL=BarChart.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DEFAULT_BAR_COLOR as
|
|
1
|
+
import{DEFAULT_BAR_COLOR as r}from"./types.js";var n=function(r,n,t){return Math.min(t,Math.max(n,r))};function t(r){var n=r.trim();if(n.startsWith("#")){var t=n.slice(1);if(3===t.length||4===t.length){var e=t.slice(0,3).split(""),a=e[0],u=e[1],i=e[2];return{r:parseInt(a+a,16),g:parseInt(u+u,16),b:parseInt(i+i,16)}}return 6===t.length||8===t.length?{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}:null}var l=n.match(/^rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/i);return l?{r:Number(l[1]),g:Number(l[2]),b:Number(l[3])}:null}function e(r,e){var a=t(r);if(!a)return r;var u=n(e,0,1),i=function(r){return Math.round(r+(255-r)*(1-u))};return"rgb(".concat(i(a.r),", ").concat(i(a.g),", ").concat(i(a.b),")")}function a(r,e){void 0===e&&(e=.18);var a=t(r);if(!a)return r;var u=n(1-e,0,1);return"rgb(".concat(Math.round(a.r*u),", ").concat(Math.round(a.g*u),", ").concat(Math.round(a.b*u),")")}function u(r,e){var a=t(r);return a?"rgba(".concat(a.r,", ").concat(a.g,", ").concat(a.b,", ").concat(n(e,0,1),")"):r}function i(n,t,a,u){void 0===t&&(t=r),void 0===a&&(a="rank"),void 0===u&&(u=[.22,1]);var i=u[0],l=u[1];if("none"===a)return n.map(function(r){var n;return null!==(n=r.color)&&void 0!==n?n:t});var o=n.map(function(r){return"number"==typeof r.value&&Number.isFinite(r.value)?r.value:null}),c=o.filter(function(r){return null!=r});if(0===c.length)return n.map(function(r){var n;return null!==(n=r.color)&&void 0!==n?n:t});var v,f=Math.min.apply(Math,c),s=Math.max.apply(Math,c);if("value"===a){var p=s-f;v=o.map(function(r){return null==r?i:0===p?l:i+(r-f)/p*(l-i)})}else{var h=Array.from(new Set(c)).sort(function(r,n){return r-n}),m=Math.max(h.length-1,1);v=o.map(function(r){if(null==r)return i;var n=h.indexOf(r);return 1===h.length?l:i+n/m*(l-i)})}return n.map(function(r,n){var a;return null!==(a=r.color)&&void 0!==a?a:e(t,v[n])})}function l(r){return r.reduce(function(r,n){return"number"==typeof n.value&&Number.isFinite(n.value)?r+n.value:r},0)}function o(r){var n=String(null!=r?r:"");if(!n.includes("_")||/\s/.test(n))return n;var t=n.replace(/_+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):n}function c(r,n,t){var e=String(r).split(/\s+/).filter(Boolean).flatMap(function(r){var t;return r.length>n&&null!==(t=r.match(new RegExp(".{1,".concat(n,"}"),"g")))&&void 0!==t?t:[r]});if(0===e.length)return[""];var a=[],u="";if(e.forEach(function(r){var t=u?"".concat(u," ").concat(r):r;t.length<=n||!u?u=t:(a.push(u),u=r)}),u&&a.push(u),a.length<=t)return a;var i=a.slice(0,t);return i[t-1]="".concat(i[t-1].slice(0,Math.max(n-1,1)),"…"),i}function v(r,n){if(!(null==r?void 0:r.length))return[];var t=n.labelKey,e=n.valueKey,a=n.colorKey;return r.map(function(r){var n,u=r[e],i="string"==typeof u?Number(u):u;return{label:String(null!==(n=r[t])&&void 0!==n?n:""),value:"number"==typeof i&&Number.isFinite(i)?i:null,color:a?r[a]:void 0,meta:r}})}export{a as darken,o as humanizeLabel,t as parseColor,i as resolveBarColors,l as sumValues,v as toBarChartData,u as withAlpha,e as withIntensity,c as wrapLabel};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{__spreadArray as e,__assign as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useState as r,useEffect as a}from"react";import{Button as o}from"primereact/button";import{RefreshCw as u,CalendarClock as s,Bell as c,ListFilter as d}from"lucide-react";import v,{formatRangeLabel as f}from"../DatePickers/CustomRangePicker.js";import{DEFAULT_DATE_PRESETS as m}from"./datePreset.js";var h=["today","7days","30days","thisMonth","last3Months"],p=function(p){var g,b,C,D=p.presets,k=void 0===D?m:D,q=p.filterCount,x=void 0===q?0:q,N=p.liveDuration,y=void 0===N?3e4:N,w=p.onDateChange,P=p.onRefresh,R=p.isRefreshLoading,B=p.onFilterClick,S=p.onSubscriptionsClick,j=p.onAlertsClick,z=p.showFilterButton,A=void 0===z||z,E=p.showSubscriptionButton,F=void 0!==E&&E,L=p.showAlertsBtn,M=void 0!==L&&L,I=p.showLiveButton,T=void 0===I||I,W=p.showFilterCount,_=void 0!==W&&W,Q=p.datePickerProps,G=p.initialStartDate,H=p.initialEndDate;p.defaultPresets;var J=p.pollingEnabled,K=void 0!==J&&J,O=p.selectedPreset,U=void 0===O?"today":O,V=p.handlePresetChange,X=r(!0),Y=X[0],Z=X[1],$=r(G||null),ee=$[0],te=$[1],ne=r(H||null),ie=ne[0],le=ne[1];a(function(){te(G||null),le(H||null)},[G,H]),a(function(){var e=setTimeout(function(){Z(!1)},y);return function(){return clearTimeout(e)}},[U,y]),a(function(){if("custom"!==U){var e=k.find(function(e){return e.value===U});if(e&&e.getRange){var t=e.getRange();null==w||w({preset:U,startDate:t.startDate,endDate:t.endDate})}}},[U,k,w]);var re=function(t){if(!t||0===t.length)return t;var n=t.find(function(e){return"custom"===e.value});if(!n)return t;var i=t.filter(function(e){return"custom"!==e.value});return e(e([],i,!0),[n],!1)}(k),ae=re.some(function(e){return"custom"===e.value}),oe=re.filter(function(e){return"custom"!==e.value}),ue=function(){if(oe.length<=5)return oe;var t=oe.filter(function(e){return h.includes(e.value)}),n=oe.filter(function(e){return!h.includes(e.value)}),i=new Set(e(e([],t,!0),n,!0).slice(0,5).map(function(e){return e.value}));return oe.filter(function(e){return i.has(e.value)})}(),se=ue.length<oe.length,ce=oe.find(function(e){return e.value===U&&!ue.some(function(t){return t.value===e.value})}),de="custom"===U&&ee&&ie?f(ee,ie):null!==(g=null==ce?void 0:ce.label)&&void 0!==g?g:ae?"Custom range":"More ranges";return n("div",t({className:"q-date-filter"},{children:i("div",t({className:"q-date-filter-toolbar"},{children:[i("div",t({style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}},{children:[i("div",t({className:"q-preset-container"},{children:[null==ue?void 0:ue.map(function(e){return n("button",t({className:"q-preset-btn ".concat(U===(null==e?void 0:e.value)?"active":""),onClick:function(){return null==V?void 0:V(null==e?void 0:e.value)}},{children:null==e?void 0:e.label}),null==e?void 0:e.value)}),(ae||se)&&n(v,{label:de,active:"custom"===U||!!ce,value:{start:ee,end:ie},quickRanges:se?oe:[],selectedPreset:U,allowCustom:ae,minDate:null===(b=null==Q?void 0:Q.from)||void 0===b?void 0:b.minDate,maxDate:null===(C=null==Q?void 0:Q.to)||void 0===C?void 0:C.maxDate,onQuickRangeSelect:function(e){return null==V?void 0:V(e)},onApply:function(e,t){te(e),le(t),null==V||V("custom"),null==w||w({preset:"custom",startDate:e,endDate:t})}})]})),T&&i(l,Y&&!K?{children:[n("div",{style:{width:"1px",height:"31px",backgroundColor:"#CBD5E1"}}),i("div",t({className:"q-live-chip"},{children:[n("span",{className:"q-live-dot"}),"Live Data"]}))]}:{children:[n("div",{className:"q-date-separator",style:{width:"1px",height:"31px",backgroundColor:"#CBD5E1"}}),i(o,t({className:"q-refresh-btn",onClick:P},{children:[n(u,{size:16,strokeWidth:2.5,className:R?"q-spin":""}),n("span",{children:R?"Refreshing...":"Refresh"})]}))]})]})),i("div",t({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[F&&i("button",t({className:"q-subscription-btn",onClick:S},{children:[n(s,{size:12.5}),"Subscriptions"]})),M&&i("button",t({className:"q-filter-btn",onClick:j},{children:[n(c,{size:14}),"Alerts"]})),A&&i("button",t({className:"q-filter-btn",onClick:B},{children:[n(d,{size:14}),"Filters",_&&x>0&&n("span",t({className:"q-filter-badge"},{children:x}))]}))]}))]}))}))};export{p as default};
|
|
2
2
|
//# sourceMappingURL=DashboardDateFilter.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as e,__assign as r,__awaiter as i,__generator as s}from"../../../../_virtual/_tslib.js";import{jsx as a,jsxs as n}from"react/jsx-runtime";import{useState as t,useEffect as l,useMemo as o}from"react";import{X as u,Check as c,Info as d}from"lucide-react";import v from"../../DropDowns/CustomMultiSelect.js";import b from"../../DropDowns/CustomSingleSelect.js";var m=function(m){var p=m.isOpen,f=m.onClose,h=m.scopeFields,g=void 0===h?[]:h,y=m.subscriptionTypes,w=void 0===y?[{label:"Periodic",value:"Periodic",triggers:[{label:"Daily",value:"daily",info:"Email is sent at 8:00 AM on the next day after the selected period."},{label:"Weekly",value:"weekly",info:"Email is sent at 8:00 AM on the Monday after the selected period."},{label:"Monthly",value:"monthly",info:"Email is sent at 8:00 AM on the Monday after the selected period."}]},{label:"Event-based",value:"Event-based"}]:y,N=m.onSearchSubscribers,q=m.onSave,C=m.editData,S=m.existingSubscriptions,L=void 0===S?[]:S,x=m.duplicateNameErrorMessage,k=void 0===x?"A subscription with this name already exists.":x,A=m.nameMaxLength,M=t(1),_=M[0],E=M[1],T=t(""),j=T[0],z=T[1],D=t({}),O=D[0],P=D[1],B=t("Periodic"),W=B[0],U=B[1],F=t(""),R=F[0],H=F[1],G=t([]),I=G[0],J=G[1],K=t(""),Q=K[0],V=K[1],X=t(!1),Y=X[0],Z=X[1],$=t([]),ee=$[0],re=$[1],ie=t(!1),se=ie[0],ae=ie[1];l(function(){var e,r,i;if(p&&C){z(C.name||"");var s={},a=(null==C?void 0:C.reportScope)||{};Object.keys(a).forEach(function(e){var r=a[e],i=g.find(function(r){return r.id.toLowerCase()===e.toLowerCase()||r.label.toLowerCase()===e.toLowerCase()});"string"==typeof r&&"multiSelect"===(null==i?void 0:i.scopeType)&&r.includes(",")&&(r=r.split(",").map(function(e){return e.trim()}));var n=r;if(i&&i.options){var t=function(e){var r=String(e).trim().toLowerCase(),s=i.options.find(function(e){return String(e.value).toLowerCase()===r||String(e.label).toLowerCase()===r});return s?s.value:e};Array.isArray(r)?n=r.map(t):r&&(n=t(r))}var l=i?i.id:e;"multiSelect"===(null==i?void 0:i.scopeType)?s[l]=Array.isArray(n)?n:n?[n]:[]:"singleSelect"===(null==i?void 0:i.scopeType)?s[l]=Array.isArray(n)?n.length>0?n[0]:"":n:s[l]=n}),E(1),P(s);var n=C.type||(w.length>0?w[0].value:"Periodic");U(n);var t=(null===(e=w.find(function(e){return e.value===n}))||void 0===e?void 0:e.triggers)||[],l=String(C.trigger||""),o=t.find(function(e){return e.value.toLowerCase()===l.toLowerCase()||e.label.toLowerCase()===l.toLowerCase()});H(o?o.value:l.toLowerCase());var u=Array.isArray(null===(r=null==C?void 0:C.raw)||void 0===r?void 0:r.subscribers)?C.raw.subscribers.map(function(e){var r=e.user_id,i=e.email;return{id:r,label:e.name,value:i}}):(null===(i=null==C?void 0:C.raw)||void 0===i?void 0:i.subscribers)?[{id:C.raw.subscribers.user_id,label:"string"==typeof C.raw.subscribers?C.raw.subscribers:C.raw.subscribers.name||C.raw.subscribers.email||C.raw.subscribers,value:"string"==typeof C.raw.subscribers?C.raw.subscribers:C.raw.subscribers.email||C.raw.subscribers.value||C.raw.subscribers}]:[];J(u)}else p&&!C&&(E(1),z(""),P({}),U(w.length>0?w[0].value:"Periodic"),H(""),J([]),V(""),re([]))},[p,C,w]);var ne=o(function(){var r=e([],g,!0);return(null==C?void 0:C.reportScope)&&Object.keys(C.reportScope).forEach(function(e){var i=r.find(function(r){var i,s;return(null===(i=r.id)||void 0===i?void 0:i.toLowerCase())===e.toLowerCase()||(null===(s=r.label)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()});if(!i){var s=C.reportScope[e],a=Array.isArray(s);r.push({id:e,label:e.charAt(0).toUpperCase()+e.slice(1),options:a?s.map(function(e){return{label:e,value:e}}):[{label:s,value:s}],scopeType:a?"multiSelect":"singleSelect"})}}),r},[g,C]),te=o(function(){var e=j.trim().toLowerCase();return!!e&&L.some(function(r){var i;return r.id!==(null==C?void 0:C.id)&&(null===(i=r.name)||void 0===i?void 0:i.trim().toLowerCase())===e})},[j,L,C]),le=o(function(){var e,r=null===(e=w.find(function(e){return e.value===W}))||void 0===e?void 0:e.triggers;return!(!r||0===r.length)&&!r.some(function(e){return e.value===R})},[w,W,R]);if(!p)return null;var oe=function(e,r){if(!e)return r?[]:"";var i=Object.keys(O).find(function(r){return r.toLowerCase()===e.toLowerCase()});if(i&&void 0!==O[i]){var s=O[i];return r?Array.isArray(s)?s:s?[s]:[]:Array.isArray(s)?s.length>0?s[0]:"":s}return r?[]:""};return a("div",r({className:"q-subs-modal-overlay"},{children:n("div",r({className:"q-subs-modal"},{children:[n("div",r({className:"q-subs-modal-header"},{children:[a("div",r({className:"q-subs-modal-title"},{children:C?"Edit Subscription":"Create Subscription"})),a("button",r({className:"q-subs-modal-close",onClick:f},{children:a(u,{size:14})}))]})),n("div",r({className:"q-subs-stepper"},{children:[n("div",r({className:"q-subs-step ".concat(_>=1?_>1?"completed":"active":"")},{children:[a("div",r({className:"q-subs-step-num"},{children:_>1?a(c,{size:14}):"1"})),"Name & scope"]})),a("div",{className:"q-subs-step-line ".concat(_>1?"completed":"")}),n("div",r({className:"q-subs-step ".concat(_>=2?_>2?"completed":"active":"")},{children:[a("div",r({className:"q-subs-step-num"},{children:_>2?a(c,{size:14}):"2"})),"Type"]})),a("div",{className:"q-subs-step-line ".concat(_>2?"completed":"")}),n("div",r({className:"q-subs-step ".concat(_>=3?"active":"")},{children:[a("div",r({className:"q-subs-step-num"},{children:"3"})),"Subscribers"]}))]})),n("div",r({className:"q-subs-modal-body"},{children:[1===_&&n("div",{children:[n("div",r({className:"q-subs-form-group"},{children:[n("label",r({className:"q-subs-form-label"},{children:["Subscription name ",a("span",r({className:"req"},{children:"*"}))]})),a("input",{type:"text",className:"q-subs-input",placeholder:"e.g. Midwest Music Weekly Report",value:j,onChange:function(e){return z(e.target.value)},maxLength:A}),te&&a("div",r({className:"q-subs-error-text"},{children:k}))]})),a("div",{style:{height:"1px",background:"#E2E8F0",margin:"0 0 24px 0"}}),a("label",r({className:"q-subs-form-label"},{children:"Report scope"})),a("div",r({className:"q-subs-grid-2"},{children:ne.map(function(e){var i,s,t,l;return n("div",{children:[a("label",r({className:"q-subs-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:e.label})),"multiSelect"===e.scopeType?a(v,{options:(null===(i=e.options)||void 0===i?void 0:i.map(function(e){var r="string"==typeof e?e:e.value||e.id||e;return{label:"string"==typeof e?e:e.label||e.name||r,value:r}}))||[],value:oe(e.id,!0)||[],onChange:function(i){var s,a=Object.keys(O).find(function(r){return r.toLowerCase()===(e.id||"").toLowerCase()});P(r(r({},O),((s={})[a||e.id]=i,s)))},placeholder:"Select ".concat((null===(s=e.label)||void 0===s?void 0:s.toLowerCase())||"")}):a(b,{options:(null===(t=e.options)||void 0===t?void 0:t.map(function(e){var r="string"==typeof e?e:e.value||e.id||e;return{label:"string"==typeof e?e:e.label||e.name||r,value:r}}))||[],value:oe(e.id,!1)||"",onChange:function(i){var s,a=Object.keys(O).find(function(r){return r.toLowerCase()===(e.id||"").toLowerCase()});P(r(r({},O),((s={})[a||e.id]=i,s)))},placeholder:"Select ".concat((null===(l=e.label)||void 0===l?void 0:l.toLowerCase())||"")})]},e.id)})}))]}),2===_&&n("div",{children:[n("div",r({className:"q-subs-form-group"},{children:[a("label",r({className:"q-subs-form-label",style:{marginBottom:"4px"}},{children:"Subscription Type"})),a("div",r({className:"q-subs-form-desc"},{children:"Choose when you want to receive this report."})),a("div",r({className:"q-subs-radio-group"},{children:w.map(function(e){return n("label",r({className:"q-subs-radio-label"},{children:[a("input",{type:"radio",className:"q-subs-radio",checked:W===e.value,onChange:function(){return U(e.value)}})," ",e.label]}),e.value)})}))]})),function(){var e=w.find(function(e){return e.value===W}),i=null==e?void 0:e.triggers;if(i&&i.length>0){var s=i.find(function(e){return e.value===R});return n("div",r({className:"q-subs-form-group"},{children:[n("label",r({className:"q-subs-form-label",style:{marginBottom:"4px"}},{children:["Trigger",a("span",r({className:"req"},{children:"*"}))]})),a("div",r({className:"q-subs-form-desc"},{children:"How often should this report be sent?"})),a("div",r({style:{width:"60%"}},{children:a(b,{options:i.map(function(e){return{label:e.label,value:e.value}}),value:R,onChange:function(e){return H(e)},placeholder:"Select trigger"})})),s&&s.info&&n("div",r({className:"q-subs-info"},{children:[a(d,{size:12,strokeWidth:3}),s.info]}))]}))}return null}()]}),3===_&&a("div",{children:n("div",r({className:"q-subs-form-group"},{children:[a("label",r({className:"q-subs-form-label",style:{marginBottom:"4px"}},{children:"Subscribers"})),a("div",r({className:"q-subs-form-desc"},{children:"Who should receive this report?"})),n("div",r({className:"q-subs-search-box"},{children:[a("input",{type:"text",className:"q-subs-input",placeholder:"Type name or email...",value:Q,onChange:function(e){return i(void 0,void 0,void 0,function(){var r,i;return s(this,function(s){switch(s.label){case 0:if(r=e.target.value,V(r),!r)return re([]),[2];if(!N)return[3,5];ae(!0),s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,N(r)];case 2:return i=s.sent(),re(i||[]),[3,5];case 3:return s.sent(),re([]),[3,5];case 4:return ae(!1),[7];case 5:return[2]}})})}}),se&&a("div",r({style:{position:"absolute",right:"12px",top:"10px",fontSize:"12px",color:"#94a3b8"}},{children:"Loading..."})),ee.length>0&&Q&&a("div",r({className:"q-subs-search-results"},{children:ee.map(function(i){return a("div",r({className:"q-subs-search-item",onClick:function(){return function(r){I.find(function(e){return e.value===r.value})||J(e(e([],I,!0),[r],!1)),V(""),re([])}(i)}},{children:i.label}),i.value)})}))]})),I.length>0&&a("div",r({className:"q-subs-chips"},{children:I.map(function(e){return n("div",r({className:"q-subs-chip"},{children:[e.label,a("div",r({className:"q-subs-chip-remove",onClick:function(){return r=e.value,void J(I.filter(function(e){return e.value!==r}));var r}},{children:a(u,{size:12,strokeWidth:3})}))]}),e.value)})}))]}))})]})),n("div",r({className:"q-subs-modal-footer"},{children:[a("button",1===_?r({className:"q-subs-btn-cancel",onClick:f},{children:"Cancel"}):r({className:"q-subs-btn-cancel",onClick:function(){return E(function(e){return Math.max(e-1,1)})}},{children:"Back"})),_<3?n("button",r({className:"q-subs-btn-primary",onClick:function(){return E(function(e){return Math.min(e+1,3)})},disabled:1===_&&(!j.trim()||te)||2===_&&le},{children:["Next ",a("span",r({style:{marginLeft:"4px"}},{children:"→"}))]})):a("button",r({className:"q-subs-btn-primary",onClick:function(){return i(void 0,void 0,void 0,function(){var e,r,i,a,n;return s(this,function(s){switch(s.label){case 0:return Z(!0),e={name:j,scope:O,subscription_type:W.toLowerCase(),trigger_frequency:(null===(n=null===(a=w.find(function(e){return e.value===W}))||void 0===a?void 0:a.triggers)||void 0===n?void 0:n.length)?R:"",trigger_event:W,subscriber_emails:I.map(function(e){return e.value}),subscriber_details:I.map(function(e){return{user_name:e.label,user_email:e.value,user_id:e.id}})},r=!1,q?[4,q(e,!!(null==C?void 0:C.id))]:[3,2];case 1:return i=s.sent(),r=!1!==i,[3,3];case 2:r=!0,s.label=3;case 3:return Z(!1),r&&(f(),E(1),z(""),P({}),U("Periodic"),H(""),J([]),V("")),[2]}})})},disabled:Y||0===I.length},{children:Y?C?"Updating...":"Creating...":C?"Update Subscription":"Create Subscription"}))]}))]}))}))};export{m as default};
|
|
1
|
+
import{__spreadArray as e,__assign as r,__awaiter as i,__generator as s}from"../../../../_virtual/_tslib.js";import{jsx as a,jsxs as n}from"react/jsx-runtime";import{useState as l,useEffect as t,useMemo as o}from"react";import{X as u,Check as c,Info as d}from"lucide-react";import v from"../../DropDowns/CustomMultiSelect.js";import b from"../../DropDowns/CustomSingleSelect.js";var m=function(m){var p=m.isOpen,f=m.onClose,h=m.scopeFields,g=void 0===h?[]:h,y=m.subscriptionTypes,w=void 0===y?[{label:"Periodic",value:"Periodic",triggers:[{label:"Daily",value:"daily",info:"Email is sent at 8:00 AM on the next day after the selected period."},{label:"Weekly",value:"weekly",info:"Email is sent at 8:00 AM on the Monday after the selected period."},{label:"Monthly",value:"monthly",info:"Email is sent at 8:00 AM on the Monday after the selected period."}]},{label:"Event-based",value:"Event-based"}]:y,N=m.onSearchSubscribers,q=m.currentUser,C=m.onSave,S=m.editData,L=m.existingSubscriptions,x=void 0===L?[]:L,k=m.duplicateNameErrorMessage,A=void 0===k?"A subscription with this name already exists.":k,M=m.nameMaxLength,_=l(1),E=_[0],T=_[1],j=l(""),z=j[0],D=j[1],O=l({}),P=O[0],B=O[1],W=l("Periodic"),U=W[0],F=W[1],R=l(""),H=R[0],G=R[1],I=l([]),J=I[0],K=I[1],Q=l(""),V=Q[0],X=Q[1],Y=l(!1),Z=Y[0],$=Y[1],ee=l([]),re=ee[0],ie=ee[1],se=l(!1),ae=se[0],ne=se[1];t(function(){var e,r,i;if(p&&S){D(S.name||"");var s={},a=(null==S?void 0:S.reportScope)||{};Object.keys(a).forEach(function(e){var r=a[e],i=g.find(function(r){return r.id.toLowerCase()===e.toLowerCase()||r.label.toLowerCase()===e.toLowerCase()});"string"==typeof r&&"multiSelect"===(null==i?void 0:i.scopeType)&&r.includes(",")&&(r=r.split(",").map(function(e){return e.trim()}));var n=r;if(i&&i.options){var l=function(e){var r=String(e).trim().toLowerCase(),s=i.options.find(function(e){return String(e.value).toLowerCase()===r||String(e.label).toLowerCase()===r});return s?s.value:e};Array.isArray(r)?n=r.map(l):r&&(n=l(r))}var t=i?i.id:e;"multiSelect"===(null==i?void 0:i.scopeType)?s[t]=Array.isArray(n)?n:n?[n]:[]:"singleSelect"===(null==i?void 0:i.scopeType)?s[t]=Array.isArray(n)?n.length>0?n[0]:"":n:s[t]=n}),T(1),B(s);var n=S.type||(w.length>0?w[0].value:"Periodic");F(n);var l=(null===(e=w.find(function(e){return e.value===n}))||void 0===e?void 0:e.triggers)||[],t=String(S.trigger||""),o=l.find(function(e){return e.value.toLowerCase()===t.toLowerCase()||e.label.toLowerCase()===t.toLowerCase()});G(o?o.value:t.toLowerCase());var u=Array.isArray(null===(r=null==S?void 0:S.raw)||void 0===r?void 0:r.subscribers)?S.raw.subscribers.map(function(e){var r=e.user_id,i=e.email;return{id:r,label:e.name,value:i}}):(null===(i=null==S?void 0:S.raw)||void 0===i?void 0:i.subscribers)?[{id:S.raw.subscribers.user_id,label:"string"==typeof S.raw.subscribers?S.raw.subscribers:S.raw.subscribers.name||S.raw.subscribers.email||S.raw.subscribers,value:"string"==typeof S.raw.subscribers?S.raw.subscribers:S.raw.subscribers.email||S.raw.subscribers.value||S.raw.subscribers}]:[];K(u)}else p&&!S&&(T(1),D(""),B({}),F(w.length>0?w[0].value:"Periodic"),G(""),K((null==q?void 0:q.value)?[q]:[]),X(""),ie([]))},[p,S,w,null==q?void 0:q.value]);var le=o(function(){var r=e([],g,!0);return(null==S?void 0:S.reportScope)&&Object.keys(S.reportScope).forEach(function(e){var i=r.find(function(r){var i,s;return(null===(i=r.id)||void 0===i?void 0:i.toLowerCase())===e.toLowerCase()||(null===(s=r.label)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()});if(!i){var s=S.reportScope[e],a=Array.isArray(s);r.push({id:e,label:e.charAt(0).toUpperCase()+e.slice(1),options:a?s.map(function(e){return{label:e,value:e}}):[{label:s,value:s}],scopeType:a?"multiSelect":"singleSelect"})}}),r},[g,S]),te=o(function(){var e=z.trim().toLowerCase();return!!e&&x.some(function(r){var i;return r.id!==(null==S?void 0:S.id)&&(null===(i=r.name)||void 0===i?void 0:i.trim().toLowerCase())===e})},[z,x,S]),oe=o(function(){var e,r=null===(e=w.find(function(e){return e.value===U}))||void 0===e?void 0:e.triggers;return!(!r||0===r.length)&&!r.some(function(e){return e.value===H})},[w,U,H]);if(!p)return null;var ue=function(e,r){if(!e)return r?[]:"";var i=Object.keys(P).find(function(r){return r.toLowerCase()===e.toLowerCase()});if(i&&void 0!==P[i]){var s=P[i];return r?Array.isArray(s)?s:s?[s]:[]:Array.isArray(s)?s.length>0?s[0]:"":s}return r?[]:""};return a("div",r({className:"q-subs-modal-overlay"},{children:n("div",r({className:"q-subs-modal"},{children:[n("div",r({className:"q-subs-modal-header"},{children:[a("div",r({className:"q-subs-modal-title"},{children:S?"Edit Subscription":"Create Subscription"})),a("button",r({className:"q-subs-modal-close",onClick:f},{children:a(u,{size:14})}))]})),n("div",r({className:"q-subs-stepper"},{children:[n("div",r({className:"q-subs-step ".concat(E>=1?E>1?"completed":"active":"")},{children:[a("div",r({className:"q-subs-step-num"},{children:E>1?a(c,{size:14}):"1"})),"Name & scope"]})),a("div",{className:"q-subs-step-line ".concat(E>1?"completed":"")}),n("div",r({className:"q-subs-step ".concat(E>=2?E>2?"completed":"active":"")},{children:[a("div",r({className:"q-subs-step-num"},{children:E>2?a(c,{size:14}):"2"})),"Type"]})),a("div",{className:"q-subs-step-line ".concat(E>2?"completed":"")}),n("div",r({className:"q-subs-step ".concat(E>=3?"active":"")},{children:[a("div",r({className:"q-subs-step-num"},{children:"3"})),"Subscribers"]}))]})),n("div",r({className:"q-subs-modal-body"},{children:[1===E&&n("div",{children:[n("div",r({className:"q-subs-form-group"},{children:[n("label",r({className:"q-subs-form-label"},{children:["Subscription name ",a("span",r({className:"req"},{children:"*"}))]})),a("input",{type:"text",className:"q-subs-input",placeholder:"e.g. Midwest Music Weekly Report",value:z,onChange:function(e){return D(e.target.value)},maxLength:M}),te&&a("div",r({className:"q-subs-error-text"},{children:A}))]})),a("div",{style:{height:"1px",background:"#E2E8F0",margin:"0 0 24px 0"}}),a("label",r({className:"q-subs-form-label"},{children:"Report scope"})),a("div",r({className:"q-subs-grid-2"},{children:le.map(function(e){var i,s,l,t;return n("div",{children:[a("label",r({className:"q-subs-form-desc",style:{display:"block",marginBottom:"4px",color:"#475569"}},{children:e.label})),"multiSelect"===e.scopeType?a(v,{options:(null===(i=e.options)||void 0===i?void 0:i.map(function(e){var r="string"==typeof e?e:e.value||e.id||e;return{label:"string"==typeof e?e:e.label||e.name||r,value:r}}))||[],value:ue(e.id,!0)||[],onChange:function(i){var s,a=Object.keys(P).find(function(r){return r.toLowerCase()===(e.id||"").toLowerCase()});B(r(r({},P),((s={})[a||e.id]=i,s)))},placeholder:"Select ".concat((null===(s=e.label)||void 0===s?void 0:s.toLowerCase())||"")}):a(b,{options:(null===(l=e.options)||void 0===l?void 0:l.map(function(e){var r="string"==typeof e?e:e.value||e.id||e;return{label:"string"==typeof e?e:e.label||e.name||r,value:r}}))||[],value:ue(e.id,!1)||"",onChange:function(i){var s,a=Object.keys(P).find(function(r){return r.toLowerCase()===(e.id||"").toLowerCase()});B(r(r({},P),((s={})[a||e.id]=i,s)))},placeholder:"Select ".concat((null===(t=e.label)||void 0===t?void 0:t.toLowerCase())||"")})]},e.id)})}))]}),2===E&&n("div",{children:[n("div",r({className:"q-subs-form-group"},{children:[a("label",r({className:"q-subs-form-label",style:{marginBottom:"4px"}},{children:"Subscription Type"})),a("div",r({className:"q-subs-form-desc"},{children:"Choose when you want to receive this report."})),a("div",r({className:"q-subs-radio-group"},{children:w.map(function(e){return n("label",r({className:"q-subs-radio-label"},{children:[a("input",{type:"radio",className:"q-subs-radio",checked:U===e.value,onChange:function(){return F(e.value)}})," ",e.label]}),e.value)})}))]})),function(){var e=w.find(function(e){return e.value===U}),i=null==e?void 0:e.triggers;if(i&&i.length>0){var s=i.find(function(e){return e.value===H});return n("div",r({className:"q-subs-form-group"},{children:[n("label",r({className:"q-subs-form-label",style:{marginBottom:"4px"}},{children:["Trigger",a("span",r({className:"req"},{children:"*"}))]})),a("div",r({className:"q-subs-form-desc"},{children:"How often should this report be sent?"})),a("div",r({style:{width:"60%"}},{children:a(b,{options:i.map(function(e){return{label:e.label,value:e.value}}),value:H,onChange:function(e){return G(e)},placeholder:"Select trigger"})})),s&&s.info&&n("div",r({className:"q-subs-info"},{children:[a(d,{size:12,strokeWidth:3}),s.info]}))]}))}return null}()]}),3===E&&a("div",{children:n("div",r({className:"q-subs-form-group"},{children:[a("label",r({className:"q-subs-form-label",style:{marginBottom:"4px"}},{children:"Subscribers"})),a("div",r({className:"q-subs-form-desc"},{children:"Who should receive this report?"})),n("div",r({className:"q-subs-search-box"},{children:[a("input",{type:"text",className:"q-subs-input",placeholder:"Type name or email...",value:V,onChange:function(e){return i(void 0,void 0,void 0,function(){var r,i;return s(this,function(s){switch(s.label){case 0:if(r=e.target.value,X(r),!r)return ie([]),[2];if(!N)return[3,5];ne(!0),s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,N(r)];case 2:return i=s.sent(),ie(i||[]),[3,5];case 3:return s.sent(),ie([]),[3,5];case 4:return ne(!1),[7];case 5:return[2]}})})}}),ae&&a("div",r({style:{position:"absolute",right:"12px",top:"10px",fontSize:"12px",color:"#94a3b8"}},{children:"Loading..."})),re.length>0&&V&&a("div",r({className:"q-subs-search-results"},{children:re.map(function(i){return a("div",r({className:"q-subs-search-item",onClick:function(){return function(r){J.find(function(e){return e.value===r.value})||K(e(e([],J,!0),[r],!1)),X(""),ie([])}(i)}},{children:i.label}),i.value)})}))]})),J.length>0&&a("div",r({className:"q-subs-chips"},{children:J.map(function(e){return n("div",r({className:"q-subs-chip"},{children:[e.label,a("div",r({className:"q-subs-chip-remove",onClick:function(){return r=e.value,void K(J.filter(function(e){return e.value!==r}));var r}},{children:a(u,{size:12,strokeWidth:3})}))]}),e.value)})}))]}))})]})),n("div",r({className:"q-subs-modal-footer"},{children:[a("button",1===E?r({className:"q-subs-btn-cancel",onClick:f},{children:"Cancel"}):r({className:"q-subs-btn-cancel",onClick:function(){return T(function(e){return Math.max(e-1,1)})}},{children:"Back"})),E<3?n("button",r({className:"q-subs-btn-primary",onClick:function(){return T(function(e){return Math.min(e+1,3)})},disabled:1===E&&(!z.trim()||te)||2===E&&oe},{children:["Next ",a("span",r({style:{marginLeft:"4px"}},{children:"→"}))]})):a("button",r({className:"q-subs-btn-primary",onClick:function(){return i(void 0,void 0,void 0,function(){var e,r,i,a,n;return s(this,function(s){switch(s.label){case 0:return $(!0),e={name:z,scope:P,subscription_type:U.toLowerCase(),trigger_frequency:(null===(n=null===(a=w.find(function(e){return e.value===U}))||void 0===a?void 0:a.triggers)||void 0===n?void 0:n.length)?H:"",trigger_event:U,subscriber_emails:J.map(function(e){return e.value}),subscriber_details:J.map(function(e){return{user_name:e.label,user_email:e.value,user_id:e.id}})},r=!1,C?[4,C(e,!!(null==S?void 0:S.id))]:[3,2];case 1:return i=s.sent(),r=!1!==i,[3,3];case 2:r=!0,s.label=3;case 3:return $(!1),r&&(f(),T(1),D(""),B({}),F("Periodic"),G(""),K([]),X("")),[2]}})})},disabled:Z||0===J.length},{children:Z?S?"Updating...":"Creating...":S?"Update Subscription":"Create Subscription"}))]}))]}))}))};export{m as default};
|
|
2
2
|
//# sourceMappingURL=CreateSubscriptionModal.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as n}from"../../../_virtual/_tslib.js";import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useMemo as i}from"react";import{useResponsiveColumns as l}from"../Table/TableGrid/useResponsiveColumns.js";import{resolveLayout as a,packLayout as o,cellHeight as r}from"./layout.js";import{useElementSize as c}from"./useElementSize.js";function d(c){var d=c.widgets,s=c.config,u=c.className,g=c.style,p=i(function(){return a(s,d)},[s,d]),h=p.columns,f=p.rowHeight,w=p.gap,v=p.packing,y=p.fillRows,S=p.equalHeights,x=p.matchRowHeights,H=p.items,N=l(h,1,w),R=N[0],_=N[1].width,j=i(function(){return new Map(d.map(function(n){return[n.key,n]}))},[d]),k=i(function(){return o(H,h,w,_,{packing:v,fillRows:y,equalHeights:S})},[H,h,w,_,v,y,S]),b=null==_?null:(_-w*(h-1))/h,T={shared:"minmax(".concat(f,"px, 1fr)"),unit:"minmax(".concat(f,"px, auto)"),content:"auto"},C=k.rows.length?k.rows.map(function(n){return T[n]}).join(" "):void 0;return t("div",n({ref:R,className:"dg-root ".concat(null!=u?u:""),style:g},{children:e("div",n({className:"dg-grid",style:{gridTemplateColumns:"repeat(".concat(h,", minmax(0, 1fr))"),gridTemplateRows:C,gap:w}},{children:[0===H.length&&e("div",n({className:"dg-empty",style:{gridColumn:"1 / -1"}},{children:[t("div",n({className:"dg-empty__title"},{children:"Nothing to show"})),t("div",n({className:"dg-empty__description"},{children:"This dashboard has no components configured."}))]})),H.map(function(n,e){var i=j.get(n.key);return i?t(m,{widget:i,item:n,place:k.items[e],nominalHeight:r(n.rowSpan,f,w),matchRowHeight:x,nominalWidth:null==b?null:k.items[e].colSpan*b+(k.items[e].colSpan-1)*w},i.key):null})]}))}))}function m(e){var i,l,a=e.widget,o=e.item,r=e.place,d=e.nominalHeight,m=e.nominalWidth,s=e.matchRowHeight,u=c(),g=u[0],p=u[1],h=null!=d,f="fit"===o.rowSpan,w=null!=d?Math.max(d,null!==(i=null==p?void 0:p.height)&&void 0!==i?i:0):null,v=null!==(l=null==p?void 0:p.width)&&void 0!==l?l:null==m?null:Math.round(m),y=a.render?a.render({colSpan:r.colSpan,rowSpan:o.rowSpan,height:w,width:v}):a.node;return t("div",n({ref:g,className:"dg-cell".concat(h?" dg-cell--fixed":f?s?" dg-cell--fit dg-cell--fit-matched":" dg-cell--fit":""),"data-widget":a.key,style:n({gridColumn:"".concat(r.colStart," / span ").concat(r.colSpan),gridRow:"".concat(r.rowStart," / span ").concat(r.rowSpan)},h?{minHeight:d}:{})},{children:t("div",n({className:"dg-cell__body"},{children:y}))}))}export{d as default};
|
|
2
|
+
//# sourceMappingURL=DashboardGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardGrid.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__spreadArray as t}from"../../../_virtual/_tslib.js";var r="chart:graphBuilder",e=function(r){return t([],null!=r?r:[],!0).sort(function(t,r){var e,n;return(null!==(e=t.displayOrder)&&void 0!==e?e:0)-(null!==(n=r.displayOrder)&&void 0!==n?n:0)})},n=function(t,r){var e;return!1!==(null===(e=null==t?void 0:t.components)||void 0===e?void 0:e[r])},i=function(t,r,e){return n(t,r)&&n(t,e)},l=function(t){return t.filter(function(t){return"string"==typeof t&&""!==t.trim()})};function a(a){var u,o,d,p,f,c,v=a.uiData,h=a.renderers,s=a.extraWidgets,y=[];(n(v,"kpiCards")?e(null==v?void 0:v.kpiCards):[]).forEach(function(t){var r;y.push({key:"kpi:".concat(null!==(r=t.key)&&void 0!==r?r:t.title),aliases:l([t.key,t.title]),title:t.title,type:"kpi",defaultColSpan:1,defaultRowSpan:"auto",minWidth:266,render:function(r){return h.kpi(t,r)}})});var k=null==v?void 0:v.graphBuilder,C=null!==(u=null==k?void 0:k.tiers)&&void 0!==u?u:[];k&&n(v,"graphBuilder")&&y.push({key:r,aliases:l(t(["graph"],C.map(function(t){return t.key}),!0)),title:k.title,type:"chart",defaultColSpan:2,defaultRowSpan:3,minWidth:360,render:function(t){return h.graph(C,t)}});var b=i(v,"barCharts","barChartBuilder")&&null!==(d=null!==(o=null==v?void 0:v.barCharts)&&void 0!==o?o:null==v?void 0:v.barChartBuilder)&&void 0!==d?d:[];e(b).forEach(function(t){var r;y.push({key:"bar:".concat(t.key),aliases:l([t.title]),title:null!==(r=t.title)&&void 0!==r?r:t.key,type:"chart",defaultColSpan:1,defaultRowSpan:3,minWidth:380,render:function(r){return h.barChart(t,r)}})});var m=i(v,"pieCharts","pieChartBuilder")&&null!==(f=null!==(p=null==v?void 0:v.pieCharts)&&void 0!==p?p:null==v?void 0:v.pieChartBuilder)&&void 0!==f?f:[];return e(m).forEach(function(t){var r;y.push({key:"pie:".concat(t.key),aliases:l([t.title]),title:null!==(r=t.title)&&void 0!==r?r:t.key,type:"chart",defaultColSpan:1,defaultRowSpan:3,minWidth:380,render:function(r){return h.pieChart(t,r)}})}),(n(v,"tableBuilder")&&null!==(c=null==v?void 0:v.tableBuilder)&&void 0!==c?c:[]).forEach(function(t){var r;y.push({key:"table:".concat(t.key),title:null!==(r=t.title)&&void 0!==r?r:t.key,type:"table",defaultColSpan:1,defaultRowSpan:3,minWidth:340,render:function(r){return h.table(t,r)}})}),(null!=s?s:[]).forEach(function(t){if(t&&"string"==typeof t.key){var r=y.findIndex(function(r){return r.key===t.key});r>=0?y[r]=t:y.push(t)}}),y}export{r as GRAPH_WIDGET_KEY,a as buildDashboardWidgets};
|
|
2
|
+
//# sourceMappingURL=buildDashboardWidgets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildDashboardWidgets.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__spreadArray as n,__assign as r}from"../../../_virtual/_tslib.js";var t=3,o=12,e=132,i=12,u=12,a=200;function l(n){if("string"!=typeof n)return null;var r=n.trim().toLowerCase().replace(/[\s_-]/g,"");return r.length?r:null}function c(n){if("number"==typeof n)return Number.isFinite(n)?n:null;if("string"==typeof n&&""!==n.trim()){var r=Number(n);return Number.isFinite(r)?r:null}return null}function f(n){var r=c(n);if(null==r||r<=0)return null;var t=Math.round(r);return t>=1?t:null}var v=function(n,r,t){return Math.min(t,Math.max(r,n))};function s(n){return!0===n||"string"==typeof n&&"true"===n.trim().toLowerCase()}function d(n){return"object"==typeof n&&null!==n&&!Array.isArray(n)}function p(r){var t=new Map,o=new Map;return r.forEach(function(n){var r=l(n.key);r&&!t.has(r)&&t.set(r,n)}),r.forEach(function(r){var t,e,i;n([(e=r.key,i=e.indexOf(":"),i>=0?e.slice(i+1):e)],null!==(t=r.aliases)&&void 0!==t?t:[],!0).forEach(function(n){var t=l(n);if(t){var e=o.get(t);void 0===e?o.set(t,r):null!==e&&e.key!==r.key&&o.set(t,null)}})}),{resolve:function(n){var r,e,i=l(n);if(i)return null!==(e=null!==(r=t.get(i))&&void 0!==r?r:o.get(i))&&void 0!==e?e:void 0}}}var h=new Set;function w(n,r){var t,o;if(s(null==n?void 0:n.defaultHeight))return"fit";var e=function(n){if("string"==typeof n){var r=n.trim().toLowerCase();if("auto"===r||"fit"===r)return r}var t=f(n);return null==t?null:v(t,1,12)};return null!==(o=null!==(t=e(null==n?void 0:n.rowSpan))&&void 0!==t?t:e(r))&&void 0!==o?o:"auto"}function m(n,t){var o,e,i=Math.min(12,null!==(o=f(null==n?void 0:n.columns))&&void 0!==o?o:3),u=null!==(e=f(null==n?void 0:n.rowHeight))&&void 0!==e?e:132,a=c(null==n?void 0:n.gap),l=null!=a&&a>=0?a:12,m=p(t),g=new Map,S=d(null==n?void 0:n.items)?n.items:{};Object.keys(S).forEach(function(n){var o=S[n];if(d(o)){var e=m.resolve(n);if(e){var i=r({},g.get(e.key));Object.keys(o).forEach(function(n){void 0!==o[n]&&(i[n]=o[n])}),g.set(e.key,i)}else!function(n,r){"production"===process.env.NODE_ENV||h.has(n)||(h.add(n),console.warn("[federated-dashboard] layout.items: ignored unrecognized key ".concat(JSON.stringify(n),". ")+"Available widgets: ".concat(r.map(function(n){return n.key}).join(", "),".")))}(n,t)}});var y=t.map(function(n,r){return{widget:n,defaultIndex:r}}).filter(function(n){var r,t=n.widget;return!0!==(null===(r=g.get(t.key))||void 0===r?void 0:r.hidden)}),k=y.map(function(n){var t;return r(r({},n),{order:c(null===(t=g.get(n.widget.key))||void 0===t?void 0:t.order)})}).sort(function(n,r){return null!=n.order&&null!=r.order?n.order-r.order||n.defaultIndex-r.defaultIndex:null!=n.order?-1:null!=r.order?1:n.defaultIndex-r.defaultIndex}),M=!1,b="string"==typeof(null==n?void 0:n.packing)&&"ordered"===n.packing.trim().toLowerCase()?"ordered":"dense";return{columns:i,rowHeight:u,gap:l,packing:b,fillRows:s(null==n?void 0:n.fillRows),equalHeights:!(!1===(null==n?void 0:n.equalHeights)||"false"===String(null==n?void 0:n.equalHeights).trim().toLowerCase()),matchRowHeights:!(!1===(null==n?void 0:n.matchRowHeights)||"false"===String(null==n?void 0:n.matchRowHeights).trim().toLowerCase()),items:k.map(function(n){var t,o,e=n.widget,u=g.get(e.key),a=function(n,r,t){var o,e,i=null!==(e=null!==(o=f(n))&&void 0!==o?o:f(r))&&void 0!==e?e:1;return v(i,1,t)}(null==u?void 0:u.colSpan,e.defaultColSpan,i),l=f(null==u?void 0:u.colStart),c=null==l?null:v(l,1,i-a+1),d=M||s(null==u?void 0:u.newRow);return M=s(null==u?void 0:u.endRow),r(r({key:e.key,colSpan:a,rowSpan:w(u,e.defaultRowSpan),minWidth:null!==(o=null!==(t=f(null==u?void 0:u.minWidth))&&void 0!==t?t:f(e.minWidth))&&void 0!==o?o:200},null!=c?{colStart:c}:{}),d?{newRow:!0}:{})})}}var g=function(n){return n.reduce(function(n,r){return n+r},0)};var S=function(){function n(n){this.cells=[],this.columns=n}return Object.defineProperty(n.prototype,"rowCount",{get:function(){return this.cells.length},enumerable:!1,configurable:!0}),n.prototype.isFree=function(n,r,t,o){if(r<0||r+t>this.columns)return!1;for(var e=n;e<n+o&&e<this.cells.length;e++)for(var i=r;i<r+t;i++)if(this.cells[e][i])return!1;return!0},n.prototype.take=function(n,r,t,o){for(;this.cells.length<n+o;)this.cells.push(new Array(this.columns).fill(!1));for(var e=n;e<n+o;e++)for(var i=r;i<r+t;i++)this.cells[e][i]=!0},n.prototype.find=function(n,r,t,o,e){for(var i=t;;i++){var u=i===t?o:0;if(null==e){for(var a=u;a+n<=this.columns;a++)if(this.isFree(i,a,n,r))return{row:i,col:a}}else if(e>=u&&this.isFree(i,e,n,r))return{row:i,col:e}}},n}();function y(n,r,t){for(var o=n.slice(),e=function(){var e=o.map(function(n,t){return n<r[t]?t:-1}).filter(function(n){return n>=0}),i=t-g(o);if(!e.length||i<=0)return{value:o};var u=e.map(function(n){return o[n]}),a=function(n,r,t){var o=Math.max(0,t-g(n)),e=g(r)||1,i=r.map(function(n){return o*n/e}),u=n.map(function(n,r){return n+Math.floor(i[r])}),a=t-g(u);return i.map(function(n,r){return{i:r,fraction:n-Math.floor(n)}}).sort(function(n,r){return r.fraction-n.fraction||n.i-r.i}).forEach(function(n){var r=n.i;a>0&&(u[r]+=1,a-=1)}),u}(u,e.map(function(r){return n[r]}),g(u)+i),l=!1;return e.forEach(function(n,t){var e=Math.min(r[n],a[t]);e!==o[n]&&(l=!0),o[n]=e}),l?void 0:{value:o}};;){var i=e();if("object"==typeof i)return i.value}}function k(n,r,t,o,e){void 0===e&&(e={});var i="ordered"!==e.packing,u=function(n,r,t,o){if(null==o)return n.map(function(n){return n.colSpan});var e=(o-t*(r-1))/r;return n.map(function(n){var o=e<=0?r:v(Math.ceil((n.minWidth+t)/(e+t)-1e-6),1,r);return Math.max(n.colSpan,o)})}(n,r,t,o),a=u.some(function(r,t){return r!==n[t].colSpan}),l=new S(r),c=0,f=0,s=0,d=n.map(function(n,t){var o=u[t],e=function(n){return"number"==typeof n.rowSpan?n.rowSpan:1}(n),a=null!=n.colStart?v(n.colStart-1,0,r-o):null;n.newRow&&(s=l.rowCount);var d=n.newRow||i?[s,0]:[c,f],p=d[0],h=d[1],w=l.find(o,e,p,h,a),m=w.row,g=w.col;return l.take(m,g,o,e),c=m,f=g+o,{key:n.key,colStart:g+1,colSpan:o,rowStart:m+1,rowSpan:e}});(e.fillRows||a)&&function(n,r,t){var o=new Map(n.map(function(n){return[n,"".concat(n.colSpan,"x").concat(n.rowSpan)]})),e=new Map,i=new Map;n.forEach(function(n){var r,t,u=o.get(n),a=(null!==(r=e.get("".concat(u,"@").concat(n.rowStart)))&&void 0!==r?r:0)+1;e.set("".concat(u,"@").concat(n.rowStart),a),i.set(u,Math.max(null!==(t=i.get(u))&&void 0!==t?t:0,a))});var u=function(n){var r=o.get(n);return e.get("".concat(r,"@").concat(n.rowStart))<i.get(r)},a=new Map;n.forEach(function(n){var r,t=null!==(r=a.get(n.rowStart))&&void 0!==r?r:[];t.push(n),a.set(n.rowStart,t)});var l=function(n){for(var o,e=function(e){var i=(null!==(o=a.get(e))&&void 0!==o?o:[]).sort(function(n,r){return n.colStart-r.colStart});if(!i.length)return"continue";for(var u=i[i.length-1],l=u.colStart-1+u.colSpan,c=0;l+c<t&&r.isFree(e-1,l+c,1,u.rowSpan);)c+=1;if(!c)return"continue";for(var f=i.length-1;f>0;){var v=i[f-1];if(v.rowSpan!==u.rowSpan||v.colStart+v.colSpan!==i[f].colStart)break;f-=1}var s=i.slice(f),d=s.map(function(n){return n.colSpan}),p=y(d,s.map(function(r){return Math.max(r.colSpan,n(r))}),g(d)+c),h=g(p)-g(d);if(!h)return"continue";var w=s[0].colStart;s.forEach(function(n,r){n.colStart=w,n.colSpan=p[r],w+=p[r]}),r.take(e-1,l,h,u.rowSpan)},i=1;i<=r.rowCount;i++)e(i)};l(function(n){return u(n)?n.colSpan:t}),l(function(r){if(!u(r))return t;var e=o.get(r);return Math.max.apply(Math,n.filter(function(n){return o.get(n)===e&&!u(n)}).map(function(n){return n.colSpan}))})}(d,l,r);var p=!1===e.equalHeights?"unit":"shared",h=new Array(l.rowCount).fill("content");return d.forEach(function(r,t){var o=n[t].rowSpan;if("fit"!==o)for(var e=r.rowStart-1;e<r.rowStart-1+r.rowSpan;e++)"auto"===o?h[e]=p:"content"===h[e]&&(h[e]="unit")}),{items:d,rows:h}}function M(n,r,t,o,e){return k(n,r,t,o,e).items}function b(n,r,t){return"number"!=typeof n?null:n*r+(n-1)*t}export{t as DEFAULT_COLUMNS,i as DEFAULT_GAP,a as DEFAULT_MIN_WIDTH,e as DEFAULT_ROW_HEIGHT,o as MAX_COLUMNS,u as MAX_ROW_SPAN,p as buildWidgetIndex,b as cellHeight,k as packLayout,M as placeItems,m as resolveLayout};
|
|
2
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useRef as n,useState as e,useLayoutEffect as r,useEffect as t}from"react";var i="undefined"!=typeof window?r:t;function u(){var r=n(null),t=e(null),u=t[0],c=t[1],o=n(null);return i(function(){var n=r.current;if(n){var e=function(){var e=n.getBoundingClientRect(),r={width:Math.round(e.width),height:Math.round(e.height)};c(function(n){return n&&n.width===r.width&&n.height===r.height?n:r})},t=function(){null==o.current&&(o.current=requestAnimationFrame(function(){o.current=null,r.current&&e()}))};if(e(),"undefined"==typeof ResizeObserver)return window.addEventListener("resize",t),function(){window.removeEventListener("resize",t),null!=o.current&&cancelAnimationFrame(o.current),o.current=null};var i=new ResizeObserver(t);return i.observe(n),function(){i.disconnect(),null!=o.current&&cancelAnimationFrame(o.current),o.current=null}}},[]),[r,u]}export{u as default,u as useElementSize};
|
|
2
|
+
//# sourceMappingURL=useElementSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementSize.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as e}from"../../../_virtual/_tslib.js";import{jsxs as n,Fragment as t,jsx as r}from"react/jsx-runtime";import{useRef as a,useState as i,useEffect as c,useLayoutEffect as l,useMemo as o}from"react";import{Calendar as u,ChevronDown as s,ArrowRight as d,ChevronLeft as m,ChevronRight as f}from"lucide-react";var p=["Mo","Tu","We","Th","Fr","Sa","Su"],g=function(e){var n=new Date(e);return n.setHours(0,0,0,0),n},v=function(e){return new Date(e.getFullYear(),e.getMonth(),1)},h=function(e,n){return new Date(e.getFullYear(),e.getMonth()+n,1)},_=function(e){return 12*e.getFullYear()+e.getMonth()},w=function(e,n){return!!e&&!!n&&e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},y=function(e){return"".concat(e.getFullYear(),"-").concat(e.getMonth(),"-").concat(e.getDate())},N=function(e){return e.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},b=function(e,n){if(w(e,n))return N(e);if(e.getFullYear()===n.getFullYear()){var t=function(e){return e.toLocaleDateString("en-US",{month:"short",day:"numeric"})};return"".concat(t(e)," – ").concat(t(n),", ").concat(n.getFullYear())}return"".concat(N(e)," – ").concat(N(n))},D=function(b){var D=b.label,k=b.active,T=void 0!==k&&k,C=b.value,E=b.quickRanges,M=void 0===E?[]:E,S=b.selectedPreset,F=b.allowCustom,L=void 0===F||F,x=b.minDate,Y=b.maxDate,A=b.onQuickRangeSelect,z=b.onApply,B=function(e){var n=i(function(){return"undefined"!=typeof window&&window.matchMedia(e).matches}),t=n[0],r=n[1];return c(function(){var n=window.matchMedia(e),t=function(){return r(n.matches)};return t(),n.addEventListener("change",t),function(){return n.removeEventListener("change",t)}},[e]),t}("(max-width: 767px)"),j=B?1:2,K=a(null),R=a(null),U=a(null),W=a(null),P=a(!1),q=i(!1),H=q[0],Q=q[1],I=i(!1),G=I[0],J=I[1],O=i(null),V=O[0],X=O[1],Z=i(null),$=Z[0],ee=Z[1],ne=i(null),te=ne[0],re=ne[1],ae=i(function(){return g(new Date)}),ie=ae[0],ce=ae[1],le=i(function(){return v(new Date)}),oe=le[0],ue=le[1],se=i(""),de=se[0],me=se[1],fe=i(""),pe=fe[0],ge=fe[1],ve=x?g(x):null,he=Y?g(Y):null,_e=function(e){return!!ve&&e.getTime()<ve.getTime()||!!he&&e.getTime()>he.getTime()},we=function(e){return ve&&e.getTime()<ve.getTime()?ve:he&&e.getTime()>he.getTime()?he:e};c(function(){me(V?N(V):""),ge($?N($):"")},[V,$]);var ye=function(e){var n;void 0===e&&(e=!1),Q(!1),re(null),e&&(null===(n=R.current)||void 0===n||n.focus())};l(function(){if(H&&!B&&K.current&&U.current){var e=K.current.getBoundingClientRect(),n=U.current.offsetWidth;J(e.left+n+8>window.innerWidth)}},[H,B]),c(function(){if(H){var e=function(e){K.current&&!K.current.contains(e.target)&&ye()},n=function(e){"Escape"===e.key&&ye(!0)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",n),function(){document.removeEventListener("mousedown",e),document.removeEventListener("keydown",n)}}},[H]),c(function(){var e;P.current&&W.current&&(P.current=!1,null===(e=W.current.querySelector('[data-day="'.concat(y(ie),'"]')))||void 0===e||e.focus())},[ie,oe]);var Ne=o(function(){return Array.from({length:j},function(e,n){return h(oe,n)})},[oe,j]),be=!ve||_(oe)>_(ve),De=!he||_(h(oe,j-1))<_(he),ke=function(e){var n,t="start"===e?de:pe,r="start"===e?V:$,a=new Date(t);if(!t.trim()||Number.isNaN(a.getTime())||_e(g(a)))"start"===e?me(r?N(r):""):ge(r?N(r):"");else{var i=g(a),c="start"===e?i:V,l="end"===e?i:$;c&&l&&c.getTime()>l.getTime()&&(c=(n=[l,c])[0],l=n[1]),X(c),ee(l),me(c?N(c):""),ge(l?N(l):""),ce(i),(_(i)<_(oe)||_(i)>_(oe)+j-1)&&ue(h(v(i),"end"===e?-(j-1):0))}},Te=function(){var e;V&&$&&(z(g(V),((e=new Date($)).setHours(23,59,59,999),e)),ye(!0))},Ce=null!=$?$:V&&te?te:null,Ee=V&&Ce?V.getTime()<=Ce.getTime()?[V,Ce]:[Ce,V]:[V,V],Me=Ee[0],Se=Ee[1],Fe=g(new Date),Le=function(){if(V&&$){var e=(a=V,i=$,Math.round((g(i).getTime()-g(a).getTime())/864e5)+1);return n(t,{children:[r("strong",{children:e})," ",1===e?"day":"days"," selected"]})}var a,i;return V?"Now pick an end date":"Pick a start date"}();return n("div",e({className:"crp",ref:K},{children:[n("button",e({ref:R,type:"button",className:"crp__trigger ".concat(T?"is-active":""," ").concat(H?"is-open":""),"aria-haspopup":"dialog","aria-expanded":H,onClick:function(){return H?ye():function(){var e,n=C.start?g(C.start):null,t=C.end?g(C.end):null;X(n),ee(t),re(null);var r=null!==(e=null!=t?t:n)&&void 0!==e?e:g(new Date);ue(h(v(r),-(j-1))),ce(we(r)),Q(!0)}()}},{children:[r(u,{size:15,strokeWidth:2.2}),r("span",e({className:"crp__trigger-label"},{children:D})),r(s,{size:14,className:"crp__chevron"})]})),H&&n(t,{children:[B&&r("div",{className:"crp__backdrop",onClick:function(){return ye()}}),n("div",e({ref:U,className:"crp__popover ".concat(G?"is-align-right":""," ").concat(B?"is-sheet":""," ").concat(L?"":"is-rail-only"),role:"dialog","aria-label":"Select date range"},{children:[M.length>0&&n("div",e({className:"crp__rail"},{children:[r("span",e({className:"crp__rail-title"},{children:"Quick ranges"})),r("div",e({className:"crp__rail-list"},{children:M.map(function(n){return r("button",e({type:"button",className:"crp__rail-item ".concat(S===n.value?"is-active":""),onClick:function(){null==A||A(n.value),ye(!0)}},{children:n.label}),n.value)})}))]})),L&&n("div",e({className:"crp__main"},{children:[n("div",e({className:"crp__inputs"},{children:[r("input",{className:"crp__input ".concat(!V||$?"is-next":""),"aria-label":"Start date",value:de,placeholder:"Start date",onChange:function(e){return me(e.target.value)},onBlur:function(){return ke("start")},onKeyDown:function(e){return"Enter"===e.key&&ke("start")}}),r(d,{size:14,className:"crp__inputs-arrow"}),r("input",{className:"crp__input ".concat(V&&!$?"is-next":""),"aria-label":"End date",value:pe,placeholder:"End date",onChange:function(e){return ge(e.target.value)},onBlur:function(){return ke("end")},onKeyDown:function(e){return"Enter"===e.key&&ke("end")}})]})),r("div",e({className:"crp__months",ref:W,onKeyDown:function(e){var n={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[e.key];if(void 0!==n){e.preventDefault();var t=we(function(e,n){var t=new Date(e);return t.setDate(t.getDate()+n),t}(ie,n));P.current=!0,ce(t);var r=_(oe),a=r+j-1;_(t)<r?ue(v(t)):_(t)>a&&ue(h(v(t),-(j-1))),V&&!$&&re(t)}},onMouseLeave:function(){return re(null)}},{children:Ne.map(function(t,a){var i=function(e){for(var n=e.getFullYear(),t=e.getMonth(),r=(new Date(n,t,1).getDay()+6)%7,a=new Date(n,t+1,0).getDate(),i=Array(r).fill(null),c=1;c<=a;c++)i.push(new Date(n,t,c));for(;i.length<42;)i.push(null);return i}(t);return n("div",e({className:"crp__month"},{children:[n("div",e({className:"crp__month-header"},{children:[0===a?r("button",e({type:"button",className:"crp__nav","aria-label":"Previous month",disabled:!be,onClick:function(){return ue(function(e){return h(e,-1)})}},{children:r(m,{size:15})})):r("span",{className:"crp__nav-spacer"}),r("span",e({className:"crp__month-title"},{children:t.toLocaleDateString("en-US",{month:"long",year:"numeric"})})),a===j-1?r("button",e({type:"button",className:"crp__nav","aria-label":"Next month",disabled:!De,onClick:function(){return ue(function(e){return h(e,1)})}},{children:r(f,{size:15})})):r("span",{className:"crp__nav-spacer"})]})),r("div",e({className:"crp__weekdays"},{children:p.map(function(e){return r("span",{children:e},e)})})),r("div",e({className:"crp__days",role:"grid"},{children:i.map(function(n,t){if(!n)return r("span",{className:"crp__cell"},t);var a=_e(n),c=w(n,Me),l=w(n,Se),o=!!Me&&!!Se&&n.getTime()>=Me.getTime()&&n.getTime()<=Se.getTime()&&!w(Me,Se),u=t%7,s=1===n.getDate(),d=null===i[t+1]||t===i.length-1,m=["crp__cell",o?"is-in-range":"",o&&c?"is-range-start":"",o&&l?"is-range-end":"",o&&(0===u||s)?"is-row-start":"",o&&(6===u||d)?"is-row-end":"",!$&&o?"is-preview":""].filter(Boolean).join(" "),f=["crp__day",c||l?"is-selected":"",w(n,Fe)?"is-today":""].filter(Boolean).join(" ");return r("span",e({className:m},{children:r("button",e({type:"button",className:f,"data-day":y(n),disabled:a,tabIndex:w(n,ie)?0:-1,"aria-label":N(n),"aria-pressed":c||l,onClick:function(){return function(e){_e(e)||(ce(e),!V||$?(X(e),ee(null)):e.getTime()<V.getTime()?(ee(V),X(e)):ee(e),re(null))}(n)},onMouseEnter:function(){return V&&!$&&re(n)},onFocus:function(){return ce(n)},onKeyDown:function(e){"Enter"===e.key&&V&&$&&w(n,ie)&&(w(n,$)||w(n,V))&&(e.preventDefault(),Te())}},{children:n.getDate()}))}),t)})}))]}),_(t))})})),n("div",e({className:"crp__footer"},{children:[r("span",e({className:"crp__summary"},{children:Le})),n("div",e({className:"crp__actions"},{children:[r("button",e({type:"button",className:"crp__btn crp__btn--ghost",onClick:function(){return ye(!0)}},{children:"Cancel"})),r("button",e({type:"button",className:"crp__btn crp__btn--primary",disabled:!V||!$,onClick:Te},{children:"Apply"}))]}))]}))]}))]}))]})]}))};export{D as default,b as formatRangeLabel};
|
|
2
|
+
//# sourceMappingURL=CustomRangePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomRangePicker.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as l,__spreadArray as i}from"../../_virtual/_tslib.js";import{jsx as o,Fragment as e,jsxs as n}from"react/jsx-runtime";import t,{useMemo as d}from"react";import{ChartLine as a}from"lucide-react";import r from"./DashboardDateFilter/DashboardDateFilter.js";import u from"./MetricCard/MetricCard.js";import v from"./FiltersSidebar/FiltersSidebar.js";import s from"./Graph/Graph.js";import c from"./Graph/GraphEmptyState.js";import{DATE_PRESET_MAP as p}from"./DashboardDateFilter/datePreset.js";import h from"./Table/TableCard.js";import g from"./Table/TableGrid/TableGrid.js";import{buildColumns as m,withRowIds as f}from"../utils/tableColumns.js";import{resolveSectionOrder as b,isSectionHidden as y}from"../utils/sectionOrder.js";import{getActiveFilterCount as C,isKpiValueObject as k,getKpiValueColor as w,getKpiDelta as F,formatKpiValue as B}from"../utils/index.js";import{getKpiIcon as x}from"../utils/kpiIcon.js";import{AlertsViewTrigger as D}from"./Alerts/AlertsViewTrigger.js";var A=["#7c3aed","#FFC130","#F43F5E","#10b981","#3b82f6"];function T(T){var L,S,j,P,O,E,V,M,R,I,G,H,z,U,W,K,q,N,Z,_,J,Q,X,Y,$,ll,il,ol,el,nl,tl,dl,al,rl,ul,vl,sl,cl,pl,hl=T.baseUrl,gl=T.configId,ml=T.uiConfig,fl=T.data,bl=T.dataLoading,yl=T.startDate,Cl=T.endDate,kl=T.onDateChange,wl=T.onRefresh,Fl=T.selectedKpis,Bl=T.onKpiChange,xl=T.sidebarVisible,Dl=T.onSidebarShow,Al=T.onSidebarHide,Tl=T.filterValues,Ll=T.onFilterChange,Sl=T.onFilterReset,jl=T.onFilterApply,Pl=T.appliedFilters,Ol=T.graphEmptyState,El=T.tables,Vl=T.tableLayout,Ml=T.sectionOrder,Rl=T.hiddenSections,Il=T.tablePages,Gl=T.onTableExpand,Hl=T.onTableLoadMore,zl=T.pollingEnabled,Ul=void 0!==zl&&zl,Wl=T.selectedPreset,Kl=T.handlePresetChange,ql=T.metricCardConfig,Nl=T.kpiCtaConfig,Zl=T.tableCtaConfig,_l=T.activeThreshold,Jl=T.onThresholdViewChange,Ql=T.onAlertsClick,Xl=T.showAlerts,Yl=T.onAlertClose,$l=T.accessToken,li=T.authBaseUrl,ii=null!==(j=null===(S=null===(L=null==ml?void 0:ml.data)||void 0===L?void 0:L.dateFilters)||void 0===S?void 0:S.datepresets)&&void 0!==j?j:[],oi=d(function(){return ii.map(function(l){return p[l]}).filter(Boolean)},[JSON.stringify(ii)]),ei=d(function(){return C(Pl)},[Pl]),ni=d(function(){var l,i,o=null==Vl?void 0:Vl.spans;if(o)return(null!==(i=null===(l=null==ml?void 0:ml.data)||void 0===l?void 0:l.tableBuilder)&&void 0!==i?i:[]).map(function(l,i){return Array.isArray(o)?o[i]:o[l.key]})},[null==Vl?void 0:Vl.spans,null===(P=null==ml?void 0:ml.data)||void 0===P?void 0:P.tableBuilder]),ti=o("div",l({style:{padding:"4px"}},{children:o(s,{loading:bl,emptyState:null!=Ol?Ol:o(c,{}),title:null===(O=null==ml?void 0:ml.data)||void 0===O?void 0:O.graphBuilder.title,description:null===(V=null===(E=null==ml?void 0:ml.data)||void 0===E?void 0:E.graphBuilder)||void 0===V?void 0:V.subtitle,icon:o(a,{size:18}),xAxis:{label:(null===(R=null===(M=null==ml?void 0:ml.data)||void 0===M?void 0:M.graphBuilder)||void 0===R?void 0:R.axis.xAxisLabel)||"Date"},style:{chartHeight:220},scrollable:Ul,panes:null===(I=null==ml?void 0:ml.data)||void 0===I?void 0:I.graphBuilder.tiers.map(function(i,e){var n,t,d,r,u,v,s,c,p,h,g,m,f=Fl[i.key]||(null===(n=i.plotOptions[0])||void 0===n?void 0:n.key),b=fl.graph.tier.find(function(l){return l.key===i.key}),y=(null===(t=null==b?void 0:b.referenceOptions)||void 0===t?void 0:t[f])||{},C=(null===(d=null==b?void 0:b.plotbyoptions)||void 0===d?void 0:d[f])||{},k=(null==i?void 0:i.series)||[],w=Object.keys(C),F=i.plotOptions.find(function(l){return l.value===f});return{key:i.key,selector:{label:"Plot By",value:f,onChange:function(l){Bl(i.key,l)},options:i.plotOptions.map(function(l){return{label:l.label,value:l.value}}),triggerIcon:o(a,{size:16,color:0===e?"green":"purple"})},yAxis:{label:null==F?void 0:F.yAxisLabel,beginAtZero:"false"!==(null==f?void 0:f.yAxisBeginAtZero)},tooltip:{formatHeading:function(l){return"".concat(l)}},legend:{position:(null===(v=null===(u=null===(r=null==ml?void 0:ml.data)||void 0===r?void 0:r.graphBuilder)||void 0===u?void 0:u.legend)||void 0===v?void 0:v.position)||"bottom",toggle:"yes"===(null===(p=null===(c=null===(s=null==ml?void 0:ml.data)||void 0===s?void 0:s.graphBuilder)||void 0===c?void 0:c.legend)||void 0===p?void 0:p.allowToggle),align:(null===(m=null===(g=null===(h=null==ml?void 0:ml.data)||void 0===h?void 0:h.graphBuilder)||void 0===g?void 0:g.legend)||void 0===m?void 0:m.alignment)||"center"},height:0===e?300:250,series:w.map(function(i,o){var e,n,t,d,a=(null===(n=null===(e=null==b?void 0:b.plotbyoptions)||void 0===e?void 0:e[f])||void 0===n?void 0:n[i])||[],r=A[o%A.length],u=k.find(function(l){return l.key===i}),v=null===(d=null===(t=null==b?void 0:b.thresholds)||void 0===t?void 0:t[f])||void 0===d?void 0:d[null==u?void 0:u.key];return l(l(l({key:i,label:(null==u?void 0:u.name)||i,data:a,area:"yes"===(null==u?void 0:u.areaFill),curve:(null==u?void 0:u.curveType)||"linear",color:"#".concat(null==u?void 0:u.color)||r,dashed:"dashed"===(null==u?void 0:u.style),strokeWidth:parseInt(null==u?void 0:u.strokeWidth)||2,showPoints:"yes"===(null==u?void 0:u.showPoints),pointRadius:parseInt(null==u?void 0:u.pointRadius)||3,showInLegend:!0},null!=(null==v?void 0:v.value)&&{threshold:v.value}),null!=(null==v?void 0:v.unit)&&{thresholdUnit:v.unit}),{valueFormatter:function(l){return"".concat(l)}})}),reference:y}}),activeThreshold:_l,onThresholdViewChange:Jl})})),di=o("div",l({style:{padding:"4px",display:"flex",gap:"10px",flexWrap:"wrap"}},{children:i([],null!==(H=null===(G=null==ml?void 0:ml.data)||void 0===G?void 0:G.kpiCards)&&void 0!==H?H:[],!0).sort(function(l,i){var o,e;return(null!==(o=l.displayOrder)&&void 0!==o?o:0)-(null!==(e=i.displayOrder)&&void 0!==e?e:0)}).map(function(l){var i,e,n,t=null===(i=null==fl?void 0:fl.kpiCards)||void 0===i?void 0:i[l.title],d=k(t)?w(t.currentValue,t.baselineValue,l.indicatorLogic):void 0,a=k(t)?F(t.currentValue,t.baselineValue,l.indicatorLogic):void 0,r=null!==(e=l.ctaKey)&&void 0!==e?e:l.key,v=r?null==Nl?void 0:Nl[r]:void 0;return o(u,{title:l.title,subtitle:l.subtitle,value:B(t,l.valueFormat),valueColor:d,delta:a&&{label:a.label,direction:a.direction,color:d},icon:x(l.icon),loading:bl,showDelta:null===(n=null==ql?void 0:ql.showDelta)||void 0===n||n,cta:{ctaEnabled:Boolean(l.showActionButton),ctaText:l.actionButtonLabel,ctaOnClick:function(){return null==v?void 0:v(l)}}},l.title)})})),ai=(null!==(W=null===(U=null===(z=null==ml?void 0:ml.data)||void 0===z?void 0:z.tableBuilder)||void 0===U?void 0:U.length)&&void 0!==W?W:0)>0?o("div",l({style:{padding:"4px"}},{children:o(g,l({itemSpans:ni,totalColumns:null!==(K=null==Vl?void 0:Vl.totalColumns)&&void 0!==K?K:12,defaultSpan:null==Vl?void 0:Vl.defaultSpan,options:null!==(q=null==Vl?void 0:Vl.options)&&void 0!==q?q:[1,2,3],defaultColumns:null==Vl?void 0:Vl.defaultColumns,columns:null==Vl?void 0:Vl.columns,onColumnsChange:null==Vl?void 0:Vl.onColumnsChange,showToggle:(null===(N=null==Vl?void 0:Vl.showToggle)||void 0===N||N)&&(null!==(J=null===(_=null===(Z=null==ml?void 0:ml.data)||void 0===Z?void 0:Z.tableBuilder)||void 0===_?void 0:_.length)&&void 0!==J?J:0)>1,toggleLabel:null==Vl?void 0:Vl.toggleLabel,minColumnWidth:null!==(Q=null==Vl?void 0:Vl.minColumnWidth)&&void 0!==Q?Q:380,gap:null!==(X=null==Vl?void 0:Vl.gap)&&void 0!==X?X:12,equalHeights:null===(Y=null==Vl?void 0:Vl.equalHeights)||void 0===Y||Y},{children:ml.data.tableBuilder.map(function(i){var e,n,d,a=null!==(n=null===(e=null==fl?void 0:fl.table)||void 0===e?void 0:e[i.key])&&void 0!==n?n:[],r=null==Il?void 0:Il[i.key],u=!!(null==r?void 0:r.loaded),v=u?r.rows:a,s=!u&&i.rowLimit&&i.rowLimit>0?a.slice(0,i.rowLimit):v,c=null==El?void 0:El[i.key],p=m(i,c),g=null==c?void 0:c.card,b=null==g?void 0:g.icon,y=x(i.icon),C=y&&t.isValidElement(y)?t.cloneElement(y,l(l({},null!=(null==b?void 0:b.size)?{size:b.size}:{}),(null==b?void 0:b.color)?{color:b.color}:{})):y,k=b?l(l(l({width:"auto",height:"auto"},b.color?{color:b.color}:{}),b.background?{background:b.background,padding:6,borderRadius:8}:{}),b.style):void 0,w=null!==(d=i.ctaKey)&&void 0!==d?d:i.key,F=w?null==Zl?void 0:Zl[w]:void 0;return o(h,{title:i.title,icon:C,styles:{root:null==g?void 0:g.root,header:null==g?void 0:g.header,title:null==g?void 0:g.title,icon:k},cta:{ctaEnabled:Boolean(i.showActionButton),ctaText:i.actionButtonLabel,ctaOnClick:function(){return null==F?void 0:F(i)}},onExpand:function(l){return null==Gl?void 0:Gl(i.key,l)},table:{rows:f(s),columns:p,loading:bl,loadingMore:null==r?void 0:r.loading,hasMore:null==r?void 0:r.hasMore,onLoadMore:r?function(){return null==Hl?void 0:Hl(i.key)}:void 0,tableProps:null==c?void 0:c.tableProps}},i.key)})}))})):null,ri={graphBuilder:ti,kpiCards:di,tableBuilder:ai},ui=b(Ml,Rl,null===($=null==ml?void 0:ml.data)||void 0===$?void 0:$.sectionOrder,Object.keys(ri)),vi=y(Rl,"dateFilters"),si=y(Rl,"sidebarFilters");return o(e,Xl?{children:o(D,{baseUrl:hl||"",authBaseUrl:li||"",configId:gl,onClose:function(){return null==Yl?void 0:Yl(!1)},uiConfig:ml,accessToken:$l})}:{children:n("div",l({style:{display:"flex",flexDirection:"column",gap:12,width:"100%"}},{children:[!vi&&o("div",l({style:{padding:"4px"}},{children:o(r,{filterCount:ei,initialStartDate:yl,initialEndDate:Cl,onDateChange:kl,onRefresh:wl,onFilterClick:Dl,presets:oi,datePickerProps:{from:{minDate:new Date(2025,0,1),maxDate:new Date},to:{minDate:yl,maxDate:new Date}},defaultPresets:null===(ll=null==ml?void 0:ml.data)||void 0===ll?void 0:ll.dateFilters.defaultPreset,showLiveButton:"yes"===(null===(ol=null===(il=null==ml?void 0:ml.data)||void 0===il?void 0:il.dateFilters)||void 0===ol?void 0:ol.showLiveButton),showFilterButton:!si&&"yes"===(null===(nl=null===(el=null==ml?void 0:ml.data)||void 0===el?void 0:el.dateFilters)||void 0===nl?void 0:nl.showFilterButton),showFilterCount:!si&&"yes"===(null===(dl=null===(tl=null==ml?void 0:ml.data)||void 0===tl?void 0:tl.dateFilters)||void 0===dl?void 0:dl.showFilterCount),liveDuration:null===(rl=null===(al=null==ml?void 0:ml.data)||void 0===al?void 0:al.dateFilters)||void 0===rl?void 0:rl.liveDurationMs,pollingEnabled:Ul,selectedPreset:Wl,handlePresetChange:Kl,showAlertsBtn:"yes"===(null===(vl=null===(ul=null==ml?void 0:ml.data)||void 0===ul?void 0:ul.dateFilters)||void 0===vl?void 0:vl.showAlertButton),onAlertsClick:Ql})})),ui.map(function(l){return o(t.Fragment,{children:ri[l]},l)}),!si&&o(v,{visible:xl,onHide:Al,onReset:Sl,onApply:jl,fields:null!==(pl=null===(cl=null===(sl=null==ml?void 0:ml.data)||void 0===sl?void 0:sl.sidebarFilters)||void 0===cl?void 0:cl.map(function(l){var i,o,e,n,t=l.schemaFilterName,d="Single select"===l.type?"singleSelect":"Multi select"===l.type?"multiSelect":"Date Range"===l.type?"dateRange":"Date"===l.type?"date":"text",a=null!==(o=null===(i=l.options)||void 0===i?void 0:i.map(function(l){return{label:l,value:l}}))&&void 0!==o?o:[];return{id:t,label:l.label,hint:l.description,type:d,placeholder:l.placeholder,options:a,value:"multiSelect"===d?null!==(e=Tl[t])&&void 0!==e?e:[]:null!==(n=Tl[t])&&void 0!==n?n:"",onChange:function(l){return Ll(t,l)}}}))&&void 0!==pl?pl:[]})]}))})}export{T as ExecutiveDashboard,T as default};
|
|
1
|
+
import{__assign as l,__spreadArray as i}from"../../_virtual/_tslib.js";import{jsx as o,Fragment as e,jsxs as n}from"react/jsx-runtime";import t,{useMemo as d,useRef as r}from"react";import{ChartLine as a}from"lucide-react";import u from"./DashboardDateFilter/DashboardDateFilter.js";import v from"./MetricCard/MetricCard.js";import s from"./FiltersSidebar/FiltersSidebar.js";import c from"./Graph/Graph.js";import p from"./Graph/GraphEmptyState.js";import{DATE_PRESET_MAP as h}from"./DashboardDateFilter/datePreset.js";import g from"./Table/TableCard.js";import f from"./Table/TableGrid/TableGrid.js";import m from"./DashboardGrid/DashboardGrid.js";import{buildDashboardWidgets as b}from"./DashboardGrid/buildDashboardWidgets.js";import y from"./BarChart/BarChart.js";import C from"./PieChart/PieChart.js";import{buildColumns as k,withRowIds as x}from"../utils/tableColumns.js";import{resolveSectionOrder as w,isSectionHidden as F}from"../utils/sectionOrder.js";import{limitChartData as B,toChartData as D,formatChartValue as L}from"../utils/chartCards.js";import{getActiveFilterCount as A,isKpiValueObject as j,getKpiValueColor as T,getKpiDelta as P,formatKpiValue as S}from"../utils/index.js";import{getKpiIcon as M}from"../utils/kpiIcon.js";import{AlertsViewTrigger as O}from"./Alerts/AlertsViewTrigger.js";var V=["#7c3aed","#FFC130","#F43F5E","#10b981","#3b82f6"];function E(l,i){return l?Math.max(80,Math.floor(l-96)):i}function R(R){var G,H,I,W,z,U,K,N,q,Z,_,J,Q,X,Y,$,ll,il,ol,el,nl,tl,dl,rl,al,ul,vl,sl,cl,pl,hl,gl,fl,ml,bl,yl,Cl,kl,xl,wl,Fl,Bl,Dl,Ll,Al,jl,Tl=R.baseUrl,Pl=R.configId,Sl=R.uiConfig,Ml=R.data,Ol=R.dataLoading,Vl=R.startDate,El=R.endDate,Rl=R.onDateChange,Gl=R.onRefresh,Hl=R.selectedKpis,Il=R.onKpiChange,Wl=R.sidebarVisible,zl=R.onSidebarShow,Ul=R.onSidebarHide,Kl=R.filterValues,Nl=R.onFilterChange,ql=R.onFilterReset,Zl=R.onFilterApply,_l=R.appliedFilters,Jl=R.graphEmptyState,Ql=R.tables,Xl=R.tableLayout,Yl=R.sectionOrder,$l=R.hiddenSections,li=R.tablePages,ii=R.onTableExpand,oi=R.onTableLoadMore,ei=R.pollingEnabled,ni=void 0!==ei&&ei,ti=R.selectedPreset,di=R.handlePresetChange,ri=R.metricCardConfig,ai=R.kpiCtaConfig,ui=R.tableCtaConfig,vi=R.activeThreshold,si=R.onThresholdViewChange,ci=R.onAlertsClick,pi=R.showAlerts,hi=R.onAlertClose,gi=R.accessToken,fi=R.authBaseUrl,mi=R.layout,bi=null!==(I=null===(H=null===(G=null==Sl?void 0:Sl.data)||void 0===G?void 0:G.dateFilters)||void 0===H?void 0:H.datepresets)&&void 0!==I?I:[],yi=d(function(){return bi.map(function(l){return h[l]}).filter(Boolean)},[JSON.stringify(bi)]),Ci=d(function(){return A(_l)},[_l]),ki=d(function(){var l,i,o=null==Xl?void 0:Xl.spans;if(o)return(null!==(i=null===(l=null==Sl?void 0:Sl.data)||void 0===l?void 0:l.tableBuilder)&&void 0!==i?i:[]).map(function(l,i){return Array.isArray(o)?o[i]:o[l.key]})},[null==Xl?void 0:Xl.spans,null===(W=null==Sl?void 0:Sl.data)||void 0===W?void 0:W.tableBuilder]),xi=null===(z=null==Sl?void 0:Sl.data)||void 0===z?void 0:z.graphBuilder,wi=function(i,e){var n=e?function(l,i){var o=l-112-18*i-12*(i-1),e=Array.from({length:i},function(l,o){return 0===o&&i>1?6:5}),n=e.reduce(function(l,i){return l+i},0);return e.map(function(l){return Math.max(80,Math.floor(o*l/n))})}(e,i.length):void 0;return o(c,{loading:Ol,emptyState:null!=Jl?Jl:o(p,{}),title:null==xi?void 0:xi.title,description:null==xi?void 0:xi.subtitle,icon:o(a,{size:18}),xAxis:{label:(null==xi?void 0:xi.axis.xAxisLabel)||"Date"},style:{chartHeight:n?n[0]:220},scrollable:ni,panes:i.map(function(i,e){return function(i,e,n){var t,d,r,u,v,s,c=Hl[i.key]||(null===(t=i.plotOptions[0])||void 0===t?void 0:t.key),p=Ml.graph.tier.find(function(l){return l.key===i.key}),h=(null===(d=null==p?void 0:p.referenceOptions)||void 0===d?void 0:d[c])||{},g=(null===(r=null==p?void 0:p.plotbyoptions)||void 0===r?void 0:r[c])||{},f=(null==i?void 0:i.series)||[],m=Object.keys(g),b=i.plotOptions.find(function(l){return l.value===c});return{key:i.key,selector:{label:"Plot By",value:c,onChange:function(l){Il(i.key,l)},options:i.plotOptions.map(function(l){return{label:l.label,value:l.value}}),triggerIcon:o(a,{size:16,color:0===e?"green":"purple"})},yAxis:{label:null==b?void 0:b.yAxisLabel,beginAtZero:"false"!==(null==c?void 0:c.yAxisBeginAtZero)},tooltip:{formatHeading:function(l){return"".concat(l)}},legend:{position:(null===(u=null==xi?void 0:xi.legend)||void 0===u?void 0:u.position)||"bottom",toggle:"yes"===(null===(v=null==xi?void 0:xi.legend)||void 0===v?void 0:v.allowToggle),align:(null===(s=null==xi?void 0:xi.legend)||void 0===s?void 0:s.alignment)||"center"},height:null!=n?n:0===e?300:250,series:m.map(function(i,o){var e,n,t,d,r=(null===(n=null===(e=null==p?void 0:p.plotbyoptions)||void 0===e?void 0:e[c])||void 0===n?void 0:n[i])||[],a=V[o%V.length],u=f.find(function(l){return l.key===i}),v=null===(d=null===(t=null==p?void 0:p.thresholds)||void 0===t?void 0:t[c])||void 0===d?void 0:d[null==u?void 0:u.key];return l(l(l({key:i,label:(null==u?void 0:u.name)||i,data:r,area:"yes"===(null==u?void 0:u.areaFill),curve:(null==u?void 0:u.curveType)||"linear",color:(null==u?void 0:u.color)?"#".concat(String(u.color).replace(/^#+/,"")):a,dashed:"dashed"===(null==u?void 0:u.style),strokeWidth:parseInt(null==u?void 0:u.strokeWidth)||2,showPoints:"yes"===(null==u?void 0:u.showPoints),kpiRole:null==u?void 0:u.kpiRole,pointRadius:parseInt(null==u?void 0:u.pointRadius)||3,showInLegend:!0},null!=(null==v?void 0:v.value)&&{threshold:v.value}),null!=(null==v?void 0:v.unit)&&{thresholdUnit:v.unit}),{valueFormatter:function(l){return"".concat(l)}})}),reference:h}}(i,e,null==n?void 0:n[e])}),activeThreshold:vi,onThresholdViewChange:si})},Fi=o("div",l({style:{padding:"4px"}},{children:wi(null!==(U=null==xi?void 0:xi.tiers)&&void 0!==U?U:[])})),Bi=function(l){var i,e,n,t=null===(i=null==Ml?void 0:Ml.kpiCards)||void 0===i?void 0:i[l.title],d=j(t)?T(t.currentValue,t.baselineValue,l.indicatorLogic):void 0,r=j(t)?P(t.currentValue,t.baselineValue,l.indicatorLogic):void 0,a=null!==(e=l.ctaKey)&&void 0!==e?e:l.key,u=a?null==ai?void 0:ai[a]:void 0;return o(v,{title:l.title,subtitle:l.subtitle,value:S(t,l.valueFormat),valueColor:d,delta:r&&{label:r.label,direction:r.direction,color:d},icon:M(l.icon),loading:Ol,showDelta:null===(n=null==ri?void 0:ri.showDelta)||void 0===n||n,cta:{ctaEnabled:Boolean(l.showActionButton),ctaText:l.actionButtonLabel,ctaOnClick:function(){return null==u?void 0:u(l)}}},l.title)},Di=o("div",l({style:{padding:"4px",display:"flex",gap:"10px",flexWrap:"wrap"}},{children:i([],null!==(N=null===(K=null==Sl?void 0:Sl.data)||void 0===K?void 0:K.kpiCards)&&void 0!==N?N:[],!0).sort(function(l,i){var o,e;return(null!==(o=l.displayOrder)&&void 0!==o?o:0)-(null!==(e=i.displayOrder)&&void 0!==e?e:0)}).map(Bi)})),Li=function(i){var e,n,d,r=null!==(n=null===(e=null==Ml?void 0:Ml.table)||void 0===e?void 0:e[i.key])&&void 0!==n?n:[],a=null==li?void 0:li[i.key],u=!!(null==a?void 0:a.loaded),v=u?a.rows:r,s=!u&&i.rowLimit&&i.rowLimit>0?r.slice(0,i.rowLimit):v,c=null==Ql?void 0:Ql[i.key],p=k(i,c),h=null==c?void 0:c.card,f=null==h?void 0:h.icon,m=M(i.icon),b=m&&t.isValidElement(m)?t.cloneElement(m,l(l({},null!=(null==f?void 0:f.size)?{size:f.size}:{}),(null==f?void 0:f.color)?{color:f.color}:{})):m,y=f?l(l(l({width:"auto",height:"auto"},f.color?{color:f.color}:{}),f.background?{background:f.background,padding:6,borderRadius:8}:{}),f.style):void 0,C=null!==(d=i.ctaKey)&&void 0!==d?d:i.key,w=C?null==ui?void 0:ui[C]:void 0;return o(g,{title:i.title,icon:b,styles:{root:null==h?void 0:h.root,header:null==h?void 0:h.header,title:null==h?void 0:h.title,icon:y},cta:{ctaEnabled:Boolean(i.showActionButton),ctaText:i.actionButtonLabel,ctaOnClick:function(){return null==w?void 0:w(i)}},onExpand:function(l){return null==ii?void 0:ii(i.key,l)},table:{rows:x(s),columns:p,loading:Ol,loadingMore:null==a?void 0:a.loading,hasMore:null==a?void 0:a.hasMore,onLoadMore:a?function(){return null==oi?void 0:oi(i.key)}:void 0,tableProps:null==c?void 0:c.tableProps}},i.key)},Ai=(null!==(_=null===(Z=null===(q=null==Sl?void 0:Sl.data)||void 0===q?void 0:q.tableBuilder)||void 0===Z?void 0:Z.length)&&void 0!==_?_:0)>0?o("div",l({style:{padding:"4px"}},{children:o(f,l({itemSpans:ki,totalColumns:null!==(J=null==Xl?void 0:Xl.totalColumns)&&void 0!==J?J:12,defaultSpan:null==Xl?void 0:Xl.defaultSpan,options:null!==(Q=null==Xl?void 0:Xl.options)&&void 0!==Q?Q:[1,2,3],defaultColumns:null==Xl?void 0:Xl.defaultColumns,columns:null==Xl?void 0:Xl.columns,onColumnsChange:null==Xl?void 0:Xl.onColumnsChange,showToggle:(null===(X=null==Xl?void 0:Xl.showToggle)||void 0===X||X)&&(null!==(ll=null===($=null===(Y=null==Sl?void 0:Sl.data)||void 0===Y?void 0:Y.tableBuilder)||void 0===$?void 0:$.length)&&void 0!==ll?ll:0)>1,toggleLabel:null==Xl?void 0:Xl.toggleLabel,minColumnWidth:null!==(il=null==Xl?void 0:Xl.minColumnWidth)&&void 0!==il?il:380,gap:null!==(ol=null==Xl?void 0:Xl.gap)&&void 0!==ol?ol:12,equalHeights:null===(el=null==Xl?void 0:Xl.equalHeights)||void 0===el||el},{children:Sl.data.tableBuilder.map(function(l){return Li(l)})}))})):null,ji=r(null);ji.current={kpi:function(l){return Bi(l)},graph:function(l,i){return wi(l,i.height)},table:function(l){return Li(l)},barChart:function(l,i){return Gi(l,i.height)},pieChart:function(l,i){return Ii(l,i.height)}};var Ti=null!=mi?mi:!1===(null===(tl=null===(nl=null==Sl?void 0:Sl.data)||void 0===nl?void 0:nl.components)||void 0===tl?void 0:tl.gridDesign)||null===(dl=null==Sl?void 0:Sl.data)||void 0===dl?void 0:dl.dashboardLayout,Pi=!0===(null==Ti?void 0:Ti.enabled),Si=null==Ti?void 0:Ti.extraWidgets,Mi=d(function(){if(!Pi)return[];var l={kpi:function(){for(var l,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return(l=ji.current).kpi.apply(l,i)},graph:function(){for(var l,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return(l=ji.current).graph.apply(l,i)},table:function(){for(var l,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return(l=ji.current).table.apply(l,i)},barChart:function(){for(var l,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return(l=ji.current).barChart.apply(l,i)},pieChart:function(){for(var l,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return(l=ji.current).pieChart.apply(l,i)}};return b({uiData:null==Sl?void 0:Sl.data,renderers:l,extraWidgets:Si})},[Pi,null==Sl?void 0:Sl.data,Si]),Oi=null!==(vl=null!==(al=null===(rl=null==Sl?void 0:Sl.data)||void 0===rl?void 0:rl.barCharts)&&void 0!==al?al:null===(ul=null==Sl?void 0:Sl.data)||void 0===ul?void 0:ul.barChartBuilder)&&void 0!==vl?vl:[],Vi=null!==(hl=null!==(cl=null===(sl=null==Sl?void 0:Sl.data)||void 0===sl?void 0:sl.pieCharts)&&void 0!==cl?cl:null===(pl=null==Sl?void 0:Sl.data)||void 0===pl?void 0:pl.pieChartBuilder)&&void 0!==hl?hl:[],Ei={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(380px, 1fr))",gap:12,alignItems:"start"},Ri=function(l,i){var o,e;return(null!==(o=l.displayOrder)&&void 0!==o?o:0)-(null!==(e=i.displayOrder)&&void 0!==e?e:0)},Gi=function(l,i){var e,n,t,d,r,a,u,v,s,c,p=B(D(null===(e=null==Ml?void 0:Ml.barChart)||void 0===e?void 0:e[l.key],l.columnName),l);return o(y,{data:p,title:l.title,description:l.subtitle||void 0,icon:M(null!==(n=l.icon)&&void 0!==n?n:void 0),color:null!==(t=l.color)&&void 0!==t?t:void 0,shadeMode:null!==(d=l.shadeMode)&&void 0!==d?d:void 0,xAxisLabel:(null===(r=l.axis)||void 0===r?void 0:r.xAxisLabel)||void 0,yAxisLabel:(null===(a=l.axis)||void 0===a?void 0:a.yAxisLabel)||void 0,yAxis:{max:null!==(v=null===(u=l.axis)||void 0===u?void 0:u.maxValue)&&void 0!==v?v:void 0},legend:{show:"yes"===l.showLegends},config:{showValueLabels:"yes"===l.showValueLabels,orientation:null!==(s=l.orientation)&&void 0!==s?s:void 0,sortBy:null!==(c=l.sortBy)&&void 0!==c?c:void 0},valueFormatter:function(i){return L(i,l.valueFormat)},style:{chartHeight:E(i,300),autoHeight:!i},loading:Ol},l.key)},Hi=Oi.length>0?o("div",l({style:{padding:"4px"}},{children:o("div",l({style:Ei},{children:i([],Oi,!0).sort(Ri).map(function(l){return Gi(l)})}))})):null,Ii=function(l,i){var e,n,t,d,r,a,u,v,s,c,p,h=B(D(null===(e=null==Ml?void 0:Ml.pieChart)||void 0===e?void 0:e[l.key],l.columnName),l);return o(C,{data:h,title:l.title,description:l.subtitle||void 0,icon:M(null!==(n=l.icon)&&void 0!==n?n:void 0),color:null!==(t=l.color)&&void 0!==t?t:void 0,shadeMode:null!==(d=l.shadeMode)&&void 0!==d?d:void 0,config:{variant:null!==(r=l.variant)&&void 0!==r?r:void 0,sortBy:null!==(a=l.sortBy)&&void 0!==a?a:void 0},center:{show:"no"!==l.showCenterTotal,label:l.centerLabel||void 0},legend:{show:"no"!==(null===(u=l.legend)||void 0===u?void 0:u.showLegends),position:null!==(s=null===(v=l.legend)||void 0===v?void 0:v.position)&&void 0!==s?s:void 0,showValue:"no"!==(null===(c=l.legend)||void 0===c?void 0:c.showValue),showPercent:"no"!==(null===(p=l.legend)||void 0===p?void 0:p.showPercent)},valueFormatter:function(i){return L(i,l.valueFormat)},style:{chartHeight:E(i,260)},loading:Ol},l.key)},Wi={graphBuilder:Fi,kpiCards:Di,barCharts:Hi,pieCharts:Vi.length>0?o("div",l({style:{padding:"4px"}},{children:o("div",l({style:Ei},{children:i([],Vi,!0).sort(Ri).map(function(l){return Ii(l)})}))})):null,tableBuilder:Ai},zi=w(Yl,$l,null===(gl=null==Sl?void 0:Sl.data)||void 0===gl?void 0:gl.sectionOrder,Object.keys(Wi)),Ui=F($l,"dateFilters"),Ki=F($l,"sidebarFilters");return o(e,pi?{children:o(O,{baseUrl:Tl||"",authBaseUrl:fi||"",configId:Pl,onClose:function(){return null==hi?void 0:hi(!1)},uiConfig:Sl,accessToken:gi})}:{children:n("div",l({style:{display:"flex",flexDirection:"column",gap:12,width:"100%"}},{children:[!Ui&&o("div",l({style:{padding:"4px"}},{children:o(u,{filterCount:Ci,initialStartDate:Vl,initialEndDate:El,onDateChange:Rl,onRefresh:Gl,onFilterClick:zl,presets:yi,datePickerProps:{from:{minDate:new Date(2025,0,1),maxDate:new Date},to:{minDate:Vl,maxDate:new Date}},defaultPresets:null===(fl=null==Sl?void 0:Sl.data)||void 0===fl?void 0:fl.dateFilters.defaultPreset,showLiveButton:"yes"===(null===(bl=null===(ml=null==Sl?void 0:Sl.data)||void 0===ml?void 0:ml.dateFilters)||void 0===bl?void 0:bl.showLiveButton),showFilterButton:!Ki&&"yes"===(null===(Cl=null===(yl=null==Sl?void 0:Sl.data)||void 0===yl?void 0:yl.dateFilters)||void 0===Cl?void 0:Cl.showFilterButton),showFilterCount:!Ki&&"yes"===(null===(xl=null===(kl=null==Sl?void 0:Sl.data)||void 0===kl?void 0:kl.dateFilters)||void 0===xl?void 0:xl.showFilterCount),liveDuration:null===(Fl=null===(wl=null==Sl?void 0:Sl.data)||void 0===wl?void 0:wl.dateFilters)||void 0===Fl?void 0:Fl.liveDurationMs,pollingEnabled:ni,selectedPreset:ti,handlePresetChange:di,showAlertsBtn:"yes"===(null===(Dl=null===(Bl=null==Sl?void 0:Sl.data)||void 0===Bl?void 0:Bl.dateFilters)||void 0===Dl?void 0:Dl.showAlertButton),onAlertsClick:ci})})),Pi?o("div",l({style:{padding:"4px"}},{children:o(m,{widgets:Mi,config:Ti})})):zi.map(function(l){return o(t.Fragment,{children:Wi[l]},l)}),!Ki&&o(s,{visible:Wl,onHide:Ul,onReset:ql,onApply:Zl,fields:null!==(jl=null===(Al=null===(Ll=null==Sl?void 0:Sl.data)||void 0===Ll?void 0:Ll.sidebarFilters)||void 0===Al?void 0:Al.map(function(l){var i,o,e,n,t=l.schemaFilterName,d="Single select"===l.type?"singleSelect":"Multi select"===l.type?"multiSelect":"Date Range"===l.type?"dateRange":"Date"===l.type?"date":"text",r=null!==(o=null===(i=l.options)||void 0===i?void 0:i.map(function(l){return{label:l,value:l}}))&&void 0!==o?o:[];return{id:t,label:l.label,hint:l.description,type:d,placeholder:l.placeholder,options:r,value:"multiSelect"===d?null!==(e=Kl[t])&&void 0!==e?e:[]:null!==(n=Kl[t])&&void 0!==n?n:"",onChange:function(l){return Nl(t,l)}}}))&&void 0!==jl?jl:[]})]}))})}export{R as ExecutiveDashboard,R as default};
|
|
2
2
|
//# sourceMappingURL=ExecutiveDashboard.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as l}from"../../../_virtual/_tslib.js";import{jsxs as n,jsx as i,Fragment as
|
|
1
|
+
import{__assign as e,__spreadArray as l}from"../../../_virtual/_tslib.js";import{jsxs as n,jsx as i,Fragment as o}from"react/jsx-runtime";import{useId as r,useState as t,useMemo as a}from"react";import s from"./LineChart.js";import d from"./GraphSkeleton.js";import c from"./PlotBySelector.js";import{colorForIndex as u}from"./types.js";function h(e){var l,n,o,r=e.config,a=void 0!==r.value,s=t(null!==(l=r.defaultValue)&&void 0!==l?l:null===(o=null===(n=r.options)||void 0===n?void 0:n[0])||void 0===o?void 0:o.value),d=s[0],u=s[1],h=a?r.value:d;return i(c,{config:r,value:h,onChange:function(e){var l;a||u(e),null===(l=r.onChange)||void 0===l||l.call(r,e)}})}function v(l){var o,r,t=l.pane,a=l.xAxis,d=l.sharedStyle,c=l.isLast,u=l.hiddenKeys,h=l.toggleSeries,v=l.syncId,m=l.reference,f=l.scrollable,p=void 0!==f&&f,g=l.onPointClick,y=l.activeThreshold,_=l.onThresholdViewChange,x=c?a:e(e({},a),{show:!1,label:void 0});return n("div",e({className:"ellm-graph__pane"},{children:[t.title&&i("div",e({className:"ellm-graph__pane-title"},{children:t.title})),i(s,{tier:null!==(o=t.key)&&void 0!==o?o:"primary",series:t.series,hiddenKeys:u,onToggleSeries:h,xAxis:x,yAxis:t.yAxis,tooltip:t.tooltip,legend:{show:!0},syncId:v,style:e(e({},d),{chartHeight:null!==(r=t.height)&&void 0!==r?r:null==d?void 0:d.chartHeight}),reference:m,scrollable:p,onPointClick:g,activeThreshold:y,onThresholdViewChange:function(e){return null==_?void 0:_(e,t)}})]}))}function m(c){var m,f,p=c.series,g=c.panes,y=c.title,_=c.description,x=c.icon,k=c.plotBy,N=c.xAxis,A=c.yAxis,C=c.tooltip,w=c.legend,S=c.config,b=c.style,T=c.emptyState,j=c.loading,P=c.scrollable,E=void 0!==P&&P,V=c.onPointClick,H=c.activeThreshold,I=c.onThresholdViewChange,K=!!(null==g?void 0:g.length),L=r(),R=t(function(){var e=new Set,l=(null!=p?p:[]).some(function(e){return void 0!==e.kpiRole})||(null!=g?g:[]).some(function(e){return e.series.some(function(e){return void 0!==e.kpiRole})}),n=function(n){l?"primary"!==n.kpiRole&&"secondary"!==n.kpiRole&&e.add(n.key):n.hidden&&e.add(n.key)};return(null!=p?p:[]).forEach(n),(null!=g?g:[]).forEach(function(e){return e.series.forEach(n)}),e}),B=R[0],G=R[1],W=function(e){return G(function(l){var n=new Set(l);return n.has(e)?n.delete(e):n.add(e),n})},M=!1!==(null==S?void 0:S.showHeader),q=a(function(){return K?g.some(function(e){return e.series.some(function(e){var l,n;return null===(n=null===(l=null==e?void 0:e.data)||void 0===l?void 0:l.some)||void 0===n?void 0:n.call(l,function(e){return null!=(null==e?void 0:e.y)})})}):(null!=p?p:[]).some(function(e){return e.data.some(function(e){return null!=e.y})})},[K,g,p]),z=a(function(){var l;if(!K)return b;var n=null!==(l=null==b?void 0:b.yAxisWidth)&&void 0!==l?l:g.some(function(e){var l;return null===(l=e.yAxis)||void 0===l?void 0:l.label})?64:48;return e(e({},b),{yAxisWidth:n})},[K,g,b]);a(function(){if(!K)return[];var e=[];return g.forEach(function(l){var n;!1!==(null===(n=l.legend)||void 0===n?void 0:n.show)&&l.series.forEach(function(l,n){var i;!1!==l.showInLegend&&e.push({key:l.key,label:l.label,color:null!==(i=l.color)&&void 0!==i?i:u(null==z?void 0:z.colors,n)})})}),e},[K,g,null==z?void 0:z.colors]);var D=l(l([],k?[k]:[],!0),K?g.flatMap(function(e){return e.selector?[e.selector]:[]}):[],!0),F=y||_||x||D.length>0;return n("div",e({className:"ellm-graph".concat((null==b?void 0:b.className)?" ".concat(b.className):""),style:null==b?void 0:b.container},{children:[M&&F&&n("div",e({className:"ellm-graph__header"},{children:[n("div",e({className:"ellm-graph__heading"},{children:[x&&i("span",e({className:"ellm-graph__icon"},{children:x})),n("div",{children:[y&&i("div",e({className:"ellm-graph__title"},{children:y})),_&&i("div",e({className:"ellm-graph__description"},{children:_}))]})]})),D.length>0&&i("div",e({className:"ellm-graph__controls"},{children:D.map(function(e,l){return i(h,{config:e},l)})}))]})),j?i(d,{height:null==b?void 0:b.chartHeight}):!q&&T?i("div",e({className:"ellm-graph__empty"},{children:T})):K?n(o,{children:[i("div",e({className:"ellm-graph__panes",style:{gap:null!==(m=null==b?void 0:b.paneGap)&&void 0!==m?m:12}},{children:g.map(function(e,l){var n;return i(v,{pane:e,xAxis:N,sharedStyle:z,isLast:l===g.length-1,hiddenKeys:B,toggleSeries:W,syncId:L,reference:e.reference,scrollable:E,onPointClick:V,activeThreshold:H,onThresholdViewChange:I},null!==(n=e.key)&&void 0!==n?n:"pane-".concat(l))})})),!1]}):i(s,{tier:"primary",series:null!=p?p:[],hiddenKeys:B,onToggleSeries:W,xAxis:N,yAxis:A,tooltip:C,legend:w,style:b,reference:null===(f=null==g?void 0:g[0])||void 0===f?void 0:f.reference,scrollable:E,onPointClick:V})]}))}export{m as default};
|
|
2
2
|
//# sourceMappingURL=Graph.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as e,__assign as l}from"../../../_virtual/_tslib.js";import{
|
|
1
|
+
import{__spreadArray as e,__assign as l}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as i}from"react/jsx-runtime";import{useState as o,useMemo as r}from"react";import{ComposedChart as t,CartesianGrid as a,XAxis as d,YAxis as u,ReferenceArea as c,ReferenceLine as v,Area as s,Line as f}from"recharts";import{ChartContainer as h,ChartTooltip as y,ChartTooltipContent as m,ChartLegend as p,ChartLegendContent as g}from"../ui/chart.js";import{colorForIndex as k}from"./types.js";import{compactNumber as x}from"../../utils/index.js";import b from"./Seperator.js";var w=function(e){return"number"==typeof e&&!Number.isNaN(e)},A=function(e){switch(e){case"linear":return"linear";case"step":return"stepAfter";default:return"monotone"}};function C(C){var L,T,S,F,D,E,K,N,W,I=C.tier,P=C.series,j=C.hiddenKeys,z=C.onToggleSeries,M=C.xAxis,R=C.yAxis,B=C.tooltip,_=C.legend,H=C.style,O=C.syncId,V=C.reference;C.scrollable;var G=C.onPointClick,U=C.activeThreshold,Z=C.onThresholdViewChange,q=null!==(L=null==H?void 0:H.chartHeight)&&void 0!==L?L:300,J=null!==(T=null==H?void 0:H.gridColor)&&void 0!==T?T:"#eef0f4",Q=null!==(S=null==H?void 0:H.axisColor)&&void 0!==S?S:"#d7dbe3",X=null!==(F=null==H?void 0:H.axisLabelColor)&&void 0!==F?F:"#6b7280",Y=null!==(D=null==H?void 0:H.tickColor)&&void 0!==D?D:"#9ca3af",$=null!==(E=null==H?void 0:H.fontFamily)&&void 0!==E?E:"Inter, system-ui, -apple-system, sans-serif",ee=o(null),le=ee[0],ne=ee[1],ie=r(function(){var l,n,i;if(null===(l=null==M?void 0:M.categories)||void 0===l?void 0:l.length)return{categories:M.categories,xType:null!==(n=M.type)&&void 0!==n?n:"category"};var o=new Set,r=[];P.forEach(function(e){return e.data.forEach(function(e){o.has(e.x)||(o.add(e.x),r.push(e.x))})});var t=r.every(w),a=null!==(i=null==M?void 0:M.type)&&void 0!==i?i:t?"number":"category";return{categories:"number"===a?e([],r,!0).sort(function(e,l){return Number(e)-Number(l)}):r,xType:a}},[P,null==M?void 0:M.categories,null==M?void 0:M.type]),oe=ie.categories,re=ie.xType,te=r(function(){var e=new Map;return P.forEach(function(l){var n=new Map;l.data.forEach(function(e){return n.set(e.x,e.y)}),e.set(l.key,n)}),oe.map(function(l){var n={x:l};return P.forEach(function(i){var o,r=null===(o=e.get(i.key))||void 0===o?void 0:o.get(l);n[i.key]=null==r?null:r}),n})},[P,oe]),ae=r(function(){var e={},l=P.map(function(l,n){var i,o=null!==(i=l.color)&&void 0!==i?i:k(null==H?void 0:H.colors,n);return e[l.key]={label:l.label,color:o,threshold:l.threshold,thresholdUnit:l.thresholdUnit},{series:l,color:o,index:n}});return{chartConfig:e,resolved:l}},[P,null==H?void 0:H.colors]),de=ae.chartConfig,ue=ae.resolved,ce=r(function(){var e={};return P.forEach(function(l){l.valueFormatter&&(e[l.key]=function(e,n){var i;return l.valueFormatter(e,null!==(i=null==n?void 0:n.payload)&&void 0!==i?i:{x:null==n?void 0:n.x,y:e})})}),e},[P]),ve=!1!==(null==B?void 0:B.enabled),se=(null==B?void 0:B.seriesKeys)?new Set(B.seriesKeys):null,fe=!1!==(null==_?void 0:_.show),he="top"===(null==_?void 0:_.position)?"top":"bottom",ye="start"===(null==_?void 0:_.align)?"left":"end"===(null==_?void 0:_.align)?"right":"center",me=!1!==(null==M?void 0:M.show),pe=!1!==(null==R?void 0:R.show),ge=!1!==(null==H?void 0:H.showGrid),ke=!!(null==H?void 0:H.showVerticalGrid),xe=r(function(){var l,n=P.filter(function(e){return!j.has(e.key)}),i=Math.max.apply(Math,e([0],te.flatMap(function(e){return n.map(function(l){return Number(e[l.key])||0})}),!1)),o=null==U?void 0:U[I],r=o?null===(l=de[o])||void 0===l?void 0:l.threshold:void 0;return void 0!==r&&r>i&&(i=r),i},[te,P,j,U,I,de]),be=r(function(){return Math.ceil(1.1*xe)},[xe]),we=[null!=(null==R?void 0:R.min)?R.min:!1!==(null==R?void 0:R.beginAtZero)?0:"auto",null!=(null==R?void 0:R.max)?R.max:be],Ae=null!==(K=null==H?void 0:H.yAxisWidth)&&void 0!==K?K:(null==R?void 0:R.label)?64:48,Ce={top:12,right:16,bottom:8,left:null!=(null==H?void 0:H.yAxisWidth)?0:(null==R?void 0:R.label)?16:0},Le=null!==(N=null==M?void 0:M.enableScroll)&&void 0!==N&&N,Te=null!==(W=null==M?void 0:M.minTickGap)&&void 0!==W?W:2;r(function(){if(!Le||!le||oe.length<=1)return"100%";var e=(oe.length-1)*Te+200;return e>le-Ae-Ce.left-Ce.right?"".concat(e,"px"):"100%"},[Le,le,oe.length,Te,Ae,Ce]);return n("div",l({style:{display:"flex",flexDirection:"column",width:"100%"}},{children:n(h,l({config:de,style:{height:q,fontFamily:$},ref:function(e){e&&null===le&&ne(e.clientWidth)}},{children:function(){var e,o;return i(t,l({data:te,margin:Ce,syncId:O},{children:[n(a,{vertical:ke,horizontal:ge,stroke:J}),n(d,{dataKey:"x",type:"number"===re?"number":"category",hide:!me,height:(null==M?void 0:M.label)?52:void 0,tickLine:!1,axisLine:!(null==M?void 0:M.hideLine)&&{stroke:Q},tickMargin:8,interval:"preserveStartEnd",tick:{fill:Y,fontSize:11},tickFormatter:(null==M?void 0:M.formatTick)?function(e,l){return M.formatTick(e,l)}:void 0,label:(null==V?void 0:V.showReferenceAreaLabel)?function(e){return function(e){var o=e.viewBox;e.startTick,e.endTick;var r=o.x,t=o.y,a=o.width,d=1;if((null==V?void 0:V.showReferenceArea)&&null!=(null==V?void 0:V.referencePoint)&&oe.length>1){var u=oe.indexOf(V.referencePoint);-1!==u&&(d=u/(oe.length-1))}var c=100*d,v=100-c;return n("foreignObject",l({x:r,y:t+24,width:a,height:40},{children:i("div",l({className:"ellm-graph__liveLabelContainer"},{children:[(null==V?void 0:V.referenceAreaLabel)&&i("div",l({style:{flex:c,display:"flex",alignItems:"center"}},{children:[n(b,{}),n("span",l({style:{padding:"0 12px",color:"#6b7280",fontSize:"12px"}},{children:null==V?void 0:V.referenceAreaLabel})),n(b,{})]})),v>0&&i("div",l({style:{flex:v,display:"flex",alignItems:"center"}},{children:[n(b,{style:{backgroundColor:"#DC2626"}}),i("div",l({className:"ellm-graph__liveLabel"},{children:[n(b,{style:{width:"8px",height:"8px",borderRadius:"100%",backgroundColor:"#DC2626",flex:"auto"},pulse:!0}),"LIVE - ",null==V?void 0:V.referenceAreaLiveLabel]})),n(b,{style:{backgroundColor:"#DC2626"}})]}))]}))}))}(l(l({},e),{startTick:oe[0],endTick:oe[oe.length-1]}))}:(null==M?void 0:M.label)?{value:M.label,position:"insideBottom",offset:4,fill:X,fontSize:12,fontWeight:500}:void 0}),n(u,{hide:!pe,domain:we,tickLine:!1,axisLine:!1===(null==R?void 0:R.hideLine)&&{stroke:Q},tickCount:null==R?void 0:R.tickCount,width:Ae,tick:{fill:Y,fontSize:11},tickFormatter:(null==R?void 0:R.formatTick)?function(e,l){return R.formatTick(e,l)}:function(e){return"number"==typeof e?x(e):String(e)},label:(null==R?void 0:R.label)?{value:R.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"},fill:X,fontSize:12,fontWeight:500}:void 0}),ve&&n(y,{cursor:{stroke:Q,strokeDasharray:"4 4"},content:function(e){var i,o=(null!==(i=e.payload)&&void 0!==i?i:[]).filter(function(e){var l=P.find(function(l){return l.key===e.dataKey});return!1!==(null==l?void 0:l.showInTooltip)&&!(se&&!se.has(String(e.dataKey)))});return(null==B?void 0:B.render)?B.render({x:e.label,points:o.map(function(l){var n;return{series:P.find(function(e){return e.key===l.dataKey}),value:null!==(n=l.value)&&void 0!==n?n:null,point:{x:e.label,y:l.value},color:l.color}})}):n(m,l({},e,{payload:o,hideLabel:!1===(null==B?void 0:B.showHeading),valueFormatters:ce,labelFormatter:(null==B?void 0:B.formatHeading)?function(e){return B.formatHeading(e)}:void 0}))}}),fe&&n(p,{verticalAlign:he,content:function(e){return n(g,l({},e,{tier:I,verticalAlign:he,align:ye,hiddenKeys:j,activeThreshold:U,onThresholdViewChange:Z,onItemClick:!1!==(null==_?void 0:_.toggle)&&z?z:void 0}))}}),(null==V?void 0:V.showReferenceArea)&&null!=(null==V?void 0:V.referencePoint)&&n(c,{x1:V.referencePoint,fill:null!==(e=V.referenceAreaFill)&&void 0!==e?e:"#2563EB1A"}),(null==V?void 0:V.showReferenceArea)&&null!=V.referencePoint&&n(v,{x:V.referencePoint,stroke:null!==(o=V.referenceLineStroke)&&void 0!==o?o:"#3B82F6",strokeDasharray:"4 4"}),(null==U?void 0:U[I])&&void 0!==de[null==U?void 0:U[I]].threshold&&n(v,{y:de[null==U?void 0:U[I]].threshold,stroke:"red",strokeWidth:1.5,strokeDasharray:"4 4",label:function(e){var i=e.viewBox;return n("text",l({x:i.x-8,y:i.y,textAnchor:"end",dominantBaseline:"middle",fill:"red",fontSize:11},{children:de[null==U?void 0:U[I]].threshold}))}}),ue.map(function(e){var i,o,r,t,a=e.series,d=j.has(a.key),u="var(--color-".concat(a.key,")"),c=!0===a.dashed?"6 5":"string"==typeof a.dashed?a.dashed:void 0,v=!1!==a.showPoints&&{r:null!==(i=a.pointRadius)&&void 0!==i?i:3,fill:"#fff",stroke:u,strokeWidth:2},h=l({r:(null!==(o=a.pointRadius)&&void 0!==o?o:3)+2},G&&{onClick:function(e,l){var n,i;return function(e,l,n){if(G){var i=P.find(function(l){return l.key===e});i&&G({series:i,point:{x:null==l?void 0:l.x,y:null==l?void 0:l[e]},index:n})}}(a.key,null!==(n=null==l?void 0:l.payload)&&void 0!==n?n:l,null!==(i=null==l?void 0:l.index)&&void 0!==i?i:0)}}),y={key:a.key,dataKey:a.key,name:a.key,type:A(a.curve),stroke:u,strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:2,strokeDasharray:c,connectNulls:!1,isAnimationActive:!1,hide:d,dot:v,activeDot:h};return a.area?n(s,l({},y,{fill:u,fillOpacity:null!==(t=a.areaOpacity)&&void 0!==t?t:.12})):n(f,l({},y))})]}))}()}))}))}export{C as default};
|
|
2
2
|
//# sourceMappingURL=LineChart.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as r}from"../../../_virtual/_tslib.js";import{resolveBarColors as
|
|
1
|
+
import{__spreadArray as r,__assign as e}from"../../../_virtual/_tslib.js";import{resolveBarColors as t}from"../BarChart/utils.js";export{darken,parseColor,withAlpha,withIntensity}from"../BarChart/utils.js";import{DEFAULT_PIE_COLOR as n}from"./types.js";var u=function(r){return"number"==typeof r&&Number.isFinite(r)&&r>0};function l(r,e,u,l){return void 0===e&&(e=n),void 0===u&&(u="rank"),void 0===l&&(l=[.18,1]),t(r,e,u,l)}function i(r){return r.reduce(function(r,e){return u(e.value)?r+e.value:r},0)}function o(r,e){return e>0?r/e*100:0}function a(t,n){var l,i=n.limit,o=n.othersLabel,a=void 0===o?"Others ({count} items)":o,v=n.othersColor,f=(null!=t?t:[]).filter(function(r){return u(r.value)});if(f.length<=i)return null!=t?t:[];var c=r([],f,!0).sort(function(r,e){return e.value-r.value}),s=c.slice(0,i),m=c.slice(i);if(m.length<=1)return null!=t?t:[];var d=a.replace("{count}",String(m.length)),p=m.reduce(function(r,e){return r+e.value},0),h=s.findIndex(function(r){return r.label===d});if(-1!==h){var b=r([],s,!0),g=b[h];return b[h]=e(e({},g),{value:g.value+p,meta:e(e({},null!==(l=g.meta)&&void 0!==l?l:{}),{grouped:m})}),b}return r(r([],s,!0),[{label:d,value:p,color:v,meta:{grouped:m}}],!1)}function v(r,e){if(!(null==r?void 0:r.length))return[];var t=e.labelKey,n=e.valueKey,u=e.colorKey;return r.map(function(r){var e,l=r[n],i="string"==typeof l?Number(l):l;return{label:String(null!==(e=r[t])&&void 0!==e?e:""),value:"number"==typeof i&&Number.isFinite(i)?i:null,color:u?r[u]:void 0,meta:r}})}export{a as groupTopSlices,u as isPlottableSlice,o as percentOf,l as resolveSliceColors,i as sumSlices,v as toPieChartData};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|