@algorithm-shift/design-system 1.2.959 → 1.2.961
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.js +25 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -27675,13 +27675,25 @@ function useLazyDropdown(config) {
|
|
|
27675
27675
|
useEffect13(() => {
|
|
27676
27676
|
configRef.current = config;
|
|
27677
27677
|
}, [config]);
|
|
27678
|
+
function getValueByPath2(obj, path) {
|
|
27679
|
+
if (!obj || !path) return void 0;
|
|
27680
|
+
const parts = path.split(/\./);
|
|
27681
|
+
return parts.reduce((acc, key) => acc?.[key], obj);
|
|
27682
|
+
}
|
|
27678
27683
|
const transformToOptions = useCallback2((data) => {
|
|
27679
27684
|
if (!data || !Array.isArray(data)) return [];
|
|
27680
27685
|
const cfg = configRef.current;
|
|
27681
|
-
return data.map((item) =>
|
|
27682
|
-
value
|
|
27683
|
-
|
|
27684
|
-
|
|
27686
|
+
return data.map((item) => {
|
|
27687
|
+
const value = getValueByPath2(item, cfg.dataKey) ?? item.id ?? "";
|
|
27688
|
+
let label = "";
|
|
27689
|
+
if (cfg.dataLabel) {
|
|
27690
|
+
label = getValueByPath2(item, cfg.dataLabel) ?? item.name ?? item.label ?? item.first_name ?? "";
|
|
27691
|
+
}
|
|
27692
|
+
return {
|
|
27693
|
+
value,
|
|
27694
|
+
label
|
|
27695
|
+
};
|
|
27696
|
+
});
|
|
27685
27697
|
}, []);
|
|
27686
27698
|
const fetchApiData = useCallback2(async (pageNum, term) => {
|
|
27687
27699
|
if (!configRef.current.apiUrl) return [];
|
|
@@ -29325,10 +29337,17 @@ function DataTable({
|
|
|
29325
29337
|
onPageChange?.(currentPageIndex, newSize);
|
|
29326
29338
|
setLocalPageSize(newSize);
|
|
29327
29339
|
};
|
|
29340
|
+
const pageSizeOptions = React9.useMemo(() => {
|
|
29341
|
+
const options = [10, 20, 50, 100].filter((size) => size < totalRecords);
|
|
29342
|
+
if (options.length === 0) {
|
|
29343
|
+
options.push(10);
|
|
29344
|
+
}
|
|
29345
|
+
return options;
|
|
29346
|
+
}, [totalRecords]);
|
|
29328
29347
|
return /* @__PURE__ */ jsxs29("div", { className: "overflow-hidden rounded-md w-full", children: [
|
|
29329
29348
|
!loading && /* @__PURE__ */ jsxs29("div", { className: "flex justify-between p-2 bg-gray-50", children: [
|
|
29330
29349
|
/* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-4 w-full", children: [
|
|
29331
|
-
/* @__PURE__ */ jsxs29("p", { className: "text-sm font-medium", children: [
|
|
29350
|
+
totalRecords && /* @__PURE__ */ jsxs29("p", { className: "text-sm font-medium", children: [
|
|
29332
29351
|
"Total Records : ",
|
|
29333
29352
|
totalRecords.toLocaleString("en-IN") || 0
|
|
29334
29353
|
] }),
|
|
@@ -29558,7 +29577,7 @@ function DataTable({
|
|
|
29558
29577
|
value: localPageSize,
|
|
29559
29578
|
onChange: handlePageSizeChange,
|
|
29560
29579
|
className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
|
|
29561
|
-
children:
|
|
29580
|
+
children: pageSizeOptions.map((size) => /* @__PURE__ */ jsxs29("option", { value: size, children: [
|
|
29562
29581
|
size,
|
|
29563
29582
|
" / page"
|
|
29564
29583
|
] }, size))
|
|
@@ -29873,7 +29892,7 @@ var CustomPagination = ({
|
|
|
29873
29892
|
var Pagination_default = CustomPagination;
|
|
29874
29893
|
|
|
29875
29894
|
// src/components/Navigation/Tabs/Tabs.tsx
|
|
29876
|
-
import { useCallback as useCallback3, useMemo as
|
|
29895
|
+
import { useCallback as useCallback3, useMemo as useMemo6, useState as useState8 } from "react";
|
|
29877
29896
|
import Link5 from "next/link";
|
|
29878
29897
|
import { useRouter } from "next/navigation";
|
|
29879
29898
|
|
|
@@ -30027,7 +30046,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
|
|
|
30027
30046
|
});
|
|
30028
30047
|
return sortMenus(rootMenus);
|
|
30029
30048
|
}
|
|
30030
|
-
const rawTabs =
|
|
30049
|
+
const rawTabs = useMemo6(() => {
|
|
30031
30050
|
if (!Array.isArray(tabs)) return [];
|
|
30032
30051
|
if (source === "manual") return Array.isArray(tabs) ? tabs : [];
|
|
30033
30052
|
return groupMenus(tabs);
|
|
@@ -30322,7 +30341,7 @@ import Link6 from "next/link";
|
|
|
30322
30341
|
import Image4 from "next/image";
|
|
30323
30342
|
import { useRouter as useRouter2 } from "next/navigation";
|
|
30324
30343
|
import { DropdownMenuSeparator } from "@radix-ui/react-dropdown-menu";
|
|
30325
|
-
import { useCallback as useCallback4, useMemo as
|
|
30344
|
+
import { useCallback as useCallback4, useMemo as useMemo7, useState as useState10 } from "react";
|
|
30326
30345
|
import { Fragment as Fragment23, jsx as jsx63, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
30327
30346
|
function Navbar({
|
|
30328
30347
|
style,
|
|
@@ -30361,7 +30380,7 @@ function Navbar({
|
|
|
30361
30380
|
router.push(pendingUrl);
|
|
30362
30381
|
}
|
|
30363
30382
|
};
|
|
30364
|
-
const formatedMenu =
|
|
30383
|
+
const formatedMenu = useMemo7(() => {
|
|
30365
30384
|
if (source === "state" && navList && navList.length) {
|
|
30366
30385
|
return navList.map((i) => ({ ...i, header: i.name || "Menu" }));
|
|
30367
30386
|
}
|
|
@@ -30539,7 +30558,7 @@ var ChartComponent = ({ className, style, loading, ...props }) => {
|
|
|
30539
30558
|
var BarChart_default = React12.memo(ChartComponent);
|
|
30540
30559
|
|
|
30541
30560
|
// src/components/Chart/PieChart.tsx
|
|
30542
|
-
import React13, { useEffect as useEffect25, useMemo as
|
|
30561
|
+
import React13, { useEffect as useEffect25, useMemo as useMemo8, useState as useState11 } from "react";
|
|
30543
30562
|
import {
|
|
30544
30563
|
PieChart,
|
|
30545
30564
|
Pie,
|
|
@@ -30568,18 +30587,18 @@ var DonutChart = ({ className, style, loading, ...props }) => {
|
|
|
30568
30587
|
const showLegends = props.showLegends ?? true;
|
|
30569
30588
|
const labelType = props.labelType || "inside";
|
|
30570
30589
|
const canvasMode = props.canvasMode;
|
|
30571
|
-
const data =
|
|
30590
|
+
const data = useMemo8(() => {
|
|
30572
30591
|
if (!Array.isArray(props.data)) return [];
|
|
30573
30592
|
return props.data.map((item) => ({ ...item, color: getRandomColor() }));
|
|
30574
30593
|
}, [props.data]);
|
|
30575
|
-
const total =
|
|
30594
|
+
const total = useMemo8(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
|
|
30576
30595
|
const forceMobile = canvasMode === "mobile" || canvasMode === "tablet";
|
|
30577
30596
|
const [mounted, setMounted] = useState11(false);
|
|
30578
30597
|
useEffect25(() => {
|
|
30579
30598
|
const timeout = setTimeout(() => setMounted(true), 100);
|
|
30580
30599
|
return () => clearTimeout(timeout);
|
|
30581
30600
|
}, []);
|
|
30582
|
-
const renderLegends =
|
|
30601
|
+
const renderLegends = useMemo8(() => {
|
|
30583
30602
|
if (!showLegends) return null;
|
|
30584
30603
|
return /* @__PURE__ */ jsx65(Fragment24, { children: data.map((d) => /* @__PURE__ */ jsxs39(
|
|
30585
30604
|
"div",
|