@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.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 ===
|
|
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,31 @@ function DataTable({
|
|
|
4408
4413
|
if (paginationMode === "client") {
|
|
4409
4414
|
return [5, 10, 20, 50, 100];
|
|
4410
4415
|
}
|
|
4411
|
-
const
|
|
4412
|
-
if (
|
|
4413
|
-
|
|
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
|
|
4416
|
-
}, [paginationMode,
|
|
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
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4426
|
+
enableTotalRecords && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4427
|
+
Button,
|
|
4428
|
+
{
|
|
4429
|
+
size: "sm",
|
|
4430
|
+
variant: "outline",
|
|
4431
|
+
className: "px-3 py-1 text-xs cursor-pointer border-gray-300",
|
|
4432
|
+
onClick: async () => {
|
|
4433
|
+
setFetchLoading(true);
|
|
4434
|
+
await getRowCount?.();
|
|
4435
|
+
setFetchLoading(false);
|
|
4436
|
+
},
|
|
4437
|
+
disabled: fetchLoading,
|
|
4438
|
+
children: fetchLoading ? "Fetching..." : "Get Count"
|
|
4439
|
+
}
|
|
4440
|
+
),
|
|
4424
4441
|
globalSearch && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
|
|
4425
4442
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "relative w-full", children: [
|
|
4426
4443
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
@@ -4620,18 +4637,18 @@ function DataTable({
|
|
|
4620
4637
|
j
|
|
4621
4638
|
);
|
|
4622
4639
|
}) }, 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
|
|
4624
|
-
const isClickable =
|
|
4640
|
+
const meta2 = cell.column.columnDef.meta || {};
|
|
4641
|
+
const isClickable = meta2?.isClickable;
|
|
4625
4642
|
const isLastCell = cellIndex === arr.length - 1;
|
|
4626
4643
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
4627
4644
|
TableCell,
|
|
4628
4645
|
{
|
|
4629
|
-
className: `break-words whitespace-normal align-top ${
|
|
4646
|
+
className: `break-words whitespace-normal align-top ${meta2?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100 underline text-blue-500" : ""} relative py-2 `,
|
|
4630
4647
|
style: {
|
|
4631
4648
|
width: cell.column.getSize(),
|
|
4632
4649
|
minWidth: cell.column.columnDef.minSize,
|
|
4633
4650
|
maxWidth: cell.column.columnDef.maxSize,
|
|
4634
|
-
...
|
|
4651
|
+
...meta2?.cellStyle ?? {}
|
|
4635
4652
|
},
|
|
4636
4653
|
onClick: () => {
|
|
4637
4654
|
if (isClickable && onCellClick) {
|
|
@@ -4670,7 +4687,7 @@ function DataTable({
|
|
|
4670
4687
|
!loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "flex gap-2 items-center", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4671
4688
|
"select",
|
|
4672
4689
|
{
|
|
4673
|
-
value: localPageSize,
|
|
4690
|
+
value: paginationMode === "server" && meta?.limit != null ? meta.limit : localPageSize,
|
|
4674
4691
|
onChange: handlePageSizeChange,
|
|
4675
4692
|
className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
|
|
4676
4693
|
children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("option", { value: size, children: [
|
|
@@ -4684,7 +4701,7 @@ function DataTable({
|
|
|
4684
4701
|
"button",
|
|
4685
4702
|
{
|
|
4686
4703
|
onClick: () => table.previousPage(),
|
|
4687
|
-
disabled: !table.getCanPreviousPage?.(),
|
|
4704
|
+
disabled: paginationMode === "server" && meta != null ? (meta.page ?? 1) <= 1 : !table.getCanPreviousPage?.(),
|
|
4688
4705
|
className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
|
|
4689
4706
|
children: "Prev"
|
|
4690
4707
|
}
|
|
@@ -4693,7 +4710,7 @@ function DataTable({
|
|
|
4693
4710
|
"button",
|
|
4694
4711
|
{
|
|
4695
4712
|
onClick: () => table.nextPage(),
|
|
4696
|
-
disabled: !table.getCanNextPage?.(),
|
|
4713
|
+
disabled: paginationMode === "server" && meta != null ? !meta.hasMore : !table.getCanNextPage?.(),
|
|
4697
4714
|
className: "px-2 py-1 border rounded disabled:opacity-50 cursor-pointer",
|
|
4698
4715
|
children: "Next"
|
|
4699
4716
|
}
|
|
@@ -4744,7 +4761,6 @@ var Table2 = ({
|
|
|
4744
4761
|
onPageChange?.({ page: pageIndex + 1, itemsPerPage: pageSize });
|
|
4745
4762
|
},
|
|
4746
4763
|
paginationMode,
|
|
4747
|
-
totalRecords,
|
|
4748
4764
|
onSortChange: (col, dir) => onSortChange?.({ sort_by: col, sort_order: dir }),
|
|
4749
4765
|
onFilterChange: (filters) => onFilterChange?.({ columnKey: filters.columnKey, columnTerm: filters.columnTerm }),
|
|
4750
4766
|
onGlobalSearch: (term) => onGlobalSearch?.({ searchTerm: term }),
|
|
@@ -5754,8 +5770,10 @@ var StagesComponent = ({
|
|
|
5754
5770
|
const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
|
|
5755
5771
|
const isCompletedStage = isAllStagesCompleted || index <= currentIndex;
|
|
5756
5772
|
const isActive = !isAllStagesCompleted && index === currentIndex;
|
|
5773
|
+
const isLastStageWhenCompleted = isAllStagesCompleted && index === stages.length - 1;
|
|
5774
|
+
const showAsActive = isActive || isLastStageWhenCompleted;
|
|
5757
5775
|
let stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
|
|
5758
|
-
let stageStyle = { borderColor: primaryColor, color:
|
|
5776
|
+
let stageStyle = { borderColor: primaryColor, color: showAsActive ? "white" : primaryColor, backgroundColor: showAsActive ? primaryColor : "transparent" };
|
|
5759
5777
|
if (stage.hasOwnProperty("isSuccess") && stage.isSuccess === false) {
|
|
5760
5778
|
stageColor = `bg-red-50 text-red-700 border-2 border-red-700`;
|
|
5761
5779
|
stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
|
|
@@ -5778,7 +5796,7 @@ var StagesComponent = ({
|
|
|
5778
5796
|
min-w-[70px] sm:min-w-[80px] w-full sm:w-auto px-3 sm:px-4 py-1.5 sm:py-2
|
|
5779
5797
|
rounded-full text-xs sm:text-sm font-medium transition-colors duration-200
|
|
5780
5798
|
whitespace-normal sm:whitespace-nowrap flex-shrink-0 max-w-[150px] text-ellipsis overflow-hidden
|
|
5781
|
-
${
|
|
5799
|
+
${showAsActive ? `bg-[${primaryColor}] text-white shadow-md` : isCompletedStage ? stageColor : "bg-white border border-gray-200"}
|
|
5782
5800
|
${isMobile ? "flex-1 text-center py-2.5" : ""}
|
|
5783
5801
|
`,
|
|
5784
5802
|
onClick: () => {
|
|
@@ -5903,7 +5921,8 @@ function Navbar({
|
|
|
5903
5921
|
isBuilder = false,
|
|
5904
5922
|
source,
|
|
5905
5923
|
navList,
|
|
5906
|
-
onSearch
|
|
5924
|
+
onSearch,
|
|
5925
|
+
primaryColor = "#2a55a3"
|
|
5907
5926
|
}) {
|
|
5908
5927
|
const router = (0, import_navigation3.useRouter)();
|
|
5909
5928
|
const [screenMode, setScreenMode] = (0, import_react35.useState)(
|
|
@@ -5996,7 +6015,7 @@ function Navbar({
|
|
|
5996
6015
|
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(DropdownMenu, { children: [
|
|
5997
6016
|
/* @__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
6017
|
!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:
|
|
6018
|
+
/* @__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
6019
|
(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
6020
|
] }) }),
|
|
6002
6021
|
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(DropdownMenuContent, { align: "end", className: "bg-white dark:bg-gray-800", children: [
|
|
@@ -6178,15 +6197,6 @@ var ChartComponent = ({
|
|
|
6178
6197
|
}
|
|
6179
6198
|
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: `${className} h-[450px]`, style, children: [
|
|
6180
6199
|
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
6200
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "flex items-center space-x-2 sm:hidden w-full justify-center", children: [
|
|
6191
6201
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
6192
6202
|
"button",
|