@algorithm-shift/design-system 1.3.113 → 1.3.115

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
@@ -239,6 +239,7 @@ interface NavbarProps extends ElementProps {
239
239
  source?: string;
240
240
  navList?: Record<string, any>;
241
241
  onSearch?: (search: { searchTerm: string }) => void;
242
+ primaryColor: string
242
243
  }
243
244
 
244
245
  interface BreadcrumbProps extends ElementProps {
@@ -500,7 +501,7 @@ declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, styl
500
501
  declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
501
502
 
502
503
  declare function Navbar({ style, badgeType, badgeCount, hideBadgeWhenZero, profileType, showName, imageUrl, altText, canvasMode, // desktop | mobile | tablet
503
- list, profileMenu, userName, isBuilder, source, navList, onSearch }: NavbarProps): react_jsx_runtime.JSX.Element;
504
+ list, profileMenu, userName, isBuilder, source, navList, onSearch, primaryColor }: NavbarProps): react_jsx_runtime.JSX.Element;
504
505
 
505
506
  declare const _default$1: React$1.MemoExoticComponent<({ className, style, loading: externalLoading, dataKey, dataLabel, apiUrl, isPaginationEnabled, limit, canvasMode, ...props }: BarChartProps) => react_jsx_runtime.JSX.Element>;
506
507
 
package/dist/index.d.ts CHANGED
@@ -239,6 +239,7 @@ interface NavbarProps extends ElementProps {
239
239
  source?: string;
240
240
  navList?: Record<string, any>;
241
241
  onSearch?: (search: { searchTerm: string }) => void;
242
+ primaryColor: string
242
243
  }
243
244
 
244
245
  interface BreadcrumbProps extends ElementProps {
@@ -500,7 +501,7 @@ declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, styl
500
501
  declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
501
502
 
502
503
  declare function Navbar({ style, badgeType, badgeCount, hideBadgeWhenZero, profileType, showName, imageUrl, altText, canvasMode, // desktop | mobile | tablet
503
- list, profileMenu, userName, isBuilder, source, navList, onSearch }: NavbarProps): react_jsx_runtime.JSX.Element;
504
+ list, profileMenu, userName, isBuilder, source, navList, onSearch, primaryColor }: NavbarProps): react_jsx_runtime.JSX.Element;
504
505
 
505
506
  declare const _default$1: React$1.MemoExoticComponent<({ className, style, loading: externalLoading, dataKey, dataLabel, apiUrl, isPaginationEnabled, limit, canvasMode, ...props }: BarChartProps) => react_jsx_runtime.JSX.Element>;
506
507
 
