@while-and-for/tremor-react
Version:
The React library to build dashboards faster.
2 lines (1 loc) • 2.25 kB
JavaScript
import e from"react";import{BaseColors as r}from"../../../lib/constants.js";import{border as t}from"../../../lib/shape.js";import{sizing as a}from"../../../lib/sizing.js";import{spacing as o}from"../../../lib/spacing.js";import{colorPalette as m}from"../../../lib/theme.js";import{getColorClassNames as d,defaultValueFormatter as s}from"../../../lib/utils.js";import{tremorTwMerge as l}from"../../../lib/tremorTwMerge.js";const n=({children:r})=>e.createElement("div",{className:l("rounded-tremor-default text-tremor-default","bg-tremor-background shadow-tremor-dropdown border-tremor-border","dark:bg-dark-tremor-background dark:shadow-dark-tremor-dropdown dark:border-dark-tremor-border",t.sm.all)},r),i=({value:r,name:t})=>e.createElement("div",{className:"flex items-center justify-between space-x-8"},e.createElement("div",{className:"flex items-center space-x-2"},e.createElement("p",{className:l("text-right whitespace-nowrap","text-tremor-content","dark:text-dark-tremor-content")},t)),e.createElement("p",{className:l("font-medium tabular-nums text-right whitespace-nowrap","text-tremor-content-emphasis","dark:text-dark-tremor-content-emphasis")},r)),c=({label:c,active:p,payload:b,valueFormatter:u,axis:k,category:g,categoryColors:f})=>{var h;return p&&b?e.createElement(n,null,e.createElement("div",{className:l("flex items-center space-x-2","border-tremor-border","dark:border-dark-tremor-border",o.twoXl.paddingX,o.sm.paddingY,t.sm.bottom)},e.createElement("span",{className:l("shrink-0 rounded-tremor-full","border-tremor-background shadow-tremor-card","dark:border-dark-tremor-background dark:shadow-dark-tremor-card",d(g&&null!==(h=f.get(b[0].payload[g]))&&void 0!==h?h:r.Blue,m.background).bgColor,a.sm.height,a.sm.width,t.md.all)}),e.createElement("p",{className:l("font-medium","text-tremor-content-emphasis","dark:text-dark-tremor-content-emphasis")},c)),e.createElement("div",{className:l(o.twoXl.paddingX,o.sm.paddingY,"space-y-1")},b.map((({value:r,name:t},a)=>{var o,m;const d=null!==(o=Object.keys(k).find((e=>k[e]===t)))&&void 0!==o?o:"",l=null!==(m=u[d])&&void 0!==m?m:s;return e.createElement(i,{key:`id-${a}`,value:u&&l?l(r):`${r}`,name:t})})))):null};export{n as ChartTooltipFrame,i as ChartTooltipRow,c as default};