@algorithm-shift/design-system 1.2.66 → 1.2.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -28404,7 +28404,7 @@ function DataTable({
28404
28404
  return [];
28405
28405
  };
28406
28406
  return /* @__PURE__ */ jsxs26("div", { className: "overflow-hidden rounded-md w-full", children: [
28407
- /* @__PURE__ */ jsxs26("div", { className: `flex ${globalSearch ? "justify-between" : "justify-end"} p-2 border-b bg-gray-50`, children: [
28407
+ /* @__PURE__ */ jsxs26("div", { className: `flex ${globalSearch ? "justify-between" : "justify-end"} p-2 bg-gray-50`, children: [
28408
28408
  globalSearch && /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
28409
28409
  /* @__PURE__ */ jsxs26("div", { className: "relative w-full", children: [
28410
28410
  /* @__PURE__ */ jsx47(
@@ -28440,7 +28440,7 @@ function DataTable({
28440
28440
  {
28441
28441
  variant: "outline",
28442
28442
  size: "sm",
28443
- className: "px-3 py-1 text-xs cursor-pointer",
28443
+ className: "px-3 py-1 text-xs cursor-pointer border-gray-300",
28444
28444
  children: "Manage Columns"
28445
28445
  }
28446
28446
  ) }),
@@ -29121,19 +29121,56 @@ function Navbar({
29121
29121
  }
29122
29122
 
29123
29123
  // src/components/Chart/BarChart.tsx
29124
- import { BarChart, Bar, Area, AreaChart, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from "recharts";
29124
+ import React9 from "react";
29125
+ import {
29126
+ BarChart,
29127
+ Bar,
29128
+ Area,
29129
+ AreaChart,
29130
+ XAxis,
29131
+ YAxis,
29132
+ CartesianGrid,
29133
+ Tooltip,
29134
+ ResponsiveContainer,
29135
+ Legend
29136
+ } from "recharts";
29125
29137
  import { jsx as jsx59, jsxs as jsxs34 } from "react/jsx-runtime";
29126
- var ChartComponent = ({ className, style, ...props }) => {
29127
- const data = Array.isArray(props?.data) ? props.data : [];
29138
+ var ChartComponent = ({ className, style, loading, ...props }) => {
29139
+ const data = Array.isArray(props.data) ? props.data : [];
29128
29140
  const chartType = props.chartType || "bar";
29129
29141
  const legendsPosition = props.legendsPosition === "middle" || props.legendsPosition === "bottom" ? props.legendsPosition : "top";
29130
- return /* @__PURE__ */ jsx59("div", { className: `${className} h-[400px]`, style, children: data.length > 0 && /* @__PURE__ */ jsx59(ResponsiveContainer, { width: "100%", height: "100%", children: chartType === "bar" ? /* @__PURE__ */ jsxs34(BarChart, { data, children: [
29142
+ if (loading || data.length === 0) {
29143
+ return /* @__PURE__ */ jsx59(
29144
+ "div",
29145
+ {
29146
+ className: `flex items-center justify-center w-full h-[300px] md:h-[400px] bg-gray-50 animate-pulse rounded-lg ${className}`,
29147
+ style,
29148
+ children: /* @__PURE__ */ jsx59("div", { className: "text-gray-400 text-sm md:text-base", children: loading ? "Loading chart report..." : "No data available to display the chart." })
29149
+ }
29150
+ );
29151
+ }
29152
+ return /* @__PURE__ */ jsx59("div", { className: `${className} h-[400px]`, style, children: /* @__PURE__ */ jsx59(ResponsiveContainer, { width: "100%", height: "100%", children: chartType === "bar" ? /* @__PURE__ */ jsxs34(BarChart, { data, title: "Leads", desc: "content", children: [
29131
29153
  /* @__PURE__ */ jsx59(CartesianGrid, { strokeDasharray: "3 3" }),
29132
29154
  /* @__PURE__ */ jsx59(XAxis, { dataKey: "name" }),
29133
29155
  /* @__PURE__ */ jsx59(YAxis, {}),
29134
- /* @__PURE__ */ jsx59(Tooltip, {}),
29156
+ /* @__PURE__ */ jsx59(Tooltip, { formatter: (value) => `${value}k` }),
29135
29157
  /* @__PURE__ */ jsx59(Legend, { verticalAlign: legendsPosition, align: "center" }),
29136
- /* @__PURE__ */ jsx59(Bar, { dataKey: "value", fill: "#00695C" })
29158
+ /* @__PURE__ */ jsx59(
29159
+ Bar,
29160
+ {
29161
+ dataKey: "value",
29162
+ fill: "#00695C",
29163
+ radius: [6, 6, 0, 0],
29164
+ isAnimationActive: false,
29165
+ children: data.map((entry, index) => /* @__PURE__ */ jsx59(
29166
+ "rect",
29167
+ {
29168
+ fill: entry.color || "#00695C"
29169
+ },
29170
+ `bar-${index}`
29171
+ ))
29172
+ }
29173
+ )
29137
29174
  ] }) : /* @__PURE__ */ jsxs34(AreaChart, { data, children: [
29138
29175
  /* @__PURE__ */ jsx59("defs", { children: /* @__PURE__ */ jsxs34("linearGradient", { id: "colorCount", x1: "0", y1: "0", x2: "0", y2: "1", children: [
29139
29176
  /* @__PURE__ */ jsx59("stop", { offset: "5%", stopColor: "#00695C", stopOpacity: 0.8 }),
@@ -29142,7 +29179,7 @@ var ChartComponent = ({ className, style, ...props }) => {
29142
29179
  /* @__PURE__ */ jsx59(CartesianGrid, { strokeDasharray: "3 3" }),
29143
29180
  /* @__PURE__ */ jsx59(XAxis, { dataKey: "name" }),
29144
29181
  /* @__PURE__ */ jsx59(YAxis, {}),
29145
- /* @__PURE__ */ jsx59(Tooltip, {}),
29182
+ /* @__PURE__ */ jsx59(Tooltip, { formatter: (value) => `${value}k` }),
29146
29183
  /* @__PURE__ */ jsx59(
29147
29184
  Area,
29148
29185
  {
@@ -29150,47 +29187,51 @@ var ChartComponent = ({ className, style, ...props }) => {
29150
29187
  dataKey: "value",
29151
29188
  stroke: "#00695C",
29152
29189
  fillOpacity: 1,
29153
- fill: "url(#colorCount)"
29190
+ fill: "url(#colorCount)",
29191
+ isAnimationActive: false
29154
29192
  }
29155
29193
  )
29156
29194
  ] }) }) });
29157
29195
  };
29158
- var BarChart_default = ChartComponent;
29196
+ var BarChart_default = React9.memo(ChartComponent);
29159
29197
 
29160
29198
  // src/components/Chart/PieChart.tsx
29161
- import { PieChart, Pie, Cell, ResponsiveContainer as ResponsiveContainer2, Tooltip as Tooltip2, LabelList } from "recharts";
29199
+ import React10, { useMemo as useMemo3 } from "react";
29200
+ import {
29201
+ PieChart,
29202
+ Pie,
29203
+ Cell,
29204
+ ResponsiveContainer as ResponsiveContainer2,
29205
+ Tooltip as Tooltip2,
29206
+ LabelList
29207
+ } from "recharts";
29162
29208
  import { Fragment as Fragment19, jsx as jsx60, jsxs as jsxs35 } from "react/jsx-runtime";
29163
- var DonutChart = ({ className, style, ...props }) => {
29164
- const data = Array.isArray(props?.data) ? props.data : [];
29165
- const total = data.reduce((sum, d) => sum + d.value, 0);
29166
- const showPercentage = props.showPercentage ?? true;
29209
+ var getRandomColor = () => {
29210
+ const palette = [
29211
+ "#2563eb",
29212
+ "#10b981",
29213
+ "#f59e0b",
29214
+ "#ef4444",
29215
+ "#8b5cf6",
29216
+ "#14b8a6",
29217
+ "#ec4899",
29218
+ "#e11d48",
29219
+ "#22c55e",
29220
+ "#3b82f6"
29221
+ ];
29222
+ return palette[Math.floor(Math.random() * palette.length)];
29223
+ };
29224
+ var DonutChart = ({ className, style, loading, ...props }) => {
29167
29225
  const showLegends = props.showLegends ?? true;
29168
29226
  const labelType = props.labelType || "inside";
29169
29227
  const canvasMode = props.canvasMode;
29170
- const renderLabel = ({ value, x, y }) => {
29171
- if (value == null) return null;
29172
- const percentage = (Number(value) / total * 100).toFixed(0);
29173
- return /* @__PURE__ */ jsxs35(
29174
- "text",
29175
- {
29176
- x,
29177
- y,
29178
- textAnchor: "middle",
29179
- dominantBaseline: "central",
29180
- className: "text-[10px] font-semibold",
29181
- fill: labelType === "inside" ? "#fff" : "#000",
29182
- children: [
29183
- value,
29184
- "k ",
29185
- showPercentage ? `(${percentage}%)` : ""
29186
- ]
29187
- }
29188
- );
29189
- };
29228
+ const data = useMemo3(() => {
29229
+ if (!Array.isArray(props.data)) return [];
29230
+ return props.data.map((item) => ({ ...item, color: getRandomColor() }));
29231
+ }, [props.data]);
29232
+ const total = useMemo3(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
29190
29233
  const forceMobile = canvasMode === "mobile" || canvasMode === "tablet";
29191
- const forceDesktop = canvasMode === "desktop";
29192
- const wrapperClass = canvasMode ? forceDesktop ? "flex-row" : "flex-col" : "flex-col md:flex-row";
29193
- const renderLegends = () => {
29234
+ const renderLegends = useMemo3(() => {
29194
29235
  if (!showLegends) return null;
29195
29236
  return /* @__PURE__ */ jsx60(Fragment19, { children: data.map((d) => /* @__PURE__ */ jsxs35(
29196
29237
  "div",
@@ -29209,23 +29250,33 @@ var DonutChart = ({ className, style, ...props }) => {
29209
29250
  },
29210
29251
  d.name
29211
29252
  )) });
29212
- };
29253
+ }, [data, showLegends]);
29254
+ if (loading || data.length === 0) {
29255
+ return /* @__PURE__ */ jsx60(
29256
+ "div",
29257
+ {
29258
+ className: `flex items-center justify-center w-full h-[300px] md:h-[400px] bg-gray-50 animate-pulse rounded-lg ${className}`,
29259
+ style,
29260
+ children: /* @__PURE__ */ jsx60("div", { className: "text-gray-400 text-sm md:text-base", children: loading ? "Loading chart report..." : "No data available to display the chart." })
29261
+ }
29262
+ );
29263
+ }
29213
29264
  return /* @__PURE__ */ jsxs35(
29214
29265
  "div",
29215
29266
  {
29216
- className: `relative flex items-center ${wrapperClass} ${className}`,
29267
+ className: `relative flex flex-col items-center ${className}`,
29217
29268
  style,
29218
29269
  children: [
29219
29270
  /* @__PURE__ */ jsxs35("div", { className: "relative w-full md:w-[70%] h-[300px] md:h-[400px] flex items-center justify-center", children: [
29220
- data.length > 0 && /* @__PURE__ */ jsx60(ResponsiveContainer2, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs35(PieChart, { children: [
29271
+ /* @__PURE__ */ jsx60(ResponsiveContainer2, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs35(PieChart, { children: [
29221
29272
  /* @__PURE__ */ jsxs35(
29222
29273
  Pie,
29223
29274
  {
29224
29275
  data,
29225
29276
  cx: "50%",
29226
29277
  cy: "50%",
29227
- innerRadius: 70,
29228
- outerRadius: 120,
29278
+ innerRadius: forceMobile ? 60 : 80,
29279
+ outerRadius: forceMobile ? 100 : 140,
29229
29280
  dataKey: "value",
29230
29281
  labelLine: false,
29231
29282
  isAnimationActive: false,
@@ -29236,26 +29287,38 @@ var DonutChart = ({ className, style, ...props }) => {
29236
29287
  {
29237
29288
  dataKey: "value",
29238
29289
  position: labelType === "inside" ? "inside" : "outside",
29239
- content: renderLabel
29290
+ fill: labelType === "inside" ? "#fff" : "#000",
29291
+ fontSize: forceMobile ? 10 : 13,
29292
+ fontWeight: 600
29240
29293
  }
29241
29294
  )
29242
29295
  ]
29243
29296
  }
29244
29297
  ),
29245
- /* @__PURE__ */ jsx60(Tooltip2, { formatter: (value, name) => [`${value}k`, name] })
29298
+ /* @__PURE__ */ jsx60(
29299
+ Tooltip2,
29300
+ {
29301
+ formatter: (value, name) => [`${value}k`, name]
29302
+ }
29303
+ )
29246
29304
  ] }) }),
29247
- /* @__PURE__ */ jsxs35("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-2xl md:text-4xl font-bold text-[#000]", children: [
29248
- total,
29249
- "k"
29250
- ] })
29305
+ /* @__PURE__ */ jsxs35(
29306
+ "div",
29307
+ {
29308
+ className: `absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 ${forceMobile ? "text-2xl" : "text-4xl"} font-bold text-[#000]`,
29309
+ children: [
29310
+ total,
29311
+ "k"
29312
+ ]
29313
+ }
29314
+ )
29251
29315
  ] }),
29252
- /* @__PURE__ */ jsx60("div", { className: `flex ${forceDesktop ? "flex-col ml-auto space-y-3" : "flex-wrap justify-center gap-2 mt-4"}
29253
- w-full md:w-auto`, children: renderLegends() })
29316
+ /* @__PURE__ */ jsx60("div", { className: "flex flex-wrap justify-center gap-2 mt-6 w-full md:w-auto", children: renderLegends })
29254
29317
  ]
29255
29318
  }
29256
29319
  );
29257
29320
  };
29258
- var PieChart_default = DonutChart;
29321
+ var PieChart_default = React10.memo(DonutChart);
29259
29322
 
29260
29323
  // src/components/Blocks/EmailComposer.tsx
29261
29324
  import { jsx as jsx61, jsxs as jsxs36 } from "react/jsx-runtime";