package/dist/index.js CHANGED
@@ -4107,7 +4107,6 @@ function DataTable({
4107
4107
  onPageChange,
4108
4108
  pageSize = 10,
4109
4109
  paginationMode = "client",
4110
- totalRecords = 0,
4111
4110
  onSortChange,
4112
4111
  onFilterChange,
4113
4112
  onGlobalSearch,
@@ -4120,13 +4119,17 @@ function DataTable({
4120
4119
  tableId,
4121
4120
  manageColumns = false,
4122
4121
  preferenceUrl,
4123
- axiosInstance
4122
+ axiosInstance,
4123
+ meta,
4124
+ enableTotalRecords,
4125
+ getRowCount
4124
4126
  }) {
4125
4127
  const [columnFilters, setColumnFilters] = React11.useState([]);
4126
4128
  const [columnVisibility, setColumnVisibility] = React11.useState({});
4127
4129
  const hasLoadedInitialState = React11.useRef(false);
4128
4130
  const isSavingRef = React11.useRef(false);
4129
4131
  const isFetchingRef = React11.useRef(false);
4132
+ const [fetchLoading, setFetchLoading] = React11.useState(false);
4130
4133
  const transformApiToFrontend = React11.useCallback((apiSettings, allColumnIds) => {
4131
4134
  if (!apiSettings || !apiSettings.columns || !apiSettings.columns.visible) {
4132
4135
  return {};
@@ -4295,8 +4298,10 @@ function DataTable({
4295
4298
  React11.useEffect(() => {
4296
4299
  if (paginationMode === "client") {
4297
4300
  setLocalPageSize(pageSize);
4301
+ } else if (paginationMode === "server" && meta?.limit != null) {
4302
+ setLocalPageSize(meta.limit);
4298
4303
  }
4299
- }, [pageSize, paginationMode]);
4304
+ }, [pageSize, paginationMode, meta?.limit]);
4300
4305
  const table = (0, import_react_table2.useReactTable)({
4301
4306
  data: finalData,
4302
4307
  columns: dynamicCols,
@@ -4311,8 +4316,8 @@ function DataTable({
4311
4316
  columnVisibility,
4312
4317
  rowSelection,
4313
4318
  pagination: {
4314
- pageIndex: paginationMode === "server" ? controlledPageIndex ?? 0 : localPageIndex,
4315
- pageSize: localPageSize
4319
+ pageIndex: paginationMode === "server" ? meta?.page != null ? meta.page - 1 : controlledPageIndex ?? 0 : localPageIndex,
4320
+ pageSize: paginationMode === "server" && meta?.limit != null ? meta.limit : localPageSize
4316
4321
  }
4317
4322
  },
4318
4323
  enableRowSelection: !!enableRowSelection,
@@ -4350,7 +4355,7 @@ function DataTable({
4350
4355
  getFilteredRowModel: (0, import_react_table2.getFilteredRowModel)(),
4351
4356
  getPaginationRowModel: pagination && paginationMode === "client" ? (0, import_react_table2.getPaginationRowModel)() : void 0,
4352
4357
  manualPagination: paginationMode === "server",
4353
- pageCount: paginationMode === "server" ? Math.ceil(totalRecords / localPageSize) : void 0,
4358
+ // pageCount: paginationMode === 'server' ? Math.ceil(totalRecords / localPageSize) : undefined,
4354
4359
  onPaginationChange: (updater) => {
4355
4360
  if (isUpdatingPageSizeRef.current) {
4356
4361
  isUpdatingPageSizeRef.current = false;
@@ -4408,19 +4413,30 @@ function DataTable({
4408
4413
  if (paginationMode === "client") {
4409
4414
  return [5, 10, 20, 50, 100];
4410
4415
  }
4411
- const options = [5, 10, 20, 50, 100].filter((size) => size < totalRecords);
4412
- if (options.length === 0) {
4413
- options.push(5);
4416
+ const base = [5, 10, 20, 50, 100];
4417
+ if (meta?.limit != null && !base.includes(meta.limit)) {
4418
+ const withMeta = [...base, meta.limit].sort((a, b) => a - b);
4419
+ return withMeta;
4414
4420
  }
4415
- return options;
4416
- }, [paginationMode, totalRecords]);
4421
+ return base;
4422
+ }, [paginationMode, meta?.limit]);
4417
4423
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "overflow-hidden rounded-md w-full", children: [
4418
4424
  !loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex justify-between p-2 bg-gray-50", children: [
4419
4425
  /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-4 w-full", children: [
4420
- !!totalRecords && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("p", { className: "text-sm font-medium", children: [
4421
- "Total Records : ",
4422
- totalRecords.toLocaleString("en-IN") || 0
4423
- ] }),
4426
+ enableTotalRecords && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4427
+ Button,
4428
+ {
4429
+ size: "sm",
4430
+ className: "bg-[#12715B] text-white text-xs h-auto py-2 px-3 cursor-pointer",
4431
+ onClick: async () => {
4432
+ setFetchLoading(true);
4433
+ await getRowCount?.();
4434
+ setFetchLoading(false);
4435
+ },
4436
+ disabled: fetchLoading,
4437
+ children: fetchLoading ? "Fetching..." : "Get Total Records"
4438
+ }
4439
+ ),
4424
4440
  globalSearch && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
4425
4441
  /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "relative w-full", children: [
4426
4442
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
@@ -4620,18 +4636,18 @@ function DataTable({
4620
4636
  j
4621
4637
  );
4622
4638
  }) }, i)) }) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableRow, { children: row.getVisibleCells().map((cell, cellIndex, arr) => {
4623
- const meta = cell.column.columnDef.meta || {};
4624
- const isClickable = meta?.isClickable;
4639
+ const meta2 = cell.column.columnDef.meta || {};
4640
+ const isClickable = meta2?.isClickable;
4625
4641
  const isLastCell = cellIndex === arr.length - 1;
4626
4642
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
4627
4643
  TableCell,
4628
4644
  {
4629
- className: `break-words whitespace-normal align-top ${meta?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100 underline text-blue-500" : ""} relative py-2 `,
4645
+ className: `break-words whitespace-normal align-top ${meta2?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100 underline text-blue-500" : ""} relative py-2 `,
4630
4646
  style: {
4631
4647
  width: cell.column.getSize(),
4632
4648
  minWidth: cell.column.columnDef.minSize,
4633
4649
  maxWidth: cell.column.columnDef.maxSize,
4634
- ...meta?.cellStyle ?? {}
4650
+ ...meta2?.cellStyle ?? {}
4635
4651
  },
4636
4652
  onClick: () => {
4637
4653
  if (isClickable && onCellClick) {
@@ -4667,55 +4683,33 @@ function DataTable({
4667
4683
  }) }, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableCell, { colSpan: dynamicCols.length, className: "h-24 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "flex items-center justify-center py-10 w-full min-w-full text-gray-600 bg-gray-100", children: "No results." }) }) }) })
4668
4684
  ] }),
4669
4685
  pagination && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center justify-between py-3 text-sm w-full", children: [
4670
- !loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex gap-2 items-center", children: [
4671
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4672
- "select",
4673
- {
4674
- value: localPageSize,
4675
- onChange: handlePageSizeChange,
4676
- className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
4677
- children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("option", { value: size, children: [
4678
- size,
4679
- " / page"
4680
- ] }, size))
4681
- }
4682
- ),
4683
- /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { children: [
4684
- "Page ",
4685
- table.getState().pagination.pageIndex + 1,
4686
- " of ",
4687
- pageCount
4688
- ] })
4689
- ] }),
4686
+ !loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "flex gap-2 items-center", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4687
+ "select",
4688
+ {
4689
+ value: paginationMode === "server" && meta?.limit != null ? meta.limit : localPageSize,
4690
+ onChange: handlePageSizeChange,
4691
+ className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
4692
+ children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("option", { value: size, children: [
4693
+ size,
4694
+ " / page"
4695
+ ] }, size))
4696
+ }
4697
+ ) }),
4690
4698
  /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-2", children: [
