@pablo-amberflo/ui-kit-test-pablo
Version:
Amberflo UI Kit
2 lines (1 loc) • 11 kB
JavaScript
"use strict";var e=require("react"),t=require("@mui/material"),l=require("./styled-19d0c372.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=a(e),i=function(e,t,l){if(void 0===e&&(e=0),void 0===t&&(t=!1),void 0===l&&(l=2),0===e||Number.isNaN(e))return"0";if("-"===e||"--"===e)return e;var a=t?e.toFixed(l):e.toFixed(0);return new Intl.NumberFormat("en-US",{minimumFractionDigits:Number.isInteger(e)?0:2}).format(parseFloat(a))},o=l.createTheme({palette:{primary:{main:"#1565c0",light:"#1E88E5",dark:"#0D47A1"},secondary:{main:"#F9FBFF",light:"#DAE9F8",dark:"#75ACE4"}},typography:{fontFamily:"Nunito",h1:{fontSize:"32px",fontWeight:600,fontStretch:"normal",fontStyle:"normal",lineHeight:1.2,letterSpacing:"-0.22px"},h2:{fontSize:"28px",fontWeight:600,fontStretch:"normal",fontStyle:"normal",lineHeight:1.2,letterSpacing:"-0.23px"},h3:{fontSize:"24px",fontWeight:600,fontStretch:"normal",fontStyle:"normal",lineHeight:1.2,letterSpacing:"normal"},h4:{fontSize:"20px",fontWeight:600,fontStretch:"normal",fontStyle:"normal",lineHeight:1.2,letterSpacing:"0.04px"},h5:{fontSize:"20px",fontWeight:"normal",fontStretch:"normal",fontStyle:"normal",lineHeight:1.2,letterSpacing:"normal"},h6:{fontSize:"17px",fontWeight:600,fontStretch:"normal",fontStyle:"normal",lineHeight:1.2,letterSpacing:"-0.06px"},subtitle1:{fontSize:"16px",fontWeight:600,fontStretch:"normal",fontStyle:"normal",lineHeight:1.75,letterSpacing:"0.09px"},subtitle2:{fontSize:"14px",fontWeight:600,fontStretch:"normal",fontStyle:"normal",lineHeight:1.43,letterSpacing:"0.07px"},body1:{fontSize:"16px",fontWeight:"normal",fontStretch:"normal",fontStyle:"normal",lineHeight:1.5,letterSpacing:"0.08px"},body2:{fontSize:"14px",fontWeight:"normal",fontStretch:"normal",fontStyle:"normal",lineHeight:1.43,letterSpacing:"0.1px"},caption:{fontSize:"12px",fontWeight:"normal",fontStretch:"normal",fontStyle:"normal",lineHeight:1.66,letterSpacing:"0.3px"},overline:{fontSize:"12px",fontWeight:"normal",fontStretch:"normal",fontStyle:"normal",lineHeight:2.58,letterSpacing:"0.83px"},button:{fontSize:"14px",fontWeight:600,fontStretch:"normal",fontStyle:"normal",lineHeight:1.71,letterSpacing:"0.3px"}},success:{main:"#4caf50",light:"#e6f4e6",dark:"#388e3c"},warning:{main:"#ff9800",light:"#FFB74D",lighter:"#ffe9c9",dark:"#f57c00",background:"#fffbf6"},error:{main:"#f44336",light:"#ffefef",dark:"#d32f2f"},info:{main:"#1565c0",medium:"#1E88E5",light:"#f9fbff"},neutral:{main:"#808080",medium:"#D0D0D1",light:"#e0e0e0"},text:{primary:"rgba(0,0,0,0.87)",secondary:"#808080",disabled:"#b2b2b2",light:"#ffffff",informative:"#eeeeee",link:"#1565c0",dark:"#212121"},action:{primary:"#1565c0",secondary:"#5c8dd1",active:"#dae9f8",hover:"rgba(255,255,255,0.2)",selected:"#1565c0",loading:"#729CE4"},background:{clear:{main:"#f9f9fc",light:"#ffffff",dark:"#f6f6f6"},obscure:{main:"#1b2430",light:"#232f3e",dark:"#121820"},modal:{main:"#ffffff",light:"#eeeeee",darkOpacity:"rgba(0,0,0,0.5)"},table:{highlight:"#f5fbff",selected:"#f3f8fe"},pieChart:{colors:["#5a6acf","#7483e3","#929ff5","#adb7f5","#c7ceff","#eeeeee"]}},dividers:{main:"#cccccc",dark:"#b2b2b2",light:"#eee",shadow:"rgba(0, 0, 0, 0.12)"},border:{light:"#4791db",main:"#e8e7ea",dark:"#cccccc",disabled:"#e0e0e0"},scrollBar:{dark:"#808080",borderRadius:"9px"},components:{MuiTable:{root:{borderCollapse:"unset"}},MuiTableCell:{sizeSmall:{padding:"1rem"}},MuiSelect:{root:{padding:"6px"},iconOutlined:{color:"black"},outlined:{paddingLeft:"1rem"}},MuiPaper:{root:{boxShadow:"none"}}}});l.createTheme({typography:{h1:"32px",h2:"28px",h3:"24px",h4:"20px",h5:"20px",h6:"17px",subtitle1:"16px",body1:"16px",body2:"14px",caption:"12px",overline:"12px",button:"14px"},components:{sidebar:"16rem",maxContainerWidth:"1560px"}});var n=function(){return n=Object.assign||function(e){for(var t,l=1,a=arguments.length;l<a;l++)for(var r in t=arguments[l])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},n.apply(this,arguments)},d=o,f=l.styled(t.TableCell,{shouldForwardProp:function(e){return"isSticky"!==e&&"withBorders"!==e}})((function(e){var t=e.isSticky,l=e.withBorders,a={minWidth:"150px",fontWeight:"600",fontSize:"1.2rem",borderBottom:"1px solid ".concat(d.dividers.dark),width:"fit-content"};return l&&(a=n(n({},a),{borderRight:"1px solid ".concat(d.dividers.main)})),t&&(a=n(n({},a),{position:"sticky",left:0,zIndex:4,background:"white",boxShadow:"2px 0px 4px ".concat(d.dividers.shadow)})),a})),c=l.styled(t.Paper)({width:"100%",height:"fit-content"}),s=l.styled(t.TableContainer,{shouldForwardProp:function(e){return"hasItems"!==e}})((function(e){return e.hasItems?{width:"fit-content",maxWidth:"100%",maxHeight:"100%","&::-webkit-scrollbar":{height:"4px",flexGrow:"0",backgroundColor:d.border.dark,borderRadius:d.scrollBar.borderRadius},"&::-webkit-scrollbar-thumb":{height:"100%",flexGrow:"0",backgroundColor:d.scrollBar.dark,borderRadius:d.scrollBar.borderRadius},table:{borderCollapse:"separate"}}:null})),u=l.styled(t.TableRow)({boxShadow:"0px 2px 4px ".concat(d.dividers.shadow)}),m=l.styled(t.TableRow)({width:"100%",display:"flex",textAlign:"center",fontSize:"1rem",color:d.text.primary,opacity:"0.8",height:"8rem",justifyContent:"center",alignItems:"center"}),h=l.styled(t.TableRow,{shouldForwardProp:function(e){return"isSelected"!==e&&"isClickable"!==e}})((function(e){var t=e.isSelected,l=e.isClickable,a={};return t&&(a.backgroundColor=d.background.table.selected),l&&(a.pointer="cursor"),a})),p=l.styled(t.TableCell,{shouldForwardProp:function(e){return"isSticky"!==e&&"hasAction"!==e&&"isSelected"!==e&&"withBorders"!==e}})((function(e){var t=e.isSticky,l=e.hasAction,a=void 0!==l&&l,r=e.isSelected,i={};return e.withBorders&&(i=n(n({},i),{borderRight:"1px solid ".concat(d.dividers.main)})),t&&(i=n(n({},i),{position:"sticky",left:0,zIndex:2,background:"white",boxShadow:"2px 0px 4px ".concat(d.dividers.shadow)})),a&&(i=n(n({},i),{fontSize:"14px",fontWeight:"600",fontStretch:"normal",fontStyle:"normal",lineHeight:"1.43",letterSpacing:"0.07px",color:d.text.link,width:"4rem",cursor:"pointer"})),r&&(i.backgroundColor=d.background.table.selected),i})),g=l.styled(t.Typography)({fontSize:"14px",fontWeight:600,fontStretch:"normal",fontStyle:"normal",lineHeight:1.43,letterSpacing:"0.07px"}),b=l.styled("div")({paddingTop:"1rem"}),x=l.styled("div")({fontSize:"14px",fontWeight:"normal",fontStretch:"normal",fontStyle:"normal",lineHeight:"1.57",letterSpacing:"0.25px",textAlign:"right",paddingRight:"2px",boxSizing:"border-box"}),S=l.styled("div",{shouldForwardProp:function(e){return"isPositive"!==e}})((function(e){var t=e.isPositive;return{color:d[t?"success":"error"].main}})),y=[{measure:"ApiCalls",label:"ApiCalls",firstColumn:"ApiCalls",customRow:!0,date_1:{value:50241,diff_from_last:"-"},date_2:{value:65034,diff_from_last:29.444079536633428},date_3:{value:63865,diff_from_last:-1.7975212965525724},date_4:{value:57315,diff_from_last:-10.256008768496047},date_5:{value:63539,diff_from_last:10.85928639972084},date_6:{value:75212,diff_from_last:18.37139394702466},date_7:{value:77756,diff_from_last:3.3824389725043877},date_8:{value:58218,diff_from_last:-25.127321364267708}},{measure:"cluster_count",label:"Cluster_Count",firstColumn:"cluster_count",customRow:!0,date_1:{value:1080,diff_from_last:"-"},date_2:{value:1200,diff_from_last:11.11111111111111},date_3:{value:1128,diff_from_last:-6},date_4:{value:1272,diff_from_last:12.76595744680851},date_5:{value:1080,diff_from_last:-15.09433962264151},date_6:{value:1272,diff_from_last:17.77777777777778},date_7:{value:1272,diff_from_last:"-"},date_8:{value:816,diff_from_last:-35.84905660377358}}],v=[{id:"firstColumn",label:"Meter",align:"left"},{id:"date_1",label:"1/17",align:"right"},{id:"date_2",label:"1/18",align:"right"},{id:"date_3",label:"1/19",align:"right"},{id:"date_4",label:"1/20",align:"right"},{id:"date_5",label:"1/21",align:"right"},{id:"date_6",label:"1/22",align:"right"},{id:"date_7",label:"1/23",align:"right"},{id:"date_8",label:"1/24",align:"right"}],_=function(e){var t,l=e.row,a=e.column,o=e.rowIndex,n=e.columnIndex,d=e.hasAction,f=e.withBorders,c=e.stickyFirstColumn,s=e.isSelected,u=e.diffFromLastMaxDecimals,m=l[a.id]||{value:0,diff_from_last:"-"},h=m.value,g=m.diff_from_last;"-"===g?t=g:t="".concat(g>0?"+":"").concat(i(g,!0,u),"%");return"firstColumn"===a.id?r.default.createElement(p,{key:"".concat(o,"_").concat(n),align:a.align,isSticky:c,withBorders:f,hasAction:d,isSelected:s},r.default.createElement("div",null,r.default.createElement("div",null,l.label))):r.default.createElement(p,{key:"".concat(o,"_").concat(n),align:a.align,isSticky:!1,withBorders:f,isSelected:s},r.default.createElement(b,null,r.default.createElement(x,null,"$",i(h,!0)),r.default.createElement("div",null,Number.isNaN(parseFloat(t))?t:r.default.createElement(S,{isPositive:parseFloat(t)>0},t))))};exports.Cell=p,exports.ColoredValue=S,exports.DataContainer=b,exports.DataTable=function(e){var l=e.columns,a=void 0===l?v:l,i=e.rows,o=void 0===i?y:i,n=e.handleRowClick,d=e.getCustomHeaderCell,b=e.selectedRowIndex,x=e.getCustomRowCell,S=void 0===x?_:x,w=e.withBorders,k=void 0!==w&&w,C=e.stickyFirstColumn,E=void 0!==C&&C,F=e.diffFromLastMaxDecimals,z=void 0===F?0:F;return r.default.createElement("div",null,r.default.createElement(c,null,r.default.createElement(s,{hasItems:!!o.length},r.default.createElement(t.Table,{"aria-label":"sticky table"},r.default.createElement(t.TableHead,null,r.default.createElement(u,null,0!==a.length&&a.map((function(e,t){return Object.prototype.hasOwnProperty.call(e,"customHeader")?null==d?void 0:d(e,t):r.default.createElement(f,{key:e.id,align:e.align,isSticky:E&&0===t,withBorders:k},r.default.createElement(g,null,e.label))})))),r.default.createElement(t.TableBody,null,!o.length&&r.default.createElement(m,{key:"emptyTable"},r.default.createElement("td",null,"No Data Available")),0!==o.length&&o.map((function(e,t){return r.default.createElement(h,{key:t,hover:"function"==typeof n,role:"checkbox",tabIndex:-1,isSelected:b===t,isClickable:"function"==typeof n,onClick:function(){null==n||n(e,t,a)}},Object.prototype.hasOwnProperty.call(e,"colSpan")?r.default.createElement(r.default.Fragment,null,S({row:e,column:a[0],rowIndex:t,columnIndex:0,hasAction:!!n,withBorders:k,stickyFirstColumn:E,isSelected:b===t,diffFromLastMaxDecimals:z}),r.default.createElement(p,{colSpan:a.length-1,isSticky:E,hasAction:!!n,isSelected:b===t,withBorders:k})):a.map((function(l,a){return Object.prototype.hasOwnProperty.call(e,"customRow")?S({row:e,column:l,rowIndex:t,columnIndex:a,hasAction:!!n,withBorders:k,stickyFirstColumn:E,isSelected:b===t,diffFromLastMaxDecimals:z}):r.default.createElement(p,{key:l.id,align:l.align,isSticky:E,hasAction:!!n,isSelected:b===t,withBorders:k},e[l.id])})))})))))))},exports.DataTableVariants={amberflo:{withBorders:!0,stickyFirstColumn:!0,diffFromLastMaxDecimals:2}},exports.DataValue=x,exports.EmptyTable=m,exports.HeaderTableCell=f,exports.MainContainer=c,exports.Row=h,exports.Subtitle2=g,exports.TableHeader=u,exports.Wrapper=s;