@algorithm-shift/design-system 1.2.984 → 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.d.mts CHANGED
@@ -234,6 +234,7 @@ interface NavbarProps extends ElementProps {
234
234
  isBuilder?: boolean;
235
235
  source?: string;
236
236
  navList?: Record<string, any>;
237
+ onSearch?: (search: { searchTerm: string }) => void;
237
238
  }
238
239
 
239
240
  interface BreadcrumbProps extends ElementProps {
@@ -449,7 +450,8 @@ declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, styl
449
450
 
450
451
  declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
451
452
 
452
- declare function Navbar({ style, badgeType, badgeCount, hideBadgeWhenZero, profileType, showName, imageUrl, altText, canvasMode, list, profileMenu, userName, isBuilder, source, navList }: NavbarProps): react_jsx_runtime.JSX.Element;
453
+ declare function Navbar({ style, badgeType, badgeCount, hideBadgeWhenZero, profileType, showName, imageUrl, altText, canvasMode, // desktop | mobile | tablet
454
+ list, profileMenu, userName, isBuilder, source, navList, onSearch }: NavbarProps): react_jsx_runtime.JSX.Element;
453
455
 
454
456
  declare const _default$1: React$1.MemoExoticComponent<({ className, style, loading: externalLoading, dataKey, dataLabel, apiUrl, isPaginationEnabled, limit, canvasMode, ...props }: BarChartProps) => react_jsx_runtime.JSX.Element>;
455
457
 
package/dist/index.d.ts CHANGED
@@ -234,6 +234,7 @@ interface NavbarProps extends ElementProps {
234
234
  isBuilder?: boolean;
235
235
  source?: string;
236
236
  navList?: Record<string, any>;
237
+ onSearch?: (search: { searchTerm: string }) => void;
237
238
  }
238
239
 
239
240
  interface BreadcrumbProps extends ElementProps {
@@ -449,7 +450,8 @@ declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, styl
449
450
 
450
451
  declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
451
452
 
452
- declare function Navbar({ style, badgeType, badgeCount, hideBadgeWhenZero, profileType, showName, imageUrl, altText, canvasMode, list, profileMenu, userName, isBuilder, source, navList }: NavbarProps): react_jsx_runtime.JSX.Element;
453
+ declare function Navbar({ style, badgeType, badgeCount, hideBadgeWhenZero, profileType, showName, imageUrl, altText, canvasMode, // desktop | mobile | tablet
454
+ list, profileMenu, userName, isBuilder, source, navList, onSearch }: NavbarProps): react_jsx_runtime.JSX.Element;
453
455
 
454
456
  declare const _default$1: React$1.MemoExoticComponent<({ className, style, loading: externalLoading, dataKey, dataLabel, apiUrl, isPaginationEnabled, limit, canvasMode, ...props }: BarChartProps) => react_jsx_runtime.JSX.Element>;
455
457
 
package/dist/index.js CHANGED
@@ -706,6 +706,19 @@ function DropdownMenuItem({
706
706
  }
707
707
  );
708
708
  }
709
+ function DropdownMenuSeparator({
710
+ className,
711
+ ...props
712
+ }) {
713
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
714
+ DropdownMenuPrimitive.Separator,
715
+ {
716
+ "data-slot": "dropdown-menu-separator",
717
+ className: cn("bg-border -mx-1 my-1 h-px", className),
718
+ ...props
719
+ }
720
+ );
721
+ }
709
722
  function DropdownMenuSub({
710
723
  ...props
711
724
  }) {
@@ -5249,7 +5262,11 @@ var import_jsx_runtime63 = require("react/jsx-runtime");
5249
5262
  var import_jsx_runtime64 = require("react/jsx-runtime");
5250
5263
 
5251
5264
  // src/components/Navigation/Navbar/Navbar.tsx
5265
+ var import_react34 = require("react");
5252
5266
  var import_lucide_react18 = require("lucide-react");
5267
+ var import_image2 = __toESM(require("next/image"));
5268
+ var import_link4 = __toESM(require("next/link"));
5269
+ var import_navigation3 = require("next/navigation");
5253
5270
 
5254
5271
  // src/components/ui/avatar.tsx
5255
5272
  var React12 = __toESM(require("react"));
@@ -5290,11 +5307,6 @@ var AvatarFallback = React12.forwardRef(({ className, ...props }, ref) => /* @__
5290
5307
  AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
5291
5308
 
5292
5309
  // src/components/Navigation/Navbar/Navbar.tsx
5293
- var import_link4 = __toESM(require("next/link"));
5294
- var import_image2 = __toESM(require("next/image"));
5295
- var import_navigation3 = require("next/navigation");
5296
- var import_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
5297
- var import_react34 = require("react");
5298
5310
  var import_jsx_runtime66 = require("react/jsx-runtime");
5299
5311
  function Navbar({
5300
5312
  style,
@@ -5306,44 +5318,76 @@ function Navbar({
5306
5318
  imageUrl,
5307
5319
  altText = "Logo",
5308
5320
  canvasMode = "desktop",
5321
+ // desktop | mobile | tablet
5309
5322
  list = [],
5310
5323
  profileMenu = [],
5311
5324
  userName = "Guest User",
5312
5325
  isBuilder = false,
5313
5326
  source,
5314
- navList
5327
+ navList,
5328
+ onSearch
5315
5329
  }) {
5316
- const isMobileView = canvasMode === "mobile" || canvasMode === "tablet";
5317
5330
  const router = (0, import_navigation3.useRouter)();
5318
- const [showExitDialog, setShowExitDialog] = (0, import_react34.useState)(false);
5319
- const [pendingUrl, setPendingUrl] = (0, import_react34.useState)(null);
5331
+ const [screenMode, setScreenMode] = (0, import_react34.useState)(
5332
+ canvasMode
5333
+ );
5334
+ (0, import_react34.useEffect)(() => {
5335
+ const detectMode = () => {
5336
+ if (window.innerWidth < 640) setScreenMode("mobile");
5337
+ else if (window.innerWidth < 1024) setScreenMode("tablet");
5338
+ else setScreenMode("desktop");
5339
+ };
5340
+ detectMode();
5341
+ window.addEventListener("resize", detectMode);
5342
+ return () => window.removeEventListener("resize", detectMode);
5343
+ }, []);
5344
+ const mode = canvasMode || screenMode;
5345
+ const isMobile = mode === "mobile";
5346
+ const isTablet = mode === "tablet";
5347
+ const isDesktop = mode === "desktop";
5320
5348
  const handleBuilderExit = (0, import_react34.useCallback)(
5321
5349
  (e, url) => {
5322
5350
  if (isBuilder) {
5323
5351
  e.preventDefault();
5324
- setPendingUrl(url);
5325
- setShowExitDialog(true);
5352
+ showSonnerToast({ variant: "info", title: `You will be redirected to ${url} in the real app.`, duration: 3e3 });
5353
+ } else {
5354
+ router.push(url);
5326
5355
  }
5327
5356
  },
5328
5357
  [isBuilder]
5329
5358
  );
5330
- const confirmExit = () => {
5331
- if (pendingUrl) {
5332
- setShowExitDialog(false);
5333
- router.push(pendingUrl);
5334
- }
5335
- };
5336
- const formatedMenu = (0, import_react34.useMemo)(() => {
5337
- if (source === "state" && navList && navList.length) {
5338
- return navList.map((i) => ({ ...i, header: i.name || "Menu" }));
5359
+ const formattedMenu = (0, import_react34.useMemo)(() => {
5360
+ if (source === "state" && navList?.length) {
5361
+ return navList.map((i) => ({
5362
+ ...i,
5363
+ header: i.name || "Menu"
5364
+ }));
5339
5365
  }
5340
- return list || [];
5341
- }, [source, navList]);
5366
+ return list;
5367
+ }, [source, navList, list]);
5368
+ const RenderSearchInput = () => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "flex-1 px-2", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "relative w-full max-w-md border border-gray-300 rounded-md", children: [
5369
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react18.Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dark:text-white text-gray-400" }),
5370
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
5371
+ Input,
5372
+ {
5373
+ placeholder: "Search",
5374
+ className: "pl-9 text-gray-500",
5375
+ onKeyDown: (event) => {
5376
+ if (event.key === "Enter") {
5377
+ const query = event.target.value;
5378
+ onSearch?.({
5379
+ searchTerm: query
5380
+ });
5381
+ }
5382
+ }
5383
+ }
5384
+ )
5385
+ ] }) });
5342
5386
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
5343
5387
  /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
5344
5388
  "nav",
5345
5389
  {
5346
- className: "w-full h-[75px] border-b border-b-white dark:border-b-gray-800 dark:bg-gray-800 bg-white shadow-sm",
5390
+ className: "w-full min-h-[75px] border-b border-gray-200 dark:border-gray-800 dark:bg-gray-800 bg-white shadow-sm",
5347
5391
  style,
5348
5392
  children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "mx-auto flex max-w-[90%] items-center justify-between px-4 py-4", children: [
5349
5393
  /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
@@ -5352,69 +5396,36 @@ function Navbar({
5352
5396
  href: "/",
5353
5397
  onClick: (e) => handleBuilderExit(e, "/"),
5354
5398
  className: "flex items-center space-x-2",
5355
- children: imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_image2.default, { src: imageUrl, alt: altText, width: 200, height: 200 }) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "font-semibold text-blue-700", children: "Logo" })
5399
+ children: imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_image2.default, { src: imageUrl, alt: altText, width: 180, height: 40 }) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "font-semibold text-blue-700", children: "Logo" })
5356
5400
  }
5357
5401
  ),
5358
- !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "flex items-center space-x-6 sm:hidden md:flex", children: formatedMenu.map((item) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
5402
+ isDesktop && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "hidden md:flex items-center space-x-6", children: formattedMenu.map((item) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
5359
5403
  import_link4.default,
5360
5404
  {
5361
- href: item.url || "#",
5405
+ href: item.url,
5362
5406
  onClick: (e) => handleBuilderExit(e, item.url),
5363
- className: "text-sm font-medium dark:text-white text-gray-600 hover:text-gray-900 transition-colors",
5407
+ className: "text-sm font-medium text-gray-600 dark:text-white hover:text-gray-900",
5364
5408
  children: item.header
5365
5409
  },
5366
5410
  item.id
5367
5411
  )) }),
5368
5412
  /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "flex items-center space-x-3", children: [
5369
- !isMobileView ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "flex-1 px-6", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "relative w-full max-w-md border border-gray-300 rounded-md", children: [
5370
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react18.Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dark:text-white text-gray-400" }),
5371
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Input, { placeholder: "Search", className: "pl-9 text-gray-400" })
5372
- ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Button, { variant: "ghost", size: "icon", className: "border border-gray-400", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react18.Search, { className: "h-5 w-5 text-gray-400" }) }),
5373
- /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "relative bg-[#E9E9E9] dark:bg-gray-700 rounded-md", children: [
5374
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react18.Bell, { className: "h-5 w-5 text-[#1C1B1F] dark:text-gray-400" }) }),
5375
- badgeType === "number" && !(hideBadgeWhenZero && badgeCount === 0) && Number(badgeCount) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("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__ */ (0, import_jsx_runtime66.jsx)("span", { className: "absolute -top-1 -right-1 flex h-2 w-2 items-center justify-center rounded-full bg-red-500" })
5413
+ (isDesktop || isTablet) && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(RenderSearchInput, {}),
5414
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "relative bg-gray-200 dark:bg-gray-700 rounded-md", children: [
5415
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react18.Bell, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }) }),
5416
+ badgeType === "number" && !(hideBadgeWhenZero && badgeCount === 0) && Number(badgeCount) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("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__ */ (0, import_jsx_runtime66.jsx)("span", { className: "absolute -top-1 -right-1 h-2 w-2 bg-red-500 rounded-full" })
5376
5417
  ] }),