4691
4699
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4692
4700
  "button",
4693
4701
  {
4694
4702
  onClick: () => table.previousPage(),
4695
- disabled: !table.getCanPreviousPage?.(),
4703
+ disabled: paginationMode === "server" && meta != null ? (meta.page ?? 1) <= 1 : !table.getCanPreviousPage?.(),
4696
4704
  className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
4697
4705
  children: "Prev"
4698
4706
  }
4699
4707
  ),
4700
- getPageNumbers(
4701
- table.getState().pagination.pageIndex + 1,
4702
- table.getPageCount(),
4703
- 5
4704
- ).map((pageNum, index) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4705
- "button",
4706
- {
4707
- disabled: pageNum === "...",
4708
- onClick: () => typeof pageNum === "number" && table.setPageIndex(pageNum - 1),
4709
- className: `px-2 py-1 border rounded ${table.getState().pagination.pageIndex + 1 === pageNum ? "bg-[#12715B] text-white" : "bg-white"} ${pageNum === "..." ? "cursor-default" : "cursor-pointer"}`,
4710
- children: pageNum
4711
- },
4712
- index
4713
- )),
4714
4708
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4715
4709
  "button",
4716
4710
  {
4717
4711
  onClick: () => table.nextPage(),
4718
- disabled: !table.getCanNextPage?.(),
4712
+ disabled: paginationMode === "server" && meta != null ? !meta.hasMore : !table.getCanNextPage?.(),
4719
4713
  className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
4720
4714
  children: "Next"
4721
4715
  }
