@algorithm-shift/design-system 1.2.960 → 1.2.962

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
@@ -137,6 +137,8 @@ interface TabsProps extends ElementProps {
137
137
  menuNameKey?: string;
138
138
  menuUrlKey?: string;
139
139
  loading?: boolean;
140
+ bgActiveColor?: string;
141
+ textActiveColor?: string;
140
142
  }
141
143
 
142
144
  interface StagesProps extends ElementProps {
@@ -382,7 +384,7 @@ declare const Table: ({ columns, data, rowActions, className, style, pagination,
382
384
 
383
385
  declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVisiblePages, perPage, }: CustomPaginationProps) => react_jsx_runtime.JSX.Element;
384
386
 
385
- declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading }: TabsProps) => react_jsx_runtime.JSX.Element;
387
+ declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }: TabsProps) => react_jsx_runtime.JSX.Element;
386
388
 
387
389
  declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading }: StagesProps) => react_jsx_runtime.JSX.Element;
388
390
 
package/dist/index.d.ts CHANGED
@@ -137,6 +137,8 @@ interface TabsProps extends ElementProps {
137
137
  menuNameKey?: string;
138
138
  menuUrlKey?: string;
139
139
  loading?: boolean;
140
+ bgActiveColor?: string;
141
+ textActiveColor?: string;
140
142
  }
141
143
 
142
144
  interface StagesProps extends ElementProps {
@@ -382,7 +384,7 @@ declare const Table: ({ columns, data, rowActions, className, style, pagination,
382
384
 
383
385
  declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVisiblePages, perPage, }: CustomPaginationProps) => react_jsx_runtime.JSX.Element;
384
386
 
385
- declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading }: TabsProps) => react_jsx_runtime.JSX.Element;
387
+ declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }: TabsProps) => react_jsx_runtime.JSX.Element;
386
388
 
387
389
  declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading }: StagesProps) => react_jsx_runtime.JSX.Element;
388
390
 
package/dist/index.js CHANGED
@@ -27772,7 +27772,7 @@ function useLazyDropdown(config) {
27772
27772
  }, [config]);
27773
27773
  function getValueByPath2(obj, path) {
27774
27774
  if (!obj || !path) return void 0;
27775
- const parts = path.split(/\.|__/);
27775
+ const parts = path.split(/\./);
27776
27776
  return parts.reduce((acc, key) => acc?.[key], obj);
27777
27777
  }
