@algorithm-shift/design-system 1.2.983 → 1.2.985

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
@@ -609,6 +609,19 @@ function DropdownMenuItem({
609
609
  }
610
610
  );
611
611
  }
612
+ function DropdownMenuSeparator({
613
+ className,
614
+ ...props
615
+ }) {
616
+ return /* @__PURE__ */ jsx16(
617
+ DropdownMenuPrimitive.Separator,
618
+ {
619
+ "data-slot": "dropdown-menu-separator",
620
+ className: cn("bg-border -mx-1 my-1 h-px", className),
621
+ ...props
622
+ }
623
+ );
624
+ }
612
625
  function DropdownMenuSub({
613
626
  ...props
614
627
  }) {
@@ -685,28 +698,12 @@ function SplitButton({ style, textContent, className, list = [] }) {
685
698
 
686
699
  // src/components/Basic/Icon/Icon.tsx
687
700
  import { useEffect as useEffect3, useState as useState5 } from "react";
701
+ import * as SolidIcons from "@fortawesome/free-solid-svg-icons";
702
+ import * as RegularIcons from "@fortawesome/free-regular-svg-icons";
703
+ import * as BrandIcons from "@fortawesome/free-brands-svg-icons";
688
704
  import { FontAwesomeIcon as FontAwesomeIcon2 } from "@fortawesome/react-fontawesome";
689
705
  import * as LucideIcons from "lucide-react";
690
706
  import { jsx as jsx18 } from "react/jsx-runtime";
691
- async function loadFAIcon(iconName, prefix = "fas") {
692
- const pkgMap = {
693
- fas: "@fortawesome/free-solid-svg-icons",
694
- // Solid
695
- far: "@fortawesome/free-regular-svg-icons",
696
- // Regular
697
- fab: "@fortawesome/free-brands-svg-icons"
698
- // Brands
699
- };
700
- const basePackage = pkgMap[prefix] || pkgMap["fas"];
701
- const modulePath = `${basePackage}`;
702
- try {
703
- const mod = await import(modulePath);
704
- return mod[iconName] || Object.values(mod)[0];
705
- } catch {
706
- console.warn(`FA icon not found in ${modulePath}`);
707
- return null;
708
- }
709
- }
710
707
  function Icon(props) {
711
708
  const {
712
709
  iconSet = "fontawesome",
@@ -722,6 +719,15 @@ function Icon(props) {
722
719
  ...rest
723
720
  } = props;
724
721
  const [dynamicIcon, setDynamicIcon] = useState5(icon || null);
722
+ async function loadFAIcon(iconName, prefix2 = "fas") {
723
+ const pkgMap = {
724
+ fas: SolidIcons,
725
+ far: RegularIcons,
726
+ fab: BrandIcons
727
+ };
728
+ const basePackage = pkgMap[prefix2] ?? SolidIcons;
729
+ return basePackage[iconName] ?? null;
730
+ }
725
731
  useEffect3(() => {
726
732
  if (icon && iconSet === "fontawesome") {
727
733
  loadFAIcon(icon, prefix).then((ico) => setDynamicIcon(ico));
@@ -738,7 +744,10 @@ function Icon(props) {
738
744
  Comp,
739
745
  {
740
746
  size: numericSize,
741
- className,
747
+ className: cn(
748
+ className,
749
+ props.onClick ? "cursor-pointer" : ""
750
+ ),
742
751
  title,
743
752
  style,
744
753
  "aria-hidden": title ? void 0 : true,
@@ -760,7 +769,10 @@ function Icon(props) {
760
769
  spin,
761
770
  spinPulse: pulse,
762
771
  widthAuto: fixedWidth,
763
- className: cn(className),
772
+ className: cn(
773
+ className,
774
+ props.onClick ? "cursor-pointer" : ""
775
+ ),
764
776
  title,
765
777
  style: {
766
778
  ...tempStyle
@@ -5167,7 +5179,11 @@ import { jsx as jsx63, jsxs as jsxs39 } from "react/jsx-runtime";
5167
5179
  import { jsx as jsx64 } from "react/jsx-runtime";
5168
5180
 
5169
5181
  // src/components/Navigation/Navbar/Navbar.tsx
5182
+ import { useCallback as useCallback4, useMemo as useMemo9, useState as useState14, useEffect as useEffect26 } from "react";
5170
5183
  import { Bell, Search as Search2, Menu as Menu2 } from "lucide-react";
5184
+ import Image3 from "next/image";
5185
+ import Link4 from "next/link";
5186
+ import { useRouter as useRouter2 } from "next/navigation";
5171
5187
 
5172
5188
  // src/components/ui/avatar.tsx
5173
5189
  import * as React12 from "react";
@@ -5208,11 +5224,6 @@ var AvatarFallback = React12.forwardRef(({ className, ...props }, ref) => /* @__
5208
5224
  AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
5209
5225
 
5210
5226
  // src/components/Navigation/Navbar/Navbar.tsx
5211
- import Link4 from "next/link";
5212
- import Image3 from "next/image";
5213
- import { useRouter as useRouter2 } from "next/navigation";
5214
- import { DropdownMenuSeparator } from "@radix-ui/react-dropdown-menu";
5215
- import { useCallback as useCallback4, useMemo as useMemo9, useState as useState14 } from "react";
5216
5227
  import { Fragment as Fragment23, jsx as jsx66, jsxs as jsxs40 } from "react/jsx-runtime";
5217
5228
  function Navbar({
5218
5229
  style,
@@ -5224,44 +5235,76 @@ function Navbar({
5224
5235
  imageUrl,
5225
5236
  altText = "Logo",
5226
5237
  canvasMode = "desktop",
5238
+ // desktop | mobile | tablet
5227
5239
  list = [],
5228
5240
  profileMenu = [],
5229
5241
  userName = "Guest User",
5230
5242
  isBuilder = false,
5231
5243
  source,
5232
- navList
5244
+ navList,
5245
+ onSearch
5233
5246
  }) {
5234
- const isMobileView = canvasMode === "mobile" || canvasMode === "tablet";
5235
5247
  const router = useRouter2();
5236
- const [showExitDialog, setShowExitDialog] = useState14(false);
5237
- const [pendingUrl, setPendingUrl] = useState14(null);
5248
+ const [screenMode, setScreenMode] = useState14(
5249
+ canvasMode
5250
+ );
5251
+ useEffect26(() => {
5252
+ const detectMode = () => {
5253
+ if (window.innerWidth < 640) setScreenMode("mobile");
5254
+ else if (window.innerWidth < 1024) setScreenMode("tablet");
5255
+ else setScreenMode("desktop");
5256
+ };
5257
+ detectMode();
5258
+ window.addEventListener("resize", detectMode);
5259
+ return () => window.removeEventListener("resize", detectMode);
5260
+ }, []);
5261
+ const mode = canvasMode || screenMode;
5262
+ const isMobile = mode === "mobile";
5263
+ const isTablet = mode === "tablet";
5264
+ const isDesktop = mode === "desktop";
5238
5265
  const handleBuilderExit = useCallback4(
5239
5266
  (e, url) => {
5240
5267
  if (isBuilder) {
5241
5268
  e.preventDefault();
5242
- setPendingUrl(url);
5243
- setShowExitDialog(true);
5269
+ showSonnerToast({ variant: "info", title: `You will be redirected to ${url} in the real app.`, duration: 3e3 });
5270
+ } else {
5271
+ router.push(url);
5244
5272
  }
5245
5273
  },
5246
5274
  [isBuilder]
5247
5275
  );
5248
- const confirmExit = () => {
5249
- if (pendingUrl) {
5250
- setShowExitDialog(false);
5251
- router.push(pendingUrl);
5252
- }
5253
- };
5254
- const formatedMenu = useMemo9(() => {
5255
- if (source === "state" && navList && navList.length) {
5256
- return navList.map((i) => ({ ...i, header: i.name || "Menu" }));
5276
+ const formattedMenu = useMemo9(() => {
5277
+ if (source === "state" && navList?.length) {
5278
+ return navList.map((i) => ({
5279
+ ...i,
5280
+ header: i.name || "Menu"
5281
+ }));
5257
5282
  }
5258
- return list || [];
5259
- }, [source, navList]);
5283
+ return list;
5284
+ }, [source, navList, list]);
5285
+ const RenderSearchInput = () => /* @__PURE__ */ jsx66("div", { className: "flex-1 px-2", children: /* @__PURE__ */ jsxs40("div", { className: "relative w-full max-w-md border border-gray-300 rounded-md", children: [
5286
+ /* @__PURE__ */ jsx66(Search2, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dark:text-white text-gray-400" }),
5287
+ /* @__PURE__ */ jsx66(
5288
+ Input,
5289
+ {
5290
+ placeholder: "Search",
5291
+ className: "pl-9 text-gray-500",
5292
+ onKeyDown: (event) => {
5293
+ if (event.key === "Enter") {
5294
+ const query = event.target.value;
5295
+ onSearch?.({
5296
+ searchTerm: query
5297
+ });
5298
+ }
5299
+ }
5300
+ }
5301
+ )
5302
+ ] }) });
5260
5303
  return /* @__PURE__ */ jsxs40(Fragment23, { children: [
5261
5304
  /* @__PURE__ */ jsx66(
5262
5305
  "nav",
5263
5306
  {
5264
- className: "w-full h-[75px] border-b border-b-white dark:border-b-gray-800 dark:bg-gray-800 bg-white shadow-sm",
5307
+ className: "w-full min-h-[75px] border-b border-gray-200 dark:border-gray-800 dark:bg-gray-800 bg-white shadow-sm",
5265
5308
  style,
5266
5309
  children: /* @__PURE__ */ jsxs40("div", { className: "mx-auto flex max-w-[90%] items-center justify-between px-4 py-4", children: [
5267
5310
  /* @__PURE__ */ jsx66(
@@ -5270,69 +5313,36 @@ function Navbar({
5270
5313
  href: "/",
5271
5314
  onClick: (e) => handleBuilderExit(e, "/"),
5272
5315
  className: "flex items-center space-x-2",
5273
- children: imageUrl ? /* @__PURE__ */ jsx66(Image3, { src: imageUrl, alt: altText, width: 200, height: 200 }) : /* @__PURE__ */ jsx66("span", { className: "font-semibold text-blue-700", children: "Logo" })
5316
+ children: imageUrl ? /* @__PURE__ */ jsx66(Image3, { src: imageUrl, alt: altText, width: 180, height: 40 }) : /* @__PURE__ */ jsx66("span", { className: "font-semibold text-blue-700", children: "Logo" })
5274
5317
  }
5275
5318
  ),
5276
- !isMobileView && /* @__PURE__ */ jsx66("div", { className: "flex items-center space-x-6 sm:hidden md:flex", children: formatedMenu.map((item) => /* @__PURE__ */ jsx66(
5319
+ isDesktop && /* @__PURE__ */ jsx66("div", { className: "hidden md:flex items-center space-x-6", children: formattedMenu.map((item) => /* @__PURE__ */ jsx66(
5277
5320
  Link4,
5278
5321
  {
5279
- href: item.url || "#",
5322
+ href: item.url,
5280
5323
  onClick: (e) => handleBuilderExit(e, item.url),
5281
- className: "text-sm font-medium dark:text-white text-gray-600 hover:text-gray-900 transition-colors",
5324
+ className: "text-sm font-medium text-gray-600 dark:text-white hover:text-gray-900",
5282
5325
  children: item.header
5283
5326
  },
5284
5327
  item.id
5285
5328
  )) }),
5286
5329
  /* @__PURE__ */ jsxs40("div", { className: "flex items-center space-x-3", children: [
5287
- !isMobileView ? /* @__PURE__ */ jsx66("div", { className: "flex-1 px-6", children: /* @__PURE__ */ jsxs40("div", { className: "relative w-full max-w-md border border-gray-300 rounded-md", children: [
5288
- /* @__PURE__ */ jsx66(Search2, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dark:text-white text-gray-400" }),
5289
- /* @__PURE__ */ jsx66(Input, { placeholder: "Search", className: "pl-9 text-gray-400" })
5290
- ] }) }) : /* @__PURE__ */ jsx66(Button, { variant: "ghost", size: "icon", className: "border border-gray-400", children: /* @__PURE__ */ jsx66(Search2, { className: "h-5 w-5 text-gray-400" }) }),
5291
- /* @__PURE__ */ jsxs40("div", { className: "relative bg-[#E9E9E9] dark:bg-gray-700 rounded-md", children: [
5292
- /* @__PURE__ */ jsx66(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ jsx66(Bell, { className: "h-5 w-5 text-[#1C1B1F] dark:text-gray-400" }) }),
5293
- badgeType === "number" && !(hideBadgeWhenZero && badgeCount === 0) && Number(badgeCount) > 0 ? /* @__PURE__ */ jsx66("span", { className: "absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full bg-red-500 text-[10px] text-white leading-8", children: badgeCount }) : /* @__PURE__ */ jsx66("span", { className: "absolute -top-1 -right-1 flex h-2 w-2 items-center justify-center rounded-full bg-red-500" })
5330
+ (isDesktop || isTablet) && /* @__PURE__ */ jsx66(RenderSearchInput, {}),
5331
+ /* @__PURE__ */ jsxs40("div", { className: "relative bg-gray-200 dark:bg-gray-700 rounded-md", children: [
5332
+ /* @__PURE__ */ jsx66(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ jsx66(Bell, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }) }),
5333
+ badgeType === "number" && !(hideBadgeWhenZero && badgeCount === 0) && Number(badgeCount) > 0 ? /* @__PURE__ */ jsx66("span", { className: "absolute -top-1 -right-1 h-4 w-4 flex items-center justify-center bg-red-500 rounded-full text-white text-[10px]", children: badgeCount }) : !hideBadgeWhenZero && /* @__PURE__ */ jsx66("span", { className: "absolute -top-1 -right-1 h-2 w-2 bg-red-500 rounded-full" })
5294
5334
  ] }),
5295
5335
  /* @__PURE__ */ jsxs40(DropdownMenu, { children: [
5296
- /* @__PURE__ */ jsx66(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs40("div", { className: "flex items-center space-x-2", children: [
5297
- !isMobileView && showName && /* @__PURE__ */ jsx66("h4", { className: "text-[#000000] dark:text-gray-300 text-[13px] font-[500] mb-0", children: userName }),
5298
- !isMobileView ? /* @__PURE__ */ jsxs40(Fragment23, { children: [
5299
- /* @__PURE__ */ jsx66(Avatar, { className: "cursor-pointer h-8 w-8 text-gray-900", children: profileType === "avatar" ? /* @__PURE__ */ jsx66(
5300
- AvatarImage,
5301
- {
5302
- src: "/images/appbuilder/toolset/profile.svg",
5303
- alt: "Profile"
5304
- }
5305
- ) : /* @__PURE__ */ jsx66("div", { className: "w-8 h-8 bg-[#12715b] rounded-full text-[#fff] text-center text-[11px] flex items-center justify-center", children: userName && getInitials(userName) }) }),
5306
- /* @__PURE__ */ jsx66(
5307
- Button,
5308
- {
5309
- variant: "ghost",
5310
- size: "icon",
5311
- className: "text-gray-900 md:hidden dark:invert",
5312
- children: /* @__PURE__ */ jsx66(Menu2, { className: "h-6 w-6" })
5313
- }
5314
- )
5315
- ] }) : /* @__PURE__ */ jsx66(Button, { variant: "ghost", size: "icon", className: "text-gray-900 dark:invert", children: /* @__PURE__ */ jsx66(Menu2, { className: "h-6 w-6" }) })
5336
+ /* @__PURE__ */ jsx66(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs40("div", { className: "flex items-center space-x-2 cursor-pointer", children: [
5337
+ !isMobile && showName && /* @__PURE__ */ jsx66("h4", { className: "text-gray-900 dark:text-gray-300 text-sm", children: userName }),
5338
+ /* @__PURE__ */ jsx66(Avatar, { className: "h-8 w-8", children: profileType === "avatar" ? /* @__PURE__ */ jsx66(AvatarImage, { src: "/images/appbuilder/toolset/profile.svg", alt: "profile" }) : /* @__PURE__ */ jsx66("div", { className: "bg-green-700 text-white h-full w-full rounded-full flex items-center justify-center text-xs", children: getInitials(userName) }) }),
5339
+ (isMobile || isTablet) && /* @__PURE__ */ jsx66(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ jsx66(Menu2, { className: "h-6 w-6" }) })
5316
5340
  ] }) }),
5317
5341
  /* @__PURE__ */ jsxs40(DropdownMenuContent, { align: "end", className: "bg-white dark:bg-gray-800", children: [
5318
- profileMenu && profileMenu.length > 0 && /* @__PURE__ */ jsx66(Fragment23, { children: profileMenu.map((item) => /* @__PURE__ */ jsx66(DropdownMenuItem, { className: "text-black dark:invert", children: /* @__PURE__ */ jsx66(
5319
- Link4,
5320
- {
5321
- href: item.url || "#",
5322
- onClick: (e) => handleBuilderExit(e, item.url),
5323
- children: item.header
5324
- }
5325
- ) }, item.id)) }),
5326
- /* @__PURE__ */ jsxs40("div", { className: "md:hidden", children: [
5342
+ profileMenu.map((item) => /* @__PURE__ */ jsx66(DropdownMenuItem, { children: /* @__PURE__ */ jsx66(Link4, { href: item.url, onClick: (e) => handleBuilderExit(e, item.url), children: item.header }) }, item.id)),
5343
+ (isMobile || isTablet) && /* @__PURE__ */ jsxs40(Fragment23, { children: [
5327
5344
  /* @__PURE__ */ jsx66(DropdownMenuSeparator, {}),
5328
- formatedMenu && formatedMenu.length > 0 && /* @__PURE__ */ jsx66(Fragment23, { children: formatedMenu.map((item) => /* @__PURE__ */ jsx66(DropdownMenuItem, { className: "text-black dark:invert", children: /* @__PURE__ */ jsx66(
5329
- Link4,
5330
- {
5331
- href: item.url || "#",
5332
- onClick: (e) => handleBuilderExit(e, item.url),
5333
- children: item.header
5334
- }
5335
- ) }, item.id)) })
5345
+ formattedMenu.map((item) => /* @__PURE__ */ jsx66(DropdownMenuItem, { children: /* @__PURE__ */ jsx66(Link4, { href: item.url, onClick: (e) => handleBuilderExit(e, item.url), children: item.header }) }, item.id))
5336
5346
  ] })
5337
5347
  ] })
5338
5348
  ] })
@@ -5340,21 +5350,12 @@ function Navbar({
5340
5350
  ] })
5341
5351
  }
5342
5352
  ),
5343
- /* @__PURE__ */ jsx66(Dialog, { open: showExitDialog, onOpenChange: setShowExitDialog, children: /* @__PURE__ */ jsxs40(DialogContent, { className: "bg-[#fff]", children: [
5344
- /* @__PURE__ */ jsxs40(DialogHeader, { children: [
5345
- /* @__PURE__ */ jsx66(DialogTitle, { children: "Exit Builder?" }),
5346
- /* @__PURE__ */ jsx66(DialogDescription, { children: "You are about to leave the builder. Any unsaved changes may be lost." })
5347
- ] }),
5348
- /* @__PURE__ */ jsxs40(DialogFooter, { children: [
5349
- /* @__PURE__ */ jsx66(Button, { className: "cursor-pointer bg-[#12715b] text-[#fff]", variant: "outline", onClick: () => setShowExitDialog(false), children: "Cancel" }),
5350
- /* @__PURE__ */ jsx66(Button, { className: "cursor-pointer border-[#12715b] border", onClick: confirmExit, children: "Yes, Exit" })
5351
- ] })
5352
- ] }) })
5353
+ isMobile && /* @__PURE__ */ jsx66("div", { className: "p-3", children: /* @__PURE__ */ jsx66(RenderSearchInput, {}) })
5353
5354
  ] });
5354
5355
  }
5355
5356
 
5356
5357
  // src/components/Chart/BarChart.tsx
5357
- import React13, { useEffect as useEffect26, useMemo as useMemo10, useState as useState15, useCallback as useCallback5 } from "react";
5358
+ import React13, { useEffect as useEffect27, useMemo as useMemo10, useState as useState15, useCallback as useCallback5 } from "react";
5358
5359
  import axios3 from "axios";
5359
5360
  import {
5360
5361
  BarChart,
@@ -5432,7 +5433,7 @@ var ChartComponent = ({
5432
5433
  const [currentPage, setCurrentPage] = useState15(1);
5433
5434
  const effectiveData = apiUrl ? rawData : props.data || [];
5434
5435
  const effectiveLoading = apiUrl ? localLoading : externalLoading;
5435
- useEffect26(() => {
5436
+ useEffect27(() => {
5436
5437
  if (apiUrl) {
5437
5438
  setCurrentPage(1);
5438
5439
  }
@@ -5474,7 +5475,7 @@ var ChartComponent = ({
5474
5475
  if (!cancelled) setLocalLoading(false);
5475
5476
  }
5476
5477
  }, [apiUrl, limit]);
5477
- useEffect26(() => {
5478
+ useEffect27(() => {
5478
5479
  if (!apiUrl) return;
5479
5480
  fetchData(currentPage);
5480
5481
  }, [apiUrl, currentPage, fetchData]);
@@ -5673,7 +5674,7 @@ var ChartComponent = ({
5673
5674
  var BarChart_default = React13.memo(ChartComponent);
5674
5675
 
5675
5676
  // src/components/Chart/PieChart.tsx
5676
- import React14, { useEffect as useEffect27, useMemo as useMemo11, useState as useState16 } from "react";
5677
+ import React14, { useEffect as useEffect28, useMemo as useMemo11, useState as useState16 } from "react";
5677
5678
  import axios4 from "axios";
5678
5679
  import {
5679
5680
  PieChart,
@@ -5763,7 +5764,7 @@ var DonutChart = ({
5763
5764
  const [localLoading, setLocalLoading] = useState16(false);
5764
5765
  const effectiveData = apiUrl ? rawData : props.data || [];
5765
5766
  const effectiveLoading = apiUrl ? localLoading : externalLoading;
5766
- useEffect27(() => {
5767
+ useEffect28(() => {
5767
5768
  if (!apiUrl) return;
5768
5769
  let cancelled = false;
5769
5770
  const fetchData = async () => {
@@ -5845,7 +5846,7 @@ var DonutChart = ({
5845
5846
  return { inner: 70, outer: 130 };
5846
5847
  };
5847
5848
  const [mounted, setMounted] = useState16(false);
5848
- useEffect27(() => {
5849
+ useEffect28(() => {
5849
5850
  const timeout = setTimeout(() => setMounted(true), 100);
5850
5851
  return () => clearTimeout(timeout);
5851
5852
  }, []);