@@ -4766,7 +4760,6 @@ var Table2 = ({
4766
4760
  onPageChange?.({ page: pageIndex + 1, itemsPerPage: pageSize });
4767
4761
  },
4768
4762
  paginationMode,
4769
- totalRecords,
4770
4763
  onSortChange: (col, dir) => onSortChange?.({ sort_by: col, sort_order: dir }),
4771
4764
  onFilterChange: (filters) => onFilterChange?.({ columnKey: filters.columnKey, columnTerm: filters.columnTerm }),
4772
4765
  onGlobalSearch: (term) => onGlobalSearch?.({ searchTerm: term }),
@@ -5776,8 +5769,10 @@ var StagesComponent = ({
5776
5769
  const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
5777
5770
  const isCompletedStage = isAllStagesCompleted || index <= currentIndex;
5778
5771
  const isActive = !isAllStagesCompleted && index === currentIndex;
5772
+ const isLastStageWhenCompleted = isAllStagesCompleted && index === stages.length - 1;
5773
+ const showAsActive = isActive || isLastStageWhenCompleted;
5779
5774
  let stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
5780
- let stageStyle = { borderColor: primaryColor, color: isActive ? "white" : primaryColor, backgroundColor: isActive ? primaryColor : "transparent" };
5775
+ let stageStyle = { borderColor: primaryColor, color: showAsActive ? "white" : primaryColor, backgroundColor: showAsActive ? primaryColor : "transparent" };
5781
5776
  if (stage.hasOwnProperty("isSuccess") && stage.isSuccess === false) {
5782
5777
  stageColor = `bg-red-50 text-red-700 border-2 border-red-700`;
5783
5778
  stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
@@ -5800,7 +5795,7 @@ var StagesComponent = ({
5800
5795
  min-w-[70px] sm:min-w-[80px] w-full sm:w-auto px-3 sm:px-4 py-1.5 sm:py-2
5801
5796
  rounded-full text-xs sm:text-sm font-medium transition-colors duration-200
5802
5797
  whitespace-normal sm:whitespace-nowrap flex-shrink-0 max-w-[150px] text-ellipsis overflow-hidden
5803
- ${isActive ? `bg-[${primaryColor}] text-white shadow-md` : isCompletedStage ? stageColor : "bg-white border border-gray-200"}
5798
+ ${showAsActive ? `bg-[${primaryColor}] text-white shadow-md` : isCompletedStage ? stageColor : "bg-white border border-gray-200"}
5804
5799
  ${isMobile ? "flex-1 text-center py-2.5" : ""}
5805
5800
  `,
5806
5801
  onClick: () => {
@@ -5925,7 +5920,8 @@ function Navbar({
5925
5920
  isBuilder = false,
5926
5921
  source,
5927
5922
  navList,
5928
- onSearch
5923
+ onSearch,
5924
+ primaryColor = "#2a55a3"
5929
5925
  }) {
5930
5926
  const router = (0, import_navigation3.useRouter)();
5931
5927
  const [screenMode, setScreenMode] = (0, import_react35.useState)(
@@ -6018,7 +6014,7 @@ function Navbar({
6018
6014
  /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(DropdownMenu, { children: [
6019
6015
  /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center space-x-2 cursor-pointer", children: [
6020
6016
  !isMobile && showName && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("h4", { className: "text-gray-900 dark:text-gray-300 text-sm", children: userName }),
6021
- /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Avatar, { className: "h-8 w-8", children: profileType === "avatar" ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(AvatarImage, { src: "/images/appbuilder/toolset/profile.svg", alt: "profile" }) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "bg-green-700 text-white h-full w-full rounded-full flex items-center justify-center text-xs", children: getInitials(userName) }) }),
6017
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Avatar, { className: "h-8 w-8", children: profileType === "avatar" ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(AvatarImage, { src: "/images/appbuilder/toolset/profile.svg", alt: "profile" }) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: `bg-[${primaryColor}] text-white h-full w-full rounded-full flex items-center justify-center text-xs`, style: { backgroundColor: primaryColor }, children: getInitials(userName) }) }),
6022
6018
  (isMobile || isTablet) && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_lucide_react18.Menu, { className: "h-6 w-6" }) })
6023
6019
  ] }) }),
6024
6020
  /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(DropdownMenuContent, { align: "end", className: "bg-white dark:bg-gray-800", children: [
@@ -6200,15 +6196,6 @@ var ChartComponent = ({
6200
6196
  }
6201
6197
  return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: `${className} h-[450px]`, style, children: [
6202
6198
  isPaginationEnabled && rawMeta && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "flex items-center justify-between mb-4 px-2", children: [
6203
- /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "text-sm text-gray-600 hidden sm:block", children: [
6204
- "Page ",
6205
- rawMeta.page,
6206
- " of ",
6207
- rawMeta.pages,
6208
- " (",
6209
- rawMeta.total.toLocaleString(),
6210
- " total records)"
6211
- ] }),
6212
6199
  /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "flex items-center space-x-2 sm:hidden w-full justify-center", children: [
6213
6200
  /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
6214
6201
  "button",