@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.d.mts CHANGED
@@ -133,6 +133,7 @@ interface PieChartProps extends ElementProps {
133
133
  showLegends?: boolean;
134
134
  labelType?: string;
135
135
  canvasMode?: 'desktop' | 'tablet' | 'mobile';
136
+ loading?: boolean;
136
137
  }
137
138
 
138
139
  interface BarChartProps extends ElementProps {
@@ -140,6 +141,7 @@ interface BarChartProps extends ElementProps {
140
141
  chartType?: string;
141
142
  legendsPosition?: string;
142
143
  canvasMode?: 'desktop' | 'tablet' | 'mobile';
144
+ loading?: boolean;
143
145
  }
144
146
 
145
147
  interface ModalProps extends ElementProps {
@@ -319,9 +321,9 @@ declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.
319
321
 
320
322
  declare function Navbar({ style, badgeType, badgeCount, hideBadgeWhenZero, profileType, showName, imageUrl, altText, canvasMode, list, profileMenu, userName }: NavbarProps): react_jsx_runtime.JSX.Element;
321
323
 
322
- declare const ChartComponent: ({ className, style, ...props }: BarChartProps) => react_jsx_runtime.JSX.Element;
324
+ declare const _default$1: React$1.MemoExoticComponent<({ className, style, loading, ...props }: BarChartProps) => react_jsx_runtime.JSX.Element>;
323
325
 
324
- declare const DonutChart: ({ className, style, ...props }: PieChartProps) => react_jsx_runtime.JSX.Element;
326
+ declare const _default: React$1.MemoExoticComponent<({ className, style, loading, ...props }: PieChartProps) => react_jsx_runtime.JSX.Element>;
325
327
 
326
328
  declare function EmailComposer({ className, style, to, setTo, showCc, setShowCc, showBcc, setShowBcc, cc, setCc, bcc, setBcc, subject, setSubject, body, setBody }: EmailComposerProps): react_jsx_runtime.JSX.Element;
327
329
 
@@ -341,4 +343,4 @@ declare const Toaster: ({ ...props }: ToasterProps) => react_jsx_runtime.JSX.Ele
341
343
  declare function cn(...inputs: ClassValue[]): string;
342
344
  declare function getInitials(name: string): string;
343
345
 
344
- export { Accordion, AccordionGroup, ChartComponent as BarChart, Breadcrumb, ButtonWrapper as Button, SplitButton as ButtonGroup, CheckboxInput as Checkbox, Container, DatePicker, DateRange, Dropdown, EmailInput as Email, EmailComposer, FileInput, Flex as FlexLayout, Grid as GridLayout, Icon, ImageControl as Image, Modal, MultiCheckbox, Navbar, NumberInput, CustomPagination as Pagination, PasswordInput as Password, PhoneInput as Phone, DonutChart as PieChart, RadioInput as RadioGroup, RichText, SearchInput as Search, Shape, Slot, Spacer, StagesComponent as Stages, SwitchToggle, TabGroupComponent as TabGroup, TabList, Table, Tabs, TextInput as Text, TextInputGroup, Textarea, Toaster, Typography, UrlInput as URL, cn, getInitials, showSonnerToast };
346
+ export { Accordion, AccordionGroup, _default$1 as BarChart, Breadcrumb, ButtonWrapper as Button, SplitButton as ButtonGroup, CheckboxInput as Checkbox, Container, DatePicker, DateRange, Dropdown, EmailInput as Email, EmailComposer, FileInput, Flex as FlexLayout, Grid as GridLayout, Icon, ImageControl as Image, Modal, MultiCheckbox, Navbar, NumberInput, CustomPagination as Pagination, PasswordInput as Password, PhoneInput as Phone, _default as PieChart, RadioInput as RadioGroup, RichText, SearchInput as Search, Shape, Slot, Spacer, StagesComponent as Stages, SwitchToggle, TabGroupComponent as TabGroup, TabList, Table, Tabs, TextInput as Text, TextInputGroup, Textarea, Toaster, Typography, UrlInput as URL, cn, getInitials, showSonnerToast };
package/dist/index.d.ts CHANGED
@@ -133,6 +133,7 @@ interface PieChartProps extends ElementProps {
133
133
  showLegends?: boolean;
134
134
  labelType?: string;
135
135
  canvasMode?: 'desktop' | 'tablet' | 'mobile';
136
+ loading?: boolean;
136
137
  }
137
138
 
138
139
  interface BarChartProps extends ElementProps {
@@ -140,6 +141,7 @@ interface BarChartProps extends ElementProps {
140
141
  chartType?: string;
141
142
  legendsPosition?: string;
142
143
  canvasMode?: 'desktop' | 'tablet' | 'mobile';
144
+ loading?: boolean;
143
145
  }
144
146
 
145
147
  interface ModalProps extends ElementProps {
@@ -319,9 +321,9 @@ declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.
319
321
 
320
322
  declare function Navbar({ style, badgeType, badgeCount, hideBadgeWhenZero, profileType, showName, imageUrl, altText, canvasMode, list, profileMenu, userName }: NavbarProps): react_jsx_runtime.JSX.Element;
321
323
 
322
- declare const ChartComponent: ({ className, style, ...props }: BarChartProps) => react_jsx_runtime.JSX.Element;
324
+ declare const _default$1: React$1.MemoExoticComponent<({ className, style, loading, ...props }: BarChartProps) => react_jsx_runtime.JSX.Element>;
323
325
 
324
- declare const DonutChart: ({ className, style, ...props }: PieChartProps) => react_jsx_runtime.JSX.Element;
326
+ declare const _default: React$1.MemoExoticComponent<({ className, style, loading, ...props }: PieChartProps) => react_jsx_runtime.JSX.Element>;
325
327
 
326
328
  declare function EmailComposer({ className, style, to, setTo, showCc, setShowCc, showBcc, setShowBcc, cc, setCc, bcc, setBcc, subject, setSubject, body, setBody }: EmailComposerProps): react_jsx_runtime.JSX.Element;
327
329
 
@@ -341,4 +343,4 @@ declare const Toaster: ({ ...props }: ToasterProps) => react_jsx_runtime.JSX.Ele
341
343
  declare function cn(...inputs: ClassValue[]): string;
342
344
  declare function getInitials(name: string): string;
343
345
 
344
- export { Accordion, AccordionGroup, ChartComponent as BarChart, Breadcrumb, ButtonWrapper as Button, SplitButton as ButtonGroup, CheckboxInput as Checkbox, Container, DatePicker, DateRange, Dropdown, EmailInput as Email, EmailComposer, FileInput, Flex as FlexLayout, Grid as GridLayout, Icon, ImageControl as Image, Modal, MultiCheckbox, Navbar, NumberInput, CustomPagination as Pagination, PasswordInput as Password, PhoneInput as Phone, DonutChart as PieChart, RadioInput as RadioGroup, RichText, SearchInput as Search, Shape, Slot, Spacer, StagesComponent as Stages, SwitchToggle, TabGroupComponent as TabGroup, TabList, Table, Tabs, TextInput as Text, TextInputGroup, Textarea, Toaster, Typography, UrlInput as URL, cn, getInitials, showSonnerToast };
346
+ export { Accordion, AccordionGroup, _default$1 as BarChart, Breadcrumb, ButtonWrapper as Button, SplitButton as ButtonGroup, CheckboxInput as Checkbox, Container, DatePicker, DateRange, Dropdown, EmailInput as Email, EmailComposer, FileInput, Flex as FlexLayout, Grid as GridLayout, Icon, ImageControl as Image, Modal, MultiCheckbox, Navbar, NumberInput, CustomPagination as Pagination, PasswordInput as Password, PhoneInput as Phone, _default as PieChart, RadioInput as RadioGroup, RichText, SearchInput as Search, Shape, Slot, Spacer, StagesComponent as Stages, SwitchToggle, TabGroupComponent as TabGroup, TabList, Table, Tabs, TextInput as Text, TextInputGroup, Textarea, Toaster, Typography, UrlInput as URL, cn, getInitials, showSonnerToast };
package/dist/index.js CHANGED
@@ -28493,7 +28493,7 @@ function DataTable({
28493
28493
  return [];
28494
28494
  };
28495
28495
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "overflow-hidden rounded-md w-full", children: [
28496
- /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: `flex ${globalSearch ? "justify-between" : "justify-end"} p-2 border-b bg-gray-50`, children: [
28496
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: `flex ${globalSearch ? "justify-between" : "justify-end"} p-2 bg-gray-50`, children: [
28497
28497
  globalSearch && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
28498
28498
  /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "relative w-full", children: [
28499
28499
  /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
@@ -28529,7 +28529,7 @@ function DataTable({
28529
28529
  {
28530
28530
  variant: "outline",
28531
28531
  size: "sm",
28532
- className: "px-3 py-1 text-xs cursor-pointer",
28532
+ className: "px-3 py-1 text-xs cursor-pointer border-gray-300",
28533
28533
  children: "Manage Columns"
28534
28534
  }
28535
28535
  ) }),
@@ -29210,19 +29210,45 @@ function Navbar({
29210
29210
  }
29211
29211
 
29212
29212
  // src/components/Chart/BarChart.tsx
29213
+ var import_react27 = __toESM(require("react"));
29213
29214
  var import_recharts = require("recharts");
29214
29215
  var import_jsx_runtime59 = require("react/jsx-runtime");
29215
- var ChartComponent = ({ className, style, ...props }) => {
29216
- const data = Array.isArray(props?.data) ? props.data : [];
29216
+ var ChartComponent = ({ className, style, loading, ...props }) => {
29217
+ const data = Array.isArray(props.data) ? props.data : [];
29217
29218
  const chartType = props.chartType || "bar";
29218
29219
  const legendsPosition = props.legendsPosition === "middle" || props.legendsPosition === "bottom" ? props.legendsPosition : "top";
29219
- return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: `${className} h-[400px]`, style, children: data.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height: "100%", children: chartType === "bar" ? /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_recharts.BarChart, { data, children: [
29220
+ if (loading || data.length === 0) {
29221
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
29222
+ "div",
29223
+ {
29224
+ className: `flex items-center justify-center w-full h-[300px] md:h-[400px] bg-gray-50 animate-pulse rounded-lg ${className}`,
29225
+ style,
29226
+ children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "text-gray-400 text-sm md:text-base", children: loading ? "Loading chart report..." : "No data available to display the chart." })
29227
+ }
29228
+ );
29229
+ }
29230
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: `${className} h-[400px]`, style, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height: "100%", children: chartType === "bar" ? /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_recharts.BarChart, { data, title: "Leads", desc: "content", children: [
29220
29231
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3" }),
29221
29232
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.XAxis, { dataKey: "name" }),
29222
29233
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.YAxis, {}),
29223
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Tooltip, {}),
29234
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Tooltip, { formatter: (value) => `${value}k` }),
29224
29235
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Legend, { verticalAlign: legendsPosition, align: "center" }),
29225
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Bar, { dataKey: "value", fill: "#00695C" })
29236
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
29237
+ import_recharts.Bar,
29238
+ {
29239
+ dataKey: "value",
29240
+ fill: "#00695C",
29241
+ radius: [6, 6, 0, 0],
29242
+ isAnimationActive: false,
29243
+ children: data.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
29244
+ "rect",
29245
+ {
29246
+ fill: entry.color || "#00695C"
29247
+ },
29248
+ `bar-${index}`
29249
+ ))
29250
+ }
29251
+ )
29226
29252
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_recharts.AreaChart, { data, children: [
29227
29253
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("linearGradient", { id: "colorCount", x1: "0", y1: "0", x2: "0", y2: "1", children: [
29228
29254
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("stop", { offset: "5%", stopColor: "#00695C", stopOpacity: 0.8 }),
@@ -29231,7 +29257,7 @@ var ChartComponent = ({ className, style, ...props }) => {
29231
29257
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3" }),
29232
29258
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.XAxis, { dataKey: "name" }),
29233
29259
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.YAxis, {}),
29234
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Tooltip, {}),
29260
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Tooltip, { formatter: (value) => `${value}k` }),
29235
29261
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
29236
29262
  import_recharts.Area,
29237
29263
  {
@@ -29239,47 +29265,44 @@ var ChartComponent = ({ className, style, ...props }) => {
29239
29265
  dataKey: "value",
29240
29266
  stroke: "#00695C",
29241
29267
  fillOpacity: 1,
29242
- fill: "url(#colorCount)"
29268
+ fill: "url(#colorCount)",
29269
+ isAnimationActive: false
29243
29270
  }
29244
29271
  )
29245
29272
  ] }) }) });