5377
5418
  /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(DropdownMenu, { children: [
5378
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "flex items-center space-x-2", children: [
5379
- !isMobileView && showName && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("h4", { className: "text-[#000000] dark:text-gray-300 text-[13px] font-[500] mb-0", children: userName }),
5380
- !isMobileView ? /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
5381
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Avatar, { className: "cursor-pointer h-8 w-8 text-gray-900", children: profileType === "avatar" ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
5382
- AvatarImage,
5383
- {
5384
- src: "/images/appbuilder/toolset/profile.svg",
5385
- alt: "Profile"
5386
- }
5387
- ) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("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) }) }),
5388
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
5389
- Button,
5390
- {
5391
- variant: "ghost",
5392
- size: "icon",
5393
- className: "text-gray-900 md:hidden dark:invert",
5394
- children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react18.Menu, { className: "h-6 w-6" })
5395
- }
5396
- )
5397
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Button, { variant: "ghost", size: "icon", className: "text-gray-900 dark:invert", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react18.Menu, { className: "h-6 w-6" }) })
5419
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "flex items-center space-x-2 cursor-pointer", children: [
5420
+ !isMobile && showName && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("h4", { className: "text-gray-900 dark:text-gray-300 text-sm", children: userName }),
5421
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Avatar, { className: "h-8 w-8", children: profileType === "avatar" ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(AvatarImage, { src: "/images/appbuilder/toolset/profile.svg", alt: "profile" }) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "bg-green-700 text-white h-full w-full rounded-full flex items-center justify-center text-xs", children: getInitials(userName) }) }),
5422
+ (isMobile || isTablet) && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react18.Menu, { className: "h-6 w-6" }) })
5398
5423
  ] }) }),
