@algorithm-shift/design-system 1.2.958 → 1.2.960
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 +3 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +79 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -37
- 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 ?? "";
|
|
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 [];
|
|
@@ -28979,9 +28991,12 @@ var valueFormatter = (value, format2, customFormatters = {}) => {
|
|
|
28979
28991
|
switch (type) {
|
|
28980
28992
|
case "date":
|
|
28981
28993
|
return dayjs_setup_default(value).format(arg || "YYYY-MM-DD");
|
|
28982
|
-
case "
|
|
28994
|
+
case "datetimenumber":
|
|
28983
28995
|
const parsed = dayjs_setup_default(value).isValid() ? dayjs_setup_default(value).utc() : dayjs_setup_default(value);
|
|
28984
28996
|
return parsed.format("YYYY-MM-DD hh:mm");
|
|
28997
|
+
case "datetime":
|
|
28998
|
+
const formated = dayjs_setup_default(value).isValid() ? dayjs_setup_default(value).utc() : dayjs_setup_default(value);
|
|
28999
|
+
return formated.format("DD MMM YYYY hh:mm A");
|
|
28985
29000
|
case "days":
|
|
28986
29001
|
return `${dayjs_setup_default().diff(dayjs_setup_default(value), "day")} days`;
|
|
28987
29002
|
case "months":
|
|
@@ -29267,6 +29282,7 @@ function DataTable({
|
|
|
29267
29282
|
const [searchTerm, setSearchTerm] = React9.useState("");
|
|
29268
29283
|
const tableData = Array.isArray(data) ? data : [];
|
|
29269
29284
|
const dynamicCols = useDynamicColumns({ columns });
|
|
29285
|
+
const [localPageSize, setLocalPageSize] = React9.useState(pageSize);
|
|
29270
29286
|
const table = useReactTable({
|
|
29271
29287
|
data: tableData,
|
|
29272
29288
|
columns: dynamicCols,
|
|
@@ -29315,36 +29331,48 @@ function DataTable({
|
|
|
29315
29331
|
return [];
|
|
29316
29332
|
};
|
|
29317
29333
|
const pageCount = table.getPageCount() === 0 ? 1 : table.getPageCount();
|
|
29334
|
+
const handlePageSizeChange = (e) => {
|
|
29335
|
+
const newSize = Number(e.target.value);
|
|
29336
|
+
const currentPageIndex = table.getState().pagination.pageIndex;
|
|
29337
|
+
onPageChange?.(currentPageIndex, newSize);
|
|
29338
|
+
setLocalPageSize(newSize);
|
|
29339
|
+
};
|
|
29318
29340
|
return /* @__PURE__ */ jsxs29("div", { className: "overflow-hidden rounded-md w-full", children: [
|
|
29319
|
-
/* @__PURE__ */ jsxs29("div", { className:
|
|
29320
|
-
|
|
29321
|
-
/* @__PURE__ */ jsxs29("
|
|
29341
|
+
!loading && /* @__PURE__ */ jsxs29("div", { className: "flex justify-between p-2 bg-gray-50", children: [
|
|
29342
|
+
/* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-4 w-full", children: [
|
|
29343
|
+
/* @__PURE__ */ jsxs29("p", { className: "text-sm font-medium", children: [
|
|
29344
|
+
"Total Records : ",
|
|
29345
|
+
totalRecords.toLocaleString("en-IN") || 0
|
|
29346
|
+
] }),
|
|
29347
|
+
globalSearch && /* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
|
|
29348
|
+
/* @__PURE__ */ jsxs29("div", { className: "relative w-full", children: [
|
|
29349
|
+
/* @__PURE__ */ jsx51(
|
|
29350
|
+
"input",
|
|
29351
|
+
{
|
|
29352
|
+
type: "text",
|
|
29353
|
+
placeholder: "Search...",
|
|
29354
|
+
value: searchTerm,
|
|
29355
|
+
onChange: (e) => setSearchTerm(e.target.value),
|
|
29356
|
+
onKeyDown: (e) => {
|
|
29357
|
+
if (e.key === "Enter" && onGlobalSearch) {
|
|
29358
|
+
onGlobalSearch(searchTerm.trim());
|
|
29359
|
+
}
|
|
29360
|
+
},
|
|
29361
|
+
className: "border border-gray-300 rounded-md text-sm px-3 py-2 pl-8 w-full focus:outline-none focus:ring-1 focus:ring-[#12715B]"
|
|
29362
|
+
}
|
|
29363
|
+
),
|
|
29364
|
+
/* @__PURE__ */ jsx51(Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
|
|
29365
|
+
] }),
|
|
29322
29366
|
/* @__PURE__ */ jsx51(
|
|
29323
|
-
|
|
29367
|
+
Button,
|
|
29324
29368
|
{
|
|
29325
|
-
|
|
29326
|
-
|
|
29327
|
-
|
|
29328
|
-
|
|
29329
|
-
onKeyDown: (e) => {
|
|
29330
|
-
if (e.key === "Enter" && onGlobalSearch) {
|
|
29331
|
-
onGlobalSearch(searchTerm.trim());
|
|
29332
|
-
}
|
|
29333
|
-
},
|
|
29334
|
-
className: "border border-gray-300 rounded-md text-sm px-3 py-2 pl-8 w-full focus:outline-none focus:ring-1 focus:ring-[#12715B]"
|
|
29369
|
+
size: "sm",
|
|
29370
|
+
className: "bg-[#12715B] text-white text-xs h-auto py-2 px-3",
|
|
29371
|
+
onClick: () => onGlobalSearch?.(searchTerm.trim()),
|
|
29372
|
+
children: "Search"
|
|
29335
29373
|
}
|
|
29336
|
-
)
|
|
29337
|
-
|
|
29338
|
-
] }),
|
|
29339
|
-
/* @__PURE__ */ jsx51(
|
|
29340
|
-
Button,
|
|
29341
|
-
{
|
|
29342
|
-
size: "sm",
|
|
29343
|
-
className: "bg-[#12715B] text-white text-xs h-auto py-2 px-3",
|
|
29344
|
-
onClick: () => onGlobalSearch?.(searchTerm.trim()),
|
|
29345
|
-
children: "Search"
|
|
29346
|
-
}
|
|
29347
|
-
)
|
|
29374
|
+
)
|
|
29375
|
+
] })
|
|
29348
29376
|
] }),
|
|
29349
29377
|
/* @__PURE__ */ jsxs29(Popover, { children: [
|
|
29350
29378
|
/* @__PURE__ */ jsx51(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx51(
|
|
@@ -29534,12 +29562,26 @@ function DataTable({
|
|
|
29534
29562
|
);
|
|
29535
29563
|
}) }, 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." }) }) }) })
|
|
29536
29564
|
] }),
|
|
29537
|
-
pagination && /* @__PURE__ */ jsxs29("div", { className: "flex items-center justify-between py-3
|
|
29538
|
-
/* @__PURE__ */ jsxs29("div", { children: [
|
|
29539
|
-
|
|
29540
|
-
|
|
29541
|
-
|
|
29542
|
-
|
|
29565
|
+
pagination && /* @__PURE__ */ jsxs29("div", { className: "flex items-center justify-between py-3 text-sm w-full", children: [
|
|
29566
|
+
!loading && /* @__PURE__ */ jsxs29("div", { className: "flex gap-2 items-center", children: [
|
|
29567
|
+
/* @__PURE__ */ jsx51(
|
|
29568
|
+
"select",
|
|
29569
|
+
{
|
|
29570
|
+
value: localPageSize,
|
|
29571
|
+
onChange: handlePageSizeChange,
|
|
29572
|
+
className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
|
|
29573
|
+
children: [10, 20, 50, 100].map((size) => /* @__PURE__ */ jsxs29("option", { value: size, children: [
|
|
29574
|
+
size,
|
|
29575
|
+
" / page"
|
|
29576
|
+
] }, size))
|
|
29577
|
+
}
|
|
29578
|
+
),
|
|
29579
|
+
/* @__PURE__ */ jsxs29("div", { children: [
|
|
29580
|
+
"Page ",
|
|
29581
|
+
table.getState().pagination.pageIndex + 1,
|
|
29582
|
+
" of ",
|
|
29583
|
+
pageCount
|
|
29584
|
+
] })
|
|
29543
29585
|
] }),
|
|
29544
29586
|
/* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-2", children: [
|
|
29545
29587
|
/* @__PURE__ */ jsx51(
|