@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/client.js +8 -2
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +8 -2
- package/dist/client.mjs.map +1 -1
- package/dist/index.css +0 -3
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +56 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4019,7 +4019,6 @@ function DataTable({
|
|
|
4019
4019
|
onPageChange,
|
|
4020
4020
|
pageSize = 10,
|
|
4021
4021
|
paginationMode = "client",
|
|
4022
|
-
totalRecords = 0,
|
|
4023
4022
|
onSortChange,
|
|
4024
4023
|
onFilterChange,
|
|
4025
4024
|
onGlobalSearch,
|
|
@@ -4032,13 +4031,17 @@ function DataTable({
|
|
|
4032
4031
|
tableId,
|
|
4033
4032
|
manageColumns = false,
|
|
4034
4033
|
preferenceUrl,
|
|
4035
|
-
axiosInstance
|
|
4034
|
+
axiosInstance,
|
|
4035
|
+
meta,
|
|
4036
|
+
enableTotalRecords,
|
|
4037
|
+
getRowCount
|
|
4036
4038
|
}) {
|
|
4037
4039
|
const [columnFilters, setColumnFilters] = React11.useState([]);
|
|
4038
4040
|
const [columnVisibility, setColumnVisibility] = React11.useState({});
|
|
4039
4041
|
const hasLoadedInitialState = React11.useRef(false);
|
|
4040
4042
|
const isSavingRef = React11.useRef(false);
|
|
4041
4043
|
const isFetchingRef = React11.useRef(false);
|
|
4044
|
+
const [fetchLoading, setFetchLoading] = React11.useState(false);
|
|
4042
4045
|
const transformApiToFrontend = React11.useCallback((apiSettings, allColumnIds) => {
|
|
4043
4046
|
if (!apiSettings || !apiSettings.columns || !apiSettings.columns.visible) {
|
|
4044
4047
|
return {};
|
|
@@ -4207,8 +4210,10 @@ function DataTable({
|
|
|
4207
4210
|
React11.useEffect(() => {
|
|
4208
4211
|
if (paginationMode === "client") {
|
|
4209
4212
|
setLocalPageSize(pageSize);
|
|
4213
|
+
} else if (paginationMode === "server" && meta?.limit != null) {
|
|
4214
|
+
setLocalPageSize(meta.limit);
|
|
4210
4215
|
}
|
|
4211
|
-
}, [pageSize, paginationMode]);
|
|
4216
|
+
}, [pageSize, paginationMode, meta?.limit]);
|
|
4212
4217
|
const table = useReactTable({
|
|
4213
4218
|
data: finalData,
|
|
4214
4219
|
columns: dynamicCols,
|
|
@@ -4223,8 +4228,8 @@ function DataTable({
|
|
|
4223
4228
|
columnVisibility,
|
|
4224
4229
|
rowSelection,
|
|
4225
4230
|
pagination: {
|
|
4226
|
-
pageIndex: paginationMode === "server" ? controlledPageIndex ?? 0 : localPageIndex,
|
|
4227
|
-
pageSize: localPageSize
|
|
4231
|
+
pageIndex: paginationMode === "server" ? meta?.page != null ? meta.page - 1 : controlledPageIndex ?? 0 : localPageIndex,
|
|
4232
|
+
pageSize: paginationMode === "server" && meta?.limit != null ? meta.limit : localPageSize
|
|
4228
4233
|
}
|
|
4229
4234
|
},
|
|
4230
4235
|
enableRowSelection: !!enableRowSelection,
|
|
@@ -4262,7 +4267,7 @@ function DataTable({
|
|
|
4262
4267
|
getFilteredRowModel: getFilteredRowModel(),
|
|
4263
4268
|
getPaginationRowModel: pagination && paginationMode === "client" ? getPaginationRowModel() : void 0,
|
|
4264
4269
|
manualPagination: paginationMode === "server",
|
|
4265
|
-
pageCount: paginationMode ===
|
|
4270
|
+
// pageCount: paginationMode === 'server' ? Math.ceil(totalRecords / localPageSize) : undefined,
|
|
4266
4271
|
onPaginationChange: (updater) => {
|
|
4267
4272
|
if (isUpdatingPageSizeRef.current) {
|
|
4268
4273
|
isUpdatingPageSizeRef.current = false;
|
|
@@ -4320,19 +4325,30 @@ function DataTable({
|
|
|
4320
4325
|
if (paginationMode === "client") {
|
|
4321
4326
|
return [5, 10, 20, 50, 100];
|
|
4322
4327
|
}
|
|
4323
|
-
const
|
|
4324
|
-
if (
|
|
4325
|
-
|
|
4328
|
+
const base = [5, 10, 20, 50, 100];
|
|
4329
|
+
if (meta?.limit != null && !base.includes(meta.limit)) {
|
|
4330
|
+
const withMeta = [...base, meta.limit].sort((a, b) => a - b);
|
|
4331
|
+
return withMeta;
|
|
4326
4332
|
}
|
|
4327
|
-
return
|
|
4328
|
-
}, [paginationMode,
|
|
4333
|
+
return base;
|
|
4334
|
+
}, [paginationMode, meta?.limit]);
|
|
4329
4335
|
return /* @__PURE__ */ jsxs30("div", { className: "overflow-hidden rounded-md w-full", children: [
|
|
4330
4336
|
!loading && /* @__PURE__ */ jsxs30("div", { className: "flex justify-between p-2 bg-gray-50", children: [
|
|
4331
4337
|
/* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-4 w-full", children: [
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4338
|
+
enableTotalRecords && /* @__PURE__ */ jsx51(
|
|
4339
|
+
Button,
|
|
4340
|
+
{
|
|
4341
|
+
size: "sm",
|
|
4342
|
+
className: "bg-[#12715B] text-white text-xs h-auto py-2 px-3 cursor-pointer",
|
|
4343
|
+
onClick: async () => {
|
|
4344
|
+
setFetchLoading(true);
|
|
4345
|
+
await getRowCount?.();
|
|
4346
|
+
setFetchLoading(false);
|
|
4347
|
+
},
|
|
4348
|
+
disabled: fetchLoading,
|
|
4349
|
+
children: fetchLoading ? "Fetching..." : "Get Total Records"
|
|
4350
|
+
}
|
|
4351
|
+
),
|
|
4336
4352
|
globalSearch && /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
|
|
4337
4353
|
/* @__PURE__ */ jsxs30("div", { className: "relative w-full", children: [
|
|
4338
4354
|
/* @__PURE__ */ jsx51(
|
|
@@ -4532,18 +4548,18 @@ function DataTable({
|
|
|
4532
4548
|
j
|
|
4533
4549
|
);
|
|
4534
4550
|
}) }, i)) }) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx51(TableRow, { children: row.getVisibleCells().map((cell, cellIndex, arr) => {
|
|
4535
|
-
const
|
|
4536
|
-
const isClickable =
|
|
4551
|
+
const meta2 = cell.column.columnDef.meta || {};
|
|
4552
|
+
const isClickable = meta2?.isClickable;
|
|
4537
4553
|
const isLastCell = cellIndex === arr.length - 1;
|
|
4538
4554
|
return /* @__PURE__ */ jsxs30(
|
|
4539
4555
|
TableCell,
|
|
4540
4556
|
{
|
|
4541
|
-
className: `break-words whitespace-normal align-top ${
|
|
4557
|
+
className: `break-words whitespace-normal align-top ${meta2?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100 underline text-blue-500" : ""} relative py-2 `,
|
|
4542
4558
|
style: {
|
|
4543
4559
|
width: cell.column.getSize(),
|
|
4544
4560
|
minWidth: cell.column.columnDef.minSize,
|
|
4545
4561
|
maxWidth: cell.column.columnDef.maxSize,
|
|
4546
|
-
...
|
|
4562
|
+
...meta2?.cellStyle ?? {}
|
|
4547
4563
|
},
|
|
4548
4564
|
onClick: () => {
|
|
4549
4565
|
if (isClickable && onCellClick) {
|
|
@@ -4579,55 +4595,33 @@ function DataTable({
|
|
|
4579
4595
|
}) }, row.id)) : /* @__PURE__ */ jsx51(TableRow, { children: /* @__PURE__ */ jsx51(TableCell, { colSpan: dynamicCols.length, className: "h-24 text-center", children: /* @__PURE__ */ jsx51("span", { className: "flex items-center justify-center py-10 w-full min-w-full text-gray-600 bg-gray-100", children: "No results." }) }) }) })
|
|
4580
4596
|
] }),
|
|
4581
4597
|
pagination && /* @__PURE__ */ jsxs30("div", { className: "flex items-center justify-between py-3 text-sm w-full", children: [
|
|
4582
|
-
!loading && /* @__PURE__ */
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
),
|
|
4595
|
-
/* @__PURE__ */ jsxs30("div", { children: [
|
|
4596
|
-
"Page ",
|
|
4597
|
-
table.getState().pagination.pageIndex + 1,
|
|
4598
|
-
" of ",
|
|
4599
|
-
pageCount
|
|
4600
|
-
] })
|
|
4601
|
-
] }),
|
|
4598
|
+
!loading && /* @__PURE__ */ jsx51("div", { className: "flex gap-2 items-center", children: /* @__PURE__ */ jsx51(
|
|
4599
|
+
"select",
|
|
4600
|
+
{
|
|
4601
|
+
value: paginationMode === "server" && meta?.limit != null ? meta.limit : localPageSize,
|
|
4602
|
+
onChange: handlePageSizeChange,
|
|
4603
|
+
className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
|
|
4604
|
+
children: pageSizeOptions.map((size) => /* @__PURE__ */ jsxs30("option", { value: size, children: [
|
|
4605
|
+
size,
|
|
4606
|
+
" / page"
|
|
4607
|
+
] }, size))
|
|
4608
|
+
}
|
|
4609
|
+
) }),
|
|
4602
4610
|
/* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-2", children: [
|
|
4603
4611
|
/* @__PURE__ */ jsx51(
|
|
4604
4612
|
"button",
|
|
4605
4613
|
{
|
|
4606
4614
|
onClick: () => table.previousPage(),
|
|
4607
|
-
disabled: !table.getCanPreviousPage?.(),
|
|
4615
|
+
disabled: paginationMode === "server" && meta != null ? (meta.page ?? 1) <= 1 : !table.getCanPreviousPage?.(),
|
|
4608
4616
|
className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
|
|
4609
4617
|
children: "Prev"
|
|
4610
4618
|
}
|
|
4611
4619
|
),
|
|
4612
|
-
getPageNumbers(
|
|
4613
|
-
table.getState().pagination.pageIndex + 1,
|
|
4614
|
-
table.getPageCount(),
|
|
4615
|
-
5
|
|
4616
|
-
).map((pageNum, index) => /* @__PURE__ */ jsx51(
|
|
4617
|
-
"button",
|
|
4618
|
-
{
|
|
4619
|
-
disabled: pageNum === "...",
|
|
4620
|
-
onClick: () => typeof pageNum === "number" && table.setPageIndex(pageNum - 1),
|
|
4621
|
-
className: `px-2 py-1 border rounded ${table.getState().pagination.pageIndex + 1 === pageNum ? "bg-[#12715B] text-white" : "bg-white"} ${pageNum === "..." ? "cursor-default" : "cursor-pointer"}`,
|
|
4622
|
-
children: pageNum
|
|
4623
|
-
},
|
|
4624
|
-
index
|
|
4625
|
-
)),
|
|
4626
4620
|
/* @__PURE__ */ jsx51(
|
|
4627
4621
|
"button",
|
|
4628
4622
|
{
|
|
4629
4623
|
onClick: () => table.nextPage(),
|
|
4630
|
-
disabled: !table.getCanNextPage?.(),
|
|
4624
|
+
disabled: paginationMode === "server" && meta != null ? !meta.hasMore : !table.getCanNextPage?.(),
|
|
4631
4625
|
className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
|
|
4632
4626
|
children: "Next"
|
|
4633
4627
|
}
|
|
@@ -4678,7 +4672,6 @@ var Table2 = ({
|
|
|
4678
4672
|
onPageChange?.({ page: pageIndex + 1, itemsPerPage: pageSize });
|
|
4679
4673
|
},
|
|
4680
4674
|
paginationMode,
|
|
4681
|
-
totalRecords,
|
|
4682
4675
|
onSortChange: (col, dir) => onSortChange?.({ sort_by: col, sort_order: dir }),
|
|
4683
4676
|
onFilterChange: (filters) => onFilterChange?.({ columnKey: filters.columnKey, columnTerm: filters.columnTerm }),
|
|
4684
4677
|
onGlobalSearch: (term) => onGlobalSearch?.({ searchTerm: term }),
|
|
@@ -5692,8 +5685,10 @@ var StagesComponent = ({
|
|
|
5692
5685
|
const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
|
|
5693
5686
|
const isCompletedStage = isAllStagesCompleted || index <= currentIndex;
|
|
5694
5687
|
const isActive = !isAllStagesCompleted && index === currentIndex;
|
|
5688
|
+
const isLastStageWhenCompleted = isAllStagesCompleted && index === stages.length - 1;
|
|
5689
|
+
const showAsActive = isActive || isLastStageWhenCompleted;
|
|
5695
5690
|
let stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
|
|
5696
|
-
let stageStyle = { borderColor: primaryColor, color:
|
|
5691
|
+
let stageStyle = { borderColor: primaryColor, color: showAsActive ? "white" : primaryColor, backgroundColor: showAsActive ? primaryColor : "transparent" };
|
|
5697
5692
|
if (stage.hasOwnProperty("isSuccess") && stage.isSuccess === false) {
|
|
5698
5693
|
stageColor = `bg-red-50 text-red-700 border-2 border-red-700`;
|
|
5699
5694
|
stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
|
|
@@ -5716,7 +5711,7 @@ var StagesComponent = ({
|
|
|
5716
5711
|
min-w-[70px] sm:min-w-[80px] w-full sm:w-auto px-3 sm:px-4 py-1.5 sm:py-2
|
|
5717
5712
|
rounded-full text-xs sm:text-sm font-medium transition-colors duration-200
|
|
5718
5713
|
whitespace-normal sm:whitespace-nowrap flex-shrink-0 max-w-[150px] text-ellipsis overflow-hidden
|
|
5719
|
-
${
|
|
5714
|
+
${showAsActive ? `bg-[${primaryColor}] text-white shadow-md` : isCompletedStage ? stageColor : "bg-white border border-gray-200"}
|
|
5720
5715
|
${isMobile ? "flex-1 text-center py-2.5" : ""}
|
|
5721
5716
|
`,
|
|
5722
5717
|
onClick: () => {
|
|
@@ -5841,7 +5836,8 @@ function Navbar({
|
|
|
5841
5836
|
isBuilder = false,
|
|
5842
5837
|
source,
|
|
5843
5838
|
navList,
|
|
5844
|
-
onSearch
|
|
5839
|
+
onSearch,
|
|
5840
|
+
primaryColor = "#2a55a3"
|
|
5845
5841
|
}) {
|
|
5846
5842
|
const router = useRouter2();
|
|
5847
5843
|
const [screenMode, setScreenMode] = useState14(
|
|
@@ -5934,7 +5930,7 @@ function Navbar({
|
|
|
5934
5930
|
/* @__PURE__ */ jsxs41(DropdownMenu, { children: [
|
|
5935
5931
|
/* @__PURE__ */ jsx67(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs41("div", { className: "flex items-center space-x-2 cursor-pointer", children: [
|
|
5936
5932
|
!isMobile && showName && /* @__PURE__ */ jsx67("h4", { className: "text-gray-900 dark:text-gray-300 text-sm", children: userName }),
|
|
5937
|
-
/* @__PURE__ */ jsx67(Avatar, { className: "h-8 w-8", children: profileType === "avatar" ? /* @__PURE__ */ jsx67(AvatarImage, { src: "/images/appbuilder/toolset/profile.svg", alt: "profile" }) : /* @__PURE__ */ jsx67("div", { className:
|
|
5933
|
+
/* @__PURE__ */ jsx67(Avatar, { className: "h-8 w-8", children: profileType === "avatar" ? /* @__PURE__ */ jsx67(AvatarImage, { src: "/images/appbuilder/toolset/profile.svg", alt: "profile" }) : /* @__PURE__ */ jsx67("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) }) }),
|
|
5938
5934
|
(isMobile || isTablet) && /* @__PURE__ */ jsx67(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ jsx67(Menu2, { className: "h-6 w-6" }) })
|
|
5939
5935
|
] }) }),
|
|
5940
5936
|
/* @__PURE__ */ jsxs41(DropdownMenuContent, { align: "end", className: "bg-white dark:bg-gray-800", children: [
|
|
@@ -6127,15 +6123,6 @@ var ChartComponent = ({
|
|
|
6127
6123
|
}
|
|
6128
6124
|
return /* @__PURE__ */ jsxs42("div", { className: `${className} h-[450px]`, style, children: [
|
|
6129
6125
|
isPaginationEnabled && rawMeta && /* @__PURE__ */ jsxs42("div", { className: "flex items-center justify-between mb-4 px-2", children: [
|
|
6130
|
-
/* @__PURE__ */ jsxs42("div", { className: "text-sm text-gray-600 hidden sm:block", children: [
|
|
6131
|
-
"Page ",
|
|
6132
|
-
rawMeta.page,
|
|
6133
|
-
" of ",
|
|
6134
|
-
rawMeta.pages,
|
|
6135
|
-
" (",
|
|
6136
|
-
rawMeta.total.toLocaleString(),
|
|
6137
|
-
" total records)"
|
|
6138
|
-
] }),
|
|
6139
6126
|
/* @__PURE__ */ jsxs42("div", { className: "flex items-center space-x-2 sm:hidden w-full justify-center", children: [
|
|
6140
6127
|
/* @__PURE__ */ jsx68(
|
|
6141
6128
|
"button",
|