@algorithm-shift/design-system 1.3.114 → 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) {
@@ -4670,7 +4686,7 @@ function DataTable({
4670
4686
  !loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "flex gap-2 items-center", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4671
4687
  "select",
4672
4688
  {
4673
- value: localPageSize,
4689
+ value: paginationMode === "server" && meta?.limit != null ? meta.limit : localPageSize,
4674
4690
  onChange: handlePageSizeChange,
4675
4691
  className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
4676
4692
  children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("option", { value: size, children: [
@@ -4684,7 +4700,7 @@ function DataTable({
4684
4700
  "button",
4685
4701
  {
4686
4702
  onClick: () => table.previousPage(),
4687
- disabled: !table.getCanPreviousPage?.(),
4703
+ disabled: paginationMode === "server" && meta != null ? (meta.page ?? 1) <= 1 : !table.getCanPreviousPage?.(),
4688
4704
  className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
4689
4705
  children: "Prev"
4690
4706
  }
@@ -4693,7 +4709,7 @@ function DataTable({
4693
4709
  "button",
4694
4710
  {
4695
4711
  onClick: () => table.nextPage(),
4696
- disabled: !table.getCanNextPage?.(),
4712
+ disabled: paginationMode === "server" && meta != null ? !meta.hasMore : !table.getCanNextPage?.(),
4697
4713
  className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
4698
4714
  children: "Next"
4699
4715
  }
@@ -4744,7 +4760,6 @@ var Table2 = ({
4744
4760
  onPageChange?.({ page: pageIndex + 1, itemsPerPage: pageSize });
4745
4761
  },
4746
4762
  paginationMode,
4747
- totalRecords,
4748
4763
  onSortChange: (col, dir) => onSortChange?.({ sort_by: col, sort_order: dir }),
4749
4764
  onFilterChange: (filters) => onFilterChange?.({ columnKey: filters.columnKey, columnTerm: filters.columnTerm }),
4750
4765
  onGlobalSearch: (term) => onGlobalSearch?.({ searchTerm: term }),
@@ -5754,8 +5769,10 @@ var StagesComponent = ({
5754
5769
  const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
5755
5770
  const isCompletedStage = isAllStagesCompleted || index <= currentIndex;
5756
5771
  const isActive = !isAllStagesCompleted && index === currentIndex;
5772
+ const isLastStageWhenCompleted = isAllStagesCompleted && index === stages.length - 1;
5773
+ const showAsActive = isActive || isLastStageWhenCompleted;
5757
5774
  let stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
5758
- 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" };
5759
5776
  if (stage.hasOwnProperty("isSuccess") && stage.isSuccess === false) {
5760
5777
  stageColor = `bg-red-50 text-red-700 border-2 border-red-700`;
5761
5778
  stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
@@ -5778,7 +5795,7 @@ var StagesComponent = ({
5778
5795
  min-w-[70px] sm:min-w-[80px] w-full sm:w-auto px-3 sm:px-4 py-1.5 sm:py-2
5779
5796
  rounded-full text-xs sm:text-sm font-medium transition-colors duration-200
5780
5797
  whitespace-normal sm:whitespace-nowrap flex-shrink-0 max-w-[150px] text-ellipsis overflow-hidden
5781
- ${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"}
5782
5799
  ${isMobile ? "flex-1 text-center py-2.5" : ""}
5783
5800
  `,
5784
5801
  onClick: () => {
@@ -5903,7 +5920,8 @@ function Navbar({
5903
5920
  isBuilder = false,
5904
5921
  source,
5905
5922
  navList,
5906
- onSearch
5923
+ onSearch,
5924
+ primaryColor = "#2a55a3"
5907
5925
  }) {
5908
5926
  const router = (0, import_navigation3.useRouter)();
5909
5927
  const [screenMode, setScreenMode] = (0, import_react35.useState)(
@@ -5996,7 +6014,7 @@ function Navbar({
5996
6014
  /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(DropdownMenu, { children: [
5997
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: [
5998
6016
  !isMobile && showName && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("h4", { className: "text-gray-900 dark:text-gray-300 text-sm", children: userName }),
5999
- /* @__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) }) }),
6000
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" }) })
6001
6019
  ] }) }),
6002
6020
  /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(DropdownMenuContent, { align: "end", className: "bg-white dark:bg-gray-800", children: [
@@ -6178,15 +6196,6 @@ var ChartComponent = ({
6178
6196
  }
6179
6197
  return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: `${className} h-[450px]`, style, children: [
6180
6198
  isPaginationEnabled && rawMeta && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "flex items-center justify-between mb-4 px-2", children: [
6181
- /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "text-sm text-gray-600 hidden sm:block", children: [
6182
- "Page ",
6183
- rawMeta.page,
6184
- " of ",
6185
- rawMeta.pages,
6186
- " (",
6187
- rawMeta.total.toLocaleString(),
6188
- " total records)"
6189
- ] }),
6190
6199
  /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "flex items-center space-x-2 sm:hidden w-full justify-center", children: [
6191
6200
  /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
6192
6201
  "button",