baaz-custom-components 5.0.27 → 5.0.29
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 +114 -9
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +265 -225
- package/dist/index.mjs +261 -225
- 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") {
|
|
@@ -2036,10 +1985,11 @@ var GridHeader = ({
|
|
|
2036
1985
|
}, [conditions]);
|
|
2037
1986
|
const activeFilterCount = (initialFilters == null ? void 0 : initialFilters.length) || 0;
|
|
2038
1987
|
const formatFiltersForApi = (conditions2) => {
|
|
2039
|
-
return conditions2.filter(isValidFilter).map(({ column, operator, value, logic }, index) => ({
|
|
1988
|
+
return conditions2.filter(isValidFilter).map(({ column, operator, value, logic, key }, index) => ({
|
|
2040
1989
|
column,
|
|
2041
1990
|
operator,
|
|
2042
1991
|
value,
|
|
1992
|
+
key,
|
|
2043
1993
|
logic: index === 0 ? "WHERE" : logic != null ? logic : "AND"
|
|
2044
1994
|
}));
|
|
2045
1995
|
};
|
|
@@ -2099,60 +2049,93 @@ var GridHeader = ({
|
|
|
2099
2049
|
action: "clear"
|
|
2100
2050
|
});
|
|
2101
2051
|
};
|
|
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
|
-
|
|
2052
|
+
useEffect5(() => {
|
|
2053
|
+
if (initialFilters && initialFilters.length > 0) {
|
|
2054
|
+
const initialConditions = initialFilters.map(
|
|
2055
|
+
(filter, index) => ({
|
|
2056
|
+
id: crypto.randomUUID(),
|
|
2057
|
+
column: filter.column,
|
|
2058
|
+
operator: filter.operator,
|
|
2059
|
+
value: filter.value,
|
|
2060
|
+
logic: index === 0 ? "WHERE" : filter.logic || "AND"
|
|
2061
|
+
})
|
|
2062
|
+
);
|
|
2063
|
+
setConditions(initialConditions);
|
|
2064
|
+
}
|
|
2065
|
+
}, []);
|
|
2066
|
+
useEffect5(() => {
|
|
2067
|
+
const handleClickOutside = (e) => {
|
|
2068
|
+
if (filterRef.current && !filterRef.current.contains(e.target)) {
|
|
2069
|
+
setFilterMenu(false);
|
|
2070
|
+
}
|
|
2071
|
+
};
|
|
2072
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2073
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2074
|
+
}, []);
|
|
2075
|
+
const selectedColumns = useMemo3(() => {
|
|
2076
|
+
return conditions.map((c) => c.column).filter(Boolean);
|
|
2077
|
+
}, [conditions]);
|
|
2078
|
+
return /* @__PURE__ */ jsxs17("div", { className: "relative", ref: filterRef, children: [
|
|
2079
|
+
/* @__PURE__ */ jsxs17(
|
|
2080
|
+
"button",
|
|
2081
|
+
{
|
|
2082
|
+
onClick: () => setFilterMenu((p) => !p),
|
|
2083
|
+
className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-input text-sm cursor-pointer",
|
|
2084
|
+
children: [
|
|
2085
|
+
/* @__PURE__ */ jsx23(ListFilter, { size: 16 }),
|
|
2086
|
+
/* @__PURE__ */ jsx23("span", { className: "hidden md:block", children: "Filters" }),
|
|
2087
|
+
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 })
|
|
2088
|
+
]
|
|
2089
|
+
}
|
|
2090
|
+
),
|
|
2091
|
+
filterMenu && /* @__PURE__ */ jsxs17(Fragment2, { children: [
|
|
2092
|
+
/* @__PURE__ */ jsx23(
|
|
2093
|
+
"div",
|
|
2094
|
+
{
|
|
2095
|
+
className: "fixed inset-0 bg-black/40 z-40 md:hidden",
|
|
2096
|
+
onClick: () => setFilterMenu(false)
|
|
2097
|
+
}
|
|
2098
|
+
),
|
|
2099
|
+
/* @__PURE__ */ jsxs17(
|
|
2100
|
+
"div",
|
|
2101
|
+
{
|
|
2102
|
+
ref: filterDropdownRef,
|
|
2103
|
+
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",
|
|
2104
|
+
children: [
|
|
2105
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-start sm:items-center justify-between gap-2", children: [
|
|
2106
|
+
/* @__PURE__ */ jsx23("span", { className: "text-sm font-medium", children: "In this view, show records" }),
|
|
2107
|
+
/* @__PURE__ */ jsx23(
|
|
2108
|
+
"button",
|
|
2109
|
+
{
|
|
2110
|
+
onClick: clearFilters,
|
|
2111
|
+
className: "p-2 rounded-md hover:bg-destructive/30 cursor-pointer",
|
|
2112
|
+
title: "Clear all filters",
|
|
2113
|
+
children: /* @__PURE__ */ jsx23(X2, { size: 16 })
|
|
2114
|
+
}
|
|
2115
|
+
)
|
|
2116
|
+
] }),
|
|
2117
|
+
/* @__PURE__ */ jsx23("div", { className: "space-y-3 w-full flex flex-col overflow-auto", children: conditions.map((condition, index) => {
|
|
2118
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2119
|
+
const selectedColumn = filterList.find(
|
|
2120
|
+
(f) => f.columnName.value === condition.column
|
|
2121
|
+
);
|
|
2122
|
+
const selectedOperator = selectedColumn == null ? void 0 : selectedColumn.operators.find(
|
|
2123
|
+
(op) => op.value === condition.operator
|
|
2124
|
+
);
|
|
2125
|
+
return /* @__PURE__ */ jsxs17(
|
|
2126
|
+
"div",
|
|
2127
|
+
{
|
|
2128
|
+
className: "flex flex-col md:flex-row gap-3 md:gap-2 w-full",
|
|
2129
|
+
children: [
|
|
2130
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex flex-col sm:flex-row gap-2 w-full", children: [
|
|
2131
|
+
/* @__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
2132
|
"select",
|
|
2150
2133
|
{
|
|
2151
2134
|
value: (_a = condition.logic) != null ? _a : "AND",
|
|
2152
2135
|
onChange: (e) => updateCondition(condition.id, {
|
|
2153
2136
|
logic: e.target.value
|
|
2154
2137
|
}),
|
|
2155
|
-
className: "w-full px-
|
|
2138
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none",
|
|
2156
2139
|
children: [
|
|
2157
2140
|
/* @__PURE__ */ jsx23("option", { value: "AND", children: "AND" }),
|
|
2158
2141
|
/* @__PURE__ */ jsx23("option", { value: "OR", children: "OR" })
|
|
@@ -2168,17 +2151,21 @@ var GridHeader = ({
|
|
|
2168
2151
|
operator: void 0,
|
|
2169
2152
|
value: void 0
|
|
2170
2153
|
}),
|
|
2171
|
-
className: "
|
|
2154
|
+
className: "w-full sm:min-w-[8rem] px-3 py-2 rounded-md bg-input text-sm focus:outline-none",
|
|
2172
2155
|
children: [
|
|
2173
2156
|
/* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Column" }),
|
|
2174
|
-
filterList.map((f) =>
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2157
|
+
filterList.map((f) => {
|
|
2158
|
+
const isUsed = selectedColumns.includes(f.columnName.value) && condition.column !== f.columnName.value;
|
|
2159
|
+
return /* @__PURE__ */ jsx23(
|
|
2160
|
+
"option",
|
|
2161
|
+
{
|
|
2162
|
+
value: f.columnName.value,
|
|
2163
|
+
disabled: isUsed,
|
|
2164
|
+
children: f.columnName.label
|
|
2165
|
+
},
|
|
2166
|
+
f.columnName.value
|
|
2167
|
+
);
|
|
2168
|
+
})
|
|
2182
2169
|
]
|
|
2183
2170
|
}
|
|
2184
2171
|
),
|
|
@@ -2187,11 +2174,18 @@ var GridHeader = ({
|
|
|
2187
2174
|
{
|
|
2188
2175
|
value: (_c = condition.operator) != null ? _c : "",
|
|
2189
2176
|
disabled: !selectedColumn,
|
|
2190
|
-
onChange: (e) =>
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2177
|
+
onChange: (e) => {
|
|
2178
|
+
const operatorValue = e.target.value;
|
|
2179
|
+
const operator = selectedColumn == null ? void 0 : selectedColumn.operators.find(
|
|
2180
|
+
(op) => op.value === operatorValue
|
|
2181
|
+
);
|
|
2182
|
+
updateCondition(condition.id, {
|
|
2183
|
+
operator: e.target.value,
|
|
2184
|
+
key: operator == null ? void 0 : operator.key,
|
|
2185
|
+
value: void 0
|
|
2186
|
+
});
|
|
2187
|
+
},
|
|
2188
|
+
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
2189
|
children: [
|
|
2196
2190
|
/* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Operator" }),
|
|
2197
2191
|
selectedColumn == null ? void 0 : selectedColumn.operators.map((op) => {
|
|
@@ -2200,8 +2194,10 @@ var GridHeader = ({
|
|
|
2200
2194
|
})
|
|
2201
2195
|
]
|
|
2202
2196
|
}
|
|
2203
|
-
)
|
|
2204
|
-
|
|
2197
|
+
)
|
|
2198
|
+
] }),
|
|
2199
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex flex-col sm:flex-row gap-2 w-full items-start sm:items-center", children: [
|
|
2200
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-1 w-full min-w-0", children: [
|
|
2205
2201
|
(selectedOperator == null ? void 0 : selectedOperator.value) === "input" && /* @__PURE__ */ jsx23(
|
|
2206
2202
|
"input",
|
|
2207
2203
|
{
|
|
@@ -2210,7 +2206,7 @@ var GridHeader = ({
|
|
|
2210
2206
|
value: e.target.value
|
|
2211
2207
|
}),
|
|
2212
2208
|
placeholder: "Enter value",
|
|
2213
|
-
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2209
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none"
|
|
2214
2210
|
}
|
|
2215
2211
|
),
|
|
2216
2212
|
(selectedOperator == null ? void 0 : selectedOperator.value) === "select" && /* @__PURE__ */ jsxs17(
|
|
@@ -2220,7 +2216,7 @@ var GridHeader = ({
|
|
|
2220
2216
|
onChange: (e) => updateCondition(condition.id, {
|
|
2221
2217
|
value: e.target.value
|
|
2222
2218
|
}),
|
|
2223
|
-
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",
|
|
2224
2220
|
children: [
|
|
2225
2221
|
/* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Select value" }),
|
|
2226
2222
|
(_f = selectedOperator.options) == null ? void 0 : _f.map((opt) => /* @__PURE__ */ jsx23("option", { value: opt.value, children: opt.label }, opt.value))
|
|
@@ -2235,10 +2231,10 @@ var GridHeader = ({
|
|
|
2235
2231
|
onChange: (e) => updateCondition(condition.id, {
|
|
2236
2232
|
value: e.target.value
|
|
2237
2233
|
}),
|
|
2238
|
-
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2234
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none"
|
|
2239
2235
|
}
|
|
2240
2236
|
),
|
|
2241
|
-
(selectedOperator == null ? void 0 : selectedOperator.value) === "date-range" && /* @__PURE__ */ jsxs17("div", { className: "flex gap-2", children: [
|
|
2237
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "date-range" && /* @__PURE__ */ jsxs17("div", { className: "flex flex-col sm:flex-row gap-2 w-full", children: [
|
|
2242
2238
|
/* @__PURE__ */ jsx23(
|
|
2243
2239
|
"input",
|
|
2244
2240
|
{
|
|
@@ -2249,8 +2245,7 @@ var GridHeader = ({
|
|
|
2249
2245
|
start: e.target.value
|
|
2250
2246
|
})
|
|
2251
2247
|
}),
|
|
2252
|
-
|
|
2253
|
-
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2248
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none"
|
|
2254
2249
|
}
|
|
2255
2250
|
),
|
|
2256
2251
|
/* @__PURE__ */ jsx23(
|
|
@@ -2263,14 +2258,13 @@ var GridHeader = ({
|
|
|
2263
2258
|
end: e.target.value
|
|
2264
2259
|
})
|
|
2265
2260
|
}),
|
|
2266
|
-
|
|
2267
|
-
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2261
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm focus:outline-none"
|
|
2268
2262
|
}
|
|
2269
2263
|
)
|
|
2270
2264
|
] }),
|
|
2271
2265
|
!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
2266
|
] }),
|
|
2273
|
-
/* @__PURE__ */ jsx23("div", { className: "w-[40px] flex justify-
|
|
2267
|
+
/* @__PURE__ */ jsx23("div", { className: "w-full sm:w-[40px] flex justify-end sm:justify-center", children: /* @__PURE__ */ jsx23(
|
|
2274
2268
|
"button",
|
|
2275
2269
|
{
|
|
2276
2270
|
onClick: () => deleteCondition(condition.id),
|
|
@@ -2279,58 +2273,100 @@ var GridHeader = ({
|
|
|
2279
2273
|
children: /* @__PURE__ */ jsx23(Trash2, { size: 16 })
|
|
2280
2274
|
}
|
|
2281
2275
|
) })
|
|
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
|
-
|
|
2276
|
+
] })
|
|
2277
|
+
]
|
|
2278
|
+
},
|
|
2279
|
+
condition.id
|
|
2280
|
+
);
|
|
2281
|
+
}) }),
|
|
2282
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between pt-2 border-t", children: [
|
|
2283
|
+
/* @__PURE__ */ jsxs17(
|
|
2284
|
+
"button",
|
|
2285
|
+
{
|
|
2286
|
+
onClick: addCondition,
|
|
2287
|
+
className: "flex items-center gap-2 text-sm text-primary hover:text-primary/80 cursor-pointer",
|
|
2288
|
+
children: [
|
|
2289
|
+
/* @__PURE__ */ jsx23(Plus, { size: 14 }),
|
|
2290
|
+
"Add condition"
|
|
2291
|
+
]
|
|
2292
|
+
}
|
|
2293
|
+
),
|
|
2294
|
+
/* @__PURE__ */ jsxs17(
|
|
2295
|
+
"button",
|
|
2296
|
+
{
|
|
2297
|
+
onClick: applyFilters,
|
|
2298
|
+
disabled: !canApply,
|
|
2299
|
+
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",
|
|
2300
|
+
children: [
|
|
2301
|
+
/* @__PURE__ */ jsx23(Check, { size: 16 }),
|
|
2302
|
+
"Apply",
|
|
2303
|
+
hasChangesFromInitial && canApply && /* @__PURE__ */ jsx23(
|
|
2304
|
+
"span",
|
|
2305
|
+
{
|
|
2306
|
+
className: "ml-1 w-2 h-2 bg-yellow-400 rounded-full",
|
|
2307
|
+
title: "Unapplied changes"
|
|
2308
|
+
}
|
|
2309
|
+
)
|
|
2310
|
+
]
|
|
2311
|
+
}
|
|
2312
|
+
)
|
|
2313
|
+
] })
|
|
2314
|
+
]
|
|
2315
|
+
}
|
|
2316
|
+
)
|
|
2317
|
+
] })
|
|
2318
|
+
] });
|
|
2319
|
+
};
|
|
2320
|
+
var filters_default = Filters;
|
|
2321
|
+
|
|
2322
|
+
// src/components/custom/grid/gridHeader/index.tsx
|
|
2323
|
+
import { jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2324
|
+
var GridHeader = ({
|
|
2325
|
+
onPdf,
|
|
2326
|
+
onExcel,
|
|
2327
|
+
onSearch = () => {
|
|
2328
|
+
},
|
|
2329
|
+
download,
|
|
2330
|
+
search,
|
|
2331
|
+
searchValue,
|
|
2332
|
+
searchkey = "",
|
|
2333
|
+
filterList,
|
|
2334
|
+
onFilterChange,
|
|
2335
|
+
initialFilters = []
|
|
2336
|
+
}) => {
|
|
2337
|
+
const [downloadMenu, setDownloadMenu] = useState7(false);
|
|
2338
|
+
const [searchOpen, setSearchOpen] = useState7(false);
|
|
2339
|
+
const downloadRef = useRef2(null);
|
|
2340
|
+
useEffect6(() => {
|
|
2341
|
+
const handleClickOutside = (e) => {
|
|
2342
|
+
if (downloadRef.current && !downloadRef.current.contains(e.target)) {
|
|
2343
|
+
setDownloadMenu(false);
|
|
2344
|
+
}
|
|
2345
|
+
};
|
|
2346
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2347
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2348
|
+
}, []);
|
|
2349
|
+
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: [
|
|
2350
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex justify-between items-center gap-3", children: [
|
|
2351
|
+
/* @__PURE__ */ jsx24(
|
|
2352
|
+
filters_default,
|
|
2353
|
+
{
|
|
2354
|
+
onFilterChange,
|
|
2355
|
+
initialFilters,
|
|
2356
|
+
filterList
|
|
2357
|
+
}
|
|
2358
|
+
),
|
|
2359
|
+
download && /* @__PURE__ */ jsxs18("div", { className: "relative", ref: downloadRef, children: [
|
|
2360
|
+
/* @__PURE__ */ jsx24(
|
|
2325
2361
|
"button",
|
|
2326
2362
|
{
|
|
2327
2363
|
onClick: () => setDownloadMenu((p) => !p),
|
|
2328
2364
|
className: "p-2 rounded-md hover:bg-input cursor-pointer",
|
|
2329
|
-
children: /* @__PURE__ */
|
|
2365
|
+
children: /* @__PURE__ */ jsx24(Ellipsis, { size: 16 })
|
|
2330
2366
|
}
|
|
2331
2367
|
),
|
|
2332
|
-
downloadMenu && /* @__PURE__ */
|
|
2333
|
-
/* @__PURE__ */
|
|
2368
|
+
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: [
|
|
2369
|
+
/* @__PURE__ */ jsxs18(
|
|
2334
2370
|
"button",
|
|
2335
2371
|
{
|
|
2336
2372
|
onClick: () => {
|
|
@@ -2339,12 +2375,12 @@ var GridHeader = ({
|
|
|
2339
2375
|
},
|
|
2340
2376
|
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2341
2377
|
children: [
|
|
2342
|
-
/* @__PURE__ */
|
|
2378
|
+
/* @__PURE__ */ jsx24(FileText, { size: 14 }),
|
|
2343
2379
|
"PDF"
|
|
2344
2380
|
]
|
|
2345
2381
|
}
|
|
2346
2382
|
),
|
|
2347
|
-
/* @__PURE__ */
|
|
2383
|
+
/* @__PURE__ */ jsxs18(
|
|
2348
2384
|
"button",
|
|
2349
2385
|
{
|
|
2350
2386
|
onClick: () => {
|
|
@@ -2353,7 +2389,7 @@ var GridHeader = ({
|
|
|
2353
2389
|
},
|
|
2354
2390
|
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2355
2391
|
children: [
|
|
2356
|
-
/* @__PURE__ */
|
|
2392
|
+
/* @__PURE__ */ jsx24(FileSpreadsheet, { size: 14 }),
|
|
2357
2393
|
"Excel"
|
|
2358
2394
|
]
|
|
2359
2395
|
}
|
|
@@ -2361,20 +2397,20 @@ var GridHeader = ({
|
|
|
2361
2397
|
] })
|
|
2362
2398
|
] })
|
|
2363
2399
|
] }),
|
|
2364
|
-
search && /* @__PURE__ */
|
|
2400
|
+
search && /* @__PURE__ */ jsx24("div", { className: "relative h-[40px] flex items-center", children: /* @__PURE__ */ jsx24(
|
|
2365
2401
|
"div",
|
|
2366
2402
|
{
|
|
2367
|
-
className: `absolute right-0 flex items-center transition-all duration-200 ${searchOpen ? "w-[250px]" : "w-[40px]"} h-[40px]`,
|
|
2368
|
-
children: !searchOpen ? /* @__PURE__ */
|
|
2403
|
+
className: `absolute md:right-0 flex items-center transition-all duration-200 ${searchOpen ? "w-[250px]" : "w-[40px]"} h-[40px]`,
|
|
2404
|
+
children: !searchOpen ? /* @__PURE__ */ jsx24(
|
|
2369
2405
|
"button",
|
|
2370
2406
|
{
|
|
2371
2407
|
onClick: () => setSearchOpen(true),
|
|
2372
2408
|
className: "w-[40px] h-[40px] flex items-center justify-center rounded-md hover:bg-input cursor-pointer",
|
|
2373
|
-
children: /* @__PURE__ */
|
|
2409
|
+
children: /* @__PURE__ */ jsx24(Search, { size: 18 })
|
|
2374
2410
|
}
|
|
2375
|
-
) : /* @__PURE__ */
|
|
2376
|
-
/* @__PURE__ */
|
|
2377
|
-
/* @__PURE__ */
|
|
2411
|
+
) : /* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2 w-full h-full px-3 rounded-md border border-input bg-background", children: [
|
|
2412
|
+
/* @__PURE__ */ jsx24(Search, { size: 16 }),
|
|
2413
|
+
/* @__PURE__ */ jsx24(
|
|
2378
2414
|
"input",
|
|
2379
2415
|
{
|
|
2380
2416
|
autoFocus: true,
|
|
@@ -2384,12 +2420,12 @@ var GridHeader = ({
|
|
|
2384
2420
|
value: searchValue
|
|
2385
2421
|
}
|
|
2386
2422
|
),
|
|
2387
|
-
/* @__PURE__ */
|
|
2423
|
+
/* @__PURE__ */ jsx24(
|
|
2388
2424
|
"button",
|
|
2389
2425
|
{
|
|
2390
2426
|
onClick: () => setSearchOpen(false),
|
|
2391
2427
|
className: "cursor-pointer",
|
|
2392
|
-
children: /* @__PURE__ */
|
|
2428
|
+
children: /* @__PURE__ */ jsx24(X3, { size: 16 })
|
|
2393
2429
|
}
|
|
2394
2430
|
)
|
|
2395
2431
|
] })
|
|
@@ -2400,7 +2436,7 @@ var GridHeader = ({
|
|
|
2400
2436
|
var gridHeader_default = GridHeader;
|
|
2401
2437
|
|
|
2402
2438
|
// src/components/custom/grid/index.tsx
|
|
2403
|
-
import { jsx as
|
|
2439
|
+
import { jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2404
2440
|
var Grid = forwardRef(
|
|
2405
2441
|
(_a, ref) => {
|
|
2406
2442
|
var _b = _a, {
|
|
@@ -2430,8 +2466,8 @@ var Grid = forwardRef(
|
|
|
2430
2466
|
"onFilterChange",
|
|
2431
2467
|
"initialFilters"
|
|
2432
2468
|
]);
|
|
2433
|
-
const apiRef =
|
|
2434
|
-
const containerRef =
|
|
2469
|
+
const apiRef = useRef3(null);
|
|
2470
|
+
const containerRef = useRef3(null);
|
|
2435
2471
|
useImperativeHandle(ref, () => apiRef.current, []);
|
|
2436
2472
|
const resizeColumns = useCallback2(() => {
|
|
2437
2473
|
var _a2;
|
|
@@ -2463,7 +2499,7 @@ var Grid = forwardRef(
|
|
|
2463
2499
|
});
|
|
2464
2500
|
}
|
|
2465
2501
|
}, [columns, data]);
|
|
2466
|
-
|
|
2502
|
+
useEffect7(() => {
|
|
2467
2503
|
if (!containerRef.current) return;
|
|
2468
2504
|
const observer = new ResizeObserver(() => {
|
|
2469
2505
|
resizeColumns();
|
|
@@ -2502,8 +2538,8 @@ var Grid = forwardRef(
|
|
|
2502
2538
|
onExportExcel == null ? void 0 : onExportExcel();
|
|
2503
2539
|
}
|
|
2504
2540
|
}, [getSelectedData, exportExcel, onExportExcel, fileName]);
|
|
2505
|
-
return /* @__PURE__ */
|
|
2506
|
-
/* @__PURE__ */
|
|
2541
|
+
return /* @__PURE__ */ jsxs19("div", { className: "w-full h-full flex flex-col overflow-hidden", children: [
|
|
2542
|
+
/* @__PURE__ */ jsx25(
|
|
2507
2543
|
gridHeader_default,
|
|
2508
2544
|
{
|
|
2509
2545
|
onPdf: handleExportPdf,
|
|
@@ -2518,7 +2554,7 @@ var Grid = forwardRef(
|
|
|
2518
2554
|
initialFilters
|
|
2519
2555
|
}
|
|
2520
2556
|
),
|
|
2521
|
-
/* @__PURE__ */
|
|
2557
|
+
/* @__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
2558
|
SvarGrid,
|
|
2523
2559
|
__spreadProps(__spreadValues({}, rest), {
|
|
2524
2560
|
data,
|
|
@@ -2534,9 +2570,9 @@ var grid_default = Grid;
|
|
|
2534
2570
|
|
|
2535
2571
|
// src/components/custom/grid/sortableHeaderCell.tsx
|
|
2536
2572
|
import { MoveDown, MoveUp, ArrowUpDown } from "lucide-react";
|
|
2537
|
-
import { jsx as
|
|
2573
|
+
import { jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2538
2574
|
function SortableHeaderCell({ cell, sortKey, sortOrder, onSortChange }) {
|
|
2539
|
-
if (!(cell == null ? void 0 : cell.id)) return /* @__PURE__ */
|
|
2575
|
+
if (!(cell == null ? void 0 : cell.id)) return /* @__PURE__ */ jsx26("span", { children: cell == null ? void 0 : cell.text });
|
|
2540
2576
|
const active = sortKey === cell.id;
|
|
2541
2577
|
const handleClick = () => {
|
|
2542
2578
|
if (!onSortChange || !cell.id) return;
|
|
@@ -2550,15 +2586,15 @@ function SortableHeaderCell({ cell, sortKey, sortOrder, onSortChange }) {
|
|
|
2550
2586
|
}
|
|
2551
2587
|
onSortChange("", null);
|
|
2552
2588
|
};
|
|
2553
|
-
return /* @__PURE__ */
|
|
2589
|
+
return /* @__PURE__ */ jsxs20(
|
|
2554
2590
|
"div",
|
|
2555
2591
|
{
|
|
2556
2592
|
onClick: handleClick,
|
|
2557
2593
|
className: "cursor-pointer flex items-center gap-2 justify-between select-none",
|
|
2558
2594
|
children: [
|
|
2559
|
-
/* @__PURE__ */
|
|
2560
|
-
!active && /* @__PURE__ */
|
|
2561
|
-
active && (sortOrder === "asc" ? /* @__PURE__ */
|
|
2595
|
+
/* @__PURE__ */ jsx26("span", { children: cell.text }),
|
|
2596
|
+
!active && /* @__PURE__ */ jsx26(ArrowUpDown, { className: "w-4 h-4 opacity-50" }),
|
|
2597
|
+
active && (sortOrder === "asc" ? /* @__PURE__ */ jsx26(MoveDown, { className: "w-4 h-4" }) : /* @__PURE__ */ jsx26(MoveUp, { className: "w-4 h-4" }))
|
|
2562
2598
|
]
|
|
2563
2599
|
}
|
|
2564
2600
|
);
|
|
@@ -2597,7 +2633,7 @@ function getPaginationRange(currentPage, totalPages, siblingCount = 2) {
|
|
|
2597
2633
|
|
|
2598
2634
|
// src/components/custom/pagination/index.tsx
|
|
2599
2635
|
import { ChevronLeft, ChevronRight as ChevronRight3 } from "lucide-react";
|
|
2600
|
-
import { jsx as
|
|
2636
|
+
import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2601
2637
|
function Pagination({
|
|
2602
2638
|
totalCount,
|
|
2603
2639
|
count = null,
|
|
@@ -2618,47 +2654,47 @@ function Pagination({
|
|
|
2618
2654
|
const handlePageSizeChange = (size) => {
|
|
2619
2655
|
onPageSizeChange == null ? void 0 : onPageSizeChange(size);
|
|
2620
2656
|
};
|
|
2621
|
-
return /* @__PURE__ */
|
|
2622
|
-
/* @__PURE__ */
|
|
2623
|
-
/* @__PURE__ */
|
|
2657
|
+
return /* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between bg-card px-3 py-2 rounded-br-md rounded-bl-md", children: [
|
|
2658
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-3 text-xs text-muted-foreground tracking-wider font-medium", children: [
|
|
2659
|
+
/* @__PURE__ */ jsxs21("span", { children: [
|
|
2624
2660
|
"Showing ",
|
|
2625
|
-
/* @__PURE__ */
|
|
2661
|
+
/* @__PURE__ */ jsx27("span", { className: "text-foreground", children: count }),
|
|
2626
2662
|
" of",
|
|
2627
2663
|
" ",
|
|
2628
|
-
/* @__PURE__ */
|
|
2664
|
+
/* @__PURE__ */ jsx27("span", { className: "text-foreground", children: totalCount })
|
|
2629
2665
|
] }),
|
|
2630
|
-
showSizeChanger && /* @__PURE__ */
|
|
2666
|
+
showSizeChanger && /* @__PURE__ */ jsx27(
|
|
2631
2667
|
"select",
|
|
2632
2668
|
{
|
|
2633
2669
|
value: pageSize,
|
|
2634
2670
|
onChange: (e) => handlePageSizeChange(Number(e.target.value)),
|
|
2635
2671
|
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__ */
|
|
2672
|
+
children: sizeChangerOptions.map((size) => /* @__PURE__ */ jsxs21("option", { value: size, children: [
|
|
2637
2673
|
size,
|
|
2638
2674
|
" / page"
|
|
2639
2675
|
] }, size))
|
|
2640
2676
|
}
|
|
2641
2677
|
)
|
|
2642
2678
|
] }),
|
|
2643
|
-
/* @__PURE__ */
|
|
2644
|
-
/* @__PURE__ */
|
|
2679
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-1", children: [
|
|
2680
|
+
/* @__PURE__ */ jsx27(
|
|
2645
2681
|
"button",
|
|
2646
2682
|
{
|
|
2647
2683
|
disabled: currentPage === 1,
|
|
2648
2684
|
onClick: () => handlePageChange(currentPage - 1),
|
|
2649
2685
|
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__ */
|
|
2686
|
+
children: /* @__PURE__ */ jsx27(ChevronLeft, { className: "w-5 h-5 select-none" })
|
|
2651
2687
|
}
|
|
2652
2688
|
),
|
|
2653
2689
|
pages.map(
|
|
2654
|
-
(page, idx) => page === "dots" ? /* @__PURE__ */
|
|
2690
|
+
(page, idx) => page === "dots" ? /* @__PURE__ */ jsx27(
|
|
2655
2691
|
"span",
|
|
2656
2692
|
{
|
|
2657
2693
|
className: "px-2 text-muted-foreground text-xs tracking-wider font-medium",
|
|
2658
2694
|
children: "\u2026"
|
|
2659
2695
|
},
|
|
2660
2696
|
`dots-${idx}`
|
|
2661
|
-
) : /* @__PURE__ */
|
|
2697
|
+
) : /* @__PURE__ */ jsx27(
|
|
2662
2698
|
"button",
|
|
2663
2699
|
{
|
|
2664
2700
|
onClick: () => handlePageChange(page),
|
|
@@ -2668,13 +2704,13 @@ function Pagination({
|
|
|
2668
2704
|
page
|
|
2669
2705
|
)
|
|
2670
2706
|
),
|
|
2671
|
-
/* @__PURE__ */
|
|
2707
|
+
/* @__PURE__ */ jsx27(
|
|
2672
2708
|
"button",
|
|
2673
2709
|
{
|
|
2674
2710
|
disabled: currentPage === totalPages,
|
|
2675
2711
|
onClick: () => handlePageChange(currentPage + 1),
|
|
2676
2712
|
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__ */
|
|
2713
|
+
children: /* @__PURE__ */ jsx27(ChevronRight3, { className: "w-5 h-5 select-none" })
|
|
2678
2714
|
}
|
|
2679
2715
|
)
|
|
2680
2716
|
] })
|