@algorithm-shift/design-system 1.3.114 → 1.3.116
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 +13 -2
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +13 -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 +46 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -36
- 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,31 @@ 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
|
+
variant: "outline",
|
|
4343
|
+
className: "px-3 py-1 text-xs cursor-pointer border-gray-300",
|
|
4344
|
+
onClick: async () => {
|
|
4345
|
+
setFetchLoading(true);
|
|
4346
|
+
await getRowCount?.();
|
|
4347
|
+
setFetchLoading(false);
|
|
4348
|
+
},
|
|
4349
|
+
disabled: fetchLoading,
|
|
4350
|
+
children: fetchLoading ? "Fetching..." : "Get Count"
|
|
4351
|
+
}
|
|
4352
|
+
),
|
|
4336
4353
|
globalSearch && /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
|
|
4337
4354
|
/* @__PURE__ */ jsxs30("div", { className: "relative w-full", children: [
|
|
4338
4355
|
/* @__PURE__ */ jsx51(
|
|
@@ -4532,18 +4549,18 @@ function DataTable({
|
|
|
4532
4549
|
j
|
|
4533
4550
|
);
|
|
4534
4551
|
}) }, 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 =
|
|
4552
|
+
const meta2 = cell.column.columnDef.meta || {};
|
|
4553
|
+
const isClickable = meta2?.isClickable;
|
|
4537
4554
|
const isLastCell = cellIndex === arr.length - 1;
|
|
4538
4555
|
return /* @__PURE__ */ jsxs30(
|
|
4539
4556
|
TableCell,
|
|
4540
4557
|
{
|
|
4541
|
-
className: `break-words whitespace-normal align-top ${
|
|
4558
|
+
className: `break-words whitespace-normal align-top ${meta2?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100 underline text-blue-500" : ""} relative py-2 `,
|
|
4542
4559
|
style: {
|
|
4543
4560
|
width: cell.column.getSize(),
|
|
4544
4561
|
minWidth: cell.column.columnDef.minSize,
|
|
4545
4562
|
maxWidth: cell.column.columnDef.maxSize,
|
|
4546
|
-
...
|
|
4563
|
+
...meta2?.cellStyle ?? {}
|
|
4547
4564
|
},
|
|
4548
4565
|
onClick: () => {
|
|
4549
4566
|
if (isClickable && onCellClick) {
|
|
@@ -4582,7 +4599,7 @@ function DataTable({
|
|
|
4582
4599
|
!loading && /* @__PURE__ */ jsx51("div", { className: "flex gap-2 items-center", children: /* @__PURE__ */ jsx51(
|
|
4583
4600
|
"select",
|
|
4584
4601
|
{
|
|
4585
|
-
value: localPageSize,
|
|
4602
|
+
value: paginationMode === "server" && meta?.limit != null ? meta.limit : localPageSize,
|
|
4586
4603
|
onChange: handlePageSizeChange,
|
|
4587
4604
|
className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
|
|
4588
4605
|
children: pageSizeOptions.map((size) => /* @__PURE__ */ jsxs30("option", { value: size, children: [
|
|
@@ -4596,7 +4613,7 @@ function DataTable({
|
|
|
4596
4613
|
"button",
|
|
4597
4614
|
{
|
|
4598
4615
|
onClick: () => table.previousPage(),
|
|
4599
|
-
disabled: !table.getCanPreviousPage?.(),
|
|
4616
|
+
disabled: paginationMode === "server" && meta != null ? (meta.page ?? 1) <= 1 : !table.getCanPreviousPage?.(),
|
|
4600
4617
|
className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
|
|
4601
4618
|
children: "Prev"
|
|
4602
4619
|
}
|
|
@@ -4605,7 +4622,7 @@ function DataTable({
|
|
|
4605
4622
|
"button",
|
|
4606
4623
|
{
|
|
4607
4624
|
onClick: () => table.nextPage(),
|
|
4608
|
-
disabled: !table.getCanNextPage?.(),
|
|
4625
|
+
disabled: paginationMode === "server" && meta != null ? !meta.hasMore : !table.getCanNextPage?.(),
|
|
4609
4626
|
className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
|
|
4610
4627
|
children: "Next"
|
|
4611
4628
|
}
|
|
@@ -4656,7 +4673,6 @@ var Table2 = ({
|
|
|
4656
4673
|
onPageChange?.({ page: pageIndex + 1, itemsPerPage: pageSize });
|
|
4657
4674
|
},
|
|
4658
4675
|
paginationMode,
|
|
4659
|
-
totalRecords,
|
|
4660
4676
|
onSortChange: (col, dir) => onSortChange?.({ sort_by: col, sort_order: dir }),
|
|
4661
4677
|
onFilterChange: (filters) => onFilterChange?.({ columnKey: filters.columnKey, columnTerm: filters.columnTerm }),
|
|
4662
4678
|
onGlobalSearch: (term) => onGlobalSearch?.({ searchTerm: term }),
|
|
@@ -5670,8 +5686,10 @@ var StagesComponent = ({
|
|
|
5670
5686
|
const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
|
|
5671
5687
|
const isCompletedStage = isAllStagesCompleted || index <= currentIndex;
|
|
5672
5688
|
const isActive = !isAllStagesCompleted && index === currentIndex;
|
|
5689
|
+
const isLastStageWhenCompleted = isAllStagesCompleted && index === stages.length - 1;
|
|
5690
|
+
const showAsActive = isActive || isLastStageWhenCompleted;
|
|
5673
5691
|
let stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
|
|
5674
|
-
let stageStyle = { borderColor: primaryColor, color:
|
|
5692
|
+
let stageStyle = { borderColor: primaryColor, color: showAsActive ? "white" : primaryColor, backgroundColor: showAsActive ? primaryColor : "transparent" };
|
|
5675
5693
|
if (stage.hasOwnProperty("isSuccess") && stage.isSuccess === false) {
|
|
5676
5694
|
stageColor = `bg-red-50 text-red-700 border-2 border-red-700`;
|
|
5677
5695
|
stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
|
|
@@ -5694,7 +5712,7 @@ var StagesComponent = ({
|
|
|
5694
5712
|
min-w-[70px] sm:min-w-[80px] w-full sm:w-auto px-3 sm:px-4 py-1.5 sm:py-2
|
|
5695
5713
|
rounded-full text-xs sm:text-sm font-medium transition-colors duration-200
|
|
5696
5714
|
whitespace-normal sm:whitespace-nowrap flex-shrink-0 max-w-[150px] text-ellipsis overflow-hidden
|
|
5697
|
-
${
|
|
5715
|
+
${showAsActive ? `bg-[${primaryColor}] text-white shadow-md` : isCompletedStage ? stageColor : "bg-white border border-gray-200"}
|
|
5698
5716
|
${isMobile ? "flex-1 text-center py-2.5" : ""}
|
|
5699
5717
|
`,
|
|
5700
5718
|
onClick: () => {
|
|
@@ -5819,7 +5837,8 @@ function Navbar({
|
|
|
5819
5837
|
isBuilder = false,
|
|
5820
5838
|
source,
|
|
5821
5839
|
navList,
|
|
5822
|
-
onSearch
|
|
5840
|
+
onSearch,
|
|
5841
|
+
primaryColor = "#2a55a3"
|
|
5823
5842
|
}) {
|
|
5824
5843
|
const router = useRouter2();
|
|
5825
5844
|
const [screenMode, setScreenMode] = useState14(
|
|
@@ -5912,7 +5931,7 @@ function Navbar({
|
|
|
5912
5931
|
/* @__PURE__ */ jsxs41(DropdownMenu, { children: [
|
|
5913
5932
|
/* @__PURE__ */ jsx67(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs41("div", { className: "flex items-center space-x-2 cursor-pointer", children: [
|
|
5914
5933
|
!isMobile && showName && /* @__PURE__ */ jsx67("h4", { className: "text-gray-900 dark:text-gray-300 text-sm", children: userName }),
|
|
5915
|
-
/* @__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:
|
|
5934
|
+
/* @__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) }) }),
|
|
5916
5935
|
(isMobile || isTablet) && /* @__PURE__ */ jsx67(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ jsx67(Menu2, { className: "h-6 w-6" }) })
|
|
5917
5936
|
] }) }),
|
|
5918
5937
|
/* @__PURE__ */ jsxs41(DropdownMenuContent, { align: "end", className: "bg-white dark:bg-gray-800", children: [
|
|
@@ -6105,15 +6124,6 @@ var ChartComponent = ({
|
|
|
6105
6124
|
}
|
|
6106
6125
|
return /* @__PURE__ */ jsxs42("div", { className: `${className} h-[450px]`, style, children: [
|
|
6107
6126
|
isPaginationEnabled && rawMeta && /* @__PURE__ */ jsxs42("div", { className: "flex items-center justify-between mb-4 px-2", children: [
|
|
6108
|
-
/* @__PURE__ */ jsxs42("div", { className: "text-sm text-gray-600 hidden sm:block", children: [
|
|
6109
|
-
"Page ",
|
|
6110
|
-
rawMeta.page,
|
|
6111
|
-
" of ",
|
|
6112
|
-
rawMeta.pages,
|
|
6113
|
-
" (",
|
|
6114
|
-
rawMeta.total.toLocaleString(),
|
|
6115
|
-
" total records)"
|
|
6116
|
-
] }),
|
|
6117
6127
|
/* @__PURE__ */ jsxs42("div", { className: "flex items-center space-x-2 sm:hidden w-full justify-center", children: [
|
|
6118
6128
|
/* @__PURE__ */ jsx68(
|
|
6119
6129
|
"button",
|