arame-data-grid-pro 1.0.6 → 1.0.8
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/README.md +3 -3
- package/dist/advanced-filter-table/advanced-filter-data-table.element.d.ts +1 -1
- package/dist/advanced-filter-table/expression-engine.d.ts +2 -2
- package/dist/advanced-filter-table/index.cjs +5 -5
- package/dist/advanced-filter-table/index.cjs.map +1 -1
- package/dist/advanced-filter-table/index.js +165 -160
- package/dist/advanced-filter-table/index.js.map +1 -1
- package/dist/advanced-filter-table/types.d.ts +21 -14
- package/dist/{base-table-controller-BXMQn5v2.cjs → base-table-controller-CAWc7Hre.cjs} +2 -2
- package/dist/base-table-controller-CAWc7Hre.cjs.map +1 -0
- package/dist/{base-table-controller-DWbA88mL.js → base-table-controller-DO-etV2a.js} +3 -2
- package/dist/base-table-controller-DO-etV2a.js.map +1 -0
- package/dist/calculated-table/calculated-data-table.element.d.ts +2 -2
- package/dist/calculated-table/calculation-engine.d.ts +4 -4
- package/dist/calculated-table/index.cjs +2 -2
- package/dist/calculated-table/index.cjs.map +1 -1
- package/dist/calculated-table/index.js +2 -2
- package/dist/calculated-table/index.js.map +1 -1
- package/dist/calculated-table/types.d.ts +13 -13
- package/dist/column-visibility-table/column-visibility-table.element.d.ts +1 -1
- package/dist/column-visibility-table/index.cjs +1 -1
- package/dist/column-visibility-table/index.cjs.map +1 -1
- package/dist/column-visibility-table/index.js +1 -1
- package/dist/column-visibility-table/index.js.map +1 -1
- package/dist/column-visibility-table/types.d.ts +7 -7
- package/dist/common/base-table-controller.d.ts +5 -5
- package/dist/common/base-table-types.d.ts +7 -7
- package/dist/common/configurable-table-types.d.ts +1 -1
- package/dist/common/index.cjs +1 -1
- package/dist/common/index.cjs.map +1 -1
- package/dist/common/index.js +1 -1
- package/dist/common/index.js.map +1 -1
- package/dist/common/table-state-manager.d.ts +4 -4
- package/dist/common/universal-exporter.d.ts +6 -6
- package/dist/context-menu-table/context-menu-data-table.element.d.ts +1 -1
- package/dist/context-menu-table/index.cjs +1 -1
- package/dist/context-menu-table/index.cjs.map +1 -1
- package/dist/context-menu-table/index.js +1 -1
- package/dist/context-menu-table/index.js.map +1 -1
- package/dist/context-menu-table/types.d.ts +11 -11
- package/dist/core/data-engine.d.ts +1 -1
- package/dist/editable-table/editable-data-table.element.d.ts +3 -3
- package/dist/editable-table/index.cjs +1 -1
- package/dist/editable-table/index.cjs.map +1 -1
- package/dist/editable-table/index.js +1 -1
- package/dist/editable-table/index.js.map +1 -1
- package/dist/editable-table/types.d.ts +22 -22
- package/dist/expandable-table/expandable-data-table.element.d.ts +1 -1
- package/dist/expandable-table/index.cjs +1 -1
- package/dist/expandable-table/index.cjs.map +1 -1
- package/dist/expandable-table/index.js +40 -39
- package/dist/expandable-table/index.js.map +1 -1
- package/dist/expandable-table/types.d.ts +8 -8
- package/dist/filterable-table/filter-engine.d.ts +1 -1
- package/dist/filterable-table/filterable-data-table.element.d.ts +2 -2
- package/dist/filterable-table/index.cjs +1 -1
- package/dist/filterable-table/index.cjs.map +1 -1
- package/dist/filterable-table/index.js +69 -68
- package/dist/filterable-table/index.js.map +1 -1
- package/dist/filterable-table/types.d.ts +12 -12
- package/dist/grouped-table/group-engine.d.ts +2 -2
- package/dist/grouped-table/grouped-data-table.element.d.ts +1 -1
- package/dist/grouped-table/index.cjs +1 -1
- package/dist/grouped-table/index.cjs.map +1 -1
- package/dist/grouped-table/index.js +1 -1
- package/dist/grouped-table/index.js.map +1 -1
- package/dist/grouped-table/types.d.ts +13 -13
- package/dist/header-filter-table/filter-engine.d.ts +2 -2
- package/dist/header-filter-table/header-filter-data-table.element.d.ts +1 -1
- package/dist/header-filter-table/index.cjs +2 -2
- package/dist/header-filter-table/index.cjs.map +1 -1
- package/dist/header-filter-table/index.js +3 -2
- package/dist/header-filter-table/index.js.map +1 -1
- package/dist/header-filter-table/types.d.ts +10 -10
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +188 -187
- package/dist/index.js.map +1 -1
- package/dist/infinite-table/index.cjs +1 -1
- package/dist/infinite-table/index.cjs.map +1 -1
- package/dist/infinite-table/index.js +1 -1
- package/dist/infinite-table/index.js.map +1 -1
- package/dist/infinite-table/infinite-data-table.element.d.ts +1 -1
- package/dist/infinite-table/types.d.ts +11 -11
- package/dist/sticky-table/index.cjs +1 -1
- package/dist/sticky-table/index.cjs.map +1 -1
- package/dist/sticky-table/index.js +1 -1
- package/dist/sticky-table/index.js.map +1 -1
- package/dist/sticky-table/sticky-data-table.element.d.ts +1 -1
- package/dist/sticky-table/types.d.ts +7 -7
- package/dist/tree-table/index.cjs +4 -4
- package/dist/tree-table/index.cjs.map +1 -1
- package/dist/tree-table/index.js +96 -95
- package/dist/tree-table/index.js.map +1 -1
- package/dist/tree-table/tree-data-table.element.d.ts +1 -1
- package/dist/tree-table/tree-engine.d.ts +6 -6
- package/dist/tree-table/types.d.ts +11 -11
- package/dist/types.d.ts +22 -22
- package/dist/ui/pro-data-grid.element.d.ts +1 -1
- package/package.json +1 -1
- package/dist/base-table-controller-BXMQn5v2.cjs.map +0 -1
- package/dist/base-table-controller-DWbA88mL.js.map +0 -1
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
var E = Object.defineProperty;
|
|
2
|
-
var C = (
|
|
3
|
-
var d = (
|
|
4
|
-
function _(
|
|
5
|
-
return "logic" in
|
|
2
|
+
var C = (l, c, e) => c in l ? E(l, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[c] = e;
|
|
3
|
+
var d = (l, c, e) => C(l, typeof c != "symbol" ? c + "" : c, e);
|
|
4
|
+
function _(l) {
|
|
5
|
+
return "logic" in l && Array.isArray(l.rules);
|
|
6
6
|
}
|
|
7
|
-
function N(
|
|
8
|
-
const e = /* @__PURE__ */ new Date(), t = c.getTime(),
|
|
9
|
-
switch (
|
|
7
|
+
function N(l, c) {
|
|
8
|
+
const e = /* @__PURE__ */ new Date(), t = c.getTime(), i = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), a = new Date(e.getFullYear(), e.getMonth(), e.getDate(), 23, 59, 59, 999).getTime();
|
|
9
|
+
switch (l) {
|
|
10
10
|
case "today":
|
|
11
|
-
return t >=
|
|
11
|
+
return t >= i && t <= a;
|
|
12
12
|
case "yesterday": {
|
|
13
|
-
const
|
|
14
|
-
return t >=
|
|
13
|
+
const s = i - 864e5, r = a - 864e5;
|
|
14
|
+
return t >= s && t <= r;
|
|
15
15
|
}
|
|
16
16
|
case "last7Days": {
|
|
17
|
-
const
|
|
18
|
-
return t >=
|
|
17
|
+
const s = i - 6048e5;
|
|
18
|
+
return t >= s && t <= a;
|
|
19
19
|
}
|
|
20
20
|
case "last30Days": {
|
|
21
|
-
const
|
|
22
|
-
return t >=
|
|
21
|
+
const s = i - 2592e6;
|
|
22
|
+
return t >= s && t <= a;
|
|
23
23
|
}
|
|
24
24
|
case "thisMonth": {
|
|
25
|
-
const
|
|
26
|
-
return t >=
|
|
25
|
+
const s = new Date(e.getFullYear(), e.getMonth(), 1).getTime(), r = new Date(e.getFullYear(), e.getMonth() + 1, 0, 23, 59, 59, 999).getTime();
|
|
26
|
+
return t >= s && t <= r;
|
|
27
27
|
}
|
|
28
28
|
case "lastMonth": {
|
|
29
|
-
const
|
|
30
|
-
return t >=
|
|
29
|
+
const s = new Date(e.getFullYear(), e.getMonth() - 1, 1).getTime(), r = new Date(e.getFullYear(), e.getMonth(), 0, 23, 59, 59, 999).getTime();
|
|
30
|
+
return t >= s && t <= r;
|
|
31
31
|
}
|
|
32
32
|
case "thisYear": {
|
|
33
|
-
const
|
|
34
|
-
return t >=
|
|
33
|
+
const s = new Date(e.getFullYear(), 0, 1).getTime(), r = new Date(e.getFullYear(), 11, 31, 23, 59, 59, 999).getTime();
|
|
34
|
+
return t >= s && t <= r;
|
|
35
35
|
}
|
|
36
36
|
default:
|
|
37
37
|
return !0;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function w(
|
|
41
|
-
const t =
|
|
40
|
+
function w(l, c, e) {
|
|
41
|
+
const t = l[c.field];
|
|
42
42
|
if (c.operator === "custom" && c.customOperatorName && e) {
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
return
|
|
43
|
+
const s = e.find((r) => r.name === c.customOperatorName);
|
|
44
|
+
if (s)
|
|
45
|
+
return s.predicate(t, c.value, l);
|
|
46
46
|
}
|
|
47
|
-
const { operator:
|
|
48
|
-
switch (
|
|
47
|
+
const { operator: i, value: a } = c;
|
|
48
|
+
switch (i) {
|
|
49
49
|
case "equals":
|
|
50
50
|
return String(t).toLowerCase() === String(a).toLowerCase();
|
|
51
51
|
case "notEquals":
|
|
@@ -59,88 +59,89 @@ function w(o, c, e) {
|
|
|
59
59
|
case "endsWith":
|
|
60
60
|
return String(t).toLowerCase().endsWith(String(a).toLowerCase().trim());
|
|
61
61
|
case "greaterThan": {
|
|
62
|
-
const
|
|
63
|
-
return isNaN(
|
|
62
|
+
const s = Number(t), r = Number(a);
|
|
63
|
+
return isNaN(s) || isNaN(r) ? !1 : s > r;
|
|
64
64
|
}
|
|
65
65
|
case "greaterThanOrEqual": {
|
|
66
|
-
const
|
|
67
|
-
return isNaN(
|
|
66
|
+
const s = Number(t), r = Number(a);
|
|
67
|
+
return isNaN(s) || isNaN(r) ? !1 : s >= r;
|
|
68
68
|
}
|
|
69
69
|
case "lessThan": {
|
|
70
|
-
const
|
|
71
|
-
return isNaN(
|
|
70
|
+
const s = Number(t), r = Number(a);
|
|
71
|
+
return isNaN(s) || isNaN(r) ? !1 : s < r;
|
|
72
72
|
}
|
|
73
73
|
case "lessThanOrEqual": {
|
|
74
|
-
const
|
|
75
|
-
return isNaN(
|
|
74
|
+
const s = Number(t), r = Number(a);
|
|
75
|
+
return isNaN(s) || isNaN(r) ? !1 : s <= r;
|
|
76
76
|
}
|
|
77
77
|
case "between": {
|
|
78
|
-
const
|
|
79
|
-
if (isNaN(
|
|
80
|
-
const
|
|
81
|
-
return !(!isNaN(
|
|
78
|
+
const s = Number(t);
|
|
79
|
+
if (isNaN(s)) return !1;
|
|
80
|
+
const r = Number(a == null ? void 0 : a.min), n = Number(a == null ? void 0 : a.max);
|
|
81
|
+
return !(!isNaN(r) && s < r || !isNaN(n) && s > n);
|
|
82
82
|
}
|
|
83
83
|
case "in":
|
|
84
|
-
return (Array.isArray(a) ? a : [a]).some((
|
|
84
|
+
return (Array.isArray(a) ? a : [a]).some((r) => String(r).toLowerCase() === String(t).toLowerCase());
|
|
85
85
|
case "notIn":
|
|
86
|
-
return !(Array.isArray(a) ? a : [a]).some((
|
|
86
|
+
return !(Array.isArray(a) ? a : [a]).some((r) => String(r).toLowerCase() === String(t).toLowerCase());
|
|
87
87
|
case "dateBefore": {
|
|
88
88
|
if (!t || !a) return !1;
|
|
89
|
-
const
|
|
90
|
-
return !isNaN(
|
|
89
|
+
const s = new Date(t).getTime(), r = new Date(a).getTime();
|
|
90
|
+
return !isNaN(s) && !isNaN(r) && s < r;
|
|
91
91
|
}
|
|
92
92
|
case "dateAfter": {
|
|
93
93
|
if (!t || !a) return !1;
|
|
94
|
-
const
|
|
95
|
-
return !isNaN(
|
|
94
|
+
const s = new Date(t).getTime(), r = new Date(a).getTime();
|
|
95
|
+
return !isNaN(s) && !isNaN(r) && s > r;
|
|
96
96
|
}
|
|
97
97
|
case "dateOn": {
|
|
98
98
|
if (!t || !a) return !1;
|
|
99
|
-
const
|
|
100
|
-
return
|
|
99
|
+
const s = new Date(t), r = new Date(a);
|
|
100
|
+
return s.toISOString().split("T")[0] === r.toISOString().split("T")[0];
|
|
101
101
|
}
|
|
102
102
|
case "dateBetween": {
|
|
103
103
|
if (!t || !a) return !1;
|
|
104
|
-
const
|
|
105
|
-
if (isNaN(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
const s = new Date(t).getTime();
|
|
105
|
+
if (isNaN(s)) return !1;
|
|
106
|
+
const r = a;
|
|
107
|
+
if (r != null && r.start) {
|
|
108
|
+
const n = new Date(r.start).getTime();
|
|
109
|
+
if (s < n) return !1;
|
|
109
110
|
}
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
111
|
+
if (r != null && r.end) {
|
|
112
|
+
const n = new Date(r.end).setHours(23, 59, 59, 999);
|
|
113
|
+
if (s > n) return !1;
|
|
113
114
|
}
|
|
114
115
|
return !0;
|
|
115
116
|
}
|
|
116
117
|
case "dateRelative": {
|
|
117
118
|
if (!t || !a) return !1;
|
|
118
|
-
const
|
|
119
|
-
return isNaN(
|
|
119
|
+
const s = new Date(t);
|
|
120
|
+
return isNaN(s.getTime()) ? !1 : N(a, s);
|
|
120
121
|
}
|
|
121
122
|
default:
|
|
122
123
|
return !0;
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
function y(
|
|
126
|
-
return !c || !c.rules || c.rules.length === 0 ? !0 : c.logic === "AND" ? c.rules.every((t) => _(t) ? y(
|
|
126
|
+
function y(l, c, e) {
|
|
127
|
+
return !c || !c.rules || c.rules.length === 0 ? !0 : c.logic === "AND" ? c.rules.every((t) => _(t) ? y(l, t, e) : w(l, t, e)) : c.rules.some((t) => _(t) ? y(l, t, e) : w(l, t, e));
|
|
127
128
|
}
|
|
128
|
-
function v(
|
|
129
|
+
function v(l) {
|
|
129
130
|
const c = [];
|
|
130
|
-
if (!
|
|
131
|
-
for (const e of
|
|
131
|
+
if (!l || !l.rules) return c;
|
|
132
|
+
for (const e of l.rules)
|
|
132
133
|
_(e) ? c.push(...v(e)) : c.push(e);
|
|
133
134
|
return c;
|
|
134
135
|
}
|
|
135
|
-
function L(
|
|
136
|
+
function L(l) {
|
|
136
137
|
try {
|
|
137
|
-
return JSON.stringify(
|
|
138
|
+
return JSON.stringify(l);
|
|
138
139
|
} catch {
|
|
139
140
|
return "";
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
|
-
function S(
|
|
143
|
-
const e = c.find((
|
|
143
|
+
function S(l, c) {
|
|
144
|
+
const e = c.find((r) => String(r.key) === l.field), t = e ? e.header : l.field, a = {
|
|
144
145
|
equals: "=",
|
|
145
146
|
notEquals: "≠",
|
|
146
147
|
contains: "contains",
|
|
@@ -159,9 +160,13 @@ function S(o, c) {
|
|
|
159
160
|
dateOn: "on",
|
|
160
161
|
dateBetween: "between",
|
|
161
162
|
dateRelative: "is"
|
|
162
|
-
}[
|
|
163
|
-
let
|
|
164
|
-
|
|
163
|
+
}[l.operator] || l.operator;
|
|
164
|
+
let s = String(l.value);
|
|
165
|
+
if (typeof l.value == "object" && l.value !== null) {
|
|
166
|
+
const r = l.value;
|
|
167
|
+
r && (r.min !== void 0 || r.max !== void 0) ? s = `${r.min ?? 0} .. ${r.max ?? "∞"}` : r && (r.start || r.end) ? s = `${r.start ?? ""} .. ${r.end ?? ""}` : s = JSON.stringify(l.value);
|
|
168
|
+
}
|
|
169
|
+
return `${t} ${a} ${s}`;
|
|
165
170
|
}
|
|
166
171
|
class k extends HTMLElement {
|
|
167
172
|
constructor() {
|
|
@@ -221,16 +226,16 @@ class k extends HTMLElement {
|
|
|
221
226
|
this.loadPersistedPresets(), this.renderDomStructure(), this.setupEventListeners(), this._options.dataLoader ? this.fetchServerData() : this.refresh();
|
|
222
227
|
}
|
|
223
228
|
disconnectedCallback() {
|
|
224
|
-
this._abortController && this._abortController.abort(), this._searchDebounceTimer && clearTimeout(this._searchDebounceTimer);
|
|
229
|
+
this._abortController && this._abortController.abort(), this._searchDebounceTimer && this._searchDebounceTimer && clearTimeout(this._searchDebounceTimer);
|
|
225
230
|
}
|
|
226
|
-
attributeChangedCallback(e, t,
|
|
227
|
-
if (e === "search-term" &&
|
|
228
|
-
this.setSearchTerm(
|
|
229
|
-
else if (e === "page" &&
|
|
230
|
-
const a = parseInt(
|
|
231
|
+
attributeChangedCallback(e, t, i) {
|
|
232
|
+
if (e === "search-term" && i !== null)
|
|
233
|
+
this.setSearchTerm(i);
|
|
234
|
+
else if (e === "page" && i !== null) {
|
|
235
|
+
const a = parseInt(i, 10);
|
|
231
236
|
!isNaN(a) && a > 0 && this.setPage(a);
|
|
232
|
-
} else if (e === "page-size" &&
|
|
233
|
-
const a = parseInt(
|
|
237
|
+
} else if (e === "page-size" && i !== null) {
|
|
238
|
+
const a = parseInt(i, 10);
|
|
234
239
|
!isNaN(a) && a > 0 && this.setPageSize(a);
|
|
235
240
|
}
|
|
236
241
|
}
|
|
@@ -251,14 +256,14 @@ class k extends HTMLElement {
|
|
|
251
256
|
return this._options;
|
|
252
257
|
}
|
|
253
258
|
set options(e) {
|
|
254
|
-
var t,
|
|
259
|
+
var t, i;
|
|
255
260
|
this._options = {
|
|
256
261
|
...this._options,
|
|
257
262
|
...e,
|
|
258
263
|
pagination: { ...this._options.pagination, ...e.pagination },
|
|
259
264
|
sorting: { ...this._options.sorting, ...e.sorting },
|
|
260
265
|
search: { ...this._options.search, ...e.search }
|
|
261
|
-
}, e.presets && (this._presets = [...e.presets]), (t = e.pagination) != null && t.pageSize && (this._pageSize = e.pagination.pageSize), ((
|
|
266
|
+
}, e.presets && (this._presets = [...e.presets]), (t = e.pagination) != null && t.pageSize && (this._pageSize = e.pagination.pageSize), ((i = e.sorting) == null ? void 0 : i.initialSort) !== void 0 && (this._sortRule = e.sorting.initialSort), this.isConnected && (this.renderHeader(), this.renderPresetsSelect(), this.renderQuickFilters(), this._options.dataLoader && e.dataLoader ? this.fetchServerData() : this.refresh());
|
|
262
267
|
}
|
|
263
268
|
get expression() {
|
|
264
269
|
return this._activeExpression;
|
|
@@ -271,8 +276,8 @@ class k extends HTMLElement {
|
|
|
271
276
|
this._activeExpression.rules.push(e), this._currentPage = 1, this.onExpressionChanged();
|
|
272
277
|
}
|
|
273
278
|
removeRule(e) {
|
|
274
|
-
function t(
|
|
275
|
-
|
|
279
|
+
function t(i) {
|
|
280
|
+
i.rules = i.rules.filter((a) => "logic" in a ? (t(a), a.rules.length > 0) : a.id !== e);
|
|
276
281
|
}
|
|
277
282
|
t(this._activeExpression), this._currentPage = 1, this.onExpressionChanged();
|
|
278
283
|
}
|
|
@@ -287,23 +292,23 @@ class k extends HTMLElement {
|
|
|
287
292
|
id: a.id,
|
|
288
293
|
label: S(a, this._columns),
|
|
289
294
|
rule: a
|
|
290
|
-
})),
|
|
295
|
+
})), i = {
|
|
291
296
|
expression: this._activeExpression,
|
|
292
297
|
flatRules: e,
|
|
293
298
|
activeChips: t
|
|
294
299
|
};
|
|
295
|
-
this.dispatchEvent(new CustomEvent("advanced-filter:expression-change", { detail:
|
|
300
|
+
this.dispatchEvent(new CustomEvent("advanced-filter:expression-change", { detail: i, bubbles: !0, composed: !0 })), this.renderActiveChips(), this.renderBuilderDrawer(), this._options.dataLoader ? this.fetchServerData() : this.refresh();
|
|
296
301
|
}
|
|
297
302
|
// --- Presets Persistence & Management ---
|
|
298
303
|
applyPreset(e) {
|
|
299
304
|
const t = this._presets.find((a) => a.id === e);
|
|
300
305
|
if (!t) return;
|
|
301
306
|
this._activePresetId = e, this._activeExpression = JSON.parse(JSON.stringify(t.expression)), t.searchTerm !== void 0 && this.setSearchTerm(t.searchTerm), this._currentPage = 1, this._presetSelect && (this._presetSelect.value = e);
|
|
302
|
-
const
|
|
307
|
+
const i = {
|
|
303
308
|
preset: t,
|
|
304
309
|
expression: this._activeExpression
|
|
305
310
|
};
|
|
306
|
-
this.dispatchEvent(new CustomEvent("advanced-filter:preset-change", { detail:
|
|
311
|
+
this.dispatchEvent(new CustomEvent("advanced-filter:preset-change", { detail: i, bubbles: !0, composed: !0 })), this.onExpressionChanged();
|
|
307
312
|
}
|
|
308
313
|
saveCurrentAsPreset(e) {
|
|
309
314
|
const t = {
|
|
@@ -322,7 +327,7 @@ class k extends HTMLElement {
|
|
|
322
327
|
const e = this._options.persistPresetsKey;
|
|
323
328
|
if (!(!e || typeof localStorage > "u"))
|
|
324
329
|
try {
|
|
325
|
-
const t = this._presets.filter((
|
|
330
|
+
const t = this._presets.filter((i) => i.isRemovable);
|
|
326
331
|
localStorage.setItem(e, JSON.stringify(t));
|
|
327
332
|
} catch (t) {
|
|
328
333
|
console.warn("[advanced-filter-table] Failed to persist presets:", t);
|
|
@@ -334,8 +339,8 @@ class k extends HTMLElement {
|
|
|
334
339
|
try {
|
|
335
340
|
const t = localStorage.getItem(e);
|
|
336
341
|
if (t) {
|
|
337
|
-
const
|
|
338
|
-
Array.isArray(
|
|
342
|
+
const i = JSON.parse(t);
|
|
343
|
+
Array.isArray(i) && (this._presets = [...this._options.presets || [], ...i]);
|
|
339
344
|
}
|
|
340
345
|
} catch (t) {
|
|
341
346
|
console.warn("[advanced-filter-table] Failed to load presets:", t);
|
|
@@ -349,8 +354,8 @@ class k extends HTMLElement {
|
|
|
349
354
|
this._sortRule = e, this.renderHeader(), this._options.dataLoader ? this.fetchServerData() : this.refresh();
|
|
350
355
|
}
|
|
351
356
|
setPage(e) {
|
|
352
|
-
const t = Math.max(1, Math.ceil(this._totalRows / this._pageSize)),
|
|
353
|
-
this._currentPage !==
|
|
357
|
+
const t = Math.max(1, Math.ceil(this._totalRows / this._pageSize)), i = Math.max(1, Math.min(e, t));
|
|
358
|
+
this._currentPage !== i && (this._currentPage = i, this._options.dataLoader ? this.fetchServerData() : this.refresh());
|
|
354
359
|
}
|
|
355
360
|
setPageSize(e) {
|
|
356
361
|
this._pageSize !== e && (this._pageSize = e, this._currentPage = 1, this._options.dataLoader ? this.fetchServerData() : this.refresh());
|
|
@@ -362,7 +367,7 @@ class k extends HTMLElement {
|
|
|
362
367
|
const e = this._abortController.signal, t = ++this._requestId;
|
|
363
368
|
this.setLoading(!0);
|
|
364
369
|
try {
|
|
365
|
-
const
|
|
370
|
+
const i = await this._options.dataLoader({
|
|
366
371
|
page: this._currentPage,
|
|
367
372
|
pageSize: this._pageSize,
|
|
368
373
|
searchTerm: this._searchTerm,
|
|
@@ -372,10 +377,10 @@ class k extends HTMLElement {
|
|
|
372
377
|
signal: e
|
|
373
378
|
});
|
|
374
379
|
if (t !== this._requestId || e.aborted) return;
|
|
375
|
-
this._allRows =
|
|
376
|
-
} catch (
|
|
380
|
+
this._allRows = i.rows || [], this._totalRows = i.totalRows || 0, this.renderBodyRows(), this.renderPaginationBar(), this.updateMetaInfo();
|
|
381
|
+
} catch (i) {
|
|
377
382
|
if (e.aborted || t !== this._requestId) return;
|
|
378
|
-
console.error("[advanced-filter-table] Error fetching data:",
|
|
383
|
+
console.error("[advanced-filter-table] Error fetching data:", i);
|
|
379
384
|
} finally {
|
|
380
385
|
t === this._requestId && this.setLoading(!1);
|
|
381
386
|
}
|
|
@@ -431,12 +436,12 @@ class k extends HTMLElement {
|
|
|
431
436
|
setupEventListeners() {
|
|
432
437
|
const e = this._options.debounceMs ?? 300;
|
|
433
438
|
this._searchInput.addEventListener("input", (t) => {
|
|
434
|
-
clearTimeout(this._searchDebounceTimer), this._searchDebounceTimer = setTimeout(() => {
|
|
439
|
+
this._searchDebounceTimer && clearTimeout(this._searchDebounceTimer), this._searchDebounceTimer = setTimeout(() => {
|
|
435
440
|
this.setSearchTerm(t.target.value.trim());
|
|
436
441
|
}, e);
|
|
437
442
|
}), this._presetSelect.addEventListener("change", (t) => {
|
|
438
|
-
const
|
|
439
|
-
|
|
443
|
+
const i = t.target.value;
|
|
444
|
+
i && this.applyPreset(i);
|
|
440
445
|
}), this._toggleBuilderBtn.addEventListener("click", () => {
|
|
441
446
|
this._isBuilderOpen = !this._isBuilderOpen, this._builderDrawer.style.display = this._isBuilderOpen ? "flex" : "none", this._isBuilderOpen && this.renderBuilderDrawer();
|
|
442
447
|
});
|
|
@@ -454,10 +459,10 @@ class k extends HTMLElement {
|
|
|
454
459
|
return;
|
|
455
460
|
}
|
|
456
461
|
this._quickBar.style.display = "flex", this._quickBar.innerHTML = "", e.forEach((t) => {
|
|
457
|
-
const
|
|
458
|
-
|
|
462
|
+
const i = document.createElement("button");
|
|
463
|
+
i.className = "aft-quick-filter-pill", i.textContent = t.label, i.addEventListener("click", () => {
|
|
459
464
|
this.expression = JSON.parse(JSON.stringify(t.expression));
|
|
460
|
-
}), this._quickBar.appendChild(
|
|
465
|
+
}), this._quickBar.appendChild(i);
|
|
461
466
|
});
|
|
462
467
|
}
|
|
463
468
|
renderActiveChips() {
|
|
@@ -466,15 +471,15 @@ class k extends HTMLElement {
|
|
|
466
471
|
this._chipsBar.style.display = "none";
|
|
467
472
|
return;
|
|
468
473
|
}
|
|
469
|
-
this._chipsBar.style.display = "flex", this._chipsBar.innerHTML = "", e.forEach((
|
|
474
|
+
this._chipsBar.style.display = "flex", this._chipsBar.innerHTML = "", e.forEach((i) => {
|
|
470
475
|
const a = document.createElement("span");
|
|
471
476
|
a.className = "aft-chip";
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
this.removeRule(
|
|
477
|
-
}), a.appendChild(
|
|
477
|
+
const s = document.createElement("span");
|
|
478
|
+
s.textContent = S(i, this._columns), a.appendChild(s);
|
|
479
|
+
const r = document.createElement("button");
|
|
480
|
+
r.className = "aft-chip-remove", r.innerHTML = "×", r.title = "Remove filter", r.addEventListener("click", () => {
|
|
481
|
+
this.removeRule(i.id);
|
|
482
|
+
}), a.appendChild(r), this._chipsBar.appendChild(a);
|
|
478
483
|
});
|
|
479
484
|
const t = document.createElement("button");
|
|
480
485
|
t.className = "aft-btn-clear-chips", t.textContent = "Clear all", t.addEventListener("click", () => {
|
|
@@ -482,7 +487,7 @@ class k extends HTMLElement {
|
|
|
482
487
|
}), this._chipsBar.appendChild(t);
|
|
483
488
|
}
|
|
484
489
|
renderBuilderDrawer() {
|
|
485
|
-
var a,
|
|
490
|
+
var a, s, r;
|
|
486
491
|
if (!this._isBuilderOpen) return;
|
|
487
492
|
this._builderDrawer.innerHTML = "";
|
|
488
493
|
const e = document.createElement("div");
|
|
@@ -497,9 +502,9 @@ class k extends HTMLElement {
|
|
|
497
502
|
<div>
|
|
498
503
|
<button class="aft-btn aft-btn-add-rule">+ Add Rule</button>
|
|
499
504
|
</div>
|
|
500
|
-
`, (a = e.querySelector("#btn-logic-and")) == null || a.addEventListener("click", () => this.setLogic("AND")), (
|
|
501
|
-
var
|
|
502
|
-
const n = ((
|
|
505
|
+
`, (a = e.querySelector("#btn-logic-and")) == null || a.addEventListener("click", () => this.setLogic("AND")), (s = e.querySelector("#btn-logic-or")) == null || s.addEventListener("click", () => this.setLogic("OR")), (r = e.querySelector(".aft-btn-add-rule")) == null || r.addEventListener("click", () => {
|
|
506
|
+
var o;
|
|
507
|
+
const n = ((o = this._columns[0]) == null ? void 0 : o.key) || "id";
|
|
503
508
|
this.addRule({
|
|
504
509
|
id: `rule-${Date.now()}`,
|
|
505
510
|
field: n,
|
|
@@ -509,8 +514,8 @@ class k extends HTMLElement {
|
|
|
509
514
|
}), this._builderDrawer.appendChild(e);
|
|
510
515
|
const t = document.createElement("div");
|
|
511
516
|
t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "0.5rem", v(this._activeExpression).forEach((n) => {
|
|
512
|
-
const
|
|
513
|
-
|
|
517
|
+
const o = document.createElement("div");
|
|
518
|
+
o.className = "aft-rule-row";
|
|
514
519
|
const h = document.createElement("select");
|
|
515
520
|
h.className = "aft-rule-select", this._columns.forEach((p) => {
|
|
516
521
|
const m = document.createElement("option");
|
|
@@ -528,7 +533,7 @@ class k extends HTMLElement {
|
|
|
528
533
|
n.field = p.target.value, this.onExpressionChanged();
|
|
529
534
|
}), f.addEventListener("change", (p) => {
|
|
530
535
|
n.operator = p.target.value, this.onExpressionChanged();
|
|
531
|
-
}),
|
|
536
|
+
}), o.appendChild(h), o.appendChild(f), o.appendChild(x), o.appendChild(b), t.appendChild(o);
|
|
532
537
|
}), this._builderDrawer.appendChild(t);
|
|
533
538
|
}
|
|
534
539
|
getOperatorsForColumn(e) {
|
|
@@ -558,16 +563,16 @@ class k extends HTMLElement {
|
|
|
558
563
|
{ value: "endsWith", label: "Ends With" }
|
|
559
564
|
];
|
|
560
565
|
}
|
|
561
|
-
renderRuleValueControl(e, t,
|
|
562
|
-
var
|
|
566
|
+
renderRuleValueControl(e, t, i) {
|
|
567
|
+
var s, r;
|
|
563
568
|
if (t != null && t.cascading) {
|
|
564
|
-
const n = v(this._activeExpression),
|
|
569
|
+
const n = v(this._activeExpression), o = n.find((f) => f.field === t.cascading.parentField), h = t.cascading.getOptions(o == null ? void 0 : o.value, n), u = document.createElement("select");
|
|
565
570
|
u.className = "aft-rule-select", h.forEach((f) => {
|
|
566
571
|
const g = document.createElement("option");
|
|
567
572
|
g.value = String(f.value), g.textContent = f.label, String(f.value) === String(e.value) && (g.selected = !0), u.appendChild(g);
|
|
568
573
|
}), u.addEventListener("change", (f) => {
|
|
569
574
|
e.value = f.target.value, this.onExpressionChanged();
|
|
570
|
-
}),
|
|
575
|
+
}), i.appendChild(u);
|
|
571
576
|
return;
|
|
572
577
|
}
|
|
573
578
|
if (e.operator === "dateRelative") {
|
|
@@ -577,68 +582,68 @@ class k extends HTMLElement {
|
|
|
577
582
|
u.value = h, u.textContent = h, h === e.value && (u.selected = !0), n.appendChild(u);
|
|
578
583
|
}), n.addEventListener("change", (h) => {
|
|
579
584
|
e.value = h.target.value, this.onExpressionChanged();
|
|
580
|
-
}),
|
|
585
|
+
}), i.appendChild(n);
|
|
581
586
|
return;
|
|
582
587
|
}
|
|
583
588
|
if (e.operator === "between") {
|
|
584
589
|
const n = document.createElement("input");
|
|
585
|
-
n.type = "number", n.className = "aft-rule-input", n.placeholder = "Min", n.style.width = "75px", n.value = ((
|
|
586
|
-
const
|
|
587
|
-
|
|
590
|
+
n.type = "number", n.className = "aft-rule-input", n.placeholder = "Min", n.style.width = "75px", n.value = ((s = e.value) == null ? void 0 : s.min) ?? "";
|
|
591
|
+
const o = document.createElement("input");
|
|
592
|
+
o.type = "number", o.className = "aft-rule-input", o.placeholder = "Max", o.style.width = "75px", o.value = ((r = e.value) == null ? void 0 : r.max) ?? "";
|
|
588
593
|
const h = () => {
|
|
589
|
-
e.value = { min: n.value, max:
|
|
594
|
+
e.value = { min: n.value, max: o.value }, this.onExpressionChanged();
|
|
590
595
|
};
|
|
591
|
-
n.addEventListener("change", h),
|
|
596
|
+
n.addEventListener("change", h), o.addEventListener("change", h), i.appendChild(n), i.appendChild(document.createTextNode(" .. ")), i.appendChild(o);
|
|
592
597
|
return;
|
|
593
598
|
}
|
|
594
599
|
const a = document.createElement("input");
|
|
595
600
|
a.type = (t == null ? void 0 : t.type) === "date" ? "date" : (t == null ? void 0 : t.type) === "number" ? "number" : "text", a.className = "aft-rule-input", a.value = e.value !== void 0 ? String(e.value) : "", a.addEventListener("change", (n) => {
|
|
596
601
|
e.value = n.target.value, this.onExpressionChanged();
|
|
597
|
-
}),
|
|
602
|
+
}), i.appendChild(a);
|
|
598
603
|
}
|
|
599
604
|
renderHeader() {
|
|
600
605
|
const e = this._thead.querySelector(".aft-header-tr");
|
|
601
606
|
e && (e.innerHTML = "", this._columns.forEach((t) => {
|
|
602
|
-
var
|
|
603
|
-
const
|
|
604
|
-
|
|
607
|
+
var r, n;
|
|
608
|
+
const i = document.createElement("th");
|
|
609
|
+
i.className = "aft-th", t.width && (i.style.width = t.width), t.minWidth && (i.style.minWidth = t.minWidth), t.align && (i.style.textAlign = t.align);
|
|
605
610
|
const a = document.createElement("div");
|
|
606
611
|
a.className = "aft-th-inner";
|
|
607
|
-
const
|
|
608
|
-
if (
|
|
609
|
-
const
|
|
610
|
-
|
|
612
|
+
const s = document.createElement("span");
|
|
613
|
+
if (s.textContent = t.header, a.appendChild(s), t.sortable !== !1 && ((r = this._options.sorting) == null ? void 0 : r.enabled) !== !1) {
|
|
614
|
+
const o = document.createElement("span");
|
|
615
|
+
o.className = "aft-sort-icon", ((n = this._sortRule) == null ? void 0 : n.column) === t.key ? o.textContent = this._sortRule.direction === "asc" ? "▲" : "▼" : (o.textContent = "↕", o.style.opacity = "0.35"), a.appendChild(o), i.addEventListener("click", () => {
|
|
611
616
|
var u;
|
|
612
617
|
let h = "asc";
|
|
613
618
|
((u = this._sortRule) == null ? void 0 : u.column) === t.key && (h = this._sortRule.direction === "asc" ? "desc" : "asc"), this.setSortRule({ column: t.key, direction: h });
|
|
614
619
|
});
|
|
615
620
|
}
|
|
616
|
-
|
|
621
|
+
i.appendChild(a), e.appendChild(i);
|
|
617
622
|
}));
|
|
618
623
|
}
|
|
619
624
|
getDisplayRows() {
|
|
620
|
-
var t,
|
|
625
|
+
var t, i, a;
|
|
621
626
|
if (this._options.dataLoader)
|
|
622
627
|
return this._allRows;
|
|
623
628
|
let e = [...this._allRows];
|
|
624
629
|
if (this._searchTerm && ((t = this._options.search) == null ? void 0 : t.enabled) !== !1) {
|
|
625
|
-
const
|
|
626
|
-
e = e.filter((
|
|
630
|
+
const s = this._searchTerm.toLowerCase();
|
|
631
|
+
e = e.filter((r) => Object.values(r).some((n) => n != null && String(n).toLowerCase().includes(s)));
|
|
627
632
|
}
|
|
628
|
-
if (e = e.filter((
|
|
629
|
-
const { column:
|
|
630
|
-
e.sort((n,
|
|
631
|
-
const h = n[
|
|
633
|
+
if (e = e.filter((s) => y(s, this._activeExpression, this._options.customOperators)), this._sortRule && ((i = this._options.sorting) == null ? void 0 : i.enabled) !== !1) {
|
|
634
|
+
const { column: s, direction: r } = this._sortRule;
|
|
635
|
+
e.sort((n, o) => {
|
|
636
|
+
const h = n[s], u = o[s];
|
|
632
637
|
if (h === u) return 0;
|
|
633
638
|
if (h == null) return 1;
|
|
634
639
|
if (u == null) return -1;
|
|
635
640
|
const f = h > u ? 1 : -1;
|
|
636
|
-
return
|
|
641
|
+
return r === "asc" ? f : -f;
|
|
637
642
|
});
|
|
638
643
|
}
|
|
639
644
|
if (this._totalRows = e.length, ((a = this._options.pagination) == null ? void 0 : a.enabled) !== !1) {
|
|
640
|
-
const
|
|
641
|
-
return e.slice(
|
|
645
|
+
const s = (this._currentPage - 1) * this._pageSize;
|
|
646
|
+
return e.slice(s, s + this._pageSize);
|
|
642
647
|
}
|
|
643
648
|
return e;
|
|
644
649
|
}
|
|
@@ -649,30 +654,30 @@ class k extends HTMLElement {
|
|
|
649
654
|
this._tbody.innerHTML = "";
|
|
650
655
|
const e = this.getDisplayRows();
|
|
651
656
|
if (e.length === 0) {
|
|
652
|
-
const
|
|
653
|
-
|
|
657
|
+
const i = document.createElement("tr");
|
|
658
|
+
i.className = "aft-tr";
|
|
654
659
|
const a = document.createElement("td");
|
|
655
|
-
a.className = "aft-td", a.colSpan = this._columns.length || 1, a.style.textAlign = "center", a.style.padding = "2.5rem 1rem", a.style.color = "var(--aft-text-muted)", a.textContent = "No matching records found",
|
|
660
|
+
a.className = "aft-td", a.colSpan = this._columns.length || 1, a.style.textAlign = "center", a.style.padding = "2.5rem 1rem", a.style.color = "var(--aft-text-muted)", a.textContent = "No matching records found", i.appendChild(a), this._tbody.appendChild(i);
|
|
656
661
|
return;
|
|
657
662
|
}
|
|
658
663
|
const t = document.createDocumentFragment();
|
|
659
|
-
e.forEach((
|
|
660
|
-
const
|
|
661
|
-
|
|
664
|
+
e.forEach((i, a) => {
|
|
665
|
+
const s = document.createElement("tr");
|
|
666
|
+
s.className = `aft-tr ${a % 2 === 1 ? "alt" : ""}`, this._columns.forEach((r) => {
|
|
662
667
|
const n = document.createElement("td");
|
|
663
|
-
n.className = "aft-td",
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
666
|
-
const h =
|
|
668
|
+
n.className = "aft-td", r.align && (n.style.textAlign = r.align);
|
|
669
|
+
const o = i[r.key];
|
|
670
|
+
if (r.render) {
|
|
671
|
+
const h = r.render(o, i, a);
|
|
667
672
|
h instanceof HTMLElement ? n.appendChild(h) : n.innerHTML = String(h ?? "");
|
|
668
673
|
} else
|
|
669
|
-
n.textContent =
|
|
670
|
-
|
|
671
|
-
}), t.appendChild(
|
|
674
|
+
n.textContent = o != null ? String(o) : "—";
|
|
675
|
+
s.appendChild(n);
|
|
676
|
+
}), t.appendChild(s);
|
|
672
677
|
}), this._tbody.appendChild(t);
|
|
673
678
|
}
|
|
674
679
|
renderPaginationBar() {
|
|
675
|
-
var n,
|
|
680
|
+
var n, o, h, u, f;
|
|
676
681
|
if (((n = this._options.pagination) == null ? void 0 : n.enabled) === !1) {
|
|
677
682
|
this._paginationBar.style.display = "none";
|
|
678
683
|
return;
|
|
@@ -680,14 +685,14 @@ class k extends HTMLElement {
|
|
|
680
685
|
this._paginationBar.style.display = "flex";
|
|
681
686
|
const e = this._totalRows, t = Math.max(1, Math.ceil(e / this._pageSize));
|
|
682
687
|
this._currentPage > t && (this._currentPage = t);
|
|
683
|
-
const
|
|
688
|
+
const i = e === 0 ? 0 : (this._currentPage - 1) * this._pageSize + 1, a = Math.min(this._currentPage * this._pageSize, e), r = (((o = this._options.pagination) == null ? void 0 : o.pageSizeOptions) || [5, 10, 25, 50]).map((g) => `<option value="${g}" ${g === this._pageSize ? "selected" : ""}>${g} / page</option>`).join("");
|
|
684
689
|
this._paginationBar.innerHTML = `
|
|
685
690
|
<div class="aft-pagination-info">
|
|
686
|
-
Showing <strong>${
|
|
691
|
+
Showing <strong>${i}</strong> to <strong>${a}</strong> of <strong>${e}</strong> entries
|
|
687
692
|
</div>
|
|
688
693
|
<div class="aft-pagination-controls">
|
|
689
694
|
<select class="aft-pagination-size-select" aria-label="Page size">
|
|
690
|
-
${
|
|
695
|
+
${r}
|
|
691
696
|
</select>
|
|
692
697
|
<div style="display:flex;align-items:center;gap:0.25rem;">
|
|
693
698
|
<button class="aft-page-btn prev-btn" ${this._currentPage <= 1 ? "disabled" : ""}>Previous</button>
|