baaz-custom-components 5.0.25 → 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 +218 -55
- package/dist/index.mjs +221 -57
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"Courier New",
|
|
23
23
|
monospace;
|
|
24
24
|
--color-red-700: oklch(50.5% 0.213 27.518);
|
|
25
|
+
--color-yellow-400: oklch(85.2% 0.199 91.936);
|
|
25
26
|
--color-green-800: oklch(44.8% 0.119 151.328);
|
|
26
27
|
--color-blue-700: oklch(48.8% 0.243 264.376);
|
|
27
28
|
--color-black: #000;
|
|
@@ -802,9 +803,21 @@
|
|
|
802
803
|
.rounded-xs {
|
|
803
804
|
border-radius: var(--radius-xs);
|
|
804
805
|
}
|
|
806
|
+
.rounded-tl-md {
|
|
807
|
+
border-top-left-radius: calc(var(--radius) - 2px);
|
|
808
|
+
}
|
|
805
809
|
.rounded-tl-sm {
|
|
806
810
|
border-top-left-radius: calc(var(--radius) - 4px);
|
|
807
811
|
}
|
|
812
|
+
.rounded-tr-md {
|
|
813
|
+
border-top-right-radius: calc(var(--radius) - 2px);
|
|
814
|
+
}
|
|
815
|
+
.rounded-br-md {
|
|
816
|
+
border-bottom-right-radius: calc(var(--radius) - 2px);
|
|
817
|
+
}
|
|
818
|
+
.rounded-bl-md {
|
|
819
|
+
border-bottom-left-radius: calc(var(--radius) - 2px);
|
|
820
|
+
}
|
|
808
821
|
.border {
|
|
809
822
|
border-style: var(--tw-border-style);
|
|
810
823
|
border-width: 1px;
|
|
@@ -901,6 +914,12 @@
|
|
|
901
914
|
.bg-input {
|
|
902
915
|
background-color: var(--input);
|
|
903
916
|
}
|
|
917
|
+
.bg-input\/50 {
|
|
918
|
+
background-color: var(--input);
|
|
919
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
920
|
+
background-color: color-mix(in oklab, var(--input) 50%, transparent);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
904
923
|
.bg-muted {
|
|
905
924
|
background-color: var(--muted);
|
|
906
925
|
}
|
|
@@ -934,6 +953,9 @@
|
|
|
934
953
|
background-color: color-mix(in oklab, var(--color-white) 10%, transparent);
|
|
935
954
|
}
|
|
936
955
|
}
|
|
956
|
+
.bg-yellow-400 {
|
|
957
|
+
background-color: var(--color-yellow-400);
|
|
958
|
+
}
|
|
937
959
|
.fill-current {
|
|
938
960
|
fill: currentcolor;
|
|
939
961
|
}
|
|
@@ -961,6 +983,9 @@
|
|
|
961
983
|
.px-1 {
|
|
962
984
|
padding-inline: calc(var(--spacing) * 1);
|
|
963
985
|
}
|
|
986
|
+
.px-1\.5 {
|
|
987
|
+
padding-inline: calc(var(--spacing) * 1.5);
|
|
988
|
+
}
|
|
964
989
|
.px-2 {
|
|
965
990
|
padding-inline: calc(var(--spacing) * 2);
|
|
966
991
|
}
|
|
@@ -1801,6 +1826,16 @@
|
|
|
1801
1826
|
}
|
|
1802
1827
|
}
|
|
1803
1828
|
}
|
|
1829
|
+
.hover\:text-primary\/80 {
|
|
1830
|
+
&:hover {
|
|
1831
|
+
@media (hover: hover) {
|
|
1832
|
+
color: var(--primary);
|
|
1833
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
1834
|
+
color: color-mix(in oklab, var(--primary) 80%, transparent);
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1804
1839
|
.hover\:text-sidebar-accent-foreground {
|
|
1805
1840
|
&:hover {
|
|
1806
1841
|
@media (hover: hover) {
|
package/dist/index.d.mts
CHANGED
|
@@ -104,15 +104,27 @@ type GridProps = {
|
|
|
104
104
|
onExportExcel?: () => void;
|
|
105
105
|
onSearch: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
106
106
|
filterList: Filters[];
|
|
107
|
-
onFilterChange
|
|
107
|
+
onFilterChange?: (payload: MultiFilterPayload) => void;
|
|
108
108
|
onApiReady?: (api: IApi) => void;
|
|
109
|
+
initialFilters?: any[];
|
|
110
|
+
};
|
|
111
|
+
type FilterCondition = ActiveFilter & {
|
|
112
|
+
id: string;
|
|
113
|
+
logic?: "AND" | "OR" | "WHERE";
|
|
114
|
+
};
|
|
115
|
+
type MultiFilterPayload = {
|
|
116
|
+
conditions: FilterCondition[];
|
|
117
|
+
formatted: any[];
|
|
118
|
+
action: "apply" | "clear";
|
|
119
|
+
};
|
|
120
|
+
type FilterValue = string | {
|
|
121
|
+
start?: string;
|
|
122
|
+
end?: string;
|
|
109
123
|
};
|
|
110
124
|
type ActiveFilter = {
|
|
111
|
-
column?: string
|
|
112
|
-
operator?: string
|
|
113
|
-
value?:
|
|
114
|
-
startDate?: string | null;
|
|
115
|
-
endDate?: string | null;
|
|
125
|
+
column?: string;
|
|
126
|
+
operator?: string;
|
|
127
|
+
value?: FilterValue;
|
|
116
128
|
};
|
|
117
129
|
|
|
118
130
|
declare const Grid: react.ForwardRefExoticComponent<GridProps & react.RefAttributes<IApi | null>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -104,15 +104,27 @@ type GridProps = {
|
|
|
104
104
|
onExportExcel?: () => void;
|
|
105
105
|
onSearch: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
106
106
|
filterList: Filters[];
|
|
107
|
-
onFilterChange
|
|
107
|
+
onFilterChange?: (payload: MultiFilterPayload) => void;
|
|
108
108
|
onApiReady?: (api: IApi) => void;
|
|
109
|
+
initialFilters?: any[];
|
|
110
|
+
};
|
|
111
|
+
type FilterCondition = ActiveFilter & {
|
|
112
|
+
id: string;
|
|
113
|
+
logic?: "AND" | "OR" | "WHERE";
|
|
114
|
+
};
|
|
115
|
+
type MultiFilterPayload = {
|
|
116
|
+
conditions: FilterCondition[];
|
|
117
|
+
formatted: any[];
|
|
118
|
+
action: "apply" | "clear";
|
|
119
|
+
};
|
|
120
|
+
type FilterValue = string | {
|
|
121
|
+
start?: string;
|
|
122
|
+
end?: string;
|
|
109
123
|
};
|
|
110
124
|
type ActiveFilter = {
|
|
111
|
-
column?: string
|
|
112
|
-
operator?: string
|
|
113
|
-
value?:
|
|
114
|
-
startDate?: string | null;
|
|
115
|
-
endDate?: string | null;
|
|
125
|
+
column?: string;
|
|
126
|
+
operator?: string;
|
|
127
|
+
value?: FilterValue;
|
|
116
128
|
};
|
|
117
129
|
|
|
118
130
|
declare const Grid: react.ForwardRefExoticComponent<GridProps & react.RefAttributes<IApi | null>>;
|
package/dist/index.js
CHANGED
|
@@ -1993,7 +1993,8 @@ var GridHeader = ({
|
|
|
1993
1993
|
searchValue,
|
|
1994
1994
|
searchkey = "",
|
|
1995
1995
|
filterList,
|
|
1996
|
-
onFilterChange
|
|
1996
|
+
onFilterChange,
|
|
1997
|
+
initialFilters = []
|
|
1997
1998
|
}) => {
|
|
1998
1999
|
const [downloadMenu, setDownloadMenu] = (0, import_react5.useState)(false);
|
|
1999
2000
|
const [filterMenu, setFilterMenu] = (0, import_react5.useState)(false);
|
|
@@ -2002,17 +2003,29 @@ var GridHeader = ({
|
|
|
2002
2003
|
const downloadRef = (0, import_react5.useRef)(null);
|
|
2003
2004
|
const filterRef = (0, import_react5.useRef)(null);
|
|
2004
2005
|
const filterDropdownRef = (0, import_react5.useRef)(null);
|
|
2006
|
+
(0, import_react5.useEffect)(() => {
|
|
2007
|
+
if (initialFilters && initialFilters.length > 0) {
|
|
2008
|
+
const initialConditions = initialFilters.map(
|
|
2009
|
+
(filter, index) => ({
|
|
2010
|
+
id: crypto.randomUUID(),
|
|
2011
|
+
column: filter.column,
|
|
2012
|
+
operator: filter.operator,
|
|
2013
|
+
value: filter.value,
|
|
2014
|
+
logic: index === 0 ? "WHERE" : filter.logic || "AND"
|
|
2015
|
+
})
|
|
2016
|
+
);
|
|
2017
|
+
setConditions(initialConditions);
|
|
2018
|
+
}
|
|
2019
|
+
}, []);
|
|
2005
2020
|
(0, import_react5.useEffect)(() => {
|
|
2006
2021
|
if (!filterMenu || !filterDropdownRef.current) return;
|
|
2007
2022
|
const dropdown = filterDropdownRef.current;
|
|
2008
2023
|
const rect = dropdown.getBoundingClientRect();
|
|
2009
|
-
|
|
2010
|
-
const overflowBottom = rect.bottom > window.innerHeight;
|
|
2011
|
-
if (overflowRight) {
|
|
2024
|
+
if (rect.right > window.innerWidth) {
|
|
2012
2025
|
dropdown.style.left = "auto";
|
|
2013
2026
|
dropdown.style.right = "0";
|
|
2014
2027
|
}
|
|
2015
|
-
if (
|
|
2028
|
+
if (rect.bottom > window.innerHeight) {
|
|
2016
2029
|
dropdown.style.top = "auto";
|
|
2017
2030
|
dropdown.style.bottom = "100%";
|
|
2018
2031
|
dropdown.style.marginBottom = "8px";
|
|
@@ -2030,17 +2043,44 @@ var GridHeader = ({
|
|
|
2030
2043
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2031
2044
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2032
2045
|
}, []);
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2046
|
+
const isValidFilter = (condition) => {
|
|
2047
|
+
if (!condition.column || !condition.operator) return false;
|
|
2048
|
+
if (condition.operator === "date-range") {
|
|
2049
|
+
const rangeValue = condition.value;
|
|
2050
|
+
return !!((rangeValue == null ? void 0 : rangeValue.start) && (rangeValue == null ? void 0 : rangeValue.end));
|
|
2051
|
+
}
|
|
2052
|
+
return condition.value !== void 0 && condition.value !== "";
|
|
2053
|
+
};
|
|
2054
|
+
const allFiltersValid = (0, import_react5.useMemo)(() => {
|
|
2055
|
+
if (conditions.length === 0) return false;
|
|
2056
|
+
return conditions.every(isValidFilter);
|
|
2037
2057
|
}, [conditions]);
|
|
2058
|
+
const activeFilterCount = (initialFilters == null ? void 0 : initialFilters.length) || 0;
|
|
2059
|
+
const formatFiltersForApi = (conditions2) => {
|
|
2060
|
+
return conditions2.filter(isValidFilter).map(({ column, operator, value, logic }, index) => ({
|
|
2061
|
+
column,
|
|
2062
|
+
operator,
|
|
2063
|
+
value,
|
|
2064
|
+
logic: index === 0 ? "WHERE" : logic != null ? logic : "AND"
|
|
2065
|
+
}));
|
|
2066
|
+
};
|
|
2067
|
+
const hasChangesFromInitial = (0, import_react5.useMemo)(() => {
|
|
2068
|
+
if (conditions.length === 0 && activeFilterCount === 0) return false;
|
|
2069
|
+
if (conditions.length !== activeFilterCount) return true;
|
|
2070
|
+
const formatted = formatFiltersForApi(conditions);
|
|
2071
|
+
const initialFormatted = initialFilters || [];
|
|
2072
|
+
if (formatted.length !== initialFormatted.length) return true;
|
|
2073
|
+
return JSON.stringify(formatted) !== JSON.stringify(initialFormatted);
|
|
2074
|
+
}, [conditions, initialFilters, activeFilterCount]);
|
|
2075
|
+
const canApply = (0, import_react5.useMemo)(() => {
|
|
2076
|
+
return allFiltersValid && hasChangesFromInitial;
|
|
2077
|
+
}, [allFiltersValid, hasChangesFromInitial]);
|
|
2038
2078
|
const addCondition = () => {
|
|
2039
2079
|
setConditions((prev) => [
|
|
2040
2080
|
...prev,
|
|
2041
2081
|
{
|
|
2042
2082
|
id: crypto.randomUUID(),
|
|
2043
|
-
logic: prev.length === 0 ?
|
|
2083
|
+
logic: prev.length === 0 ? "WHERE" : "AND"
|
|
2044
2084
|
}
|
|
2045
2085
|
]);
|
|
2046
2086
|
};
|
|
@@ -2050,22 +2090,48 @@ var GridHeader = ({
|
|
|
2050
2090
|
);
|
|
2051
2091
|
};
|
|
2052
2092
|
const deleteCondition = (id) => {
|
|
2053
|
-
|
|
2093
|
+
const updatedConditions = conditions.filter((c) => c.id !== id);
|
|
2094
|
+
setConditions(updatedConditions);
|
|
2095
|
+
if (updatedConditions.length === 0) {
|
|
2096
|
+
setFilterMenu(false);
|
|
2097
|
+
onFilterChange == null ? void 0 : onFilterChange({
|
|
2098
|
+
conditions: [],
|
|
2099
|
+
formatted: [],
|
|
2100
|
+
action: "clear"
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2103
|
+
};
|
|
2104
|
+
const applyFilters = () => {
|
|
2105
|
+
if (!canApply) return;
|
|
2106
|
+
const formatted = formatFiltersForApi(conditions);
|
|
2107
|
+
onFilterChange == null ? void 0 : onFilterChange({
|
|
2108
|
+
conditions: conditions.filter(isValidFilter),
|
|
2109
|
+
formatted,
|
|
2110
|
+
action: "apply"
|
|
2111
|
+
});
|
|
2112
|
+
setFilterMenu(false);
|
|
2054
2113
|
};
|
|
2055
2114
|
const clearFilters = () => {
|
|
2056
2115
|
setConditions([]);
|
|
2116
|
+
setFilterMenu(false);
|
|
2117
|
+
onFilterChange == null ? void 0 : onFilterChange({
|
|
2118
|
+
conditions: [],
|
|
2119
|
+
formatted: [],
|
|
2120
|
+
action: "clear"
|
|
2121
|
+
});
|
|
2057
2122
|
};
|
|
2058
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between bg-card py-2 px-4", children: [
|
|
2123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between bg-card py-2 px-4 rounded-tl-md rounded-tr-md", children: [
|
|
2059
2124
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
2060
2125
|
filterList.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "relative", ref: filterRef, children: [
|
|
2061
2126
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2062
2127
|
"button",
|
|
2063
2128
|
{
|
|
2064
2129
|
onClick: () => setFilterMenu((p) => !p),
|
|
2065
|
-
className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-input text-sm",
|
|
2130
|
+
className: "flex items-center gap-2 px-3 py-2 rounded-md hover:bg-input text-sm cursor-pointer",
|
|
2066
2131
|
children: [
|
|
2067
2132
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.ListFilter, { size: 16 }),
|
|
2068
|
-
"Filters"
|
|
2133
|
+
"Filters",
|
|
2134
|
+
activeFilterCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "ml-1 px-1.5 py-0.5 text-xs bg-primary text-primary-foreground rounded-full font-medium", children: activeFilterCount })
|
|
2069
2135
|
]
|
|
2070
2136
|
}
|
|
2071
2137
|
),
|
|
@@ -2081,16 +2147,20 @@ var GridHeader = ({
|
|
|
2081
2147
|
"button",
|
|
2082
2148
|
{
|
|
2083
2149
|
onClick: clearFilters,
|
|
2084
|
-
className: "p-2 rounded-md hover:bg-destructive/30",
|
|
2150
|
+
className: "p-2 rounded-md hover:bg-destructive/30 cursor-pointer",
|
|
2151
|
+
title: "Clear all filters",
|
|
2085
2152
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.X, { size: 16 })
|
|
2086
2153
|
}
|
|
2087
2154
|
)
|
|
2088
2155
|
] }),
|
|
2089
2156
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "space-y-3", children: conditions.map((condition, index) => {
|
|
2090
|
-
var _a, _b, _c, _d;
|
|
2157
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2091
2158
|
const selectedColumn = filterList.find(
|
|
2092
2159
|
(f) => f.columnName.value === condition.column
|
|
2093
2160
|
);
|
|
2161
|
+
const selectedOperator = selectedColumn == null ? void 0 : selectedColumn.operators.find(
|
|
2162
|
+
(op) => op.value === condition.operator
|
|
2163
|
+
);
|
|
2094
2164
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2095
2165
|
"div",
|
|
2096
2166
|
{
|
|
@@ -2105,8 +2175,8 @@ var GridHeader = ({
|
|
|
2105
2175
|
}),
|
|
2106
2176
|
className: "w-full px-2 py-2 rounded-md bg-input text-sm",
|
|
2107
2177
|
children: [
|
|
2108
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "AND", children: "
|
|
2109
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "OR", children: "
|
|
2178
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "AND", children: "AND" }),
|
|
2179
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "OR", children: "OR" })
|
|
2110
2180
|
]
|
|
2111
2181
|
}
|
|
2112
2182
|
) }),
|
|
@@ -2121,7 +2191,7 @@ var GridHeader = ({
|
|
|
2121
2191
|
}),
|
|
2122
2192
|
className: "flex-1 min-w-0 px-3 py-2 rounded-md bg-input text-sm",
|
|
2123
2193
|
children: [
|
|
2124
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", children: "Column" }),
|
|
2194
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", disabled: true, children: "Column" }),
|
|
2125
2195
|
filterList.map((f) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2126
2196
|
"option",
|
|
2127
2197
|
{
|
|
@@ -2142,29 +2212,91 @@ var GridHeader = ({
|
|
|
2142
2212
|
operator: e.target.value,
|
|
2143
2213
|
value: void 0
|
|
2144
2214
|
}),
|
|
2145
|
-
className: "flex-1 min-w-0 px-3 py-2 rounded-md bg-input text-sm",
|
|
2215
|
+
className: "flex-1 min-w-0 px-3 py-2 rounded-md bg-input text-sm disabled:opacity-50 disabled:cursor-not-allowed",
|
|
2146
2216
|
children: [
|
|
2147
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", children: "Operator" }),
|
|
2148
|
-
selectedColumn == null ? void 0 : selectedColumn.operators.map((op) =>
|
|
2217
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", disabled: true, children: "Operator" }),
|
|
2218
|
+
selectedColumn == null ? void 0 : selectedColumn.operators.map((op) => {
|
|
2219
|
+
var _a2;
|
|
2220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: (_a2 = op.value) != null ? _a2 : "", children: op.label }, op.value);
|
|
2221
|
+
})
|
|
2149
2222
|
]
|
|
2150
2223
|
}
|
|
2151
2224
|
),
|
|
2152
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.
|
|
2153
|
-
"input",
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2225
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
2226
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "input" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2227
|
+
"input",
|
|
2228
|
+
{
|
|
2229
|
+
value: (_d = condition.value) != null ? _d : "",
|
|
2230
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2231
|
+
value: e.target.value
|
|
2232
|
+
}),
|
|
2233
|
+
placeholder: "Enter value",
|
|
2234
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2235
|
+
}
|
|
2236
|
+
),
|
|
2237
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "select" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2238
|
+
"select",
|
|
2239
|
+
{
|
|
2240
|
+
value: (_e = condition.value) != null ? _e : "",
|
|
2241
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2242
|
+
value: e.target.value
|
|
2243
|
+
}),
|
|
2244
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm",
|
|
2245
|
+
children: [
|
|
2246
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", disabled: true, children: "Select value" }),
|
|
2247
|
+
(_f = selectedOperator.options) == null ? void 0 : _f.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
|
|
2248
|
+
]
|
|
2249
|
+
}
|
|
2250
|
+
),
|
|
2251
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "date" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2252
|
+
"input",
|
|
2253
|
+
{
|
|
2254
|
+
type: "date",
|
|
2255
|
+
value: (_g = condition.value) != null ? _g : "",
|
|
2256
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2257
|
+
value: e.target.value
|
|
2258
|
+
}),
|
|
2259
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2260
|
+
}
|
|
2261
|
+
),
|
|
2262
|
+
(selectedOperator == null ? void 0 : selectedOperator.value) === "date-range" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex gap-2", children: [
|
|
2263
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2264
|
+
"input",
|
|
2265
|
+
{
|
|
2266
|
+
type: "date",
|
|
2267
|
+
value: (_i = (_h = condition.value) == null ? void 0 : _h.start) != null ? _i : "",
|
|
2268
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2269
|
+
value: __spreadProps(__spreadValues({}, condition.value), {
|
|
2270
|
+
start: e.target.value
|
|
2271
|
+
})
|
|
2272
|
+
}),
|
|
2273
|
+
placeholder: "Start date",
|
|
2274
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2275
|
+
}
|
|
2276
|
+
),
|
|
2277
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2278
|
+
"input",
|
|
2279
|
+
{
|
|
2280
|
+
type: "date",
|
|
2281
|
+
value: (_k = (_j = condition.value) == null ? void 0 : _j.end) != null ? _k : "",
|
|
2282
|
+
onChange: (e) => updateCondition(condition.id, {
|
|
2283
|
+
value: __spreadProps(__spreadValues({}, condition.value), {
|
|
2284
|
+
end: e.target.value
|
|
2285
|
+
})
|
|
2286
|
+
}),
|
|
2287
|
+
placeholder: "End date",
|
|
2288
|
+
className: "w-full px-3 py-2 rounded-md bg-input text-sm"
|
|
2289
|
+
}
|
|
2290
|
+
)
|
|
2291
|
+
] }),
|
|
2292
|
+
!selectedOperator && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-full px-3 py-2 rounded-md bg-input/50 text-sm text-muted-foreground", children: "Select operator" })
|
|
2293
|
+
] }),
|
|
2163
2294
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-[40px] flex justify-center shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2164
2295
|
"button",
|
|
2165
2296
|
{
|
|
2166
2297
|
onClick: () => deleteCondition(condition.id),
|
|
2167
|
-
className: "p-2 rounded-md hover:bg-destructive/30",
|
|
2298
|
+
className: "p-2 rounded-md hover:bg-destructive/30 cursor-pointer",
|
|
2299
|
+
title: "Delete condition",
|
|
2168
2300
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.Trash2, { size: 16 })
|
|
2169
2301
|
}
|
|
2170
2302
|
) })
|
|
@@ -2173,17 +2305,38 @@ var GridHeader = ({
|
|
|
2173
2305
|
condition.id
|
|
2174
2306
|
);
|
|
2175
2307
|
}) }),
|
|
2176
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2308
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between pt-2 border-t", children: [
|
|
2309
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2310
|
+
"button",
|
|
2311
|
+
{
|
|
2312
|
+
onClick: addCondition,
|
|
2313
|
+
className: "flex items-center gap-2 text-sm text-primary hover:text-primary/80 cursor-pointer",
|
|
2314
|
+
children: [
|
|
2315
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.Plus, { size: 14 }),
|
|
2316
|
+
"Add condition"
|
|
2317
|
+
]
|
|
2318
|
+
}
|
|
2319
|
+
),
|
|
2320
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2321
|
+
"button",
|
|
2322
|
+
{
|
|
2323
|
+
onClick: applyFilters,
|
|
2324
|
+
disabled: !canApply,
|
|
2325
|
+
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",
|
|
2326
|
+
children: [
|
|
2327
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.Check, { size: 16 }),
|
|
2328
|
+
"Apply",
|
|
2329
|
+
hasChangesFromInitial && canApply && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2330
|
+
"span",
|
|
2331
|
+
{
|
|
2332
|
+
className: "ml-1 w-2 h-2 bg-yellow-400 rounded-full",
|
|
2333
|
+
title: "Unapplied changes"
|
|
2334
|
+
}
|
|
2335
|
+
)
|
|
2336
|
+
]
|
|
2337
|
+
}
|
|
2338
|
+
)
|
|
2339
|
+
] })
|
|
2187
2340
|
]
|
|
2188
2341
|
}
|
|
2189
2342
|
)
|
|
@@ -2193,11 +2346,11 @@ var GridHeader = ({
|
|
|
2193
2346
|
"button",
|
|
2194
2347
|
{
|
|
2195
2348
|
onClick: () => setDownloadMenu((p) => !p),
|
|
2196
|
-
className: "p-2 rounded-md hover:bg-input",
|
|
2349
|
+
className: "p-2 rounded-md hover:bg-input cursor-pointer",
|
|
2197
2350
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.Ellipsis, { size: 16 })
|
|
2198
2351
|
}
|
|
2199
2352
|
),
|
|
2200
|
-
downloadMenu && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "absolute top-full right-0 mt-2 w-32 rounded-md border bg-background shadow-lg z-50", children: [
|
|
2353
|
+
downloadMenu && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "absolute top-full right-0 mt-2 w-32 rounded-md border bg-background shadow-lg z-50 overflow-hidden", children: [
|
|
2201
2354
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2202
2355
|
"button",
|
|
2203
2356
|
{
|
|
@@ -2205,7 +2358,7 @@ var GridHeader = ({
|
|
|
2205
2358
|
onPdf == null ? void 0 : onPdf();
|
|
2206
2359
|
setDownloadMenu(false);
|
|
2207
2360
|
},
|
|
2208
|
-
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted",
|
|
2361
|
+
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2209
2362
|
children: [
|
|
2210
2363
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.FileText, { size: 14 }),
|
|
2211
2364
|
"PDF"
|
|
@@ -2219,7 +2372,7 @@ var GridHeader = ({
|
|
|
2219
2372
|
onExcel == null ? void 0 : onExcel();
|
|
2220
2373
|
setDownloadMenu(false);
|
|
2221
2374
|
},
|
|
2222
|
-
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted",
|
|
2375
|
+
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2223
2376
|
children: [
|
|
2224
2377
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.FileSpreadsheet, { size: 14 }),
|
|
2225
2378
|
"Excel"
|
|
@@ -2237,7 +2390,7 @@ var GridHeader = ({
|
|
|
2237
2390
|
"button",
|
|
2238
2391
|
{
|
|
2239
2392
|
onClick: () => setSearchOpen(true),
|
|
2240
|
-
className: "w-[40px] h-[40px] flex items-center justify-center rounded-md hover:bg-input",
|
|
2393
|
+
className: "w-[40px] h-[40px] flex items-center justify-center rounded-md hover:bg-input cursor-pointer",
|
|
2241
2394
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.Search, { size: 18 })
|
|
2242
2395
|
}
|
|
2243
2396
|
) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2 w-full h-full px-3 rounded-md border border-input bg-background", children: [
|
|
@@ -2252,7 +2405,14 @@ var GridHeader = ({
|
|
|
2252
2405
|
value: searchValue
|
|
2253
2406
|
}
|
|
2254
2407
|
),
|
|
2255
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2408
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2409
|
+
"button",
|
|
2410
|
+
{
|
|
2411
|
+
onClick: () => setSearchOpen(false),
|
|
2412
|
+
className: "cursor-pointer",
|
|
2413
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.X, { size: 16 })
|
|
2414
|
+
}
|
|
2415
|
+
)
|
|
2256
2416
|
] })
|
|
2257
2417
|
}
|
|
2258
2418
|
) })
|
|
@@ -2275,7 +2435,8 @@ var Grid = (0, import_react6.forwardRef)(
|
|
|
2275
2435
|
downloadable = true,
|
|
2276
2436
|
fileName,
|
|
2277
2437
|
fonts,
|
|
2278
|
-
onFilterChange
|
|
2438
|
+
onFilterChange,
|
|
2439
|
+
initialFilters
|
|
2279
2440
|
} = _b, rest = __objRest(_b, [
|
|
2280
2441
|
"data",
|
|
2281
2442
|
"columns",
|
|
@@ -2287,7 +2448,8 @@ var Grid = (0, import_react6.forwardRef)(
|
|
|
2287
2448
|
"downloadable",
|
|
2288
2449
|
"fileName",
|
|
2289
2450
|
"fonts",
|
|
2290
|
-
"onFilterChange"
|
|
2451
|
+
"onFilterChange",
|
|
2452
|
+
"initialFilters"
|
|
2291
2453
|
]);
|
|
2292
2454
|
const apiRef = (0, import_react6.useRef)(null);
|
|
2293
2455
|
const containerRef = (0, import_react6.useRef)(null);
|
|
@@ -2373,7 +2535,8 @@ var Grid = (0, import_react6.forwardRef)(
|
|
|
2373
2535
|
onSearch: rest.onSearch,
|
|
2374
2536
|
searchValue: rest.searchValue,
|
|
2375
2537
|
filterList: rest.filterList,
|
|
2376
|
-
onFilterChange
|
|
2538
|
+
onFilterChange,
|
|
2539
|
+
initialFilters
|
|
2377
2540
|
}
|
|
2378
2541
|
),
|
|
2379
2542
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex-1 w-full overflow-hidden", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_grid.WillowDark, { fonts, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "w-full h-full relative", children: rest.loading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "absolute inset-0 bg-background/60 backdrop-blur-sm flex items-center justify-center z-10", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "animate-spin rounded-full h-8 w-8 border-2 border-primary border-t-transparent" }) }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
@@ -2476,7 +2639,7 @@ function Pagination({
|
|
|
2476
2639
|
const handlePageSizeChange = (size) => {
|
|
2477
2640
|
onPageSizeChange == null ? void 0 : onPageSizeChange(size);
|
|
2478
2641
|
};
|
|
2479
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center justify-between bg-card px-3 py-2", children: [
|
|
2642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center justify-between bg-card px-3 py-2 rounded-br-md rounded-bl-md", children: [
|
|
2480
2643
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-3 text-xs text-muted-foreground tracking-wider font-medium", children: [
|
|
2481
2644
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { children: [
|
|
2482
2645
|
"Showing ",
|