@ammarkhalidfarooq/dashboard-package 0.6.98 → 0.6.100

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.
@@ -134,7 +134,12 @@ var MetricCard = function MetricCard(_ref) {
134
134
  width: 30,
135
135
  height: 30,
136
136
  bgcolor: warning ? "#FFF3CF" : error ? "#fee2e2" : "#EEF2FF",
137
- color: warning ? "#B45309" : error ? "#ef4444" : "#4F46E5"
137
+ color: warning ? "#B45309" : error ? "#ef4444" : "#4F46E5",
138
+ p: 0.625,
139
+ "& .MuiSvgIcon-root, & svg": {
140
+ width: "100%",
141
+ height: "100%"
142
+ }
138
143
  }, avatarSx),
139
144
  children: icon
140
145
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"MetricCard.cjs.js","sources":["../src/config/helper.js","../src/components/advanced/MetricCard/index.jsx"],"sourcesContent":["export const TREND_UP_COLOR = \"#22C55E\";\r\nexport const TREND_DOWN_COLOR = \"#EF4444\";\r\n\r\nexport function getTrendDirection(valueOrText) {\r\n const text = String(valueOrText ?? \"\").trim();\r\n if (text.includes(\"▼\")) return \"down\";\r\n if (text.includes(\"▲\")) return \"up\";\r\n\r\n const match = text.match(/-?\\d+(\\.\\d+)?/);\r\n if (!match) return \"neutral\";\r\n\r\n const n = Number(match[0]);\r\n if (n < 0) return \"down\";\r\n if (n > 0) return \"up\";\r\n return \"neutral\";\r\n}\r\n\r\nexport function getTrendColor(\r\n valueOrText,\r\n { up = TREND_UP_COLOR, down = TREND_DOWN_COLOR, neutral = up } = {}\r\n) {\r\n const direction = getTrendDirection(valueOrText);\r\n if (direction === \"down\") return down;\r\n if (direction === \"up\") return up;\r\n return neutral;\r\n}\r\n\r\nexport function getTrendArrow(valueOrText) {\r\n const direction = getTrendDirection(valueOrText);\r\n if (direction === \"down\") return \"▼\";\r\n if (direction === \"up\") return \"▲\";\r\n return \"\";\r\n}\r\n\r\nexport function formatCurrency(value) {\r\n return `$${Number(value ?? 0).toLocaleString(\"en-US\")}`;\r\n}\r\n\r\nexport function formatNumber(num) {\r\n if (num >= 1_000_000_000) {\r\n return (num / 1_000_000_000).toFixed(1).replace(/\\.0$/, \"\") + \"B\";\r\n }\r\n\r\n if (num >= 1_000_000) {\r\n return (num / 1_000_000).toFixed(1).replace(/\\.0$/, \"\") + \"M\";\r\n }\r\n\r\n if (num >= 1_000) {\r\n return (num / 1_000).toFixed(1).replace(/\\.0$/, \"\") + \"K\";\r\n }\r\n\r\n return (num ?? 0).toString();\r\n}","import { Avatar, Box, Stack, Typography } from \"@mui/material\";\r\nimport { getTrendColor, getTrendDirection } from \"../../../config/helper\";\r\n\r\n\r\nconst MetricCard = ({\r\n title,\r\n value,\r\n caption,\r\n icon,\r\n active,\r\n warning,\r\n error,\r\n onClick,\r\n sx = {},\r\n titleSx = {},\r\n valueSx = {},\r\n captionSx = {},\r\n avatarSx = {},\r\n}) => {\r\n const captionText = String(caption ?? \"\");\r\n const isPercentCaption = captionText.includes(\"%\");\r\n const trendDirection = isPercentCaption ? getTrendDirection(captionText) : \"neutral\";\r\n const hasTrendArrow = captionText.includes(\"▼\") || captionText.includes(\"▲\");\r\n const trendPrefix =\r\n hasTrendArrow || !isPercentCaption\r\n ? \"\"\r\n : trendDirection === \"down\"\r\n ? \"▼ \"\r\n : trendDirection === \"up\"\r\n ? \"▲ \"\r\n : \"\";\r\n const captionColor = captionText.includes(\"failed\")\r\n ? \"#4F46E5\"\r\n : error\r\n ? \"#ef4444\"\r\n : isPercentCaption\r\n ? getTrendColor(captionText, { up: \"#0B8F61\", down: \"#ef4444\" })\r\n : \"#0B8F61\";\r\n\r\n return (\r\n <Box\r\n sx={{\r\n bgcolor: \"#fff\",\r\n border: `1.5px solid ${active ? \"#4F46E5\" : warning ? \"#F3B33D\" : error ? \"#ef4444\" : \"#F1F1F5\"}`,\r\n borderRadius: \"16px\",\r\n p: { xs: 1.75, md: 2 },\r\n paddingTop: \"10px !important\", paddingBottom: \"10px !important\",\r\n height: 92,\r\n boxShadow: \"0 14px 30px rgba(21, 26, 45, 0.06)\",\r\n ...sx,\r\n }}\r\n onClick={onClick}\r\n >\r\n <Stack\r\n direction=\"row\"\r\n justifyContent=\"space-between\"\r\n alignItems=\"center\"\r\n >\r\n <Typography\r\n sx={{\r\n color: active ? \"#818CF8\" : \"#999EAA\",\r\n fontSize: 13,\r\n fontWeight: 500,\r\n letterSpacing: 0,\r\n ...titleSx,\r\n }}\r\n >\r\n {title}\r\n </Typography>\r\n <Avatar\r\n sx={{\r\n width: 30,\r\n height: 30,\r\n bgcolor: warning ? \"#FFF3CF\" : error ? \"#fee2e2\" : \"#EEF2FF\",\r\n color: warning ? \"#B45309\" : error ? \"#ef4444\" : \"#4F46E5\",\r\n ...avatarSx,\r\n }}\r\n >\r\n {icon}\r\n </Avatar>\r\n </Stack>\r\n <Typography\r\n sx={{\r\n fontSize: 22,\r\n fontWeight: 700,\r\n color: active ? \"#4F46E5\" : \"#050509\",\r\n lineHeight: 1.15,\r\n ...valueSx,\r\n }}\r\n >\r\n {value}\r\n </Typography>\r\n <Typography\r\n sx={{\r\n fontSize: 12,\r\n fontWeight: 500,\r\n color: captionColor,\r\n ...captionSx,\r\n }}\r\n >\r\n {`${trendPrefix}${captionText}`}\r\n </Typography>\r\n </Box>\r\n );\r\n};\r\n\r\nexport default MetricCard;\r\n"],"names":["TREND_UP_COLOR","TREND_DOWN_COLOR","getTrendDirection","valueOrText","text","String","trim","includes","match","n","Number","getTrendColor","_ref","arguments","length","undefined","_ref$up","up","_ref$down","down","_ref$neutral","neutral","direction","MetricCard","title","value","caption","icon","active","warning","error","onClick","_ref$sx","sx","_ref$titleSx","titleSx","_ref$valueSx","valueSx","_ref$captionSx","captionSx","_ref$avatarSx","avatarSx","captionText","isPercentCaption","trendDirection","hasTrendArrow","trendPrefix","captionColor","_jsxs","Box","_objectSpread","bgcolor","border","concat","borderRadius","p","xs","md","paddingTop","paddingBottom","height","boxShadow","children","Stack","justifyContent","alignItems","_jsx","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AAI,OAAA,EACbrC,OAAO,CACV;AAAAyB,MAAAA,QAAA,EAEDrC;AAAK,KACI,CAAC,eACXyC,cAAA,CAACC,mBAAU,EAAA;AACTlC,MAAAA,EAAE,EAAAiB,cAAA,CAAA;AACAmB,QAAAA,QAAQ,EAAE,EAAE;AACZC,QAAAA,UAAU,EAAE,GAAG;AACfF,QAAAA,KAAK,EAAErB;AAAY,OAAA,EAChBR,SAAS,CACZ;AAAAuB,MAAAA,QAAA,KAAAT,MAAA,CAEEP,WAAW,CAAA,CAAAO,MAAA,CAAGX,WAAW;AAAA,KACnB,CAAC;AAAA,GACV,CAAC;AAEV;;;;"}
1
+ {"version":3,"file":"MetricCard.cjs.js","sources":["../src/config/helper.js","../src/components/advanced/MetricCard/index.jsx"],"sourcesContent":["export const TREND_UP_COLOR = \"#22C55E\";\r\nexport const TREND_DOWN_COLOR = \"#EF4444\";\r\n\r\nexport function getTrendDirection(valueOrText) {\r\n const text = String(valueOrText ?? \"\").trim();\r\n if (text.includes(\"▼\")) return \"down\";\r\n if (text.includes(\"▲\")) return \"up\";\r\n\r\n const match = text.match(/-?\\d+(\\.\\d+)?/);\r\n if (!match) return \"neutral\";\r\n\r\n const n = Number(match[0]);\r\n if (n < 0) return \"down\";\r\n if (n > 0) return \"up\";\r\n return \"neutral\";\r\n}\r\n\r\nexport function getTrendColor(\r\n valueOrText,\r\n { up = TREND_UP_COLOR, down = TREND_DOWN_COLOR, neutral = up } = {}\r\n) {\r\n const direction = getTrendDirection(valueOrText);\r\n if (direction === \"down\") return down;\r\n if (direction === \"up\") return up;\r\n return neutral;\r\n}\r\n\r\nexport function getTrendArrow(valueOrText) {\r\n const direction = getTrendDirection(valueOrText);\r\n if (direction === \"down\") return \"▼\";\r\n if (direction === \"up\") return \"▲\";\r\n return \"\";\r\n}\r\n\r\nexport function formatCurrency(value) {\r\n return `$${Number(value ?? 0).toLocaleString(\"en-US\")}`;\r\n}\r\n\r\nexport function formatNumber(num) {\r\n if (num >= 1_000_000_000) {\r\n return (num / 1_000_000_000).toFixed(1).replace(/\\.0$/, \"\") + \"B\";\r\n }\r\n\r\n if (num >= 1_000_000) {\r\n return (num / 1_000_000).toFixed(1).replace(/\\.0$/, \"\") + \"M\";\r\n }\r\n\r\n if (num >= 1_000) {\r\n return (num / 1_000).toFixed(1).replace(/\\.0$/, \"\") + \"K\";\r\n }\r\n\r\n return (num ?? 0).toString();\r\n}","import { Avatar, Box, Stack, Typography } from \"@mui/material\";\r\nimport { getTrendColor, getTrendDirection } from \"../../../config/helper\";\r\n\r\n\r\nconst MetricCard = ({\r\n title,\r\n value,\r\n caption,\r\n icon,\r\n active,\r\n warning,\r\n error,\r\n onClick,\r\n sx = {},\r\n titleSx = {},\r\n valueSx = {},\r\n captionSx = {},\r\n avatarSx = {},\r\n}) => {\r\n const captionText = String(caption ?? \"\");\r\n const isPercentCaption = captionText.includes(\"%\");\r\n const trendDirection = isPercentCaption ? getTrendDirection(captionText) : \"neutral\";\r\n const hasTrendArrow = captionText.includes(\"▼\") || captionText.includes(\"▲\");\r\n const trendPrefix =\r\n hasTrendArrow || !isPercentCaption\r\n ? \"\"\r\n : trendDirection === \"down\"\r\n ? \"▼ \"\r\n : trendDirection === \"up\"\r\n ? \"▲ \"\r\n : \"\";\r\n const captionColor = captionText.includes(\"failed\")\r\n ? \"#4F46E5\"\r\n : error\r\n ? \"#ef4444\"\r\n : isPercentCaption\r\n ? getTrendColor(captionText, { up: \"#0B8F61\", down: \"#ef4444\" })\r\n : \"#0B8F61\";\r\n\r\n return (\r\n <Box\r\n sx={{\r\n bgcolor: \"#fff\",\r\n border: `1.5px solid ${active ? \"#4F46E5\" : warning ? \"#F3B33D\" : error ? \"#ef4444\" : \"#F1F1F5\"}`,\r\n borderRadius: \"16px\",\r\n p: { xs: 1.75, md: 2 },\r\n paddingTop: \"10px !important\", paddingBottom: \"10px !important\",\r\n height: 92,\r\n boxShadow: \"0 14px 30px rgba(21, 26, 45, 0.06)\",\r\n ...sx,\r\n }}\r\n onClick={onClick}\r\n >\r\n <Stack\r\n direction=\"row\"\r\n justifyContent=\"space-between\"\r\n alignItems=\"center\"\r\n >\r\n <Typography\r\n sx={{\r\n color: active ? \"#818CF8\" : \"#999EAA\",\r\n fontSize: 13,\r\n fontWeight: 500,\r\n letterSpacing: 0,\r\n ...titleSx,\r\n }}\r\n >\r\n {title}\r\n </Typography>\r\n <Avatar\r\n sx={{\r\n width: 30,\r\n height: 30,\r\n bgcolor: warning ? \"#FFF3CF\" : error ? \"#fee2e2\" : \"#EEF2FF\",\r\n color: warning ? \"#B45309\" : error ? \"#ef4444\" : \"#4F46E5\",\r\n p: 0.625,\r\n \"& .MuiSvgIcon-root, & svg\": {\r\n width: \"100%\",\r\n height: \"100%\",\r\n },\r\n ...avatarSx,\r\n }}\r\n >\r\n {icon}\r\n </Avatar>\r\n </Stack>\r\n <Typography\r\n sx={{\r\n fontSize: 22,\r\n fontWeight: 700,\r\n color: active ? \"#4F46E5\" : \"#050509\",\r\n lineHeight: 1.15,\r\n ...valueSx,\r\n }}\r\n >\r\n {value}\r\n </Typography>\r\n <Typography\r\n sx={{\r\n fontSize: 12,\r\n fontWeight: 500,\r\n color: captionColor,\r\n ...captionSx,\r\n }}\r\n >\r\n {`${trendPrefix}${captionText}`}\r\n </Typography>\r\n </Box>\r\n );\r\n};\r\n\r\nexport default MetricCard;\r\n"],"names":["TREND_UP_COLOR","TREND_DOWN_COLOR","getTrendDirection","valueOrText","text","String","trim","includes","match","n","Number","getTrendColor","_ref","arguments","length","undefined","_ref$up","up","_ref$down","down","_ref$neutral","neutral","direction","MetricCard","title","value","caption","icon","active","warning","error","onClick","_ref$sx","sx","_ref$titleSx","titleSx","_ref$valueSx","valueSx","_ref$captionSx","captionSx","_ref$avatarSx","avatarSx","captionText","isPercentCaption","trendDirection","hasTrendArrow","trendPrefix","captionColor","_jsxs","Box","_objectSpread","bgcolor","border","concat","borderRadius","p","xs","md","paddingTop","paddingBottom","height","boxShadow","children","Stack","justifyContent","al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QAAAA,QAAQ,EAAE,EAAE;AACZC,QAAAA,UAAU,EAAE,GAAG;AACfF,QAAAA,KAAK,EAAExC,MAAM,GAAG,SAAS,GAAG,SAAS;AACrC8C,QAAAA,UAAU,EAAE;AAAI,OAAA,EACbrC,OAAO,CACV;AAAAyB,MAAAA,QAAA,EAEDrC;AAAK,KACI,CAAC,eACXyC,cAAA,CAACC,mBAAU,EAAA;AACTlC,MAAAA,EAAE,EAAAiB,cAAA,CAAA;AACAmB,QAAAA,QAAQ,EAAE,EAAE;AACZC,QAAAA,UAAU,EAAE,GAAG;AACfF,QAAAA,KAAK,EAAErB;AAAY,OAAA,EAChBR,SAAS,CACZ;AAAAuB,MAAAA,QAAA,KAAAT,MAAA,CAEEP,WAAW,CAAA,CAAAO,MAAA,CAAGX,WAAW;AAAA,KACnB,CAAC;AAAA,GACV,CAAC;AAEV;;;;"}
@@ -132,7 +132,12 @@ var MetricCard = function MetricCard(_ref) {
132
132
  width: 30,
133
133
  height: 30,
134
134
  bgcolor: warning ? "#FFF3CF" : error ? "#fee2e2" : "#EEF2FF",
135
- color: warning ? "#B45309" : error ? "#ef4444" : "#4F46E5"
135
+ color: warning ? "#B45309" : error ? "#ef4444" : "#4F46E5",
136
+ p: 0.625,
137
+ "& .MuiSvgIcon-root, & svg": {
138
+ width: "100%",
139
+ height: "100%"
140
+ }
136
141
  }, avatarSx),
