baaz-custom-components 3.3.3 → 5.0.1
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 +4791 -103
- package/dist/index.d.mts +62 -1
- package/dist/index.d.ts +62 -1
- package/dist/index.js +550 -2
- package/dist/index.mjs +554 -1
- package/dist/styles.css +1 -1
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -60,7 +60,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
60
60
|
var index_exports = {};
|
|
61
61
|
__export(index_exports, {
|
|
62
62
|
CustomBreadcrumb: () => breadcrumb_default,
|
|
63
|
-
|
|
63
|
+
Grid: () => grid_default,
|
|
64
|
+
Navbar: () => Navbar,
|
|
65
|
+
Pagination: () => pagination_default
|
|
64
66
|
});
|
|
65
67
|
module.exports = __toCommonJS(index_exports);
|
|
66
68
|
|
|
@@ -1947,8 +1949,554 @@ var CustomBreadcrumb = ({
|
|
|
1947
1949
|
] }) });
|
|
1948
1950
|
};
|
|
1949
1951
|
var breadcrumb_default = CustomBreadcrumb;
|
|
1952
|
+
|
|
1953
|
+
// src/components/custom/grid/index.tsx
|
|
1954
|
+
var import_react6 = require("react");
|
|
1955
|
+
var import_react_grid = require("@svar-ui/react-grid");
|
|
1956
|
+
|
|
1957
|
+
// src/components/custom/grid/sortableHeaderCell.tsx
|
|
1958
|
+
var import_lucide_react12 = require("lucide-react");
|
|
1959
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1960
|
+
function SortableHeaderCell({ cell, sortKey, sortOrder, onSortChange }) {
|
|
1961
|
+
if (!(cell == null ? void 0 : cell.id)) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: cell == null ? void 0 : cell.text });
|
|
1962
|
+
const active = sortKey === cell.id;
|
|
1963
|
+
const handleClick = () => {
|
|
1964
|
+
if (!onSortChange) return;
|
|
1965
|
+
if (active) {
|
|
1966
|
+
onSortChange(cell.id, sortOrder === "asc" ? "desc" : "asc");
|
|
1967
|
+
} else {
|
|
1968
|
+
onSortChange(cell.id, "asc");
|
|
1969
|
+
}
|
|
1970
|
+
};
|
|
1971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1972
|
+
"div",
|
|
1973
|
+
{
|
|
1974
|
+
onClick: handleClick,
|
|
1975
|
+
className: "cursor-pointer flex items-center gap-2 justify-between select-none",
|
|
1976
|
+
children: [
|
|
1977
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: cell.text }),
|
|
1978
|
+
active && (sortOrder === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.MoveDown, { className: "w-3 h-4" }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.MoveUp, { className: "w-3 h-4" }))
|
|
1979
|
+
]
|
|
1980
|
+
}
|
|
1981
|
+
);
|
|
1982
|
+
}
|
|
1983
|
+
var sortableHeaderCell_default = SortableHeaderCell;
|
|
1984
|
+
|
|
1985
|
+
// src/utils/exportPdf.ts
|
|
1986
|
+
var import_jspdf = __toESM(require("jspdf"));
|
|
1987
|
+
var import_jspdf_autotable = __toESM(require("jspdf-autotable"));
|
|
1988
|
+
function exportPdf(rows, name) {
|
|
1989
|
+
if (!rows.length) return;
|
|
1990
|
+
const doc = new import_jspdf.default();
|
|
1991
|
+
const columns = Object.keys(rows[0]);
|
|
1992
|
+
const body = rows.map((row) => columns.map((col) => {
|
|
1993
|
+
var _a;
|
|
1994
|
+
return String((_a = row[col]) != null ? _a : "");
|
|
1995
|
+
}));
|
|
1996
|
+
(0, import_jspdf_autotable.default)(doc, {
|
|
1997
|
+
head: [columns],
|
|
1998
|
+
body,
|
|
1999
|
+
styles: { fontSize: 8 },
|
|
2000
|
+
headStyles: { fillColor: [40, 40, 40] }
|
|
2001
|
+
});
|
|
2002
|
+
doc.save(`${name != null ? name : "export"}.pdf`);
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
// src/utils/exportExcel.ts
|
|
2006
|
+
var XLSX = __toESM(require("xlsx"));
|
|
2007
|
+
function exportExcel(rows, name) {
|
|
2008
|
+
if (!rows.length) return;
|
|
2009
|
+
const worksheet = XLSX.utils.json_to_sheet(rows);
|
|
2010
|
+
const workbook = XLSX.utils.book_new();
|
|
2011
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, "Data");
|
|
2012
|
+
XLSX.writeFile(workbook, `${name != null ? name : "export"}.xlsx`);
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
// src/components/custom/grid/gridHeader.tsx
|
|
2016
|
+
var import_react5 = require("react");
|
|
2017
|
+
var import_lucide_react13 = require("lucide-react");
|
|
2018
|
+
var import_navigation = require("next/navigation");
|
|
2019
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2020
|
+
var GridHeader = ({
|
|
2021
|
+
onPdf,
|
|
2022
|
+
onExcel,
|
|
2023
|
+
onSearch,
|
|
2024
|
+
download,
|
|
2025
|
+
search,
|
|
2026
|
+
searchValue,
|
|
2027
|
+
searchkey = "",
|
|
2028
|
+
filterList
|
|
2029
|
+
}) => {
|
|
2030
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2031
|
+
const router = (0, import_navigation.useRouter)();
|
|
2032
|
+
const searchParams = (0, import_navigation.useSearchParams)();
|
|
2033
|
+
const [downloadMenu, setDownloadMenu] = (0, import_react5.useState)(false);
|
|
2034
|
+
const [filterMenu, setFilterMenu] = (0, import_react5.useState)(false);
|
|
2035
|
+
const [filter, setFilter] = (0, import_react5.useState)({});
|
|
2036
|
+
const downloadRef = (0, import_react5.useRef)(null);
|
|
2037
|
+
const filterRef = (0, import_react5.useRef)(null);
|
|
2038
|
+
const selectedColumn = filterList.find((f) => f.columnName === filter.column);
|
|
2039
|
+
const selectedOperator = selectedColumn == null ? void 0 : selectedColumn.operators.find(
|
|
2040
|
+
(op) => op.label === filter.operator
|
|
2041
|
+
);
|
|
2042
|
+
const updateParams = (next) => {
|
|
2043
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
2044
|
+
if (next.column) params.set("column", next.column);
|
|
2045
|
+
else params.delete("column");
|
|
2046
|
+
if (next.operator) params.set("operator", next.operator);
|
|
2047
|
+
else params.delete("operator");
|
|
2048
|
+
if (next.value) {
|
|
2049
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "date" ? params.set("value", String(Date.parse(next.value))) : params.set("value", next.value);
|
|
2050
|
+
} else params.delete("value");
|
|
2051
|
+
if (next.startDate)
|
|
2052
|
+
params.set("startDate", String(Date.parse(next.startDate)));
|
|
2053
|
+
else params.delete("startDate");
|
|
2054
|
+
if (next.endDate) params.set("endDate", String(Date.parse(next.endDate)));
|
|
2055
|
+
else params.delete("endDate");
|
|
2056
|
+
router.replace(`?${params.toString()}`);
|
|
2057
|
+
};
|
|
2058
|
+
const clearFilters = () => {
|
|
2059
|
+
setFilter({});
|
|
2060
|
+
router.replace("?", { scroll: false });
|
|
2061
|
+
};
|
|
2062
|
+
(0, import_react5.useEffect)(() => {
|
|
2063
|
+
const handleClickOutside = (e) => {
|
|
2064
|
+
if (downloadRef.current && !downloadRef.current.contains(e.target)) {
|
|
2065
|
+
setDownloadMenu(false);
|
|
2066
|
+
}
|
|
2067
|
+
if (filterRef.current && !filterRef.current.contains(e.target)) {
|
|
2068
|
+
setFilterMenu(false);
|
|
2069
|
+
}
|
|
2070
|
+
};
|
|
2071
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2072
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2073
|
+
}, []);
|
|
2074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex justify-end gap-4 items-center", children: [
|
|
2075
|
+
filterList.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "relative", ref: filterRef, children: [
|
|
2076
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2077
|
+
"button",
|
|
2078
|
+
{
|
|
2079
|
+
onClick: () => setFilterMenu((p) => !p),
|
|
2080
|
+
className: "py-2 px-4 rounded-md bg-input hover:bg-muted transition cursor-pointer",
|
|
2081
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react13.ListFilter, { size: 18 })
|
|
2082
|
+
}
|
|
2083
|
+
),
|
|
2084
|
+
filterMenu && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "absolute top-full right-0 mt-2 p-3 !min-w-[30rem] rounded-md border bg-background shadow-lg z-50 flex items-center gap-2", children: [
|
|
2085
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2086
|
+
"select",
|
|
2087
|
+
{
|
|
2088
|
+
className: "px-4 py-2 rounded-md bg-input text-sm focus:outline-none",
|
|
2089
|
+
value: (_a = filter.column) != null ? _a : "",
|
|
2090
|
+
onChange: (e) => {
|
|
2091
|
+
const next = {
|
|
2092
|
+
column: e.target.value,
|
|
2093
|
+
operator: null,
|
|
2094
|
+
value: null
|
|
2095
|
+
};
|
|
2096
|
+
setFilter(next);
|
|
2097
|
+
updateParams(next);
|
|
2098
|
+
},
|
|
2099
|
+
children: [
|
|
2100
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: "", disabled: true, children: "Columns" }),
|
|
2101
|
+
filterList.map((f) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: f.columnName, children: f.columnName }, f.columnName))
|
|
2102
|
+
]
|
|
2103
|
+
}
|
|
2104
|
+
),
|
|
2105
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2106
|
+
"select",
|
|
2107
|
+
{
|
|
2108
|
+
className: "px-4 py-2 rounded-md bg-input text-sm focus:outline-none",
|
|
2109
|
+
value: (_b = filter.operator) != null ? _b : "",
|
|
2110
|
+
disabled: !selectedColumn,
|
|
2111
|
+
onChange: (e) => {
|
|
2112
|
+
const next = __spreadProps(__spreadValues({}, filter), {
|
|
2113
|
+
operator: e.target.value,
|
|
2114
|
+
value: void 0
|
|
2115
|
+
});
|
|
2116
|
+
setFilter(next);
|
|
2117
|
+
updateParams(next);
|
|
2118
|
+
},
|
|
2119
|
+
children: [
|
|
2120
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: "", disabled: true, children: "Operator" }),
|
|
2121
|
+
selectedColumn == null ? void 0 : selectedColumn.operators.map((op) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: op.label, children: op.label }, op.label))
|
|
2122
|
+
]
|
|
2123
|
+
}
|
|
2124
|
+
),
|
|
2125
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "input" && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2126
|
+
"input",
|
|
2127
|
+
{
|
|
2128
|
+
className: "px-4 py-2 rounded-md bg-input text-sm focus:outline-none",
|
|
2129
|
+
placeholder: "Filter value",
|
|
2130
|
+
value: (_c = filter.value) != null ? _c : "",
|
|
2131
|
+
onChange: (e) => {
|
|
2132
|
+
const next = __spreadProps(__spreadValues({}, filter), {
|
|
2133
|
+
value: e.target.value
|
|
2134
|
+
});
|
|
2135
|
+
setFilter(next);
|
|
2136
|
+
updateParams(next);
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
),
|
|
2140
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "date" && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2141
|
+
"input",
|
|
2142
|
+
{
|
|
2143
|
+
type: "datetime-local",
|
|
2144
|
+
className: "px-4 py-2 rounded-md bg-input text-sm focus:outline-none",
|
|
2145
|
+
value: (_d = filter.value) != null ? _d : "",
|
|
2146
|
+
onChange: (e) => setFilter((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
2147
|
+
value: e.target.value
|
|
2148
|
+
}))
|
|
2149
|
+
}
|
|
2150
|
+
),
|
|
2151
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "select" && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2152
|
+
"select",
|
|
2153
|
+
{
|
|
2154
|
+
className: "px-2 py-1 rounded-md bg-input text-sm focus:outline-none",
|
|
2155
|
+
value: (_e = filter.value) != null ? _e : "",
|
|
2156
|
+
onChange: (e) => setFilter((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
2157
|
+
value: e.target.value
|
|
2158
|
+
})),
|
|
2159
|
+
children: [
|
|
2160
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: "", disabled: true, children: "Value" }),
|
|
2161
|
+
(_f = selectedOperator.options) == null ? void 0 : _f.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
|
|
2162
|
+
]
|
|
2163
|
+
}
|
|
2164
|
+
),
|
|
2165
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "date-range" && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2166
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2167
|
+
"input",
|
|
2168
|
+
{
|
|
2169
|
+
type: "datetime-local",
|
|
2170
|
+
className: "px-3 py-2 rounded-md bg-input text-sm",
|
|
2171
|
+
value: (_g = filter.startDate) != null ? _g : "",
|
|
2172
|
+
onChange: (e) => {
|
|
2173
|
+
const nextRange = __spreadProps(__spreadValues({}, filter), {
|
|
2174
|
+
startDate: e.target.value
|
|
2175
|
+
});
|
|
2176
|
+
if (nextRange.startDate) {
|
|
2177
|
+
const next = __spreadProps(__spreadValues({}, filter), {
|
|
2178
|
+
startDate: nextRange.startDate
|
|
2179
|
+
});
|
|
2180
|
+
setFilter(next);
|
|
2181
|
+
updateParams(next);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
),
|
|
2186
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-sm text-muted-foreground", children: "to" }),
|
|
2187
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2188
|
+
"input",
|
|
2189
|
+
{
|
|
2190
|
+
type: "datetime-local",
|
|
2191
|
+
className: "px-3 py-2 rounded-md bg-input text-sm",
|
|
2192
|
+
value: (_h = filter.endDate) != null ? _h : "",
|
|
2193
|
+
onChange: (e) => {
|
|
2194
|
+
const nextRange = __spreadProps(__spreadValues({}, filter), {
|
|
2195
|
+
endDate: e.target.value
|
|
2196
|
+
});
|
|
2197
|
+
if (nextRange.startDate && nextRange.endDate) {
|
|
2198
|
+
const next = __spreadProps(__spreadValues({}, filter), {
|
|
2199
|
+
endDate: nextRange.endDate
|
|
2200
|
+
});
|
|
2201
|
+
setFilter(next);
|
|
2202
|
+
updateParams(next);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
)
|
|
2207
|
+
] }),
|
|
2208
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2209
|
+
"button",
|
|
2210
|
+
{
|
|
2211
|
+
onClick: clearFilters,
|
|
2212
|
+
className: "ml-auto p-2 rounded-md hover:bg-muted transition",
|
|
2213
|
+
title: "Clear filters",
|
|
2214
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react13.X, { size: 16 })
|
|
2215
|
+
}
|
|
2216
|
+
)
|
|
2217
|
+
] })
|
|
2218
|
+
] }),
|
|
2219
|
+
download && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "relative", ref: downloadRef, children: [
|
|
2220
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2221
|
+
"button",
|
|
2222
|
+
{
|
|
2223
|
+
onClick: () => setDownloadMenu((p) => !p),
|
|
2224
|
+
className: "py-2 px-4 rounded-md bg-input hover:bg-muted transition",
|
|
2225
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react13.Download, { size: 18 })
|
|
2226
|
+
}
|
|
2227
|
+
),
|
|
2228
|
+
downloadMenu && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "absolute top-full right-0 mt-2 w-32 rounded-md border bg-background shadow-lg z-50", children: [
|
|
2229
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2230
|
+
"button",
|
|
2231
|
+
{
|
|
2232
|
+
onClick: () => {
|
|
2233
|
+
onPdf();
|
|
2234
|
+
setDownloadMenu(false);
|
|
2235
|
+
},
|
|
2236
|
+
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted",
|
|
2237
|
+
children: [
|
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react13.FileText, { size: 14 }),
|
|
2239
|
+
"PDF"
|
|
2240
|
+
]
|
|
2241
|
+
}
|
|
2242
|
+
),
|
|
2243
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2244
|
+
"button",
|
|
2245
|
+
{
|
|
2246
|
+
onClick: () => {
|
|
2247
|
+
onExcel();
|
|
2248
|
+
setDownloadMenu(false);
|
|
2249
|
+
},
|
|
2250
|
+
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted",
|
|
2251
|
+
children: [
|
|
2252
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react13.FileSpreadsheet, { size: 14 }),
|
|
2253
|
+
"Excel"
|
|
2254
|
+
]
|
|
2255
|
+
}
|
|
2256
|
+
)
|
|
2257
|
+
] })
|
|
2258
|
+
] }),
|
|
2259
|
+
search && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "py-2 px-4 w-[20rem] rounded-md border border-input bg-background flex items-center gap-2 text-sm", children: [
|
|
2260
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react13.Search, { className: "w-4 h-4" }),
|
|
2261
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2262
|
+
"input",
|
|
2263
|
+
{
|
|
2264
|
+
placeholder: `Search by ${searchkey}`,
|
|
2265
|
+
className: "w-full focus:outline-none bg-transparent",
|
|
2266
|
+
onChange: onSearch,
|
|
2267
|
+
value: searchValue
|
|
2268
|
+
}
|
|
2269
|
+
)
|
|
2270
|
+
] })
|
|
2271
|
+
] });
|
|
2272
|
+
};
|
|
2273
|
+
var gridHeader_default = GridHeader;
|
|
2274
|
+
|
|
2275
|
+
// src/components/custom/grid/index.tsx
|
|
2276
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2277
|
+
function Grid(_a) {
|
|
2278
|
+
var _b = _a, {
|
|
2279
|
+
data,
|
|
2280
|
+
columns,
|
|
2281
|
+
sortKey,
|
|
2282
|
+
sortOrder,
|
|
2283
|
+
onSortChange,
|
|
2284
|
+
onExportPdf,
|
|
2285
|
+
onExportExcel,
|
|
2286
|
+
downloadable = true,
|
|
2287
|
+
fileNmae,
|
|
2288
|
+
fonts
|
|
2289
|
+
} = _b, rest = __objRest(_b, [
|
|
2290
|
+
"data",
|
|
2291
|
+
"columns",
|
|
2292
|
+
"sortKey",
|
|
2293
|
+
"sortOrder",
|
|
2294
|
+
"onSortChange",
|
|
2295
|
+
"onExportPdf",
|
|
2296
|
+
"onExportExcel",
|
|
2297
|
+
"downloadable",
|
|
2298
|
+
"fileNmae",
|
|
2299
|
+
"fonts"
|
|
2300
|
+
]);
|
|
2301
|
+
const apiRef = (0, import_react6.useRef)(null);
|
|
2302
|
+
const svarColumns = columns.map((col) => {
|
|
2303
|
+
const _a2 = col, { sortable, header } = _a2, columnProps = __objRest(_a2, ["sortable", "header"]);
|
|
2304
|
+
if (!sortable) {
|
|
2305
|
+
return __spreadProps(__spreadValues({}, columnProps), {
|
|
2306
|
+
header
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
return __spreadProps(__spreadValues({}, columnProps), {
|
|
2310
|
+
header: {
|
|
2311
|
+
text: header,
|
|
2312
|
+
cell: (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2313
|
+
sortableHeaderCell_default,
|
|
2314
|
+
__spreadProps(__spreadValues({}, props), {
|
|
2315
|
+
sortKey,
|
|
2316
|
+
sortOrder,
|
|
2317
|
+
onSortChange
|
|
2318
|
+
})
|
|
2319
|
+
)
|
|
2320
|
+
}
|
|
2321
|
+
});
|
|
2322
|
+
});
|
|
2323
|
+
const init = (api) => {
|
|
2324
|
+
apiRef.current = api;
|
|
2325
|
+
};
|
|
2326
|
+
const getSelectedData = () => {
|
|
2327
|
+
var _a2, _b2;
|
|
2328
|
+
const selected = (_b2 = (_a2 = apiRef.current) == null ? void 0 : _a2.getState().selectedRows) != null ? _b2 : [];
|
|
2329
|
+
let selectedData = data.filter((row) => {
|
|
2330
|
+
return selected.includes(row.id);
|
|
2331
|
+
});
|
|
2332
|
+
return selectedData;
|
|
2333
|
+
};
|
|
2334
|
+
const handleExportPdf = () => {
|
|
2335
|
+
const selected = getSelectedData();
|
|
2336
|
+
if (selected.length) {
|
|
2337
|
+
exportPdf(selected, fileNmae);
|
|
2338
|
+
} else {
|
|
2339
|
+
onExportPdf == null ? void 0 : onExportPdf();
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2342
|
+
const handleExportExcel = () => {
|
|
2343
|
+
const selected = getSelectedData();
|
|
2344
|
+
if (selected.length) {
|
|
2345
|
+
exportExcel(selected, fileNmae);
|
|
2346
|
+
} else {
|
|
2347
|
+
onExportExcel == null ? void 0 : onExportExcel();
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "w-full h-full overflow-auto flex flex-col gap-4", children: [
|
|
2351
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2352
|
+
gridHeader_default,
|
|
2353
|
+
{
|
|
2354
|
+
onPdf: handleExportPdf,
|
|
2355
|
+
onExcel: handleExportExcel,
|
|
2356
|
+
download: downloadable,
|
|
2357
|
+
search: rest.search,
|
|
2358
|
+
searchkey: rest.searchkey,
|
|
2359
|
+
onSearch: rest.onSearch,
|
|
2360
|
+
searchValue: rest.searchValue,
|
|
2361
|
+
filterList: rest.filterList
|
|
2362
|
+
}
|
|
2363
|
+
),
|
|
2364
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_grid.WillowDark, { fonts, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_grid.Grid, __spreadProps(__spreadValues({}, rest), { data, columns: svarColumns, init })) })
|
|
2365
|
+
] });
|
|
2366
|
+
}
|
|
2367
|
+
var grid_default = Grid;
|
|
2368
|
+
|
|
2369
|
+
// src/components/custom/pagination/index.tsx
|
|
2370
|
+
var import_react7 = require("react");
|
|
2371
|
+
var import_navigation2 = require("next/navigation");
|
|
2372
|
+
|
|
2373
|
+
// src/utils/pagination.ts
|
|
2374
|
+
function getPaginationRange(currentPage, totalPages, siblingCount = 2) {
|
|
2375
|
+
const range = [];
|
|
2376
|
+
if (totalPages <= 1) return [1];
|
|
2377
|
+
const firstPage = 1;
|
|
2378
|
+
const lastPage = totalPages;
|
|
2379
|
+
const leftSiblingStart = Math.max(
|
|
2380
|
+
currentPage - siblingCount,
|
|
2381
|
+
firstPage + 1
|
|
2382
|
+
);
|
|
2383
|
+
const rightSiblingEnd = Math.min(
|
|
2384
|
+
currentPage + siblingCount,
|
|
2385
|
+
lastPage - 1
|
|
2386
|
+
);
|
|
2387
|
+
range.push(firstPage);
|
|
2388
|
+
if (leftSiblingStart > firstPage + 1) {
|
|
2389
|
+
range.push("dots");
|
|
2390
|
+
}
|
|
2391
|
+
for (let page = leftSiblingStart; page <= rightSiblingEnd; page++) {
|
|
2392
|
+
range.push(page);
|
|
2393
|
+
}
|
|
2394
|
+
if (rightSiblingEnd < lastPage - 1) {
|
|
2395
|
+
range.push("dots");
|
|
2396
|
+
}
|
|
2397
|
+
if (lastPage !== firstPage) {
|
|
2398
|
+
range.push(lastPage);
|
|
2399
|
+
}
|
|
2400
|
+
return range;
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
// src/components/custom/pagination/index.tsx
|
|
2404
|
+
var import_lucide_react14 = require("lucide-react");
|
|
2405
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2406
|
+
function Pagination({
|
|
2407
|
+
totalCount,
|
|
2408
|
+
count = null,
|
|
2409
|
+
currentPage = 1,
|
|
2410
|
+
totalPages = 1,
|
|
2411
|
+
pageSize = 10,
|
|
2412
|
+
onPageChange,
|
|
2413
|
+
onPageSizeChange,
|
|
2414
|
+
showSizeChanger = false,
|
|
2415
|
+
sizeChangerOptions = [10, 20, 50, 100]
|
|
2416
|
+
}) {
|
|
2417
|
+
const router = (0, import_navigation2.useRouter)();
|
|
2418
|
+
const params = (0, import_navigation2.useSearchParams)();
|
|
2419
|
+
const setParams = (0, import_react7.useCallback)(
|
|
2420
|
+
(updates) => {
|
|
2421
|
+
const q = new URLSearchParams(params.toString());
|
|
2422
|
+
Object.entries(updates).forEach(([k, v]) => q.set(k, v));
|
|
2423
|
+
router.replace(`?${q.toString()}`, { scroll: false });
|
|
2424
|
+
},
|
|
2425
|
+
[params, router]
|
|
2426
|
+
);
|
|
2427
|
+
const handlePageChange = (page) => {
|
|
2428
|
+
if (page < 1 || page > totalPages) return;
|
|
2429
|
+
if (onPageChange) {
|
|
2430
|
+
onPageChange(page);
|
|
2431
|
+
return;
|
|
2432
|
+
}
|
|
2433
|
+
setParams({ page: String(page) });
|
|
2434
|
+
};
|
|
2435
|
+
const handlePageSizeChange = (size) => {
|
|
2436
|
+
if (onPageSizeChange) {
|
|
2437
|
+
onPageSizeChange(size);
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
setParams({ pageSize: String(size), page: "1" });
|
|
2441
|
+
};
|
|
2442
|
+
if (totalPages <= 1) return null;
|
|
2443
|
+
const pages = getPaginationRange(currentPage, totalPages);
|
|
2444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center justify-between px-4 py-3 text-foreground", children: [
|
|
2445
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-3 text-sm text-muted-foreground", children: [
|
|
2446
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { children: [
|
|
2447
|
+
"Showing ",
|
|
2448
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-foreground", children: count }),
|
|
2449
|
+
" of",
|
|
2450
|
+
" ",
|
|
2451
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-foreground", children: totalCount })
|
|
2452
|
+
] }),
|
|
2453
|
+
showSizeChanger && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2454
|
+
"select",
|
|
2455
|
+
{
|
|
2456
|
+
value: pageSize,
|
|
2457
|
+
onChange: (e) => handlePageSizeChange(Number(e.target.value)),
|
|
2458
|
+
className: "rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",
|
|
2459
|
+
children: sizeChangerOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("option", { value: size, children: [
|
|
2460
|
+
size,
|
|
2461
|
+
" / page"
|
|
2462
|
+
] }, size))
|
|
2463
|
+
}
|
|
2464
|
+
)
|
|
2465
|
+
] }),
|
|
2466
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2467
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2468
|
+
import_lucide_react14.ChevronLeft,
|
|
2469
|
+
{
|
|
2470
|
+
onClick: () => currentPage === totalPages ? null : handlePageChange(currentPage - 1),
|
|
2471
|
+
className: "rounded-md border border-border w-8 h-8 text-sm hover:bg-card-foreground disabled:opacity-40"
|
|
2472
|
+
}
|
|
2473
|
+
),
|
|
2474
|
+
pages.map(
|
|
2475
|
+
(page, idx) => page === "dots" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "px-2 text-muted-foreground", children: "\u2026" }, `dots-${idx}`) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2476
|
+
"button",
|
|
2477
|
+
{
|
|
2478
|
+
onClick: () => handlePageChange(page),
|
|
2479
|
+
className: `rounded-md w-8 h-8 text-sm transition ${page === currentPage ? "bg-card-foreground text-foreground" : "hover:bg-card-foreground"}`,
|
|
2480
|
+
children: page
|
|
2481
|
+
},
|
|
2482
|
+
page
|
|
2483
|
+
)
|
|
2484
|
+
),
|
|
2485
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2486
|
+
import_lucide_react14.ChevronRight,
|
|
2487
|
+
{
|
|
2488
|
+
onClick: () => currentPage === totalPages ? null : handlePageChange(currentPage + 1),
|
|
2489
|
+
className: "rounded-md border border-border w-8 h-8 text-sm hover:bg-card-foreground disabled:opacity-40"
|
|
2490
|
+
}
|
|
2491
|
+
)
|
|
2492
|
+
] })
|
|
2493
|
+
] });
|
|
2494
|
+
}
|
|
2495
|
+
var pagination_default = Pagination;
|
|
1950
2496
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1951
2497
|
0 && (module.exports = {
|
|
1952
2498
|
CustomBreadcrumb,
|
|
1953
|
-
|
|
2499
|
+
Grid,
|
|
2500
|
+
Navbar,
|
|
2501
|
+
Pagination
|
|
1954
2502
|
});
|