29246
29273
  };
29247
- var BarChart_default = ChartComponent;
29274
+ var BarChart_default = import_react27.default.memo(ChartComponent);
29248
29275
 
29249
29276
  // src/components/Chart/PieChart.tsx
29277
+ var import_react28 = __toESM(require("react"));
29250
29278
  var import_recharts2 = require("recharts");
29251
29279
  var import_jsx_runtime60 = require("react/jsx-runtime");
29252
- var DonutChart = ({ className, style, ...props }) => {
29253
- const data = Array.isArray(props?.data) ? props.data : [];
29254
- const total = data.reduce((sum, d) => sum + d.value, 0);
29255
- const showPercentage = props.showPercentage ?? true;
29280
+ var getRandomColor = () => {
29281
+ const palette = [
29282
+ "#2563eb",
29283
+ "#10b981",
29284
+ "#f59e0b",
29285
+ "#ef4444",
29286
+ "#8b5cf6",
29287
+ "#14b8a6",
29288
+ "#ec4899",
29289
+ "#e11d48",
29290
+ "#22c55e",
29291
+ "#3b82f6"
29292
+ ];
29293
+ return palette[Math.floor(Math.random() * palette.length)];
29294
+ };
29295
+ var DonutChart = ({ className, style, loading, ...props }) => {
29256
29296
  const showLegends = props.showLegends ?? true;
29257
29297
  const labelType = props.labelType || "inside";
29258
29298
  const canvasMode = props.canvasMode;
29259
- const renderLabel = ({ value, x, y }) => {
29260
- if (value == null) return null;
29261
- const percentage = (Number(value) / total * 100).toFixed(0);
29262
- return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29263
- "text",
29264
- {
29265
- x,
29266
- y,
29267
- textAnchor: "middle",
29268
- dominantBaseline: "central",
29269
- className: "text-[10px] font-semibold",
29270
- fill: labelType === "inside" ? "#fff" : "#000",
29271
- children: [
29272
- value,
29273
- "k ",
29274
- showPercentage ? `(${percentage}%)` : ""
29275
- ]
29276
- }
29277
- );
29278
- };
29299
+ const data = (0, import_react28.useMemo)(() => {
29300
+ if (!Array.isArray(props.data)) return [];
29301
+ return props.data.map((item) => ({ ...item, color: getRandomColor() }));
29302
+ }, [props.data]);
29303
+ const total = (0, import_react28.useMemo)(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
29279
29304
  const forceMobile = canvasMode === "mobile" || canvasMode === "tablet";
29280
- const forceDesktop = canvasMode === "desktop";
29281
- const wrapperClass = canvasMode ? forceDesktop ? "flex-row" : "flex-col" : "flex-col md:flex-row";
29282
- const renderLegends = () => {
29305
+ const renderLegends = (0, import_react28.useMemo)(() => {
29283
29306
  if (!showLegends) return null;
29284
29307
  return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_jsx_runtime60.Fragment, { children: data.map((d) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29285
29308
  "div",
@@ -29298,23 +29321,33 @@ var DonutChart = ({ className, style, ...props }) => {
29298
29321
  },
29299
29322
  d.name
29300
29323
  )) });
29301
- };
29324
+ }, [data, showLegends]);
29325
+ if (loading || data.length === 0) {
29326
+ return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
29327
+ "div",
29328
+ {
29329
+ className: `flex items-center justify-center w-full h-[300px] md:h-[400px] bg-gray-50 animate-pulse rounded-lg ${className}`,
29330
+ style,
29331
+ children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "text-gray-400 text-sm md:text-base", children: loading ? "Loading chart report..." : "No data available to display the chart." })
29332
+ }
29333
+ );
29334
+ }
29302
29335
  return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29303