137
142
  children: icon
138
143
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"MetricCard.es.js","sources":["../src/config/helper.js","../src/components/advanced/MetricCard/index.jsx"],"sourcesContent":["export const TREND_UP_COLOR = \"#22C55E\";\r\nexport const TREND_DOWN_COLOR = \"#EF4444\";\r\n\r\nexport function getTrendDirection(valueOrText) {\r\n const text = String(valueOrText ?? \"\").trim();\r\n if (text.includes(\"▼\")) return \"down\";\r\n if (text.includes(\"▲\")) return \"up\";\r\n\r\n const match = text.match(/-?\\d+(\\.\\d+)?/);\r\n if (!match) return \"neutral\";\r\n\r\n const n = Number(match[0]);\r\n if (n < 0) return \"down\";\r\n if (n > 0) return \"up\";\r\n return \"neutral\";\r\n}\r\n\r\nexport function getTrendColor(\r\n valueOrText,\r\n { up = TREND_UP_COLOR, down = TREND_DOWN_COLOR, neutral = up } = {}\r\n) {\r\n const direction = getTrendDirection(valueOrText);\r\n if (direction === \"down\") return down;\r\n if (direction === \"up\") return up;\r\n return neutral;\r\n}\r\n\r\nexport function getTrendArrow(valueOrText) {\r\n const direction = getTrendDirection(valueOrText);\r\n if (direction === \"down\") return \"▼\";\r\n if (direction === \"up\") return \"▲\";\r\n return \"\";\r\n}\r\n\r\nexport function formatCurrency(value) {\r\n return `$${Number(value ?? 0).toLocaleString(\"en-US\")}`;\r\n}\r\n\r\nexport function formatNumber(num) {\r\n if (num >= 1_000_000_000) {\r\n return (num / 1_000_000_000).toFixed(1).replace(/\\.0$/, \"\") + \"B\";\r\n }\r\n\r\n if (num >= 1_000_000) {\r\n return (num / 1_000_000).toFixed(1).replace(/\\.0$/, \"\") + \"M\";\r\n }\r\n\r\n if (num >= 1_000) {\r\n return (num / 1_000).toFixed(1).replace(/\\.0$/, \"\") + \"K\";\r\n }\r\n\r\n return (num ?? 0).toString();\r\n}","import { Avatar, Box, Stack, Typography } from \"@mui/material\";\r\nimport { getTrendColor, getTrendDirection } from \"../../../config/helper\";\r\n\r\n\r\nconst MetricCard = ({\r\n title,\r\n value,\r\n caption,\r\n icon,\r\n active,\r\n warning,\r\n error,\r\n onClick,\r\n sx = {},\r\n titleSx = {},\r\n valueSx = {},\r\n captionSx = {},\r\n avatarSx = {},\r\n}) => {\r\n const captionText = String(caption ?? \"\");\r\n const isPercentCaption = captionText.includes(\"%\");\r\n const trendDirection = isPercentCaption ? getTrendDirection(captionText) : \"neutral\";\r\n const hasTrendArrow = captionText.includes(\"▼\") || captionText.includes(\"▲\");\r\n const trendPrefix =\r\n hasTrendArrow || !isPercentCaption\r\n ? \"\"\r\n : trendDirection === \"down\"\r\n ? \"▼ \"\r\n : trendDirection === \"up\"\r\n ? \"▲ \"\r\n : \"\";\r\n const captionColor = captionText.includes(\"failed\")\r\n ? \"#4F46E5\"\r\n : error\r\n ? \"#ef4444\"\r\n : isPercentCaption\r\n ? getTrendColor(captionText, { up: \"#0B8F61\", down: \"#ef4444\" })\r\n : \"#0B8F61\";\r\n\r\n return (\r\n <Box\r\n sx={{\r\n bgcolor: \"#fff\",\r\n border: `1.5px solid ${active ? \"#4F46E5\" : warning ? \"#F3B33D\" : error ? \"#ef4444\" : \"#F1F1F5\"}`,\r\n borderRadius: \"16px\",\r\n p: { xs: 1.75, md: 2 },\r\n paddingTop: \"10px !important\", paddingBottom: \"10px !important\",\r\n height: 92,\r\n boxShadow: \"0 14px 30px rgba(21, 26, 45, 0.06)\",\r\n ...sx,\r\n }}\r\n onClick={onClick}\r\n >\r\n <Stack\r\n direction=\"row\"\r\n justifyContent=\"space-between\"\r\n alignItems=\"center\"\r\n >\r\n <Typography\r\n sx={{\r\n color: active ? \"#818CF8\" : \"#999EAA\",\r\n fontSize: 13,\r\n fontWeight: 500,\r\n letterSpacing: 0,\r\n ...titleSx,\r\n }}\r\n >\r\n {title}\r\n </Typography>\r\n <Avatar\r\n sx={{\r\n width: 30,\r\n height: 30,\r\n bgcolor: warning ? \"#FFF3CF\" : error ? \"#fee2e2\" : \"#EEF2FF\",\r\n color: warning ? \"#B45309\" : error ? \"#ef4444\" : \"#4F46E5\",\r\n ...avatarSx,\r\n }}\r\n >\r\n {icon}\r\n </Avatar>\r\n </Stack>\r\n <Typography\r\n sx={{\r\n fontSize: 22,\r\n fontWeight: 700,\r\n color: active ? \"#4F46E5\" : \"#050509\",\r\n lineHeight: 1.15,\r\n ...valueSx,\r\n }}\r\n >\r\n {value}\r\n </Typography>\r\n <Typography\r\n sx={{\r\n fontSize: 12,\r\n fontWeight: 500,\r\n color: captionColor,\r\n ...captionSx,\r\n }}\r\n >\r\n {`${trendPrefix}${captionText}`}\r\n </Typography>\r\n </Box>\r\n );\r\n};\r\n\r\nexport default MetricCard;\r\n"],"names":["TREND_UP_COLOR","TREND_DOWN_COLOR","getTrendDirection","valueOrText","text","String","trim","includes","match","n","Number","getTrendColor","_ref","arguments","length","undefined","_ref$up","up","_ref$down","down","_ref$neutral","neutral","direction","MetricCard","title","value","caption","icon","active","warning","error","onClick","_ref$sx","sx","_ref$titleSx","titleSx","_ref$valueSx","valueSx","_ref$captionSx","captionSx","_ref$avatarSx","avatarSx","captionText","isPercentCaption","trendDirection","hasTrendArrow","trendPrefix","captionColor","_jsxs","Box","_objectSpread","bgcolor","border","concat","borderRadius","p","xs","md","paddingTop","paddingBottom","height","boxShadow","children","Stack","justifyContent","alignItems","_jsx","Typography","color","fontSize","fontWeight","letterSpacing","Avatar","width","lineHeight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,cAAc,GAAG,SAAS;AAChC,IAAMC,gBAAgB,GAAG,SAAS;AAElC,SAASC,iBAAiBA,CAACC,WAAW,EAAE;AAC7C,EAAA,IAAMC,IAAI,GAAGC,MAAM,CAACF,WAAW,KAAA,IAAA,IAAXA,WAAW,KAAA,MAAA,GAAXA,WAAW,GAAI,EAAE,CAAC,CAACG,IAAI,EAAE;EAC7C,IAAIF,IAAI,CAACG,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,MAAM;EACrC,IAAIH,IAAI,CAACG,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,IAAI;AAEnC,EAAA,IAAMC,KAAK,GAAGJ,IAAI,CAACI,KAAK,CAAC,eAAe,CAAC;AACzC,EAAA,IAAI,CAACA,KAAK,EAAE,OAAO,SAAS;EAE5B,IAAMC,CAAC,GAAGC,MAAM,CAACF,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1B,EAAA,IAAIC,CAAC,GAAG,CAAC,EAAE,OAAO,MAAM;AACxB,EAAA,IAAIA,CAAC,GAAG,CAAC,EAAE,OAAO,IAAI;AACtB,EAAA,OAAO,SAAS;A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G,SAAS,GAAG,SAAS;UAC5DsC,KAAK,EAAEvC,OAAO,GAAG,SAAS,GAAGC,KAAK,GAAG,SAAS,GAAG;AAAS,SAAA,EACvDW,QAAQ,CACX;AAAAqB,QAAAA,QAAA,EAEDnC;AAAI,OACC,CAAC;AAAA,KACJ,CAAC,eACRuC,GAAA,CAACC,UAAU,EAAA;AACTlC,MAAAA,EAAE,EAAAiB,cAAA,CAAA;AACAmB,QAAAA,QAAQ,EAAE,EAAE;AACZC,QAAAA,UAAU,EAAE,GAAG;AACfF,QAAAA,KAAK,EAAExC,MAAM,GAAG,SAAS,GAAG,SAAS;AACrC8C,QAAAA,UAAU,EAAE;AAAI,OAAA,EACbrC,OAAO,CACV;AAAAyB,MAAAA,QAAA,EAEDrC;AAAK,KACI,CAAC,eACXyC,GAAA,CAACC,UAAU,EAAA;AACTlC,MAAAA,EAAE,EAAAiB,cAAA,CAAA;AACAmB,QAAAA,QAAQ,EAAE,EAAE;AACZC,QAAAA,UAAU,EAAE,GAAG;AACfF,QAAAA,KAAK,EAAErB;AAAY,OAAA,EAChBR,SAAS,CACZ;AAAAuB,MAAAA,QAAA,KAAAT,MAAA,CAEEP,WAAW,CAAA,CAAAO,MAAA,CAAGX,WAAW;AAAA,KACnB,CAAC;AAAA,GACV,CAAC;AAEV;;;;"}
1
+ {"version":3,"file":"MetricCard.es.js","sources":["../src/config/helper.js","../src/components/advanced/MetricCard/index.jsx"],"sourcesContent":["export const TREND_UP_COLOR = \"#22C55E\";\r\nexport const TREND_DOWN_COLOR = \"#EF4444\";\r\n\r\nexport function getTrendDirection(valueOrText) {\r\n const text = String(valueOrText ?? \"\").trim();\r\n if (text.includes(\"▼\")) return \"down\";\r\n if (text.includes(\"▲\")) return \"up\";\r\n\r\n const match = text.match(/-?\\d+(\\.\\d+)?/);\r\n if (!match) return \"neutral\";\r\n\r\n const n = Number(match[0]);\r\n if (n < 0) return \"down\";\r\n if (n > 0) return \"up\";\r\n return \"neutral\";\r\n}\r\n\r\nexport function getTrendColor(\r\n valueOrText,\r\n { up = TREND_UP_COLOR, down = TREND_DOWN_COLOR, neutral = up } = {}\r\n) {\r\n const direction = getTrendDirection(valueOrText);\r\n if (direction === \"down\") return down;\r\n if (direction === \"up\") return up;\r\n return neutral;\r\n}\r\n\r\nexport function getTrendArrow(valueOrText) {\r\n const direction = getTrendDirection(valueOrText);\r\n if (direction === \"down\") return \"▼\";\r\n if (direction === \"up\") return \"▲\";\r\n return \"\";\r\n}\r\n\r\nexport function formatCurrency(value) {\r\n return `$${Number(value ?? 0).toLocaleString(\"en-US\")}`;\r\n}\r\n\r\nexport function formatNumber(num) {\r\n if (num >= 1_000_000_000) {\r\n return (num / 1_000_000_000).toFixed(1).replace(/\\.0$/, \"\") + \"B\";\r\n }\r\n\r\n if (num >= 1_000_000) {\r\n return (num / 1_000_000).toFixed(1).replace(/\\.0$/, \"\") + \"M\";\r\n }\r\n\r\n if (num >= 1_000) {\r\n return (num / 1_000).toFixed(1).replace(/\\.0$/, \"\") + \"K\";\r\n }\r\n\r\n return (num ?? 0).toString();\r\n}","import { Avatar, Box, Stack, Typography } from \"@mui/material\";\r\nimport { getTrendColor, getTrendDirection } from \"../../../config/helper\";\r\n\r\n\r\nconst MetricCard = ({\r\n title,\r\n value,\r\n caption,\r\n icon,\r\n active,\r\n warning,\r\n error,\r\n onClick,\r\n sx = {},\r\n titleSx = {},\r\n valueSx = {},\r\n captionSx = {},\r\n avatarSx = {},\r\n}) => {\r\n const captionText = String(caption ?? \"\");\r\n const isPercentCaption = captionText.includes(\"%\");\r\n const trendDirection = isPercentCaption ? getTrendDirection(captionText) : \"neutral\";\r\n const hasTrendArrow = captionText.includes(\"▼\") || captionText.includes(\"▲\");\r\n const trendPrefix =\r\n hasTrendArrow || !isPercentCaption\r\n ? \"\"\r\n : trendDirection === \"down\"\r\n ? \"▼ \"\r\n : trendDirection === \"up\"\r\n ? \"▲ \"\r\n : \"\";\r\n const captionColor = captionText.includes(\"failed\")\r\n ? \"#4F46E5\"\r\n : error\r\n ? \"#ef4444\"\r\n : isPercentCaption\r\n ? getTrendColor(captionText, { up: \"#0B8F61\", down: \"#ef4444\" })\r\n : \"#0B8F61\";\r\n\r\n return (\r\n <Box\r\n sx={{\r\n bgcolor: \"#fff\",\r\n border: `1.5px solid ${active ? \"#4F46E5\" : warning ? \"#F3B33D\" : error ? \"#ef4444\" : \"#F1F1F5\"}`,\r\n borderRadius: \"16px\",\r\n p: { xs: 1.75, md: 2 },\r\n paddingTop: \"10px !important\", paddingBottom: \"10px !important\",\r\n height: 92,\r\n boxShadow: \"0 14px 30px rgba(21, 26, 45, 0.06)\",\r\n ...sx,\r\n }}\r\n onClick={onClick}\r\n >\r\n <Stack\r\n direction=\"row\"\r\n justifyContent=\"space-between\"\r\n alignItems=\"center\"\r\n >\r\n <Typography\r\n sx={{\r\n color: active ? \"#818CF8\" : \"#999EAA\",\r\n fontSize: 13,\r\n fontWeight: 500,\r\n letterSpacing: 0,\r\n ...titleSx,\r\n }}\r\n >\r\n {title}\r\n </Typography>\r\n <Avatar\r\n sx={{\r\n width: 30,\r\n height: 30,\r\n bgcolor: warning ? \"#FFF3CF\" : error ? \"#fee2e2\" : \"#EEF2FF\",\r\n color: warning ? \"#B45309\" : error ? \"#ef4444\" : \"#4F46E5\",\r\n p: 0.625,\r\n \"& .MuiSvgIcon-root, & svg\": {\r\n width: \"100%\",\r\n height: \"100%\",\r\n },\r\n ...avatarSx,\r\n }}\r\n >\r\n {icon}\r\n </Avatar>\r\n </Stack>\r\n <Typography\r\n sx={{\r\n fontSize: 22,\r\n fontWeight: 700,\r\n color: active ? \"#4F46E5\" : \"#050509\",\r\n lineHeight: 1.15,\r\n ...valueSx,\r\n }}\r\n >\r\n {value}\r\n </Typography>\r\n <Typography\r\n sx={{\r\n fontSize: 12,\r\n fontWeight: 500,\r\n color: captionColor,\r\n ...captionSx,\r\n }}\r\n >\r\n {`${trendPrefix}${captionText}`}\r\n </Typography>\r\n </Box>\r\n );\r\n};\r\n\r\nexport default MetricCard;\r\n"],"names":["TREND_UP_COLOR","TREND_DOWN_COLOR","getTrendDirection","valueOrText","text","String","trim","includes","match","n","Number","getTrendColor","_ref","arguments","length","undefined","_ref$up","up","_ref$down","down","_ref$neutral","neutral","direction","MetricCard","title","value","caption","icon","active","warning","error","onClick","_ref$sx","sx","_ref$titleSx","titleSx","_ref$valueSx","valueSx","_ref$captionSx","captionSx","_ref$avatarSx","avatarSx","captionText","isPercentCaption","trendDirection","hasTrendArrow","trendPrefix","captionColor","_jsxs","Box","_objectSpread","bgcolor","border","concat","borderRadius","p","xs","md","paddingTop","paddingBottom","height","boxShadow","children","Stack","justifyContent","alignItems","_jsx","Typography","color","fontSize","fontWeight","letterSpacing","Avatar","width","lineHeight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,cAAc,GAAG,SAAS;AAChC,IAAMC,gBAAgB,GAAG,SAAS;AAElC,SAASC,iBAAiBA,CAACC,WAAW,EAAE;AAC7C,EAAA,IAAMC,IAAI,GAAGC,MAAM,CAACF,WAAW,KAAA,IAAA,IAAXA,WAAW,KAAA,MAAA,GAAXA,WAAW,GAAI,EAAE,CAAC,CAACG,IAAI,EAAE;EAC7C,IAAIF,IAAI,CAACG,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,MAAM;EACrC,IAAIH,IAAI,CAACG,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,IAAI;AAEnC,EAAA,IAAMC,KAAK,GAAGJ,IAAI,CAACI,KAAK,CAAC,eAAe,CAAC;AACzC,EAAA,IAAI,CAACA,KAAK,EAAE,OAAO,SAAS;EAE5B,IAAMC,CAAC,GAAGC,MAAM,CAACF,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1B,EAAA,IAAIC,CAAC,GAAG,CAAC,EAAE,OAAO,MAAM;AACxB,EAAA,IAAIA,CAAC,GAAG,CAAC,EAAE,OAAO,IAAI;AACtB,EAAA,OAAO,SAA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