baaz-custom-components 5.0.23 → 5.0.26
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 +35 -0
- package/dist/index.d.mts +18 -6
- package/dist/index.d.ts +18 -6
- package/dist/index.js +226 -55
- package/dist/index.mjs +236 -58
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1909,7 +1909,13 @@ var CustomBreadcrumb = ({
|
|
|
1909
1909
|
var breadcrumb_default = CustomBreadcrumb;
|
|
1910
1910
|
|
|
1911
1911
|
// src/components/custom/grid/index.tsx
|
|
1912
|
-
import {
|
|
1912
|
+
import {
|
|
1913
|
+
useCallback as useCallback2,
|
|
1914
|
+
useRef as useRef2,
|
|
1915
|
+
useImperativeHandle,
|
|
1916
|
+
forwardRef,
|
|
1917
|
+
useEffect as useEffect6
|
|
1918
|
+
} from "react";
|
|
1913
1919
|
import { Grid as SvarGrid, WillowDark } from "@svar-ui/react-grid";
|
|
1914
1920
|
|
|
1915
1921
|
// src/utils/exportPdf.ts
|
|
@@ -1943,7 +1949,7 @@ function exportExcel(rows, name) {
|
|
|
1943
1949
|
}
|
|
1944
1950
|
|
|
1945
1951
|
// src/components/custom/grid/gridHeader.tsx
|
|
1946
|
-
import { useEffect as useEffect5, useRef, useState as useState6 } from "react";
|
|
1952
|
+
import { useEffect as useEffect5, useRef, useState as useState6, useMemo as useMemo3 } from "react";
|
|
1947
1953
|
import {
|
|
1948
1954
|
FileText,
|
|
1949
1955
|
FileSpreadsheet,
|
|
@@ -1952,7 +1958,8 @@ import {
|
|
|
1952
1958
|
Ellipsis,
|
|
1953
1959
|
X as X2,
|
|
1954
1960
|
Plus,
|
|
1955
|
-
Trash2
|
|
1961
|
+
Trash2,
|
|
1962
|
+
Check
|
|
1956
1963
|
} from "lucide-react";
|
|
1957
1964
|
import { jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1958
1965
|
var GridHeader = ({
|
|
@@ -1965,7 +1972,8 @@ var GridHeader = ({
|
|
|
1965
1972
|
searchValue,
|
|
1966
1973
|
searchkey = "",
|
|
1967
1974
|
filterList,
|
|
1968
|
-
onFilterChange
|
|
1975
|
+
onFilterChange,
|
|
1976
|
+
initialFilters = []
|
|
1969
1977
|
}) => {
|
|
1970
1978
|
const [downloadMenu, setDownloadMenu] = useState6(false);
|
|
1971
1979
|
const [filterMenu, setFilterMenu] = useState6(false);
|
|
@@ -1974,17 +1982,29 @@ var GridHeader = ({
|
|
|
1974
1982
|
const downloadRef = useRef(null);
|
|
1975
1983
|
const filterRef = useRef(null);
|
|
1976
1984
|
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
|
+
}, []);
|
|
1977
1999
|
useEffect5(() => {
|
|
1978
2000
|
if (!filterMenu || !filterDropdownRef.current) return;
|
|
1979
2001
|
const dropdown = filterDropdownRef.current;
|
|
1980
2002
|
const rect = dropdown.getBoundingClientRect();
|
|
1981
|
-
|
|
1982
|
-
const overflowBottom = rect.bottom > window.innerHeight;
|
|
1983
|
-
if (overflowRight) {
|
|
2003
|
+
if (rect.right > window.innerWidth) {
|
|
1984
2004
|
dropdown.style.left = "auto";
|
|
1985
2005
|
dropdown.style.right = "0";
|
|
1986
2006
|
}
|
|
1987
|
-
if (
|
|
2007
|
+
if (rect.bottom > window.innerHeight) {
|
|
1988
2008
|
dropdown.style.top = "auto";
|
|
1989
2009
|
dropdown.style.bottom = "100%";
|
|
1990
2010
|
dropdown.style.marginBottom = "8px";
|
|
@@ -2002,17 +2022,44 @@ var GridHeader = ({
|
|
|
2002
2022
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2003
2023
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2004
2024
|
}, []);
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2025
|
+
const isValidFilter = (condition) => {
|
|
2026
|
+
if (!condition.column || !condition.operator) return false;
|
|
2027
|
+
if (condition.operator === "date-range") {
|
|
2028
|
+
const rangeValue = condition.value;
|
|
2029
|
+
return !!((rangeValue == null ? void 0 : rangeValue.start) && (rangeValue == null ? void 0 : rangeValue.end));
|
|
2030
|
+
}
|
|
2031
|
+
return condition.value !== void 0 && condition.value !== "";
|
|
2032
|
+
};
|
|
2033
|
+
const allFiltersValid = useMemo3(() => {
|
|
2034
|
+
if (conditions.length === 0) return false;
|
|
2035
|
+
return conditions.every(isValidFilter);
|
|
2009
2036
|
}, [conditions]);
|
|
2037
|
+
const activeFilterCount = (initialFilters == null ? void 0 : initialFilters.length) || 0;
|
|
2038
|
+
const formatFiltersForApi = (conditions2) => {
|
|
2039
|
+
return conditions2.filter(isValidFilter).map(({ column, operator, value, logic }, index) => ({
|
|
2040
|
+
column,
|
|
2041
|
+
operator,
|
|
2042
|
+
value,
|
|
2043
|
+
logic: index === 0 ? "WHERE" : logic != null ? logic : "AND"
|
|
2044
|
+
}));
|
|
2045
|
+
};
|
|
2046
|
+
const hasChangesFromInitial = useMemo3(() => {
|
|
2047
|
+
if (conditions.length === 0 && activeFilterCount === 0) return false;
|
|
2048
|
+
if (conditions.length !== activeFilterCount) return true;
|
|
2049
|
+
const formatted = formatFiltersForApi(conditions);
|
|
2050
|
+
const initialFormatted = initialFilters || [];
|
|
2051
|
+
if (formatted.length !== initialFormatted.length) return true;
|
|
2052
|
+
return JSON.stringify(formatted) !== JSON.stringify(initialFormatted);
|
|
2053
|
+
}, [conditions, initialFilters, activeFilterCount]);
|
|
2054
|
+
const canApply = useMemo3(() => {
|
|
2055
|
+
return allFiltersValid && hasChangesFromInitial;
|
|
2056
|
+
}, [allFiltersValid, hasChangesFromInitial]);
|
|
2010
2057
|
const addCondition = () => {
|
|
2011
2058
|
setConditions((prev) => [
|
|
2012
2059
|
...prev,
|
|
2013
2060
|
{
|
|
2014
2061
|
id: crypto.randomUUID(),
|
|
2015
|
-
logic: prev.length === 0 ?
|
|
2062
|
+
logic: prev.length === 0 ? "WHERE" : "AND"
|
|
2016
2063
|
}
|
|
2017
2064
|
]);
|
|
2018
2065
|
};
|
|
@@ -2022,22 +2069,48 @@ var GridHeader = ({
|
|
|
2022
2069
|
);
|
|
2023
2070
|
};
|
|
2024
2071
|
const deleteCondition = (id) => {
|
|
2025
|
-
|
|
2072
|
+
const updatedConditions = conditions.filter((c) => c.id !== id);
|
|
2073
|
+
setConditions(updatedConditions);
|
|
2074
|
+
if (updatedConditions.length === 0) {
|
|
2075
|
+
setFilterMenu(false);
|
|
2076
|
+
onFilterChange == null ? void 0 : onFilterChange({
|
|
2077
|
+
conditions: [],
|
|
2078
|
+
formatted: [],
|
|
2079
|
+
action: "clear"
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
};
|
|
2083
|
+
const applyFilters = () => {
|
|
2084
|
+
if (!canApply) return;
|
|
2085
|
+
const formatted = formatFiltersForApi(conditions);
|
|
2086
|
+
onFilterChange == null ? void 0 : onFilterChange({
|
|
2087
|
+
conditions: conditions.filter(isValidFilter),
|
|
2088
|
+
formatted,
|
|
2089
|
+
action: "apply"
|
|
2090
|
+
});
|
|
2091
|
+
setFilterMenu(false);
|
|
2026
2092
|
};
|
|
2027
2093
|
const clearFilters = () => {
|
|
2028
2094
|
setConditions([]);
|
|
2095
|
+
setFilterMenu(false);
|
|
2096
|
+
onFilterChange == null ? void 0 : onFilterChange({
|
|
2097
|
+
conditions: [],
|
|
2098
|
+
formatted: [],
|
|
2099
|
+
action: "clear"
|
|
2100
|
+
});
|
|
2029
2101
|
};
|
|
2030
|
-
return /* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between bg-card py-2 px-4", children: [
|
|
2102
|
+
return /* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between bg-card py-2 px-4 rounded-tl-md rounded-tr-md", children: [
|
|
2031
2103
|
/* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-3", children: [
|
|
2032
2104
|
filterList.length > 0 && /* @__PURE__ */ jsxs17("div", { className: "relative", ref: filterRef, children: [
|
|
2033
2105
|
/* @__PURE__ */ jsxs17(
|
|
2034
2106
|
"button",
|
|
2035
2107
|
{
|
|
2036
2108
|
onClick: () => setFilterMenu((p) => !p),
|
|
2037
|
-
className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-input text-sm",
|
|
2109
|
+
className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-input text-sm cursor-pointer",
|
|
2038
2110
|
children: [
|
|
2039
2111
|
/* @__PURE__ */ jsx23(ListFilter, { size: 16 }),
|
|
2040
|
-
"Filters"
|
|
2112
|
+
"Filters",
|
|
2113
|
+
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 })
|
|
2041
2114
|
]
|
|
2042
2115
|
}
|
|
2043
2116
|
),
|
|
@@ -2053,16 +2126,20 @@ var GridHeader = ({
|
|
|
2053
2126
|
"button",
|
|
2054
2127
|
{
|
|
2055
2128
|
onClick: clearFilters,
|
|
2056
|
-
className: "p-2 rounded-md hover:bg-destructive/30",
|
|
2129
|
+
className: "p-2 rounded-md hover:bg-destructive/30 cursor-pointer",
|
|
2130
|
+
title: "Clear all filters",
|
|
2057
2131
|
children: /* @__PURE__ */ jsx23(X2, { size: 16 })
|
|
2058
2132
|
}
|
|
2059
2133
|
)
|
|
2060
2134
|
] }),
|
|
2061
2135
|
/* @__PURE__ */ jsx23("div", { className: "space-y-3", children: conditions.map((condition, index) => {
|
|
2062
|
-
var _a, _b, _c, _d;
|
|
2136
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2063
2137
|
const selectedColumn = filterList.find(
|
|
2064
2138
|
(f) => f.columnName.value === condition.column
|
|
2065
2139
|
);
|
|
2140
|
+
const selectedOperator = selectedColumn == null ? void 0 : selectedColumn.operators.find(
|
|
2141
|
+
(op) => op.value === condition.operator
|
|
2142
|
+
);
|
|
2066
2143
|
return /* @__PURE__ */ jsxs17(
|
|
2067
2144
|
"div",
|
|
2068
2145
|
{
|
|
@@ -2077,8 +2154,8 @@ var GridHeader = ({
|
|
|
2077
2154
|
}),
|
|
2078
2155
|
className: "w-full px-2 py-2 rounded-md bg-input text-sm",
|
|
2079
2156
|
children: [
|
|
2080
|
-
/* @__PURE__ */ jsx23("option", { value: "AND", children: "
|
|
2081
|
-
/* @__PURE__ */ jsx23("option", { value: "OR", children: "
|
|
2157
|
+
/* @__PURE__ */ jsx23("option", { value: "AND", children: "AND" }),
|
|
2158
|
+
/* @__PURE__ */ jsx23("option", { value: "OR", children: "OR" })
|
|
2082
2159
|
]
|
|
2083
2160
|
}
|
|
2084
2161
|
) }),
|
|
@@ -2093,7 +2170,7 @@ var GridHeader = ({
|
|
|
2093
2170
|
}),
|
|
2094
2171
|
className: "flex-1 min-w-0 px-3 py-2 rounded-md bg-input text-sm",
|
|
2095
2172
|
children: [
|
|
2096
|
-
/* @__PURE__ */ jsx23("option", { value: "", children: "Column" }),
|
|
2173
|
+
/* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Column" }),
|
|
2097
2174
|
filterList.map((f) => /* @__PURE__ */ jsx23(
|
|
2098
2175
|
"option",
|
|
2099
2176
|
{
|
|
@@ -2114,29 +2191,91 @@ var GridHeader = ({
|
|
|
2114
2191
|
operator: e.target.value,
|
|
2115
2192
|
value: void 0
|
|
2116
2193
|
}),
|
|
2117
|
-
className: "flex-1 min-w-0 px-3 py-2 rounded-md bg-input text-sm",
|
|
2194
|
+
className: "flex-1 min-w-0 px-3 py-2 rounded-md bg-input text-sm disabled:opacity-50 disabled:cursor-not-allowed",
|
|
2118
2195
|
children: [
|
|
2119
|
-
/* @__PURE__ */ jsx23("option", { value: "", children: "Operator" }),
|
|
2120
|
-
selectedColumn == null ? void 0 : selectedColumn.operators.map((op) =>
|
|
2196
|
+
/* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Operator" }),
|
|
2197
|
+
selectedColumn == null ? void 0 : selectedColumn.operators.map((op) => {
|
|
2198
|
+
var _a2;
|
|
2199
|
+
return /* @__PURE__ */ jsx23("option", { value: (_a2 = op.value) != null ? _a2 : "", children: op.label }, op.value);
|
|
2200
|
+
})
|
|
2121
2201
|
]
|
|
2122
2202
|
}
|
|
2123
2203
|
),
|
|
2124
|
-
/* @__PURE__ */
|
|
2125
|
-
"input"
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2204
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-1 min-w-0", children: [
|
|
2205
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "input" && /* @__PURE__ */ jsx23(
|
|
2206
|
+
"input",
|
|
2207
|
+
{
|
|
2208
|
+
value: (_d = condition.value) != null ? _d : "",
|
|
2209
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2210
|
+
value: e.target.value
|
|
2211
|
+
}),
|
|
2212
|
+
placeholder: "Enter value",
|
|
2213
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2214
|
+
}
|
|
2215
|
+
),
|
|
2216
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "select" && /* @__PURE__ */ jsxs17(
|
|
2217
|
+
"select",
|
|
2218
|
+
{
|
|
2219
|
+
value: (_e = condition.value) != null ? _e : "",
|
|
2220
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2221
|
+
value: e.target.value
|
|
2222
|
+
}),
|
|
2223
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm",
|
|
2224
|
+
children: [
|
|
2225
|
+
/* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Select value" }),
|
|
2226
|
+
(_f = selectedOperator.options) == null ? void 0 : _f.map((opt) => /* @__PURE__ */ jsx23("option", { value: opt.value, children: opt.label }, opt.value))
|
|
2227
|
+
]
|
|
2228
|
+
}
|
|
2229
|
+
),
|
|
2230
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "date" && /* @__PURE__ */ jsx23(
|
|
2231
|
+
"input",
|
|
2232
|
+
{
|
|
2233
|
+
type: "date",
|
|
2234
|
+
value: (_g = condition.value) != null ? _g : "",
|
|
2235
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2236
|
+
value: e.target.value
|
|
2237
|
+
}),
|
|
2238
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2239
|
+
}
|
|
2240
|
+
),
|
|
2241
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "date-range" && /* @__PURE__ */ jsxs17("div", { className: "flex gap-2", children: [
|
|
2242
|
+
/* @__PURE__ */ jsx23(
|
|
2243
|
+
"input",
|
|
2244
|
+
{
|
|
2245
|
+
type: "date",
|
|
2246
|
+
value: (_i = (_h = condition.value) == null ? void 0 : _h.start) != null ? _i : "",
|
|
2247
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2248
|
+
value: __spreadProps(__spreadValues({}, condition.value), {
|
|
2249
|
+
start: e.target.value
|
|
2250
|
+
})
|
|
2251
|
+
}),
|
|
2252
|
+
placeholder: "Start date",
|
|
2253
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2254
|
+
}
|
|
2255
|
+
),
|
|
2256
|
+
/* @__PURE__ */ jsx23(
|
|
2257
|
+
"input",
|
|
2258
|
+
{
|
|
2259
|
+
type: "date",
|
|
2260
|
+
value: (_k = (_j = condition.value) == null ? void 0 : _j.end) != null ? _k : "",
|
|
2261
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2262
|
+
value: __spreadProps(__spreadValues({}, condition.value), {
|
|
2263
|
+
end: e.target.value
|
|
2264
|
+
})
|
|
2265
|
+
}),
|
|
2266
|
+
placeholder: "End date",
|
|
2267
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2268
|
+
}
|
|
2269
|
+
)
|
|
2270
|
+
] }),
|
|
2271
|
+
!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
|
+
] }),
|
|
2135
2273
|
/* @__PURE__ */ jsx23("div", { className: "w-[40px] flex justify-center shrink-0", children: /* @__PURE__ */ jsx23(
|
|
2136
2274
|
"button",
|
|
2137
2275
|
{
|
|
2138
2276
|
onClick: () => deleteCondition(condition.id),
|
|
2139
|
-
className: "p-2 rounded-md hover:bg-destructive/30",
|
|
2277
|
+
className: "p-2 rounded-md hover:bg-destructive/30 cursor-pointer",
|
|
2278
|
+
title: "Delete condition",
|
|
2140
2279
|
children: /* @__PURE__ */ jsx23(Trash2, { size: 16 })
|
|
2141
2280
|
}
|
|
2142
2281
|
) })
|
|
@@ -2145,17 +2284,38 @@ var GridHeader = ({
|
|
|
2145
2284
|
condition.id
|
|
2146
2285
|
);
|
|
2147
2286
|
}) }),
|
|
2148
|
-
/* @__PURE__ */ jsxs17(
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2287
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between pt-2 border-t", children: [
|
|
2288
|
+
/* @__PURE__ */ jsxs17(
|
|
2289
|
+
"button",
|
|
2290
|
+
{
|
|
2291
|
+
onClick: addCondition,
|
|
2292
|
+
className: "flex items-center gap-2 text-sm text-primary hover:text-primary/80 cursor-pointer",
|
|
2293
|
+
children: [
|
|
2294
|
+
/* @__PURE__ */ jsx23(Plus, { size: 14 }),
|
|
2295
|
+
"Add condition"
|
|
2296
|
+
]
|
|
2297
|
+
}
|
|
2298
|
+
),
|
|
2299
|
+
/* @__PURE__ */ jsxs17(
|
|
2300
|
+
"button",
|
|
2301
|
+
{
|
|
2302
|
+
onClick: applyFilters,
|
|
2303
|
+
disabled: !canApply,
|
|
2304
|
+
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",
|
|
2305
|
+
children: [
|
|
2306
|
+
/* @__PURE__ */ jsx23(Check, { size: 16 }),
|
|
2307
|
+
"Apply",
|
|
2308
|
+
hasChangesFromInitial && canApply && /* @__PURE__ */ jsx23(
|
|
2309
|
+
"span",
|
|
2310
|
+
{
|
|
2311
|
+
className: "ml-1 w-2 h-2 bg-yellow-400 rounded-full",
|
|
2312
|
+
title: "Unapplied changes"
|
|
2313
|
+
}
|
|
2314
|
+
)
|
|
2315
|
+
]
|
|
2316
|
+
}
|
|
2317
|
+
)
|
|
2318
|
+
] })
|
|
2159
2319
|
]
|
|
2160
2320
|
}
|
|
2161
2321
|
)
|
|
@@ -2165,11 +2325,11 @@ var GridHeader = ({
|
|
|
2165
2325
|
"button",
|
|
2166
2326
|
{
|
|
2167
2327
|
onClick: () => setDownloadMenu((p) => !p),
|
|
2168
|
-
className: "p-2 rounded-md hover:bg-input",
|
|
2328
|
+
className: "p-2 rounded-md hover:bg-input cursor-pointer",
|
|
2169
2329
|
children: /* @__PURE__ */ jsx23(Ellipsis, { size: 16 })
|
|
2170
2330
|
}
|
|
2171
2331
|
),
|
|
2172
|
-
downloadMenu && /* @__PURE__ */ jsxs17("div", { className: "absolute top-full right-0 mt-2 w-32 rounded-md border bg-background shadow-lg z-50", children: [
|
|
2332
|
+
downloadMenu && /* @__PURE__ */ jsxs17("div", { className: "absolute top-full right-0 mt-2 w-32 rounded-md border bg-background shadow-lg z-50 overflow-hidden", children: [
|
|
2173
2333
|
/* @__PURE__ */ jsxs17(
|
|
2174
2334
|
"button",
|
|
2175
2335
|
{
|
|
@@ -2177,7 +2337,7 @@ var GridHeader = ({
|
|
|
2177
2337
|
onPdf == null ? void 0 : onPdf();
|
|
2178
2338
|
setDownloadMenu(false);
|
|
2179
2339
|
},
|
|
2180
|
-
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted",
|
|
2340
|
+
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2181
2341
|
children: [
|
|
2182
2342
|
/* @__PURE__ */ jsx23(FileText, { size: 14 }),
|
|
2183
2343
|
"PDF"
|
|
@@ -2191,7 +2351,7 @@ var GridHeader = ({
|
|
|
2191
2351
|
onExcel == null ? void 0 : onExcel();
|
|
2192
2352
|
setDownloadMenu(false);
|
|
2193
2353
|
},
|
|
2194
|
-
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted",
|
|
2354
|
+
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2195
2355
|
children: [
|
|
2196
2356
|
/* @__PURE__ */ jsx23(FileSpreadsheet, { size: 14 }),
|
|
2197
2357
|
"Excel"
|
|
@@ -2209,7 +2369,7 @@ var GridHeader = ({
|
|
|
2209
2369
|
"button",
|
|
2210
2370
|
{
|
|
2211
2371
|
onClick: () => setSearchOpen(true),
|
|
2212
|
-
className: "w-[40px] h-[40px] flex items-center justify-center rounded-md hover:bg-input",
|
|
2372
|
+
className: "w-[40px] h-[40px] flex items-center justify-center rounded-md hover:bg-input cursor-pointer",
|
|
2213
2373
|
children: /* @__PURE__ */ jsx23(Search, { size: 18 })
|
|
2214
2374
|
}
|
|
2215
2375
|
) : /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2 w-full h-full px-3 rounded-md border border-input bg-background", children: [
|
|
@@ -2224,7 +2384,14 @@ var GridHeader = ({
|
|
|
2224
2384
|
value: searchValue
|
|
2225
2385
|
}
|
|
2226
2386
|
),
|
|
2227
|
-
/* @__PURE__ */ jsx23(
|
|
2387
|
+
/* @__PURE__ */ jsx23(
|
|
2388
|
+
"button",
|
|
2389
|
+
{
|
|
2390
|
+
onClick: () => setSearchOpen(false),
|
|
2391
|
+
className: "cursor-pointer",
|
|
2392
|
+
children: /* @__PURE__ */ jsx23(X2, { size: 16 })
|
|
2393
|
+
}
|
|
2394
|
+
)
|
|
2228
2395
|
] })
|
|
2229
2396
|
}
|
|
2230
2397
|
) })
|
|
@@ -2247,7 +2414,8 @@ var Grid = forwardRef(
|
|
|
2247
2414
|
downloadable = true,
|
|
2248
2415
|
fileName,
|
|
2249
2416
|
fonts,
|
|
2250
|
-
onFilterChange
|
|
2417
|
+
onFilterChange,
|
|
2418
|
+
initialFilters
|
|
2251
2419
|
} = _b, rest = __objRest(_b, [
|
|
2252
2420
|
"data",
|
|
2253
2421
|
"columns",
|
|
@@ -2259,7 +2427,8 @@ var Grid = forwardRef(
|
|
|
2259
2427
|
"downloadable",
|
|
2260
2428
|
"fileName",
|
|
2261
2429
|
"fonts",
|
|
2262
|
-
"onFilterChange"
|
|
2430
|
+
"onFilterChange",
|
|
2431
|
+
"initialFilters"
|
|
2263
2432
|
]);
|
|
2264
2433
|
const apiRef = useRef2(null);
|
|
2265
2434
|
const containerRef = useRef2(null);
|
|
@@ -2294,6 +2463,14 @@ var Grid = forwardRef(
|
|
|
2294
2463
|
});
|
|
2295
2464
|
}
|
|
2296
2465
|
}, [columns, data]);
|
|
2466
|
+
useEffect6(() => {
|
|
2467
|
+
if (!containerRef.current) return;
|
|
2468
|
+
const observer = new ResizeObserver(() => {
|
|
2469
|
+
resizeColumns();
|
|
2470
|
+
});
|
|
2471
|
+
observer.observe(containerRef.current);
|
|
2472
|
+
return () => observer.disconnect();
|
|
2473
|
+
}, [resizeColumns]);
|
|
2297
2474
|
const init = useCallback2(
|
|
2298
2475
|
(api) => {
|
|
2299
2476
|
apiRef.current = api;
|
|
@@ -2337,7 +2514,8 @@ var Grid = forwardRef(
|
|
|
2337
2514
|
onSearch: rest.onSearch,
|
|
2338
2515
|
searchValue: rest.searchValue,
|
|
2339
2516
|
filterList: rest.filterList,
|
|
2340
|
-
onFilterChange
|
|
2517
|
+
onFilterChange,
|
|
2518
|
+
initialFilters
|
|
2341
2519
|
}
|
|
2342
2520
|
),
|
|
2343
2521
|
/* @__PURE__ */ jsx24("div", { className: "flex-1 w-full overflow-hidden", ref: containerRef, children: /* @__PURE__ */ jsx24(WillowDark, { fonts, children: /* @__PURE__ */ jsx24("div", { className: "w-full h-full relative", children: rest.loading ? /* @__PURE__ */ jsx24("div", { className: "absolute inset-0 bg-background/60 backdrop-blur-sm flex items-center justify-center z-10", children: /* @__PURE__ */ jsx24("div", { className: "animate-spin rounded-full h-8 w-8 border-2 border-primary border-t-transparent" }) }) : /* @__PURE__ */ jsx24(
|
|
@@ -2440,7 +2618,7 @@ function Pagination({
|
|
|
2440
2618
|
const handlePageSizeChange = (size) => {
|
|
2441
2619
|
onPageSizeChange == null ? void 0 : onPageSizeChange(size);
|
|
2442
2620
|
};
|
|
2443
|
-
return /* @__PURE__ */ jsxs20("div", { className: "flex items-center justify-between bg-card px-3 py-2", children: [
|
|
2621
|
+
return /* @__PURE__ */ jsxs20("div", { className: "flex items-center justify-between bg-card px-3 py-2 rounded-br-md rounded-bl-md", children: [
|
|
2444
2622
|
/* @__PURE__ */ jsxs20("div", { className: "flex items-center gap-3 text-xs text-muted-foreground tracking-wider font-medium", children: [
|
|
2445
2623
|
/* @__PURE__ */ jsxs20("span", { children: [
|
|
2446
2624
|
"Showing ",
|