baaz-custom-components 5.0.26 → 5.0.28
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 +117 -9
- package/dist/index.js +237 -212
- package/dist/index.mjs +233 -212
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1911,10 +1911,10 @@ var breadcrumb_default = CustomBreadcrumb;
|
|
|
1911
1911
|
// src/components/custom/grid/index.tsx
|
|
1912
1912
|
import {
|
|
1913
1913
|
useCallback as useCallback2,
|
|
1914
|
-
useRef as
|
|
1914
|
+
useRef as useRef3,
|
|
1915
1915
|
useImperativeHandle,
|
|
1916
1916
|
forwardRef,
|
|
1917
|
-
useEffect as
|
|
1917
|
+
useEffect as useEffect7
|
|
1918
1918
|
} from "react";
|
|
1919
1919
|
import { Grid as SvarGrid, WillowDark } from "@svar-ui/react-grid";
|
|
1920
1920
|
|
|
@@ -1948,80 +1948,29 @@ function exportExcel(rows, name) {
|
|
|
1948
1948
|
XLSX.writeFile(workbook, `${name != null ? name : "export"}.xlsx`);
|
|
1949
1949
|
}
|
|
1950
1950
|
|
|
1951
|
-
// src/components/custom/grid/gridHeader.tsx
|
|
1952
|
-
import { useEffect as
|
|
1951
|
+
// src/components/custom/grid/gridHeader/index.tsx
|
|
1952
|
+
import { useEffect as useEffect6, useRef as useRef2, useState as useState7 } from "react";
|
|
1953
1953
|
import {
|
|
1954
1954
|
FileText,
|
|
1955
1955
|
FileSpreadsheet,
|
|
1956
1956
|
Search,
|
|
1957
|
-
ListFilter,
|
|
1958
1957
|
Ellipsis,
|
|
1959
|
-
X as
|
|
1960
|
-
Plus,
|
|
1961
|
-
Trash2,
|
|
1962
|
-
Check
|
|
1958
|
+
X as X3
|
|
1963
1959
|
} from "lucide-react";
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
download,
|
|
1971
|
-
search,
|
|
1972
|
-
searchValue,
|
|
1973
|
-
searchkey = "",
|
|
1974
|
-
filterList,
|
|
1960
|
+
|
|
1961
|
+
// src/components/custom/grid/gridHeader/components/filters.tsx
|
|
1962
|
+
import { useEffect as useEffect5, useMemo as useMemo3, useRef, useState as useState6 } from "react";
|
|
1963
|
+
import { ListFilter, X as X2, Plus, Trash2, Check } from "lucide-react";
|
|
1964
|
+
import { Fragment as Fragment2, jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1965
|
+
var Filters = ({
|
|
1975
1966
|
onFilterChange,
|
|
1976
|
-
initialFilters = []
|
|
1967
|
+
initialFilters = [],
|
|
1968
|
+
filterList
|
|
1977
1969
|
}) => {
|
|
1978
|
-
const [downloadMenu, setDownloadMenu] = useState6(false);
|
|
1979
|
-
const [filterMenu, setFilterMenu] = useState6(false);
|
|
1980
|
-
const [searchOpen, setSearchOpen] = useState6(false);
|
|
1981
1970
|
const [conditions, setConditions] = useState6([]);
|
|
1982
|
-
const
|
|
1971
|
+
const [filterMenu, setFilterMenu] = useState6(false);
|
|
1983
1972
|
const filterRef = useRef(null);
|
|
1984
1973
|
const filterDropdownRef = useRef(null);
|
|
1985
|
-
useEffect5(() => {
|
|
1986
|
-
if (initialFilters && initialFilters.length > 0) {
|
|
1987
|
-
const initialConditions = initialFilters.map(
|
|
1988
|
-
(filter, index) => ({
|
|
1989
|
-
id: crypto.randomUUID(),
|
|
1990
|
-
column: filter.column,
|
|
1991
|
-
operator: filter.operator,
|
|
1992
|
-
value: filter.value,
|
|
1993
|
-
logic: index === 0 ? "WHERE" : filter.logic || "AND"
|
|
1994
|
-
})
|
|
1995
|
-
);
|
|
1996
|
-
setConditions(initialConditions);
|
|
1997
|
-
}
|
|
1998
|
-
}, []);
|
|
1999
|
-
useEffect5(() => {
|
|
2000
|
-
if (!filterMenu || !filterDropdownRef.current) return;
|
|
2001
|
-
const dropdown = filterDropdownRef.current;
|
|
2002
|
-
const rect = dropdown.getBoundingClientRect();
|
|
2003
|
-
if (rect.right > window.innerWidth) {
|
|
2004
|
-
dropdown.style.left = "auto";
|
|
2005
|
-
dropdown.style.right = "0";
|
|
2006
|
-
}
|
|
2007
|
-
if (rect.bottom > window.innerHeight) {
|
|
2008
|
-
dropdown.style.top = "auto";
|
|
2009
|
-
dropdown.style.bottom = "100%";
|
|
2010
|
-
dropdown.style.marginBottom = "8px";
|
|
2011
|
-
}
|
|
2012
|
-
}, [filterMenu]);
|
|
2013
|
-
useEffect5(() => {
|
|
2014
|
-
const handleClickOutside = (e) => {
|
|
2015
|
-
if (downloadRef.current && !downloadRef.current.contains(e.target)) {
|
|
2016
|
-
setDownloadMenu(false);
|
|
2017
|
-
}
|
|
2018
|
-
if (filterRef.current && !filterRef.current.contains(e.target)) {
|
|
2019
|
-
setFilterMenu(false);
|
|
2020
|
-
}
|
|
2021
|
-
};
|
|
2022
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
2023
|
-
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2024
|
-
}, []);
|
|
2025
1974
|
const isValidFilter = (condition) => {
|
|
2026
1975
|
if (!condition.column || !condition.operator) return false;
|
|
2027
1976
|
if (condition.operator === "date-range") {
|
|
@@ -2099,60 +2048,90 @@ var GridHeader = ({
|
|
|
2099
2048
|
action: "clear"
|
|
2100
2049
|
});
|
|
2101
2050
|
};
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2051
|
+
useEffect5(() => {
|
|
2052
|
+
if (initialFilters && initialFilters.length > 0) {
|
|
2053
|
+
const initialConditions = initialFilters.map(
|
|
2054
|
+
(filter, index) => ({
|
|
2055
|
+
id: crypto.randomUUID(),
|
|
2056
|
+
column: filter.column,
|
|
2057
|
+
operator: filter.operator,
|
|
2058
|
+
value: filter.value,
|
|
2059
|
+
logic: index === 0 ? "WHERE" : filter.logic || "AND"
|
|
2060
|
+
})
|
|
2061
|
+
);
|
|
2062
|
+
setConditions(initialConditions);
|
|
2063
|
+
}
|
|
2064
|
+
}, []);
|
|
2065
|
+
useEffect5(() => {
|
|
2066
|
+
const handleClickOutside = (e) => {
|
|
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__ */ jsxs17("div", { className: "relative", ref: filterRef, children: [
|
|
2075
|
+
/* @__PURE__ */ jsxs17(
|
|
2076
|
+
"button",
|
|
2077
|
+
{
|
|
2078
|
+
onClick: () => setFilterMenu((p) => !p),
|
|
2079
|
+
className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-input text-sm cursor-pointer",
|
|
2080
|
+
children: [
|
|
2081
|
+
/* @__PURE__ */ jsx23(ListFilter, { size: 16 }),
|
|
2082
|
+
/* @__PURE__ */ jsx23("span", { className: "hidden md:block", children: "Filters" }),
|
|
2083
|
+
activeFilterCount > 0 && /* @__PURE__ */ jsx23("span", { className: "ml-1 px-1.5 py-0.5 text-xs bg-primary text-primary-foreground rounded-full font-medium", children: activeFilterCount })
|
|
2084
|
+
]
|
|
2085
|
+
}
|
|
2086
|
+
),
|
|
2087
|
+
filterMenu && /* @__PURE__ */ jsxs17(Fragment2, { children: [
|
|
2088
|
+
/* @__PURE__ */ jsx23(
|
|
2089
|
+
"div",
|
|
2090
|
+
{
|
|
2091
|
+
className: "fixed inset-0 bg-black/40 z-40 md:hidden",
|
|
2092
|
+
onClick: () => setFilterMenu(false)
|
|
2093
|
+
}
|
|
2094
|
+
),
|
|
2095
|
+
/* @__PURE__ */ jsxs17(
|
|
2096
|
+
"div",
|
|
2097
|
+
{
|
|
2098
|
+
ref: filterDropdownRef,
|
|
2099
|
+
className: "fixed inset-x-0 bottom-0 md:absolute md:top-full md:bottom-auto md:left-0 w-full md:w-[700px] md:max-w-[95vw] max-h-[85vh] overflow-y-auto p-4 rounded-t-2xl md:rounded-md border bg-background shadow-xl z-50 space-y-4",
|
|
2100
|
+
children: [
|
|
2101
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-start sm:items-center justify-between gap-2", children: [
|
|
2102
|
+
/* @__PURE__ */ jsx23("span", { className: "text-sm font-medium", children: "In this view, show records" }),
|
|
2103
|
+
/* @__PURE__ */ jsx23(
|
|
2104
|
+
"button",
|
|
2105
|
+
{
|
|
2106
|
+
onClick: clearFilters,
|
|
2107
|
+
className: "p-2 rounded-md hover:bg-destructive/30 cursor-pointer",
|
|
2108
|
+
title: "Clear all filters",
|
|
2109
|
+
children: /* @__PURE__ */ jsx23(X2, { size: 16 })
|
|
2110
|
+
}
|
|
2111
|
+
)
|
|
2112
|
+
] }),
|
|
2113
|
+
/* @__PURE__ */ jsx23("div", { className: "space-y-3 w-full flex flex-col overflow-auto", children: conditions.map((condition, index) => {
|
|
2114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2115
|
+
const selectedColumn = filterList.find(
|
|
2116
|
+
(f) => f.columnName.value === condition.column
|
|
2117
|
+
);
|
|
2118
|
+
const selectedOperator = selectedColumn == null ? void 0 : selectedColumn.operators.find(
|
|
2119
|
+
(op) => op.value === condition.operator
|
|
2120
|
+
);
|
|
2121
|
+
return /* @__PURE__ */ jsxs17(
|
|
2122
|
+
"div",
|
|
2123
|
+
{
|
|
2124
|
+
className: "flex flex-col md:flex-row gap-3 md:gap-2 w-full",
|
|
2125
|
+
children: [
|
|
2126
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex flex-col sm:flex-row gap-2 w-full", children: [
|
|
2127
|
+
/* @__PURE__ */ jsx23("div", { className: "w-full sm:w-[90px] shrink-0", children: index === 0 ? /* @__PURE__ */ jsx23("span", { className: "text-sm font-medium", children: "Where" }) : /* @__PURE__ */ jsxs17(
|
|
2149
2128
|
"select",
|
|
2150
2129
|
{
|
|
2151
2130
|
value: (_a = condition.logic) != null ? _a : "AND",
|
|
2152
2131
|
onChange: (e) => updateCondition(condition.id, {
|
|
2153
2132
|
logic: e.target.value
|
|
2154
2133
|
}),
|
|
2155
|
-
className: "w-full px-
|
|
2134
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none",
|
|
2156
2135
|
children: [
|
|
2157
2136
|
/* @__PURE__ */ jsx23("option", { value: "AND", children: "AND" }),
|
|
2158
2137
|
/* @__PURE__ */ jsx23("option", { value: "OR", children: "OR" })
|
|
@@ -2168,7 +2147,7 @@ var GridHeader = ({
|
|
|
2168
2147
|
operator: void 0,
|
|
2169
2148
|
value: void 0
|
|
2170
2149
|
}),
|
|
2171
|
-
className: "
|
|
2150
|
+
className: "w-full sm:min-w-[8rem] px-3 py-2 rounded-md bg-input text-sm focus:outline-none",
|
|
2172
2151
|
children: [
|
|
2173
2152
|
/* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Column" }),
|
|
2174
2153
|
filterList.map((f) => /* @__PURE__ */ jsx23(
|
|
@@ -2191,7 +2170,7 @@ var GridHeader = ({
|
|
|
2191
2170
|
operator: e.target.value,
|
|
2192
2171
|
value: void 0
|
|
2193
2172
|
}),
|
|
2194
|
-
className: "
|
|
2173
|
+
className: "w-full sm:min-w-[8rem] px-3 py-2 rounded-md bg-input text-sm disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none",
|
|
2195
2174
|
children: [
|
|
2196
2175
|
/* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Operator" }),
|
|
2197
2176
|
selectedColumn == null ? void 0 : selectedColumn.operators.map((op) => {
|
|
@@ -2200,8 +2179,10 @@ var GridHeader = ({
|
|
|
2200
2179
|
})
|
|
2201
2180
|
]
|
|
2202
2181
|
}
|
|
2203
|
-
)
|
|
2204
|
-
|
|
2182
|
+
)
|
|
2183
|
+
] }),
|
|
2184
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex flex-col sm:flex-row gap-2 w-full items-start sm:items-center", children: [
|
|
2185
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-1 w-full min-w-0", children: [
|
|
2205
2186
|
(selectedOperator == null ? void 0 : selectedOperator.value) === "input" && /* @__PURE__ */ jsx23(
|
|
2206
2187
|
"input",
|
|
2207
2188
|
{
|
|
@@ -2210,7 +2191,7 @@ var GridHeader = ({
|
|
|
2210
2191
|
value: e.target.value
|
|
2211
2192
|
}),
|
|
2212
2193
|
placeholder: "Enter value",
|
|
2213
|
-
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2194
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none"
|
|
2214
2195
|
}
|
|
2215
2196
|
),
|
|
2216
2197
|
(selectedOperator == null ? void 0 : selectedOperator.value) === "select" && /* @__PURE__ */ jsxs17(
|
|
@@ -2220,7 +2201,7 @@ var GridHeader = ({
|
|
|
2220
2201
|
onChange: (e) => updateCondition(condition.id, {
|
|
2221
2202
|
value: e.target.value
|
|
2222
2203
|
}),
|
|
2223
|
-
className: "w-full px-3 py-2 rounded-md bg-input text-sm",
|
|
2204
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none",
|
|
2224
2205
|
children: [
|
|
2225
2206
|
/* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Select value" }),
|
|
2226
2207
|
(_f = selectedOperator.options) == null ? void 0 : _f.map((opt) => /* @__PURE__ */ jsx23("option", { value: opt.value, children: opt.label }, opt.value))
|
|
@@ -2235,10 +2216,10 @@ var GridHeader = ({
|
|
|
2235
2216
|
onChange: (e) => updateCondition(condition.id, {
|
|
2236
2217
|
value: e.target.value
|
|
2237
2218
|
}),
|
|
2238
|
-
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2219
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none"
|
|
2239
2220
|
}
|
|
2240
2221
|
),
|
|
2241
|
-
(selectedOperator == null ? void 0 : selectedOperator.value) === "date-range" && /* @__PURE__ */ jsxs17("div", { className: "flex gap-2", children: [
|
|
2222
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "date-range" && /* @__PURE__ */ jsxs17("div", { className: "flex flex-col sm:flex-row gap-2 w-full", children: [
|
|
2242
2223
|
/* @__PURE__ */ jsx23(
|
|
2243
2224
|
"input",
|
|
2244
2225
|
{
|
|
@@ -2249,8 +2230,7 @@ var GridHeader = ({
|
|
|
2249
2230
|
start: e.target.value
|
|
2250
2231
|
})
|
|
2251
2232
|
}),
|
|
2252
|
-
|
|
2253
|
-
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2233
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none"
|
|
2254
2234
|
}
|
|
2255
2235
|
),
|
|
2256
2236
|
/* @__PURE__ */ jsx23(
|
|
@@ -2263,14 +2243,13 @@ var GridHeader = ({
|
|
|
2263
2243
|
end: e.target.value
|
|
2264
2244
|
})
|
|
2265
2245
|
}),
|
|
2266
|
-
|
|
2267
|
-
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2246
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none"
|
|
2268
2247
|
}
|
|
2269
2248
|
)
|
|
2270
2249
|
] }),
|
|
2271
2250
|
!selectedOperator && /* @__PURE__ */ jsx23("div", { className: "w-full px-3 py-2 rounded-md bg-input/50 text-sm text-muted-foreground", children: "Select operator" })
|
|
2272
2251
|
] }),
|
|
2273
|
-
/* @__PURE__ */ jsx23("div", { className: "w-[40px] flex justify-
|
|
2252
|
+
/* @__PURE__ */ jsx23("div", { className: "w-full sm:w-[40px] flex justify-end sm:justify-center", children: /* @__PURE__ */ jsx23(
|
|
2274
2253
|
"button",
|
|
2275
2254
|
{
|
|
2276
2255
|
onClick: () => deleteCondition(condition.id),
|
|
@@ -2279,58 +2258,100 @@ var GridHeader = ({
|
|
|
2279
2258
|
children: /* @__PURE__ */ jsx23(Trash2, { size: 16 })
|
|
2280
2259
|
}
|
|
2281
2260
|
) })
|
|
2282
|
-
]
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
]
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2261
|
+
] })
|
|
2262
|
+
]
|
|
2263
|
+
},
|
|
2264
|
+
condition.id
|
|
2265
|
+
);
|
|
2266
|
+
}) }),
|
|
2267
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between pt-2 border-t", children: [
|
|
2268
|
+
/* @__PURE__ */ jsxs17(
|
|
2269
|
+
"button",
|
|
2270
|
+
{
|
|
2271
|
+
onClick: addCondition,
|
|
2272
|
+
className: "flex items-center gap-2 text-sm text-primary hover:text-primary/80 cursor-pointer",
|
|
2273
|
+
children: [
|
|
2274
|
+
/* @__PURE__ */ jsx23(Plus, { size: 14 }),
|
|
2275
|
+
"Add condition"
|
|
2276
|
+
]
|
|
2277
|
+
}
|
|
2278
|
+
),
|
|
2279
|
+
/* @__PURE__ */ jsxs17(
|
|
2280
|
+
"button",
|
|
2281
|
+
{
|
|
2282
|
+
onClick: applyFilters,
|
|
2283
|
+
disabled: !canApply,
|
|
2284
|
+
className: "flex items-center gap-2 px-4 py-2 rounded-md bg-primary text-primary-foreground text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed hover:bg-primary/90 transition-colors cursor-pointer",
|
|
2285
|
+
children: [
|
|
2286
|
+
/* @__PURE__ */ jsx23(Check, { size: 16 }),
|
|
2287
|
+
"Apply",
|
|
2288
|
+
hasChangesFromInitial && canApply && /* @__PURE__ */ jsx23(
|
|
2289
|
+
"span",
|
|
2290
|
+
{
|
|
2291
|
+
className: "ml-1 w-2 h-2 bg-yellow-400 rounded-full",
|
|
2292
|
+
title: "Unapplied changes"
|
|
2293
|
+
}
|
|
2294
|
+
)
|
|
2295
|
+
]
|
|
2296
|
+
}
|
|
2297
|
+
)
|
|
2298
|
+
] })
|
|
2299
|
+
]
|
|
2300
|
+
}
|
|
2301
|
+
)
|
|
2302
|
+
] })
|
|
2303
|
+
] });
|
|
2304
|
+
};
|
|
2305
|
+
var filters_default = Filters;
|
|
2306
|
+
|
|
2307
|
+
// src/components/custom/grid/gridHeader/index.tsx
|
|
2308
|
+
import { jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2309
|
+
var GridHeader = ({
|
|
2310
|
+
onPdf,
|
|
2311
|
+
onExcel,
|
|
2312
|
+
onSearch = () => {
|
|
2313
|
+
},
|
|
2314
|
+
download,
|
|
2315
|
+
search,
|
|
2316
|
+
searchValue,
|
|
2317
|
+
searchkey = "",
|
|
2318
|
+
filterList,
|
|
2319
|
+
onFilterChange,
|
|
2320
|
+
initialFilters = []
|
|
2321
|
+
}) => {
|
|
2322
|
+
const [downloadMenu, setDownloadMenu] = useState7(false);
|
|
2323
|
+
const [searchOpen, setSearchOpen] = useState7(false);
|
|
2324
|
+
const downloadRef = useRef2(null);
|
|
2325
|
+
useEffect6(() => {
|
|
2326
|
+
const handleClickOutside = (e) => {
|
|
2327
|
+
if (downloadRef.current && !downloadRef.current.contains(e.target)) {
|
|
2328
|
+
setDownloadMenu(false);
|
|
2329
|
+
}
|
|
2330
|
+
};
|
|
2331
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2332
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2333
|
+
}, []);
|
|
2334
|
+
return /* @__PURE__ */ jsxs18("div", { className: "flex flex-col md:flex-row md:items-center justify-between bg-card py-2 px-2 md:px-4 rounded-tl-md rounded-tr-md", children: [
|
|
2335
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex justify-between items-center gap-3", children: [
|
|
2336
|
+
/* @__PURE__ */ jsx24(
|
|
2337
|
+
filters_default,
|
|
2338
|
+
{
|
|
2339
|
+
onFilterChange,
|
|
2340
|
+
initialFilters,
|
|
2341
|
+
filterList
|
|
2342
|
+
}
|
|
2343
|
+
),
|
|
2344
|
+
download && /* @__PURE__ */ jsxs18("div", { className: "relative", ref: downloadRef, children: [
|
|
2345
|
+
/* @__PURE__ */ jsx24(
|
|
2325
2346
|
"button",
|
|
2326
2347
|
{
|
|
2327
2348
|
onClick: () => setDownloadMenu((p) => !p),
|
|
2328
2349
|
className: "p-2 rounded-md hover:bg-input cursor-pointer",
|
|
2329
|
-
children: /* @__PURE__ */
|
|
2350
|
+
children: /* @__PURE__ */ jsx24(Ellipsis, { size: 16 })
|
|
2330
2351
|
}
|
|
2331
2352
|
),
|
|
2332
|
-
downloadMenu && /* @__PURE__ */
|
|
2333
|
-
/* @__PURE__ */
|
|
2353
|
+
downloadMenu && /* @__PURE__ */ jsxs18("div", { className: "absolute top-full right-0 mt-2 w-32 rounded-md border !bg-background shadow-lg z-50 overflow-hidden", children: [
|
|
2354
|
+
/* @__PURE__ */ jsxs18(
|
|
2334
2355
|
"button",
|
|
2335
2356
|
{
|
|
2336
2357
|
onClick: () => {
|
|
@@ -2339,12 +2360,12 @@ var GridHeader = ({
|
|
|
2339
2360
|
},
|
|
2340
2361
|
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2341
2362
|
children: [
|
|
2342
|
-
/* @__PURE__ */
|
|
2363
|
+
/* @__PURE__ */ jsx24(FileText, { size: 14 }),
|
|
2343
2364
|
"PDF"
|
|
2344
2365
|
]
|
|
2345
2366
|
}
|
|
2346
2367
|
),
|
|
2347
|
-
/* @__PURE__ */
|
|
2368
|
+
/* @__PURE__ */ jsxs18(
|
|
2348
2369
|
"button",
|
|
2349
2370
|
{
|
|
2350
2371
|
onClick: () => {
|
|
@@ -2353,7 +2374,7 @@ var GridHeader = ({
|
|
|
2353
2374
|
},
|
|
2354
2375
|
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2355
2376
|
children: [
|
|
2356
|
-
/* @__PURE__ */
|
|
2377
|
+
/* @__PURE__ */ jsx24(FileSpreadsheet, { size: 14 }),
|
|
2357
2378
|
"Excel"
|
|
2358
2379
|
]
|
|
2359
2380
|
}
|
|
@@ -2361,20 +2382,20 @@ var GridHeader = ({
|
|
|
2361
2382
|
] })
|
|
2362
2383
|
] })
|
|
2363
2384
|
] }),
|
|
2364
|
-
search && /* @__PURE__ */
|
|
2385
|
+
search && /* @__PURE__ */ jsx24("div", { className: "relative h-[40px] flex items-center", children: /* @__PURE__ */ jsx24(
|
|
2365
2386
|
"div",
|
|
2366
2387
|
{
|
|
2367
|
-
className: `absolute right-0 flex items-center transition-all duration-200 ${searchOpen ? "w-[250px]" : "w-[40px]"} h-[40px]`,
|
|
2368
|
-
children: !searchOpen ? /* @__PURE__ */
|
|
2388
|
+
className: `absolute left-0 md:right-0 flex items-center transition-all duration-200 ${searchOpen ? "w-[250px]" : "w-[40px]"} h-[40px]`,
|
|
2389
|
+
children: !searchOpen ? /* @__PURE__ */ jsx24(
|
|
2369
2390
|
"button",
|
|
2370
2391
|
{
|
|
2371
2392
|
onClick: () => setSearchOpen(true),
|
|
2372
2393
|
className: "w-[40px] h-[40px] flex items-center justify-center rounded-md hover:bg-input cursor-pointer",
|
|
2373
|
-
children: /* @__PURE__ */
|
|
2394
|
+
children: /* @__PURE__ */ jsx24(Search, { size: 18 })
|
|
2374
2395
|
}
|
|
2375
|
-
) : /* @__PURE__ */
|
|
2376
|
-
/* @__PURE__ */
|
|
2377
|
-
/* @__PURE__ */
|
|
2396
|
+
) : /* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2 w-full h-full px-3 rounded-md border border-input bg-background", children: [
|
|
2397
|
+
/* @__PURE__ */ jsx24(Search, { size: 16 }),
|
|
2398
|
+
/* @__PURE__ */ jsx24(
|
|
2378
2399
|
"input",
|
|
2379
2400
|
{
|
|
2380
2401
|
autoFocus: true,
|
|
@@ -2384,12 +2405,12 @@ var GridHeader = ({
|
|
|
2384
2405
|
value: searchValue
|
|
2385
2406
|
}
|
|
2386
2407
|
),
|
|
2387
|
-
/* @__PURE__ */
|
|
2408
|
+
/* @__PURE__ */ jsx24(
|
|
2388
2409
|
"button",
|
|
2389
2410
|
{
|
|
2390
2411
|
onClick: () => setSearchOpen(false),
|
|
2391
2412
|
className: "cursor-pointer",
|
|
2392
|
-
children: /* @__PURE__ */
|
|
2413
|
+
children: /* @__PURE__ */ jsx24(X3, { size: 16 })
|
|
2393
2414
|
}
|
|
2394
2415
|
)
|
|
2395
2416
|
] })
|
|
@@ -2400,7 +2421,7 @@ var GridHeader = ({
|
|
|
2400
2421
|
var gridHeader_default = GridHeader;
|
|
2401
2422
|
|
|
2402
2423
|
// src/components/custom/grid/index.tsx
|
|
2403
|
-
import { jsx as
|
|
2424
|
+
import { jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2404
2425
|
var Grid = forwardRef(
|
|
2405
2426
|
(_a, ref) => {
|
|
2406
2427
|
var _b = _a, {
|
|
@@ -2430,8 +2451,8 @@ var Grid = forwardRef(
|
|
|
2430
2451
|
"onFilterChange",
|
|
2431
2452
|
"initialFilters"
|
|
2432
2453
|
]);
|
|
2433
|
-
const apiRef =
|
|
2434
|
-
const containerRef =
|
|
2454
|
+
const apiRef = useRef3(null);
|
|
2455
|
+
const containerRef = useRef3(null);
|
|
2435
2456
|
useImperativeHandle(ref, () => apiRef.current, []);
|
|
2436
2457
|
const resizeColumns = useCallback2(() => {
|
|
2437
2458
|
var _a2;
|
|
@@ -2463,7 +2484,7 @@ var Grid = forwardRef(
|
|
|
2463
2484
|
});
|
|
2464
2485
|
}
|
|
2465
2486
|
}, [columns, data]);
|
|
2466
|
-
|
|
2487
|
+
useEffect7(() => {
|
|
2467
2488
|
if (!containerRef.current) return;
|
|
2468
2489
|
const observer = new ResizeObserver(() => {
|
|
2469
2490
|
resizeColumns();
|
|
@@ -2502,8 +2523,8 @@ var Grid = forwardRef(
|
|
|
2502
2523
|
onExportExcel == null ? void 0 : onExportExcel();
|
|
2503
2524
|
}
|
|
2504
2525
|
}, [getSelectedData, exportExcel, onExportExcel, fileName]);
|
|
2505
|
-
return /* @__PURE__ */
|
|
2506
|
-
/* @__PURE__ */
|
|
2526
|
+
return /* @__PURE__ */ jsxs19("div", { className: "w-full h-full flex flex-col overflow-hidden", children: [
|
|
2527
|
+
/* @__PURE__ */ jsx25(
|
|
2507
2528
|
gridHeader_default,
|
|
2508
2529
|
{
|
|
2509
2530
|
onPdf: handleExportPdf,
|
|
@@ -2518,7 +2539,7 @@ var Grid = forwardRef(
|
|
|
2518
2539
|
initialFilters
|
|
2519
2540
|
}
|
|
2520
2541
|
),
|
|
2521
|
-
/* @__PURE__ */
|
|
2542
|
+
/* @__PURE__ */ jsx25("div", { className: "flex-1 w-full overflow-hidden", ref: containerRef, children: /* @__PURE__ */ jsx25(WillowDark, { fonts, children: /* @__PURE__ */ jsx25("div", { className: "w-full h-full relative", children: rest.loading ? /* @__PURE__ */ jsx25("div", { className: "absolute inset-0 bg-background/60 backdrop-blur-sm flex items-center justify-center z-10", children: /* @__PURE__ */ jsx25("div", { className: "animate-spin rounded-full h-8 w-8 border-2 border-primary border-t-transparent" }) }) : /* @__PURE__ */ jsx25(
|
|
2522
2543
|
SvarGrid,
|
|
2523
2544
|
__spreadProps(__spreadValues({}, rest), {
|
|
2524
2545
|
data,
|
|
@@ -2534,9 +2555,9 @@ var grid_default = Grid;
|
|
|
2534
2555
|
|
|
2535
2556
|
// src/components/custom/grid/sortableHeaderCell.tsx
|
|
2536
2557
|
import { MoveDown, MoveUp, ArrowUpDown } from "lucide-react";
|
|
2537
|
-
import { jsx as
|
|
2558
|
+
import { jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2538
2559
|
function SortableHeaderCell({ cell, sortKey, sortOrder, onSortChange }) {
|
|
2539
|
-
if (!(cell == null ? void 0 : cell.id)) return /* @__PURE__ */
|
|
2560
|
+
if (!(cell == null ? void 0 : cell.id)) return /* @__PURE__ */ jsx26("span", { children: cell == null ? void 0 : cell.text });
|
|
2540
2561
|
const active = sortKey === cell.id;
|
|
2541
2562
|
const handleClick = () => {
|
|
2542
2563
|
if (!onSortChange || !cell.id) return;
|
|
@@ -2550,15 +2571,15 @@ function SortableHeaderCell({ cell, sortKey, sortOrder, onSortChange }) {
|
|
|
2550
2571
|
}
|
|
2551
2572
|
onSortChange("", null);
|
|
2552
2573
|
};
|
|
2553
|
-
return /* @__PURE__ */
|
|
2574
|
+
return /* @__PURE__ */ jsxs20(
|
|
2554
2575
|
"div",
|
|
2555
2576
|
{
|
|
2556
2577
|
onClick: handleClick,
|
|
2557
2578
|
className: "cursor-pointer flex items-center gap-2 justify-between select-none",
|
|
2558
2579
|
children: [
|
|
2559
|
-
/* @__PURE__ */
|
|
2560
|
-
!active && /* @__PURE__ */
|
|
2561
|
-
active && (sortOrder === "asc" ? /* @__PURE__ */
|
|
2580
|
+
/* @__PURE__ */ jsx26("span", { children: cell.text }),
|
|
2581
|
+
!active && /* @__PURE__ */ jsx26(ArrowUpDown, { className: "w-4 h-4 opacity-50" }),
|
|
2582
|
+
active && (sortOrder === "asc" ? /* @__PURE__ */ jsx26(MoveDown, { className: "w-4 h-4" }) : /* @__PURE__ */ jsx26(MoveUp, { className: "w-4 h-4" }))
|
|
2562
2583
|
]
|
|
2563
2584
|
}
|
|
2564
2585
|
);
|
|
@@ -2597,7 +2618,7 @@ function getPaginationRange(currentPage, totalPages, siblingCount = 2) {
|
|
|
2597
2618
|
|
|
2598
2619
|
// src/components/custom/pagination/index.tsx
|
|
2599
2620
|
import { ChevronLeft, ChevronRight as ChevronRight3 } from "lucide-react";
|
|
2600
|
-
import { jsx as
|
|
2621
|
+
import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2601
2622
|
function Pagination({
|
|
2602
2623
|
totalCount,
|
|
2603
2624
|
count = null,
|
|
@@ -2618,47 +2639,47 @@ function Pagination({
|
|
|
2618
2639
|
const handlePageSizeChange = (size) => {
|
|
2619
2640
|
onPageSizeChange == null ? void 0 : onPageSizeChange(size);
|
|
2620
2641
|
};
|
|
2621
|
-
return /* @__PURE__ */
|
|
2622
|
-
/* @__PURE__ */
|
|
2623
|
-
/* @__PURE__ */
|
|
2642
|
+
return /* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between bg-card px-3 py-2 rounded-br-md rounded-bl-md", children: [
|
|
2643
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-3 text-xs text-muted-foreground tracking-wider font-medium", children: [
|
|
2644
|
+
/* @__PURE__ */ jsxs21("span", { children: [
|
|
2624
2645
|
"Showing ",
|
|
2625
|
-
/* @__PURE__ */
|
|
2646
|
+
/* @__PURE__ */ jsx27("span", { className: "text-foreground", children: count }),
|
|
2626
2647
|
" of",
|
|
2627
2648
|
" ",
|
|
2628
|
-
/* @__PURE__ */
|
|
2649
|
+
/* @__PURE__ */ jsx27("span", { className: "text-foreground", children: totalCount })
|
|
2629
2650
|
] }),
|
|
2630
|
-
showSizeChanger && /* @__PURE__ */
|
|
2651
|
+
showSizeChanger && /* @__PURE__ */ jsx27(
|
|
2631
2652
|
"select",
|
|
2632
2653
|
{
|
|
2633
2654
|
value: pageSize,
|
|
2634
2655
|
onChange: (e) => handlePageSizeChange(Number(e.target.value)),
|
|
2635
2656
|
className: "rounded-md border border-input bg-background px-3 py-2 text-xs text-foreground focus:outline-none",
|
|
2636
|
-
children: sizeChangerOptions.map((size) => /* @__PURE__ */
|
|
2657
|
+
children: sizeChangerOptions.map((size) => /* @__PURE__ */ jsxs21("option", { value: size, children: [
|
|
2637
2658
|
size,
|
|
2638
2659
|
" / page"
|
|
2639
2660
|
] }, size))
|
|
2640
2661
|
}
|
|
2641
2662
|
)
|
|
2642
2663
|
] }),
|
|
2643
|
-
/* @__PURE__ */
|
|
2644
|
-
/* @__PURE__ */
|
|
2664
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-1", children: [
|
|
2665
|
+
/* @__PURE__ */ jsx27(
|
|
2645
2666
|
"button",
|
|
2646
2667
|
{
|
|
2647
2668
|
disabled: currentPage === 1,
|
|
2648
2669
|
onClick: () => handlePageChange(currentPage - 1),
|
|
2649
2670
|
className: "border border-border w-8 h-8 rounded-md flex items-center justify-center disabled:opacity-40 hover:bg-card-foreground transition",
|
|
2650
|
-
children: /* @__PURE__ */
|
|
2671
|
+
children: /* @__PURE__ */ jsx27(ChevronLeft, { className: "w-5 h-5 select-none" })
|
|
2651
2672
|
}
|
|
2652
2673
|
),
|
|
2653
2674
|
pages.map(
|
|
2654
|
-
(page, idx) => page === "dots" ? /* @__PURE__ */
|
|
2675
|
+
(page, idx) => page === "dots" ? /* @__PURE__ */ jsx27(
|
|
2655
2676
|
"span",
|
|
2656
2677
|
{
|
|
2657
2678
|
className: "px-2 text-muted-foreground text-xs tracking-wider font-medium",
|
|
2658
2679
|
children: "\u2026"
|
|
2659
2680
|
},
|
|
2660
2681
|
`dots-${idx}`
|
|
2661
|
-
) : /* @__PURE__ */
|
|
2682
|
+
) : /* @__PURE__ */ jsx27(
|
|
2662
2683
|
"button",
|
|
2663
2684
|
{
|
|
2664
2685
|
onClick: () => handlePageChange(page),
|
|
@@ -2668,13 +2689,13 @@ function Pagination({
|
|
|
2668
2689
|
page
|
|
2669
2690
|
)
|
|
2670
2691
|
),
|
|
2671
|
-
/* @__PURE__ */
|
|
2692
|
+
/* @__PURE__ */ jsx27(
|
|
2672
2693
|
"button",
|
|
2673
2694
|
{
|
|
2674
2695
|
disabled: currentPage === totalPages,
|
|
2675
2696
|
onClick: () => handlePageChange(currentPage + 1),
|
|
2676
2697
|
className: "border border-border w-8 h-8 rounded-md flex items-center justify-center disabled:opacity-40 hover:bg-card-foreground transition",
|
|
2677
|
-
children: /* @__PURE__ */
|
|
2698
|
+
children: /* @__PURE__ */ jsx27(ChevronRight3, { className: "w-5 h-5 select-none" })
|
|
2678
2699
|
}
|
|
2679
2700
|
)
|
|
2680
2701
|
] })
|