impact-nova 1.7.21 → 1.7.23

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.
@@ -1,45 +1,45 @@
1
- import { jsxs as f, jsx as r, Fragment as U } from "react/jsx-runtime";
1
+ import { jsxs as f, jsx as o, Fragment as W } from "react/jsx-runtime";
2
2
  import { useState as R } from "react";
3
- import { Dialog as W, DialogContent as X, DialogHeader as Y, DialogTitle as Z, DialogClose as _, DialogBody as I, DialogFooter as ee } from "../../../dialog.js";
4
- import { Button as C } from "../../../button.js";
5
- import { ButtonGroup as te } from "../../../button-group.js";
6
- import { Cross as le } from "../../../../../icons/index.js";
7
- import { ColumnFilterSection as z } from "./column-filter-section.js";
8
- import { createEmptyRule as N } from "../utils/filter-utils.js";
9
- import { useImpactNovaI18n as ne } from "../../../../../i18n/ImpactNovaI18nContext.js";
10
- const B = (S) => {
11
- const u = {};
3
+ import { Dialog as X, DialogContent as Y, DialogHeader as Z, DialogTitle as _, DialogClose as I, DialogBody as ee, DialogFooter as te } from "../../../dialog.js";
4
+ import { Button as v } from "../../../button.js";
5
+ import { Tooltip as le, TooltipTrigger as ne, TooltipContent as oe } from "../../../tooltip.js";
6
+ import { Cross as re } from "../../../../../icons/index.js";
7
+ import { ColumnFilterSection as B } from "./column-filter-section.js";
8
+ import { createEmptyRule as w } from "../utils/filter-utils.js";
9
+ import { useImpactNovaI18n as ae } from "../../../../../i18n/ImpactNovaI18nContext.js";
10
+ const j = (S) => {
11
+ const d = {};
12
12
  return S.forEach((m) => {
13
- m.columnId && (u[m.columnId] || (u[m.columnId] = []), u[m.columnId].push(m));
14
- }), u;
15
- }, fe = ({
13
+ m.columnId && (d[m.columnId] || (d[m.columnId] = []), d[m.columnId].push(m));
14
+ }), d;
15
+ }, be = ({
16
16
  isOpen: S,
17
- onClose: u,
17
+ onClose: d,
18
18
  onApply: m,
19
- columnId: s,
20
- columnLabel: P,
21
- columnType: v,
19
+ columnId: a,
20
+ columnLabel: J,
21
+ columnType: C,
22
22
  selectOptions: A,
23
- isMultiSelect: $,
24
- initialModel: k,
25
- api: h
23
+ isMultiSelect: G,
24
+ initialModel: E,
25
+ api: p
26
26
  // Add api to props
27
27
  }) => {
28
- const { t: d } = ne(), E = () => (k?.rules || []).filter((e) => !("logic" in e)), [y, G] = R("column"), [x, O] = R(() => {
29
- const e = {}, n = E(), t = B(n);
30
- return Object.keys(t).forEach((a) => {
31
- e[a] = k?.logic || "OR";
32
- }), e[s] || (e[s] = "OR"), e;
33
- }), [g, w] = R(() => {
34
- const e = E();
35
- if (h) {
36
- const t = h.getFilterModel();
28
+ const { t: u } = ae(), z = () => (E?.rules || []).filter((e) => !("logic" in e)), [h, q] = R("column"), [x, O] = R(() => {
29
+ const e = {}, n = z(), t = j(n);
30
+ return Object.keys(t).forEach((s) => {
31
+ e[s] = E?.logic || "OR";
32
+ }), e[a] || (e[a] = "OR"), e;
33
+ }), [g, T] = R(() => {
34
+ const e = z();
35
+ if (p) {
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 o = null;
40
+ let r = null;
41
41
  if (l.filterType === "text")
42
- o = {
42
+ r = {
43
43
  id: Math.random().toString(36).substr(2, 9),
44
44
  columnId: i,
45
45
  columnType: "text",
@@ -47,7 +47,7 @@ const B = (S) => {
47
47
  value: l.filter
48
48
  };
49
49
  else if (l.filterType === "number")
50
- o = {
50
+ r = {
51
51
  id: Math.random().toString(36).substr(2, 9),
52
52
  columnId: i,
53
53
  columnType: "number",
@@ -55,7 +55,7 @@ const B = (S) => {
55
55
  value: String(l.filter)
56
56
  };
57
57
  else if (l.filterType === "set")
58
- o = {
58
+ r = {
59
59
  id: Math.random().toString(36).substr(2, 9),
60
60
  columnId: i,
61
61
  columnType: "select",
@@ -63,8 +63,8 @@ const B = (S) => {
63
63
  value: l.values
64
64
  };
65
65
  else if (l.filterType === "multi") {
66
- const c = l.filterModels?.find((D) => D && D.filterType === "set");
67
- c && (o = {
66
+ const c = l.filterModels?.find((N) => N && N.filterType === "set");
67
+ c && (r = {
68
68
  id: Math.random().toString(36).substr(2, 9),
69
69
  columnId: i,
70
70
  columnType: "multi",
@@ -73,33 +73,33 @@ const B = (S) => {
73
73
  value: c.values
74
74
  });
75
75
  }
76
- o && e.push(o);
76
+ r && e.push(r);
77
77
  }
78
78
  });
79
79
  }
80
- return e.some((t) => t.columnId === s) || e.push(N(s, v)), e;
81
- }), [b] = R(() => ({
80
+ return e.some((t) => t.columnId === a) || e.push(w(a, C)), e;
81
+ }), [F] = R(() => ({
82
82
  allRules: g,
83
83
  // Use the computed rules (potentially synced)
84
84
  columnLogic: { ...x }
85
- })), J = JSON.stringify({ allRules: g, columnLogic: x }) !== JSON.stringify(b), T = (e) => g.filter((n) => n.columnId === e), F = (e, n) => {
86
- w((t) => {
87
- const a = /* @__PURE__ */ new Set(), i = [];
88
- t.forEach((o) => {
89
- a.has(o.columnId) || (a.add(o.columnId), i.push(o.columnId));
90
- }), a.has(e) || i.push(e);
85
+ })), H = JSON.stringify({ allRules: g, columnLogic: x }) !== JSON.stringify(F), $ = (e) => g.filter((n) => n.columnId === e), D = (e, n) => {
86
+ T((t) => {
87
+ const s = /* @__PURE__ */ new Set(), i = [];
88
+ t.forEach((r) => {
89
+ s.has(r.columnId) || (s.add(r.columnId), i.push(r.columnId));
90
+ }), s.has(e) || i.push(e);
91
91
  const l = [];
92
- return i.forEach((o) => {
93
- o === e ? l.push(...n) : l.push(...t.filter((c) => c.columnId === o));
92
+ return i.forEach((r) => {
93
+ r === e ? l.push(...n) : l.push(...t.filter((c) => c.columnId === r));
94
94
  }), l;
95
95
  });
96
96
  }, L = (e) => x[e] || "OR", M = (e, n) => {
97
97
  O((t) => ({ ...t, [e]: n }));
98
- }, H = () => {
99
- y === "column" ? (F(s, [N(s, v)]), M(s, "OR")) : (w([N(s, v)]), O({ [s]: "OR" }));
100
- }, V = () => {
101
- w(b.allRules.length > 0 ? b.allRules : [N(s, v)]), O(b.columnLogic);
102
98
  }, K = () => {
99
+ h === "column" ? (D(a, [w(a, C)]), M(a, "OR")) : (T([w(a, C)]), O({ [a]: "OR" }));
100
+ }, Q = () => {
101
+ T(F.allRules.length > 0 ? F.allRules : [w(a, C)]), O(F.columnLogic);
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);
@@ -107,110 +107,141 @@ const B = (S) => {
107
107
  const n = e[0].columnId;
108
108
  m({ logic: L(n), rules: e });
109
109
  }
110
- u();
111
- }, Q = B(g), j = Object.keys(Q), q = (e, n) => {
112
- if (!h) return n;
113
- const t = h.getColumn(e);
110
+ d();
111
+ }, V = j(g), k = Object.keys(V), y = Object.keys(j(
112
+ g.filter((e) => e.operator === "empty" || e.operator === "notEmpty" ? !!e.columnId : e.columnId && e.value !== "" && e.value !== null)
113
+ )).length <= 1, P = (e, n) => {
114
+ if (!p) return n;
115
+ const t = p.getColumn(e);
114
116
  if (!t) return n;
115
- const a = t.getColDef(), i = [];
117
+ const s = t.getColDef(), i = [];
116
118
  let l = t.getParent();
117
119
  for (; l; ) {
118
120
  const c = l.getColGroupDef();
119
121
  c && c.headerName && i.unshift(c.headerName), l = l.getParent();
120
122
  }
121
- const o = a?.headerName || e;
122
- return i.push(o), i.join(" > ");
123
+ const r = s?.headerName || e;
124
+ return i.push(r), i.join(" > ");
123
125
  };
124
- return /* @__PURE__ */ f(W, { open: S, onOpenChange: u, children: [
126
+ return /* @__PURE__ */ f(X, { open: S, onOpenChange: d, children: [
125
127
  (console.log("[AdvancedFilterDialog] Current State:", {
126
- mode: y,
128
+ mode: h,
127
129
  allRules: g,
128
130
  columnLogic: x,
129
- activeColumns: j
131
+ activeColumns: k
130
132
  }), null),
131
- /* @__PURE__ */ f(X, { className: "w-[800px] max-w-[95vw] max-h-[90vh] flex flex-col p-0", hideClose: !0, children: [
132
- /* @__PURE__ */ f(Y, { className: "flex flex-row items-center justify-between px-4 py-3", children: [
133
- /* @__PURE__ */ r(Z, { children: d("advancedFilter.title") }),
134
- /* @__PURE__ */ r(_, { asChild: !0, children: /* @__PURE__ */ r(C, { variant: "ghost", size: "icon", className: "h-8 w-8 p-0 text-content-tertiary hover:text-brand-variant-hover", onClick: u, "aria-label": d("aria.close"), children: /* @__PURE__ */ r(le, { size: 14 }) }) })
133
+ /* @__PURE__ */ f(Y, { className: "w-[800px] max-w-[95vw] max-h-[90vh] flex flex-col p-0", hideClose: !0, children: [
134
+ /* @__PURE__ */ f(Z, { className: "flex flex-row items-center justify-between px-4 py-3", children: [
135
+ /* @__PURE__ */ o(_, { children: u("advancedFilter.title") }),
136
+ /* @__PURE__ */ o(I, { asChild: !0, children: /* @__PURE__ */ o(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__ */ o(re, { size: 14 }) }) })
135
137
  ] }),
136
138
  /* @__PURE__ */ f("div", { className: "flex items-center justify-between px-4 py-4 pb-2", children: [
137
- /* @__PURE__ */ f(
138
- te,
139
- {
140
- value: y,
141
- onValueChange: (e) => G(e),
142
- children: [
143
- /* @__PURE__ */ r(C, { value: "column", size: "md", children: d("advancedFilter.currentColumn") }),
144
- /* @__PURE__ */ r(C, { value: "global", size: "md", children: d("advancedFilter.allFilters") })
145
- ]
146
- }
147
- ),
148
- /* @__PURE__ */ r(C, { variant: "ghost", onClick: H, className: "!text-brand", children: d("advancedFilter.clearAll") })
139
+ /* @__PURE__ */ f("div", { className: "inline-flex", role: "group", "data-component": "button-group", children: [
140
+ /* @__PURE__ */ o(
141
+ v,
142
+ {
143
+ value: "column",
144
+ size: "md",
145
+ variant: "ghost",
146
+ "aria-pressed": h === "column",
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: () => q("column"),
149
+ children: u("advancedFilter.currentColumn")
150
+ }
151
+ ),
152
+ /* @__PURE__ */ f(le, { children: [
153
+ /* @__PURE__ */ o(ne, { asChild: !0, children: /* @__PURE__ */ o(
154
+ "span",
155
+ {
156
+ style: {
157
+ cursor: y ? "not-allowed" : "default",
158
+ display: "inline-flex"
159
+ },
160
+ children: /* @__PURE__ */ o(
161
+ v,
162
+ {
163
+ value: "global",
164
+ size: "md",
165
+ variant: "ghost",
166
+ "aria-pressed": h === "global",
167
+ disabled: y,
168
+ style: y ? { pointerEvents: "none" } : void 0,
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: () => q("global"),
171
+ children: u("advancedFilter.allFilters")
172
+ }
173
+ )
174
+ }
175
+ ) }),
176
+ y && /* @__PURE__ */ o(oe, { variant: "tertiary", children: u("advancedFilter.allFiltersDisabledTooltip") })
177
+ ] })
178
+ ] }),
179
+ /* @__PURE__ */ o(v, { variant: "ghost", onClick: K, className: "!text-brand", children: u("advancedFilter.clearAll") })
149
180
  ] }),
150
- /* @__PURE__ */ r(I, { 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: y === "column" ? (
181
+ /* @__PURE__ */ o(ee, { className: "px-0 py-4 flex-1 overflow-y-auto min-h-0", children: /* @__PURE__ */ o("div", { className: "flex flex-col gap-6 w-full px-4", children: h === "column" ? (
151
182
  // Column Mode: Single column section
152
- /* @__PURE__ */ r(
153
- z,
183
+ /* @__PURE__ */ o(
184
+ B,
154
185
  {
155
- columnId: s,
156
- columnLabel: q(s, P),
157
- columnType: v,
186
+ columnId: a,
187
+ columnLabel: P(a, J),
188
+ columnType: C,
158
189
  selectOptions: A,
159
- isMultiSelect: A ? !!$ : !0,
160
- rules: T(s),
161
- logic: L(s),
162
- onLogicChange: (e) => M(s, e),
163
- onRulesChange: (e) => F(s, e)
190
+ isMultiSelect: A ? !!G : !0,
191
+ rules: $(a),
192
+ logic: L(a),
193
+ onLogicChange: (e) => M(a, e),
194
+ onRulesChange: (e) => D(a, e)
164
195
  }
165
196
  )
166
197
  ) : (
167
198
  // Global Mode: All columns with filters
168
- /* @__PURE__ */ r(U, { children: j.length === 0 ? /* @__PURE__ */ r("div", { className: "text-center py-8 text-content-placeholder", children: d("advancedFilter.noFiltersApplied") }) : j.map((e, n) => {
199
+ /* @__PURE__ */ o(W, { children: k.length === 0 ? /* @__PURE__ */ o("div", { className: "text-center py-8 text-content-placeholder", children: u("advancedFilter.noFiltersApplied") }) : k.map((e, n) => {
169
200
  let t = null;
170
- if (h) {
171
- const p = h.getColumn(e);
172
- p && (t = p.getColDef());
201
+ if (p) {
202
+ const b = p.getColumn(e);
203
+ b && (t = b.getColDef());
173
204
  }
174
- const a = t?.headerComponentParams, i = t?.headerName || e, l = q(e, i), o = t?.filter === "agNumberColumnFilter" ? "number" : t?.filter === "agDateColumnFilter" ? "date" : t?.filter === "agMultiColumnFilter" ? "multi" : t?.filter === "agSetColumnFilter" || a?.selectOptions ? "select" : "text";
175
- console.log(`[AdvancedFilterDialog] Column: ${e}, Type: ${o}, Filter: ${t?.filter}`);
176
- const c = a?.selectOptions, D = a?.isMultiSelect;
205
+ const s = t?.headerComponentParams, i = t?.headerName || e, l = P(e, i), r = t?.filter === "agNumberColumnFilter" ? "number" : t?.filter === "agDateColumnFilter" ? "date" : t?.filter === "agMultiColumnFilter" ? "multi" : t?.filter === "agSetColumnFilter" || s?.selectOptions ? "select" : "text";
206
+ console.log(`[AdvancedFilterDialog] Column: ${e}, Type: ${r}, Filter: ${t?.filter}`);
207
+ const c = s?.selectOptions, N = s?.isMultiSelect;
177
208
  return /* @__PURE__ */ f("div", { children: [
178
- n > 0 && /* @__PURE__ */ r("hr", { className: "border-stroke-hairline mb-6" }),
179
- /* @__PURE__ */ r(
180
- z,
209
+ n > 0 && /* @__PURE__ */ o("hr", { className: "border-stroke-hairline mb-6" }),
210
+ /* @__PURE__ */ o(
211
+ B,
181
212
  {
182
213
  columnId: e,
183
214
  columnLabel: l,
184
- columnType: o,
215
+ columnType: r,
185
216
  selectOptions: c,
186
- isMultiSelect: D,
187
- rules: T(e),
217
+ isMultiSelect: N,
218
+ rules: $(e),
188
219
  logic: L(e),
189
- onLogicChange: (p) => M(e, p),
190
- onRulesChange: (p) => F(e, p),
220
+ onLogicChange: (b) => M(e, b),
221
+ onRulesChange: (b) => D(e, b),
191
222
  canDeleteLastRule: !0,
192
- onDeleteColumnFilter: () => F(e, [])
223
+ onDeleteColumnFilter: () => D(e, [])
193
224
  }
194
225
  )
195
226
  ] }, e);
196
227
  }) })
197
228
  ) }) }),
198
- /* @__PURE__ */ r(ee, { className: "flex justify-end border-t border-[#D9DDE7]", children: /* @__PURE__ */ f("div", { className: "flex gap-3", children: [
199
- /* @__PURE__ */ r(
200
- C,
229
+ /* @__PURE__ */ o(te, { className: "flex justify-end border-t border-[#D9DDE7]", children: /* @__PURE__ */ f("div", { className: "flex gap-3", children: [
230
+ /* @__PURE__ */ o(
231
+ v,
201
232
  {
202
- onClick: V,
233
+ onClick: Q,
203
234
  variant: "secondary",
204
- disabled: !J,
205
- children: d("advancedFilter.discard")
235
+ disabled: !H,
236
+ children: u("advancedFilter.discard")
206
237
  }
207
238
  ),
208
- /* @__PURE__ */ r(C, { onClick: K, variant: "default", children: d("advancedFilter.apply") })
239
+ /* @__PURE__ */ o(v, { onClick: U, variant: "default", children: u("advancedFilter.apply") })
209
240
  ] }) })
210
241
  ] })
211
242
  ] });
212
243
  };
213
244
  export {
214
- fe as AdvancedFilterDialog,
215
- fe as default
245
+ be as AdvancedFilterDialog,
246
+ be as default
216
247
  };