29336
  "div",
29304
29337
  {
29305
- className: `relative flex items-center ${wrapperClass} ${className}`,
29338
+ className: `relative flex flex-col items-center ${className}`,
29306
29339
  style,
29307
29340
  children: [
29308
29341
  /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "relative w-full md:w-[70%] h-[300px] md:h-[400px] flex items-center justify-center", children: [
29309
- data.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_recharts2.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_recharts2.PieChart, { children: [
29342
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_recharts2.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_recharts2.PieChart, { children: [
29310
29343
  /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29311
29344
  import_recharts2.Pie,
29312
29345
  {
29313
29346
  data,
29314
29347
  cx: "50%",
29315
29348
  cy: "50%",
29316
- innerRadius: 70,
29317
- outerRadius: 120,
29349
+ innerRadius: forceMobile ? 60 : 80,
29350
+ outerRadius: forceMobile ? 100 : 140,
29318
29351
  dataKey: "value",
29319
29352
  labelLine: false,
29320
29353
  isAnimationActive: false,
@@ -29325,26 +29358,38 @@ var DonutChart = ({ className, style, ...props }) => {
29325
29358
  {
29326
29359
  dataKey: "value",
29327
29360
  position: labelType === "inside" ? "inside" : "outside",
29328
- content: renderLabel
29361
+ fill: labelType === "inside" ? "#fff" : "#000",
29362
+ fontSize: forceMobile ? 10 : 13,
29363
+ fontWeight: 600
29329
29364
  }
29330
29365
  )
29331
29366
  ]
29332
29367
  }
29333
29368
  ),
29334
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_recharts2.Tooltip, { formatter: (value, name) => [`${value}k`, name] })
29369
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
29370
+ import_recharts2.Tooltip,
29371
+ {
29372
+ formatter: (value, name) => [`${value}k`, name]
29373
+ }
29374
+ )
29335
29375
  ] }) }),
29336
- /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("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: [
29337
- total,
29338
- "k"
29339
- ] })
29376
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29377
+ "div",
29378
+ {
29379
+ 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]`,
29380
+ children: [
29381
+ total,
29382
+ "k"
29383
+ ]
29384
+ }
29385
+ )
29340
29386
  ] }),
29341
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: `flex ${forceDesktop ? "flex-col ml-auto space-y-3" : "flex-wrap justify-center gap-2 mt-4"}
29342
- w-full md:w-auto`, children: renderLegends() })
29387
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "flex flex-wrap justify-center gap-2 mt-6 w-full md:w-auto", children: renderLegends })
29343
29388
  ]
29344
29389
  }
29345
29390
  );
29346
29391
  };
29347
- var PieChart_default = DonutChart;
29392
+ var PieChart_default = import_react28.default.memo(DonutChart);
29348
29393
 
29349
29394
  // src/components/Blocks/EmailComposer.tsx
29350
29395
  var import_jsx_runtime61 = require("react/jsx-runtime");