@algorithm-shift/design-system 1.2.85 → 1.2.87
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.css +19 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +73 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -226,12 +226,17 @@ function Repeater({
|
|
|
226
226
|
render,
|
|
227
227
|
emptyFallback = null,
|
|
228
228
|
wrapper,
|
|
229
|
-
className
|
|
229
|
+
className,
|
|
230
|
+
loading = false,
|
|
231
|
+
loadingText = "Loading..."
|
|
230
232
|
}) {
|
|
231
233
|
const list = React3.useMemo(
|
|
232
234
|
() => typeof count === "number" ? items.slice(0, count) : items,
|
|
233
235
|
[items, count]
|
|
234
236
|
);
|
|
237
|
+
if (loading) {
|
|
238
|
+
return /* @__PURE__ */ jsx10("div", { className, children: loadingText });
|
|
239
|
+
}
|
|
235
240
|
if (!list.length) {
|
|
236
241
|
return emptyFallback ? /* @__PURE__ */ jsx10(Fragment2, { children: emptyFallback }) : /* @__PURE__ */ jsx10("div", { className, children: "No items to display." });
|
|
237
242
|
}
|
|
@@ -27717,6 +27722,31 @@ function useLazyDropdown(config) {
|
|
|
27717
27722
|
setLoading(false);
|
|
27718
27723
|
}
|
|
27719
27724
|
}, [fetchApiData, transformToOptions]);
|
|
27725
|
+
const fetchValueItem = async () => {
|
|
27726
|
+
if (!configRef.current.apiUrl) return [];
|
|
27727
|
+
try {
|
|
27728
|
+
setLoading(true);
|
|
27729
|
+
const res = await axios.get(configRef.current.apiUrl, {
|
|
27730
|
+
params: { [configRef.current.dataKey]: configRef.current.value },
|
|
27731
|
+
withCredentials: true
|
|
27732
|
+
});
|
|
27733
|
+
if (res.data?.success && Array.isArray(res.data.data) && res.data.data.length > 0) {
|
|
27734
|
+
const fetched = transformToOptions(res.data.data);
|
|
27735
|
+
setOptions((prev) => [...fetched, ...prev]);
|
|
27736
|
+
}
|
|
27737
|
+
} catch (err) {
|
|
27738
|
+
console.warn("\u26A0\uFE0F Failed to fetch default value for dropdown:", err);
|
|
27739
|
+
} finally {
|
|
27740
|
+
setLoading(false);
|
|
27741
|
+
}
|
|
27742
|
+
};
|
|
27743
|
+
useEffect13(() => {
|
|
27744
|
+
const cfg = configRef.current;
|
|
27745
|
+
if (!cfg.enabled || !cfg.value || cfg.dataSource !== "api" || !cfg.apiUrl) return;
|
|
27746
|
+
const valueExists = options.some((opt) => opt.value === cfg.value);
|
|
27747
|
+
if (valueExists) return;
|
|
27748
|
+
fetchValueItem();
|
|
27749
|
+
}, [config.value, config.dataKey, config.apiUrl, config.dataSource, transformToOptions]);
|
|
27720
27750
|
const loadMore = useCallback2(() => {
|
|
27721
27751
|
if (!loading && hasMore) {
|
|
27722
27752
|
loadPage(page + 1, searchTerm);
|
|
@@ -27793,7 +27823,8 @@ function LazySelectDropdown({
|
|
|
27793
27823
|
pageSize: pageSize || 10,
|
|
27794
27824
|
dataKey,
|
|
27795
27825
|
dataLabel,
|
|
27796
|
-
initialData: options || []
|
|
27826
|
+
initialData: options || [],
|
|
27827
|
+
value
|
|
27797
27828
|
});
|
|
27798
27829
|
const selectedOption = lazyOptions.find((opt) => opt.value === value);
|
|
27799
27830
|
useEffect14(() => {
|
|
@@ -27858,7 +27889,7 @@ function LazySelectDropdown({
|
|
|
27858
27889
|
"div",
|
|
27859
27890
|
{
|
|
27860
27891
|
onMouseDown: (e) => e.stopPropagation(),
|
|
27861
|
-
className: "
|
|
27892
|
+
className: "absolute z-[900] w-fit mt-1 bg-white border border-gray-300 rounded-lg shadow-lg max-h-60 overflow-y-auto",
|
|
27862
27893
|
style: {
|
|
27863
27894
|
width: dropdownRef.current?.offsetWidth,
|
|
27864
27895
|
top: dropdownRef.current ? dropdownRef.current.getBoundingClientRect().bottom + window.scrollY : 0,
|
|
@@ -29235,7 +29266,10 @@ var useDynamicColumns = (config, customRenderers = {}, customFormatters = {}) =>
|
|
|
29235
29266
|
col.format,
|
|
29236
29267
|
customFormatters
|
|
29237
29268
|
);
|
|
29238
|
-
}
|
|
29269
|
+
},
|
|
29270
|
+
enableSorting: col.enableSorting,
|
|
29271
|
+
enableColumnFilter: col.enableColumnFilter,
|
|
29272
|
+
meta: col.meta
|
|
29239
29273
|
});
|
|
29240
29274
|
});
|
|
29241
29275
|
};
|
|
@@ -29258,37 +29292,13 @@ function DataTable({
|
|
|
29258
29292
|
globalSearch,
|
|
29259
29293
|
onCellClick,
|
|
29260
29294
|
onDeleteRow,
|
|
29261
|
-
|
|
29295
|
+
rowActions
|
|
29262
29296
|
}) {
|
|
29263
29297
|
const [columnFilters, setColumnFilters] = React9.useState([]);
|
|
29264
29298
|
const [columnVisibility, setColumnVisibility] = React9.useState({});
|
|
29265
29299
|
const [manualSort, setManualSort] = React9.useState(null);
|
|
29266
29300
|
const [searchTerm, setSearchTerm] = React9.useState("");
|
|
29267
|
-
const
|
|
29268
|
-
id: "delete",
|
|
29269
|
-
header: "Actions",
|
|
29270
|
-
cell: ({ row }) => /* @__PURE__ */ jsx53(
|
|
29271
|
-
"button",
|
|
29272
|
-
{
|
|
29273
|
-
className: "px-3 py-1 text-[12px] bg-red-800 text-white rounded hover:bg-neutral-600 cursor-pointer",
|
|
29274
|
-
onClick: (event) => {
|
|
29275
|
-
event.stopPropagation();
|
|
29276
|
-
if (onDeleteRow) {
|
|
29277
|
-
onDeleteRow(row.original, "delete");
|
|
29278
|
-
}
|
|
29279
|
-
},
|
|
29280
|
-
children: "Delete"
|
|
29281
|
-
}
|
|
29282
|
-
),
|
|
29283
|
-
meta: { isClickable: true }
|
|
29284
|
-
}), [onDeleteRow]);
|
|
29285
|
-
const combinedColumns = React9.useMemo(() => {
|
|
29286
|
-
if (enableDelete) {
|
|
29287
|
-
return [...columns, deleteColumn];
|
|
29288
|
-
}
|
|
29289
|
-
return columns;
|
|
29290
|
-
}, [columns, enableDelete, deleteColumn]);
|
|
29291
|
-
const dynamicCols = useDynamicColumns({ columns: combinedColumns });
|
|
29301
|
+
const dynamicCols = useDynamicColumns({ columns });
|
|
29292
29302
|
const table = useReactTable({
|
|
29293
29303
|
data,
|
|
29294
29304
|
columns: dynamicCols,
|
|
@@ -29414,7 +29424,7 @@ function DataTable({
|
|
|
29414
29424
|
] })
|
|
29415
29425
|
] }),
|
|
29416
29426
|
/* @__PURE__ */ jsxs31(Table3, { children: [
|
|
29417
|
-
/* @__PURE__ */ jsx53(TableHeader, { children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ jsx53(TableRow, { children: hg.headers.map((header) => {
|
|
29427
|
+
/* @__PURE__ */ jsx53(TableHeader, { children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ jsx53(TableRow, { children: hg.headers.map((header, index) => {
|
|
29418
29428
|
const canSort = header.column.getCanSort();
|
|
29419
29429
|
const canFilter = header.column.getCanFilter();
|
|
29420
29430
|
const sortDir = manualSort?.key === header.column.id ? manualSort.dir : null;
|
|
@@ -29494,26 +29504,49 @@ function DataTable({
|
|
|
29494
29504
|
}
|
|
29495
29505
|
)
|
|
29496
29506
|
] })
|
|
29497
|
-
] }) }, header.id);
|
|
29498
|
-
}) }, hg.id)) }),
|
|
29499
|
-
/* @__PURE__ */ jsx53(TableBody, { children: loading ? /* @__PURE__ */ jsx53(Fragment20, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsx53(TableRow, { children:
|
|
29507
|
+
] }) }, `header-${header.id}-${index}`);
|
|
29508
|
+
}) }, `header-group-${hg.id}`)) }),
|
|
29509
|
+
/* @__PURE__ */ jsx53(TableBody, { children: loading ? /* @__PURE__ */ jsx53(Fragment20, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsx53(TableRow, { children: dynamicCols.map((_2, j) => /* @__PURE__ */ jsx53(TableCell, { className: "p-3", children: /* @__PURE__ */ jsx53("span", { className: "h-4 bg-gray-200 rounded w-3/4 block animate-pulse" }) }, j)) }, i)) }) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx53(TableRow, { children: row.getVisibleCells().map((cell, cellIndex, arr) => {
|
|
29500
29510
|
const meta = cell.column.columnDef.meta || {};
|
|
29501
29511
|
const isClickable = meta?.isClickable;
|
|
29502
|
-
|
|
29512
|
+
const isLastCell = cellIndex === arr.length - 1;
|
|
29513
|
+
return /* @__PURE__ */ jsxs31(
|
|
29503
29514
|
TableCell,
|
|
29504
29515
|
{
|
|
29505
|
-
className: `${meta?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100" : ""}`,
|
|
29516
|
+
className: `${meta?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100" : ""} relative`,
|
|
29506
29517
|
style: meta?.cellStyle,
|
|
29507
29518
|
onClick: () => {
|
|
29508
29519
|
if (isClickable && onCellClick) {
|
|
29509
29520
|
onCellClick(cell.row.original, cell.column.id);
|
|
29510
29521
|
}
|
|
29511
29522
|
},
|
|
29512
|
-
children:
|
|
29523
|
+
children: [
|
|
29524
|
+
flexRender(cell.column.columnDef.cell, cell.getContext()),
|
|
29525
|
+
isLastCell && rowActions && rowActions.length > 0 && /* @__PURE__ */ jsx53("div", { className: "absolute bg-[#fff] p-1 px-4 inset-y-0 right-0 flex items-center opacity-0 group-hover:opacity-100 transition-opacity duration-200 shadow-lg rounded", children: rowActions.map((action) => {
|
|
29526
|
+
const isDelete = action.id === "delete" || action.icon === "delete";
|
|
29527
|
+
return /* @__PURE__ */ jsx53(
|
|
29528
|
+
"button",
|
|
29529
|
+
{
|
|
29530
|
+
className: `ml-2 px-2 py-1 text-[12px] rounded cursor-pointer ${isDelete ? "bg-red-800 text-white hover:bg-neutral-600" : "bg-gray-300 hover:bg-gray-400"}`,
|
|
29531
|
+
onClick: (event) => {
|
|
29532
|
+
event.stopPropagation();
|
|
29533
|
+
if (isDelete) {
|
|
29534
|
+
onDeleteRow?.(cell.row.original, "delete");
|
|
29535
|
+
} else {
|
|
29536
|
+
onCellClick?.(cell.row.original, cell.column.id);
|
|
29537
|
+
}
|
|
29538
|
+
},
|
|
29539
|
+
title: action.header,
|
|
29540
|
+
children: action.header
|
|
29541
|
+
},
|
|
29542
|
+
action.id
|
|
29543
|
+
);
|
|
29544
|
+
}) })
|
|
29545
|
+
]
|
|
29513
29546
|
},
|
|
29514
|
-
cell.id
|
|
29547
|
+
`cell-${cell.id}-${cellIndex}`
|
|
29515
29548
|
);
|
|
29516
|
-
}) }, row.id)) : /* @__PURE__ */ jsx53(TableRow, { children: /* @__PURE__ */ jsx53(TableCell, { colSpan:
|
|
29549
|
+
}) }, row.id)) : /* @__PURE__ */ jsx53(TableRow, { children: /* @__PURE__ */ jsx53(TableCell, { colSpan: dynamicCols.length, className: "h-24 text-center", children: /* @__PURE__ */ jsx53("span", { className: "flex items-center justify-center py-10 w-full min-w-full text-gray-600 bg-gray-100", children: "No results." }) }) }) })
|
|
29517
29550
|
] }),
|
|
29518
29551
|
pagination && /* @__PURE__ */ jsxs31("div", { className: "flex items-center justify-between py-3 px-2 text-sm w-full", children: [
|
|
29519
29552
|
/* @__PURE__ */ jsxs31("div", { children: [
|
|
@@ -29580,7 +29613,6 @@ var Table4 = ({
|
|
|
29580
29613
|
totalRecords = 0,
|
|
29581
29614
|
globalSearch = false,
|
|
29582
29615
|
onCellClick,
|
|
29583
|
-
enableDelete,
|
|
29584
29616
|
onDeleteRow,
|
|
29585
29617
|
...props
|
|
29586
29618
|
}) => {
|
|
@@ -29612,8 +29644,7 @@ var Table4 = ({
|
|
|
29612
29644
|
},
|
|
29613
29645
|
onDeleteRow: (cell) => {
|
|
29614
29646
|
onDeleteRow?.(cell.id);
|
|
29615
|
-
}
|
|
29616
|
-
enableDelete
|
|
29647
|
+
}
|
|
29617
29648
|
}
|
|
29618
29649
|
) });
|
|
29619
29650
|
};
|
|
@@ -29826,7 +29857,7 @@ var CustomPagination = ({
|
|
|
29826
29857
|
var Pagination_default = CustomPagination;
|
|
29827
29858
|
|
|
29828
29859
|
// src/components/Navigation/Tabs/Tabs.tsx
|
|
29829
|
-
import { useCallback as useCallback3, useMemo as
|
|
29860
|
+
import { useCallback as useCallback3, useMemo as useMemo4, useState as useState8 } from "react";
|
|
29830
29861
|
import Link5 from "next/link";
|
|
29831
29862
|
import { useRouter } from "next/navigation";
|
|
29832
29863
|
import { Fragment as Fragment21, jsx as jsx57, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
@@ -29863,7 +29894,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
|
|
|
29863
29894
|
});
|
|
29864
29895
|
return sortMenus(rootMenus);
|
|
29865
29896
|
}
|
|
29866
|
-
const rawTabs =
|
|
29897
|
+
const rawTabs = useMemo4(() => {
|
|
29867
29898
|
if (!Array.isArray(tabs)) return [];
|
|
29868
29899
|
if (source === "manual") return Array.isArray(tabs) ? tabs : [];
|
|
29869
29900
|
return groupMenus(tabs);
|
|
@@ -30105,7 +30136,7 @@ import Link6 from "next/link";
|
|
|
30105
30136
|
import Image4 from "next/image";
|
|
30106
30137
|
import { useRouter as useRouter2 } from "next/navigation";
|
|
30107
30138
|
import { DropdownMenuSeparator } from "@radix-ui/react-dropdown-menu";
|
|
30108
|
-
import { useCallback as useCallback4, useMemo as
|
|
30139
|
+
import { useCallback as useCallback4, useMemo as useMemo5, useState as useState9 } from "react";
|
|
30109
30140
|
import { Fragment as Fragment22, jsx as jsx64, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
30110
30141
|
function Navbar({
|
|
30111
30142
|
style,
|
|
@@ -30144,7 +30175,7 @@ function Navbar({
|
|
|
30144
30175
|
router.push(pendingUrl);
|
|
30145
30176
|
}
|
|
30146
30177
|
};
|
|
30147
|
-
const formatedMenu =
|
|
30178
|
+
const formatedMenu = useMemo5(() => {
|
|
30148
30179
|
if (source === "state" && navList && navList.length) {
|
|
30149
30180
|
return navList.map((i) => ({ ...i, header: i.name || "Menu" }));
|
|
30150
30181
|
}
|
|
@@ -30322,7 +30353,7 @@ var ChartComponent = ({ className, style, loading, ...props }) => {
|
|
|
30322
30353
|
var BarChart_default = React12.memo(ChartComponent);
|
|
30323
30354
|
|
|
30324
30355
|
// src/components/Chart/PieChart.tsx
|
|
30325
|
-
import React13, { useEffect as useEffect25, useMemo as
|
|
30356
|
+
import React13, { useEffect as useEffect25, useMemo as useMemo6, useState as useState10 } from "react";
|
|
30326
30357
|
import {
|
|
30327
30358
|
PieChart,
|
|
30328
30359
|
Pie,
|
|
@@ -30351,18 +30382,18 @@ var DonutChart = ({ className, style, loading, ...props }) => {
|
|
|
30351
30382
|
const showLegends = props.showLegends ?? true;
|
|
30352
30383
|
const labelType = props.labelType || "inside";
|
|
30353
30384
|
const canvasMode = props.canvasMode;
|
|
30354
|
-
const data =
|
|
30385
|
+
const data = useMemo6(() => {
|
|
30355
30386
|
if (!Array.isArray(props.data)) return [];
|
|
30356
30387
|
return props.data.map((item) => ({ ...item, color: getRandomColor() }));
|
|
30357
30388
|
}, [props.data]);
|
|
30358
|
-
const total =
|
|
30389
|
+
const total = useMemo6(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
|
|
30359
30390
|
const forceMobile = canvasMode === "mobile" || canvasMode === "tablet";
|
|
30360
30391
|
const [mounted, setMounted] = useState10(false);
|
|
30361
30392
|
useEffect25(() => {
|
|
30362
30393
|
const timeout = setTimeout(() => setMounted(true), 100);
|
|
30363
30394
|
return () => clearTimeout(timeout);
|
|
30364
30395
|
}, []);
|
|
30365
|
-
const renderLegends =
|
|
30396
|
+
const renderLegends = useMemo6(() => {
|
|
30366
30397
|
if (!showLegends) return null;
|
|
30367
30398
|
return /* @__PURE__ */ jsx66(Fragment23, { children: data.map((d) => /* @__PURE__ */ jsxs40(
|
|
30368
30399
|
"div",
|