27778
27778
  const transformToOptions = (0, import_react19.useCallback)((data) => {
@@ -27782,7 +27782,7 @@ function useLazyDropdown(config) {
27782
27782
  const value = getValueByPath2(item, cfg.dataKey) ?? item.id ?? "";
27783
27783
  let label = "";
27784
27784
  if (cfg.dataLabel) {
27785
- label = getValueByPath2(item, cfg.dataLabel) ?? item.name ?? item.label ?? "";
27785
+ label = getValueByPath2(item, cfg.dataLabel) ?? item.name ?? item.label ?? item.first_name ?? "";
27786
27786
  }
27787
27787
  return {
27788
27788
  value,
@@ -29426,10 +29426,17 @@ function DataTable({
29426
29426
  onPageChange?.(currentPageIndex, newSize);
29427
29427
  setLocalPageSize(newSize);
29428
29428
  };
29429
+ const pageSizeOptions = React9.useMemo(() => {
29430
+ const options = [10, 20, 50, 100].filter((size) => size < totalRecords);
29431
+ if (options.length === 0) {
29432
+ options.push(10);
29433
+ }
29434
+ return options;
29435
+ }, [totalRecords]);
29429
29436
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "overflow-hidden rounded-md w-full", children: [
29430
29437
  !loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex justify-between p-2 bg-gray-50", children: [
29431
29438
  /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-4 w-full", children: [
29432
- /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("p", { className: "text-sm font-medium", children: [
29439
+ !!totalRecords && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("p", { className: "text-sm font-medium", children: [
29433
29440
  "Total Records : ",
29434
29441
  totalRecords.toLocaleString("en-IN") || 0
29435
29442
  ] }),
@@ -29659,7 +29666,7 @@ function DataTable({
29659
29666
  value: localPageSize,
29660
29667
  onChange: handlePageSizeChange,
29661
29668
  className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
29662
- children: [10, 20, 50, 100].map((size) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("option", { value: size, children: [
29669
+ children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("option", { value: size, children: [
29663
29670
  size,
29664
29671
  " / page"
29665
29672
  ] }, size))
@@ -30092,9 +30099,46 @@ function DialogDescription({
30092
30099
  );
30093
30100
  }
30094
30101
 
30102
+ // src/components/ui/sonner-toast.tsx
30103
+ var import_sonner = require("sonner");
30104
+ function showSonnerToast({
30105
+ title,
30106
+ description,
30107
+ variant = "default",
30108
+ duration = 3e3,
30109
+ actionLabel,
30110
+ onAction
30111
+ }) {
30112
+ const options = {
30113
+ description,
30114
+ duration,
30115
+ action: actionLabel ? {
30116
+ label: actionLabel,
30117
+ onClick: onAction || (() => {
30118
+ })
30119
+ } : void 0
30120
+ };
30121
+ switch (variant) {
30122
+ case "success":
30123
+ import_sonner.toast.success(title, options);
30124
+ break;
30125
+ case "error":
30126
+ import_sonner.toast.error(title, options);
30127
+ break;
30128
+ case "info":
30129
+ import_sonner.toast.info(title, options);
30130
+ break;
30131
+ case "warning":
30132
+ import_sonner.toast.warning(title, options);
30133
+ break;
30134
+ default:
30135
+ (0, import_sonner.toast)(title, options);
30136
+ }
30137
+ }
30138
+
30095
30139
  // src/components/Navigation/Tabs/Tabs.tsx
30096
30140
  var import_jsx_runtime56 = require("react/jsx-runtime");
30097
- var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder = false, source, parentKey, menuNameKey, menuUrlKey, loading }) => {
30141
+ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder = false, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }) => {
30098
30142
  const [openIndex, setOpenIndex] = (0, import_react31.useState)(null);
30099
30143
  function groupMenus(menus = []) {
30100
30144
  const menuMap = /* @__PURE__ */ new Map();
@@ -30134,11 +30178,23 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30134
30178
  return groupMenus(tabs);
30135
30179
  }, [tabs, source, parentKey, menuNameKey, menuUrlKey]);
30136
30180
  const baseClasses = "text-foreground p-2 text-center rounded-md transition-colors";
30137
- const activeClasses = "bg-white/10 text-white";
30138
- const hoverClasses = "hover:bg-white/5";
30181
+ const activeClasses = `${bgActiveColor ?? "bg-white/10"} ${textActiveColor ?? "text-white"}`;
30182
+ const hoverClasses = `${bgActiveColor ? bgActiveColor.replace("bg-", "hover:bg-") : "hover:bg-white/5"} ${textActiveColor ? textActiveColor.replace("text-", "hover:text-") : "hover:text-white"}`;
30139
30183
  const isActive = (path) => {
30140
30184
  if (!path) return false;
30141
- return pathname === path || path !== "/" && pathname?.startsWith(path);
30185
+ const clean = (p) => p.replace(/\/+$/, "");
30186
+ const current = clean(pathname || "");
30187
+ const target = clean(path);
30188
+ if (!current || !target) return false;
30189
+ if (current === target) return true;
30190
+ if (current.startsWith(target) || target.startsWith(current)) return true;
30191
+ const currentLast = current.split("/").pop();
30192
+ const targetLast = target.split("/").pop();
30193
+ return !!currentLast && !!targetLast && currentLast === targetLast;
30194
+ };
30195
+ const isParentActive = (tab) => {
30196
+ if (!Array.isArray(tab.children)) return false;
30197
+ return tab.children.some((child) => isActive(child.url));
30142
30198
  };
30143
30199
  const router = (0, import_navigation3.useRouter)();
30144
30200
  const [showExitDialog, setShowExitDialog] = (0, import_react31.useState)(false);
@@ -30148,7 +30204,11 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30148
30204
  if (isBuilder) {
30149
30205
  e.preventDefault();
30150
30206
  setPendingUrl(url);
30151
- setShowExitDialog(true);
30207
+ showSonnerToast({
30208
+ variant: "success",
30209
+ title: "Navigation Alert",
30210
+ description: `You will be redirected to ${url} in the built application.`
30211
+ });
30152
30212
  }
30153
30213
  },
30154
30214
  [isBuilder]
@@ -30161,7 +30221,8 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30161
30221
  };
30162
30222
  let timeout;
30163
30223
  const renderDesktopTab = (tab, index) => {
30164
- const finalClasses = [baseClasses, isActive(tab.url) ? activeClasses : hoverClasses, tab.className || ""].join(" ");
30224
+ const active = isActive(tab.url) || isParentActive(tab);
30225
+ const finalClasses = [baseClasses, active ? activeClasses : hoverClasses, tab.className || ""].join(" ");
30165
30226
  if (Array.isArray(tab.children) && tab.children.length > 0 && tab.isDropDown) {
30166
30227
  return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
30167
30228
  DropdownMenu,
@@ -30833,43 +30894,6 @@ function EmailComposer({ className, style, to, setTo, showCc, setShowCc, showBcc
30833
30894
  ] }) });
30834
30895
  }
30835
30896
 
30836
- // src/components/ui/sonner-toast.tsx
30837
- var import_sonner = require("sonner");
30838
- function showSonnerToast({
30839
- title,
30840
- description,
30841
- variant = "default",
30842
- duration = 3e3,
30843
- actionLabel,
30844
- onAction
30845
- }) {
30846
- const options = {
30847
- description,
30848
- duration,
30849
- action: actionLabel ? {
30850
- label: actionLabel,
30851
- onClick: onAction || (() => {
30852
- })
30853
- } : void 0
30854
- };
30855
- switch (variant) {
30856
- case "success":
30857
- import_sonner.toast.success(title, options);
30858
- break;
30859
- case "error":
30860
- import_sonner.toast.error(title, options);
30861
- break;
30862
- case "info":
30863
- import_sonner.toast.info(title, options);
30864
- break;
30865
- case "warning":
30866
- import_sonner.toast.warning(title, options);
30867
- break;
30868
- default:
30869
- (0, import_sonner.toast)(title, options);
30870
- }
30871
- }
30872
-
30873
30897
  // src/components/ui/sonner.tsx
30874
30898
  var import_next_themes = require("next-themes");
30875
30899
  var import_sonner2 = require("sonner");