impact-nova 1.7.29 → 1.7.31
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/components/ui/ag-grid-react/headers/advanced-filter/advanced-filter-dialog.d.ts +2 -0
- package/dist/components/ui/ag-grid-react/headers/advanced-filter/advanced-filter-dialog.js +69 -67
- package/dist/components/ui/ag-grid-react/headers/advanced-filter/column-filter-section.d.ts +2 -0
- package/dist/components/ui/ag-grid-react/headers/advanced-filter/column-filter-section.js +107 -71
- package/dist/components/ui/ag-grid-react/headers/header-search-input.js +277 -213
- package/dist/components/ui/ag-grid-react/headers/utils/date-utils.d.ts +11 -1
- package/dist/components/ui/ag-grid-react/headers/utils/date-utils.js +34 -20
- package/dist/components/ui/ag-grid-react/index.js +16 -15
- package/dist/components/ui/data-table/data-table-column-list.js +86 -82
- package/dist/components/ui/nested-list/components/SortableItem.d.ts +1 -0
- package/dist/components/ui/nested-list/components/SortableItem.js +37 -36
- package/dist/components/ui/nested-list/hooks/useNestedListDragDrop.d.ts +3 -1
- package/dist/components/ui/nested-list/hooks/useNestedListDragDrop.js +186 -172
- package/dist/components/ui/nested-list/hooks/useNestedListState.d.ts +2 -1
- package/dist/components/ui/nested-list/hooks/useNestedListState.js +67 -66
- package/dist/components/ui/nested-list/nested-list.js +249 -237
- package/dist/components/ui/types/ag-grid.types.d.ts +2 -0
- package/dist/components/ui/types/nested-list.types.d.ts +3 -0
- package/package.json +1 -1
package/dist/components/ui/ag-grid-react/headers/advanced-filter/advanced-filter-dialog.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface AdvancedFilterDialogProps {
|
|
|
13
13
|
value: string;
|
|
14
14
|
}>;
|
|
15
15
|
isMultiSelect?: boolean;
|
|
16
|
+
/** Which picker to render for date columns. Default: 'date' */
|
|
17
|
+
datePickerVariant?: 'date' | 'month';
|
|
16
18
|
initialModel?: AdvancedFilterModel | null;
|
|
17
19
|
api?: GridApi;
|
|
18
20
|
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { jsxs as f, jsx as
|
|
1
|
+
import { jsxs as f, jsx as r, Fragment as Y } from "react/jsx-runtime";
|
|
2
2
|
import { useState as R } from "react";
|
|
3
|
-
import { Dialog as
|
|
3
|
+
import { Dialog as Z, DialogContent as _, DialogHeader as I, DialogTitle as ee, DialogClose as te, DialogBody as le, DialogFooter as ne } from "../../../dialog.js";
|
|
4
4
|
import { Button as v } from "../../../button.js";
|
|
5
|
-
import { Tooltip as
|
|
6
|
-
import { Cross as
|
|
5
|
+
import { Tooltip as re, TooltipTrigger as oe, TooltipContent as ae } from "../../../tooltip.js";
|
|
6
|
+
import { Cross as ie } from "../../../../../icons/index.js";
|
|
7
7
|
import { ColumnFilterSection as B } from "./column-filter-section.js";
|
|
8
8
|
import { createEmptyRule as w } from "../utils/filter-utils.js";
|
|
9
|
-
import { useImpactNovaI18n as
|
|
9
|
+
import { useImpactNovaI18n as se } from "../../../../../i18n/ImpactNovaI18nContext.js";
|
|
10
10
|
const j = (S) => {
|
|
11
11
|
const d = {};
|
|
12
12
|
return S.forEach((m) => {
|
|
13
13
|
m.columnId && (d[m.columnId] || (d[m.columnId] = []), d[m.columnId].push(m));
|
|
14
14
|
}), d;
|
|
15
|
-
},
|
|
15
|
+
}, Ce = ({
|
|
16
16
|
isOpen: S,
|
|
17
17
|
onClose: d,
|
|
18
18
|
onApply: m,
|
|
19
19
|
columnId: a,
|
|
20
|
-
columnLabel:
|
|
20
|
+
columnLabel: V,
|
|
21
21
|
columnType: C,
|
|
22
22
|
selectOptions: A,
|
|
23
|
-
isMultiSelect:
|
|
23
|
+
isMultiSelect: J,
|
|
24
|
+
datePickerVariant: G = "date",
|
|
24
25
|
initialModel: E,
|
|
25
26
|
api: p
|
|
26
|
-
// Add api to props
|
|
27
27
|
}) => {
|
|
28
|
-
const { t: u } =
|
|
28
|
+
const { t: u } = se(), z = () => (E?.rules || []).filter((e) => !("logic" in e)), [h, P] = R("column"), [x, O] = R(() => {
|
|
29
29
|
const e = {}, n = z(), t = j(n);
|
|
30
30
|
return Object.keys(t).forEach((s) => {
|
|
31
31
|
e[s] = E?.logic || "OR";
|
|
32
32
|
}), e[a] || (e[a] = "OR"), e;
|
|
33
|
-
}), [g,
|
|
33
|
+
}), [g, k] = R(() => {
|
|
34
34
|
const e = z();
|
|
35
35
|
if (p) {
|
|
36
36
|
const t = p.getFilterModel();
|
|
37
37
|
t && Object.keys(t).forEach((i) => {
|
|
38
38
|
if (!e.some((l) => l.columnId === i)) {
|
|
39
39
|
const l = t[i];
|
|
40
|
-
let
|
|
40
|
+
let o = null;
|
|
41
41
|
if (l.filterType === "text")
|
|
42
|
-
|
|
42
|
+
o = {
|
|
43
43
|
id: Math.random().toString(36).substr(2, 9),
|
|
44
44
|
columnId: i,
|
|
45
45
|
columnType: "text",
|
|
@@ -47,7 +47,7 @@ const j = (S) => {
|
|
|
47
47
|
value: l.filter
|
|
48
48
|
};
|
|
49
49
|
else if (l.filterType === "number")
|
|
50
|
-
|
|
50
|
+
o = {
|
|
51
51
|
id: Math.random().toString(36).substr(2, 9),
|
|
52
52
|
columnId: i,
|
|
53
53
|
columnType: "number",
|
|
@@ -55,7 +55,7 @@ const j = (S) => {
|
|
|
55
55
|
value: String(l.filter)
|
|
56
56
|
};
|
|
57
57
|
else if (l.filterType === "set")
|
|
58
|
-
|
|
58
|
+
o = {
|
|
59
59
|
id: Math.random().toString(36).substr(2, 9),
|
|
60
60
|
columnId: i,
|
|
61
61
|
columnType: "select",
|
|
@@ -64,7 +64,7 @@ const j = (S) => {
|
|
|
64
64
|
};
|
|
65
65
|
else if (l.filterType === "multi") {
|
|
66
66
|
const c = l.filterModels?.find((N) => N && N.filterType === "set");
|
|
67
|
-
c && (
|
|
67
|
+
c && (o = {
|
|
68
68
|
id: Math.random().toString(36).substr(2, 9),
|
|
69
69
|
columnId: i,
|
|
70
70
|
columnType: "multi",
|
|
@@ -73,7 +73,7 @@ const j = (S) => {
|
|
|
73
73
|
value: c.values
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
o && e.push(o);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -82,35 +82,35 @@ const j = (S) => {
|
|
|
82
82
|
allRules: g,
|
|
83
83
|
// Use the computed rules (potentially synced)
|
|
84
84
|
columnLogic: { ...x }
|
|
85
|
-
})), H = JSON.stringify({ allRules: g, columnLogic: x }) !== JSON.stringify(F),
|
|
86
|
-
|
|
85
|
+
})), H = JSON.stringify({ allRules: g, columnLogic: x }) !== JSON.stringify(F), q = (e) => g.filter((n) => n.columnId === e), D = (e, n) => {
|
|
86
|
+
k((t) => {
|
|
87
87
|
const s = /* @__PURE__ */ new Set(), i = [];
|
|
88
|
-
t.forEach((
|
|
89
|
-
s.has(
|
|
88
|
+
t.forEach((o) => {
|
|
89
|
+
s.has(o.columnId) || (s.add(o.columnId), i.push(o.columnId));
|
|
90
90
|
}), s.has(e) || i.push(e);
|
|
91
91
|
const l = [];
|
|
92
|
-
return i.forEach((
|
|
93
|
-
|
|
92
|
+
return i.forEach((o) => {
|
|
93
|
+
o === e ? l.push(...n) : l.push(...t.filter((c) => c.columnId === o));
|
|
94
94
|
}), l;
|
|
95
95
|
});
|
|
96
|
-
},
|
|
96
|
+
}, T = (e) => x[e] || "OR", L = (e, n) => {
|
|
97
97
|
O((t) => ({ ...t, [e]: n }));
|
|
98
98
|
}, K = () => {
|
|
99
|
-
h === "column" ? (D(a, [w(a, C)]),
|
|
99
|
+
h === "column" ? (D(a, [w(a, C)]), L(a, "OR")) : (k([w(a, C)]), O({ [a]: "OR" }));
|
|
100
100
|
}, Q = () => {
|
|
101
|
-
|
|
101
|
+
k(F.allRules.length > 0 ? F.allRules : [w(a, C)]), O(F.columnLogic);
|
|
102
102
|
}, U = () => {
|
|
103
103
|
const e = g.filter((n) => n.operator === "empty" || n.operator === "notEmpty" ? !!n.columnId : n.columnId && n.value !== "" && n.value !== null);
|
|
104
104
|
if (e.length === 0)
|
|
105
105
|
m(null);
|
|
106
106
|
else {
|
|
107
107
|
const n = e[0].columnId;
|
|
108
|
-
m({ logic:
|
|
108
|
+
m({ logic: T(n), rules: e });
|
|
109
109
|
}
|
|
110
110
|
d();
|
|
111
|
-
},
|
|
111
|
+
}, W = j(g), M = Object.keys(W), y = Object.keys(j(
|
|
112
112
|
g.filter((e) => e.operator === "empty" || e.operator === "notEmpty" ? !!e.columnId : e.columnId && e.value !== "" && e.value !== null)
|
|
113
|
-
)).length <= 1,
|
|
113
|
+
)).length <= 1, $ = (e, n) => {
|
|
114
114
|
if (!p) return n;
|
|
115
115
|
const t = p.getColumn(e);
|
|
116
116
|
if (!t) return n;
|
|
@@ -120,24 +120,24 @@ const j = (S) => {
|
|
|
120
120
|
const c = l.getColGroupDef();
|
|
121
121
|
c && c.headerName && i.unshift(c.headerName), l = l.getParent();
|
|
122
122
|
}
|
|
123
|
-
const
|
|
124
|
-
return i.push(
|
|
123
|
+
const o = s?.headerName || e;
|
|
124
|
+
return i.push(o), i.join(" > ");
|
|
125
125
|
};
|
|
126
|
-
return /* @__PURE__ */ f(
|
|
126
|
+
return /* @__PURE__ */ f(Z, { open: S, onOpenChange: d, children: [
|
|
127
127
|
(console.log("[AdvancedFilterDialog] Current State:", {
|
|
128
128
|
mode: h,
|
|
129
129
|
allRules: g,
|
|
130
130
|
columnLogic: x,
|
|
131
|
-
activeColumns:
|
|
131
|
+
activeColumns: M
|
|
132
132
|
}), null),
|
|
133
|
-
/* @__PURE__ */ f(
|
|
134
|
-
/* @__PURE__ */ f(
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ f(_, { className: "w-[800px] max-w-[95vw] max-h-[90vh] flex flex-col p-0", hideClose: !0, children: [
|
|
134
|
+
/* @__PURE__ */ f(I, { className: "flex flex-row items-center justify-between px-4 py-3", children: [
|
|
135
|
+
/* @__PURE__ */ r(ee, { children: u("advancedFilter.title") }),
|
|
136
|
+
/* @__PURE__ */ r(te, { asChild: !0, children: /* @__PURE__ */ r(v, { variant: "ghost", size: "icon", className: "h-8 w-8 p-0 text-content-tertiary hover:text-brand-variant-hover", onClick: d, "aria-label": u("aria.close"), children: /* @__PURE__ */ r(ie, { size: 14 }) }) })
|
|
137
137
|
] }),
|
|
138
138
|
/* @__PURE__ */ f("div", { className: "flex items-center justify-between px-4 py-4 pb-2", children: [
|
|
139
139
|
/* @__PURE__ */ f("div", { className: "inline-flex", role: "group", "data-component": "button-group", children: [
|
|
140
|
-
/* @__PURE__ */
|
|
140
|
+
/* @__PURE__ */ r(
|
|
141
141
|
v,
|
|
142
142
|
{
|
|
143
143
|
value: "column",
|
|
@@ -145,19 +145,19 @@ const j = (S) => {
|
|
|
145
145
|
variant: "ghost",
|
|
146
146
|
"aria-pressed": h === "column",
|
|
147
147
|
className: `!shadow-none relative border transition-colors min-w-14 !rounded-none !rounded-l-md z-[1] ${h === "column" ? "!bg-accent !border-brand !text-brand z-10" : "!bg-canvas-elevated !border-button-primary-disabled !text-[#60697d] hover:!bg-canvas-elevated hover:!text-brand"}`,
|
|
148
|
-
onClick: () =>
|
|
148
|
+
onClick: () => P("column"),
|
|
149
149
|
children: u("advancedFilter.currentColumn")
|
|
150
150
|
}
|
|
151
151
|
),
|
|
152
|
-
/* @__PURE__ */ f(
|
|
153
|
-
/* @__PURE__ */
|
|
152
|
+
/* @__PURE__ */ f(re, { children: [
|
|
153
|
+
/* @__PURE__ */ r(oe, { asChild: !0, children: /* @__PURE__ */ r(
|
|
154
154
|
"span",
|
|
155
155
|
{
|
|
156
156
|
style: {
|
|
157
157
|
cursor: y ? "not-allowed" : "default",
|
|
158
158
|
display: "inline-flex"
|
|
159
159
|
},
|
|
160
|
-
children: /* @__PURE__ */
|
|
160
|
+
children: /* @__PURE__ */ r(
|
|
161
161
|
v,
|
|
162
162
|
{
|
|
163
163
|
value: "global",
|
|
@@ -167,57 +167,59 @@ const j = (S) => {
|
|
|
167
167
|
disabled: y,
|
|
168
168
|
style: y ? { pointerEvents: "none" } : void 0,
|
|
169
169
|
className: `!shadow-none relative border transition-colors min-w-14 !rounded-none !rounded-r-md -ml-px ${y ? "!bg-disabled-surface !border-disabled-border !text-disabled-foreground opacity-100" : h === "global" ? "!bg-accent !border-brand !text-brand z-10" : "!bg-canvas-elevated !border-button-primary-disabled !text-[#60697d] hover:!bg-canvas-elevated hover:!text-brand z-[1]"}`,
|
|
170
|
-
onClick: () =>
|
|
170
|
+
onClick: () => P("global"),
|
|
171
171
|
children: u("advancedFilter.allFilters")
|
|
172
172
|
}
|
|
173
173
|
)
|
|
174
174
|
}
|
|
175
175
|
) }),
|
|
176
|
-
y && /* @__PURE__ */
|
|
176
|
+
y && /* @__PURE__ */ r(ae, { variant: "tertiary", children: u("advancedFilter.allFiltersDisabledTooltip") })
|
|
177
177
|
] })
|
|
178
178
|
] }),
|
|
179
|
-
/* @__PURE__ */
|
|
179
|
+
/* @__PURE__ */ r(v, { variant: "ghost", onClick: K, className: "!text-brand", children: u("advancedFilter.clearAll") })
|
|
180
180
|
] }),
|
|
181
|
-
/* @__PURE__ */
|
|
181
|
+
/* @__PURE__ */ r(le, { className: "px-0 py-4 flex-1 overflow-y-auto min-h-0", children: /* @__PURE__ */ r("div", { className: "flex flex-col gap-6 w-full px-4", children: h === "column" ? (
|
|
182
182
|
// Column Mode: Single column section
|
|
183
|
-
/* @__PURE__ */
|
|
183
|
+
/* @__PURE__ */ r(
|
|
184
184
|
B,
|
|
185
185
|
{
|
|
186
186
|
columnId: a,
|
|
187
|
-
columnLabel:
|
|
187
|
+
columnLabel: $(a, V),
|
|
188
188
|
columnType: C,
|
|
189
189
|
selectOptions: A,
|
|
190
|
-
isMultiSelect: A ? !!
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
isMultiSelect: A ? !!J : !0,
|
|
191
|
+
datePickerVariant: G,
|
|
192
|
+
rules: q(a),
|
|
193
|
+
logic: T(a),
|
|
194
|
+
onLogicChange: (e) => L(a, e),
|
|
194
195
|
onRulesChange: (e) => D(a, e)
|
|
195
196
|
}
|
|
196
197
|
)
|
|
197
198
|
) : (
|
|
198
199
|
// Global Mode: All columns with filters
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
+
/* @__PURE__ */ r(Y, { children: M.length === 0 ? /* @__PURE__ */ r("div", { className: "text-center py-8 text-content-placeholder", children: u("advancedFilter.noFiltersApplied") }) : M.map((e, n) => {
|
|
200
201
|
let t = null;
|
|
201
202
|
if (p) {
|
|
202
203
|
const b = p.getColumn(e);
|
|
203
204
|
b && (t = b.getColDef());
|
|
204
205
|
}
|
|
205
|
-
const s = t?.headerComponentParams, i = t?.headerName || e, l =
|
|
206
|
-
console.log(`[AdvancedFilterDialog] Column: ${e}, Type: ${
|
|
207
|
-
const c = s?.selectOptions, N = s?.isMultiSelect;
|
|
206
|
+
const s = t?.headerComponentParams, i = t?.headerName || e, l = $(e, i), o = t?.filter === "agNumberColumnFilter" ? "number" : t?.filter === "agDateColumnFilter" ? "date" : t?.filter === "agMultiColumnFilter" ? "multi" : t?.filter === "agSetColumnFilter" || s?.selectOptions ? "select" : "text";
|
|
207
|
+
console.log(`[AdvancedFilterDialog] Column: ${e}, Type: ${o}, Filter: ${t?.filter}`);
|
|
208
|
+
const c = s?.selectOptions, N = s?.isMultiSelect, X = s?.datePickerVariant || "date";
|
|
208
209
|
return /* @__PURE__ */ f("div", { children: [
|
|
209
|
-
n > 0 && /* @__PURE__ */
|
|
210
|
-
/* @__PURE__ */
|
|
210
|
+
n > 0 && /* @__PURE__ */ r("hr", { className: "border-stroke-hairline mb-6" }),
|
|
211
|
+
/* @__PURE__ */ r(
|
|
211
212
|
B,
|
|
212
213
|
{
|
|
213
214
|
columnId: e,
|
|
214
215
|
columnLabel: l,
|
|
215
|
-
columnType:
|
|
216
|
+
columnType: o,
|
|
216
217
|
selectOptions: c,
|
|
217
218
|
isMultiSelect: N,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
datePickerVariant: X,
|
|
220
|
+
rules: q(e),
|
|
221
|
+
logic: T(e),
|
|
222
|
+
onLogicChange: (b) => L(e, b),
|
|
221
223
|
onRulesChange: (b) => D(e, b),
|
|
222
224
|
canDeleteLastRule: !0,
|
|
223
225
|
onDeleteColumnFilter: () => D(e, [])
|
|
@@ -226,8 +228,8 @@ const j = (S) => {
|
|
|
226
228
|
] }, e);
|
|
227
229
|
}) })
|
|
228
230
|
) }) }),
|
|
229
|
-
/* @__PURE__ */
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
+
/* @__PURE__ */ r(ne, { className: "flex justify-end border-t border-[#D9DDE7]", children: /* @__PURE__ */ f("div", { className: "flex gap-3", children: [
|
|
232
|
+
/* @__PURE__ */ r(
|
|
231
233
|
v,
|
|
232
234
|
{
|
|
233
235
|
onClick: Q,
|
|
@@ -236,12 +238,12 @@ const j = (S) => {
|
|
|
236
238
|
children: u("advancedFilter.discard")
|
|
237
239
|
}
|
|
238
240
|
),
|
|
239
|
-
/* @__PURE__ */
|
|
241
|
+
/* @__PURE__ */ r(v, { onClick: U, variant: "default", children: u("advancedFilter.apply") })
|
|
240
242
|
] }) })
|
|
241
243
|
] })
|
|
242
244
|
] });
|
|
243
245
|
};
|
|
244
246
|
export {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
+
Ce as AdvancedFilterDialog,
|
|
248
|
+
Ce as default
|
|
247
249
|
};
|
|
@@ -9,6 +9,8 @@ export interface ColumnFilterSectionProps {
|
|
|
9
9
|
value: string;
|
|
10
10
|
}>;
|
|
11
11
|
isMultiSelect?: boolean;
|
|
12
|
+
/** Which picker to render for date columns. Default: 'date' */
|
|
13
|
+
datePickerVariant?: 'date' | 'month';
|
|
12
14
|
rules: AdvancedFilterRule[];
|
|
13
15
|
logic: 'AND' | 'OR';
|
|
14
16
|
onLogicChange: (logic: 'AND' | 'OR') => void;
|
|
@@ -1,60 +1,95 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { Button as
|
|
4
|
-
import { Input as
|
|
1
|
+
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as y } from "react";
|
|
3
|
+
import { Button as v } from "../../../button.js";
|
|
4
|
+
import { Input as h } from "../../../input.js";
|
|
5
5
|
import { DatePicker as P } from "../../../date-picker/date-picker.js";
|
|
6
|
-
import { DateRangePicker as
|
|
6
|
+
import { DateRangePicker as V } from "../../../date-picker/date-range-picker.js";
|
|
7
|
+
import { MonthPicker as z } from "../../../date-picker/month-picker.js";
|
|
8
|
+
import { MonthRangePicker as M } from "../../../date-picker/month-range-picker.js";
|
|
7
9
|
import p from "../../../select/select.js";
|
|
8
|
-
import { Bin as
|
|
9
|
-
import { createEmptyRule as
|
|
10
|
-
import { useImpactNovaI18n as
|
|
11
|
-
const
|
|
10
|
+
import { Bin as C } from "../../../../../icons/index.js";
|
|
11
|
+
import { createEmptyRule as E } from "../utils/filter-utils.js";
|
|
12
|
+
import { useImpactNovaI18n as W } from "../../../../../i18n/ImpactNovaI18nContext.js";
|
|
13
|
+
const R = {
|
|
12
14
|
text: ["contains", "notContains", "equals", "notEqual", "startsWith", "endsWith", "empty", "notEmpty"],
|
|
13
15
|
number: ["equals", "notEqual", "greaterThan", "greaterThanOrEqual", "lessThan", "lessThanOrEqual", "inRange", "empty", "notEmpty"],
|
|
14
16
|
date: ["equals", "notEqual", "greaterThan", "lessThan", "inRange"],
|
|
15
17
|
select: ["equals"],
|
|
16
18
|
multi: ["contains", "notContains", "startsWith", "endsWith", "equals", "notEqual", "empty", "notEmpty"]
|
|
17
|
-
},
|
|
18
|
-
columnId:
|
|
19
|
-
columnLabel:
|
|
19
|
+
}, Z = ({
|
|
20
|
+
columnId: g,
|
|
21
|
+
columnLabel: S,
|
|
20
22
|
columnType: l,
|
|
21
|
-
selectOptions:
|
|
22
|
-
isMultiSelect:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
selectOptions: x,
|
|
24
|
+
isMultiSelect: m,
|
|
25
|
+
datePickerVariant: O = "date",
|
|
26
|
+
rules: d,
|
|
27
|
+
logic: q,
|
|
28
|
+
onLogicChange: F,
|
|
29
|
+
onRulesChange: f,
|
|
30
|
+
canDeleteLastRule: u = !1,
|
|
31
|
+
onDeleteColumnFilter: b
|
|
29
32
|
}) => {
|
|
30
|
-
const { t: r } =
|
|
33
|
+
const { t: r } = W(), w = y(() => (R[l] ?? R.text).map((n) => ({ label: r(`filter.operators.${l === "date" && n === "greaterThan" ? "after" : l === "date" && n === "lessThan" ? "before" : l === "date" && n === "inRange" ? "between" : n}`), value: n })), [l, r]), N = y(
|
|
31
34
|
() => [
|
|
32
35
|
{ label: r("filter.logicAll"), value: "AND" },
|
|
33
36
|
{ label: r("filter.logicAny"), value: "OR" }
|
|
34
37
|
],
|
|
35
38
|
[r]
|
|
36
|
-
),
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
if (
|
|
40
|
-
const n =
|
|
41
|
-
n.length === 0 &&
|
|
39
|
+
), D = () => {
|
|
40
|
+
f([...d, E(g, l)]);
|
|
41
|
+
}, k = (e) => {
|
|
42
|
+
if (d.length > 1 || u) {
|
|
43
|
+
const n = d.filter((t) => t.id !== e);
|
|
44
|
+
n.length === 0 && u ? f([]) : f(n.length > 0 ? n : [E(g, l)]);
|
|
42
45
|
}
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
+
}, i = (e, n) => {
|
|
47
|
+
f(d.map((t) => t.id === e ? { ...t, ...n } : t));
|
|
48
|
+
}, T = (e) => {
|
|
46
49
|
if (e.operator === "empty" || e.operator === "notEmpty")
|
|
47
50
|
return /* @__PURE__ */ a("span", { className: "text-content-placeholder italic text-sm", children: r("advancedFilter.noValueNeeded") });
|
|
48
|
-
if (l === "date")
|
|
51
|
+
if (l === "date") {
|
|
52
|
+
if (O === "month") {
|
|
53
|
+
const t = (o) => {
|
|
54
|
+
if (!o) return;
|
|
55
|
+
const s = new Date(o);
|
|
56
|
+
return isNaN(s.getTime()) ? void 0 : { year: s.getFullYear(), month: s.getMonth() };
|
|
57
|
+
};
|
|
58
|
+
return e.operator === "inRange" ? /* @__PURE__ */ a(
|
|
59
|
+
M,
|
|
60
|
+
{
|
|
61
|
+
value: {
|
|
62
|
+
from: t(e.value) || { year: (/* @__PURE__ */ new Date()).getFullYear(), month: 0 },
|
|
63
|
+
to: t(e.valueTo || "")
|
|
64
|
+
},
|
|
65
|
+
onChange: (o) => {
|
|
66
|
+
const s = o?.from ? new Date(o.from.year, o.from.month, 1).toISOString() : "", I = o?.to ? new Date(o.to.year, o.to.month + 1, 0).toISOString() : "";
|
|
67
|
+
i(e.id, { value: s, valueTo: I });
|
|
68
|
+
},
|
|
69
|
+
showFooter: !0
|
|
70
|
+
}
|
|
71
|
+
) : /* @__PURE__ */ a(
|
|
72
|
+
z,
|
|
73
|
+
{
|
|
74
|
+
value: t(e.value),
|
|
75
|
+
onChange: (o) => {
|
|
76
|
+
const s = o ? new Date(o.year, o.month, 1).toISOString() : "";
|
|
77
|
+
i(e.id, { value: s });
|
|
78
|
+
},
|
|
79
|
+
placeholder: r("filter.selectMonth"),
|
|
80
|
+
showFooter: !0
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
49
84
|
return e.operator === "inRange" ? /* @__PURE__ */ a(
|
|
50
|
-
|
|
85
|
+
V,
|
|
51
86
|
{
|
|
52
87
|
value: {
|
|
53
88
|
from: e.value ? new Date(e.value) : void 0,
|
|
54
89
|
to: e.valueTo ? new Date(e.valueTo) : void 0
|
|
55
90
|
},
|
|
56
91
|
onChange: (t) => {
|
|
57
|
-
|
|
92
|
+
i(e.id, {
|
|
58
93
|
value: t?.from?.toISOString() || "",
|
|
59
94
|
valueTo: t?.to?.toISOString() || ""
|
|
60
95
|
});
|
|
@@ -65,34 +100,35 @@ const y = {
|
|
|
65
100
|
P,
|
|
66
101
|
{
|
|
67
102
|
value: e.value ? new Date(e.value) : void 0,
|
|
68
|
-
onChange: (t) =>
|
|
103
|
+
onChange: (t) => i(e.id, { value: t?.toISOString() || "" }),
|
|
69
104
|
placeholder: r("filter.selectDate"),
|
|
70
105
|
showFooter: !0
|
|
71
106
|
}
|
|
72
107
|
);
|
|
108
|
+
}
|
|
73
109
|
const n = e.operator === "equals" || e.operator === "notEqual";
|
|
74
110
|
return l === "select" || l === "multi" && n ? /* @__PURE__ */ a(
|
|
75
111
|
p,
|
|
76
112
|
{
|
|
77
|
-
options:
|
|
113
|
+
options: x || [],
|
|
78
114
|
value: (() => {
|
|
79
|
-
const t = (
|
|
80
|
-
return t.length === 0 ? null :
|
|
115
|
+
const t = (x || []).filter((o) => Array.isArray(e.value) ? e.value.includes(o.value) : String(e.value) === String(o.value));
|
|
116
|
+
return t.length === 0 ? null : m !== !1 ? t : t[0];
|
|
81
117
|
})(),
|
|
82
118
|
onChange: (t) => {
|
|
83
|
-
Array.isArray(t) ?
|
|
119
|
+
Array.isArray(t) ? i(e.id, { value: t.map((o) => o.value) }) : i(e.id, { value: t?.value || "" });
|
|
84
120
|
},
|
|
85
|
-
isMulti:
|
|
86
|
-
placeholder: r(
|
|
121
|
+
isMulti: m !== void 0 ? m : !0,
|
|
122
|
+
placeholder: r(m === !1 ? "filter.selectValue" : "filter.selectValues"),
|
|
87
123
|
className: "w-full",
|
|
88
124
|
menuPortalTarget: document.body
|
|
89
125
|
}
|
|
90
|
-
) : e.operator === "inRange" ? /* @__PURE__ */
|
|
126
|
+
) : e.operator === "inRange" ? /* @__PURE__ */ c("div", { className: "flex items-center gap-2 w-full", children: [
|
|
91
127
|
/* @__PURE__ */ a(
|
|
92
|
-
|
|
128
|
+
h,
|
|
93
129
|
{
|
|
94
130
|
value: e.value,
|
|
95
|
-
onChange: (t) =>
|
|
131
|
+
onChange: (t) => i(e.id, { value: t.target.value }),
|
|
96
132
|
placeholder: r("filter.from"),
|
|
97
133
|
type: l === "number" ? "number" : "text",
|
|
98
134
|
className: "flex-1"
|
|
@@ -100,67 +136,67 @@ const y = {
|
|
|
100
136
|
),
|
|
101
137
|
/* @__PURE__ */ a("span", { className: "text-content-placeholder shrink-0", children: r("filter.to") }),
|
|
102
138
|
/* @__PURE__ */ a(
|
|
103
|
-
|
|
139
|
+
h,
|
|
104
140
|
{
|
|
105
141
|
value: e.valueTo || "",
|
|
106
|
-
onChange: (t) =>
|
|
142
|
+
onChange: (t) => i(e.id, { valueTo: t.target.value }),
|
|
107
143
|
placeholder: r("filter.to"),
|
|
108
144
|
type: l === "number" ? "number" : "text",
|
|
109
145
|
className: "flex-1"
|
|
110
146
|
}
|
|
111
147
|
)
|
|
112
148
|
] }) : /* @__PURE__ */ a(
|
|
113
|
-
|
|
149
|
+
h,
|
|
114
150
|
{
|
|
115
151
|
value: e.value,
|
|
116
|
-
onChange: (t) =>
|
|
152
|
+
onChange: (t) => i(e.id, { value: t.target.value }),
|
|
117
153
|
placeholder: r("filter.enterValue"),
|
|
118
154
|
type: l === "number" ? "number" : "text",
|
|
119
155
|
className: "w-full"
|
|
120
156
|
}
|
|
121
157
|
);
|
|
122
|
-
},
|
|
123
|
-
const n =
|
|
124
|
-
return /* @__PURE__ */
|
|
158
|
+
}, A = (e) => {
|
|
159
|
+
const n = w.find((t) => t.value === e.operator);
|
|
160
|
+
return /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
|
|
125
161
|
/* @__PURE__ */ a("div", { className: "w-[120px] shrink-0", children: /* @__PURE__ */ a(
|
|
126
162
|
p,
|
|
127
163
|
{
|
|
128
|
-
options:
|
|
164
|
+
options: w,
|
|
129
165
|
value: n || null,
|
|
130
166
|
onChange: (t) => {
|
|
131
|
-
const
|
|
132
|
-
|
|
167
|
+
const o = t;
|
|
168
|
+
o && i(e.id, { operator: o.value });
|
|
133
169
|
},
|
|
134
170
|
placeholder: r("filter.operator"),
|
|
135
171
|
className: "w-full",
|
|
136
172
|
menuPortalTarget: document.body
|
|
137
173
|
}
|
|
138
174
|
) }),
|
|
139
|
-
/* @__PURE__ */ a("div", { className: "flex-1 min-w-0", children:
|
|
175
|
+
/* @__PURE__ */ a("div", { className: "flex-1 min-w-0", children: T(e) }),
|
|
140
176
|
/* @__PURE__ */ a(
|
|
141
|
-
|
|
177
|
+
v,
|
|
142
178
|
{
|
|
143
|
-
onClick: () =>
|
|
179
|
+
onClick: () => k(e.id),
|
|
144
180
|
variant: "tertiary",
|
|
145
181
|
size: "icon",
|
|
146
182
|
"aria-label": r("aria.removeRule"),
|
|
147
|
-
disabled:
|
|
148
|
-
children: /* @__PURE__ */ a(
|
|
183
|
+
disabled: d.length === 1 && !u,
|
|
184
|
+
children: /* @__PURE__ */ a(C, { size: "xs" })
|
|
149
185
|
}
|
|
150
186
|
)
|
|
151
187
|
] }, e.id);
|
|
152
188
|
};
|
|
153
|
-
return /* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
189
|
+
return /* @__PURE__ */ c("div", { className: "flex flex-col gap-4", children: [
|
|
190
|
+
/* @__PURE__ */ c("div", { className: "text-content-muted text-sm flex items-center gap-2 flex-wrap", children: [
|
|
155
191
|
/* @__PURE__ */ a("span", { children: r("advancedFilter.match") }),
|
|
156
192
|
/* @__PURE__ */ a("div", { className: "w-[80px]", children: /* @__PURE__ */ a(
|
|
157
193
|
p,
|
|
158
194
|
{
|
|
159
195
|
options: N,
|
|
160
|
-
value: N.find((e) => e.value ===
|
|
196
|
+
value: N.find((e) => e.value === q),
|
|
161
197
|
onChange: (e) => {
|
|
162
198
|
const n = e;
|
|
163
|
-
n &&
|
|
199
|
+
n && F(n.value);
|
|
164
200
|
},
|
|
165
201
|
className: "h-8",
|
|
166
202
|
menuPortalTarget: document.body,
|
|
@@ -168,20 +204,20 @@ const y = {
|
|
|
168
204
|
}
|
|
169
205
|
) }),
|
|
170
206
|
/* @__PURE__ */ a("span", { children: r("advancedFilter.ofTheFollowingRulesForColumn") }),
|
|
171
|
-
/* @__PURE__ */ a("span", { className: "font-semibold text-content-tertiary", children:
|
|
207
|
+
/* @__PURE__ */ a("span", { className: "font-semibold text-content-tertiary", children: S })
|
|
172
208
|
] }),
|
|
173
|
-
/* @__PURE__ */ a("div", { className: "flex flex-col gap-3", children:
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */ a(
|
|
176
|
-
|
|
177
|
-
|
|
209
|
+
/* @__PURE__ */ a("div", { className: "flex flex-col gap-3", children: d.map((e) => A(e)) }),
|
|
210
|
+
/* @__PURE__ */ c("div", { className: "flex items-center justify-between mt-1", children: [
|
|
211
|
+
/* @__PURE__ */ a(v, { onClick: D, variant: "outline", size: "sm", children: r("advancedFilter.addRule") }),
|
|
212
|
+
b && /* @__PURE__ */ c(
|
|
213
|
+
v,
|
|
178
214
|
{
|
|
179
215
|
variant: "outline",
|
|
180
216
|
size: "sm",
|
|
181
|
-
onClick:
|
|
217
|
+
onClick: b,
|
|
182
218
|
className: "text-validation hover:text-destructive hover:bg-feedback-error-surface border-destructive",
|
|
183
219
|
children: [
|
|
184
|
-
/* @__PURE__ */ a(
|
|
220
|
+
/* @__PURE__ */ a(C, { size: "xs" }),
|
|
185
221
|
r("advancedFilter.deleteColumn")
|
|
186
222
|
]
|
|
187
223
|
}
|
|
@@ -190,5 +226,5 @@ const y = {
|
|
|
190
226
|
] });
|
|
191
227
|
};
|
|
192
228
|
export {
|
|
193
|
-
|
|
229
|
+
Z as ColumnFilterSection
|
|
194
230
|
};
|