5399
5424
  /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(DropdownMenuContent, { align: "end", className: "bg-white dark:bg-gray-800", children: [
5400
- profileMenu && profileMenu.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_jsx_runtime66.Fragment, { children: profileMenu.map((item) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DropdownMenuItem, { className: "text-black dark:invert", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
5401
- import_link4.default,
5402
- {
5403
- href: item.url || "#",
5404
- onClick: (e) => handleBuilderExit(e, item.url),
5405
- children: item.header
5406
- }
5407
- ) }, item.id)) }),
5408
- /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "md:hidden", children: [
5409
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_react_dropdown_menu.DropdownMenuSeparator, {}),
5410
- formatedMenu && formatedMenu.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_jsx_runtime66.Fragment, { children: formatedMenu.map((item) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DropdownMenuItem, { className: "text-black dark:invert", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
5411
- import_link4.default,
5412
- {
5413
- href: item.url || "#",
5414
- onClick: (e) => handleBuilderExit(e, item.url),
5415
- children: item.header
5416
- }
5417
- ) }, item.id)) })
5425
+ profileMenu.map((item) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DropdownMenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_link4.default, { href: item.url, onClick: (e) => handleBuilderExit(e, item.url), children: item.header }) }, item.id)),
5426
+ (isMobile || isTablet) && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
5427
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DropdownMenuSeparator, {}),
5428
+ formattedMenu.map((item) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DropdownMenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_link4.default, { href: item.url, onClick: (e) => handleBuilderExit(e, item.url), children: item.header }) }, item.id))
5418
5429
  ] })
5419
5430
  ] })
5420
5431
  ] })
@@ -5422,16 +5433,7 @@ function Navbar({
5422
5433
  ] })
5423
5434
  }
5424
5435
  ),
5425
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Dialog, { open: showExitDialog, onOpenChange: setShowExitDialog, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(DialogContent, { className: "bg-[#fff]", children: [
5426
- /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(DialogHeader, { children: [
5427
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DialogTitle, { children: "Exit Builder?" }),
5428
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DialogDescription, { children: "You are about to leave the builder. Any unsaved changes may be lost." })
5429
- ] }),
5430
- /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(DialogFooter, { children: [
5431
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Button, { className: "cursor-pointer bg-[#12715b] text-[#fff]", variant: "outline", onClick: () => setShowExitDialog(false), children: "Cancel" }),
5432
- /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Button, { className: "cursor-pointer border-[#12715b] border", onClick: confirmExit, children: "Yes, Exit" })
5433
- ] })
5434
- ] }) })
5436
+ isMobile && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "p-3", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(RenderSearchInput, {}) })
5435
5437
  ] });
5436
5438
  }
5437
5439