@algorithm-shift/design-system 1.2.90 → 1.2.92

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
@@ -27678,7 +27678,8 @@ function useLazyDropdown(config) {
27678
27678
  const limit = PAGE_SIZE;
27679
27679
  const params = { page: pageNum, limit };
27680
27680
  if (term) params[configRef.current.dataLabel ?? "search"] = term;
27681
- const res = await axios.get(configRef.current.apiUrl, {
27681
+ const axiosClient = configRef.current.axiosInstance ?? axios;
27682
+ const res = await axiosClient.get(configRef.current.apiUrl, {
27682
27683
  params,
27683
27684
  withCredentials: true
27684
27685
  });
@@ -27726,7 +27727,8 @@ function useLazyDropdown(config) {
27726
27727
  if (!configRef.current.apiUrl) return [];
27727
27728
  try {
27728
27729
  setLoading(true);
27729
- const res = await axios.get(configRef.current.apiUrl, {
27730
+ const axiosClient = configRef.current.axiosInstance ?? axios;
27731
+ const res = await axiosClient.get(configRef.current.apiUrl, {
27730
27732
  params: { [configRef.current.dataKey]: configRef.current.value },
27731
27733
  withCredentials: true
27732
27734
  });
@@ -27802,7 +27804,8 @@ function LazySelectDropdown({
27802
27804
  pageSize,
27803
27805
  dataKey = "id",
27804
27806
  dataLabel = "name",
27805
- errorMessage
27807
+ errorMessage,
27808
+ axiosInstance
27806
27809
  }) {
27807
27810
  const [isOpen, setIsOpen] = useState5(false);
27808
27811
  const [searchTerm, setSearchTerm] = useState5("");
@@ -27824,7 +27827,8 @@ function LazySelectDropdown({
27824
27827
  dataKey,
27825
27828
  dataLabel,
27826
27829
  initialData: options || [],
27827
- value
27830
+ value,
27831
+ axiosInstance
27828
27832
  });
27829
27833
  const selectedOption = lazyOptions.find((opt) => opt.value === value);
27830
27834
  useEffect14(() => {
@@ -28913,7 +28917,7 @@ var MultiSelect = ({
28913
28917
  var MultiSelect_default = MultiSelect;
28914
28918
 
28915
28919
  // src/components/ui/data-table.tsx
28916
- import * as React9 from "react";
28920
+ import * as React10 from "react";
28917
28921
  import { faEllipsisH } from "@fortawesome/free-solid-svg-icons";
28918
28922
  import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
28919
28923
  import {
@@ -29013,6 +29017,7 @@ function TableCell({ className, ...props }) {
29013
29017
  import { createColumnHelper } from "@tanstack/react-table";
29014
29018
 
29015
29019
  // src/lib/table/cellRendererFactory.tsx
29020
+ import React9 from "react";
29016
29021
  import Image2 from "next/image";
29017
29022
 
29018
29023
  // src/lib/dayjs-setup.ts
@@ -29093,6 +29098,22 @@ var getContrastColor = (bg) => {
29093
29098
  const brightness = (r * 299 + g * 587 + b * 114) / 1e3;
29094
29099
  return brightness > 160 ? "#000000" : "#FFFFFF";
29095
29100
  };
29101
+ var sanitizeValue = (val) => {
29102
+ if (val == null) return null;
29103
+ if (React9.isValidElement(val)) return val;
29104
+ if (typeof val === "string" || typeof val === "number") return val;
29105
+ if (Array.isArray(val)) return val.map((v, i) => /* @__PURE__ */ jsx52(React9.Fragment, { children: sanitizeValue(v) }, i));
29106
+ if (typeof val === "object") {
29107
+ if ("name" in val && typeof val.name === "string") return val.name;
29108
+ if ("label" in val && typeof val.label === "string") return val.label;
29109
+ try {
29110
+ return JSON.stringify(val);
29111
+ } catch {
29112
+ return "[object]";
29113
+ }
29114
+ }
29115
+ return String(val);
29116
+ };
29096
29117
  var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers = {}, format2, customFormatters = {}) => {
29097
29118
  const formattedValue = valueFormatter(value, format2, customFormatters);
29098
29119
  switch (renderer) {
@@ -29244,13 +29265,15 @@ var useDynamicColumns = (config, customRenderers = {}, customFormatters = {}) =>
29244
29265
  return config.columns.map((col) => {
29245
29266
  const accessorKey = col.accessorKey ?? col.id;
29246
29267
  const accessorFn = (row) => {
29268
+ if (!row) return null;
29247
29269
  if (Object.prototype.hasOwnProperty.call(row, accessorKey)) {
29248
- return row[accessorKey];
29270
+ return sanitizeValue(row[accessorKey]);
29249
29271
  }
29250
29272
  if (accessorKey.includes(".")) {
29251
- return getValueByPath(row, accessorKey);
29273
+ const val = getValueByPath(row, accessorKey);
29274
+ return sanitizeValue(val);
29252
29275
  }
29253
- return row[accessorKey];
29276
+ return sanitizeValue(row[accessorKey]);
29254
29277
  };
29255
29278
  return columnHelper.accessor(accessorFn, {
29256
29279
  id: col.id ?? accessorKey,
@@ -29295,13 +29318,13 @@ function DataTable({
29295
29318
  onDeleteRow,
29296
29319
  rowActions
29297
29320
  }) {
29298
- const [columnFilters, setColumnFilters] = React9.useState([]);
29299
- const [columnVisibility, setColumnVisibility] = React9.useState({});
29300
- const [manualSort, setManualSort] = React9.useState(null);
29301
- const [searchTerm, setSearchTerm] = React9.useState("");
29321
+ const [columnFilters, setColumnFilters] = React10.useState([]);
29322
+ const [columnVisibility, setColumnVisibility] = React10.useState({});
29323
+ const [manualSort, setManualSort] = React10.useState(null);
29324
+ const [searchTerm, setSearchTerm] = React10.useState("");
29302
29325
  const dynamicCols = useDynamicColumns({ columns });
29303
29326
  const table = useReactTable({
29304
- data,
29327
+ data: data ?? [],
29305
29328
  columns: dynamicCols,
29306
29329
  state: {
29307
29330
  columnFilters,
@@ -29514,7 +29537,7 @@ function DataTable({
29514
29537
  return /* @__PURE__ */ jsxs31(
29515
29538
  TableCell,
29516
29539
  {
29517
- className: `${meta?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100" : ""} relative`,
29540
+ className: `${meta?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100 underline text-blue-500" : ""} relative`,
29518
29541
  style: meta?.cellStyle,
29519
29542
  onClick: () => {
29520
29543
  if (isClickable && onCellClick) {
@@ -29863,6 +29886,7 @@ import Link5 from "next/link";
29863
29886
  import { useRouter } from "next/navigation";
29864
29887
  import { Fragment as Fragment21, jsx as jsx57, jsxs as jsxs34 } from "react/jsx-runtime";
29865
29888
  var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder = false, source, parentKey, menuNameKey, menuUrlKey, loading }) => {
29889
+ const [openIndex, setOpenIndex] = useState8(null);
29866
29890
  function groupMenus(menus = []) {
29867
29891
  const menuMap = /* @__PURE__ */ new Map();
29868
29892
  menus.forEach((menu) => {
@@ -29926,40 +29950,69 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
29926
29950
  router.push(pendingUrl);
29927
29951
  }
29928
29952
  };
29953
+ let timeout;
29929
29954
  const renderDesktopTab = (tab, index) => {
29930
29955
  const finalClasses = [baseClasses, isActive(tab.url) ? activeClasses : hoverClasses, tab.className || ""].join(" ");
29931
29956
  if (Array.isArray(tab.children) && tab.children.length > 0 && tab.isDropDown) {
29932
- return /* @__PURE__ */ jsxs34(DropdownMenu, { children: [
29933
- /* @__PURE__ */ jsxs34(DropdownMenuTrigger, { className: `${finalClasses} inline-flex items-center gap-1`, children: [
29934
- tab.header,
29935
- /* @__PURE__ */ jsx57(ChevronDown, { className: "h-4 w-4 opacity-80" })
29936
- ] }),
29937
- /* @__PURE__ */ jsx57(
29938
- DropdownMenuContent,
29939
- {
29940
- align: "start",
29941
- sideOffset: 6,
29942
- className: "z-50 min-w-[160px] rounded-md border border-gray-200 bg-white p-1 shadow-lg",
29943
- children: tab.children.map((item, index2) => /* @__PURE__ */ jsx57(
29944
- DropdownMenuItem,
29957
+ return /* @__PURE__ */ jsxs34(
29958
+ DropdownMenu,
29959
+ {
29960
+ open: openIndex === index,
29961
+ onOpenChange: (open) => setOpenIndex(open ? index : null),
29962
+ children: [
29963
+ /* @__PURE__ */ jsxs34(
29964
+ DropdownMenuTrigger,
29945
29965
  {
29946
- asChild: true,
29947
- className: "cursor-pointer rounded-sm px-3 py-2 text-[12px] text-gray-800 hover:bg-gray-100 focus:bg-gray-100",
29948
- children: /* @__PURE__ */ jsx57(
29949
- Link5,
29966
+ className: `${finalClasses} inline-flex items-center gap-1`,
29967
+ onMouseEnter: () => {
29968
+ clearTimeout(timeout);
29969
+ setOpenIndex(index);
29970
+ },
29971
+ onMouseLeave: () => {
29972
+ timeout = setTimeout(() => setOpenIndex(null), 150);
29973
+ },
29974
+ children: [
29975
+ tab.header,
29976
+ /* @__PURE__ */ jsx57(ChevronDown, { className: "h-4 w-4 opacity-80" })
29977
+ ]
29978
+ }
29979
+ ),
29980
+ /* @__PURE__ */ jsx57(
29981
+ DropdownMenuContent,
29982
+ {
29983
+ align: "start",
29984
+ sideOffset: 6,
29985
+ className: "z-50 min-w-[200px] max-h-80 rounded-md border border-gray-200 bg-white p-1 shadow-lg",
29986
+ onMouseEnter: () => {
29987
+ clearTimeout(timeout);
29988
+ setOpenIndex(index);
29989
+ },
29990
+ onMouseLeave: () => {
29991
+ timeout = setTimeout(() => setOpenIndex(null), 150);
29992
+ },
29993
+ children: tab.children.map((item, index2) => /* @__PURE__ */ jsx57(
29994
+ DropdownMenuItem,
29950
29995
  {
29951
- href: item.url || "#",
29952
- target: item.opens_in_new_tab ? "_blank" : "_self",
29953
- onClick: (e) => handleBuilderExit(e, item.url || "#"),
29954
- children: item.header
29955
- }
29956
- )
29957
- },
29958
- item.id || index2
29959
- ))
29960
- }
29961
- )
29962
- ] }, index);
29996
+ asChild: true,
29997
+ className: "cursor-pointer rounded-sm px-3 py-2 text-[12px] text-gray-800 hover:bg-gray-100 focus:bg-gray-100",
29998
+ children: /* @__PURE__ */ jsx57(
29999
+ Link5,
30000
+ {
30001
+ href: item.url || "#",
30002
+ target: item.opens_in_new_tab ? "_blank" : "_self",
30003
+ onClick: (e) => handleBuilderExit(e, item.url || "#"),
30004
+ children: item.header
30005
+ }
30006
+ )
30007
+ },
30008
+ item.id || index2
30009
+ ))
30010
+ }
30011
+ )
30012
+ ]
30013
+ },
30014
+ index
30015
+ );
29963
30016
  }
29964
30017
  return tab.url ? /* @__PURE__ */ jsx57(
29965
30018
  Link5,
@@ -30017,7 +30070,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30017
30070
  const forceMobile = canvasMode ? canvasMode === "mobile" || canvasMode === "tablet" : void 0;
30018
30071
  const forceDesktop = canvasMode ? canvasMode === "desktop" : void 0;
30019
30072
  return /* @__PURE__ */ jsxs34(Fragment21, { children: [
30020
- /* @__PURE__ */ jsxs34("div", { className, style, children: [
30073
+ /* @__PURE__ */ jsxs34("div", { className: cn("min-h-10", className), style, children: [
30021
30074
  forceDesktop !== void 0 ? forceDesktop && /* @__PURE__ */ jsx57("div", { className: "hidden md:flex", children: /* @__PURE__ */ jsx57("div", { className: `flex gap-2 ${verticalMenu ? "flex-col items-start" : "flex-row"}`, children: rawTabs.map(renderDesktopTab) }) }) : /* @__PURE__ */ jsx57("div", { className: "hidden md:flex", children: /* @__PURE__ */ jsx57("div", { className: `flex gap-2 ${verticalMenu ? "flex-col items-start" : "flex-row"}`, children: rawTabs.map(renderDesktopTab) }) }),
30022
30075
  forceMobile !== void 0 ? forceMobile && /* @__PURE__ */ jsx57("div", { children: renderMobileMenu() }) : /* @__PURE__ */ jsx57("div", { className: "flex md:hidden", children: renderMobileMenu() })
30023
30076
  ] }),
@@ -30036,7 +30089,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30036
30089
  var Tabs_default = Tabs;
30037
30090
 
30038
30091
  // src/components/Navigation/Stages/Stages.tsx
30039
- import React10, { useState as useState9 } from "react";
30092
+ import React11, { useState as useState9 } from "react";
30040
30093
  import { jsx as jsx58, jsxs as jsxs35 } from "react/jsx-runtime";
30041
30094
  var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey = "key", dataLabel = "header", loading }) => {
30042
30095
  const [activeStage, setActiveStage] = useState9(currentStage || (stages && stages.length > 0 ? stages[0].key : null));
@@ -30071,7 +30124,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
30071
30124
  const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
30072
30125
  const isCompleted = isAllStagesCompleted || index < currentIndex;
30073
30126
  const isActive = !isAllStagesCompleted && index === currentIndex;
30074
- return /* @__PURE__ */ jsxs35(React10.Fragment, { children: [
30127
+ return /* @__PURE__ */ jsxs35(React11.Fragment, { children: [
30075
30128
  /* @__PURE__ */ jsx58(
30076
30129
  "button",
30077
30130
  {
@@ -30119,10 +30172,10 @@ import { jsx as jsx61, jsxs as jsxs37 } from "react/jsx-runtime";
30119
30172
  import { jsx as jsx62 } from "react/jsx-runtime";
30120
30173
 
30121
30174
  // src/components/ui/avatar.tsx
30122
- import * as React11 from "react";
30175
+ import * as React12 from "react";
30123
30176
  import * as AvatarPrimitive from "@radix-ui/react-avatar";
30124
30177
  import { jsx as jsx63 } from "react/jsx-runtime";
30125
- var Avatar = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63(
30178
+ var Avatar = React12.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63(
30126
30179
  AvatarPrimitive.Root,
30127
30180
  {
30128
30181
  ref,
@@ -30134,7 +30187,7 @@ var Avatar = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ *
30134
30187
  }
30135
30188
  ));
30136
30189
  Avatar.displayName = AvatarPrimitive.Root.displayName;
30137
- var AvatarImage = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63(
30190
+ var AvatarImage = React12.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63(
30138
30191
  AvatarPrimitive.Image,
30139
30192
  {
30140
30193
  ref,
@@ -30143,7 +30196,7 @@ var AvatarImage = React11.forwardRef(({ className, ...props }, ref) => /* @__PUR
30143
30196
  }
30144
30197
  ));
30145
30198
  AvatarImage.displayName = AvatarPrimitive.Image.displayName;
30146
- var AvatarFallback = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63(
30199
+ var AvatarFallback = React12.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63(
30147
30200
  AvatarPrimitive.Fallback,
30148
30201
  {
30149
30202
  ref,
@@ -30303,7 +30356,7 @@ function Navbar({
30303
30356
  }
30304
30357
 
30305
30358
  // src/components/Chart/BarChart.tsx
30306
- import React12 from "react";
30359
+ import React13 from "react";
30307
30360
  import {
30308
30361
  BarChart,
30309
30362
  Bar,
@@ -30375,10 +30428,10 @@ var ChartComponent = ({ className, style, loading, ...props }) => {
30375
30428
  )
30376
30429
  ] }) }) });
30377
30430
  };
30378
- var BarChart_default = React12.memo(ChartComponent);
30431
+ var BarChart_default = React13.memo(ChartComponent);
30379
30432
 
30380
30433
  // src/components/Chart/PieChart.tsx
30381
- import React13, { useEffect as useEffect25, useMemo as useMemo6, useState as useState11 } from "react";
30434
+ import React14, { useEffect as useEffect25, useMemo as useMemo6, useState as useState11 } from "react";
30382
30435
  import {
30383
30436
  PieChart,
30384
30437
  Pie,
@@ -30506,7 +30559,7 @@ var DonutChart = ({ className, style, loading, ...props }) => {
30506
30559
  }
30507
30560
  );
30508
30561
  };
30509
- var PieChart_default = React13.memo(DonutChart);
30562
+ var PieChart_default = React14.memo(DonutChart);
30510
30563
 
30511
30564
  // src/components/Blocks/EmailComposer.tsx
30512
30565
  import { jsx as jsx67, jsxs as jsxs41 } from "react/jsx-runtime";